mesa: change init subroutine defaults helper to work per gl_program
authorTimothy Arceri <timothy.arceri@collabora.com>
Mon, 9 Jan 2017 05:13:28 +0000 (16:13 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Thu, 19 Jan 2017 04:55:02 +0000 (15:55 +1100)
A later patch will result in SSO programs calling this helper
per gl_program rather than per gl_shader_program.

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
src/mesa/main/pipelineobj.c
src/mesa/main/shaderapi.c
src/mesa/main/shaderapi.h

index 9651a40dbb8ed122e6d0d6b4b4b241d79672f713..e777f991589e5670fb390d767cc9bd38208382bc 100644 (file)
@@ -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);
+         }
+      }
    }
 }
 
index 4c67f9564abe0000e636877d270857c893bb7a4a..4ee71dcdcb14dbd34910c9791d00f1e591d4f6b2 100644 (file)
@@ -1221,8 +1221,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 */
@@ -2875,7 +2882,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)
 {
@@ -2897,20 +2904,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);
-   }
-}
index 50929f4483e7d20e1c92cc2c216fe9955b4d0d91..06de11ff766df9d615124a61f69bdc33b6e00bc6 100644 (file)
@@ -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,