pan/decode: Restore bifrost sample_locations
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Fri, 28 Feb 2020 12:17:53 +0000 (07:17 -0500)
committerMarge Bot <eric+marge@anholt.net>
Tue, 3 Mar 2020 00:03:50 +0000 (00:03 +0000)
Code by Connor Abbott, reverting a part of
254f40fd535ef57dee2bcc4afd97840749ce5918 where it was removed during a
Midgard refactor.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4025>

src/panfrost/include/panfrost-job.h
src/panfrost/pandecode/decode.c

index 405440146e6bcdc8a4d6d7c55cae3b426b6f42f5..1e67c150aa8115ba8734cab6ad07a0fc56fe02f4 100644 (file)
@@ -1491,7 +1491,14 @@ struct mali_shared_memory {
         mali_ptr unknown1;
 } __attribute__((packed));
 
+/* Configures multisampling on Bifrost fragment jobs */
 
+struct bifrost_multisampling {
+        u64 zero1;
+        u64 zero2;
+        mali_ptr sample_locations;
+        u64 zero4;
+} __attribute__((packed));
 
 struct mali_single_framebuffer {
         struct mali_shared_memory shared_memory;
@@ -1685,7 +1692,10 @@ struct mali_framebuffer_extra  {
 #define MALI_MFBD_EXTRA (1 << 13)
 
 struct mali_framebuffer {
-        struct mali_shared_memory shared_memory;
+        union {
+                struct mali_shared_memory shared_memory;
+                struct bifrost_multisampling msaa;
+        };
 
         /* 0x20 */
         u16 width1, height1;
index 2b69b2e92af4b47a8e4eda2d5bb2bb30434c6d32..b84a6473fb9cb70a143a5bd8db84989fb1e300fe 100644 (file)
@@ -1063,21 +1063,68 @@ pandecode_render_target(uint64_t gpu_va, unsigned job_no, const struct mali_fram
 }
 
 static struct pandecode_fbd
-pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_compute)
+pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_compute, bool is_bifrost)
 {
         struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va);
         const struct mali_framebuffer *PANDECODE_PTR_VAR(fb, mem, (mali_ptr) gpu_va);
 
         struct pandecode_fbd info;
+
+        if (is_bifrost && fb->msaa.sample_locations) {
+                /* The blob stores all possible sample locations in a single buffer
+                 * allocated on startup, and just switches the pointer when switching
+                 * MSAA state. For now, we just put the data into the cmdstream, but we
+                 * should do something like what the blob does with a real driver.
+                 *
+                 * There seem to be 32 slots for sample locations, followed by another
+                 * 16. The second 16 is just the center location followed by 15 zeros
+                 * in all the cases I've identified (maybe shader vs. depth/color
+                 * samples?).
+                 */
+
+                struct pandecode_mapped_memory *smem = pandecode_find_mapped_gpu_mem_containing(fb->msaa.sample_locations);
+
+                const u16 *PANDECODE_PTR_VAR(samples, smem, fb->msaa.sample_locations);
+
+                pandecode_log("uint16_t sample_locations_%d[] = {\n", job_no);
+                pandecode_indent++;
+
+                for (int i = 0; i < 32 + 16; i++) {
+                        pandecode_log("%d, %d,\n", samples[2 * i], samples[2 * i + 1]);
+                }
+
+                pandecode_indent--;
+                pandecode_log("};\n");
+        }
  
         pandecode_log("struct mali_framebuffer framebuffer_%"PRIx64"_%d = {\n", gpu_va, job_no);
         pandecode_indent++;
 
-        pandecode_log(".shared_memory = {\n");
-        pandecode_indent++;
-        pandecode_shared_memory(&fb->shared_memory, is_compute);
-        pandecode_indent--;
-        pandecode_log("},\n");
+        if (is_bifrost) {
+                pandecode_log(".msaa = {\n");
+                pandecode_indent++;
+
+                if (fb->msaa.sample_locations)
+                        pandecode_prop("sample_locations = sample_locations_%d", job_no);
+                else
+                        pandecode_msg("XXX: sample_locations missing\n");
+
+                if (fb->msaa.zero1 || fb->msaa.zero2 || fb->msaa.zero4) {
+                        pandecode_msg("XXX: multisampling zero tripped\n");
+                        pandecode_prop("zero1 = %" PRIx64, fb->msaa.zero1);
+                        pandecode_prop("zero2 = %" PRIx64, fb->msaa.zero2);
+                        pandecode_prop("zero4 = %" PRIx64, fb->msaa.zero4);
+                }
+
+                pandecode_indent--;
+                pandecode_log("},\n");
+        } else {
+                pandecode_log(".shared_memory = {\n");
+                pandecode_indent++;
+                pandecode_shared_memory(&fb->shared_memory, is_compute);
+                pandecode_indent--;
+                pandecode_log("},\n");
+        }
 
         info.width = fb->width1 + 1;
         info.height = fb->height1 + 1;
@@ -2126,7 +2173,7 @@ pandecode_vertex_tiler_postfix_pre(
                 pandecode_log_cont("\t/* %X %/\n", p->shared_memory & 1);
                 pandecode_compute_fbd(p->shared_memory & ~1, job_no);
         } else if (p->shared_memory & MALI_MFBD)
-                fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared_memory) & FBD_MASK, job_no, false, job_type == JOB_TYPE_COMPUTE);
+                fbd_info = pandecode_mfbd_bfr((u64) ((uintptr_t) p->shared_memory) & FBD_MASK, job_no, false, job_type == JOB_TYPE_COMPUTE, false);
         else if (job_type == JOB_TYPE_COMPUTE)
                 pandecode_compute_fbd((u64) (uintptr_t) p->shared_memory, job_no);
         else
@@ -2753,7 +2800,7 @@ pandecode_fragment_job(const struct pandecode_mapped_memory *mem,
         struct pandecode_fbd info;
 
         if (is_mfbd)
-                info = pandecode_mfbd_bfr(s->framebuffer & FBD_MASK, job_no, true, false);
+                info = pandecode_mfbd_bfr(s->framebuffer & FBD_MASK, job_no, true, false, is_bifrost);
         else
                 info = pandecode_sfbd(s->framebuffer & FBD_MASK, job_no, true, gpu_id);