v3dv: don't swap R/B channels for VK_FORMAT_R5B6G5_UNORM_PACK16

This corresponds to PIPE_FORMAT_B5G6R5_UNORM, which is the format that
is natively supported. Also, we can't swap R/B on 3-channel images!

Also, we should rely on the v3dv format table for this rather than
pipe format descriptions since we specify the expected correct swizzles
there for all supported formats. This, for example, gets us correct
beahvior for things like VK_FORMAT_B4G4R4A4_UNORM_PACK16 without
needing to special case it.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
diff --git a/src/broadcom/vulkan/v3dv_image.c b/src/broadcom/vulkan/v3dv_image.c
index 8633a7f..9e16792 100644
--- a/src/broadcom/vulkan/v3dv_image.c
+++ b/src/broadcom/vulkan/v3dv_image.c
@@ -449,11 +449,7 @@
    iview->vk_format = pCreateInfo->format;
    iview->format = v3dv_get_format(pCreateInfo->format);
    assert(iview->format && iview->format->supported);
-
-   const struct util_format_description *desc =
-      vk_format_description(iview->vk_format);
-   iview->swap_rb = desc->swizzle[0] == PIPE_SWIZZLE_Z &&
-                    iview->vk_format != VK_FORMAT_B5G6R5_UNORM_PACK16;
+   iview->swap_rb = iview->format->swizzle[0] == PIPE_SWIZZLE_Z;
 
    /* FIXME: should we just move this to
     * v3dv_get_internal_type_bpp_for_output_format instead?
diff --git a/src/broadcom/vulkan/v3dv_meta_copy.c b/src/broadcom/vulkan/v3dv_meta_copy.c
index 8f11f33..89fd78e 100644
--- a/src/broadcom/vulkan/v3dv_meta_copy.c
+++ b/src/broadcom/vulkan/v3dv_meta_copy.c
@@ -151,6 +151,13 @@
    }
 }
 
+static inline bool
+format_needs_rb_swap(VkFormat format)
+{
+   const uint8_t *swizzle = v3dv_get_format_swizzle(format);
+   return swizzle[0] == PIPE_SWIZZLE_Z;
+}
+
 static void
 get_internal_type_bpp_for_image_aspects(struct v3dv_image *image,
                                         VkImageAspectFlags aspect_mask,
@@ -452,10 +459,7 @@
          /* This is not a raw data copy (i.e. we are clearing the image),
           * so we need to make sure we respect the format swizzle.
           */
-         const struct util_format_description *desc =
-            vk_format_description(image->vk_format);
-         needs_rb_swap = desc->swizzle[0] == PIPE_SWIZZLE_Z &&
-                         image->vk_format != VK_FORMAT_B5G6R5_UNORM_PACK16;
+         needs_rb_swap = format_needs_rb_swap(image->vk_format);
       }
 
       load.r_b_swap = needs_rb_swap;
@@ -509,10 +513,7 @@
          needs_chan_reverse = true;
       } else if (!is_copy_from_buffer && !is_copy_to_buffer &&
                  (aspect & VK_IMAGE_ASPECT_COLOR_BIT)) {
-         const struct util_format_description *desc =
-            vk_format_description(image->vk_format);
-         needs_rb_swap = desc->swizzle[0] == PIPE_SWIZZLE_Z &&
-                         image->vk_format != VK_FORMAT_B5G6R5_UNORM_PACK16;
+         needs_rb_swap = format_needs_rb_swap(image->vk_format);
       }
 
       store.r_b_swap = needs_rb_swap;