Mesa (master): panfrost: implement gallium->set_shader_images

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jan 27 12:52:33 UTC 2021


Module: Mesa
Branch: master
Commit: 0b9b0ee5321d9b483ed3c734b97135d04d039f18
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b9b0ee5321d9b483ed3c734b97135d04d039f18

Author: Italo Nicola <italonicola at collabora.com>
Date:   Fri Dec 11 16:47:35 2020 +0000

panfrost: implement gallium->set_shader_images

Implements gallium images endpoint.
If an AFBC resource is bound to an image, we convert it to tiled, since
images need pixel-level granularity and AFBC doesn't allow for that.

Signed-off-by: Italo Nicola <italonicola at collabora.com>
Reviewed-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/8066>

---

 src/gallium/drivers/panfrost/pan_context.c | 51 ++++++++++++++++++++++++------
 src/gallium/drivers/panfrost/pan_context.h |  3 ++
 2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 95ee7e5ee90..3382c35c087 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -637,6 +637,47 @@ panfrost_bind_rasterizer_state(
         ctx->rasterizer = hwcso;
 }
 
+static void
+panfrost_set_shader_images(
+        struct pipe_context *pctx,
+        enum pipe_shader_type shader,
+        unsigned start_slot, unsigned count,
+        const struct pipe_image_view *iviews)
+{
+        struct panfrost_context *ctx = pan_context(pctx);
+
+        /* Unbind start_slot...start_slot+count */
+        if (!iviews) {
+                for (int i = start_slot; i < start_slot + count; i++) {
+                        pipe_resource_reference(&ctx->images[shader][i].resource, NULL);
+                }
+
+                ctx->image_mask[shader] &= ~(((1ull << count) - 1) << start_slot);
+                return;
+        }
+
+        /* Bind start_slot...start_slot+count */
+        for (int i = 0; i < count; i++) {
+                const struct pipe_image_view *image = &iviews[i];
+                SET_BIT(ctx->image_mask[shader], 1 << (start_slot + i), image->resource);
+
+                if (!image->resource) {
+                        util_copy_image_view(&ctx->images[shader][start_slot+i], NULL);
+                        continue;
+                }
+
+                struct panfrost_resource *rsrc = pan_resource(image->resource);
+
+                /* Images don't work with AFBC, since they require pixel-level granularity */
+                if (drm_is_afbc(rsrc->layout.modifier)) {
+                        pan_resource_modifier_convert(ctx, rsrc,
+                                        DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED);
+                }
+
+                util_copy_image_view(&ctx->images[shader][start_slot+i], image);
+        }
+}
+
 static void *
 panfrost_create_vertex_elements_state(
         struct pipe_context *pctx,
@@ -1186,16 +1227,6 @@ panfrost_set_shader_buffers(
                         buffers, start, count);
 }
 
-static void
-panfrost_set_shader_images(
-        struct pipe_context *pctx,
-        enum pipe_shader_type shader,
-        unsigned start, unsigned count,
-        const struct pipe_image_view *images)
-{
-        /* TODO */
-}
-
 static void
 panfrost_set_framebuffer_state(struct pipe_context *pctx,
                                const struct pipe_framebuffer_state *fb)
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index 39ee2186418..8a0ea8fdf0c 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -156,6 +156,9 @@ struct panfrost_context {
         struct pipe_shader_buffer ssbo[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_BUFFERS];
         uint32_t ssbo_mask[PIPE_SHADER_TYPES];
 
+        struct pipe_image_view images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
+        uint32_t image_mask[PIPE_SHADER_TYPES];
+
         struct panfrost_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
         unsigned sampler_count[PIPE_SHADER_TYPES];
 



More information about the mesa-commit mailing list