panfrost: Note "MFBD preload disable" bit
[mesa.git] / src / gallium / drivers / panfrost / pan_mfbd.c
index c9f3dc315a0fb8f139f572554befa630f60870ca..1f504294bda804b4102a660a80b99a0e308882a7 100644 (file)
@@ -73,7 +73,7 @@ panfrost_mfbd_format(struct pipe_surface *surf)
                 .unk3 = 0x4,
                 .flags = 0x8,
                 .swizzle = panfrost_translate_swizzle_4(swizzle),
-                .unk4 = 0x8
+                .no_preload = true
         };
 
         if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
@@ -394,46 +394,52 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws)
         struct bifrost_fb_extra fbx = {};
         struct bifrost_render_target rts[4] = {};
 
-        /* XXX: MRT case */
-        fb.rt_count_2 = 1;
+        /* We always upload at least one dummy GL_NONE render target */
+
+        unsigned rt_descriptors =
+                MAX2(ctx->pipe_framebuffer.nr_cbufs, 1);
+
+        fb.rt_count_1 = MALI_POSITIVE(rt_descriptors);
+        fb.rt_count_2 = rt_descriptors;
         fb.mfbd_flags = 0x100;
 
         /* TODO: MRT clear */
         panfrost_mfbd_clear(job, &fb, &fbx, rts, fb.rt_count_2);
 
-        for (int cb = 0; cb < ctx->pipe_framebuffer.nr_cbufs; ++cb) {
+
+        /* Upload either the render target or a dummy GL_NONE target */
+
+        for (int cb = 0; cb < rt_descriptors; ++cb) {
                 struct pipe_surface *surf = ctx->pipe_framebuffer.cbufs[cb];
 
-                if (!surf)
-                        continue;
+                if (surf) {
+                        panfrost_mfbd_set_cbuf(&rts[cb], surf);
 
-                unsigned bpp = util_format_get_blocksize(surf->format);
+                        /* What is this? Looks like some extension of the bpp
+                         * field. Maybe it establishes how much internal
+                         * tilebuffer space is reserved? */
 
-                panfrost_mfbd_set_cbuf(&rts[cb], surf);
+                        unsigned bpp = util_format_get_blocksize(surf->format);
+                        fb.rt_count_2 = MAX2(fb.rt_count_2, ALIGN_POT(bpp, 4) / 4);
+                } else {
+                        struct mali_rt_format null_rt = {
+                                .unk1 = 0x4000000,
+                                .no_preload = true
+                        };
 
-                /* What is this? Looks like some extension of the bpp field.
-                 * Maybe it establishes how much internal tilebuffer space is
-                 * reserved? */
-                fb.rt_count_2 = MAX2(fb.rt_count_2, ALIGN_POT(bpp, 4) / 4);
+                        rts[cb].format = null_rt;
+                        rts[cb].framebuffer = 0;
+                        rts[cb].framebuffer_stride = 0;
+                }
+
+                /* TODO: Break out the field */
+                rts[cb].format.unk1 |= (cb * 0x400);
         }
 
         if (ctx->pipe_framebuffer.zsbuf) {
                 panfrost_mfbd_set_zsbuf(&fb, &fbx, ctx->pipe_framebuffer.zsbuf);
         }
 
-        /* For the special case of a depth-only FBO, we need to attach a dummy render target */
-
-        if (ctx->pipe_framebuffer.nr_cbufs == 0) {
-                struct mali_rt_format null_rt = {
-                        .unk1 = 0x4000000,
-                        .unk4 = 0x8
-                };
-
-                rts[0].format = null_rt;
-                rts[0].framebuffer = 0;
-                rts[0].framebuffer_stride = 0;
-        }
-
         /* When scanning out, the depth buffer is immediately invalidated, so
          * we don't need to waste bandwidth writing it out. This can improve
          * performance substantially (Z32_UNORM 1080p @ 60fps is 475 MB/s of