[Mesa-dev] [PATCH 2/2] mesa: optimize GL_PRIMITIVE_RESTART_NV more

Nicolai Hähnle nhaehnle at gmail.com
Mon Jun 26 09:48:00 UTC 2017


Both patches:

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>


On 26.06.2017 02:49, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> And other client state changes don't have to call
> update_derived_primitive_restart_state.
> ---
>   src/mesa/main/enable.c | 19 +++++++++----------
>   1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
> index 18a288d..2e5fb00 100644
> --- a/src/mesa/main/enable.c
> +++ b/src/mesa/main/enable.c
> @@ -59,21 +59,20 @@ update_derived_primitive_restart_state(struct gl_context *ctx)
>   
>   /**
>    * Helper to enable/disable client-side state.
>    */
>   static void
>   client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
>   {
>      struct gl_vertex_array_object *vao = ctx->Array.VAO;
>      GLbitfield64 flag;
>      GLboolean *var;
> -   uint64_t new_state = _NEW_ARRAY;
>   
>      switch (cap) {
>         case GL_VERTEX_ARRAY:
>            var = &vao->VertexAttrib[VERT_ATTRIB_POS].Enabled;
>            flag = VERT_BIT_POS;
>            break;
>         case GL_NORMAL_ARRAY:
>            var = &vao->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled;
>            flag = VERT_BIT_NORMAL;
>            break;
> @@ -104,41 +103,41 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean state)
>   
>         case GL_POINT_SIZE_ARRAY_OES:
>            var = &vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled;
>            flag = VERT_BIT_POINT_SIZE;
>            FLUSH_VERTICES(ctx, _NEW_PROGRAM);
>            ctx->VertexProgram.PointSizeEnabled = state;
>            break;
>   
>         /* GL_NV_primitive_restart */
>         case GL_PRIMITIVE_RESTART_NV:
> -         if (!ctx->Extensions.NV_primitive_restart) {
> +         if (!ctx->Extensions.NV_primitive_restart)
>               goto invalid_enum_error;
> -         }
> -         var = &ctx->Array.PrimitiveRestart;
> -         flag = 0;
> -         new_state = 0; /* primitive restart is not a vertex array state */
> -         break;
> +         if (ctx->Array.PrimitiveRestart == state)
> +            return;
> +
> +         FLUSH_VERTICES(ctx, 0);
> +         ctx->Array.PrimitiveRestart = state;
> +         update_derived_primitive_restart_state(ctx);
> +         return;
>   
>         default:
>            goto invalid_enum_error;
>      }
>   
>      if (*var == state)
>         return;
>   
> -   FLUSH_VERTICES(ctx, new_state);
> +   FLUSH_VERTICES(ctx, _NEW_ARRAY);
>   
>      *var = state;
>   
> -   update_derived_primitive_restart_state(ctx);
> -
>      if (state)
>         vao->_Enabled |= flag;
>      else
>         vao->_Enabled &= ~flag;
>   
>      vao->NewArrays |= flag;
>   
>      if (ctx->Driver.Enable) {
>         ctx->Driver.Enable( ctx, cap, state );
>      }
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list