diff options
author | Joshua Ashton <joshua@froggi.es> | 2020-02-14 22:19:22 +0300 |
---|---|---|
committer | Joshua Ashton <joshua@froggi.es> | 2020-02-14 22:19:22 +0300 |
commit | 7d3ec74b40e6c23d28e30c2c992ac165d365bf08 (patch) | |
tree | 1ee04007bc19b3b0afaf46c6c7bd413445d3db7d | |
parent | 0c16cc7749c6383f810bc8a8891c0914311dff74 (diff) |
[d3d9] Don't perform clipping in FF if disabledd3d9-ff-clipping-inv-view
Avoids unnecessary matrix multiplications in the shader, given this isn't as cheap as it is for programmable.
-rw-r--r-- | src/d3d9/d3d9_device.cpp | 12 | ||||
-rw-r--r-- | src/d3d9/d3d9_device.h | 4 | ||||
-rw-r--r-- | src/d3d9/d3d9_fixed_function.cpp | 3 | ||||
-rw-r--r-- | src/d3d9/d3d9_fixed_function.h | 2 |
4 files changed, 19 insertions, 2 deletions
diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index 9d5530be..7419cc48 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -1668,6 +1668,8 @@ namespace dxvk { bool changed = states[State] != Value; if (likely(changed)) { + const bool oldClipPlaneEnabled = IsClipPlaneEnabled(); + const bool oldDepthBiasEnabled = IsDepthBiasEnabled(); const bool oldATOC = IsAlphaToCoverageEnabled(); @@ -1836,9 +1838,15 @@ namespace dxvk { m_flags.set(D3D9DeviceFlag::DirtyRasterizerState); break; - case D3DRS_CLIPPLANEENABLE: + case D3DRS_CLIPPLANEENABLE: { + const bool clipPlaneEnabled = IsClipPlaneEnabled(); + + if (clipPlaneEnabled != oldClipPlaneEnabled) + m_flags.set(D3D9DeviceFlag::DirtyFFVertexShader); + m_flags.set(D3D9DeviceFlag::DirtyClipPlanes); break; + } case D3DRS_ALPHAREF: UpdatePushConstant<D3D9RenderStateItem::AlphaRef>(); @@ -5946,6 +5954,8 @@ namespace dxvk { key.Data.Contents.VertexBlendCount = m_state.renderStates[D3DRS_VERTEXBLEND] & 0xff; } + key.Data.Contents.VertexClipping = IsClipPlaneEnabled(); + EmitCs([ this, cKey = key, diff --git a/src/d3d9/d3d9_device.h b/src/d3d9/d3d9_device.h index fb825600..25174dc3 100644 --- a/src/d3d9/d3d9_device.h +++ b/src/d3d9/d3d9_device.h @@ -776,6 +776,10 @@ namespace dxvk { return m_state.renderStates[D3DRS_ZENABLE] && m_state.depthStencil != nullptr; } + inline bool IsClipPlaneEnabled() { + return m_state.renderStates[D3DRS_CLIPPLANEENABLE] != 0; + } + void BindMultiSampleState(); void BindBlendState(); diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index 22c9c20c..b4c459fc 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -1163,7 +1163,8 @@ namespace dxvk { uint32_t pointSize = m_module.opFClamp(m_floatType, pointInfo.defaultValue, pointInfo.min, pointInfo.max); m_module.opStore(m_vs.out.POINTSIZE, pointSize); - emitVsClipping(vtx); + if (m_vsKey.Data.Contents.VertexClipping) + emitVsClipping(vtx); } diff --git a/src/d3d9/d3d9_fixed_function.h b/src/d3d9/d3d9_fixed_function.h index 378685d3..f839e12e 100644 --- a/src/d3d9/d3d9_fixed_function.h +++ b/src/d3d9/d3d9_fixed_function.h @@ -107,6 +107,8 @@ namespace dxvk { uint32_t VertexBlendMode : 2; uint32_t VertexBlendIndexed : 1; uint32_t VertexBlendCount : 3; + + uint32_t VertexClipping : 1; } Contents; uint32_t Primitive[4]; |