From 15441e9305b1fca1df236c2283a88db63b72236d Mon Sep 17 00:00:00 2001 From: Jordan Justen Date: Mon, 5 Mar 2018 23:35:54 -0800 Subject: i965: Load shader program from disk cache at link time 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 --- src/mesa/drivers/dri/i965/brw_disk_cache.c | 9 +++++++++ src/mesa/drivers/dri/i965/brw_link.cpp | 13 ++++++++++++- src/mesa/drivers/dri/i965/brw_program.h | 5 +++++ 3 files changed, 26 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3