[Mesa-dev] [PATCH 02/70] mesa/glsl: move subroutine metadata to gl_program
Eric Anholt
eric at anholt.net
Tue Dec 27 17:29:27 UTC 2016
Timothy Arceri <timothy.arceri at collabora.com> writes:
> This will allow us to store gl_program rather than gl_shader_program
> as the current program perstage which allows us to simplify code
> that makes use of the CurrentProgram list.
> ---
> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
> index 10cee7b..4fe26fd 100644
> --- a/src/mesa/main/shaderapi.c
> +++ b/src/mesa/main/shaderapi.c
> @@ -2853,44 +2863,28 @@ _mesa_shader_write_subroutine_indices(struct gl_context *ctx,
> if (ctx->_Shader->CurrentProgram[stage] &&
> ctx->_Shader->CurrentProgram[stage]->_LinkedShaders[stage])
> _mesa_shader_write_subroutine_index(ctx,
> - ctx->_Shader->CurrentProgram[stage]->_LinkedShaders[stage]);
> + ctx->_Shader->CurrentProgram[stage]->_LinkedShaders[stage]->Program);
> }
>
> -static void
> -_mesa_shader_init_subroutine_defaults(struct gl_context *ctx,
> - struct gl_linked_shader *sh)
> +void
> +_mesa_shader_program_init_subroutine_defaults(struct gl_context *ctx,
> + struct gl_program *p)
> {
> - int i;
> - struct gl_subroutine_index_binding *binding = &ctx->SubroutineIndex[sh->Stage];
> - if (binding->NumIndex != sh->NumSubroutineUniformRemapTable) {
> + assert(p);
> +
> + struct gl_subroutine_index_binding *binding = &ctx->SubroutineIndex[p->info.stage];
> + if (binding->NumIndex != p->sh.NumSubroutineUniformRemapTable) {
> binding->IndexPtr = realloc(binding->IndexPtr,
> - sh->NumSubroutineUniformRemapTable * (sizeof(GLuint)));
> - binding->NumIndex = sh->NumSubroutineUniformRemapTable;
> + p->sh.NumSubroutineUniformRemapTable * (sizeof(GLuint)));
> + binding->NumIndex = p->sh.NumSubroutineUniformRemapTable;
> }
>
> - for (i = 0; i < sh->NumSubroutineUniformRemapTable; i++) {
> - struct gl_uniform_storage *uni = sh->SubroutineUniformRemapTable[i];
> + for (int i = 0; i < p->sh.NumSubroutineUniformRemapTable; i++) {
> + struct gl_uniform_storage *uni = p->sh.SubroutineUniformRemapTable[i];
>
> if (!uni)
> continue;
>
> - binding->IndexPtr[i] = find_compat_subroutine(sh, 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_shader_init_subroutine_defaults(ctx, shProg->_LinkedShaders[i]);
> + binding->IndexPtr[i] = find_compat_subroutine(p, uni->type);
> }
> }
The change in signature of mesa_shader_init_subroutine_defaults() forces
moving its loop out to the callers in this patch. It gets cleaned up a
bit in patch 49, but it doesn't seem to belong here. Also, if it's
taking a program instead of a shader_program, it seems like it should be
called _mesa_program, instead.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161227/06b74d2b/attachment.sig>
More information about the mesa-dev
mailing list