[Mesa-dev] [PATCH 86/88] glsl: don't lose sampler or image units when cache falls back

Timothy Arceri timothy.arceri at collabora.com
Sat Sep 24 05:26:07 UTC 2016


The old linked shader is deleted so we need to make sure we hold onto
these values.
---
 src/compiler/glsl/linker.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 3d7e5ae..90af8a8 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4770,6 +4770,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
                    "type of shader\n");
    }
 
+   unsigned char img_units[MAX_IMAGE_UNIFORMS];
    gl_uniform_block **ubos[MESA_SHADER_STAGES];
    gl_uniform_block **ssbos[MESA_SHADER_STAGES];
    unsigned num_ubos[MESA_SHADER_STAGES];
@@ -4785,6 +4786,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
             ssbos[i] = prog->_LinkedShaders[i]->ShaderStorageBlocks;
             num_ubos[i] = prog->_LinkedShaders[i]->NumUniformBlocks;
             num_ssbos[i] = prog->_LinkedShaders[i]->NumShaderStorageBlocks;
+            memcpy(img_units, prog->_LinkedShaders[i]->ImageUnits,
+                   sizeof(img_units));
          }
 
 	 _mesa_delete_linked_shader(ctx, prog->_LinkedShaders[i]);
@@ -4837,6 +4840,11 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
             prog->_LinkedShaders[stage]->NumUniformBlocks = num_ubos[stage];
             prog->_LinkedShaders[stage]->NumShaderStorageBlocks =
                num_ssbos[stage];
+            memcpy(prog->_LinkedShaders[stage]->ImageUnits, img_units,
+                   sizeof(img_units));
+            memcpy(prog->_LinkedShaders[stage]->SamplerUnits,
+                   prog->cache_progs[stage]->SamplerUnits,
+                   sizeof(prog->_LinkedShaders[stage]->SamplerUnits));
          }
       }
    }
-- 
2.7.4



More information about the mesa-dev mailing list