glsl: produce a linker error for a subroutine uniform with no functions.
authorDave Airlie <airlied@redhat.com>
Fri, 6 May 2016 01:37:06 +0000 (11:37 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 23 May 2016 06:19:56 +0000 (16:19 +1000)
If a subroutine uniform is declared with no functions backing it,
that isn't legal, so we should fail to link.

Fixes:
GL43-CTS.shader_subroutine.subroutine_uniform_wo_matching_subroutines

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

index de569453ee4d0674d38ece187cae8f15f45e62c9..ef8db563bb288dca14f91934c76715e98c8715ad 100644 (file)
@@ -3094,6 +3094,10 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
             continue;
 
          count = 0;
+         if (sh->NumSubroutineFunctions == 0) {
+            linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name);
+            continue;
+         }
          for (unsigned f = 0; f < sh->NumSubroutineFunctions; f++) {
             struct gl_subroutine_function *fn = &sh->SubroutineFunctions[f];
             for (int k = 0; k < fn->num_compat_types; k++) {