On 14 December 2011 13:54, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Wed, Dec 7, 2011 at 8:09 PM, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> This patch adds a new bit to the ctx->NewState bitfield,<br>
> _NEW_TRANSFORM_FEEDBACK, to track state changes that affect<br>
> ctx->TransformFeedback. This bit can be used by driver back-ends to<br>
> avoid expensive recomputations when transform feedback state has not<br>
> been modified.<br>
><br>
> Reviewed-by: Kenneth Graunke <<a href="mailto:kenneth@whitecape.org">kenneth@whitecape.org</a>><br>
> ---<br>
> src/mesa/main/mtypes.h | 1 +<br>
> src/mesa/main/transformfeedback.c | 9 ++++++++-<br>
> 2 files changed, 9 insertions(+), 1 deletions(-)<br>
><br>
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
> index 33b00c6..fc494f7 100644<br>
> --- a/src/mesa/main/mtypes.h<br>
> +++ b/src/mesa/main/mtypes.h<br>
> @@ -3051,6 +3051,7 @@ struct gl_matrix_stack<br>
> #define _NEW_PROGRAM_CONSTANTS (1 << 27)<br>
> #define _NEW_BUFFER_OBJECT (1 << 28)<br>
> #define _NEW_FRAG_CLAMP (1 << 29)<br>
> +#define _NEW_TRANSFORM_FEEDBACK (1 << 30) /**< gl_context::TransformFeedback */<br>
> #define _NEW_ALL ~0<br>
> /*@}*/<br>
><br>
> diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c<br>
> index 11abd03..799245d 100644<br>
> --- a/src/mesa/main/transformfeedback.c<br>
> +++ b/src/mesa/main/transformfeedback.c<br>
> @@ -376,6 +376,7 @@ _mesa_BeginTransformFeedback(GLenum mode)<br>
> return;<br>
> }<br>
><br>
> + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);<br>
> obj->Active = GL_TRUE;<br>
> ctx->TransformFeedback.Mode = mode;<br>
><br>
> @@ -398,6 +399,7 @@ _mesa_EndTransformFeedback(void)<br>
> return;<br>
> }<br>
><br>
> + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);<br>
> ctx->TransformFeedback.CurrentObject->Active = GL_FALSE;<br>
><br>
> assert(ctx->Driver.EndTransformFeedback);<br>
> @@ -415,6 +417,7 @@ bind_buffer_range(struct gl_context *ctx, GLuint index,<br>
> {<br>
> struct gl_transform_feedback_object *obj =<br>
> ctx->TransformFeedback.CurrentObject;<br>
> + FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK);<br>
><br>
> /* The general binding point */<br>
> _mesa_reference_buffer_object(ctx,<br>
<br>
</div></div>Sorry for the late reply.<br>
<br>
There's no need to set _NEW_TRANSFORM_FEEDBACK in bind_buffer_range,<br>
because it's not allowed to change buffer bindings for an active TFB<br>
object. Buffer bindings can only be changed for inactive TFB objects.<br>
And because they're inactive, the drivers don't need to know about it.<br>
The TFB buffers are effectively bound through BeginTransformFeedback<br>
and unbound through EndTransformFeedback (likewise for Resume and<br>
Pause).<br>
<span class="HOEnZb"><font color="#888888"><br>
Marek<br>
</font></span></blockquote></div><br>Ah, you're right. I missed this subtlety. I've already landed this patch, so I'll submit a follow-up patch that replaces the unnecessary calls to FLUSH_VERTICES() with comments explaining why a flush is unnecessary.<br>