From 352b46fe801222b92accea0d65d4da55d325f124 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Mon, 11 Dec 2017 13:07:27 +0100 Subject: [PATCH] [d3d11] Refactored state object binding --- src/d3d11/d3d11_context.cpp | 9 +++------ src/d3d11/d3d11_depth_stencil.cpp | 6 ++++++ src/d3d11/d3d11_depth_stencil.h | 5 ++--- src/d3d11/d3d11_rasterizer.cpp | 5 +++++ src/d3d11/d3d11_rasterizer.h | 5 ++--- 5 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/d3d11/d3d11_context.cpp b/src/d3d11/d3d11_context.cpp index 5e915e6f7..09aa5b1f8 100644 --- a/src/d3d11/d3d11_context.cpp +++ b/src/d3d11/d3d11_context.cpp @@ -1262,13 +1262,10 @@ namespace dxvk { if (m_state.rs.state != rasterizerState) { m_state.rs.state = rasterizerState; - if (rasterizerState != nullptr) { - m_context->setRasterizerState( - rasterizerState->GetDXVKRasterizerState()); - } else { - // Restore the initial state + if (rasterizerState != nullptr) + rasterizerState->BindToContext(m_context); + else this->SetDefaultRasterizerState(); - } // In D3D11, the rasterizer state defines // whether the scissor test is enabled, so diff --git a/src/d3d11/d3d11_depth_stencil.cpp b/src/d3d11/d3d11_depth_stencil.cpp index 535723912..6be5def8a 100644 --- a/src/d3d11/d3d11_depth_stencil.cpp +++ b/src/d3d11/d3d11_depth_stencil.cpp @@ -47,6 +47,12 @@ namespace dxvk { } + void D3D11DepthStencilState::BindToContext( + const Rc& ctx) { + ctx->setDepthStencilState(m_state); + } + + VkStencilOpState D3D11DepthStencilState::DecodeStencilOpState( const D3D11_DEPTH_STENCILOP_DESC& stencilDesc, const D3D11_DEPTH_STENCIL_DESC& desc) const { diff --git a/src/d3d11/d3d11_depth_stencil.h b/src/d3d11/d3d11_depth_stencil.h index b17697a9b..f697ae929 100644 --- a/src/d3d11/d3d11_depth_stencil.h +++ b/src/d3d11/d3d11_depth_stencil.h @@ -30,9 +30,8 @@ namespace dxvk { void GetDesc( D3D11_DEPTH_STENCIL_DESC* pDesc) final; - const DxvkDepthStencilState& GetDXVKDepthStencilState() const { - return m_state; - } + void BindToContext( + const Rc& ctx); private: diff --git a/src/d3d11/d3d11_rasterizer.cpp b/src/d3d11/d3d11_rasterizer.cpp index ec80c7a03..27d3e1ff9 100644 --- a/src/d3d11/d3d11_rasterizer.cpp +++ b/src/d3d11/d3d11_rasterizer.cpp @@ -86,4 +86,9 @@ namespace dxvk { *pDesc = m_desc; } + + void D3D11RasterizerState::BindToContext(const Rc& ctx) { + ctx->setRasterizerState(m_state); + } + } \ No newline at end of file diff --git a/src/d3d11/d3d11_rasterizer.h b/src/d3d11/d3d11_rasterizer.h index 6aadf7a77..a050fe450 100644 --- a/src/d3d11/d3d11_rasterizer.h +++ b/src/d3d11/d3d11_rasterizer.h @@ -29,9 +29,8 @@ namespace dxvk { void GetDesc( D3D11_RASTERIZER_DESC* pDesc) final; - const DxvkRasterizerState& GetDXVKRasterizerState() const { - return m_state; - } + void BindToContext( + const Rc& ctx); private: