mesa/subroutines: count number subroutines properly.
authorDave Airlie <airlied@redhat.com>
Tue, 17 May 2016 04:22:57 +0000 (14:22 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 23 May 2016 06:19:57 +0000 (16:19 +1000)
The code was implementing the ACTIVE_SUBROUTINE_UNIFORMS
incorrectly, using the number of types not the number of
uniforms. This is different than the locations as the
locations may be sparsly allocated.

This fixes:
GL43-CTS.shader_subroutine.four_subroutines_with_two_uniforms

Reviewed-by: Chris Forbes <chrisforbes@google.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/compiler/glsl/linker.cpp
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c

index 2374c013c1594945db28c500e062ba89fe61b096..a7b2a19a66b09388180dcdc16a36dc097e09a679 100644 (file)
@@ -3096,6 +3096,7 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
          if (!uni)
             continue;
 
+         sh->NumSubroutineUniforms++;
          count = 0;
          if (sh->NumSubroutineFunctions == 0) {
             linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name);
index 569e0acc1ecab72ee87fc117fc72bb8bbeb86c5f..05b205903697d28a94301b96d7c0a707ecb7bba7 100644 (file)
@@ -2436,6 +2436,7 @@ struct gl_shader
      * Subroutine uniform remap table
      * based on the program level uniform remap table.
      */
+   GLuint NumSubroutineUniforms; /* non-sparse total */
    GLuint NumSubroutineUniformRemapTable;
    struct gl_uniform_storage **SubroutineUniformRemapTable;
 
index 47666d83ded3b6451d77aee583909b4768787e07..79097679e90a268d9067614d79882106f3c59ca4 100644 (file)
@@ -2368,7 +2368,7 @@ _mesa_GetActiveSubroutineUniformiv(GLuint program, GLenum shadertype,
       return;
    }
 
-   if (index >= sh->NumSubroutineUniformTypes) {
+   if (index >= sh->NumSubroutineUniforms) {
       _mesa_error(ctx, GL_INVALID_VALUE, "%s: invalid index greater than GL_ACTIVE_SUBROUTINE_UNIFORMS", api_name);
       return;
    }
@@ -2672,7 +2672,7 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype,
       values[0] = sh->NumSubroutineUniformRemapTable;
       break;
    case GL_ACTIVE_SUBROUTINE_UNIFORMS:
-      values[0] = sh->NumSubroutineUniformTypes;
+      values[0] = sh->NumSubroutineUniforms;
       break;
    case GL_ACTIVE_SUBROUTINE_MAX_LENGTH:
    {