mesa/st: add 'base_serialized_nir'
this is the pre-finalize nir which has (ideally) not been mangled by driver-specific lowering passes Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28189>
This commit is contained in:
committed by
Marge Bot
parent
3d279bee0a
commit
f2f640f3c7
@@ -504,6 +504,8 @@ struct gl_program
|
||||
GLboolean _Used; /**< Ever used for drawing? Used for debugging */
|
||||
|
||||
struct nir_shader *nir;
|
||||
void *base_serialized_nir;
|
||||
size_t base_serialized_nir_size;
|
||||
|
||||
/* Saved and restored with metadata. Freed with ralloc. */
|
||||
void *driver_cache_blob;
|
||||
|
||||
@@ -251,6 +251,7 @@ _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog)
|
||||
st_release_variants(st, prog);
|
||||
|
||||
free(prog->serialized_nir);
|
||||
free(prog->base_serialized_nir);
|
||||
|
||||
if (prog == &_mesa_DummyProgram)
|
||||
return;
|
||||
|
||||
@@ -385,8 +385,10 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
|
||||
st_finalize_nir_before_variants(nir);
|
||||
|
||||
char *msg = NULL;
|
||||
if (st->allow_st_finalize_nir_twice)
|
||||
if (st->allow_st_finalize_nir_twice) {
|
||||
st_serialize_base_nir(prog, nir);
|
||||
msg = st_finalize_nir(st, prog, shader_program, nir, true, true);
|
||||
}
|
||||
|
||||
if (st->ctx->_Shader->Flags & GLSL_DUMP) {
|
||||
_mesa_log("\n");
|
||||
|
||||
@@ -390,6 +390,8 @@ st_prog_to_nir_postprocess(struct st_context *st, nir_shader *nir,
|
||||
st_finalize_nir_before_variants(nir);
|
||||
|
||||
if (st->allow_st_finalize_nir_twice) {
|
||||
st_serialize_base_nir(prog, nir);
|
||||
|
||||
char *msg = st_finalize_nir(st, prog, NULL, nir, true, true);
|
||||
free(msg);
|
||||
}
|
||||
@@ -560,6 +562,7 @@ st_translate_vertex_program(struct st_context *st,
|
||||
free(prog->serialized_nir);
|
||||
prog->serialized_nir = NULL;
|
||||
}
|
||||
free(prog->base_serialized_nir);
|
||||
|
||||
prog->state.type = PIPE_SHADER_IR_NIR;
|
||||
if (prog->arb.Instructions)
|
||||
@@ -1301,6 +1304,20 @@ st_serialize_nir(struct gl_program *prog)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
st_serialize_base_nir(struct gl_program *prog, nir_shader *nir)
|
||||
{
|
||||
if (!prog->base_serialized_nir && nir->info.stage == MESA_SHADER_VERTEX) {
|
||||
struct blob blob;
|
||||
size_t size;
|
||||
|
||||
blob_init(&blob);
|
||||
nir_serialize(&blob, nir, false);
|
||||
blob_finish_get_buffer(&blob, &prog->base_serialized_nir, &size);
|
||||
prog->base_serialized_nir_size = size;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
st_finalize_program(struct st_context *st, struct gl_program *prog)
|
||||
{
|
||||
@@ -1338,6 +1355,7 @@ st_finalize_program(struct st_context *st, struct gl_program *prog)
|
||||
* is disabled. If the disk cache is enabled, GLSL programs are
|
||||
* serialized in write_nir_to_cache.
|
||||
*/
|
||||
st_serialize_base_nir(prog, prog->nir);
|
||||
st_serialize_nir(prog);
|
||||
}
|
||||
|
||||
|
||||
@@ -352,6 +352,8 @@ st_translate_stream_output_info(struct gl_program *prog);
|
||||
|
||||
extern void
|
||||
st_serialize_nir(struct gl_program *stp);
|
||||
void
|
||||
st_serialize_base_nir(struct gl_program *prog, struct nir_shader *nir);
|
||||
|
||||
extern void
|
||||
st_finalize_program(struct st_context *st, struct gl_program *prog);
|
||||
|
||||
Reference in New Issue
Block a user