summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shaderapi.c
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/mesa/main/shaderapi.c
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/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 6d58fbb492e..167e06f3d4f 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2546,16 +2546,24 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
}
int uni_count = uni->array_elements ? uni->array_elements : 1;
- int j, k;
+ int j, k, f;
for (j = i; j < i + uni_count; j++) {
- struct gl_subroutine_function *subfn;
- if (indices[j] >= sh->NumSubroutineFunctions) {
+ struct gl_subroutine_function *subfn = NULL;
+ if (indices[j] > sh->MaxSubroutineFunctionIndex) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s", api_name);
return;
}
- subfn = &sh->SubroutineFunctions[indices[j]];
+ for (f = 0; f < sh->NumSubroutineFunctions; f++) {
+ if (sh->SubroutineFunctions[f].index == indices[j])
+ subfn = &sh->SubroutineFunctions[f];
+ }
+
+ if (!subfn) {
+ continue;
+ }
+
for (k = 0; k < subfn->num_compat_types; k++) {
if (subfn->types[k] == uni->type)
break;