[Mesa-dev] [PATCH v2 07/17] i965: Add brw_program_serialize_nir

Jordan Justen jordan.l.justen at intel.com
Mon Nov 20 22:27:33 UTC 2017


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
---
 src/mesa/drivers/dri/i965/brw_link.cpp  |  9 ++-------
 src/mesa/drivers/dri/i965/brw_program.c | 12 ++++++++++++
 src/mesa/drivers/dri/i965/brw_program.h |  3 +++
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index d18521e792d..6ac3a79a41e 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -302,13 +302,8 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
       NIR_PASS_V(prog->nir, nir_lower_atomics_to_ssbo,
                  prog->nir->info.num_abos);
 
-      if (brw->ctx.Cache) {
-         struct blob writer;
-         blob_init(&writer);
-         nir_serialize(&writer, prog->nir);
-         prog->driver_cache_blob = ralloc_size(NULL, writer.size);
-         memcpy(prog->driver_cache_blob, writer.data, writer.size);
-         prog->driver_cache_blob_size = writer.size;
+      if (ctx->Cache) {
+         brw_program_serialize_nir(ctx, prog, (gl_shader_stage)stage);
       }
 
       infos[stage] = &prog->nir->info;
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 30cc14e88a2..c8513c947da 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -787,6 +787,18 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
    return next_binding_table_offset;
 }
 
+void
+brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog,
+                          gl_shader_stage stage)
+{
+   struct blob writer;
+   blob_init(&writer);
+   nir_serialize(&writer, prog->nir);
+   prog->driver_cache_blob = ralloc_size(NULL, writer.size);
+   memcpy(prog->driver_cache_blob, writer.data, writer.size);
+   prog->driver_cache_blob_size = writer.size;
+}
+
 void
 brw_program_deserialize_nir(struct gl_context *ctx, struct gl_program *prog,
                             gl_shader_stage stage)
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index bd9b4ad168a..a5e41522841 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -82,6 +82,9 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
                                         uint32_t next_binding_table_offset);
 
 void
+brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog,
+                          gl_shader_stage stage);
+void
 brw_program_deserialize_nir(struct gl_context *ctx, struct gl_program *prog,
                             gl_shader_stage stage);
 
-- 
2.14.1



More information about the mesa-dev mailing list