panfrost: On Bifrost, set the right tiler descriptor
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Wed, 8 Apr 2020 13:58:42 +0000 (15:58 +0200)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Fri, 10 Apr 2020 14:53:39 +0000 (16:53 +0200)
On both fragment and tiler jobs.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4505>

src/gallium/drivers/panfrost/pan_cmdstream.c
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_job.h
src/gallium/drivers/panfrost/pan_mfbd.c
src/panfrost/include/panfrost-job.h
src/panfrost/pandecode/decode.c

index 5695378394d357b3171c7b69bfbdc1fbdc16d1fb..784f170a34cda84bae8bf02675b97c16c6eaa293 100644 (file)
@@ -1818,7 +1818,7 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch,
 
                 bifrost_tiler.prefix = *tiler_prefix;
                 bifrost_tiler.tiler.primitive_size = *primitive_size;
-                //bifrost_tiler.tiler.tiler_meta;
+                bifrost_tiler.tiler.tiler_meta = panfrost_batch_get_tiler_meta(batch, ~0);
                 bifrost_tiler.postfix = *tiler_postfix;
                 tp = &bifrost_tiler;
                 tp_size = sizeof(bifrost_tiler);
index cf74a73a86d11f88f626c44576abe50372596c64..3efacac943541cc0927ce25bd843fc9a9aab505c 100644 (file)
@@ -699,6 +699,41 @@ panfrost_batch_get_tiler_heap(struct panfrost_batch *batch)
         return batch->tiler_heap;
 }
 
+/* TODO: Figure out how to remove the hardcoded values */
+mali_ptr
+panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_count)
+{
+        if (!vertex_count)
+                return 0;
+
+        if (batch->tiler_meta)
+                return batch->tiler_meta;
+
+        struct panfrost_bo *tiler_heap;
+        tiler_heap = panfrost_batch_get_tiler_heap(batch);
+
+        struct bifrost_tiler_heap_meta tiler_heap_meta = {
+            .heap_size = tiler_heap->size,
+            .tiler_heap_start = tiler_heap->gpu,
+            .tiler_heap_free = tiler_heap->gpu,
+            .tiler_heap_end = tiler_heap->gpu + tiler_heap->size,
+        };
+
+        tiler_heap_meta.zeros[10] = 0x1;
+        tiler_heap_meta.zeros[11] = 0x7e007e;
+
+        struct bifrost_tiler_meta tiler_meta = {
+            .hierarchy_mask = 0xf0,
+            .flags = 0x0,
+            .width = MALI_POSITIVE(batch->key.width),
+            .height = MALI_POSITIVE(batch->key.height),
+            .tiler_heap_meta = panfrost_upload_transient(batch, &tiler_heap_meta, sizeof(tiler_heap_meta)),
+        };
+
+        batch->tiler_meta = panfrost_upload_transient(batch, &tiler_meta, sizeof(tiler_meta));
+        return batch->tiler_meta;
+}
+
 struct panfrost_bo *
 panfrost_batch_get_tiler_dummy(struct panfrost_batch *batch)
 {
index 9ed544f6c63c4483533e98838d2beffe65a26d52..f9499fc1b90600690fdd485e5482f564439caeb3 100644 (file)
@@ -142,6 +142,9 @@ struct panfrost_batch {
         /* Framebuffer descriptor. */
         struct panfrost_transfer framebuffer;
 
+        /* Bifrost tiler meta descriptor. */
+        mali_ptr tiler_meta;
+
         /* Output sync object. Only valid when submitted is true. */
         struct panfrost_batch_fence *out_sync;
 
@@ -240,4 +243,7 @@ void panfrost_scoreboard_initialize_tiler(struct panfrost_batch *batch);
 bool
 panfrost_batch_is_scanout(struct panfrost_batch *batch);
 
+mali_ptr
+panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_count);
+
 #endif
index 04646e5eda82682ccd080c8be04125243a0ac111..b0e295ea51c5b53a3e7918982d88f988625e0eea 100644 (file)
@@ -25,6 +25,7 @@
 #include "pan_bo.h"
 #include "pan_context.h"
 #include "pan_util.h"
+#include "panfrost-quirks.h"
 
 static struct mali_rt_format
 panfrost_mfbd_format(struct pipe_surface *surf)
@@ -377,8 +378,6 @@ panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count)
                 .rt_count_1 = MALI_POSITIVE(batch->key.nr_cbufs),
                 .rt_count_2 = 4,
 
-                .tiler = panfrost_emit_midg_tiler(batch, vertex_count),
-
                 .shared_memory = {
                         .stack_shift = shift,
                         .scratchpad = panfrost_batch_get_scratchpad(batch, shift, dev->thread_tls_alloc, dev->core_count)->gpu,
@@ -386,6 +385,11 @@ panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count)
                 }
         };
 
+        if (dev->quirks & IS_BIFROST)
+                framebuffer.tiler_meta = panfrost_batch_get_tiler_meta(batch, vertex_count);
+        else
+                framebuffer.tiler = panfrost_emit_midg_tiler(batch, vertex_count);
+
         return framebuffer;
 }
 
index 644606fb054f1461ba08afad81270e157f41a5db..2f330d3e5470a53c78f62965bdd2f2fd6afd7b62 100644 (file)
@@ -1702,7 +1702,13 @@ struct mali_framebuffer {
         u32 mfbd_flags : 24; // = 0x100
         float clear_depth;
 
-        struct midgard_tiler_descriptor tiler;
+        union {
+                struct midgard_tiler_descriptor tiler;
+                struct {
+                        mali_ptr tiler_meta;
+                        u32 zeros[16];
+                };
+        };
 
         /* optional: struct mali_framebuffer_extra  extra */
         /* struct mali_render_target rts[] */
index 840ff4a7807cee4413730c416d84ee62adcb3695..3e70967562e0d3e4566ab9e40fe22f4463414ec5 100644 (file)
@@ -629,24 +629,18 @@ pandecode_midgard_tiler_descriptor(
 /* TODO: The Bifrost tiler is not understood at all yet */
 
 static void
-pandecode_bifrost_tiler_descriptor(const struct midgard_tiler_descriptor *t)
+pandecode_bifrost_tiler_descriptor(const struct mali_framebuffer *fb)
 {
         pandecode_log(".tiler = {\n");
         pandecode_indent++;
 
-        pandecode_prop("polygon_list_size = 0x%" PRIx32, t->polygon_list_size);
-        pandecode_prop("hierarchy_mask = 0x%" PRIx16, t->hierarchy_mask);
-        pandecode_prop("flags = 0x%" PRIx16, t->flags);
+        MEMORY_PROP(fb, tiler_meta);
 
-        MEMORY_PROP(t, polygon_list);
-        MEMORY_PROP(t, polygon_list_body);
-        MEMORY_PROP(t, heap_start);
-        MEMORY_PROP(t, heap_end);
-
-        pandecode_log(".weights = { ");
-
-        for (unsigned w = 0; w < ARRAY_SIZE(t->weights); ++w) {
-                pandecode_log_cont("%d, ", t->weights[w]);
+        for (int i = 0; i < 16; i++) {
+                if (fb->zeros[i] != 0) {
+                        pandecode_msg("XXX: tiler descriptor zero %d tripped, value %x\n",
+                                      i, fb->zeros[i]);
+                }
         }
 
         pandecode_log("},\n");
@@ -1180,12 +1174,11 @@ pandecode_mfbd_bfr(uint64_t gpu_va, int job_no, bool is_fragment, bool is_comput
         if (fb->clear_depth)
                 pandecode_prop("clear_depth = %f", fb->clear_depth);
 
-        const struct midgard_tiler_descriptor t = fb->tiler;
         if (!is_compute)
                 if (is_bifrost)
-                        pandecode_bifrost_tiler_descriptor(&t);
+                        pandecode_bifrost_tiler_descriptor(fb);
                 else
-                        pandecode_midgard_tiler_descriptor(&t, fb->width1 + 1, fb->height1 + 1, is_fragment, true);
+                        pandecode_midgard_tiler_descriptor(&fb->tiler, fb->width1 + 1, fb->height1 + 1, is_fragment, true);
         else
                 pandecode_msg("XXX: skipping compute MFBD, fixme\n");
 
@@ -2592,17 +2585,10 @@ pandecode_vertex_tiler_postfix(const struct mali_vertex_tiler_postfix *p, int jo
 static void
 pandecode_tiler_heap_meta(mali_ptr gpu_va, int job_no)
 {
-
         struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va);
-
-        if (gpu_va == 0) {
-                pandecode_msg("XXX: bifrost_tiler_heap_meta is NULL!!\n");
-                return;
-        }
-
         const struct bifrost_tiler_heap_meta *PANDECODE_PTR_VAR(h, mem, gpu_va);
 
-        pandecode_log("struct mali_tiler_heap_meta tiler_heap_meta_%d = {\n", job_no);
+        pandecode_log("struct bifrost_tiler_heap_meta tiler_heap_meta_%"PRIx64"_%d = {\n", gpu_va, job_no);
         pandecode_indent++;
 
         if (h->zero) {
@@ -2646,7 +2632,7 @@ pandecode_tiler_meta(mali_ptr gpu_va, int job_no)
 
         pandecode_tiler_heap_meta(t->tiler_heap_meta, job_no);
 
-        pandecode_log("struct bifrost_tiler_meta tiler_meta_%d = {\n", job_no);
+        pandecode_log("struct bifrost_tiler_meta tiler_meta_%"PRIx64"_%d = {\n", gpu_va, job_no);
         pandecode_indent++;
 
         if (t->zero0 || t->zero1) {
@@ -2746,7 +2732,7 @@ pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h,
         pandecode_vertex_tiler_postfix_pre(&t->postfix, job_no, h->job_type, "", true, gpu_id);
         pandecode_tiler_meta(t->tiler.tiler_meta, job_no);
 
-        pandecode_log("struct bifrost_payload_tiler payload_%d = {\n", job_no);
+        pandecode_log("struct bifrost_payload_tiler payload_%"PRIx64"_%d = {\n", payload, job_no);
         pandecode_indent++;
 
         pandecode_vertex_tiler_prefix(&t->prefix, job_no, false);