[Mesa-dev] [PATCH 53/65] i965: check memory cache before disk cache

Timothy Arceri timothy.arceri at collabora.com
Fri Apr 29 13:33:52 UTC 2016


---
 src/mesa/drivers/dri/i965/brw_state_upload.c |  4 ----
 src/mesa/drivers/dri/i965/brw_vs.c           | 21 ++++++++++++++++-----
 src/mesa/drivers/dri/i965/brw_wm.c           | 17 ++++++++++++++---
 3 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 556c9d1..ba9e098 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -724,10 +724,6 @@ brw_upload_programs(struct brw_context *brw,
                     enum brw_pipeline pipeline)
 {
    if (pipeline == BRW_RENDER_PIPELINE) {
-#ifdef ENABLE_SHADER_CACHE
-      upload_cached_program(brw);
-#endif
-
       brw_upload_vs_prog(brw);
       brw_upload_tess_programs(brw);
 
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index d16d825..f12545a 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -353,7 +353,6 @@ brw_upload_vs_prog(struct brw_context *brw)
    struct gl_context *ctx = &brw->ctx;
    struct gl_shader_program **current = ctx->_Shader->CurrentProgram;
    struct brw_vs_prog_key key;
-   /* BRW_NEW_VERTEX_PROGRAM */
    struct brw_vertex_program *vp =
       (struct brw_vertex_program *)brw->vertex_program;
 
@@ -365,10 +364,22 @@ brw_upload_vs_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
 			 &key, sizeof(key),
 			 &brw->vs.base.prog_offset, &brw->vs.prog_data)) {
-      bool success = brw_codegen_vs_prog(brw, current[MESA_SHADER_VERTEX],
-                                         vp, &key);
-      (void) success;
-      assert(success);
+#ifdef ENABLE_SHADER_CACHE
+      upload_cached_program(brw);
+
+      /* If upload from disk cache failed call codegen */
+      if (!current[MESA_SHADER_VERTEX] ||
+          !current[MESA_SHADER_VERTEX]->program_written_to_cache) {
+         vp = (struct brw_vertex_program *) brw->vertex_program;
+         vp->id = key.program_string_id;
+#endif
+         bool success = brw_codegen_vs_prog(brw, current[MESA_SHADER_VERTEX],
+                                            vp, &key);
+         (void) success;
+         assert(success);
+#ifdef ENABLE_SHADER_CACHE
+      }
+#endif
    }
    brw->vs.base.prog_data = &brw->vs.prog_data->base.base;
 }
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index daebb48..46e1955 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -575,9 +575,20 @@ brw_upload_wm_prog(struct brw_context *brw)
    if (!brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG,
 			 &key, sizeof(key),
 			 &brw->wm.base.prog_offset, &brw->wm.prog_data)) {
-      bool success = brw_codegen_wm_prog(brw, current, fp, &key);
-      (void) success;
-      assert(success);
+#ifdef ENABLE_SHADER_CACHE
+      upload_cached_program(brw);
+
+      /* If upload from disk cache failed call codegen */
+      if (!current || !current->program_written_to_cache) {
+         fp = (struct brw_fragment_program *) brw->fragment_program;
+         fp->id = key.program_string_id;
+#endif
+         bool success = brw_codegen_wm_prog(brw, current, fp, &key);
+         (void) success;
+         assert(success);
+#ifdef ENABLE_SHADER_CACHE
+      }
+#endif
    }
    brw->wm.base.prog_data = &brw->wm.prog_data->base;
 }
-- 
2.5.5



More information about the mesa-dev mailing list