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

[dxvk] Add flat shading field to pipeline state

This commit is contained in:
Philip Rebohle 2022-08-08 02:35:58 +02:00 committed by Philip Rebohle
parent 0adf64f085
commit a84beae112
4 changed files with 19 additions and 5 deletions

View File

@ -2405,7 +2405,8 @@ namespace dxvk {
rs.depthBiasEnable, rs.depthBiasEnable,
rs.polygonMode, rs.polygonMode,
rs.sampleCount, rs.sampleCount,
rs.conservativeMode); rs.conservativeMode,
rs.flatShading);
if (!m_state.gp.state.rs.eq(rsInfo)) { if (!m_state.gp.state.rs.eq(rsInfo)) {
m_flags.set(DxvkContextFlag::GpDirtyPipelineState); m_flags.set(DxvkContextFlag::GpDirtyPipelineState);

View File

@ -1050,6 +1050,10 @@ namespace dxvk {
if (state.useDualSourceBlending()) if (state.useDualSourceBlending())
return false; 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 // Multisample state must match in this case, and the
// library assumes that MSAA is disabled in this case. // library assumes that MSAA is disabled in this case.
if (m_shaders.fs->flags().test(DxvkShaderFlag::HasSampleRateShading)) { if (m_shaders.fs->flags().test(DxvkShaderFlag::HasSampleRateShading)) {

View File

@ -222,12 +222,14 @@ namespace dxvk {
VkBool32 depthBiasEnable, VkBool32 depthBiasEnable,
VkPolygonMode polygonMode, VkPolygonMode polygonMode,
VkSampleCountFlags sampleCount, VkSampleCountFlags sampleCount,
VkConservativeRasterizationModeEXT conservativeMode) VkConservativeRasterizationModeEXT conservativeMode,
VkBool32 flatShading)
: m_depthClipEnable (uint16_t(depthClipEnable)), : m_depthClipEnable (uint16_t(depthClipEnable)),
m_depthBiasEnable (uint16_t(depthBiasEnable)), m_depthBiasEnable (uint16_t(depthBiasEnable)),
m_polygonMode (uint16_t(polygonMode)), m_polygonMode (uint16_t(polygonMode)),
m_sampleCount (uint16_t(sampleCount)), m_sampleCount (uint16_t(sampleCount)),
m_conservativeMode(uint16_t(conservativeMode)), m_conservativeMode(uint16_t(conservativeMode)),
m_flatShading (uint16_t(flatShading)),
m_reserved (0) { } m_reserved (0) { }
VkBool32 depthClipEnable() const { VkBool32 depthClipEnable() const {
@ -250,6 +252,10 @@ namespace dxvk {
return VkConservativeRasterizationModeEXT(m_conservativeMode); return VkConservativeRasterizationModeEXT(m_conservativeMode);
} }
VkBool32 flatShading() const {
return VkBool32(m_flatShading);
}
bool eq(const DxvkRsInfo& other) const { bool eq(const DxvkRsInfo& other) const {
return !std::memcmp(this, &other, sizeof(*this)); return !std::memcmp(this, &other, sizeof(*this));
} }
@ -261,7 +267,8 @@ namespace dxvk {
uint16_t m_polygonMode : 2; uint16_t m_polygonMode : 2;
uint16_t m_sampleCount : 5; uint16_t m_sampleCount : 5;
uint16_t m_conservativeMode : 2; uint16_t m_conservativeMode : 2;
uint16_t m_reserved : 5; uint16_t m_flatShading : 1;
uint16_t m_reserved : 4;
}; };

View File

@ -133,7 +133,8 @@ namespace dxvk {
VkBool32(m_depthBiasEnable), VkBool32(m_depthBiasEnable),
VkPolygonMode(m_polygonMode), VkPolygonMode(m_polygonMode),
VkSampleCountFlags(m_sampleCount), VkSampleCountFlags(m_sampleCount),
VkConservativeRasterizationModeEXT(m_conservativeMode)); VkConservativeRasterizationModeEXT(m_conservativeMode),
VK_FALSE);
} }
}; };
@ -158,7 +159,8 @@ namespace dxvk {
VkBool32(m_depthBiasEnable), VkBool32(m_depthBiasEnable),
VkPolygonMode(m_polygonMode), VkPolygonMode(m_polygonMode),
VkSampleCountFlags(m_sampleCount), VkSampleCountFlags(m_sampleCount),
VkConservativeRasterizationModeEXT(m_conservativeMode)); VkConservativeRasterizationModeEXT(m_conservativeMode),
VK_FALSE);
} }
}; };