From ef55f836bcdd4ac8a2f7ef5d2bb7e003b16ec3ba Mon Sep 17 00:00:00 2001 From: Simon Perretta Date: Mon, 18 Sep 2023 10:04:15 +0100 Subject: [PATCH] pvr: texture swizzle depth/stencil fix With the currrent state of things when setting up the texture state word we need to make sure the swizzle is obtained from a format compatible with the TPU. Signed-off-by: Simon Perretta Co-authored-by: Luigi Santivetti Acked-by: Erik Faye-Lund Part-of: --- src/imagination/vulkan/pvr_image.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index 93202b99ebf..41ae3a9be97 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -322,7 +322,7 @@ VkResult pvr_CreateImageView(VkDevice _device, info.base_level = iview->vk.base_mip_level; info.mip_levels = iview->vk.level_count; info.extent = image->vk.extent; - info.aspect_mask = image->vk.aspects; + info.aspect_mask = iview->vk.aspects; info.is_cube = (info.type == VK_IMAGE_VIEW_TYPE_CUBE || info.type == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY); info.array_size = iview->vk.layer_count; @@ -341,7 +341,29 @@ VkResult pvr_CreateImageView(VkDevice _device, pvr_adjust_non_compressed_view(image, &info); vk_component_mapping_to_pipe_swizzle(iview->vk.swizzle, input_swizzle); - format_swizzle = pvr_get_format_swizzle(info.format); + + enum pipe_format pipe_format = + vk_format_to_pipe_format(iview->vk.view_format); + if (util_format_is_depth_or_stencil(pipe_format)) { + switch (pipe_format) { + case PIPE_FORMAT_S8_UINT: + pipe_format = PIPE_FORMAT_R8_UINT; + break; + + case PIPE_FORMAT_Z16_UNORM: + pipe_format = PIPE_FORMAT_R16_UINT; + break; + + case PIPE_FORMAT_Z32_FLOAT: + pipe_format = PIPE_FORMAT_R32_FLOAT; + break; + + default: + break; + } + } + format_swizzle = util_format_description(pipe_format)->swizzle; + util_format_compose_swizzles(format_swizzle, input_swizzle, info.swizzle); result = pvr_pack_tex_state(device,