[Mesa-dev] [PATCH 3/8] mesa: update fixed-func state constants for TCS, TES, GS

Nicolai Hähnle nhaehnle at gmail.com
Thu May 24 08:37:45 UTC 2018


On 23.05.2018 22:58, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> ---
>   src/mesa/main/state.c | 64 ++++++++++++++++++++++++-------------------
>   1 file changed, 36 insertions(+), 28 deletions(-)
> 
> diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
> index be8f3f302c6..097cd9e20d2 100644
> --- a/src/mesa/main/state.c
> +++ b/src/mesa/main/state.c
> @@ -215,55 +215,63 @@ update_program(struct gl_context *ctx)
>          ctx->GeometryProgram._Current != prevGP ||
>          ctx->TessEvalProgram._Current != prevTEP ||
>          ctx->TessCtrlProgram._Current != prevTCP ||
>          ctx->ComputeProgram._Current != prevCP)
>         return _NEW_PROGRAM;
>   
>      return 0;
>   }
>   
>   
> -/**
> - * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
> - */
>   static GLbitfield
> -update_program_constants(struct gl_context *ctx)
> +update_single_program_constants(struct gl_context *ctx,
> +                                struct gl_program *prog,
> +                                gl_shader_stage stage)
>   {
> -   GLbitfield new_state = 0x0;
> -
> -   if (ctx->FragmentProgram._Current) {
> -      const struct gl_program_parameter_list *params =
> -         ctx->FragmentProgram._Current->Parameters;
> +   if (prog) {

It may be slightly better to put this check into the caller to avoid the 
function call overhead. But admittedly that's just a hunch, and it's 
your call.

Apart from that, patches 1-3:

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


> +      const struct gl_program_parameter_list *params = prog->Parameters;
>         if (params && params->StateFlags & ctx->NewState) {
> -         if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT]) {
> -            ctx->NewDriverState |=
> -               ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT];
> -         } else {
> -            new_state |= _NEW_PROGRAM_CONSTANTS;
> -         }
> +         if (ctx->DriverFlags.NewShaderConstants[stage])
> +            ctx->NewDriverState |= ctx->DriverFlags.NewShaderConstants[stage];
> +         else
> +            return _NEW_PROGRAM_CONSTANTS;
>         }
>      }
> +   return 0;
> +}
>   
> -   /* Don't handle tessellation and geometry shaders here. They don't use
> -    * any state constants.
> -    */
>   
> -   if (ctx->VertexProgram._Current) {
> -      const struct gl_program_parameter_list *params =
> -         ctx->VertexProgram._Current->Parameters;
> -      if (params && params->StateFlags & ctx->NewState) {
> -         if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX]) {
> -            ctx->NewDriverState |=
> -               ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX];
> -         } else {
> -            new_state |= _NEW_PROGRAM_CONSTANTS;
> -         }
> +/**
> + * This updates fixed-func state constants such as gl_ModelViewMatrix.
> + * Examine shader constants and return either _NEW_PROGRAM_CONSTANTS or 0.
> + */
> +static GLbitfield
> +update_program_constants(struct gl_context *ctx)
> +{
> +   GLbitfield new_state =
> +      update_single_program_constants(ctx, ctx->VertexProgram._Current,
> +                                      MESA_SHADER_VERTEX) |
> +      update_single_program_constants(ctx, ctx->FragmentProgram._Current,
> +                                      MESA_SHADER_FRAGMENT);
> +
> +   if (ctx->API == API_OPENGL_COMPAT &&
> +       ctx->Const.GLSLVersionCompat >= 150) {
> +      new_state |=
> +         update_single_program_constants(ctx, ctx->GeometryProgram._Current,
> +                                         MESA_SHADER_GEOMETRY);
> +
> +      if (_mesa_has_ARB_tessellation_shader(ctx)) {
> +         new_state |=
> +            update_single_program_constants(ctx, ctx->TessCtrlProgram._Current,
> +                                            MESA_SHADER_TESS_CTRL) |
> +            update_single_program_constants(ctx, ctx->TessEvalProgram._Current,
> +                                            MESA_SHADER_TESS_EVAL);
>         }
>      }
>   
>      return new_state;
>   }
>   
>   
>   /**
>    * Compute derived GL state.
>    * If __struct gl_contextRec::NewState is non-zero then this function \b must
> 


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


More information about the mesa-dev mailing list