From 46e4246d495da2fa836baaeec89a1030f3951f2e Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 8 Apr 2020 15:58:42 +0200 Subject: [PATCH] panfrost: On Bifrost, set the right tiler descriptor On both fragment and tiler jobs. Signed-off-by: Tomeu Vizoso Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 2 +- src/gallium/drivers/panfrost/pan_job.c | 35 ++++++++++++++++++ src/gallium/drivers/panfrost/pan_job.h | 6 ++++ src/gallium/drivers/panfrost/pan_mfbd.c | 8 +++-- src/panfrost/include/panfrost-job.h | 8 ++++- src/panfrost/pandecode/decode.c | 38 +++++++------------- 6 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 5695378394d..784f170a34c 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index cf74a73a86d..3efacac9435 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -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) { diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index 9ed544f6c63..f9499fc1b90 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -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 diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 04646e5eda8..b0e295ea51c 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -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; } diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 644606fb054..2f330d3e547 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -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[] */ diff --git a/src/panfrost/pandecode/decode.c b/src/panfrost/pandecode/decode.c index 840ff4a7807..3e70967562e 100644 --- a/src/panfrost/pandecode/decode.c +++ b/src/panfrost/pandecode/decode.c @@ -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); -- 2.30.2