Mesa (main): panfrost: Get rid of all _packed structs in pan_context.h

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 26 08:52:46 UTC 2021


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

Author: Boris Brezillon <boris.brezillon at collabora.com>
Date:   Wed Aug  4 12:28:48 2021 +0200

panfrost: Get rid of all _packed structs in pan_context.h

Such that pan_context.h remains generic even after the per-gen XML
switch.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12551>

---

 src/gallium/drivers/panfrost/pan_cmdstream.c | 64 ++++++++++++++++++++++++++--
 src/gallium/drivers/panfrost/pan_context.c   | 13 ------
 src/gallium/drivers/panfrost/pan_context.h   | 44 +++----------------
 3 files changed, 67 insertions(+), 54 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c
index da87963bf84..fe59d8998c5 100644
--- a/src/gallium/drivers/panfrost/pan_cmdstream.c
+++ b/src/gallium/drivers/panfrost/pan_cmdstream.c
@@ -47,6 +47,44 @@
 #include "pan_indirect_dispatch.h"
 #include "pan_blitter.h"
 
+struct panfrost_rasterizer {
+        struct pipe_rasterizer_state base;
+
+        /* Partially packed RSD words */
+        struct mali_multisample_misc_packed multisample;
+        struct mali_stencil_mask_misc_packed stencil_misc;
+};
+
+struct panfrost_zsa_state {
+        struct pipe_depth_stencil_alpha_state base;
+
+        /* Is any depth, stencil, or alpha testing enabled? */
+        bool enabled;
+
+        /* Mask of PIPE_CLEAR_{DEPTH,STENCIL} written */
+        unsigned draws;
+
+        /* Prepacked words from the RSD */
+        struct mali_multisample_misc_packed rsd_depth;
+        struct mali_stencil_mask_misc_packed rsd_stencil;
+        struct mali_stencil_packed stencil_front, stencil_back;
+};
+
+struct panfrost_sampler_state {
+        struct pipe_sampler_state base;
+        struct mali_midgard_sampler_packed hw;
+};
+
+/* Misnomer: Sampler view corresponds to textures, not samplers */
+
+struct panfrost_sampler_view {
+        struct pipe_sampler_view base;
+        struct panfrost_pool_ref state;
+        struct mali_bifrost_texture_packed bifrost_descriptor;
+        mali_ptr texture_bo;
+        uint64_t modifier;
+};
+
 /* Statically assert that PIPE_* enums match the hardware enums.
  * (As long as they match, we don't need to translate them.)
  */
@@ -499,10 +537,14 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx,
 #endif
 
         /* Merge with CSO state and upload */
-        if (panfrost_fs_required(fs, ctx->blend, &ctx->pipe_framebuffer, zsa))
-                pan_merge(rsd, fs->partial_rsd, RENDERER_STATE);
-        else
+        if (panfrost_fs_required(fs, ctx->blend, &ctx->pipe_framebuffer, zsa)) {
+                struct mali_renderer_state_packed *partial_rsd =
+                        (struct mali_renderer_state_packed *)&fs->partial_rsd;
+                STATIC_ASSERT(sizeof(fs->partial_rsd) == sizeof(*partial_rsd));
+                pan_merge(rsd, *partial_rsd, RENDERER_STATE);
+        } else {
                 pan_merge_empty_fs(&rsd);
+        }
 
         /* Word 8, 9 Misc state */
         rsd.opaque[8] |= zsa->rsd_depth.opaque[0]
@@ -3447,7 +3489,8 @@ prepare_rsd(struct panfrost_device *dev,
             struct panfrost_shader_state *state,
             struct panfrost_pool *pool, bool upload)
 {
-        struct mali_renderer_state_packed *out = &state->partial_rsd;
+        struct mali_renderer_state_packed *out =
+                (struct mali_renderer_state_packed *)&state->partial_rsd;
 
         if (upload) {
                 struct panfrost_ptr ptr =
@@ -3513,6 +3556,18 @@ init_batch(struct panfrost_batch *batch)
 #endif
 }
 
+static void
+panfrost_sampler_view_destroy(
+        struct pipe_context *pctx,
+        struct pipe_sampler_view *pview)
+{
+        struct panfrost_sampler_view *view = (struct panfrost_sampler_view *) pview;
+
+        pipe_resource_reference(&pview->texture, NULL);
+        panfrost_bo_unreference(view->state.bo);
+        ralloc_free(view);
+}
+
 static void
 context_init(struct pipe_context *pipe)
 {
@@ -3523,6 +3578,7 @@ context_init(struct pipe_context *pipe)
         pipe->create_rasterizer_state = panfrost_create_rasterizer_state;
         pipe->create_depth_stencil_alpha_state = panfrost_create_depth_stencil_state;
         pipe->create_sampler_view = panfrost_create_sampler_view;
+        pipe->sampler_view_destroy = panfrost_sampler_view_destroy;
         pipe->create_sampler_state = panfrost_create_sampler_state;
         pipe->create_blend_state = panfrost_create_blend_state;
 
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index ad94015de6c..ea6d313deec 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -653,18 +653,6 @@ panfrost_set_sampler_views(
         ctx->sampler_view_count[shader] = new_nr;
 }
 
-static void
-panfrost_sampler_view_destroy(
-        struct pipe_context *pctx,
-        struct pipe_sampler_view *pview)
-{
-        struct panfrost_sampler_view *view = (struct panfrost_sampler_view *) pview;
-
-        pipe_resource_reference(&pview->texture, NULL);
-        panfrost_bo_unreference(view->state.bo);
-        ralloc_free(view);
-}
-
 static void
 panfrost_set_shader_buffers(
         struct pipe_context *pctx,
@@ -1065,7 +1053,6 @@ panfrost_create_context(struct pipe_screen *screen, void *priv, unsigned flags)
         gallium->set_stencil_ref = panfrost_set_stencil_ref;
 
         gallium->set_sampler_views = panfrost_set_sampler_views;
-        gallium->sampler_view_destroy = panfrost_sampler_view_destroy;
 
         gallium->bind_rasterizer_state = panfrost_bind_rasterizer_state;
         gallium->delete_rasterizer_state = panfrost_generic_cso_delete;
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index b8debbaeeae..82486f7f149 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -222,13 +222,7 @@ struct panfrost_context {
 
 /* Corresponds to the CSO */
 
-struct panfrost_rasterizer {
-        struct pipe_rasterizer_state base;
-
-        /* Partially packed RSD words */
-        struct mali_multisample_misc_packed multisample;
-        struct mali_stencil_mask_misc_packed stencil_misc;
-};
+struct panfrost_rasterizer;
 
 /* Linked varyings */
 struct pan_linkage {
@@ -247,6 +241,8 @@ struct pan_linkage {
         uint32_t stride;
 };
 
+#define RSD_WORDS 16
+
 /* Variants bundle together to form the backing CSO, bundling multiple
  * shaders with varying emulated features baked in */
 
@@ -259,7 +255,7 @@ struct panfrost_shader_state {
         struct panfrost_pool_ref bin, state;
 
         /* For fragment shaders, a prepared (but not uploaded RSD) */
-        struct mali_renderer_state_packed partial_rsd;
+        uint32_t partial_rsd[RSD_WORDS];
 
         struct pan_shader_info info;
 
@@ -319,35 +315,9 @@ struct panfrost_vertex_state {
         unsigned formats[PIPE_MAX_ATTRIBS];
 };
 
-struct panfrost_zsa_state {
-        struct pipe_depth_stencil_alpha_state base;
-
-        /* Is any depth, stencil, or alpha testing enabled? */
-        bool enabled;
-
-        /* Mask of PIPE_CLEAR_{DEPTH,STENCIL} written */
-        unsigned draws;
-
-        /* Prepacked words from the RSD */
-        struct mali_multisample_misc_packed rsd_depth;
-        struct mali_stencil_mask_misc_packed rsd_stencil;
-        struct mali_stencil_packed stencil_front, stencil_back;
-};
-
-struct panfrost_sampler_state {
-        struct pipe_sampler_state base;
-        struct mali_midgard_sampler_packed hw;
-};
-
-/* Misnomer: Sampler view corresponds to textures, not samplers */
-
-struct panfrost_sampler_view {
-        struct pipe_sampler_view base;
-        struct panfrost_pool_ref state;
-        struct mali_bifrost_texture_packed bifrost_descriptor;
-        mali_ptr texture_bo;
-        uint64_t modifier;
-};
+struct panfrost_zsa_state;
+struct panfrost_sampler_state;
+struct panfrost_sampler_view;
 
 static inline struct panfrost_context *
 pan_context(struct pipe_context *pcontext)



More information about the mesa-commit mailing list