[Mesa-dev] [PATCH 13/27] i965: add image param shader cache support

Jordan Justen jordan.l.justen at intel.com
Sat Aug 19 07:44:29 UTC 2017


From: Timothy Arceri <timothy.arceri at collabora.com>

---
 src/mesa/drivers/dri/i965/brw_disk_cache.c | 31 +++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 1156fc0b8f..4a6f3f340e 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -24,6 +24,7 @@
 #include "compiler/glsl/blob.h"
 #include "compiler/glsl/ir_uniform.h"
 #include "compiler/glsl/shader_cache.h"
+#include "compiler/nir_types.h"
 #include "main/mtypes.h"
 #include "util/disk_cache.h"
 #include "util/macros.h"
@@ -109,13 +110,36 @@ load_program_data(struct gl_program *glprog, 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);
+
+   uint64_t image_params_base = blob_read_uint64(binary);
+
+   /* calculate image bounds */
+   unsigned image_upper_boundary = 0;
+   for (unsigned u = 0; u < glprog->sh.data->NumUniformStorage; u++) {
+      struct gl_uniform_storage *storage = &glprog->sh.data->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++) {
       uint64_t param = blob_read_uint64(binary);
-      ptrdiff_t p_offset, u_offset;
+      ptrdiff_t p_offset, u_offset, i_offset;
       struct gl_program_parameter_list *param_list = glprog->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] =
@@ -123,6 +147,9 @@ load_program_data(struct gl_program *glprog, struct blob_reader *binary,
       } else if (u_offset >= 0 &&
                  u_offset < glprog->sh.data->NumUniformDataSlots) {
          prog_data->param[i] = glprog->sh.data->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;
       }
@@ -396,6 +423,8 @@ write_program_data(struct brw_context *brw, struct gl_program *prog,
    blob_write_uint64(binary, ptr_to_uint64_t(prog->sh.data->UniformDataSlots));
 
    blob_write_uint32(binary, prog_data->nr_params);
+   blob_write_uint32(binary, prog_data->nr_image_params);
+   blob_write_uint64(binary, ptr_to_uint64_t(prog_data->image_param));
 
    for (unsigned i = 0; i < prog_data->nr_params; i++) {
       blob_write_uint64(binary, ptr_to_uint64_t((void *) prog_data->param[i]));
-- 
2.14.0



More information about the mesa-dev mailing list