[Mesa-dev] [PATCH v2 1/8] mesa: Track changes to transform feedback state.

Marek Olšák maraeo at gmail.com
Wed Dec 14 13:54:48 PST 2011


On Wed, Dec 7, 2011 at 8:09 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> 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.
>
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  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..799245d 100644
> --- a/src/mesa/main/transformfeedback.c
> +++ b/src/mesa/main/transformfeedback.c
> @@ -376,6 +376,7 @@ _mesa_BeginTransformFeedback(GLenum mode)
>       return;
>    }
>
> +   FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
>    obj->Active = GL_TRUE;
>    ctx->TransformFeedback.Mode = mode;
>
> @@ -398,6 +399,7 @@ _mesa_EndTransformFeedback(void)
>       return;
>    }
>
> +   FLUSH_VERTICES(ctx, _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;
> +   FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);
>
>    /* The general binding point */
>    _mesa_reference_buffer_object(ctx,

Sorry for the late reply.

There's no need to set _NEW_TRANSFORM_FEEDBACK in bind_buffer_range,
because it's not allowed to change buffer bindings for an active TFB
object. Buffer bindings can only be changed for inactive TFB objects.
And because they're inactive, the drivers don't need to know about it.
The TFB buffers are effectively bound through BeginTransformFeedback
and unbound through EndTransformFeedback (likewise for Resume and
Pause).

Marek


More information about the mesa-dev mailing list