summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/linker.cpp
diff options
context:
space:
mode:
authorDave Airlie <[email protected]>2016-05-17 14:44:47 +1000
committerDave Airlie <[email protected]>2016-05-23 16:19:57 +1000
commit6f2dc0d04498a1d03f02a4b72480e8b409981432 (patch)
tree339b4212c25e8e523318fecb423af168056b38ff /src/compiler/glsl/linker.cpp
parent5fe912831cac6722f2cf8add010c553a43e178b4 (diff)
subroutines: handle explicit indexes properly
The code didn't deal with explicit function indexes properly. It also handed out the indexes at link time, when we really need them in the lowering pass to create the correct if ladder. So this patch moves assigning the non-explicit indexes earlier, fixes the lowering pass and the lookups to get the correct values. This fixes a few of: GL45-CTS.explicit_uniform_location.subroutine-index-* Signed-off-by: Dave Airlie <[email protected]>
Diffstat (limited to 'src/compiler/glsl/linker.cpp')
-rw-r--r--src/compiler/glsl/linker.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index a7b2a19a66b..0b8c4943695 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4222,6 +4222,7 @@ link_assign_subroutine_types(struct gl_shader_program *prog)
if (sh == NULL)
continue;
+ sh->MaxSubroutineFunctionIndex = 0;
foreach_in_list(ir_instruction, node, sh->ir) {
ir_function *fn = node->as_function();
if (!fn)
@@ -4233,6 +4234,8 @@ link_assign_subroutine_types(struct gl_shader_program *prog)
if (!fn->num_subroutine_types)
continue;
+ /* these should have been calculated earlier. */
+ assert(fn->subroutine_index != -1);
if (sh->NumSubroutineFunctions + 1 > MAX_SUBROUTINES) {
linker_error(prog, "Too many subroutine functions declared.\n");
return;
@@ -4264,24 +4267,13 @@ link_assign_subroutine_types(struct gl_shader_program *prog)
sh->SubroutineFunctions[sh->NumSubroutineFunctions].index =
fn->subroutine_index;
+ if (fn->subroutine_index > (int)sh->MaxSubroutineFunctionIndex)
+ sh->MaxSubroutineFunctionIndex = fn->subroutine_index;
+
for (int j = 0; j < fn->num_subroutine_types; j++)
sh->SubroutineFunctions[sh->NumSubroutineFunctions].types[j] = fn->subroutine_types[j];
sh->NumSubroutineFunctions++;
}
-
- /* Assign index for subroutines without an explicit index*/
- int index = 0;
- for (unsigned j = 0; j < sh->NumSubroutineFunctions; j++) {
- while (sh->SubroutineFunctions[j].index == -1) {
- for (unsigned k = 0; k < sh->NumSubroutineFunctions; k++) {
- if (sh->SubroutineFunctions[k].index == index)
- break;
- else if (k == sh->NumSubroutineFunctions - 1)
- sh->SubroutineFunctions[j].index = index;
- }
- index++;
- }
- }
}
}