[Mesa-dev] [PATCH 03/25] mesa: change init subroutine defaults helper to work per gl_program

Lionel Landwerlin lionel.g.landwerlin at intel.com
Wed Jan 11 14:54:27 UTC 2017


Thanks,

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

On 09/01/17 05:13, Timothy Arceri wrote:
> A later patch will result in SSO programs calling this helper
> per gl_program rather than per gl_shader_program.
> ---
>   src/mesa/main/pipelineobj.c | 10 ++++++++--
>   src/mesa/main/shaderapi.c   | 30 ++++++++++--------------------
>   src/mesa/main/shaderapi.h   |  4 ++--
>   3 files changed, 20 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
> index 9651a40..e777f99 100644
> --- a/src/mesa/main/pipelineobj.c
> +++ b/src/mesa/main/pipelineobj.c
> @@ -468,8 +468,14 @@ _mesa_bind_pipeline(struct gl_context *ctx,
>   
>         FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
>   
> -      for (i = 0; i < MESA_SHADER_STAGES; i++)
> -         _mesa_shader_program_init_subroutine_defaults(ctx, ctx->_Shader->CurrentProgram[i]);
> +      for (i = 0; i < MESA_SHADER_STAGES; i++) {
> +         if (ctx->_Shader->CurrentProgram[i]) {
> +            struct gl_linked_shader *sh =
> +               ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i];
> +            if (sh)
> +               _mesa_program_init_subroutine_defaults(ctx, sh->Program);
> +         }
> +      }
>      }
>   }
>   
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 23f8fdd..a7aa544 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -1242,8 +1242,15 @@ use_shader_program(struct gl_context *ctx, gl_shader_stage stage,
>      if ((shProg != NULL) && (shProg->_LinkedShaders[stage] == NULL))
>         shProg = NULL;
>   
> -   if (shProg)
> -      _mesa_shader_program_init_subroutine_defaults(ctx, shProg);
> +   if (shProg) {
> +      for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> +         struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
> +         if (!sh)
> +            continue;
> +
> +         _mesa_program_init_subroutine_defaults(ctx, sh->Program);
> +      }
> +   }
>   
>      if (*target != shProg) {
>         /* Program is current, flush it */
> @@ -2897,7 +2904,7 @@ _mesa_shader_write_subroutine_indices(struct gl_context *ctx,
>                                             ctx->_Shader->CurrentProgram[stage]->_LinkedShaders[stage]->Program);
>   }
>   
> -static void
> +void
>   _mesa_program_init_subroutine_defaults(struct gl_context *ctx,
>                                          struct gl_program *p)
>   {
> @@ -2919,20 +2926,3 @@ _mesa_program_init_subroutine_defaults(struct gl_context *ctx,
>         binding->IndexPtr[i] = find_compat_subroutine(p, uni->type);
>      }
>   }
> -
> -void
> -_mesa_shader_program_init_subroutine_defaults(struct gl_context *ctx,
> -                                              struct gl_shader_program *shProg)
> -{
> -   int i;
> -
> -   if (!shProg)
> -      return;
> -
> -   for (i = 0; i < MESA_SHADER_STAGES; i++) {
> -      if (!shProg->_LinkedShaders[i])
> -         continue;
> -
> -      _mesa_program_init_subroutine_defaults(ctx, shProg->_LinkedShaders[i]->Program);
> -   }
> -}
> diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h
> index 50929f4..06de11f 100644
> --- a/src/mesa/main/shaderapi.h
> +++ b/src/mesa/main/shaderapi.h
> @@ -288,8 +288,8 @@ _mesa_PatchParameterfv(GLenum pname, const GLfloat *values);
>   
>   /* GL_ARB_shader_subroutine */
>   void
> -_mesa_shader_program_init_subroutine_defaults(struct gl_context *ctx,
> -                                              struct gl_shader_program *shProg);
> +_mesa_program_init_subroutine_defaults(struct gl_context *ctx,
> +                                       struct gl_program *prog);
>   
>   extern GLint GLAPIENTRY
>   _mesa_GetSubroutineUniformLocation(GLuint program, GLenum shadertype,




More information about the mesa-dev mailing list