diff --git a/src/dxvk/dxvk_context.cpp b/src/dxvk/dxvk_context.cpp index 502f3a71..48eb05f5 100644 --- a/src/dxvk/dxvk_context.cpp +++ b/src/dxvk/dxvk_context.cpp @@ -2405,7 +2405,8 @@ namespace dxvk { rs.depthBiasEnable, rs.polygonMode, rs.sampleCount, - rs.conservativeMode); + rs.conservativeMode, + rs.flatShading); if (!m_state.gp.state.rs.eq(rsInfo)) { m_flags.set(DxvkContextFlag::GpDirtyPipelineState); diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index 4a8e7a82..8e295e60 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -1050,6 +1050,10 @@ namespace dxvk { if (state.useDualSourceBlending()) return false; + // Flat shading requires patching the fragment shader + if (state.rs.flatShading() && m_shaders.fs->info().flatShadingInputs) + return false; + // Multisample state must match in this case, and the // library assumes that MSAA is disabled in this case. if (m_shaders.fs->flags().test(DxvkShaderFlag::HasSampleRateShading)) { diff --git a/src/dxvk/dxvk_graphics_state.h b/src/dxvk/dxvk_graphics_state.h index 5713115c..24c7dbb3 100644 --- a/src/dxvk/dxvk_graphics_state.h +++ b/src/dxvk/dxvk_graphics_state.h @@ -222,12 +222,14 @@ namespace dxvk { VkBool32 depthBiasEnable, VkPolygonMode polygonMode, VkSampleCountFlags sampleCount, - VkConservativeRasterizationModeEXT conservativeMode) + VkConservativeRasterizationModeEXT conservativeMode, + VkBool32 flatShading) : m_depthClipEnable (uint16_t(depthClipEnable)), m_depthBiasEnable (uint16_t(depthBiasEnable)), m_polygonMode (uint16_t(polygonMode)), m_sampleCount (uint16_t(sampleCount)), m_conservativeMode(uint16_t(conservativeMode)), + m_flatShading (uint16_t(flatShading)), m_reserved (0) { } VkBool32 depthClipEnable() const { @@ -250,6 +252,10 @@ namespace dxvk { return VkConservativeRasterizationModeEXT(m_conservativeMode); } + VkBool32 flatShading() const { + return VkBool32(m_flatShading); + } + bool eq(const DxvkRsInfo& other) const { return !std::memcmp(this, &other, sizeof(*this)); } @@ -261,7 +267,8 @@ namespace dxvk { uint16_t m_polygonMode : 2; uint16_t m_sampleCount : 5; uint16_t m_conservativeMode : 2; - uint16_t m_reserved : 5; + uint16_t m_flatShading : 1; + uint16_t m_reserved : 4; }; diff --git a/src/dxvk/dxvk_state_cache_types.h b/src/dxvk/dxvk_state_cache_types.h index d257325a..c2f81868 100644 --- a/src/dxvk/dxvk_state_cache_types.h +++ b/src/dxvk/dxvk_state_cache_types.h @@ -133,7 +133,8 @@ namespace dxvk { VkBool32(m_depthBiasEnable), VkPolygonMode(m_polygonMode), VkSampleCountFlags(m_sampleCount), - VkConservativeRasterizationModeEXT(m_conservativeMode)); + VkConservativeRasterizationModeEXT(m_conservativeMode), + VK_FALSE); } }; @@ -158,7 +159,8 @@ namespace dxvk { VkBool32(m_depthBiasEnable), VkPolygonMode(m_polygonMode), VkSampleCountFlags(m_sampleCount), - VkConservativeRasterizationModeEXT(m_conservativeMode)); + VkConservativeRasterizationModeEXT(m_conservativeMode), + VK_FALSE); } };