diff --git a/src/dxvk/dxvk_swapchain_blitter.cpp b/src/dxvk/dxvk_swapchain_blitter.cpp index bba23e74..4e3eabef 100644 --- a/src/dxvk/dxvk_swapchain_blitter.cpp +++ b/src/dxvk/dxvk_swapchain_blitter.cpp @@ -494,14 +494,24 @@ namespace dxvk { msState.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; msState.pSampleMask = &sampleMask; - VkPipelineColorBlendAttachmentState cbOpaqueAttachment = { }; - cbOpaqueAttachment.colorWriteMask = + VkPipelineColorBlendAttachmentState cbAttachment = { }; + cbAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; - VkPipelineColorBlendStateCreateInfo cbOpaqueState = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; - cbOpaqueState.attachmentCount = 1; - cbOpaqueState.pAttachments = &cbOpaqueAttachment; + if (key.needsBlending) { + cbAttachment.blendEnable = VK_TRUE; + cbAttachment.colorBlendOp = VK_BLEND_OP_ADD; + cbAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; + cbAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + cbAttachment.alphaBlendOp = VK_BLEND_OP_ADD; + cbAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + cbAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + } + + VkPipelineColorBlendStateCreateInfo cbState = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; + cbState.attachmentCount = 1; + cbState.pAttachments = &cbAttachment; static const std::array dynStates = { VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT, @@ -520,7 +530,7 @@ namespace dxvk { blitInfo.pViewportState = &vpState; blitInfo.pRasterizationState = &rsState; blitInfo.pMultisampleState = &msState; - blitInfo.pColorBlendState = &cbOpaqueState; + blitInfo.pColorBlendState = &cbState; blitInfo.pDynamicState = &dynState; blitInfo.layout = m_pipelineLayout; blitInfo.basePipelineIndex = -1; diff --git a/src/dxvk/dxvk_swapchain_blitter.h b/src/dxvk/dxvk_swapchain_blitter.h index 5b7d8f7d..d49f28f8 100644 --- a/src/dxvk/dxvk_swapchain_blitter.h +++ b/src/dxvk/dxvk_swapchain_blitter.h @@ -43,6 +43,8 @@ namespace dxvk { VkBool32 needsBlit = VK_FALSE; /// Bit indicating whether a gamma curve is to be applied. VkBool32 needsGamma = VK_FALSE; + /// Bit indicating whether alpha blending is required + VkBool32 needsBlending = VK_FALSE; size_t hash() const { DxvkHashState hash; @@ -53,6 +55,7 @@ namespace dxvk { hash.add(uint32_t(dstFormat)); hash.add(uint32_t(needsBlit)); hash.add(uint32_t(needsGamma)); + hash.add(uint32_t(needsBlending)); return hash; } @@ -63,7 +66,8 @@ namespace dxvk { && dstSpace == other.dstSpace && dstFormat == other.dstFormat && needsBlit == other.needsBlit - && needsGamma == other.needsGamma; + && needsGamma == other.needsGamma + && needsBlending == other.needsBlending; } };