int stencilValue = (m_testMode == MODE_STENCIL) ? dsPixelAccess.getPixStencil(x, y, z) : 0;
// Depth test should write to the depth buffer even when there is a discard in the fragment shader,
- // when early fragment tests are enabled.
+ // when early fragment tests are enabled. We allow some tolerance to account for precision error
+ // on depth writes.
if (m_testMode == MODE_DEPTH)
{
- if (m_useEarlyTests && ((x + y) < 31) && depthValue >= 0.5f)
+ float tolerance = 0.0001f;
+ if (m_useEarlyTests && ((x + y) < 31) && depthValue >= 0.50 + tolerance)
{
std::ostringstream error;
error << "Rendered depth value [ "<< x << ", " << y << ", " << z << "] is not correct: " << depthValue << " >= 0.5f";
}
// When early fragment tests are disabled, the depth test happens after the fragment shader, but as we are discarding
// all fragments, the stored value in the depth buffer should be the clear one (0.5f).
- if (!m_useEarlyTests && deAbs(depthValue - 0.5f) > 0.01f)
+ if (!m_useEarlyTests && deAbs(depthValue - 0.5f) > tolerance)
{
std::ostringstream error;
error << "Rendered depth value [ "<< x << ", " << y << ", " << z << "] is not correct: " << depthValue << " != 0.5f";