From d226595210763bd031fa7fcd40ff79ca061edbaf Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 15 Sep 2020 19:55:47 +0100 Subject: [PATCH] radv: initialize with expanded cmask if the destination layout needs it If radv_layout_can_fast_clear() is false, 028C70_COMPRESSION is unset when the image is rendered to and CMASK isn't updated. This appears to cause FMASK to be ignored and the 0th sample to always be used. Signed-off-by: Rhys Perry Reviewed-by: Bas Nieuwenhuizen Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3449 Fixes: 7b21ce401f7e81deca5ab6a4353b1369d059bcee ('radv: disable FMASK compression when drawing with GENERAL layout') Part-of: (cherry picked from commit 85cc2950a045ca0fe153498fb7d48322d2906482) --- .pick_status.json | 2 +- src/amd/vulkan/radv_cmd_buffer.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index bf045feb5df..b0cee274fa1 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -22,7 +22,7 @@ "description": "radv: initialize with expanded cmask if the destination layout needs it", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "7b21ce401f7e81deca5ab6a4353b1369d059bcee" }, diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c index ab1e1a6d2c8..af68af599a3 100644 --- a/src/amd/vulkan/radv_cmd_buffer.c +++ b/src/amd/vulkan/radv_cmd_buffer.c @@ -5517,8 +5517,16 @@ static void radv_init_color_image_metadata(struct radv_cmd_buffer *cmd_buffer, if (radv_image_has_cmask(image)) { uint32_t value = 0xffffffffu; /* Fully expanded mode. */ - /* TODO: clarify this. */ - if (radv_image_has_fmask(image)) { + /* TODO: clarify why 0xccccccccu is used. */ + + /* If CMASK isn't updated with the new layout, we should use the + * fully expanded mode so that the image is read correctly if + * CMASK is used (such as when transitioning to a compressed + * layout). + */ + if (radv_image_has_fmask(image) && + radv_layout_can_fast_clear(image, dst_layout, + dst_render_loop, dst_queue_mask)) { value = 0xccccccccu; }