Repository navigation
D3D-240: blends into B8G8R8X8 render targets read destination alpha 1 - #1977
Merged
Merged
Conversation
B8G8R8X8 has no alpha, and WARP and AMD's D3D12 driver blend into it with destination alpha 1. Its Vulkan image is BGRA8, so the blend factors that read destination alpha read the X byte instead. For B8G8R8X8 render targets the PSO now turns DST_ALPHA into ONE, ONE_MINUS_DST_ALPHA into ZERO and the colour SRC_ALPHA_SATURATE into ZERO, in the colour and alpha factors alike. d3d12_draw_test blends a full-screen pass into B8G8R8X8 and B8G8R8A8 targets cleared with alpha 0.25 through the five factors that read destination alpha, and compares red, green and blue. The X byte is left out: WARP writes 0 there after a draw and AMD the blended alpha, and no view reads it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that blending into a B8G8R8X8 render target reads destination alpha as 1, which factors the PSO rewrites, and that what a draw leaves in the X byte is not defined. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 22, 2026
Contributor
|
Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51): no regression from this PR. RTX 4080 SUPER: 111/113 pass. On current |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: a B8G8R8X8 render target has no alpha, so D3D12 blends into it with destination alpha 1. The layer's Vulkan image for it is BGRA8 (#759), so the blend factors that read destination alpha read the X byte instead. For B8G8R8X8 render targets,
CreateGraphicsPipelineStatenow turnsDST_ALPHAintoONE,ONE_MINUS_DST_ALPHAintoZEROand the colourSRC_ALPHA_SATURATEintoZERO(its alpha form is 1 in both APIs), in the colour and alpha factors alike.Why: D3D-240 in #313 (the part #759 / D3D-87 left out); claim: #1745 (comment)
Measured on the host runtime before changing anything (RX 9060 XT with AMD's D3D12 driver, and WARP): a full-screen draw of (0.8, 0.6, 0.4, 0.3) into a 4x4 target cleared with (0.2, 0.4, 0.6, 0.25).
DEST_ALPHAINV_DEST_ALPHASRC_ALPHA_SATDEST_ALPHAINV_DEST_ALPHAB8G8R8X8_UNORM_SRGB blends the same way. What a draw leaves in the X byte differs between the two: WARP writes 0 after every draw, even with alpha out of the write mask, and AMD writes the blended alpha (computed with destination alpha 1), or 255 with alpha masked off. No view reads the X byte (#759), so the test leaves it out.
Tests:
d3d12_draw_test: a full-screen pass blended into B8G8R8X8_UNORM and B8G8R8A8_UNORM targets cleared to the same bytes (alpha 0.25), through the five factors above. Red, green and blue must follow the rule within one level: destination alpha 1 for B8G8R8X8, the stored 64/255 for B8G8R8A8.got B,G,R 0,38,51, channel 0 wants 204, the colour scaled by the X byte's 0.25).Tested:
6a6704df+ this PRd3d12_draw_test: 3/3 runs pass, and 3/3 withLEONIDA_VK_VALIDATION=1(0 validation errors), with the bundle-blend wait raised from 21 to 31 locally (fix(test): use monotonic fence value (31) for bundle blend pass in d3d12_draw_test #1807's change, not part of this PR). Without it, the bundle-blend check before the new block fails 2 runs in 3 on this GPU, the same on6a6704dfwithout this PR.d3d12_clear_test(197/197 readbacks matched WARP),d3d12_descriptor_test,d3d12_uav_clear_test,d3d12_vulkan_device_test: pass, with and withoutLEONIDA_VK_VALIDATION=1ctest --test-dir runtime\build -C RelWithDebInfo: 112/113, the same with validation. Onlyd3d12_computefails, atline 515: rt::d3d12_xs::device_proxy_ref_count(device.p) == 1, as on6a6704dfwithout this PR (d3d12_compute_test: release the slot-67 PSO before the device reference check #1898)python -I scripts\run_gpu_tests.py: 178 translated, 178 pass spirv-val; 164/173 pass and 9 skip, native wave64 and withLEONIDA_W64_EMULATE=1python -m compileall -q make_game.py tools tests,python -I make_game.py --help: pass;tests/semantic: 1644 OK; pytest-based tests: 1332 passed, 14 skipped;python -I tests/test_*.py: 178/180.test_cf_ref.pyandtest_world_names.pyfail on this Windows machine, and since this PR changes no Python file they fail on6a6704dftooNot in this PR:
IndependentBlendEnable = FALSE, a B8G8R8X8 and a B8G8R8A8 target in one PSO now get different Vulkan blend states, so a GPU withoutindependentBlendrefuses that PSO (E_NOTIMPL), as it already does for any per-target blend state.AI-assisted: written with Claude Code; reviewed and tested by me.
No game data, keys or decryption involved.
🤖 Generated with Claude Code