[Mesa-dev] [PATCH 01/10] mesa: Track changes to transform feedback state.

Paul Berry stereotype441 at gmail.com
Mon Dec 5 09:40:44 PST 2011


This patch adds a new bit to the ctx->NewState bitfield,
_NEW_TRANSFORM_FEEDBACK, to track state changes that affect
ctx->TransformFeedback.  This bit can be used by driver back-ends to
avoid expensive recomputations when transform feedback state has not
been modified.
---
 src/mesa/main/mtypes.h            |    1 +
 src/mesa/main/transformfeedback.c |    9 ++++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 33b00c6..fc494f7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3051,6 +3051,7 @@ struct gl_matrix_stack
 #define _NEW_PROGRAM_CONSTANTS (1 << 27)
 #define _NEW_BUFFER_OBJECT     (1 << 28)
 #define _NEW_FRAG_CLAMP        (1 << 29)
+#define _NEW_TRANSFORM_FEEDBACK (1 << 30) /**< gl_context::TransformFeedback */
 #define _NEW_ALL ~0
 /*@}*/
 
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index 11abd03..a1809db 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -376,6 +376,7 @@ _mesa_BeginTransformFeedback(GLenum mode)
       return;
    }
 
+   ctx->NewState |= _NEW_TRANSFORM_FEEDBACK;
    obj->Active = GL_TRUE;
    ctx->TransformFeedback.Mode = mode;
 
@@ -398,6 +399,7 @@ _mesa_EndTransformFeedback(void)
       return;
    }
 
+   ctx->NewState |= _NEW_TRANSFORM_FEEDBACK;
    ctx->TransformFeedback.CurrentObject->Active = GL_FALSE;
 
    assert(ctx->Driver.EndTransformFeedback);
@@ -415,6 +417,7 @@ bind_buffer_range(struct gl_context *ctx, GLuint index,
 {
    struct gl_transform_feedback_object *obj =
       ctx->TransformFeedback.CurrentObject;
+   ctx->NewState |= _NEW_TRANSFORM_FEEDBACK;
 
    /* The general binding point */
    _mesa_reference_buffer_object(ctx,
@@ -650,7 +653,9 @@ _mesa_TransformFeedbackVaryings(GLuint program, GLsizei count,
 
    shProg->TransformFeedback.BufferMode = bufferMode;
 
-   /* The varyings won't be used until shader link time */
+   /* No need to set _NEW_TRANSFORM_FEEDBACK since The varyings won't be used
+    * until shader link time.
+    */
 }
 
 
@@ -874,6 +879,7 @@ _mesa_PauseTransformFeedback(void)
       return;
    }
 
+   ctx->NewState |= _NEW_TRANSFORM_FEEDBACK;
    obj->Paused = GL_TRUE;
 
    assert(ctx->Driver.PauseTransformFeedback);
@@ -899,6 +905,7 @@ _mesa_ResumeTransformFeedback(void)
       return;
    }
 
+   ctx->NewState |= _NEW_TRANSFORM_FEEDBACK;
    obj->Paused = GL_FALSE;
 
    assert(ctx->Driver.ResumeTransformFeedback);
-- 
1.7.6.4



More information about the mesa-dev mailing list