Mesa (master): radv: initialize CMASK with correct clear codes

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Mar 22 10:28:16 UTC 2021


Module: Mesa
Branch: master
Commit: 35816188b72286cae6d5cc70e156f9825a9251e3
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=35816188b72286cae6d5cc70e156f9825a9251e3

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Wed Mar 17 10:27:37 2021 +0100

radv: initialize CMASK with correct clear codes

>From AMDVLK.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9650>

---

 src/amd/vulkan/radv_cmd_buffer.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index c5d8f628118..eb6a7cff8de 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -6179,10 +6179,17 @@ static void radv_handle_depth_image_transition(struct radv_cmd_buffer *cmd_buffe
 
 static void radv_initialise_cmask(struct radv_cmd_buffer *cmd_buffer,
 				  struct radv_image *image,
-				  const VkImageSubresourceRange *range,
-				  uint32_t value)
+				  const VkImageSubresourceRange *range)
 {
 	struct radv_cmd_state *state = &cmd_buffer->state;
+	static const uint32_t cmask_clear_values[4] = {
+		0xffffffff,
+		0xdddddddd,
+		0xeeeeeeee,
+		0xffffffff
+	};
+	uint32_t log2_samples = util_logbase2(image->info.samples);
+	uint32_t value = cmask_clear_values[log2_samples];
 	struct radv_barrier_data barrier = {0};
 
 	barrier.layout_transitions.init_mask_ram = 1;
@@ -6280,23 +6287,7 @@ static void radv_init_color_image_metadata(struct radv_cmd_buffer *cmd_buffer,
 					   const VkImageSubresourceRange *range)
 {
 	if (radv_image_has_cmask(image)) {
-		uint32_t value = 0xffffffffu; /* Fully expanded mode. */
-
-		/*  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_is_tc_compat_cmask(image) ||
-		    (radv_image_has_fmask(image) &&
-		     radv_layout_can_fast_clear(cmd_buffer->device, image, dst_layout,
-					       dst_render_loop, dst_queue_mask))) {
-			value = 0xccccccccu;
-		}
-
-		radv_initialise_cmask(cmd_buffer, image, range, value);
+		radv_initialise_cmask(cmd_buffer, image, range);
 	}
 
 	if (radv_image_has_fmask(image)) {



More information about the mesa-commit mailing list