mesa: Separate transform feedback object initialization from allocation.
authorKenneth Graunke <kenneth@whitecape.org>
Fri, 25 Oct 2013 22:54:10 +0000 (15:54 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 31 Oct 2013 18:04:36 +0000 (11:04 -0700)
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 <kenneth@whitecape.org>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/transformfeedback.c
src/mesa/main/transformfeedback.h

index bc9b52ab9d108c765b6bd0db319b22aebdcd72a0..76d213b16aaf4f2984a932154bd057d805c8b99f 100644 (file)
@@ -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;
 }
 
index 0ffaab508019e43f58f6279de58c91c02036ca5e..7aecd66a75a531fbd6149c7c7359c2977b1bb183 100644 (file)
@@ -91,6 +91,9 @@ _mesa_GetTransformFeedbackVarying(GLuint program, GLuint index,
 
 
 /*** GL_ARB_transform_feedback2 ***/
+extern void
+_mesa_init_transform_feedback_object(struct gl_transform_feedback_object *obj,
+                                     GLuint name);
 
 struct gl_transform_feedback_object *
 _mesa_lookup_transform_feedback_object(struct gl_context *ctx, GLuint name);