From 9f506d817ee38e421d7ff3f32a28808c685f66da Mon Sep 17 00:00:00 2001 From: Timothy Arceri Date: Wed, 1 Feb 2017 15:52:27 +1100 Subject: st/mesa: implement a tgsi on-disk shader cache MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implements a tgsi cache for the OpenGL state tracker. V2: add support for compute shaders Reviewed-by: Nicolai Hähnle --- src/mesa/state_tracker/st_program.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/mesa/state_tracker/st_program.c') diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 3795f25a74e..4d9250b73cc 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -58,6 +58,7 @@ #include "st_mesa_to_tgsi.h" #include "st_atifs_to_tgsi.h" #include "st_nir.h" +#include "st_shader_cache.h" #include "cso_cache/cso_context.h" @@ -364,7 +365,6 @@ st_release_cp_variants(struct st_context *st, struct st_compute_program *stcp) } } - /** * Translate a vertex program. */ @@ -583,7 +583,6 @@ st_translate_vertex_program(struct st_context *st, &stvp->tgsi.stream_output); free_glsl_to_tgsi_visitor(stvp->glsl_to_tgsi); - stvp->glsl_to_tgsi = NULL; } else error = st_translate_mesa_program(st->ctx, PIPE_SHADER_VERTEX, @@ -608,8 +607,15 @@ st_translate_vertex_program(struct st_context *st, return false; } - stvp->tgsi.tokens = ureg_get_tokens(ureg, NULL); + unsigned num_tokens; + stvp->tgsi.tokens = ureg_get_tokens(ureg, &num_tokens); ureg_destroy(ureg); + + if (stvp->glsl_to_tgsi) { + stvp->glsl_to_tgsi = NULL; + st_store_tgsi_in_disk_cache(st, &stvp->Base, NULL, num_tokens); + } + return stvp->tgsi.tokens != NULL; } @@ -1031,7 +1037,6 @@ st_translate_fragment_program(struct st_context *st, fs_output_semantic_index); free_glsl_to_tgsi_visitor(stfp->glsl_to_tgsi); - stfp->glsl_to_tgsi = NULL; } else if (stfp->ati_fs) st_translate_atifs_program(ureg, stfp->ati_fs, @@ -1064,8 +1069,15 @@ st_translate_fragment_program(struct st_context *st, fs_output_semantic_name, fs_output_semantic_index); - stfp->tgsi.tokens = ureg_get_tokens(ureg, NULL); + unsigned num_tokens; + stfp->tgsi.tokens = ureg_get_tokens(ureg, &num_tokens); ureg_destroy(ureg); + + if (stfp->glsl_to_tgsi) { + stfp->glsl_to_tgsi = NULL; + st_store_tgsi_in_disk_cache(st, &stfp->Base, NULL, num_tokens); + } + return stfp->tgsi.tokens != NULL; } @@ -1600,13 +1612,16 @@ st_translate_program_common(struct st_context *st, output_semantic_name, output_semantic_index); - out_state->tokens = ureg_get_tokens(ureg, NULL); + unsigned num_tokens; + out_state->tokens = ureg_get_tokens(ureg, &num_tokens); ureg_destroy(ureg); st_translate_stream_output_info(glsl_to_tgsi, outputMapping, &out_state->stream_output); + st_store_tgsi_in_disk_cache(st, prog, out_state, num_tokens); + if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { _mesa_print_program(prog); debug_printf("\n"); -- cgit v1.2.3