[Mesa-dev] [PATCH 3/4] meta: Add flag MESA_META_SELECT_FEEDBACK

Brian Paul brianp at vmware.com
Fri Oct 7 16:23:25 PDT 2011


On 10/07/2011 04:55 PM, Chad Versace wrote:
> If this flag is set, then _mesa_meta_begin will save/restore the state of
> GL_SELECT and GL_FEEDBACK render modes.
>
> Intel's futue resolve meta-ops will require this, since buffer resolves
> may occur when the GL_RENDER_MODE is GL_SELECT.
>
> Signed-off-by: Chad Versace<chad at chad-versace.us>
> ---
>   src/mesa/drivers/common/meta.c |   26 ++++++++++++++++++++++++++
>   src/mesa/drivers/common/meta.h |    1 +
>   2 files changed, 27 insertions(+), 0 deletions(-)
>
> diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
> index 5b73dcd..fc25f92 100644
> --- a/src/mesa/drivers/common/meta.c
> +++ b/src/mesa/drivers/common/meta.c
> @@ -172,6 +172,11 @@ struct save_state
>      struct gl_query_object *CondRenderQuery;
>      GLenum CondRenderMode;
>
> +   /** MESA_META_SELECT_FEEDBACK */
> +   GLenum RenderMode;
> +   struct gl_selection Select;
> +   struct gl_feedback Feedback;
> +
>      /** Miscellaneous (always disabled) */
>      GLboolean Lighting;
>   };
> @@ -608,6 +613,17 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
>   	 _mesa_EndConditionalRender();
>      }
>
> +   if (state&  MESA_META_SELECT_FEEDBACK) {
> +      save->RenderMode = ctx->RenderMode;
> +      if (ctx->RenderMode == GL_SELECT) {
> +	 save->Select = ctx->Select; /* struct copy */
> +	 _mesa_RenderMode(GL_RENDER);
> +      } else if (ctx->RenderMode == GL_FEEDBACK) {
> +	 save->Feedback = ctx->Feedback; /* struct copy */
> +	 _mesa_RenderMode(GL_RENDER);
> +      }
> +   }
> +
>      /* misc */
>      {
>         save->Lighting = ctx->Light.Enabled;
> @@ -893,6 +909,16 @@ _mesa_meta_end(struct gl_context *ctx)
>   				      save->CondRenderMode);
>      }
>
> +   if (state&  MESA_META_SELECT_FEEDBACK) {
> +      if (save->RenderMode == GL_SELECT) {
> +	 ctx->Select = save->Select;
> +	 _mesa_RenderMode(GL_SELECT);
> +      } else if (save->RenderMode == GL_FEEDBACK) {
> +	 ctx->Feedback = save->Feedback;
> +	 _mesa_RenderMode(GL_FEEDBACK);
> +      }
> +   }

You might need to switch the order of calling _mesa_RenderMode() and 
assigning the ctx->Feedback/Select state.  That is:

	 _mesa_RenderMode(GL_FEEDBACK);
	 ctx->Feedback = save->Feedback;

I presume that after _mesa_meta_end() is called, we want the 
selection/feedback state to be just as it was before 
_mesa_meta_begin() was called, right?

When _mesa_RenderMode() is called it mucks with various ctx->Select or 
ctx->Feedback fields.  So we need to assign/restore the old 
ctx->Select/Feedback state _after_ that if we want to restore things 
just as they were.

What do you think?

-Brian


More information about the mesa-dev mailing list