From 67cbbf941751440d1d840112d61523f40aa77c3f Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 28 Dec 2022 16:14:14 -0500 Subject: [PATCH] panfrost: Use framebuffer pointer XML Rather than manipulating the raw pointers. This is cleaner. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 9 +++- src/panfrost/lib/genxml/decode.c | 6 --- src/panfrost/lib/genxml/decode_jm.c | 63 ++++++++++++++++------------ src/panfrost/lib/pan_cs.c | 10 +++-- src/panfrost/vulkan/panvk_vX_cmd_buffer.c | 4 -- 5 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index a35d0a5..2d72f8d 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -4381,8 +4381,6 @@ init_batch(struct panfrost_batch *batch) pan_pool_alloc_desc_aggregate( &batch->pool.base, PAN_DESC(FRAMEBUFFER), PAN_DESC(ZS_CRC_EXTENSION), PAN_DESC_ARRAY(MAX2(batch->key.nr_cbufs, 1), RENDER_TARGET)); - - batch->framebuffer.gpu |= MALI_FBD_TAG_IS_MFBD; #endif #if PAN_ARCH >= 6 @@ -4390,6 +4388,13 @@ init_batch(struct panfrost_batch *batch) #else /* On Midgard, the TLS is embedded in the FB descriptor */ batch->tls = batch->framebuffer; + +#if PAN_ARCH == 5 + pan_pack(&batch->tls.gpu, FRAMEBUFFER_POINTER, cfg) { + cfg.pointer = batch->framebuffer.gpu; + cfg.render_target_count = 1; /* a necessary lie */ + } +#endif #endif } diff --git a/src/panfrost/lib/genxml/decode.c b/src/panfrost/lib/genxml/decode.c index 35d9aac..5e05abd 100644 --- a/src/panfrost/lib/genxml/decode.c +++ b/src/panfrost/lib/genxml/decode.c @@ -107,12 +107,6 @@ pandecode_sample_locations(const void *fb) struct pandecode_fbd GENX(pandecode_fbd)(uint64_t gpu_va, bool is_fragment, unsigned gpu_id) { -#if PAN_ARCH >= 5 - /* We only see MFBDs on architectures that support them */ - assert(gpu_va & MALI_FBD_TAG_IS_MFBD); - gpu_va &= ~MALI_FBD_TAG_MASK; -#endif - const void *PANDECODE_PTR_VAR(fb, (mali_ptr)gpu_va); pan_section_unpack(fb, FRAMEBUFFER, PARAMETERS, params); DUMP_UNPACKED(FRAMEBUFFER_PARAMETERS, params, "Parameters:\n"); diff --git a/src/panfrost/lib/genxml/decode_jm.c b/src/panfrost/lib/genxml/decode_jm.c index 8df4a14..dff3a70 100644 --- a/src/panfrost/lib/genxml/decode_jm.c +++ b/src/panfrost/lib/genxml/decode_jm.c @@ -259,7 +259,21 @@ GENX(pandecode_dcd)(const struct MALI_DRAW *p, enum mali_job_type job_type, DUMP_ADDR(LOCAL_STORAGE, p->thread_storage & ~1, "Local Storage:\n"); #endif } else { -#if PAN_ARCH <= 5 +#if PAN_ARCH == 5 + /* On v5 only, the actual framebuffer pointer is tagged with extra + * metadata that we validate but do not print. + */ + pan_unpack(&p->fbd, FRAMEBUFFER_POINTER, ptr); + + if (!ptr.type || ptr.zs_crc_extension_present || + ptr.render_target_count != 1) { + + fprintf(pandecode_dump_stream, + "Unexpected framebuffer pointer settings"); + } + + GENX(pandecode_fbd)(ptr.pointer, false, gpu_id); +#elif PAN_ARCH == 4 GENX(pandecode_fbd)(p->fbd, false, gpu_id); #endif } @@ -307,13 +321,13 @@ GENX(pandecode_dcd)(const struct MALI_DRAW *p, enum mali_job_type job_type, pandecode_indent--; pandecode_log("\n"); - /* MRT blend fields are used whenever MFBD is used, with - * per-RT descriptors */ - + /* MRT blend fields are used on v5+. Technically, they are optional on v5 + * for backwards compatibility but we don't care about that. + */ #if PAN_ARCH >= 5 if ((job_type == MALI_JOB_TYPE_TILER || job_type == MALI_JOB_TYPE_FRAGMENT) && - (PAN_ARCH >= 6 || p->thread_storage & MALI_FBD_TAG_IS_MFBD)) { + PAN_ARCH >= 5) { void *blend_base = ((void *)cl) + pan_size(RENDERER_STATE); for (unsigned i = 0; i < fbd_info.rt_count; i++) { @@ -455,36 +469,31 @@ pandecode_fragment_job(mali_ptr job, unsigned gpu_id) struct mali_fragment_job_packed *PANDECODE_PTR_VAR(p, job); pan_section_unpack(p, FRAGMENT_JOB, PAYLOAD, s); - UNUSED struct pandecode_fbd info = - GENX(pandecode_fbd)(s.framebuffer, true, gpu_id); + uint64_t fbd_pointer; #if PAN_ARCH >= 5 - unsigned expected_tag = 0; - - /* Compute the tag for the tagged pointer. This contains the type of - * FBD (MFBD/SFBD), and in the case of an MFBD, information about which - * additional structures follow the MFBD header (an extra payload or - * not, as well as a count of render targets) */ - - expected_tag = MALI_FBD_TAG_IS_MFBD; - if (info.has_extra) - expected_tag |= MALI_FBD_TAG_HAS_ZS_RT; - - expected_tag |= MALI_FBD_TAG_IS_MFBD | (MALI_POSITIVE(info.rt_count) << 2); + /* On v5 and newer, the actual framebuffer pointer is tagged with extra + * metadata that we need to disregard. + */ + pan_unpack(&s.framebuffer, FRAMEBUFFER_POINTER, ptr); + fbd_pointer = ptr.pointer; +#else + /* On v4, the framebuffer pointer is untagged. */ + fbd_pointer = s.framebuffer; #endif - DUMP_UNPACKED(FRAGMENT_JOB_PAYLOAD, s, "Fragment Job Payload:\n"); + UNUSED struct pandecode_fbd info = + GENX(pandecode_fbd)(fbd_pointer, true, gpu_id); #if PAN_ARCH >= 5 - /* The FBD is a tagged pointer */ - - unsigned tag = (s.framebuffer & MALI_FBD_TAG_MASK); - - if (tag != expected_tag) - pandecode_log("// XXX: expected FBD tag %X but got %X\n", expected_tag, - tag); + if (!ptr.type || ptr.zs_crc_extension_present != info.has_extra || + ptr.render_target_count != info.rt_count) { + pandecode_log("invalid FBD tag\n"); + } #endif + DUMP_UNPACKED(FRAGMENT_JOB_PAYLOAD, s, "Fragment Job Payload:\n"); + pandecode_log("\n"); } diff --git a/src/panfrost/lib/pan_cs.c b/src/panfrost/lib/pan_cs.c index 45b578d..4e02305 100644 --- a/src/panfrost/lib/pan_cs.c +++ b/src/panfrost/lib/pan_cs.c @@ -717,7 +717,6 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev, const struct pan_fb_info *fb, const struct pan_tls_info *tls, const struct pan_tiler_context *tiler_ctx, void *out) { - unsigned tags = MALI_FBD_TAG_IS_MFBD; void *fbd = out; void *rtd = out + pan_size(FRAMEBUFFER); @@ -815,7 +814,6 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev, if (has_zs_crc_ext) { pan_emit_zs_crc_ext(fb, crc_rt, out + pan_size(FRAMEBUFFER)); rtd += pan_size(ZS_CRC_EXTENSION); - tags |= MALI_FBD_TAG_HAS_ZS_RT; } unsigned rt_count = MAX2(fb->rt_count, 1); @@ -832,9 +830,13 @@ GENX(pan_emit_fbd)(const struct panfrost_device *dev, if (i != crc_rt) *(fb->rts[i].crc_valid) = false; } - tags |= MALI_POSITIVE(MAX2(fb->rt_count, 1)) << 2; - return tags; + uint64_t tag = 0; + pan_pack(&tag, FRAMEBUFFER_POINTER, cfg) { + cfg.zs_crc_extension_present = has_zs_crc_ext; + cfg.render_target_count = MAX2(fb->rt_count, 1); + } + return tag; } #else /* PAN_ARCH == 4 */ unsigned diff --git a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c index 8de18c3..ad742705 100644 --- a/src/panfrost/vulkan/panvk_vX_cmd_buffer.c +++ b/src/panfrost/vulkan/panvk_vX_cmd_buffer.c @@ -181,7 +181,6 @@ panvk_per_arch(cmd_alloc_fb_desc)(struct panvk_cmd_buffer *cmdbuf) const struct pan_fb_info *fbinfo = &cmdbuf->state.fb.info; bool has_zs_ext = fbinfo->zs.view.zs || fbinfo->zs.view.s; - unsigned tags = MALI_FBD_TAG_IS_MFBD; batch->fb.info = cmdbuf->state.framebuffer; batch->fb.desc = @@ -190,9 +189,6 @@ panvk_per_arch(cmd_alloc_fb_desc)(struct panvk_cmd_buffer *cmdbuf) PAN_DESC_ARRAY(has_zs_ext ? 1 : 0, ZS_CRC_EXTENSION), PAN_DESC_ARRAY(MAX2(fbinfo->rt_count, 1), RENDER_TARGET)); - /* Tag the pointer */ - batch->fb.desc.gpu |= tags; - memset(&cmdbuf->state.fb.info.bifrost.pre_post.dcds, 0, sizeof(cmdbuf->state.fb.info.bifrost.pre_post.dcds)); } -- 2.7.4