mesa/st: Remove now unused TGSI paths from disk cache.
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8044>
This commit is contained in:
parent
8dc99300d6
commit
7221cc7657
|
@ -42,7 +42,7 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
struct pipe_screen *pscreen = sctx->screen;
|
||||
|
||||
/* Return early if we are loading the shader from on-disk cache */
|
||||
if (st_load_ir_from_disk_cache(ctx, prog, true)) {
|
||||
if (st_load_nir_from_disk_cache(ctx, prog)) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -933,7 +933,7 @@ st_link_nir(struct gl_context *ctx,
|
|||
shader->Stage == MESA_SHADER_GEOMETRY)
|
||||
st_translate_stream_output_info(prog);
|
||||
|
||||
st_store_ir_in_disk_cache(st, prog, true);
|
||||
st_store_nir_in_disk_cache(st, prog);
|
||||
|
||||
st_release_variants(st, prog);
|
||||
st_finalize_program(st, prog);
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include "compiler/nir/nir_serialize.h"
|
||||
#include "main/uniforms.h"
|
||||
#include "pipe/p_shader_tokens.h"
|
||||
#include "tgsi/tgsi_parse.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
void
|
||||
|
@ -61,17 +60,6 @@ copy_blob_to_driver_cache_blob(struct blob *blob, struct gl_program *prog)
|
|||
prog->driver_cache_blob_size = blob->size;
|
||||
}
|
||||
|
||||
static void
|
||||
write_tgsi_to_cache(struct blob *blob, const struct tgsi_token *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);
|
||||
}
|
||||
|
||||
static void
|
||||
write_nir_to_cache(struct blob *blob, struct gl_program *prog)
|
||||
{
|
||||
|
@ -83,9 +71,8 @@ write_nir_to_cache(struct blob *blob, struct gl_program *prog)
|
|||
copy_blob_to_driver_cache_blob(blob, prog);
|
||||
}
|
||||
|
||||
static void
|
||||
st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
|
||||
bool nir)
|
||||
void
|
||||
st_serialise_nir_program(struct gl_context *ctx, struct gl_program *prog)
|
||||
{
|
||||
if (prog->driver_cache_blob)
|
||||
return;
|
||||
|
@ -107,20 +94,16 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
|
|||
prog->info.stage == MESA_SHADER_GEOMETRY)
|
||||
write_stream_out_to_cache(&blob, &prog->state);
|
||||
|
||||
if (nir)
|
||||
write_nir_to_cache(&blob, prog);
|
||||
else
|
||||
write_tgsi_to_cache(&blob, prog->state.tokens, prog);
|
||||
|
||||
blob_finish(&blob);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store TGSI or NIR and any other required state in on-disk shader cache.
|
||||
* Store NIR and any other required state in on-disk shader cache.
|
||||
*/
|
||||
void
|
||||
st_store_ir_in_disk_cache(struct st_context *st, struct gl_program *prog,
|
||||
bool nir)
|
||||
st_store_nir_in_disk_cache(struct st_context *st, struct gl_program *prog)
|
||||
{
|
||||
if (!st->ctx->Cache)
|
||||
return;
|
||||
|
@ -132,7 +115,7 @@ st_store_ir_in_disk_cache(struct st_context *st, struct gl_program *prog,
|
|||
if (memcmp(prog->sh.data->sha1, zero, sizeof(prog->sh.data->sha1)) == 0)
|
||||
return;
|
||||
|
||||
st_serialise_ir_program(st->ctx, prog, nir);
|
||||
st_serialise_nir_program(st->ctx, prog);
|
||||
|
||||
if (st->ctx->_Shader->Flags & GLSL_CACHE_INFO) {
|
||||
fprintf(stderr, "putting %s state tracker IR in cache\n",
|
||||
|
@ -154,20 +137,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 = 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);
|
||||
}
|
||||
|
||||
static void
|
||||
st_deserialise_ir_program(struct gl_context *ctx,
|
||||
void
|
||||
st_deserialise_nir_program(struct gl_context *ctx,
|
||||
struct gl_shader_program *shProg,
|
||||
struct gl_program *prog, bool nir)
|
||||
struct gl_program *prog)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
size_t size = prog->driver_cache_blob_size;
|
||||
|
@ -201,7 +174,6 @@ st_deserialise_ir_program(struct gl_context *ctx,
|
|||
prog->info.stage == MESA_SHADER_GEOMETRY)
|
||||
read_stream_out_from_cache(&blob_reader, &prog->state);
|
||||
|
||||
if (nir) {
|
||||
assert(prog->nir == NULL);
|
||||
assert(prog->serialized_nir == NULL);
|
||||
|
||||
|
@ -210,20 +182,17 @@ st_deserialise_ir_program(struct gl_context *ctx,
|
|||
prog->serialized_nir = malloc(prog->serialized_nir_size);
|
||||
blob_copy_bytes(&blob_reader, prog->serialized_nir, prog->serialized_nir_size);
|
||||
prog->shader_program = shProg;
|
||||
} else {
|
||||
read_tgsi_from_cache(&blob_reader, &prog->state.tokens);
|
||||
}
|
||||
|
||||
/* Make sure we don't try to read more data than we wrote. This should
|
||||
* never happen in release builds but its useful to have this check to
|
||||
* catch development bugs.
|
||||
*/
|
||||
if (blob_reader.current != blob_reader.end || blob_reader.overrun) {
|
||||
assert(!"Invalid TGSI shader disk cache item!");
|
||||
assert(!"Invalid shader disk cache item!");
|
||||
|
||||
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
|
||||
fprintf(stderr, "Error reading program from cache (invalid "
|
||||
"TGSI cache item)\n");
|
||||
"cache item)\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -231,15 +200,14 @@ st_deserialise_ir_program(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
bool
|
||||
st_load_ir_from_disk_cache(struct gl_context *ctx,
|
||||
struct gl_shader_program *prog,
|
||||
bool nir)
|
||||
st_load_nir_from_disk_cache(struct gl_context *ctx,
|
||||
struct gl_shader_program *prog)
|
||||
{
|
||||
if (!ctx->Cache)
|
||||
return false;
|
||||
|
||||
/* If we didn't load the GLSL metadata from cache then we could not have
|
||||
* loaded TGSI or NIR either.
|
||||
* loaded the NIR either.
|
||||
*/
|
||||
if (prog->data->LinkStatus != LINKING_SKIPPED)
|
||||
return false;
|
||||
|
@ -249,7 +217,7 @@ st_load_ir_from_disk_cache(struct gl_context *ctx,
|
|||
continue;
|
||||
|
||||
struct gl_program *glprog = prog->_LinkedShaders[i]->Program;
|
||||
st_deserialise_ir_program(ctx, prog, glprog, nir);
|
||||
st_deserialise_nir_program(ctx, prog, glprog);
|
||||
|
||||
/* We don't need the cached blob anymore so free it */
|
||||
ralloc_free(glprog->driver_cache_blob);
|
||||
|
@ -265,46 +233,10 @@ st_load_ir_from_disk_cache(struct gl_context *ctx,
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
st_serialise_tgsi_program(struct gl_context *ctx, struct gl_program *prog)
|
||||
{
|
||||
st_serialise_ir_program(ctx, prog, false);
|
||||
}
|
||||
|
||||
void
|
||||
st_serialise_tgsi_program_binary(struct gl_context *ctx,
|
||||
struct gl_shader_program *shProg,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
st_serialise_ir_program(ctx, prog, false);
|
||||
}
|
||||
|
||||
void
|
||||
st_deserialise_tgsi_program(struct gl_context *ctx,
|
||||
struct gl_shader_program *shProg,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
st_deserialise_ir_program(ctx, shProg, prog, false);
|
||||
}
|
||||
|
||||
void
|
||||
st_serialise_nir_program(struct gl_context *ctx, struct gl_program *prog)
|
||||
{
|
||||
st_serialise_ir_program(ctx, prog, true);
|
||||
}
|
||||
|
||||
void
|
||||
st_serialise_nir_program_binary(struct gl_context *ctx,
|
||||
struct gl_shader_program *shProg,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
st_serialise_ir_program(ctx, prog, true);
|
||||
}
|
||||
|
||||
void
|
||||
st_deserialise_nir_program(struct gl_context *ctx,
|
||||
struct gl_shader_program *shProg,
|
||||
struct gl_program *prog)
|
||||
{
|
||||
st_deserialise_ir_program(ctx, shProg, prog, true);
|
||||
st_serialise_nir_program(ctx, prog);
|
||||
}
|
||||
|
|
|
@ -64,13 +64,11 @@ st_deserialise_nir_program(struct gl_context *ctx,
|
|||
struct gl_program *prog);
|
||||
|
||||
bool
|
||||
st_load_ir_from_disk_cache(struct gl_context *ctx,
|
||||
struct gl_shader_program *prog,
|
||||
bool nir);
|
||||
st_load_nir_from_disk_cache(struct gl_context *ctx,
|
||||
struct gl_shader_program *prog);
|
||||
|
||||
void
|
||||
st_store_ir_in_disk_cache(struct st_context *st, struct gl_program *prog,
|
||||
bool nir);
|
||||
st_store_nir_in_disk_cache(struct st_context *st, struct gl_program *prog);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue