Fix depth clamping during 'very' early depth test.
We perform depth testing before computing scanline invariants, as an
optimization. But it was not taking into account that the
fixed-function depth value may require clamping due to the depth bias.
Bug swiftshader:82
Change-Id: I6f8953f9d060c73b5fe209b8cbad70e7cb7588b4
Reviewed-on: https://swiftshader-review.googlesource.com/13088
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Shader/PixelRoutine.cpp b/src/Shader/PixelRoutine.cpp
index 90e2073..e681fb4 100644
--- a/src/Shader/PixelRoutine.cpp
+++ b/src/Shader/PixelRoutine.cpp
@@ -94,12 +94,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);
-
- if(state.depthClamp)
- {
- z[q] = Min(Max(z[q], Float4(0.0f)), Float4(1.0f));
- }
+ z[q] = interpolate(x, Dz[q], z[q], primitive + OFFSET(Primitive,z), false, false, state.depthClamp);
}
}
@@ -146,7 +141,7 @@
if(interpolateW())
{
- w = interpolate(xxxx, Dw, rhw, primitive + OFFSET(Primitive,w), false, false);
+ w = interpolate(xxxx, Dw, rhw, primitive + OFFSET(Primitive,w), false, false, false);
rhw = reciprocal(w, false, false, true);
if(state.centroid)
@@ -163,7 +158,7 @@
{
if(!state.interpolant[interpolant].centroid)
{
- v[interpolant][component] = interpolate(xxxx, Dv[interpolant][component], rhw, primitive + OFFSET(Primitive, V[interpolant][component]), (state.interpolant[interpolant].flat & (1 << component)) != 0, state.perspective);
+ v[interpolant][component] = interpolate(xxxx, Dv[interpolant][component], rhw, primitive + OFFSET(Primitive, V[interpolant][component]), (state.interpolant[interpolant].flat & (1 << component)) != 0, state.perspective, false);
}
else
{
@@ -198,7 +193,7 @@
if(state.fog.component)
{
- f = interpolate(xxxx, Df, rhw, primitive + OFFSET(Primitive,f), state.fog.flat & 0x01, state.perspective);
+ f = interpolate(xxxx, Df, rhw, primitive + OFFSET(Primitive,f), state.fog.flat & 0x01, state.perspective, false);
}
setBuiltins(x, y, z, w);