[Mesa-dev] [PATCH 06/25] mesa: update active relinked program

Timothy Arceri timothy.arceri at collabora.com
Mon Jan 9 05:13:31 UTC 2017


This likely fixes a subroutine bug were
_mesa_shader_program_init_subroutine_defaults() would never have been
called for the relinked program as we previously just set
_NEW_PROGRAM as dirty and never called the _mesa_use* functions.

We also switch to using gl_program for the CurrentProgram array so
this change will need to be sqashed with the previous two.
---
 src/mesa/main/shaderapi.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 9fa8ce1..f03c47d 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1098,7 +1098,8 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
    unsigned programs_in_use = 0;
    if (ctx->_Shader)
       for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
-         if (ctx->_Shader->CurrentProgram[stage] == shProg) {
+         if (ctx->_Shader->CurrentProgram[stage] &&
+             ctx->_Shader->CurrentProgram[stage]->Id == shProg->Name) {
             programs_in_use |= 1 << stage;
          }
    }
@@ -1117,7 +1118,15 @@ _mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg)
     *     is attached."
     */
    if (shProg->data->LinkStatus && programs_in_use) {
-      ctx->NewState |= _NEW_PROGRAM;
+      while (programs_in_use) {
+         const int stage = u_bit_scan(&programs_in_use);
+
+         struct gl_program *prog = NULL;
+         if (shProg->_LinkedShaders[stage])
+            prog = shProg->_LinkedShaders[stage]->Program;
+
+         _mesa_use_program(ctx, stage, prog, ctx->_Shader);
+      }
    }
 
    /* Capture .shader_test files. */
-- 
2.9.3



More information about the mesa-dev mailing list