From f02ee3044ffe3ec3e3613e79c0c25aa9eeef5c9f Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Fri, 25 Oct 2013 15:54:10 -0700 Subject: mesa: Separate transform feedback object initialization from allocation. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both Gallium and i965 subclass gl_transform_feedback_object, which requires implementing a custom NewTransformFeedback hook. Creating a helper function to initialize the fields avoids code duplication and divergence. Signed-off-by: Kenneth Graunke Reviewed-by: Marek Olšák Reviewed-by: Eric Anholt --- src/mesa/main/transformfeedback.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/mesa/main/transformfeedback.c') diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index bc9b52ab9d1..76d213b16aa 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -205,17 +205,27 @@ _mesa_free_transform_feedback(struct gl_context *ctx) } +/** Initialize the fields of a gl_transform_feedback_object. */ +void +_mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj, + GLuint name) +{ + if (!obj) + return; + + obj->Name = name; + obj->RefCount = 1; + obj->EverBound = GL_FALSE; +} + + /** Default fallback for ctx->Driver.NewTransformFeedback() */ static struct gl_transform_feedback_object * new_transform_feedback(struct gl_context *ctx, GLuint name) { struct gl_transform_feedback_object *obj; obj = CALLOC_STRUCT(gl_transform_feedback_object); - if (obj) { - obj->Name = name; - obj->RefCount = 1; - obj->EverBound = GL_FALSE; - } + _mesa_init_transform_feedback_object(obj, name); return obj; } -- cgit v1.2.3