Clamp blend factors and color output
The spec requires that input to the blending stage is clamped to the
range of the color attachment's format.
The clamp that was performed at the end of blending has been moved to
the color write method. Only VK_FORMAT_B10G11R11_UFLOAT_PACK32 was
previously affected by that, but it already has a clamp in the
r11g11b10Pack() function.
These changes prepare for handling normalized formats in the floating-
point code path.
Bug: b/204322086
Change-Id: I7eba90afb98c8aace93ddabb3168f6752e0d4f31
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/58789
Tested-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Pipeline/PixelRoutine.hpp b/src/Pipeline/PixelRoutine.hpp
index 956f230..3b13ac1 100644
--- a/src/Pipeline/PixelRoutine.hpp
+++ b/src/Pipeline/PixelRoutine.hpp
@@ -79,6 +79,7 @@
void readPixel(int index, const Pointer<Byte> &cBuffer, const Int &x, Vector4s &pixel);
void blendFactorRGB(Vector4f &blendFactorRGB, const Vector4f &sourceColor, const Vector4f &destColor, VkBlendFactor colorBlendFactor, vk::Format format);
void blendFactorAlpha(Float4 &blendFactorAlpha, const Float4 &sourceAlpha, const Float4 &destAlpha, VkBlendFactor alphaBlendFactor, vk::Format format);
+ bool blendFactorCanExceedFormatRange(VkBlendFactor blendFactor, vk::Format format);
void writeStencil(Pointer<Byte> &sBuffer, const Int &x, const Int sMask[4], const Int zMask[4], const Int cMask[4], const SampleSet &samples);
void writeDepth(Pointer<Byte> &zBuffer, const Int &x, const Int zMask[4], const SampleSet &samples);
void occlusionSampleCount(const Int zMask[4], const Int sMask[4], const SampleSet &samples);