[Mesa-dev] [PATCH v3 24/34] i965: add shader cache support for tess stages
Jordan Justen
jordan.l.justen at intel.com
Sun Oct 22 20:01:32 UTC 2017
From: Timothy Arceri <timothy.arceri at collabora.com>
v2:
* Use MAYBE_UNUSED. (Matt)
[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_disk_cache.c | 45 ++++++++++++++++++++++++++++++
src/mesa/drivers/dri/i965/brw_tcs.c | 23 +++++++++------
src/mesa/drivers/dri/i965/brw_tes.c | 22 +++++++++------
3 files changed, 74 insertions(+), 16 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index f2a6b8c3e85..4123142a15f 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -30,6 +30,7 @@
#include "util/mesa-sha1.h"
#include "brw_context.h"
+#include "brw_program.h"
#include "brw_gs.h"
#include "brw_state.h"
#include "brw_vs.h"
@@ -128,6 +129,14 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
*/
prog_key.vs.program_string_id = 0;
break;
+ case MESA_SHADER_TESS_CTRL:
+ brw_tcs_populate_key(brw, &prog_key.tcs);
+ prog_key.tcs.program_string_id = 0;
+ break;
+ case MESA_SHADER_TESS_EVAL:
+ brw_tes_populate_key(brw, &prog_key.tes);
+ prog_key.tes.program_string_id = 0;
+ break;
case MESA_SHADER_GEOMETRY:
brw_gs_populate_key(brw, &prog_key.gs);
prog_key.gs.program_string_id = 0;
@@ -204,6 +213,16 @@ read_and_upload(struct brw_context *brw, struct disk_cache *cache,
SET_UPLOAD_PARAMS(vs, VS, vp);
break;
}
+ case MESA_SHADER_TESS_CTRL: {
+ struct brw_program *tcp = (struct brw_program *) prog;
+ SET_UPLOAD_PARAMS(tcs, TCS, tcp);
+ break;
+ }
+ case MESA_SHADER_TESS_EVAL: {
+ struct brw_program *tep = (struct brw_program *) prog;
+ SET_UPLOAD_PARAMS(tes, TES, tep);
+ break;
+ }
case MESA_SHADER_GEOMETRY: {
struct brw_program *gp = (struct brw_program *) prog;
SET_UPLOAD_PARAMS(gs, GS, gp);
@@ -324,6 +343,32 @@ brw_disk_cache_write_program(struct brw_context *brw)
MESA_SHADER_VERTEX);
}
+ prog = brw->ctx._Shader->CurrentProgram[MESA_SHADER_TESS_CTRL];
+ if (prog && !prog->program_written_to_cache) {
+ struct brw_tcs_prog_key tcs_key;
+ brw_tcs_populate_key(brw, &tcs_key);
+ tcs_key.program_string_id = 0;
+
+ write_program_data(brw, prog, &tcs_key, brw->tcs.base.prog_data,
+ brw->tcs.base.prog_data->program_size,
+ sizeof(struct brw_tcs_prog_data),
+ brw->tcs.base.prog_offset, cache,
+ MESA_SHADER_TESS_CTRL);
+ }
+
+ prog = brw->ctx._Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
+ if (prog && !prog->program_written_to_cache) {
+ struct brw_tes_prog_key tes_key;
+ brw_tes_populate_key(brw, &tes_key);
+ tes_key.program_string_id = 0;
+
+ write_program_data(brw, prog, &tes_key, brw->tes.base.prog_data,
+ brw->tes.base.prog_data->program_size,
+ sizeof(struct brw_tes_prog_data),
+ brw->tes.base.prog_offset, cache,
+ MESA_SHADER_TESS_EVAL);
+ }
+
prog = brw->ctx._Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
if (prog && !prog->program_written_to_cache) {
struct brw_gs_prog_key gs_key;
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index 5ac728ee68f..94fafe04f03 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -338,14 +338,21 @@ brw_upload_tcs_prog(struct brw_context *brw)
brw_tcs_populate_key(brw, &key);
- if (!brw_search_cache(&brw->cache, BRW_CACHE_TCS_PROG,
- &key, sizeof(key),
- &stage_state->prog_offset,
- &brw->tcs.base.prog_data)) {
- bool success = brw_codegen_tcs_prog(brw, tcp, tep, &key);
- assert(success);
- (void)success;
- }
+ if (brw_search_cache(&brw->cache, BRW_CACHE_TCS_PROG,
+ &key, sizeof(key),
+ &stage_state->prog_offset,
+ &brw->tcs.base.prog_data))
+ return;
+
+ if (brw_disk_cache_upload_program(brw, MESA_SHADER_TESS_CTRL))
+ return;
+
+ tcp = (struct brw_program *) brw->programs[MESA_SHADER_TESS_CTRL];
+ if (tcp)
+ tcp->id = key.program_string_id;
+
+ MAYBE_UNUSED bool success = brw_codegen_tcs_prog(brw, tcp, tep, &key);
+ assert(success);
}
diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c
index 21f44ae74af..628f26fed2d 100644
--- a/src/mesa/drivers/dri/i965/brw_tes.c
+++ b/src/mesa/drivers/dri/i965/brw_tes.c
@@ -196,14 +196,20 @@ brw_upload_tes_prog(struct brw_context *brw)
brw_tes_populate_key(brw, &key);
- if (!brw_search_cache(&brw->cache, BRW_CACHE_TES_PROG,
- &key, sizeof(key),
- &stage_state->prog_offset,
- &brw->tes.base.prog_data)) {
- bool success = brw_codegen_tes_prog(brw, tep, &key);
- assert(success);
- (void)success;
- }
+ if (brw_search_cache(&brw->cache, BRW_CACHE_TES_PROG,
+ &key, sizeof(key),
+ &stage_state->prog_offset,
+ &brw->tes.base.prog_data))
+ return;
+
+ if (brw_disk_cache_upload_program(brw, MESA_SHADER_TESS_EVAL))
+ return;
+
+ tep = (struct brw_program *) brw->programs[MESA_SHADER_TESS_EVAL];
+ tep->id = key.program_string_id;
+
+ MAYBE_UNUSED bool success = brw_codegen_tes_prog(brw, tep, &key);
+ assert(success);
}
--
2.15.0.rc0
More information about the mesa-dev
mailing list