[Mesa-dev] [PATCH 6/8] glsl: always write a name/label string to the cache
Timothy Arceri
tarceri at itsqueeze.com
Sun Aug 13 23:49:05 UTC 2017
In the following patch we will stop writing the pointer to cache.
Unfortunately adding empty strings to that cache seems to be the
only thing we can do here once we no longer have the pointers.
---
src/compiler/glsl/shader_cache.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 26be9e1f88..0e7744bb0b 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1308,24 +1308,23 @@ create_linked_shader_and_program(struct gl_context *ctx,
glprog = ctx->Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage),
prog->Name, false);
glprog->info.stage = stage;
linked->Program = glprog;
read_shader_metadata(metadata, glprog, linked);
/* Restore shader info */
blob_copy_bytes(metadata, (uint8_t *) &glprog->info, sizeof(shader_info));
- if (glprog->info.name)
- glprog->info.name = ralloc_strdup(glprog, blob_read_string(metadata));
- if (glprog->info.label)
- glprog->info.label = ralloc_strdup(glprog, blob_read_string(metadata));
+
+ glprog->info.name = ralloc_strdup(glprog, blob_read_string(metadata));
+ glprog->info.label = ralloc_strdup(glprog, blob_read_string(metadata));
_mesa_reference_shader_program_data(ctx, &glprog->sh.data, prog->data);
_mesa_reference_program(ctx, &linked->Program, glprog);
prog->_LinkedShaders[stage] = linked;
}
void
shader_cache_write_program_metadata(struct gl_context *ctx,
struct gl_shader_program *prog)
{
@@ -1355,23 +1354,27 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh) {
write_shader_metadata(metadata, sh);
/* Store nir shader info */
blob_write_bytes(metadata, &sh->Program->info, sizeof(shader_info));
if (sh->Program->info.name)
blob_write_string(metadata, sh->Program->info.name);
+ else
+ blob_write_string(metadata, "");
if (sh->Program->info.label)
blob_write_string(metadata, sh->Program->info.label);
+ else
+ blob_write_string(metadata, "");
}
}
write_xfb(metadata, prog);
write_uniform_remap_tables(metadata, prog);
write_atomic_buffers(metadata, prog);
write_buffer_blocks(metadata, prog);
--
2.13.4
More information about the mesa-dev
mailing list