Mesa (main): panfrost: Don't subclass pipe_compute_state

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon May 2 14:14:35 UTC 2022


Module: Mesa
Branch: main
Commit: 1c5adbb3df137fbf12a132a8ceb64aa9ade7fec6
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c5adbb3df137fbf12a132a8ceb64aa9ade7fec6

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Apr 26 14:01:41 2022 -0400

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 at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16173>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c |  2 +-
 src/gallium/drivers/panfrost/pan_compute.c   | 17 ++++++++---------
 src/gallium/drivers/panfrost/pan_context.c   |  3 +--
 src/gallium/drivers/panfrost/pan_context.h   | 11 +++--------
 4 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index 8cf8aa83032..e2d724252e1 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -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
         };
 
diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c
index 1f473b52563..32ea70fece6 100644
--- a/src/gallium/drivers/panfrost/pan_compute.c
+++ b/src/gallium/drivers/panfrost/pan_compute.c
@@ -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;
 }
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index f93656e43f6..0bc16a9f447 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -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];
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index 54db73ebfb6..2b071b71ba3 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -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;
 



More information about the mesa-commit mailing list