vk: Clamp depth export in FS

- PS3 matches OGL behavior where writing to the depth export
register results in clamping.
This commit is contained in:
kd-11 2020-01-01 21:52:07 +03:00 committed by kd-11
parent 4c20881f8f
commit c4e59b5115
1 changed files with 6 additions and 3 deletions

View File

@ -345,9 +345,12 @@ void VKFragmentDecompilerThread::insertMainEnd(std::stringstream & OS)
{ {
if (m_parr.HasParam(PF_PARAM_NONE, "vec4", "r1")) if (m_parr.HasParam(PF_PARAM_NONE, "vec4", "r1"))
{ {
//Depth writes are always from a fp32 register. See issues section on nvidia's NV_fragment_program spec // NOTE: Depth writes are always from a fp32 register. See issues section on nvidia's NV_fragment_program spec
//https://www.khronos.org/registry/OpenGL/extensions/NV/NV_fragment_program.txt // https://www.khronos.org/registry/OpenGL/extensions/NV/NV_fragment_program.txt
OS << " gl_FragDepth = r1.z;\n";
// NOTE: Depth writes in OpenGL (and by extension RSX) are clamped to 0,1 range.
// Indeed, hardware tests on realhw prove that even in depth float mode, values outside this range are clamped.
OS << " gl_FragDepth = _saturate(r1.z);\n";
} }
else else
{ {