Skip to content

Commit 5c5382a

Browse files
Vulkan/D3D12: Use BLEND_OP_MAX for alpha channel blending
Change the alpha blend operation from ADD to MAX in the blend-enabled pipeline states for both Vulkan and D3D12. This ensures the render target alpha channel is always 1.0 (since the background establishes alpha=1.0 and max(src, 1.0) preserves it) while leaving RGB blending with SRC_ALPHA / ONE_MINUS_SRC_ALPHA completely unchanged.
1 parent 4b4d82e commit 5c5382a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

gfx/drivers/d3d12.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ static D3D12_RENDER_TARGET_BLEND_DESC d3d12_blend_enable_desc = {
456456
D3D12_BLEND_OP_ADD,
457457
D3D12_BLEND_SRC_ALPHA,
458458
D3D12_BLEND_INV_SRC_ALPHA,
459-
D3D12_BLEND_OP_ADD,
459+
D3D12_BLEND_OP_MAX,
460460
D3D12_LOGIC_OP_NOOP,
461461
D3D12_COLOR_WRITE_ENABLE_ALL,
462462
};

gfx/drivers/vulkan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2628,7 +2628,7 @@ static void vulkan_init_pipelines(vk_t *vk)
26282628
blend_attachment.colorBlendOp = VK_BLEND_OP_ADD;
26292629
blend_attachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
26302630
blend_attachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
2631-
blend_attachment.alphaBlendOp = VK_BLEND_OP_ADD;
2631+
blend_attachment.alphaBlendOp = VK_BLEND_OP_MAX;
26322632

26332633
/* Glyph pipeline */
26342634
module_info.codeSize = sizeof(font_frag);

0 commit comments

Comments
 (0)