From: Timothy Arceri Date: Tue, 28 Nov 2017 10:43:12 +0000 (+1100) Subject: st/glsl_to_tgsi: store num_tgsi_tokens in st_*_program X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c69b0dd6817b3321d0d9ccfd1c3d44b44277c736;p=mesa.git st/glsl_to_tgsi: store num_tgsi_tokens in st_*_program We will need this for ARB_get_program_binary binary support. Tested-by: Dieter Nützel Reviewed-by: Nicolai Hähnle --- diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 05e6042f425..9f8bf5f76fd 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -534,13 +534,12 @@ st_translate_vertex_program(struct st_context *st, return false; } - unsigned num_tokens; - stvp->tgsi.tokens = ureg_get_tokens(ureg, &num_tokens); + stvp->tgsi.tokens = ureg_get_tokens(ureg, &stvp->num_tgsi_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); + st_store_tgsi_in_disk_cache(st, &stvp->Base, NULL); } return stvp->tgsi.tokens != NULL; @@ -992,13 +991,12 @@ st_translate_fragment_program(struct st_context *st, fs_output_semantic_name, fs_output_semantic_index); - unsigned num_tokens; - stfp->tgsi.tokens = ureg_get_tokens(ureg, &num_tokens); + stfp->tgsi.tokens = ureg_get_tokens(ureg, &stfp->num_tgsi_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); + st_store_tgsi_in_disk_cache(st, &stfp->Base, NULL); } return stfp->tgsi.tokens != NULL; @@ -1400,15 +1398,20 @@ st_translate_program_common(struct st_context *st, output_semantic_name, output_semantic_index); - unsigned num_tokens; - out_state->tokens = ureg_get_tokens(ureg, &num_tokens); + if (tgsi_processor == PIPE_SHADER_COMPUTE) { + struct st_compute_program *stcp = (struct st_compute_program *) prog; + out_state->tokens = ureg_get_tokens(ureg, &stcp->num_tgsi_tokens); + } else { + struct st_common_program *stcp = (struct st_common_program *) prog; + out_state->tokens = ureg_get_tokens(ureg, &stcp->num_tgsi_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); + st_store_tgsi_in_disk_cache(st, prog, out_state); if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { _mesa_print_program(prog); diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 0e6c8e00c6e..a520ffbecb4 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -150,6 +150,9 @@ struct st_fragment_program struct gl_shader_program *shader_program; struct st_fp_variant *variants; + + /* Used by the shader cache and ARB_get_program_binary */ + unsigned num_tgsi_tokens; }; @@ -222,6 +225,9 @@ struct st_vertex_program /** SHA1 hash of linked tgsi shader program, used for on-disk cache */ unsigned char sha1[20]; + + /* Used by the shader cache and ARB_get_program_binary */ + unsigned num_tgsi_tokens; }; @@ -264,6 +270,9 @@ struct st_common_program /** SHA1 hash of linked tgsi shader program, used for on-disk cache */ unsigned char sha1[20]; + + /* Used by the shader cache and ARB_get_program_binary */ + unsigned num_tgsi_tokens; }; @@ -284,6 +293,9 @@ struct st_compute_program /** SHA1 hash of linked tgsi shader program, used for on-disk cache */ unsigned char sha1[20]; + + /* Used by the shader cache and ARB_get_program_binary */ + unsigned num_tgsi_tokens; }; diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index a5e33133b3c..a9413fb0534 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -56,8 +56,7 @@ write_tgsi_to_cache(struct blob *blob, struct pipe_shader_state *tgsi, */ void st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog, - struct pipe_shader_state *out_state, - unsigned num_tokens) + struct pipe_shader_state *out_state) { if (!st->ctx->Cache) return; @@ -83,24 +82,28 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog, sizeof(stvp->result_to_output)); write_stream_out_to_cache(&blob, &stvp->tgsi); - write_tgsi_to_cache(&blob, &stvp->tgsi, prog, num_tokens); + write_tgsi_to_cache(&blob, &stvp->tgsi, prog, stvp->num_tgsi_tokens); break; } case MESA_SHADER_TESS_CTRL: case MESA_SHADER_TESS_EVAL: case MESA_SHADER_GEOMETRY: { + struct st_common_program *stcp = (struct st_common_program *) prog; + write_stream_out_to_cache(&blob, out_state); - write_tgsi_to_cache(&blob, out_state, prog, num_tokens); + write_tgsi_to_cache(&blob, out_state, prog, stcp->num_tgsi_tokens); break; } case MESA_SHADER_FRAGMENT: { struct st_fragment_program *stfp = (struct st_fragment_program *) prog; - write_tgsi_to_cache(&blob, &stfp->tgsi, prog, num_tokens); + write_tgsi_to_cache(&blob, &stfp->tgsi, prog, stfp->num_tgsi_tokens); break; } case MESA_SHADER_COMPUTE: { - write_tgsi_to_cache(&blob, out_state, prog, num_tokens); + struct st_compute_program *stcp = (struct st_compute_program *) prog; + + write_tgsi_to_cache(&blob, out_state, prog, stcp->num_tgsi_tokens); break; } default: diff --git a/src/mesa/state_tracker/st_shader_cache.h b/src/mesa/state_tracker/st_shader_cache.h index 090d7d85cc8..7644d437521 100644 --- a/src/mesa/state_tracker/st_shader_cache.h +++ b/src/mesa/state_tracker/st_shader_cache.h @@ -38,8 +38,7 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx, void st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog, - struct pipe_shader_state *out_state, - unsigned num_tokens); + struct pipe_shader_state *out_state); #ifdef __cplusplus }