summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-02-13 09:34:54 +1100
committerTimothy Arceri <[email protected]>2017-02-17 11:18:42 +1100
commite5bb4a0b0f4743fa0a0567991dca751ef49a7200 (patch)
tree23ac824bb7ecc033145244df6688adbbc1be3f71 /src/compiler
parent877194068208a9fb87f7b5513bca85d09be8a20f (diff)
glsl: use correct shader source in case of cache fallback
The scenario is: glShaderSource glCompileShader <-- deferred due to cache hit of shader glShaderSource <-- with new source code glAttachShader glLinkProgram <-- no cache hit for program At this point we need to compile the original source when we fallback. Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 833b5fefa18..375a99a49da 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -1927,7 +1927,8 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
{
struct _mesa_glsl_parse_state *state =
new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
- const char *source = shader->Source;
+ const char *source = force_recompile && shader->FallbackSource ?
+ shader->FallbackSource : shader->Source;
if (ctx->Const.GenerateTemporaryNames)
(void) p_atomic_cmpxchg(&ir_variable::temporaries_allocate_names,
@@ -1946,6 +1947,9 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
_mesa_sha1_format(buf, shader->sha1));
}
shader->CompileStatus = true;
+
+ free((void *)shader->FallbackSource);
+ shader->FallbackSource = NULL;
return;
}
}
@@ -2067,6 +2071,11 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
_mesa_glsl_initialize_derived_variables(ctx, shader);
+ if (!force_recompile) {
+ free((void *)shader->FallbackSource);
+ shader->FallbackSource = NULL;
+ }
+
delete state->symbols;
ralloc_free(state);
}