[Mesa-dev] [PATCH v3 22/34] i965: Add shader cache support for vertex and fragment stages
Jordan Justen
jordan.l.justen at intel.com
Sun Oct 22 20:01:30 UTC 2017
From: Timothy Arceri <timothy.arceri at collabora.com>
This enables the cache on vertex and fragment shaders only.
v2:
* Use MAYBE_UNUSED. (Matt)
[jordan.l.justen at intel.com: reword subject]
[jordan.l.justen at intel.com: *_cached_program => brw_disk_cache_*_program]
Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
src/mesa/drivers/dri/i965/brw_state_upload.c | 2 ++
src/mesa/drivers/dri/i965/brw_vs.c | 20 +++++++++++++-------
src/mesa/drivers/dri/i965/brw_wm.c | 24 +++++++++++++++---------
3 files changed, 30 insertions(+), 16 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c b/src/mesa/drivers/dri/i965/brw_state_upload.c
index 16f44d03bbe..1ee99648cb8 100644
--- a/src/mesa/drivers/dri/i965/brw_state_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
@@ -442,6 +442,8 @@ brw_upload_programs(struct brw_context *brw,
brw_upload_clip_prog(brw);
brw_upload_sf_prog(brw);
}
+
+ brw_disk_cache_write_program(brw);
} else if (pipeline == BRW_COMPUTE_PIPELINE) {
brw_upload_cs_prog(brw);
}
diff --git a/src/mesa/drivers/dri/i965/brw_vs.c b/src/mesa/drivers/dri/i965/brw_vs.c
index d308bb83332..38948216269 100644
--- a/src/mesa/drivers/dri/i965/brw_vs.c
+++ b/src/mesa/drivers/dri/i965/brw_vs.c
@@ -343,13 +343,19 @@ brw_upload_vs_prog(struct brw_context *brw)
brw_vs_populate_key(brw, &key);
- if (!brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
- &key, sizeof(key),
- &brw->vs.base.prog_offset, &brw->vs.base.prog_data)) {
- bool success = brw_codegen_vs_prog(brw, vp, &key);
- (void) success;
- assert(success);
- }
+ if (brw_search_cache(&brw->cache, BRW_CACHE_VS_PROG,
+ &key, sizeof(key),
+ &brw->vs.base.prog_offset, &brw->vs.base.prog_data))
+ return;
+
+ if (brw_disk_cache_upload_program(brw, MESA_SHADER_VERTEX))
+ return;
+
+ vp = (struct brw_program *) brw->programs[MESA_SHADER_VERTEX];
+ vp->id = key.program_string_id;
+
+ MAYBE_UNUSED bool success = brw_codegen_vs_prog(brw, vp, &key);
+ assert(success);
}
bool
diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c
index 601de18b041..8428847b4c6 100644
--- a/src/mesa/drivers/dri/i965/brw_wm.c
+++ b/src/mesa/drivers/dri/i965/brw_wm.c
@@ -587,15 +587,21 @@ brw_upload_wm_prog(struct brw_context *brw)
brw_wm_populate_key(brw, &key);
- if (!brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG,
- &key, sizeof(key),
- &brw->wm.base.prog_offset,
- &brw->wm.base.prog_data)) {
- bool success = brw_codegen_wm_prog(brw, fp, &key,
- &brw->vue_map_geom_out);
- (void) success;
- assert(success);
- }
+ if (brw_search_cache(&brw->cache, BRW_CACHE_FS_PROG,
+ &key, sizeof(key),
+ &brw->wm.base.prog_offset,
+ &brw->wm.base.prog_data))
+ return;
+
+ if (brw_disk_cache_upload_program(brw, MESA_SHADER_FRAGMENT))
+ return;
+
+ fp = (struct brw_program *) brw->programs[MESA_SHADER_FRAGMENT];
+ fp->id = key.program_string_id;
+
+ MAYBE_UNUSED bool success = brw_codegen_wm_prog(brw, fp, &key,
+ &brw->vue_map_geom_out);
+ assert(success);
}
bool
--
2.15.0.rc0
More information about the mesa-dev
mailing list