Perform all blend operations in floating-point
In order to fix loss of precision issues, this CL performs all
blending operations in floating point. Concretely, the alphaBlend()
function which used shorts is gone and conversion functions have been
added after readPixel (in shorts) and before writeColor (in shorts).
Bug: b/204322086
Change-Id: Ifad29eaf5b145d49da8611be598343a28f3005f4
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/58668
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexis Hétu <sugoi@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Pipeline/PixelProgram.cpp b/src/Pipeline/PixelProgram.cpp
index 24d9499..1853b62 100644
--- a/src/Pipeline/PixelProgram.cpp
+++ b/src/Pipeline/PixelProgram.cpp
@@ -297,14 +297,14 @@
for(unsigned int q : samples)
{
Pointer<Byte> buffer = cBuffer[index] + q * *Pointer<Int>(data + OFFSET(DrawData, colorSliceB[index]));
+
+ Vector4f colorf = alphaBlend(index, buffer, c[index], x);
+
Vector4s color;
-
- color.x = convertFixed16(c[index].x, false);
- color.y = convertFixed16(c[index].y, false);
- color.z = convertFixed16(c[index].z, false);
- color.w = convertFixed16(c[index].w, false);
-
- alphaBlend(index, buffer, color, x);
+ color.x = convertFixed16(colorf.x, true);
+ color.y = convertFixed16(colorf.y, true);
+ color.z = convertFixed16(colorf.z, true);
+ color.w = convertFixed16(colorf.w, true);
writeColor(index, buffer, x, color, sMask[q], zMask[q], cMask[q]);
}
break;