[Mesa-dev] [PATCH 77/87] i965: enable cache uploads for tess stages

Timothy Arceri timothy.arceri at collabora.com
Wed Jul 13 02:48:12 UTC 2016


---
 src/mesa/drivers/dri/i965/brw_tcs.c | 22 ++++++++++++++++++----
 src/mesa/drivers/dri/i965/brw_tes.c | 21 +++++++++++++++++----
 2 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index d1a329e..19b36e5 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -376,10 +376,24 @@ brw_upload_tcs_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_CACHE_TCS_PROG,
                          &key, sizeof(key),
                          &stage_state->prog_offset, &brw->tcs.prog_data)) {
-      bool success = brw_codegen_tcs_prog(brw, current[MESA_SHADER_TESS_CTRL],
-                                          tcp, &key);
-      assert(success);
-      (void)success;
+#ifdef ENABLE_SHADER_CACHE
+      upload_cached_program(brw, MESA_SHADER_TESS_CTRL);
+
+      /* If upload from disk cache failed call codegen */
+      if (!current[MESA_SHADER_TESS_CTRL] ||
+          !current[MESA_SHADER_TESS_CTRL]->program_written_to_cache) {
+         tcp = (struct brw_tess_ctrl_program *) brw->tess_ctrl_program;
+         if (tcp)
+            tcp->id = key.program_string_id;
+#endif
+         bool success = brw_codegen_tcs_prog(brw,
+                                             current[MESA_SHADER_TESS_CTRL],
+                                             tcp, &key);
+         assert(success);
+         (void)success;
+#ifdef ENABLE_SHADER_CACHE
+      }
+#endif
    }
    brw->tcs.base.prog_data = &brw->tcs.prog_data->base.base;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
index 485dc3e..8105d31 100644
--- a/src/mesa/drivers/dri/i965/brw_tes.c
+++ b/src/mesa/drivers/dri/i965/brw_tes.c
@@ -288,10 +288,23 @@ brw_upload_tes_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_CACHE_TES_PROG,
                          &key, sizeof(key),
                          &stage_state->prog_offset, &brw->tes.prog_data)) {
-      bool success = brw_codegen_tes_prog(brw, current[MESA_SHADER_TESS_EVAL],
-                                          tep, &key);
-      assert(success);
-      (void)success;
+#ifdef ENABLE_SHADER_CACHE
+      upload_cached_program(brw, MESA_SHADER_TESS_EVAL);
+
+      /* If upload from disk cache failed call codegen */
+      if (!current[MESA_SHADER_TESS_EVAL] ||
+          !current[MESA_SHADER_TESS_EVAL]->program_written_to_cache) {
+         tep = (struct brw_tess_eval_program *) brw->tess_eval_program;
+         tep->id = key.program_string_id;
+#endif
+         bool success = brw_codegen_tes_prog(brw,
+                                             current[MESA_SHADER_TESS_EVAL],
+                                             tep, &key);
+         assert(success);
+         (void)success;
+#ifdef ENABLE_SHADER_CACHE
+      }
+#endif
    }
    brw->tes.base.prog_data = &brw->tes.prog_data->base.base;
 }
-- 
2.7.4



More information about the mesa-dev mailing list