--- src/mesa/drivers/dri/i965/brw_shader_cache.c | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c index 751abb1..d37d5e0 100644 --- a/src/mesa/drivers/dri/i965/brw_shader_cache.c +++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c @@ -28,6 +28,7 @@ #include <compiler/glsl/ir_uniform.h> #include <compiler/glsl/cache.h> #include <compiler/glsl/blob.h> +#include <compiler/nir_types.h> #include "brw_state.h" #include "brw_wm.h" @@ -97,20 +98,46 @@ load_program_data(struct gl_shader_program *prog, struct blob_reader *binary, prog_data->nr_params, prog_data->param); } + uint32_t nr_image_params = blob_read_uint32(binary); + assert(nr_image_params == prog_data->nr_image_params); + + prog_data->image_param = rzalloc_array(NULL, struct brw_image_param, + nr_image_params); + + intptr_t image_params_base = blob_read_intptr(binary); + + /* calculate image bounds */ + unsigned image_upper_boundary = 0; + for (unsigned u = 0; u < prog->NumUniformStorage; u++) { + struct gl_uniform_storage *storage = &prog->UniformStorage[u]; + + if (storage->builtin) + continue; + + if (glsl_get_base_type(storage->type) == GLSL_TYPE_IMAGE) { + image_upper_boundary += + BRW_IMAGE_PARAM_SIZE * MAX2(storage->array_elements, 1); + } + } + for (unsigned i = 0; i < nr_params; i++) { intptr_t param = blob_read_intptr(binary); - ptrdiff_t p_offset, u_offset; + ptrdiff_t p_offset, u_offset, i_offset; struct gl_program_parameter_list *param_list = prog->_LinkedShaders[stage]->Program->Parameters; p_offset = (param - parameter_values_base) / sizeof(gl_constant_value); u_offset = (param - uniform_data_slots_base) / sizeof(gl_constant_value); + i_offset = (param - image_params_base) / sizeof(gl_constant_value); if (p_offset >= 0 && p_offset < 4 * param_list->NumParameters) { prog_data->param[i] = ((gl_constant_value *) param_list->ParameterValues) + p_offset; } else if (u_offset >= 0 && u_offset < prog->NumUniformDataSlots) { prog_data->param[i] = prog->UniformDataSlots + u_offset; + } else if (i_offset >= 0 && i_offset < image_upper_boundary) { + prog_data->param[i] = + ((gl_constant_value *) prog_data->image_param) + i_offset; } else { prog_data->param[i] = &zero; } @@ -291,6 +318,8 @@ write_program_data(struct gl_shader_program *prog, struct blob *binary, blob_write_intptr(binary, (intptr_t) prog->UniformDataSlots); blob_write_uint32(binary, prog_data->nr_params); + blob_write_uint32(binary, prog_data->nr_image_params); + blob_write_intptr(binary, (intptr_t) prog_data->image_param); for (unsigned i = 0; i < prog_data->nr_params; i++) { blob_write_intptr(binary, (intptr_t) prog_data->param[i]); -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev