Commit 81e08df2 by Alexis Hetu Committed by Alexis Hétu

Fix fragments depth values not being clamped

According to the Vulkan 1.2 spec: "For fixed-point depth buffers, fragment depth values are always limited to the range [0,1] by clamping after depth bias addition is performed. Fragment depth values are clamped even when the depth buffer uses a floating-point representation." So, unless the VK_EXT_depth_range_unrestricted extension is enabled, clamping should always occur. Bug: b/152634772 Change-Id: I2aee2aeb91efed7399580689fc0ffc0634b2f487 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43869 Presubmit-Ready: Alexis Hétu <sugoi@google.com> Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 9418b511
...@@ -123,7 +123,6 @@ const PixelProcessor::State PixelProcessor::update(const Context *context) const ...@@ -123,7 +123,6 @@ const PixelProcessor::State PixelProcessor::update(const Context *context) const
} }
state.occlusionEnabled = context->occlusionEnabled; state.occlusionEnabled = context->occlusionEnabled;
state.depthClamp = (context->depthBias != 0.0f) || (context->slopeDepthBias != 0.0f);
for(int i = 0; i < RENDERTARGETS; i++) for(int i = 0; i < RENDERTARGETS; i++)
{ {
......
...@@ -77,7 +77,6 @@ public: ...@@ -77,7 +77,6 @@ public:
bool depthTestActive; bool depthTestActive;
bool occlusionEnabled; bool occlusionEnabled;
bool perspective; bool perspective;
bool depthClamp;
BlendState blendState[RENDERTARGETS]; BlendState blendState[RENDERTARGETS];
......
...@@ -85,7 +85,7 @@ void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBu ...@@ -85,7 +85,7 @@ void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBu
x -= *Pointer<Float4>(constants + OFFSET(Constants, X) + q * sizeof(float4)); x -= *Pointer<Float4>(constants + OFFSET(Constants, X) + q * sizeof(float4));
} }
z[q] = interpolate(x, Dz[q], z[q], primitive + OFFSET(Primitive, z), false, false, state.depthClamp); z[q] = interpolate(x, Dz[q], z[q], primitive + OFFSET(Primitive, z), false, false, true);
} }
} }
......
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