summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Justen <jordan.l.justen@intel.com>2018-03-05 23:35:54 -0800
committerJordan Justen <jordan.l.justen@intel.com>2018-03-05 23:40:03 -0800
commit15441e9305b1fca1df236c2283a88db63b72236d (patch)
tree8a05cf907000177cabe80ee53c4f4f56ad570c2b
parent25b642e6563f6546f51b1243535b20115423793c (diff)
i965: Load shader program from disk cache at link timei965-shader-cache-link-upload
Loading the shader at link time may save a small amount of time from loading the program at draw time. When the shader cache is not used, we normally populate the default program at link time, so this also matches that behavior. We skip this step if shader_precompile is set to false. Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
-rw-r--r--src/mesa/drivers/dri/i965/brw_disk_cache.c9
-rw-r--r--src/mesa/drivers/dri/i965/brw_link.cpp13
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.h5
3 files changed, 26 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_disk_cache.c b/src/mesa/drivers/dri/i965/brw_disk_cache.c
index 3478a7f5040..5ec8f808bd0 100644
--- a/src/mesa/drivers/dri/i965/brw_disk_cache.c
+++ b/src/mesa/drivers/dri/i965/brw_disk_cache.c
@@ -307,6 +307,15 @@ brw_disk_cache_upload_program(struct brw_context *brw, gl_shader_stage stage)
return disk_cache_upload_program(brw, sh_prog, prog, stage, false);
}
+bool
+brw_disk_cache_upload_default_program(struct brw_context *brw,
+ struct gl_shader_program *sh_prog,
+ struct gl_program *prog,
+ gl_shader_stage stage)
+{
+ return disk_cache_upload_program(brw, sh_prog, prog, stage, true);
+}
+
static void
write_program_data(struct brw_context *brw, struct gl_program *prog,
void *key, struct brw_stage_prog_data *prog_data,
diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index b08b56a9353..2f43d14935c 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -226,8 +226,19 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
unsigned int stage;
struct shader_info *infos[MESA_SHADER_STAGES] = { 0, };
- if (shProg->data->LinkStatus == LINKING_SKIPPED)
+ if (shProg->data->LinkStatus == LINKING_SKIPPED) {
+ if (brw->precompile) {
+ for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
+ struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
+ if (!shader)
+ continue;
+
+ brw_disk_cache_upload_default_program(brw, shProg, shader->Program,
+ (gl_shader_stage)stage);
+ }
+ }
return GL_TRUE;
+ }
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index eb4fad60389..0e0562a2cb4 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -107,6 +107,11 @@ bool brw_cs_precompile(struct gl_context *ctx, struct gl_program *prog);
GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
+bool brw_disk_cache_upload_default_program(struct brw_context *brw,
+ struct gl_shader_program *sh_prog,
+ struct gl_program *prog,
+ gl_shader_stage stage);
+
void brw_upload_tcs_prog(struct brw_context *brw);
void brw_tcs_populate_key(struct brw_context *brw,
struct brw_tcs_prog_key *key);