[dxvk] Be consistent about enabling dynamic blend constants

This commit is contained in:
Philip Rebohle 2022-07-15 16:47:08 +02:00
parent 46a596dd84
commit 661a8cd258
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 11 additions and 20 deletions

View File

@ -285,21 +285,10 @@ namespace dxvk {
msSampleMask = state.ms.sampleMask() & ((1u << msInfo.rasterizationSamples) - 1);
msInfo.pSampleMask = &msSampleMask;
msInfo.alphaToCoverageEnable = state.ms.enableAlphaToCoverage();
}
bool DxvkGraphicsPipelineFragmentOutputState::useDynamicBlendConstants() const {
bool result = false;
for (uint32_t i = 0; i < MaxNumRenderTargets && !result; i++) {
result = cbAttachments[i].blendEnable
&& (util::isBlendConstantBlendFactor(cbAttachments[i].srcColorBlendFactor)
|| util::isBlendConstantBlendFactor(cbAttachments[i].dstColorBlendFactor)
|| util::isBlendConstantBlendFactor(cbAttachments[i].srcAlphaBlendFactor)
|| util::isBlendConstantBlendFactor(cbAttachments[i].dstAlphaBlendFactor));
}
return result;
// We need to be fully consistent with the pipeline state here, and
// while we could consistently infer it, just don't take any chances
cbUseDynamicBlendConstants = state.useDynamicBlendConstants();
}
@ -315,7 +304,8 @@ namespace dxvk {
&& msInfo.minSampleShading == other.msInfo.minSampleShading
&& msInfo.alphaToCoverageEnable == other.msInfo.alphaToCoverageEnable
&& msInfo.alphaToOneEnable == other.msInfo.alphaToOneEnable
&& msSampleMask == other.msSampleMask;
&& msSampleMask == other.msSampleMask
&& cbUseDynamicBlendConstants == other.cbUseDynamicBlendConstants;
for (uint32_t i = 0; i < rtInfo.colorAttachmentCount && eq; i++)
eq = rtColorFormats[i] == other.rtColorFormats[i];
@ -353,6 +343,7 @@ namespace dxvk {
hash.add(uint32_t(msInfo.alphaToCoverageEnable));
hash.add(uint32_t(msInfo.alphaToOneEnable));
hash.add(uint32_t(msSampleMask));
hash.add(uint32_t(cbUseDynamicBlendConstants));
for (uint32_t i = 0; i < rtInfo.colorAttachmentCount; i++)
hash.add(uint32_t(rtColorFormats[i]));
@ -384,7 +375,7 @@ namespace dxvk {
VkDynamicState dynamicState = VK_DYNAMIC_STATE_BLEND_CONSTANTS;
VkPipelineDynamicStateCreateInfo dyInfo = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO };
if (state.useDynamicBlendConstants()) {
if (state.cbUseDynamicBlendConstants) {
dyInfo.dynamicStateCount = 1;
dyInfo.pDynamicStates = &dynamicState;
}

View File

@ -99,12 +99,12 @@ namespace dxvk {
VkPipelineColorBlendStateCreateInfo cbInfo = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO };
VkPipelineMultisampleStateCreateInfo msInfo = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO };
uint32_t msSampleMask = 0u;
uint32_t msSampleMask = 0u;
VkBool32 cbUseDynamicBlendConstants = VK_FALSE;
std::array<VkPipelineColorBlendAttachmentState, MaxNumRenderTargets> cbAttachments = { };
std::array<VkFormat, MaxNumRenderTargets> rtColorFormats = { };
bool useDynamicBlendConstants() const;
bool eq(const DxvkGraphicsPipelineFragmentOutputState& other) const;
size_t hash() const;

View File

@ -747,7 +747,7 @@ namespace dxvk {
bool result = false;
for (uint32_t i = 0; i < MaxNumRenderTargets && !result; i++) {
result |= omBlend[i].blendEnable()
result |= rt.getColorFormat(i) && omBlend[i].blendEnable()
&& (util::isBlendConstantBlendFactor(omBlend[i].srcColorBlendFactor())
|| util::isBlendConstantBlendFactor(omBlend[i].dstColorBlendFactor())
|| util::isBlendConstantBlendFactor(omBlend[i].srcAlphaBlendFactor())