Mesa (master): panfrost: Determine framebuffer format bits late

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Mar 12 02:40:33 UTC 2019


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Thu Mar  7 04:42:49 2019 +0000

panfrost: Determine framebuffer format bits late

Again, these formats are only properly known at the time of fragment job
emit. Rather than hardcoding the format, at least for MFBD we begin to
construct the format bits on-demand. This cleans up the code,
futureproofs for ES3 framebuffer formats, and should fix bugs regarding
FBO colour swizzles.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Reviewed-by: Tomeu Vizoso <tomeu.visozo at collabora.com>

---

 src/gallium/drivers/panfrost/pan_context.c | 59 +++++++++++++++++++++---------
 1 file changed, 42 insertions(+), 17 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index adad59a13fc..4c02fbbe125 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -131,6 +131,35 @@ panfrost_enable_checksum(struct panfrost_context *ctx, struct panfrost_resource
         rsrc->bo->has_checksum = true;
 }
 
+static unsigned
+panfrost_sfbd_format_for_surface(struct pipe_surface *surf)
+{
+        /* TODO */
+        return 0xb84e0281; /* RGB32, no MSAA */
+}
+
+static struct mali_rt_format
+panfrost_mfbd_format_for_surface(struct pipe_surface *surf)
+{
+        /* Explode details on the format */
+
+        const struct util_format_description *desc =
+                util_format_description(surf->texture->format);
+
+        /* Fill in accordingly */
+
+        struct mali_rt_format fmt = {
+                .unk1 = 0x4000000,
+                .unk2 = 0x1,
+                .nr_channels = MALI_POSITIVE(desc->nr_channels),
+                .flags = 0x444,
+                .swizzle = panfrost_translate_swizzle_4(desc->swizzle),
+                .unk4 = 0x8
+        };
+
+        return fmt;
+}
+
 static bool panfrost_is_scanout(struct panfrost_context *ctx);
 
 /* These routines link a fragment job with the bound surface, accounting for the
@@ -147,6 +176,18 @@ panfrost_set_fragment_target_cbuf(
         signed stride =
                 util_format_get_stride(surf->format, surf->texture->width0);
 
+        /* First, we set the format bits */
+
+        if (ctx->require_sfbd) {
+                ctx->fragment_sfbd.format =
+                        panfrost_sfbd_format_for_surface(surf);
+        } else {
+                ctx->fragment_rts[cb].format =
+                        panfrost_mfbd_format_for_surface(surf);
+        }
+
+        /* Now, we set the layout specific pieces */
+
         if (rsrc->bo->layout == PAN_LINEAR) {
                 mali_ptr framebuffer = rsrc->bo->gpu[0];
 
@@ -367,7 +408,6 @@ panfrost_new_frag_framebuffer(struct panfrost_context *ctx)
 {
         if (ctx->require_sfbd) {
                 struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx);
-                fb.format = 0xb84e0281; /* RGB32, no MSAA */
                 memcpy(&ctx->fragment_sfbd, &fb, sizeof(fb));
         } else {
                 struct bifrost_framebuffer fb = panfrost_emit_mfbd(ctx);
@@ -376,24 +416,9 @@ panfrost_new_frag_framebuffer(struct panfrost_context *ctx)
                 fb.rt_count_2 = 1;
                 fb.unk3 = 0x100;
 
-                /* By default, Gallium seems to need a BGR framebuffer */
-                unsigned char bgra[4] = {
-                        PIPE_SWIZZLE_Z, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_X, PIPE_SWIZZLE_W
-                };
-
-                struct bifrost_render_target rt = {
-                        .format = {
-                                .unk1 = 0x4000000,
-                                .unk2 = 0x1,
-                                .nr_channels = MALI_POSITIVE(4),
-                                .flags = 0x444,
-                                .swizzle = panfrost_translate_swizzle_4(bgra),
-                                .unk4 = 0x8
-                        },
-                };
+                struct bifrost_render_target rt = {};
 
                 memcpy(&ctx->fragment_rts[0], &rt, sizeof(rt));
-
                 memset(&ctx->fragment_extra, 0, sizeof(ctx->fragment_extra));
                 memcpy(&ctx->fragment_mfbd, &fb, sizeof(fb));
         }




More information about the mesa-commit mailing list