summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_parser_extras.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/glsl_parser_extras.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/glsl_parser_extras.cpp')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 771fd197221..1d0110b0770 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1755,6 +1755,27 @@ set_shader_inout_layout(struct gl_shader *shader,
extern "C" {
+static void
+assign_subroutine_indexes(struct gl_shader *sh,
+ struct _mesa_glsl_parse_state *state)
+{
+ int j, k;
+ int index = 0;
+
+ for (j = 0; j < state->num_subroutines; j++) {
+ while (state->subroutines[j]->subroutine_index == -1) {
+ for (k = 0; k < state->num_subroutines; k++) {
+ if (state->subroutines[k]->subroutine_index == index)
+ break;
+ else if (k == state->num_subroutines - 1) {
+ state->subroutines[j]->subroutine_index = index;
+ }
+ }
+ index++;
+ }
+ }
+}
+
void
_mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
bool dump_ast, bool dump_hir)
@@ -1802,6 +1823,7 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
struct gl_shader_compiler_options *options =
&ctx->Const.ShaderCompilerOptions[shader->Stage];
+ assign_subroutine_indexes(shader, state);
lower_subroutine(shader->ir, state);
/* Do some optimization at compile time to reduce shader IR size
* and reduce later work if the same shader is linked multiple times