Improve 565 and 5551 precision
As with 888 and 1010102, 565 and 5551 need to be rounded before being written.
Bug: b/146633956
Change-Id: Ifea2e8f187a276a1f49effedc377612dbe338057
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40368
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index c36f8a4..1f382e6 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -1233,6 +1233,17 @@
current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 10) + Short4(0x0020);
current.w = current.w - As<Short4>(As<UShort4>(current.w) >> 2) + Short4(0x2000);
break;
+ case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
+ current.x = current.x - As<Short4>(As<UShort4>(current.x) >> 5) + Short4(0x0400);
+ current.y = current.y - As<Short4>(As<UShort4>(current.y) >> 5) + Short4(0x0400);
+ current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 5) + Short4(0x0400);
+ current.w = current.w - As<Short4>(As<UShort4>(current.w) >> 1) + Short4(0x4000);
+ break;
+ case VK_FORMAT_R5G6B5_UNORM_PACK16:
+ current.x = current.x - As<Short4>(As<UShort4>(current.x) >> 5) + Short4(0x0400);
+ current.y = current.y - As<Short4>(As<UShort4>(current.y) >> 6) + Short4(0x0200);
+ current.z = current.z - As<Short4>(As<UShort4>(current.z) >> 5) + Short4(0x0400);
+ break;
default:
break;
}