1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-04-01 09:25:24 +02:00

[d3d9] Clamp depth bounds to 0..1 range

Silences validation errors in The Witcher 2.
This commit is contained in:
Philip Rebohle 2025-03-23 19:35:24 +01:00
parent f6fdb441cf
commit bdb9e4f814

View File

@ -7380,10 +7380,13 @@ namespace dxvk {
if (unlikely(m_flags.test(D3D9DeviceFlag::DirtyDepthBounds))) { if (unlikely(m_flags.test(D3D9DeviceFlag::DirtyDepthBounds))) {
m_flags.clr(D3D9DeviceFlag::DirtyDepthBounds); m_flags.clr(D3D9DeviceFlag::DirtyDepthBounds);
DxvkDepthBounds db; DxvkDepthBounds db = { };
db.enableDepthBounds = (m_state.renderStates[D3DRS_ADAPTIVETESS_X] == uint32_t(D3D9Format::NVDB)); db.enableDepthBounds = (m_state.renderStates[D3DRS_ADAPTIVETESS_X] == uint32_t(D3D9Format::NVDB));
db.minDepthBounds = bit::cast<float>(m_state.renderStates[D3DRS_ADAPTIVETESS_Z]);
db.maxDepthBounds = bit::cast<float>(m_state.renderStates[D3DRS_ADAPTIVETESS_W]); if (db.enableDepthBounds) {
db.minDepthBounds = std::clamp(bit::cast<float>(m_state.renderStates[D3DRS_ADAPTIVETESS_Z]), 0.0f, 1.0f);
db.maxDepthBounds = std::clamp(bit::cast<float>(m_state.renderStates[D3DRS_ADAPTIVETESS_W]), 0.0f, 1.0f);
}
EmitCs([ EmitCs([
cDepthBounds = db cDepthBounds = db