1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-02-20 19:54:19 +01:00

[dxbc] Clamp written depth value to (0.0, 1.0)

Fixes shadow issue in Overwatch (#738).
This commit is contained in:
Philip Rebohle 2018-11-22 17:39:10 +01:00
parent 0418c02ac3
commit 6dd82dfe03
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 25 additions and 0 deletions

View File

@ -5392,6 +5392,29 @@ namespace dxvk {
DxbcRegMask::firstN(vector.type.ccount));
}
}
void DxbcCompiler::emitOutputDepthClamp() {
// HACK: Some drivers do not clamp FragDepth to [minDepth..maxDepth]
// before writing to the depth attachment, but we do not have acccess
// to those. Clamp to [0..1] instead.
if (m_ps.builtinDepth) {
DxbcRegisterPointer ptr;
ptr.type = { DxbcScalarType::Float32, 1 };
ptr.id = m_ps.builtinDepth;
DxbcRegisterValue value = emitValueLoad(ptr);
value.id = m_module.opFClamp(
getVectorTypeId(ptr.type),
value.id,
m_module.constf32(0.0f),
m_module.constf32(1.0f));
emitValueStore(ptr, value,
DxbcRegMask::firstN(1));
}
}
DxbcRegisterValue DxbcCompiler::emitVsSystemValueLoad(
@ -6321,6 +6344,7 @@ namespace dxvk {
this->emitOutputSetup();
this->emitOutputMapping();
this->emitOutputDepthClamp();
this->emitFunctionEnd();
}

View File

@ -985,6 +985,7 @@ namespace dxvk {
void emitOutputSetup();
void emitOutputMapping();
void emitOutputDepthClamp();
//////////////////////////////////////////
// System value load methods (per shader)