Commit 64da65bd by Alexis Hetu Committed by Alexis Hétu

Fix sRGB color clear

According to the Vulkan spec: 2.9.2. Conversion from Floating-Point to Normalized Fixed-Point "The conversion from a floating-point value f to the corresponding unsigned normalized fixed-point value c is defined by first clamping f to the range [0,1], then computing ..." Also, in section 18.3. Clear Values: "float32 are the color clear values when the format of the image or attachment is one of the formats in the Interpretation of Numeric Format table other than signed integer (SINT) or unsigned integer (UINT). Floating point values are automatically converted to the format of the image, with the clear value being treated as linear if the image is sRGB" Added a clamp to sRGB values to avoid getting out of bound values for the sRGB color space. Bug: b/151469361 Change-Id: I22615b807384904ca4fa887e93529d5a4b185d04 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/45090 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com>
parent d9ba4b7d
...@@ -58,7 +58,7 @@ void Blitter::clear(void *pixel, vk::Format format, vk::Image *dest, const vk::F ...@@ -58,7 +58,7 @@ void Blitter::clear(void *pixel, vk::Format format, vk::Image *dest, const vk::F
} }
float *pPixel = static_cast<float *>(pixel); float *pPixel = static_cast<float *>(pixel);
if(viewFormat.isUnsignedNormalized()) if(viewFormat.isUnsignedNormalized() || viewFormat.isSRGBformat())
{ {
pPixel[0] = sw::clamp(pPixel[0], 0.0f, 1.0f); pPixel[0] = sw::clamp(pPixel[0], 0.0f, 1.0f);
pPixel[1] = sw::clamp(pPixel[1], 0.0f, 1.0f); pPixel[1] = sw::clamp(pPixel[1], 0.0f, 1.0f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment