From 93952916c6d26b6bf1b8d295fe580f9bf688f7b2 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Thu, 16 Feb 2023 09:21:38 +0100 Subject: [PATCH] v3dv: fix stencil view aspect selection of depth/stencil image MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Instead of fixing the swizzle to X001, we should compose this swizzle with the image view's own swizzle. Reviewed-by: Alejandro Piñeiro Part-of: --- src/broadcom/vulkan/v3dv_image.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_image.c b/src/broadcom/vulkan/v3dv_image.c index 5350188..325cc7c 100644 --- a/src/broadcom/vulkan/v3dv_image.c +++ b/src/broadcom/vulkan/v3dv_image.c @@ -635,23 +635,26 @@ create_image_view(struct v3dv_device *device, * we want to re-interpret the format as RGBA8_UINT, then map our stencil * data reads to the R component and ignore the GBA channels that contain * the depth aspect data. + * + * FIXME: thwe code belows calls vk_component_mapping_to_pipe_swizzle + * only so it can then call util_format_compose_swizzles later. Maybe it + * makes sense to implement swizzle composition using VkSwizzle directly. */ VkFormat format; uint8_t image_view_swizzle[4]; if (pCreateInfo->format == VK_FORMAT_D24_UNORM_S8_UINT && range->aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT) { format = VK_FORMAT_R8G8B8A8_UINT; - image_view_swizzle[0] = PIPE_SWIZZLE_X; - image_view_swizzle[1] = PIPE_SWIZZLE_0; - image_view_swizzle[2] = PIPE_SWIZZLE_0; - image_view_swizzle[3] = PIPE_SWIZZLE_1; + uint8_t stencil_aspect_swizzle[4] = { + PIPE_SWIZZLE_X, PIPE_SWIZZLE_0, PIPE_SWIZZLE_0, PIPE_SWIZZLE_1, + }; + uint8_t view_swizzle[4]; + vk_component_mapping_to_pipe_swizzle(iview->vk.swizzle, view_swizzle); + + util_format_compose_swizzles(stencil_aspect_swizzle, view_swizzle, + image_view_swizzle); } else { format = pCreateInfo->format; - - /* FIXME: we are doing this vk to pipe swizzle mapping just to call - * util_format_compose_swizzles. Would be good to check if it would be - * better to reimplement the latter using vk component - */ vk_component_mapping_to_pipe_swizzle(iview->vk.swizzle, image_view_swizzle); } -- 2.7.4