summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/shaderapi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main/shaderapi.c')
-rw-r--r--src/mesa/main/shaderapi.c15
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