diff options
author | Timothy Arceri <[email protected]> | 2017-02-13 09:34:54 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-02-17 11:18:42 +1100 |
commit | e5bb4a0b0f4743fa0a0567991dca751ef49a7200 (patch) | |
tree | 23ac824bb7ecc033145244df6688adbbc1be3f71 /src/mesa/main/shaderapi.c | |
parent | 877194068208a9fb87f7b5513bca85d09be8a20f (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/mesa/main/shaderapi.c')
-rw-r--r-- | src/mesa/main/shaderapi.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 86ce0bc5fdf..0c38cea2555 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -1003,9 +1003,18 @@ shader_source(struct gl_shader *sh, const GLchar *source) { assert(sh); - /* free old shader source string and install new one */ - free((void *)sh->Source); - sh->Source = source; + if (sh->CompileStatus == GL_TRUE && !sh->FallbackSource) { + /* If shader was previously compiled back-up the source in case of cache + * fallback. + */ + sh->FallbackSource = sh->Source; + sh->Source = source; + } else { + /* free old shader source string and install new one */ + free((void *)sh->Source); + sh->Source = source; + } + #ifdef DEBUG sh->SourceChecksum = util_hash_crc32(sh->Source, strlen(sh->Source)); #endif |