[Mesa-dev] [PATCH 3/3] mesa: optimize _mesa_attr_zero_aliases_vertex()
Marek Olšák
maraeo at gmail.com
Mon Aug 21 21:33:00 UTC 2017
For the series:
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Marek
On Mon, Aug 21, 2017 at 8:56 PM, Brian Paul <brianp at vmware.com> wrote:
> After the context is initialized, the API and context flags won't
> change. So, we can compute whether vertex attribute 0 aliases
> vertex position just once.
>
> This should make the glVertexAttrib*() functions a little quicker.
>
> No Piglit regressions with llvmpipe.
> ---
> src/mesa/main/context.c | 17 +++++++++++++++++
> src/mesa/main/mtypes.h | 3 +++
> src/mesa/main/varray.h | 14 ++------------
> 3 files changed, 22 insertions(+), 12 deletions(-)
>
> diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
> index b4b7b6e..842edf0 100644
> --- a/src/mesa/main/context.c
> +++ b/src/mesa/main/context.c
> @@ -1607,6 +1607,23 @@ handle_first_current(struct gl_context *ctx)
> }
> }
>
> + /* Determine if generic vertex attribute 0 alias the conventional
> + * glVertex position.
> + */
> + {
> + const bool is_forward_compatible_context =
> + ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
> +
> + /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
> + * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
> + * that will erroneously allow this usage in a 3.0 forward-compatible
> + * context too.
> + */
> + ctx->AttribZeroAliasesVertex = (ctx->API == API_OPENGLES
> + || (ctx->API == API_OPENGL_COMPAT
> + && !is_forward_compatible_context));
> + }
> +
> /* We can use this to help debug user's problems. Tell them to set
> * the MESA_INFO env variable before running their app. Then the
> * first time each context is made current we'll print some useful
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 49eb7d5..a8fa045 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -4972,6 +4972,9 @@ struct gl_context
> GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
> GLboolean IntelConservativeRasterization; /**< GL_INTEL_CONSERVATIVE_RASTERIZATION */
>
> + /** Does glVertexAttrib(0) alias glVertex()? */
> + bool AttribZeroAliasesVertex;
> +
> /**
> * \name Hooks for module contexts.
> *
> diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
> index 730f7cf..ba74ae6 100644
> --- a/src/mesa/main/varray.h
> +++ b/src/mesa/main/varray.h
> @@ -73,19 +73,9 @@ _mesa_update_client_array(struct gl_context *ctx,
> }
>
> static inline bool
> -_mesa_attr_zero_aliases_vertex(struct gl_context *ctx)
> +_mesa_attr_zero_aliases_vertex(const struct gl_context *ctx)
> {
> - const bool is_forward_compatible_context =
> - ctx->Const.ContextFlags & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
> -
> - /* In OpenGL 3.1 attribute 0 becomes non-magic, just like in OpenGL ES
> - * 2.0. Note that we cannot just check for API_OPENGL_COMPAT here because
> - * that will erroneously allow this usage in a 3.0 forward-compatible
> - * context too.
> - */
> - return (ctx->API == API_OPENGLES
> - || (ctx->API == API_OPENGL_COMPAT
> - && !is_forward_compatible_context));
> + return ctx->AttribZeroAliasesVertex;
> }
>
> extern void
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list