From 3960355d47542feeb77d13bd72f28a9a102b8557 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 23 Jan 2019 05:36:49 +0100 Subject: [PATCH] [d3d11] Avoid redundant viewport updates in RSSetState Rise of the Tomb Raider changes its rasterizer state very frequently (once every handful of draws), and the viewport package is very large, so we should avoid sending it to the CS thread redundantly. We only need to update when the scissor test state has changed. --- src/d3d11/d3d11_context.cpp | 14 ++++++++++++-- src/d3d11/d3d11_rasterizer.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index aae1d2d4c..b5b719766 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -2688,14 +2688,24 @@ namespace dxvk { auto rasterizerState = static_cast(pRasterizerState); + bool currScissorEnable = m_state.rs.state != nullptr + ? m_state.rs.state->Desc()->ScissorEnable + : false; + + bool nextScissorEnable = rasterizerState != nullptr + ? rasterizerState->Desc()->ScissorEnable + : false; + if (m_state.rs.state != rasterizerState) { m_state.rs.state = rasterizerState; - + // In D3D11, the rasterizer state defines whether the // scissor test is enabled, so we have to update the // scissor rectangles as well. ApplyRasterizerState(); - ApplyViewportState(); + + if (currScissorEnable != nextScissorEnable) + ApplyViewportState(); } } diff --git a/src/d3d11/d3d11_rasterizer.h b/src/d3d11/d3d11_rasterizer.h index a2378d2c3..34dbbc1f3 100644 --- a/src/d3d11/d3d11_rasterizer.h +++ b/src/d3d11/d3d11_rasterizer.h @@ -34,6 +34,10 @@ namespace dxvk { void STDMETHODCALLTYPE GetDesc1( D3D11_RASTERIZER_DESC1* pDesc) final; + const D3D11_RASTERIZER_DESC1* Desc() const { + return &m_desc; + } + void BindToContext( const Rc& ctx);