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: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index 120661a..1e25645 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -123,7 +123,6 @@
}
state.occlusionEnabled = context->occlusionEnabled;
- state.depthClamp = (context->depthBias != 0.0f) || (context->slopeDepthBias != 0.0f);
for(int i = 0; i < RENDERTARGETS; i++)
{
diff --git a/src/Device/PixelProcessor.hpp b/src/Device/PixelProcessor.hpp
index e92065d..c140e0c 100644
--- a/src/Device/PixelProcessor.hpp
+++ b/src/Device/PixelProcessor.hpp
@@ -77,7 +77,6 @@
bool depthTestActive;
bool occlusionEnabled;
bool perspective;
- bool depthClamp;
BlendState blendState[RENDERTARGETS];
diff --git a/src/Pipeline/PixelRoutine.cpp b/src/Pipeline/PixelRoutine.cpp
index 25325fb..5c3f0c9 100644
--- a/src/Pipeline/PixelRoutine.cpp
+++ b/src/Pipeline/PixelRoutine.cpp
@@ -85,7 +85,7 @@
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);
}
}