From efce73d99d0e0299dd4f3983bc610f6d1828761c Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Tue, 8 Sep 2020 10:11:26 +0200 Subject: [PATCH] panfrost: XML-ify the bifrost tiler descriptors Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 2 +- src/gallium/drivers/panfrost/pan_job.c | 36 ++++++----- src/gallium/drivers/panfrost/pan_job.h | 2 +- src/gallium/drivers/panfrost/pan_mfbd.c | 2 +- src/panfrost/include/panfrost-job.h | 27 -------- src/panfrost/lib/decode.c | 94 ++++------------------------ src/panfrost/lib/midgard.xml | 30 +++++++++ 7 files changed, 65 insertions(+), 128 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index ddeb4f5..20fc474 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1811,7 +1811,7 @@ panfrost_emit_vertex_tiler_jobs(struct panfrost_batch *batch, bifrost_tiler.prefix = *tiler_prefix; bifrost_tiler.primitive_size = *primitive_size; - bifrost_tiler.tiler_meta = panfrost_batch_get_tiler_meta(batch, ~0); + bifrost_tiler.tiler_meta = panfrost_batch_get_bifrost_tiler(batch, ~0); memcpy(&bifrost_tiler.postfix, tiler_draw, MALI_DRAW_LENGTH); 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 ac3ac15..7419c1d 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -678,7 +678,7 @@ panfrost_batch_get_shared_memory(struct panfrost_batch *batch, } mali_ptr -panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_count) +panfrost_batch_get_bifrost_tiler(struct panfrost_batch *batch, unsigned vertex_count) { if (!vertex_count) return 0; @@ -687,25 +687,27 @@ panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_coun return batch->tiler_meta; struct panfrost_device *dev = pan_device(batch->ctx->base.screen); + struct panfrost_transfer t = + panfrost_pool_alloc_aligned(&batch->pool, MALI_BIFROST_TILER_HEAP_LENGTH, 64); + + pan_pack(t.cpu, BIFROST_TILER_HEAP, heap) { + heap.size = dev->tiler_heap->size; + heap.base = dev->tiler_heap->gpu; + heap.bottom = dev->tiler_heap->gpu; + heap.top = dev->tiler_heap->gpu + dev->tiler_heap->size; + } - struct bifrost_tiler_heap_meta tiler_heap_meta = { - .heap_size = dev->tiler_heap->size, - .tiler_heap_start = dev->tiler_heap->gpu, - .tiler_heap_free = dev->tiler_heap->gpu, - .tiler_heap_end = dev->tiler_heap->gpu + dev->tiler_heap->size, - .unk1 = 0x1, - .unk7e007e = 0x7e007e, - }; + mali_ptr heap = t.gpu; - struct bifrost_tiler_meta tiler_meta = { - .hierarchy_mask = 0x28, - .flags = 0x0, - .width = MALI_POSITIVE(batch->key.width), - .height = MALI_POSITIVE(batch->key.height), - .tiler_heap_meta = panfrost_pool_upload_aligned(&batch->pool, &tiler_heap_meta, sizeof(tiler_heap_meta), 64) - }; + t = panfrost_pool_alloc_aligned(&batch->pool, MALI_BIFROST_TILER_LENGTH, 64); + pan_pack(t.cpu, BIFROST_TILER, tiler) { + tiler.hierarchy_mask = 0x28; + tiler.fb_width = batch->key.width; + tiler.fb_height = batch->key.height; + tiler.heap = heap; + } - batch->tiler_meta = panfrost_pool_upload_aligned(&batch->pool, &tiler_meta, sizeof(tiler_meta), 64); + batch->tiler_meta = t.gpu; return batch->tiler_meta; } diff --git a/src/gallium/drivers/panfrost/pan_job.h b/src/gallium/drivers/panfrost/pan_job.h index eb3cc58..2a61980 100644 --- a/src/gallium/drivers/panfrost/pan_job.h +++ b/src/gallium/drivers/panfrost/pan_job.h @@ -205,7 +205,7 @@ bool panfrost_batch_is_scanout(struct panfrost_batch *batch); mali_ptr -panfrost_batch_get_tiler_meta(struct panfrost_batch *batch, unsigned vertex_count); +panfrost_batch_get_bifrost_tiler(struct panfrost_batch *batch, unsigned vertex_count); mali_ptr panfrost_batch_reserve_framebuffer(struct panfrost_batch *batch); diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index 20b95d3..5420916 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -496,7 +496,7 @@ panfrost_emit_mfbd(struct panfrost_batch *batch, unsigned vertex_count) if (dev->quirks & IS_BIFROST) { mfbd.msaa.sample_locations = panfrost_emit_sample_locations(batch); - mfbd.tiler_meta = panfrost_batch_get_tiler_meta(batch, vertex_count); + mfbd.tiler_meta = panfrost_batch_get_bifrost_tiler(batch, vertex_count); } else { struct mali_local_storage_packed lsp; diff --git a/src/panfrost/include/panfrost-job.h b/src/panfrost/include/panfrost-job.h index 52dc696..c0390cd 100644 --- a/src/panfrost/include/panfrost-job.h +++ b/src/panfrost/include/panfrost-job.h @@ -422,33 +422,6 @@ union midgard_primitive_size { u64 pointer; }; -struct bifrost_tiler_heap_meta { - u32 zero; - u32 heap_size; - /* note: these are just guesses! */ - mali_ptr tiler_heap_start; - mali_ptr tiler_heap_free; - mali_ptr tiler_heap_end; - - /* hierarchy weights? but they're still 0 after the job has run... */ - u32 zeros[10]; - u32 unk1; - u32 unk7e007e; -} __attribute__((packed)); - -struct bifrost_tiler_meta { - u32 tiler_heap_next_start; /* To be written by the GPU */ - u32 used_hierarchy_mask; /* To be written by the GPU */ - u16 hierarchy_mask; /* Five values observed: 0xa, 0x14, 0x28, 0x50, 0xa0 */ - u16 flags; - u16 width; - u16 height; - u64 zero0; - mali_ptr tiler_heap_meta; - /* TODO what is this used for? */ - u64 zeros[20]; -} __attribute__((packed)); - struct midgard_payload_vertex_tiler { struct mali_vertex_tiler_prefix prefix; struct mali_draw_packed postfix; diff --git a/src/panfrost/lib/decode.c b/src/panfrost/lib/decode.c index c0aac7e..544b0d1 100644 --- a/src/panfrost/lib/decode.c +++ b/src/panfrost/lib/decode.c @@ -1577,99 +1577,31 @@ pandecode_vertex_tiler_postfix_pre( } static void -pandecode_tiler_heap_meta(mali_ptr gpu_va, int job_no) +pandecode_bifrost_tiler_heap(mali_ptr gpu_va, int job_no) { struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); - const struct bifrost_tiler_heap_meta *PANDECODE_PTR_VAR(h, mem, gpu_va); - - pandecode_log("struct bifrost_tiler_heap_meta tiler_heap_meta_%"PRIx64"_%d = {\n", gpu_va, job_no); - pandecode_indent++; - - if (h->zero) { - pandecode_msg("XXX: tiler heap zero tripped\n"); - pandecode_prop("zero = 0x%x", h->zero); - } - - pandecode_prop("heap_size = 0x%x", h->heap_size); - MEMORY_PROP(h, tiler_heap_start); - MEMORY_PROP(h, tiler_heap_free); - - /* this might point to the beginning of another buffer, when it's - * really the end of the tiler heap buffer, so we have to be careful - * here. but for zero length, we need the same pointer. - */ - - if (h->tiler_heap_end == h->tiler_heap_start) { - MEMORY_PROP(h, tiler_heap_start); - } else { - char *a = pointer_as_memory_reference(h->tiler_heap_end - 1); - pandecode_prop("tiler_heap_end = %s + 1", a); - free(a); - } - - for (int i = 0; i < 10; i++) { - if (h->zeros[i] != 0) { - pandecode_msg("XXX: tiler heap zero %d tripped, value %x\n", - i, h->zeros[i]); - } - } - - if (h->unk1 != 0x1) { - pandecode_msg("XXX: tiler heap unk1 tripped\n"); - pandecode_prop("unk1 = 0x%x", h->unk1); - } - - if (h->unk7e007e != 0x7e007e) { - pandecode_msg("XXX: tiler heap unk7e007e tripped\n"); - pandecode_prop("unk7e007e = 0x%x", h->unk7e007e); - } - - pandecode_indent--; - pandecode_log("};\n"); + pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER_HEAP, h); + DUMP_UNPACKED(BIFROST_TILER_HEAP, h, "Bifrost Tiler Heap:\n"); } static void -pandecode_tiler_meta(mali_ptr gpu_va, int job_no) +pandecode_bifrost_tiler(mali_ptr gpu_va, int job_no) { struct pandecode_mapped_memory *mem = pandecode_find_mapped_gpu_mem_containing(gpu_va); - const struct bifrost_tiler_meta *PANDECODE_PTR_VAR(t, mem, gpu_va); + pan_unpack(PANDECODE_PTR(mem, gpu_va, void), BIFROST_TILER, t); - pandecode_tiler_heap_meta(t->tiler_heap_meta, job_no); + pandecode_bifrost_tiler_heap(t.heap, job_no); - pandecode_log("struct bifrost_tiler_meta tiler_meta_%"PRIx64"_%d = {\n", gpu_va, job_no); + DUMP_UNPACKED(BIFROST_TILER, t, "Bifrost Tiler:\n"); pandecode_indent++; - - pandecode_prop("tiler_heap_next_start = 0x%" PRIx32, t->tiler_heap_next_start); - pandecode_prop("used_hierarchy_mask = 0x%" PRIx32, t->used_hierarchy_mask); - - if (t->hierarchy_mask != 0xa && - t->hierarchy_mask != 0x14 && - t->hierarchy_mask != 0x28 && - t->hierarchy_mask != 0x50 && - t->hierarchy_mask != 0xa0) + if (t.hierarchy_mask != 0xa && + t.hierarchy_mask != 0x14 && + t.hierarchy_mask != 0x28 && + t.hierarchy_mask != 0x50 && + t.hierarchy_mask != 0xa0) pandecode_prop("XXX: Unexpected hierarchy_mask (not 0xa, 0x14, 0x28, 0x50 or 0xa0)!"); - pandecode_prop("hierarchy_mask = 0x%" PRIx16, t->hierarchy_mask); - - pandecode_prop("flags = 0x%" PRIx16, t->flags); - - pandecode_prop("width = MALI_POSITIVE(%d)", t->width + 1); - pandecode_prop("height = MALI_POSITIVE(%d)", t->height + 1); - - if (t->zero0) { - pandecode_msg("XXX: tiler meta zero tripped\n"); - pandecode_prop("zero0 = 0x%" PRIx64, t->zero0); - } - - for (int i = 0; i < 12; i++) { - if (t->zeros[i] != 0) { - pandecode_msg("XXX: tiler heap zero %d tripped, value %" PRIx64 "\n", - i, t->zeros[i]); - } - } - pandecode_indent--; - pandecode_log("};\n"); } static void @@ -1720,7 +1652,7 @@ pandecode_tiler_job_bfr(const struct mali_job_descriptor_header *h, memcpy(&draw_packed, &t->postfix, sizeof(draw_packed)); pan_unpack(&draw_packed, DRAW, draw); pandecode_vertex_tiler_postfix_pre(&draw, job_no, h->job_type, "", true, gpu_id); - pandecode_tiler_meta(t->tiler_meta, job_no); + pandecode_bifrost_tiler(t->tiler_meta, job_no); pandecode_vertex_tiler_prefix(&t->prefix, job_no, false); diff --git a/src/panfrost/lib/midgard.xml b/src/panfrost/lib/midgard.xml index 0514b86..4466e11 100644 --- a/src/panfrost/lib/midgard.xml +++ b/src/panfrost/lib/midgard.xml @@ -751,4 +751,34 @@
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.7.4