From 76e18c23ded13d1c4791fe996a60254ba6947d00 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Wed, 2 Oct 2024 18:42:59 -0400 Subject: [PATCH] hk: fix store_op_none Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/vulkan/hk_cmd_draw.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/asahi/vulkan/hk_cmd_draw.c b/src/asahi/vulkan/hk_cmd_draw.c index a3e81360f45..7bcf742cb15 100644 --- a/src/asahi/vulkan/hk_cmd_draw.c +++ b/src/asahi/vulkan/hk_cmd_draw.c @@ -367,6 +367,38 @@ hk_build_bg_eot(struct hk_cmd_buffer *cmd, const VkRenderingInfo *info, /* Don't read back spilled render targets, they're already in memory */ load &= !key.tib.spilled[i]; + /* This is a very frustrating corner case. From the spec: + * + * VK_ATTACHMENT_STORE_OP_NONE specifies the contents within the + * render area are not accessed by the store operation as long as + * no values are written to the attachment during the render pass. + * + * With VK_ATTACHMENT_STORE_OP_NONE, we suppress stores on the main + * end-of-tile program. Unfortunately, that's not enough: we also need + * to preserve the contents throughout partial renders. The easiest way + * to do that is forcing a load in the background program, so that + * partial stores for unused attachments will be no-op'd by writing + * existing contents. + * + * Optimizing this would require nontrivial tracking. Fortunately, + * this is all Android gunk and we don't have to care too much for + * dekstop games. So do the simple thing. + * + * VK_ATTACHMENT_STORE_OP_DONT_CARE does not need this workaround, + * fortunately. It's just here as a temporary stopgap to workaround CTS + * issue #5369. + */ + bool no_store = + (att_info->storeOp == VK_ATTACHMENT_STORE_OP_NONE) || + (att_info->storeOp == VK_ATTACHMENT_STORE_OP_DONT_CARE); + + bool no_store_wa = no_store && !load && !clear; + if (no_store_wa) { + perf_debug(dev, "STORE_OP_NONE workaround"); + } + + load |= no_store_wa; + /* Don't apply clears for spilled render targets when we clear the * render area explicitly after. */