panfrost: Don't subclass pipe_compute_state
Just copy the bit we need so the NIR doesn't hang around. This is simpler. Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16173>
This commit is contained in:
@@ -3916,7 +3916,7 @@ panfrost_launch_grid(struct pipe_context *pipe,
|
||||
struct pipe_constant_buffer ubuf = {
|
||||
.buffer = NULL,
|
||||
.buffer_offset = 0,
|
||||
.buffer_size = ctx->shader[PIPE_SHADER_COMPUTE]->cbase.req_input_mem,
|
||||
.buffer_size = ctx->shader[PIPE_SHADER_COMPUTE]->req_input_mem,
|
||||
.user_buffer = info->input
|
||||
};
|
||||
|
||||
|
||||
@@ -46,8 +46,7 @@ panfrost_create_compute_state(
|
||||
struct panfrost_screen *screen = pan_screen(pctx->screen);
|
||||
|
||||
struct panfrost_shader_variants *so = CALLOC_STRUCT(panfrost_shader_variants);
|
||||
so->cbase = *cso;
|
||||
so->is_compute = true;
|
||||
so->req_input_mem = cso->req_input_mem;
|
||||
|
||||
struct panfrost_shader_state *v = calloc(1, sizeof(*v));
|
||||
so->variants = v;
|
||||
@@ -55,6 +54,8 @@ panfrost_create_compute_state(
|
||||
so->variant_count = 1;
|
||||
so->active_variant = 0;
|
||||
|
||||
nir_shader *deserialized = NULL;
|
||||
|
||||
if (cso->ir_type == PIPE_SHADER_IR_NIR_SERIALIZED) {
|
||||
struct blob_reader reader;
|
||||
const struct pipe_binary_program_header *hdr = cso->prog;
|
||||
@@ -64,18 +65,16 @@ panfrost_create_compute_state(
|
||||
const struct nir_shader_compiler_options *options =
|
||||
screen->vtbl.get_compiler_options();
|
||||
|
||||
so->cbase.prog = nir_deserialize(NULL, options, &reader);
|
||||
so->cbase.ir_type = PIPE_SHADER_IR_NIR;
|
||||
deserialized = nir_deserialize(NULL, options, &reader);
|
||||
} else {
|
||||
assert(cso->ir_type == PIPE_SHADER_IR_NIR && "TGSI kernels unsupported");
|
||||
}
|
||||
|
||||
assert(so->cbase.ir_type == PIPE_SHADER_IR_NIR && "TGSI kernels unsupported");
|
||||
|
||||
panfrost_shader_compile(pctx->screen, &ctx->shaders, &ctx->descs,
|
||||
so->cbase.prog, MESA_SHADER_COMPUTE, v);
|
||||
deserialized ?: cso->prog, MESA_SHADER_COMPUTE, v);
|
||||
|
||||
/* There are no variants so we won't need the NIR again */
|
||||
ralloc_free((void *)so->cbase.prog);
|
||||
so->cbase.prog = NULL;
|
||||
ralloc_free(deserialized);
|
||||
|
||||
return so;
|
||||
}
|
||||
|
||||
@@ -331,8 +331,7 @@ panfrost_delete_shader_state(
|
||||
{
|
||||
struct panfrost_shader_variants *cso = (struct panfrost_shader_variants *) so;
|
||||
|
||||
if (!cso->is_compute)
|
||||
ralloc_free(cso->nir);
|
||||
ralloc_free(cso->nir);
|
||||
|
||||
for (unsigned i = 0; i < cso->variant_count; ++i) {
|
||||
struct panfrost_shader_state *shader_state = &cso->variants[i];
|
||||
|
||||
@@ -283,18 +283,13 @@ struct panfrost_shader_state {
|
||||
|
||||
/* A collection of varyings (the CSO) */
|
||||
struct panfrost_shader_variants {
|
||||
/* A panfrost_shader_variants can represent a shader for
|
||||
* either graphics or compute */
|
||||
|
||||
bool is_compute;
|
||||
nir_shader *nir;
|
||||
|
||||
union {
|
||||
struct pipe_compute_state cbase;
|
||||
struct pipe_stream_output_info stream_output;
|
||||
unsigned req_input_mem;
|
||||
};
|
||||
|
||||
nir_shader *nir;
|
||||
struct pipe_stream_output_info stream_output;
|
||||
|
||||
/** Lock for the variants array */
|
||||
simple_mtx_t lock;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user