From 1183eb487f65cc8f101578866c404026d6b6dfaa Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Thu, 2 Jun 2016 14:13:26 +1000 Subject: glsl: don't try to load/store buffer object values in the cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add an assert to catch buffer overflows. Reviewed-by: Nicolai Hähnle --- src/compiler/glsl/shader_cache.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/glsl/shader_cache.cpp b/src/compiler/glsl/shader_cache.cpp index 499470b68dc..92417e8eb30 100644 --- a/src/compiler/glsl/shader_cache.cpp +++ b/src/compiler/glsl/shader_cache.cpp @@ -575,6 +575,7 @@ write_uniforms(struct blob *metadata, struct gl_shader_program *prog) blob_write_uint32(metadata, prog->data->UniformStorage[i].offset); blob_write_uint32(metadata, prog->data->UniformStorage[i].array_stride); blob_write_uint32(metadata, prog->data->UniformStorage[i].hidden); + blob_write_uint32(metadata, prog->data->UniformStorage[i].is_shader_storage); blob_write_uint32(metadata, prog->data->UniformStorage[i].matrix_stride); blob_write_uint32(metadata, prog->data->UniformStorage[i].row_major); blob_write_uint32(metadata, @@ -594,7 +595,9 @@ write_uniforms(struct blob *metadata, struct gl_shader_program *prog) */ blob_write_uint32(metadata, prog->data->NumHiddenUniforms); for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) { - if (!prog->data->UniformStorage[i].builtin) { + if (!prog->data->UniformStorage[i].builtin && + !prog->data->UniformStorage[i].is_shader_storage && + prog->data->UniformStorage[i].block_index == -1) { unsigned vec_size = values_for_type(prog->data->UniformStorage[i].type) * MAX2(prog->data->UniformStorage[i].array_elements, 1); @@ -636,6 +639,7 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog) uniforms[i].offset = blob_read_uint32(metadata); uniforms[i].array_stride = blob_read_uint32(metadata); uniforms[i].hidden = blob_read_uint32(metadata); + uniforms[i].is_shader_storage = blob_read_uint32(metadata); uniforms[i].matrix_stride = blob_read_uint32(metadata); uniforms[i].row_major = blob_read_uint32(metadata); uniforms[i].num_compatible_subroutines = blob_read_uint32(metadata); @@ -651,13 +655,18 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog) /* Restore uniform values. */ prog->data->NumHiddenUniforms = blob_read_uint32(metadata); for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) { - if (!prog->data->UniformStorage[i].builtin) { + if (!prog->data->UniformStorage[i].builtin && + !prog->data->UniformStorage[i].is_shader_storage && + prog->data->UniformStorage[i].block_index == -1) { unsigned vec_size = values_for_type(prog->data->UniformStorage[i].type) * MAX2(prog->data->UniformStorage[i].array_elements, 1); blob_copy_bytes(metadata, (uint8_t *) prog->data->UniformStorage[i].storage, sizeof(union gl_constant_value) * vec_size); + + assert(vec_size + prog->data->UniformStorage[i].storage <= + data + prog->data->NumUniformDataSlots); } } } -- cgit v1.2.3