summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/shader_cache.cpp
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-08-11 15:13:38 +1000
committerTimothy Arceri <[email protected]>2017-08-24 11:18:48 +1000
commita6618afd2740f997cc23bd75de712af6452589a7 (patch)
treed72e9c1c6133a4e610a7ad9e85e9ce6fb028ed75 /src/compiler/glsl/shader_cache.cpp
parent3ea3f757237d977adfb69293654522647d1812b3 (diff)
glsl: stop adding pointers from shader_info to the cache
This is so we always create reproducible cache entries. Consistency is required for verification of any third party distributed shaders. Reviewed-by: Samuel Pitoiset <[email protected]>
Diffstat (limited to 'src/compiler/glsl/shader_cache.cpp')
-rw-r--r--src/compiler/glsl/shader_cache.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp
index 0e7744bb0bd..aa63bdcf012 100644
--- a/src/compiler/glsl/shader_cache.cpp
+++ b/src/compiler/glsl/shader_cache.cpp
@@ -1296,6 +1296,14 @@ create_binding_str(const char *key, unsigned value, void *closure)
}
static void
+get_shader_info_and_pointer_sizes(size_t *s_info_size, size_t *s_info_ptrs,
+ shader_info *info)
+{
+ *s_info_size = sizeof(shader_info);
+ *s_info_ptrs = sizeof(info->name) + sizeof(info->label);
+}
+
+static void
create_linked_shader_and_program(struct gl_context *ctx,
gl_shader_stage stage,
struct gl_shader_program *prog,
@@ -1313,12 +1321,17 @@ create_linked_shader_and_program(struct gl_context *ctx,
read_shader_metadata(metadata, glprog, linked);
- /* Restore shader info */
- blob_copy_bytes(metadata, (uint8_t *) &glprog->info, sizeof(shader_info));
-
glprog->info.name = ralloc_strdup(glprog, blob_read_string(metadata));
glprog->info.label = ralloc_strdup(glprog, blob_read_string(metadata));
+ size_t s_info_size, s_info_ptrs;
+ get_shader_info_and_pointer_sizes(&s_info_size, &s_info_ptrs,
+ &glprog->info);
+
+ /* Restore shader info */
+ blob_copy_bytes(metadata, ((uint8_t *) &glprog->info) + s_info_ptrs,
+ s_info_size - s_info_ptrs);
+
_mesa_reference_shader_program_data(ctx, &glprog->sh.data, prog->data);
_mesa_reference_program(ctx, &linked->Program, glprog);
prog->_LinkedShaders[stage] = linked;
@@ -1356,9 +1369,6 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
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
@@ -1368,6 +1378,15 @@ shader_cache_write_program_metadata(struct gl_context *ctx,
blob_write_string(metadata, sh->Program->info.label);
else
blob_write_string(metadata, "");
+
+ size_t s_info_size, s_info_ptrs;
+ get_shader_info_and_pointer_sizes(&s_info_size, &s_info_ptrs,
+ &sh->Program->info);
+
+ /* Store shader info */
+ blob_write_bytes(metadata,
+ ((char *) &sh->Program->info) + s_info_ptrs,
+ s_info_size - s_info_ptrs);
}
}