mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:50:52 +01:00
[PR #1703] [MERGED] d3d12: dual-source blending reads SV_Target1 at Location 0, Index 1 (RT-DUAL-SOURCE-BLEND) #1717
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1717
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1703
Author: @OreoFR
Created: 11/25/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142
Base:
main← Head:rt-dual-source-blend📝 Commits (10+)
70d3517d3d12_xs: blend state for slot 57 native pipelines from state blob A (RT-SLOT57-BLEND-STATE)2f44380docs: state blob A's colour-target registers, measured over the library (RT-SLOT57-BLEND-STATE)4e7b764d3d12_xs: integer render targets keep blending off in slot 57 native PSOs (RT-SLOT57-BLEND-STATE)f557637d3d12_xs: a native PSO whose blend state the device refuses is built with blending off on its stand-in targets (RT-SLOT57-BLEND-STATE)81f33dedocs: the stand-in-target fallback of RT-SLOT57-BLEND-STATEd763845d3d12: dual-source blending reads SV_Target1 at Location 0, Index 1 (RT-DUAL-SOURCE-BLEND)0000242runtime: register dual_source_fragment_test away from the slot 57 tests (RT-DUAL-SOURCE-BLEND)1943a92d3d12: lazy pipelines keep the dual-source remap, and a dual-source draw test (RT-DUAL-SOURCE-BLEND review)188207arun_gpu_tests: ps_m15_dual is run by d3d12_translated_draw_test, like ps_m15 (RT-DUAL-SOURCE-BLEND review)668d65bd3d12_xs: slot 57 retries only a pipeline that blends a B4G4R4A4 stand-in (RT-SLOT57-BLEND-STATE review)📊 Changes
14 files changed (+752 additions, -17 deletions)
View changed files
📝
docs/fspx.md(+47 -2)📝
runtime/CMakeLists.txt(+18 -3)📝
runtime/shims/d3d12_vulkan_device.cpp(+44 -3)📝
runtime/shims/d3d12_xs_native_pso.h(+66 -2)➕
runtime/shims/d3d12_xs_native_pso_fallback.h(+25 -0)➕
runtime/src/dual_source_fragment.h(+59 -0)📝
runtime/src/native_pso.h(+122 -1)📝
runtime/test/d3d12_translated_draw_test.cpp(+34 -5)➕
runtime/test/dual_source_fragment_test.cpp(+82 -0)➕
runtime/test/native_pso_blend_test.cpp(+148 -0)➕
runtime/test/native_pso_fallback_test.cpp(+73 -0)➕
runtime/test/shaders/ps_m15_dual.asm(+31 -0)📝
runtime/test/vk_test_device.h(+1 -0)📝
scripts/run_gpu_tests.py(+2 -1)📄 Description
Claimed in the coordination issue as: RT-DUAL-SOURCE-BLEND (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7157103042)
Depends on: #1671, #1592
This builds on #1671: its commits are the first five here and drop out once it merges. Like #1671, it has a one-line
#includeconflict with #1592. It merges cleanly with #1691, which is also stacked on #1671. The real-boot test also used #1558 and #1547 to get past the landing screen on NVIDIA; this change doesn't need them.What and why
D3D12 dual-source blending takes the second source from the pixel shader's
SV_Target1. The translator declaresSV_Target1as the colour output atLocation 1, which is right for two render targets. But Vulkan takes the second blend source fromLocation 0, Index 1(VK_BLEND_FACTOR_SRC1_*,dualSrcBlend). So no PSO that blends with aSRC1factor could be built correctly. #1671 therefore keeps the 1,937 slot 57 records that blend this way (CB_BLEND0 0xf1010f01: colourONE/SRC1_COLOR, alphaONE/SRC1_ALPHA, plus a fewINV_SRC1forms) on blending off.runtime/src/dual_source_fragment.h(standard library only),dual_source::remap:OutputatLocation 1toLocation 0and addsOpDecorate ... Index 1next to it;Location 2or above (Vulkan has one dual-source attachment), or already carries anIndex.runtime/shims/d3d12_vulkan_device.cpp: when an enabled target's blend usesD3D12_BLEND_(INV_)SRC1_COLOR/ALPHA, the fragment module is remapped at pipeline creation, beside the existingB4G4R4A4output rewrite. A refused module refuses the PSO throughstream_unsupported, as today. This applies to every graphics PSO, not only slot 57 ones.runtime/src/native_pso.h: #1671's blend mapping now takes theSRC1factors (SRC1_COLOR/INV_SRC1_COLORread as their alpha forms in the alpha factors). Only theBOTH_*factors and an unknownCOMB_FCNstay refused.runtime/test/dual_source_fragment_test.cpp(portable): hand-built word streams test the rewrite and each refusal. The input atLocation 1and theFragDepthbuiltin are left alone.native_pso_blend_testcovers theSRC1mappings. The layout note indocs/fspx.mdis updated.Tested
The game's own shaders. The 1,937 dual-source records use 1,457 distinct pixel shaders. All of them have their second colour output at
Location 1and nothing past it:spirv-val --target-env vulkan1.3;v_interp_p2_f16and similar).Aggregate counts only.
Real boot, retail 1.0.2.1, native Windows, with
LEONIDA_VK_VALIDATION=1. Build:main+ #1558 + #1547 + #1671 + this branch, fresh first-run profile, factory on.SRC1blend: the "keeps blending off (CB_BLEND0 f1010f01)" lines are gone.VUID-VkImageViewCreateInfo-image-12397(a BC7 view of an RGBA16F image).ctest on Windows:
dual_source_fragment,native_pso_blend,d3d12_pso_validation,xs_proxy_mockandxbox_native_base_drawpass.GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase). It's stacked on #1671, as stated above.docs/design.md, with how it was confirmed. (Not a translator change: the rewrite happens at pipeline creation; the measurement is indocs/fspx.md.)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.