From 373d9df7ceddcb45214d50f5375dd31c42d76927 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Thu, 16 Jan 2025 09:56:42 +0100 Subject: [PATCH] panvk/csf: Add a knob to force texture cache invalidation on RUN_FRAGMENT Applications tend to forget to describe subpass dependencies, especially when it comes to write -> read dependencies on attachments. The proprietary driver forces "others" invalidation as a workaround, and this invalidation even became implicit (done as part of the RUN_FRAGMENT) on v13+. We will consider adding a dri-conf hook for this option in the future, but for now, let's just keep it as an opt-in debug flag. Signed-off-by: Boris Brezillon Reviewed-by: Erik Faye-Lund Reviewed-by: Lars-Ivar Hesselberg Simonsen Part-of: --- src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c | 14 ++++++++++++++ src/panfrost/vulkan/panvk_instance.c | 1 + src/panfrost/vulkan/panvk_instance.h | 1 + 3 files changed, 16 insertions(+) diff --git a/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c b/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c index 00f57c0b0e8..18acab6e13b 100644 --- a/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c +++ b/src/panfrost/vulkan/csf/panvk_vX_cmd_draw.c @@ -2236,6 +2236,8 @@ static VkResult issue_fragment_jobs(struct panvk_cmd_buffer *cmdbuf) { struct panvk_device *dev = to_panvk_device(cmdbuf->vk.base.device); + struct panvk_instance *instance = + to_panvk_instance(dev->vk.physical->instance); const struct cs_tracing_ctx *tracing_ctx = &cmdbuf->state.cs[PANVK_SUBQUEUE_FRAGMENT].tracing; struct pan_fb_info *fbinfo = &cmdbuf->state.gfx.render.fb.info; @@ -2320,6 +2322,18 @@ issue_fragment_jobs(struct panvk_cmd_buffer *cmdbuf) cs_add64(b, cs_sr_reg64(b, 40), cs_sr_reg64(b, 40), (1 + PANVK_IR_LAST_PASS) * fbd_ir_pass_offset); + /* Applications tend to forget to describe subpass dependencies, especially + * when it comes to write -> read dependencies on attachments. The + * proprietary driver forces "others" invalidation as a workaround, and this + * invalidation even became implicit (done as part of the RUN_FRAGMENT) on + * v13+. We don't do that in panvk, but we provide a debug flag to help + * identify those issues. */ + if (unlikely(instance->debug_flags & PANVK_DEBUG_IMPLICIT_OTHERS_INV)) { + cs_flush_caches(b, 0, 0, true, length_reg, + cs_defer(0x0, SB_ID(IMM_FLUSH))); + cs_wait_slot(b, SB_ID(IMM_FLUSH), false); + } + cs_req_res(b, CS_FRAG_RES); if (cmdbuf->state.gfx.render.layer_count > 1) { struct cs_index layer_count = cs_sr_reg32(b, 47); diff --git a/src/panfrost/vulkan/panvk_instance.c b/src/panfrost/vulkan/panvk_instance.c index 78835c832f3..10f0ea5f296 100644 --- a/src/panfrost/vulkan/panvk_instance.c +++ b/src/panfrost/vulkan/panvk_instance.c @@ -40,6 +40,7 @@ static const struct debug_control panvk_debug_options[] = { {"cs", PANVK_DEBUG_CS}, {"copy_gfx", PANVK_DEBUG_COPY_GFX}, {"force_simultaneous", PANVK_DEBUG_FORCE_SIMULTANEOUS}, + {"implicit_others_inv", PANVK_DEBUG_IMPLICIT_OTHERS_INV}, {NULL, 0}}; VKAPI_ATTR VkResult VKAPI_CALL diff --git a/src/panfrost/vulkan/panvk_instance.h b/src/panfrost/vulkan/panvk_instance.h index aba96e49f5f..f600eef4d24 100644 --- a/src/panfrost/vulkan/panvk_instance.h +++ b/src/panfrost/vulkan/panvk_instance.h @@ -24,6 +24,7 @@ enum panvk_debug_flags { PANVK_DEBUG_CS = 1 << 8, PANVK_DEBUG_COPY_GFX = 1 << 9, PANVK_DEBUG_FORCE_SIMULTANEOUS = 1 << 10, + PANVK_DEBUG_IMPLICIT_OTHERS_INV = 1 << 11, }; #if defined(VK_USE_PLATFORM_WAYLAND_KHR) || \