Pass unclamped fragcoord.z to shader

The Vulkan spec is being clarified to explain that the FragCoord passed to a shader should use the unclamped depth value and that only the depth test and depth write should use clamped values. Bug: b/184063472 Change-Id: Ic76c13512745abea2181475eff5147134a1bf147 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/54668 Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarSean Risser <srisser@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Commit-Queue: Sean Risser <srisser@google.com>
parent 90c0551c
......@@ -61,6 +61,7 @@ void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBu
Int zMask[4]; // Depth mask
Int sMask[4]; // Stencil mask
Float4 unclampedZ[4];
bool sampleShadingEnabled = state.sampleShadingEnabled;
float minSampleShading = state.minSampleShading;
......@@ -127,6 +128,7 @@ void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBu
z[q] += *Pointer<Float4>(primitive + OFFSET(Primitive, zBias), 16);
}
unclampedZ[q] = z[q];
if(state.depthClamp)
{
z[q] = Min(Max(z[q], Float4(state.minDepthClamp)), Float4(state.maxDepthClamp));
......@@ -233,7 +235,7 @@ void PixelRoutine::quad(Pointer<Byte> cBuffer[RENDERTARGETS], Pointer<Byte> &zBu
}
}
setBuiltins(x, y, z, w, cMask, sampleId);
setBuiltins(x, y, unclampedZ, w, cMask, sampleId);
for(uint32_t i = 0; i < state.numClipDistances; i++)
{
......
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