1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-03 22:24:13 +01:00

[dxvk] Add blending toggle to swap chain blitter pipelines

This commit is contained in:
Philip Rebohle 2024-10-04 15:14:23 +02:00
parent 836e990dc5
commit dbaa4d8df4
2 changed files with 21 additions and 7 deletions

View File

@ -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<VkDynamicState, 2> 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;

View File

@ -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;
}
};