[Mesa-dev] [PATCH 02/10] panfrost: Remove staging SFBD for pan_context

Alyssa Rosenzweig alyssa at rosenzweig.io
Wed Mar 13 02:03:19 UTC 2019


The fragment framebuffer descriptor should not be a context entry;
rather, it should be constructed only at fragment time to keep analysis
tractable.

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
---
 src/gallium/drivers/panfrost/pan_context.h  |  5 +-
 src/gallium/drivers/panfrost/pan_fragment.c |  7 ++-
 src/gallium/drivers/panfrost/pan_mfbd.c     |  2 +-
 src/gallium/drivers/panfrost/pan_sfbd.c     | 55 +++++++++------------
 4 files changed, 30 insertions(+), 39 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index a304d83e4fe..a3c87199d00 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -140,7 +140,6 @@ struct panfrost_context {
          * e.g. clearing information */
 
         union {
-                struct mali_single_framebuffer fragment_sfbd;
                 struct {
                         struct bifrost_framebuffer fragment_mfbd;
                         struct bifrost_fb_extra fragment_extra;
@@ -371,10 +370,10 @@ bool
 panfrost_is_scanout(struct panfrost_context *ctx);
 
 mali_ptr
-panfrost_sfbd_fragment(struct panfrost_context *ctx);
+panfrost_sfbd_fragment(struct panfrost_context *ctx, bool flip_y);
 
 mali_ptr
-panfrost_mfbd_fragment(struct panfrost_context *ctx);
+panfrost_mfbd_fragment(struct panfrost_context *ctx, bool flip_y);
 
 struct bifrost_framebuffer
 panfrost_emit_mfbd(struct panfrost_context *ctx);
diff --git a/src/gallium/drivers/panfrost/pan_fragment.c b/src/gallium/drivers/panfrost/pan_fragment.c
index 16405a4ed21..0dc15c2d235 100644
--- a/src/gallium/drivers/panfrost/pan_fragment.c
+++ b/src/gallium/drivers/panfrost/pan_fragment.c
@@ -34,9 +34,12 @@
 mali_ptr
 panfrost_fragment_job(struct panfrost_context *ctx)
 {
+        /* TODO: Check viewport or something */
+        bool flip_y = panfrost_is_scanout(ctx);
+
         mali_ptr framebuffer = ctx->require_sfbd ?
-                panfrost_sfbd_fragment(ctx) :
-                panfrost_mfbd_fragment(ctx);
+                panfrost_sfbd_fragment(ctx, flip_y) :
+                panfrost_mfbd_fragment(ctx, flip_y);
 
         struct mali_job_descriptor_header header = {
                 .job_type = JOB_TYPE_FRAGMENT,
diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c
index dffe13e6713..cb36a374063 100644
--- a/src/gallium/drivers/panfrost/pan_mfbd.c
+++ b/src/gallium/drivers/panfrost/pan_mfbd.c
@@ -234,7 +234,7 @@ panfrost_mfbd_upload(struct panfrost_context *ctx)
 /* Creates an MFBD for the FRAGMENT section of the bound framebuffer */
 
 mali_ptr
-panfrost_mfbd_fragment(struct panfrost_context *ctx)
+panfrost_mfbd_fragment(struct panfrost_context *ctx, bool flip_y)
 {
         struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
 
diff --git a/src/gallium/drivers/panfrost/pan_sfbd.c b/src/gallium/drivers/panfrost/pan_sfbd.c
index d04da20e258..0e283bbb082 100644
--- a/src/gallium/drivers/panfrost/pan_sfbd.c
+++ b/src/gallium/drivers/panfrost/pan_sfbd.c
@@ -36,16 +36,11 @@ panfrost_sfbd_format(struct pipe_surface *surf)
 }
 
 static void
-panfrost_sfbd_enable_msaa(struct panfrost_context *ctx)
-{
-        ctx->fragment_sfbd.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
-}
-
-static void
-panfrost_sfbd_clear(struct panfrost_job *job)
+panfrost_sfbd_clear(
+                struct panfrost_job *job,
+                struct mali_single_framebuffer *sfbd)
 {
         struct panfrost_context *ctx = job->ctx;
-        struct mali_single_framebuffer *sfbd = &ctx->fragment_sfbd;
 
         if (job->clear & PIPE_CLEAR_COLOR) {
                 sfbd->clear_color_1 = job->clear_color;
@@ -91,60 +86,54 @@ panfrost_sfbd_clear(struct panfrost_job *job)
 
 static void
 panfrost_sfbd_set_cbuf(
-                struct panfrost_context *ctx,
-                struct pipe_surface *surf)
+                struct mali_single_framebuffer *fb,
+                struct pipe_surface *surf,
+                bool flip_y)
 {
         struct panfrost_resource *rsrc = pan_resource(surf->texture);
 
         signed stride =
                 util_format_get_stride(surf->format, surf->texture->width0);
 
-        ctx->fragment_sfbd.format = panfrost_sfbd_format(surf);
+        fb->format = panfrost_sfbd_format(surf);
 
         if (rsrc->bo->layout == PAN_LINEAR) {
                 mali_ptr framebuffer = rsrc->bo->gpu[0];
 
                 /* The default is upside down from OpenGL's perspective. */
-                if (panfrost_is_scanout(ctx)) {
+                if (flip_y) {
                         framebuffer += stride * (surf->texture->height0 - 1);
                         stride = -stride;
                 }
 
-                ctx->fragment_sfbd.framebuffer = framebuffer;
-                ctx->fragment_sfbd.stride = stride;
+                fb->framebuffer = framebuffer;
+                fb->stride = stride;
         } else {
                 fprintf(stderr, "Invalid render layout\n");
                 assert(0);
         }
 }
 
-static void
-panfrost_sfbd_set_targets(struct panfrost_context *ctx)
-{
-        assert(ctx->pipe_framebuffer.nr_cbufs == 1);
-        panfrost_sfbd_set_cbuf(ctx, ctx->pipe_framebuffer.cbufs[0]);
-
-        if (ctx->pipe_framebuffer.zsbuf) {
-                /* TODO */
-        }
-}
-
 /* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
 
 mali_ptr
-panfrost_sfbd_fragment(struct panfrost_context *ctx)
+panfrost_sfbd_fragment(struct panfrost_context *ctx, bool flip_y)
 {
         struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
-
         struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx);
-        memcpy(&ctx->fragment_sfbd, &fb, sizeof(fb));
 
-        panfrost_sfbd_clear(job);
-        panfrost_sfbd_set_targets(ctx);
+        panfrost_sfbd_clear(job, &fb);
+
+        /* SFBD does not support MRT natively; sanity check */
+        assert(ctx->pipe_framebuffer.nr_cbufs == 1);
+        panfrost_sfbd_set_cbuf(&fb, ctx->pipe_framebuffer.cbufs[0], flip_y);
+
+        if (ctx->pipe_framebuffer.zsbuf) {
+                /* TODO */
+        }
 
         if (job->msaa)
-                panfrost_sfbd_enable_msaa(ctx);
+                fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
 
-        return MALI_SFBD |
-                panfrost_upload_transient(ctx, &ctx->fragment_sfbd, sizeof(fb));
+        return panfrost_upload_transient(ctx, &fb, sizeof(fb)) | MALI_SFBD;
 }
-- 
2.20.1



More information about the mesa-dev mailing list