diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 7 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.h | 9 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_shader_cache.c | 30 |
3 files changed, 16 insertions, 30 deletions
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index eb230c2e933..c6c63f90a28 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -604,7 +604,7 @@ st_translate_vertex_program(struct st_context *st, return false; } - stvp->state.tokens = ureg_get_tokens(ureg, &stvp->num_tgsi_tokens); + stvp->state.tokens = ureg_get_tokens(ureg, NULL); ureg_destroy(ureg); if (stvp->glsl_to_tgsi) { @@ -1158,7 +1158,7 @@ st_translate_fragment_program(struct st_context *st, fs_output_semantic_name, fs_output_semantic_index); - stfp->state.tokens = ureg_get_tokens(ureg, &stfp->num_tgsi_tokens); + stfp->state.tokens = ureg_get_tokens(ureg, NULL); ureg_destroy(ureg); if (stfp->glsl_to_tgsi) { @@ -1650,7 +1650,7 @@ st_translate_common_program(struct st_context *st, output_semantic_name, output_semantic_index); - stcp->state.tokens = ureg_get_tokens(ureg, &stcp->num_tgsi_tokens); + stcp->state.tokens = ureg_get_tokens(ureg, NULL); ureg_destroy(ureg); @@ -1726,7 +1726,6 @@ st_get_common_variant(struct st_context *st, tgsi_free_tokens(prog->state.tokens); prog->state.tokens = tokens; - prog->num_tgsi_tokens = tgsi_num_tokens(tokens); } tgsi = prog->state; } diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index b591633209d..8c86453ed49 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -177,9 +177,6 @@ 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; }; @@ -267,9 +264,6 @@ 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; }; @@ -320,9 +314,6 @@ 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; }; diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index dd3f25ae2a1..be334eee759 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -31,6 +31,7 @@ #include "compiler/nir/nir_serialize.h" #include "pipe/p_shader_tokens.h" #include "program/ir_to_mesa.h" +#include "tgsi/tgsi_parse.h" #include "util/u_memory.h" void @@ -57,8 +58,10 @@ copy_blob_to_driver_cache_blob(struct blob *blob, struct gl_program *prog) static void write_tgsi_to_cache(struct blob *blob, const struct tgsi_token *tokens, - struct gl_program *prog, unsigned num_tokens) + struct gl_program *prog) { + unsigned num_tokens = tgsi_num_tokens(tokens); + blob_write_uint32(blob, num_tokens); blob_write_bytes(blob, tokens, num_tokens * sizeof(struct tgsi_token)); copy_blob_to_driver_cache_blob(blob, prog); @@ -98,8 +101,7 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog, if (nir) write_nir_to_cache(&blob, prog); else - write_tgsi_to_cache(&blob, stvp->state.tokens, prog, - stvp->num_tgsi_tokens); + write_tgsi_to_cache(&blob, stvp->state.tokens, prog); break; } case MESA_SHADER_TESS_CTRL: @@ -115,8 +117,7 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog, if (nir) write_nir_to_cache(&blob, prog); else - write_tgsi_to_cache(&blob, stcp->state.tokens, prog, - stcp->num_tgsi_tokens); + write_tgsi_to_cache(&blob, stcp->state.tokens, prog); break; } case MESA_SHADER_FRAGMENT: { @@ -125,8 +126,7 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog, if (nir) write_nir_to_cache(&blob, prog); else - write_tgsi_to_cache(&blob, stfp->state.tokens, prog, - stfp->num_tgsi_tokens); + write_tgsi_to_cache(&blob, stfp->state.tokens, prog); break; } default: @@ -171,11 +171,10 @@ read_stream_out_from_cache(struct blob_reader *blob_reader, static void read_tgsi_from_cache(struct blob_reader *blob_reader, - const struct tgsi_token **tokens, - unsigned *num_tokens) + const struct tgsi_token **tokens) { - *num_tokens = blob_read_uint32(blob_reader); - unsigned tokens_size = *num_tokens * sizeof(struct tgsi_token); + unsigned num_tokens = blob_read_uint32(blob_reader); + unsigned tokens_size = num_tokens * sizeof(struct tgsi_token); *tokens = (const struct tgsi_token*) MALLOC(tokens_size); blob_copy_bytes(blob_reader, (uint8_t *) *tokens, tokens_size); } @@ -218,8 +217,7 @@ st_deserialise_ir_program(struct gl_context *ctx, stvp->state.ir.nir = nir_deserialize(NULL, options, &blob_reader); prog->nir = stvp->state.ir.nir; } else { - read_tgsi_from_cache(&blob_reader, &stvp->state.tokens, - &stvp->num_tgsi_tokens); + read_tgsi_from_cache(&blob_reader, &stvp->state.tokens); } if (st->vp == stvp) @@ -245,8 +243,7 @@ st_deserialise_ir_program(struct gl_context *ctx, stcp->shader_program = shProg; prog->nir = stcp->state.ir.nir; } else { - read_tgsi_from_cache(&blob_reader, &stcp->state.tokens, - &stcp->num_tgsi_tokens); + read_tgsi_from_cache(&blob_reader, &stcp->state.tokens); } if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) || @@ -267,8 +264,7 @@ st_deserialise_ir_program(struct gl_context *ctx, stfp->state.ir.nir = nir_deserialize(NULL, options, &blob_reader); prog->nir = stfp->state.ir.nir; } else { - read_tgsi_from_cache(&blob_reader, &stfp->state.tokens, - &stfp->num_tgsi_tokens); + read_tgsi_from_cache(&blob_reader, &stfp->state.tokens); } if (st->fp == stfp) |