[Mesa-dev] [PATCH 75/88] i965: add support for writing tess programs to cache

Timothy Arceri timothy.arceri at collabora.com
Sat Sep 24 05:25:56 UTC 2016


---
 src/mesa/drivers/dri/i965/brw_compiler.h     |  4 ++
 src/mesa/drivers/dri/i965/brw_shader_cache.c | 66 ++++++++++++++++++++++++++++
 src/mesa/drivers/dri/i965/brw_tcs.c          |  2 +
 src/mesa/drivers/dri/i965/brw_tes.c          |  2 +
 4 files changed, 74 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h b/src/mesa/drivers/dri/i965/brw_compiler.h
index e67db0c..17c3b13 100644
--- a/src/mesa/drivers/dri/i965/brw_compiler.h
+++ b/src/mesa/drivers/dri/i965/brw_compiler.h
@@ -656,6 +656,8 @@ struct brw_tcs_prog_data
 
    /** Number vertices in output patch */
    int instances;
+
+   GLuint program_size;
 };
 
 
@@ -666,6 +668,8 @@ struct brw_tes_prog_data
    enum brw_tess_partitioning partitioning;
    enum brw_tess_output_topology output_topology;
    enum brw_tess_domain domain;
+
+   GLuint program_size;
 };
 
 struct brw_gs_prog_data
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index 097e079..00bc1d2 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -761,6 +761,72 @@ write_cached_program(struct brw_context *brw)
       ralloc_free (binary);
    }
 
+   if (prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]) {
+      struct brw_tcs_prog_key tcs_key;
+      unsigned char tcs_sha1[20];
+
+      binary = blob_create (NULL);
+      if (binary == NULL)
+         return;
+
+      blob_write_string(binary, brw->ctx.VersionString);
+
+      gen_tcs_sha1(brw, prog, &tcs_key, tcs_sha1);
+
+      /* Write TCS program to blob. */
+      program_size = brw->tcs.prog_data->program_size;
+
+      blob_write_uint32(binary, program_size);
+
+      blob_cursor = blob_reserve_bytes(binary, program_size);
+      drm_intel_bo_get_subdata(brw->cache.bo, brw->tcs.base.prog_offset,
+                               program_size, blob_cursor);
+
+      /* Write TCS program_data to blob. */
+      blob_write_uint32(binary, sizeof *brw->tcs.prog_data);
+      blob_write_bytes(binary, brw->tcs.prog_data,
+                       sizeof *brw->tcs.prog_data);
+
+      write_program_data(prog, binary, &brw->tcs.prog_data->base.base,
+                         MESA_SHADER_TESS_CTRL);
+
+      cache_binary(brw, binary, cache, tcs_sha1);
+      ralloc_free(binary);
+   }
+
+   if (prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]) {
+      struct brw_tes_prog_key tes_key;
+      unsigned char tes_sha1[20];
+
+      binary = blob_create (NULL);
+      if (binary == NULL)
+         return;
+
+      blob_write_string(binary, brw->ctx.VersionString);
+
+      gen_tes_sha1(brw, prog, &tes_key, tes_sha1);
+
+      /* Write TES program to blob. */
+      program_size = brw->tes.prog_data->program_size;
+
+      blob_write_uint32(binary, program_size);
+
+      blob_cursor = blob_reserve_bytes(binary, program_size);
+      drm_intel_bo_get_subdata(brw->cache.bo, brw->tes.base.prog_offset,
+                               program_size, blob_cursor);
+
+      /* Write TES program_data to blob. */
+      blob_write_uint32(binary, sizeof *brw->tes.prog_data);
+      blob_write_bytes(binary, brw->tes.prog_data,
+                       sizeof *brw->tes.prog_data);
+
+      write_program_data(prog, binary, &brw->tes.prog_data->base.base,
+                         MESA_SHADER_TESS_EVAL);
+
+      cache_binary(brw, binary, cache, tes_sha1);
+      ralloc_free(binary);
+   }
+
    if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY]) {
       struct brw_gs_prog_key gs_key;
       unsigned char gs_sha1[20];
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index 4d6ef29..d5289fb 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -309,6 +309,8 @@ brw_codegen_tcs_prog(struct brw_context *brw,
    if (!tcs)
       ralloc_free(nir);
 
+   brw->tcs.prog_data->program_size = program_size;
+
    return true;
 }
 
diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
index 8ce77d6..41a6f86 100644
--- a/src/mesa/drivers/dri/i965/brw_tes.c
+++ b/src/mesa/drivers/dri/i965/brw_tes.c
@@ -226,6 +226,8 @@ brw_codegen_tes_prog(struct brw_context *brw,
                     &stage_state->prog_offset, &brw->tes.prog_data, tep);
    ralloc_free(mem_ctx);
 
+   brw->tes.prog_data->program_size = program_size;
+
    return true;
 }
 
-- 
2.7.4



More information about the mesa-dev mailing list