Mesa (master): radv: Fix SRGB compute copies.

Bas Nieuwenhuizen bnieuwenhuizen at kemper.freedesktop.org
Mon May 21 08:37:43 UTC 2018


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

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Mon May 21 01:26:46 2018 +0200

radv: Fix SRGB compute copies.

SRGB stores are broken. We had compensation code in the
resolve path but none in the copy path. Since we don't
want any conversion and it does not matter for DCC,
just make everything UNORM instead.

This happened to cause wrong colors for the PRIME path, as
that uses image->buffer copies which always use the compute
path.

CC: 18.0 18.1 <mesa-stable at lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106587
Reviewed-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/radv_meta_copy.c |  2 ++
 src/amd/vulkan/vk_format.h      | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/src/amd/vulkan/radv_meta_copy.c b/src/amd/vulkan/radv_meta_copy.c
index 1f18886d2c..a4d3598266 100644
--- a/src/amd/vulkan/radv_meta_copy.c
+++ b/src/amd/vulkan/radv_meta_copy.c
@@ -94,6 +94,8 @@ blit_surf_for_image_level_layer(struct radv_image *image,
 	    !(radv_image_is_tc_compat_htile(image)))
 		format = vk_format_for_size(vk_format_get_blocksize(format));
 
+	format = vk_format_no_srgb(format);
+
 	return (struct radv_meta_blit2d_surf) {
 		.format = format,
 		.bs = vk_format_get_blocksize(format),
diff --git a/src/amd/vulkan/vk_format.h b/src/amd/vulkan/vk_format.h
index b8cb4f4ed3..933db4d961 100644
--- a/src/amd/vulkan/vk_format.h
+++ b/src/amd/vulkan/vk_format.h
@@ -417,6 +417,46 @@ vk_format_is_srgb(VkFormat format)
 }
 
 static inline VkFormat
+vk_format_no_srgb(VkFormat format)
+{
+	switch(format) {
+	case VK_FORMAT_R8_SRGB:
+		return VK_FORMAT_R8_UNORM;
+	case VK_FORMAT_R8G8_SRGB:
+		return VK_FORMAT_R8G8_UNORM;
+	case VK_FORMAT_R8G8B8_SRGB:
+		return VK_FORMAT_R8G8B8_UNORM;
+	case VK_FORMAT_B8G8R8_SRGB:
+		return VK_FORMAT_B8G8R8_UNORM;
+	case VK_FORMAT_R8G8B8A8_SRGB:
+		return VK_FORMAT_R8G8B8A8_UNORM;
+	case VK_FORMAT_B8G8R8A8_SRGB:
+		return VK_FORMAT_B8G8R8A8_UNORM;
+	case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
+		return VK_FORMAT_A8B8G8R8_UNORM_PACK32;
+	case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
+		return VK_FORMAT_BC1_RGB_UNORM_BLOCK;
+	case VK_FORMAT_BC1_RGBA_SRGB_BLOCK:
+		return VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
+	case VK_FORMAT_BC2_SRGB_BLOCK:
+		return VK_FORMAT_BC2_UNORM_BLOCK;
+	case VK_FORMAT_BC3_SRGB_BLOCK:
+		return VK_FORMAT_BC3_UNORM_BLOCK;
+	case VK_FORMAT_BC7_SRGB_BLOCK:
+		return VK_FORMAT_BC7_UNORM_BLOCK;
+	case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
+		return VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK;
+	case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
+		return VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK;
+	case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
+		return VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK;
+	default:
+		assert(!vk_format_is_srgb(format));
+		return format;
+	}
+}
+
+static inline VkFormat
 vk_format_stencil_only(VkFormat format)
 {
 	return VK_FORMAT_S8_UINT;




More information about the mesa-commit mailing list