Mesa (master): radv: fix identity swizzle handling

Dave Airlie airlied at kemper.freedesktop.org
Thu Oct 13 18:46:16 UTC 2016


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Tue Oct 11 16:46:25 2016 +1000

radv: fix identity swizzle handling

The identity swizzle should operate exactly
like an .r = R, .g = G, .b = B, .a = A swizzle.

This fixes a bunch of the 16-bit BGRA blit tests
dEQP-VK.api.copy_and_blit.blit_image.all_formats.b4g4r4a4*

Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/vk_format.h | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/amd/vulkan/vk_format.h b/src/amd/vulkan/vk_format.h
index 7b78373..58ee3f7 100644
--- a/src/amd/vulkan/vk_format.h
+++ b/src/amd/vulkan/vk_format.h
@@ -32,6 +32,7 @@ extern "C" {
 
 #include <assert.h>
 #include <vulkan/vulkan.h>
+#include <util/macros.h>
 enum vk_format_layout {
 	/**
 	 * Formats with vk_format_block::width == vk_format_block::height == 1
@@ -257,12 +258,13 @@ vk_format_aspects(VkFormat format)
 }
 
 static inline enum vk_swizzle
-radv_swizzle_conv(int idx, const unsigned char chan[4], VkComponentSwizzle vk_swiz)
+radv_swizzle_conv(VkComponentSwizzle component, const unsigned char chan[4], VkComponentSwizzle vk_swiz)
 {
 	int x;
+
+	if (vk_swiz == VK_COMPONENT_SWIZZLE_IDENTITY)
+		vk_swiz = component;
 	switch (vk_swiz) {
-	case VK_COMPONENT_SWIZZLE_IDENTITY:
-		return chan[idx];
 	case VK_COMPONENT_SWIZZLE_ZERO:
 		return VK_SWIZZLE_0;
 	case VK_COMPONENT_SWIZZLE_ONE:
@@ -288,7 +290,7 @@ radv_swizzle_conv(int idx, const unsigned char chan[4], VkComponentSwizzle vk_sw
 				return x;
 		return VK_SWIZZLE_1;
 	default:
-		return chan[idx];
+		unreachable("Illegal swizzle");
 	}
 }
 
@@ -296,10 +298,10 @@ static inline void vk_format_compose_swizzles(const VkComponentMapping *mapping,
 					      const unsigned char swz[4],
 					      enum vk_swizzle dst[4])
 {
-	dst[0] = radv_swizzle_conv(0, swz, mapping->r);
-	dst[1] = radv_swizzle_conv(1, swz, mapping->g);
-	dst[2] = radv_swizzle_conv(2, swz, mapping->b);
-	dst[3] = radv_swizzle_conv(3, swz, mapping->a);
+	dst[0] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_R, swz, mapping->r);
+	dst[1] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_G, swz, mapping->g);
+	dst[2] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_B, swz, mapping->b);
+	dst[3] = radv_swizzle_conv(VK_COMPONENT_SWIZZLE_A, swz, mapping->a);
 }
 
 static inline bool




More information about the mesa-commit mailing list