diff options
author | Timothy Arceri <[email protected]> | 2017-08-11 13:55:13 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-08-24 11:18:48 +1000 |
commit | 37d453b55a7b4c1b10d28dba4acfe12de4634bc8 (patch) | |
tree | b81f110a9f8f5e666640bf25ec99400ef46ca7a1 /src | |
parent | 37eb67714e0092a5d80ec40d10ca1fe72fa64657 (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]>
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 1fd49b82e98..e004ed4f64d 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; |