[Mesa-dev] [PATCH 72/77] glsl: retain buffer block state on cache fallback
Timothy Arceri
timothy.arceri at collabora.com
Mon Oct 3 06:05:31 UTC 2016
---
src/compiler/glsl/linker.cpp | 70 ++++++++++++++++++++++++++++----------------
1 file changed, 45 insertions(+), 25 deletions(-)
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index ac03283..df02198 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -2054,7 +2054,7 @@ link_intrastage_shaders(void *mem_ctx,
struct gl_context *ctx,
struct gl_shader_program *prog,
struct gl_shader **shader_list,
- unsigned num_shaders)
+ unsigned num_shaders, bool is_cache_fallback)
{
struct gl_uniform_block *ubo_blocks = NULL;
struct gl_uniform_block *ssbo_blocks = NULL;
@@ -2186,32 +2186,34 @@ link_intrastage_shaders(void *mem_ctx,
v.run(linked->ir);
v.fixup_unnamed_interface_types();
- /* Link up uniform blocks defined within this stage. */
- link_uniform_blocks(mem_ctx, ctx, prog, linked, &ubo_blocks,
- &num_ubo_blocks, &ssbo_blocks, &num_ssbo_blocks);
+ if (!is_cache_fallback) {
+ /* Link up uniform blocks defined within this stage. */
+ link_uniform_blocks(mem_ctx, ctx, prog, linked, &ubo_blocks,
+ &num_ubo_blocks, &ssbo_blocks, &num_ssbo_blocks);
- if (!prog->LinkStatus) {
- _mesa_delete_linked_shader(ctx, linked);
- return NULL;
- }
-
- /* Copy ubo blocks to linked shader list */
- linked->UniformBlocks =
- ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
- ralloc_steal(linked, ubo_blocks);
- for (unsigned i = 0; i < num_ubo_blocks; i++) {
- linked->UniformBlocks[i] = &ubo_blocks[i];
- }
- linked->NumUniformBlocks = num_ubo_blocks;
+ if (!prog->LinkStatus) {
+ _mesa_delete_linked_shader(ctx, linked);
+ return NULL;
+ }
- /* Copy ssbo blocks to linked shader list */
- linked->ShaderStorageBlocks =
- ralloc_array(linked, gl_uniform_block *, num_ssbo_blocks);
- ralloc_steal(linked, ssbo_blocks);
- for (unsigned i = 0; i < num_ssbo_blocks; i++) {
- linked->ShaderStorageBlocks[i] = &ssbo_blocks[i];
+ /* Copy ubo blocks to linked shader list */
+ linked->UniformBlocks =
+ ralloc_array(linked, gl_uniform_block *, num_ubo_blocks);
+ ralloc_steal(linked, ubo_blocks);
+ for (unsigned i = 0; i < num_ubo_blocks; i++) {
+ linked->UniformBlocks[i] = &ubo_blocks[i];
+ }
+ linked->NumUniformBlocks = num_ubo_blocks;
+
+ /* Copy ssbo blocks to linked shader list */
+ linked->ShaderStorageBlocks =
+ ralloc_array(linked, gl_uniform_block *, num_ssbo_blocks);
+ ralloc_steal(linked, ssbo_blocks);
+ for (unsigned i = 0; i < num_ssbo_blocks; i++) {
+ linked->ShaderStorageBlocks[i] = &ssbo_blocks[i];
+ }
+ linked->NumShaderStorageBlocks = num_ssbo_blocks;
}
- linked->NumShaderStorageBlocks = num_ssbo_blocks;
/* At this point linked should contain all of the linked IR, so
* validate it to make sure nothing went wrong.
@@ -4765,10 +4767,21 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
"type of shader\n");
}
+ gl_uniform_block **ubos[MESA_SHADER_STAGES];
+ gl_uniform_block **ssbos[MESA_SHADER_STAGES];
+ unsigned num_ubos[MESA_SHADER_STAGES];
+ unsigned num_ssbos[MESA_SHADER_STAGES];
for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
if (prog->_LinkedShaders[i] != NULL) {
+ /* Before deleting shader store anything we don't want to lose if we
+ * are here because of a shader cache miss.
+ */
if (is_cache_fallback) {
prog->cache_progs[i] = prog->_LinkedShaders[i]->Program;
+ ubos[i] = prog->_LinkedShaders[i]->UniformBlocks;
+ ssbos[i] = prog->_LinkedShaders[i]->ShaderStorageBlocks;
+ num_ubos[i] = prog->_LinkedShaders[i]->NumUniformBlocks;
+ num_ssbos[i] = prog->_LinkedShaders[i]->NumShaderStorageBlocks;
}
_mesa_delete_linked_shader(ctx, prog->_LinkedShaders[i]);
@@ -4783,7 +4796,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
if (num_shaders[stage] > 0) {
gl_linked_shader *const sh =
link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage],
- num_shaders[stage]);
+ num_shaders[stage], is_cache_fallback);
if (!prog->LinkStatus) {
if (sh)
@@ -4815,6 +4828,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog,
}
prog->_LinkedShaders[stage] = sh;
+ if (is_cache_fallback) {
+ prog->_LinkedShaders[stage]->UniformBlocks = ubos[stage];
+ prog->_LinkedShaders[stage]->ShaderStorageBlocks = ssbos[stage];
+ prog->_LinkedShaders[stage]->NumUniformBlocks = num_ubos[stage];
+ prog->_LinkedShaders[stage]->NumShaderStorageBlocks =
+ num_ssbos[stage];
+ }
}
}
--
2.7.4
More information about the mesa-dev
mailing list