From 2fabc90f4603f406610b205dd65041f756767b1b Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Sat, 16 Jul 2022 13:21:44 +0200 Subject: [PATCH] [dxvk] Add fast path for rasterizer state comparison --- src/dxvk/dxvk_context.cpp | 19 ++++++++----------- src/dxvk/dxvk_graphics_state.h | 4 ++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 19efd460b..81ec35e2c 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -2428,19 +2428,16 @@ namespace dxvk { m_flags.set(DxvkContextFlag::GpDirtyRasterizerState); } - if (m_state.gp.state.rs.depthClipEnable() != rs.depthClipEnable - || m_state.gp.state.rs.depthBiasEnable() != rs.depthBiasEnable - || m_state.gp.state.rs.polygonMode() != rs.polygonMode - || m_state.gp.state.rs.sampleCount() != rs.sampleCount - || m_state.gp.state.rs.conservativeMode() != rs.conservativeMode) { - m_state.gp.state.rs = DxvkRsInfo( - rs.depthClipEnable, - rs.depthBiasEnable, - rs.polygonMode, - rs.sampleCount, - rs.conservativeMode); + DxvkRsInfo rsInfo( + rs.depthClipEnable, + rs.depthBiasEnable, + rs.polygonMode, + rs.sampleCount, + rs.conservativeMode); + if (!m_state.gp.state.rs.eq(rsInfo)) { m_flags.set(DxvkContextFlag::GpDirtyPipelineState); + m_state.gp.state.rs = rsInfo; } } diff --git a/src/dxvk/dxvk_graphics_state.h b/src/dxvk/dxvk_graphics_state.h index 7e10c0d07..918f558b5 100644 --- a/src/dxvk/dxvk_graphics_state.h +++ b/src/dxvk/dxvk_graphics_state.h @@ -250,6 +250,10 @@ namespace dxvk { return VkConservativeRasterizationModeEXT(m_conservativeMode); } + bool eq(const DxvkRsInfo& other) const { + return !std::memcmp(this, &other, sizeof(*this)); + } + private: uint16_t m_depthClipEnable : 1;