diff options
author | Timothy Arceri <[email protected]> | 2017-08-11 13:55:13 +1000 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-09-13 21:52:02 +0100 |
commit | 7fef8d436abbec4f4d88a3a53d0f61063a8a5df0 (patch) | |
tree | ab1b29ac5791d8584304a55b538bf09cabd0c832 /src | |
parent | ea1bcfc0632b9496c5de3597ee393ceaf1b65119 (diff) |
glsl: stop adding pointers from gl_shader_variable 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]>
(cherry picked from commit 37d453b55a7b4c1b10d28dba4acfe12de4634bc8)
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/glsl/shader_cache.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp index 1f17b318800..a63e9742d6a 100644 --- a/src/compiler/glsl/shader_cache.cpp +++ b/src/compiler/glsl/shader_cache.cpp @@ -878,6 +878,18 @@ write_shader_subroutine_index(struct blob *metadata, } static void +get_shader_var_and_pointer_sizes(size_t *s_var_size, size_t *s_var_ptrs, + const gl_shader_variable *var) +{ + *s_var_size = sizeof(gl_shader_variable); + *s_var_ptrs = + sizeof(var->type) + + sizeof(var->interface_type) + + sizeof(var->outermost_struct_type) + + sizeof(var->name); +} + +static void write_program_resource_data(struct blob *metadata, struct gl_shader_program *prog, struct gl_program_resource *res) @@ -888,16 +900,19 @@ write_program_resource_data(struct blob *metadata, case GL_PROGRAM_INPUT: case GL_PROGRAM_OUTPUT: { const gl_shader_variable *var = (gl_shader_variable *)res->Data; - blob_write_bytes(metadata, var, sizeof(gl_shader_variable)); + encode_type_to_blob(metadata, var->type); + encode_type_to_blob(metadata, var->interface_type); + encode_type_to_blob(metadata, var->outermost_struct_type); - if (var->interface_type) - encode_type_to_blob(metadata, var->interface_type); + blob_write_string(metadata, var->name); - if (var->outermost_struct_type) - encode_type_to_blob(metadata, var->outermost_struct_type); + size_t s_var_size, s_var_ptrs; + get_shader_var_and_pointer_sizes(&s_var_size, &s_var_ptrs, var); - blob_write_string(metadata, var->name); + /* Write gl_shader_variable skipping over the pointers */ + blob_write_bytes(metadata, ((char *)var) + s_var_ptrs, + s_var_size - s_var_ptrs); break; } case GL_UNIFORM_BLOCK: @@ -988,16 +1003,17 @@ read_program_resource_data(struct blob_reader *metadata, case GL_PROGRAM_OUTPUT: { gl_shader_variable *var = ralloc(prog, struct gl_shader_variable); - blob_copy_bytes(metadata, (uint8_t *) var, sizeof(gl_shader_variable)); var->type = decode_type_from_blob(metadata); + var->interface_type = decode_type_from_blob(metadata); + var->outermost_struct_type = decode_type_from_blob(metadata); - if (var->interface_type) - var->interface_type = decode_type_from_blob(metadata); + var->name = ralloc_strdup(prog, blob_read_string(metadata)); - if (var->outermost_struct_type) - var->outermost_struct_type = decode_type_from_blob(metadata); + size_t s_var_size, s_var_ptrs; + get_shader_var_and_pointer_sizes(&s_var_size, &s_var_ptrs, var); - var->name = ralloc_strdup(prog, blob_read_string(metadata)); + blob_copy_bytes(metadata, ((uint8_t *) var) + s_var_ptrs, + s_var_size - s_var_ptrs); res->Data = var; break; |