[Mesa-dev] [PATCH 51/56] i965: add shader cache support for geometry shaders
Timothy Arceri
timothy.arceri at collabora.com
Tue Nov 29 03:58:50 UTC 2016
---
src/mesa/drivers/dri/i965/brw_gs.c | 15 ++++++++++++---
src/mesa/drivers/dri/i965/brw_shader_cache.c | 25 +++++++++++++++++++++++++
2 files changed, 37 insertions(+), 3 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c
index 84a3cff..c57b100 100644
--- a/src/mesa/drivers/dri/i965/brw_gs.c
+++ b/src/mesa/drivers/dri/i965/brw_gs.c
@@ -242,9 +242,18 @@ brw_upload_gs_prog(struct brw_context *brw)
&key, sizeof(key),
&stage_state->prog_offset,
&brw->gs.base.prog_data)) {
- bool success = brw_codegen_gs_prog(brw, gp, &key);
- assert(success);
- (void)success;
+#ifdef ENABLE_SHADER_CACHE
+ /* If upload from disk cache failed call codegen */
+ if (!upload_cached_program(brw, MESA_SHADER_GEOMETRY)) {
+ gp = (struct brw_program *) brw->geometry_program;
+ gp->id = key.program_string_id;
+#endif
+ bool success = brw_codegen_gs_prog(brw, gp, &key);
+ assert(success);
+ (void)success;
+#ifdef ENABLE_SHADER_CACHE
+ }
+#endif
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_shader_cache.c b/src/mesa/drivers/dri/i965/brw_shader_cache.c
index f64b888..f03809e 100644
--- a/src/mesa/drivers/dri/i965/brw_shader_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_shader_cache.c
@@ -35,6 +35,7 @@
#include "util/string_to_uint_map.h"
#include "brw_context.h"
+#include "brw_gs.h"
#include "brw_state.h"
#include "brw_vs.h"
#include "brw_wm.h"
@@ -305,6 +306,7 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
unsigned char binary_sha1[20];
struct brw_wm_prog_key wm_key;
+ struct brw_gs_prog_key gs_key;
struct brw_vs_prog_key vs_key;
brw_vs_populate_key(brw, &vs_key);
@@ -317,6 +319,11 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
case MESA_SHADER_VERTEX:
gen_shader_sha1(brw, prog, stage, &vs_key, binary_sha1);
break;
+ case MESA_SHADER_GEOMETRY:
+ brw_gs_populate_key(brw, &gs_key);
+ gs_key.program_string_id = 0;
+ gen_shader_sha1(brw, prog, stage, &gs_key, binary_sha1);
+ break;
case MESA_SHADER_FRAGMENT:
brw_wm_populate_key(brw, &wm_key);
wm_key.program_string_id = 0;
@@ -382,6 +389,11 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
SET_UPLOAD_PRAMS(vs, VS, vp)
break;
}
+ case MESA_SHADER_GEOMETRY: {
+ struct brw_program *gp = (struct brw_program *) prog;
+ SET_UPLOAD_PRAMS(gs, GS, gp)
+ break;
+ }
case MESA_SHADER_FRAGMENT: {
struct brw_program *wp = (struct brw_program *) prog;
SET_UPLOAD_PRAMS(wm, FS, wp)
@@ -586,6 +598,19 @@ write_cached_program(struct brw_context *brw)
MESA_SHADER_VERTEX);
}
+ prog = brw->ctx._Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
+ if (prog && !prog->program_written_to_cache) {
+ struct brw_gs_prog_key gs_key;
+ brw_gs_populate_key(brw, &gs_key);
+ gs_key.program_string_id = 0;
+
+ write_program_data(brw, prog, &gs_key, brw->gs.base.prog_data,
+ brw->gs.base.prog_data->program_size,
+ sizeof(struct brw_gs_prog_data),
+ brw->gs.base.prog_offset, cache,
+ MESA_SHADER_GEOMETRY);
+ }
+
prog = brw->ctx._Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
if (prog && !prog->program_written_to_cache) {
struct brw_wm_prog_key wm_key;
--
2.7.4
More information about the mesa-dev
mailing list