Mesa (main): radv: Deal with border colors with emulated ETC2.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 14 12:10:38 UTC 2021


Module: Mesa
Branch: main
Commit: a8078bab91c80aa7e49c1b9cf9181b8dc729a6b4
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a8078bab91c80aa7e49c1b9cf9181b8dc729a6b4

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Mon Dec  6 02:22:32 2021 +0100

radv: Deal with border colors with emulated ETC2.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14071>

---

 src/amd/vulkan/radv_image.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 7e09be00257..c6d7d2b3ad8 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -956,6 +956,18 @@ gfx10_make_texture_descriptor(struct radv_device *device, struct radv_image *ima
    unsigned type;
 
    desc = vk_format_description(vk_format);
+
+   /* For emulated ETC2 without alpha we need to override the format to a 3-componenent format, so
+    * that border colors work correctly (alpha forced to 1). Since Vulkan has no such format,
+    * this uses the Gallium formats to set the description. */
+   if (image->vk_format == VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK &&
+       vk_format == VK_FORMAT_R8G8B8A8_UNORM) {
+      desc = util_format_description(PIPE_FORMAT_R8G8B8X8_UNORM);
+   } else if (image->vk_format == VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK &&
+              vk_format == VK_FORMAT_R8G8B8A8_SRGB) {
+      desc = util_format_description(PIPE_FORMAT_R8G8B8X8_SRGB);
+   }
+
    img_format = gfx10_format_table[vk_format_to_pipe_format(vk_format)].img_format;
 
    radv_compose_swizzle(desc, mapping, swizzle);
@@ -1079,6 +1091,17 @@ si_make_texture_descriptor(struct radv_device *device, struct radv_image *image,
 
    desc = vk_format_description(vk_format);
 
+   /* For emulated ETC2 without alpha we need to override the format to a 3-componenent format, so
+    * that border colors work correctly (alpha forced to 1). Since Vulkan has no such format,
+    * this uses the Gallium formats to set the description. */
+   if (image->vk_format == VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK &&
+       vk_format == VK_FORMAT_R8G8B8A8_UNORM) {
+      desc = util_format_description(PIPE_FORMAT_R8G8B8X8_UNORM);
+   } else if (image->vk_format == VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK &&
+              vk_format == VK_FORMAT_R8G8B8A8_SRGB) {
+      desc = util_format_description(PIPE_FORMAT_R8G8B8X8_SRGB);
+   }
+
    radv_compose_swizzle(desc, mapping, swizzle);
 
    first_non_void = vk_format_get_first_non_void_channel(vk_format);



More information about the mesa-commit mailing list