Mesa (master): radv: Add CPU color packing for VK_FORMAT_A2B10G10R10_UNORM_PACK32.

Dave Airlie airlied at kemper.freedesktop.org
Wed Feb 8 22:43:23 UTC 2017


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

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Wed Feb  8 18:19:58 2017 +0100

radv: Add CPU color packing for VK_FORMAT_A2B10G10R10_UNORM_PACK32.

For allowing fast color clears in the main render targets of dota2.

[airlied: fix clear_vals[1] as suggested by Andres.

Signed-off-by: Bas Nieuwenhuizen <basni at google.com>
Signed-off-by: Dave Airlie <airlied at redhat.com>

---

 src/amd/vulkan/radv_formats.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_formats.c b/src/amd/vulkan/radv_formats.c
index f18ecee..1188ee5 100644
--- a/src/amd/vulkan/radv_formats.c
+++ b/src/amd/vulkan/radv_formats.c
@@ -940,8 +940,12 @@ bool radv_format_pack_clear_color(VkFormat format,
 		clear_vals[1] |= ((uint16_t)util_iround(CLAMP(value->float32[3], 0.0f, 1.0f) * 0xffff)) << 16;
 		break;
 	case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
-		/* TODO */
-		return false;
+		clear_vals[0] = ((uint16_t)util_iround(CLAMP(value->float32[0], 0.0f, 1.0f) * 0x3ff)) & 0x3ff;
+		clear_vals[0] |= (((uint16_t)util_iround(CLAMP(value->float32[1], 0.0f, 1.0f) * 0x3ff)) & 0x3ff) << 10;
+		clear_vals[0] |= (((uint16_t)util_iround(CLAMP(value->float32[2], 0.0f, 1.0f) * 0x3ff)) & 0x3ff) << 20;
+		clear_vals[0] |= (((uint16_t)util_iround(CLAMP(value->float32[1], 0.0f, 1.0f) * 0x3)) & 0x3) << 30;
+		clear_vals[1] = 0;
+		return true;
 	case VK_FORMAT_R32G32_SFLOAT:
 		clear_vals[0] = fui(value->float32[0]);
 		clear_vals[1] = fui(value->float32[1]);




More information about the mesa-commit mailing list