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

Timothy Arceri timothy.arceri at collabora.com
Mon Oct 3 06:05:32 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 df02198..ecdf7ef 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4767,6 +4767,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];
@@ -4782,6 +4783,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]);
@@ -4834,6 +4837,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