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:
parent
0418c02ac3
commit
6dd82dfe03
@ -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();
|
||||
}
|
||||
|
||||
|
@ -985,6 +985,7 @@ namespace dxvk {
|
||||
|
||||
void emitOutputSetup();
|
||||
void emitOutputMapping();
|
||||
void emitOutputDepthClamp();
|
||||
|
||||
//////////////////////////////////////////
|
||||
// System value load methods (per shader)
|
||||
|
Loading…
x
Reference in New Issue
Block a user