1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-12 04:08:52 +01:00

[d3d11] Filter redundant OMSetRenderTargets calls

Since rebinding render targets is a rather expensive
operation, we should avoid doing so whenever possible.

Affects Resident Evil 2 and Devil May Cry 5.
This commit is contained in:
Philip Rebohle 2019-08-26 23:59:08 +02:00
parent 4789790087
commit afc8e4c29d
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -2597,6 +2597,9 @@ namespace dxvk {
const UINT* pUAVInitialCounts) { const UINT* pUAVInitialCounts) {
D3D10DeviceLock lock = LockContext(); D3D10DeviceLock lock = LockContext();
bool needsUpdate = false;
bool needsSpill = false;
if (likely(NumRTVs != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL)) { if (likely(NumRTVs != D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL)) {
// Native D3D11 does not change the render targets if // Native D3D11 does not change the render targets if
// the parameters passed to this method are invalid. // the parameters passed to this method are invalid.
@ -2610,6 +2613,7 @@ namespace dxvk {
if (m_state.om.renderTargetViews[i] != rtv) { if (m_state.om.renderTargetViews[i] != rtv) {
m_state.om.renderTargetViews[i] = rtv; m_state.om.renderTargetViews[i] = rtv;
needsUpdate = true;
TestOmSrvHazards(rtv); TestOmSrvHazards(rtv);
} }
} }
@ -2618,14 +2622,13 @@ namespace dxvk {
if (m_state.om.depthStencilView != dsv) { if (m_state.om.depthStencilView != dsv) {
m_state.om.depthStencilView = dsv; m_state.om.depthStencilView = dsv;
needsUpdate = true;
TestOmSrvHazards(dsv); TestOmSrvHazards(dsv);
} }
m_state.om.maxRtv = NumRTVs; m_state.om.maxRtv = NumRTVs;
} }
bool spillRenderPass = false;
if (unlikely(NumUAVs || m_state.om.maxUav)) { if (unlikely(NumUAVs || m_state.om.maxUav)) {
uint32_t uavSlotId = computeUavBinding (DxbcProgramType::PixelShader, 0); uint32_t uavSlotId = computeUavBinding (DxbcProgramType::PixelShader, 0);
uint32_t ctrSlotId = computeUavCounterBinding(DxbcProgramType::PixelShader, 0); uint32_t ctrSlotId = computeUavCounterBinding(DxbcProgramType::PixelShader, 0);
@ -2652,13 +2655,14 @@ namespace dxvk {
TestOmSrvHazards(uav); TestOmSrvHazards(uav);
spillRenderPass = true; needsSpill = true;
} }
} }
} }
} }
BindFramebuffer(spillRenderPass); if (needsUpdate || needsSpill)
BindFramebuffer(needsSpill);
} }