d3d12: dual-source blending reads SV_Target1 at Location 0, Index 1 (RT-DUAL-SOURCE-BLEND) #1703

Manually merged
github merged 11 commits from gh-pr/1703/head into gh-pr/1703/base 2026-11-26 10:01:33 +00:00
Owner

@⁠OreoFR on GitHub · 2026-11-25 08:46 UTC · original
OreoFR:rt-dual-source-blend → main · +752 −17 · 14 files · 11 commits · merged 2026-11-25 13:46 UTC

Claimed in the coordination issue as: RT-DUAL-SOURCE-BLEND (#1608)

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 #include conflict 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 declares SV_Target1 as the colour output at Location 1, which is right for two render targets. But Vulkan takes the second blend source from Location 0, Index 1 (VK_BLEND_FACTOR_SRC1_*, dualSrcBlend). So no PSO that blends with a SRC1 factor could be built correctly. #1671 therefore keeps the 1,937 slot 57 records that blend this way (CB_BLEND0 0xf1010f01: colour ONE/SRC1_COLOR, alpha ONE/SRC1_ALPHA, plus a few INV_SRC1 forms) on blending off.

  • runtime/src/dual_source_fragment.h (standard library only), dual_source::remap:
    • moves the fragment module's non-builtin Output at Location 1 to Location 0 and adds OpDecorate ... Index 1 next to it;
    • refuses, leaving the words unchanged, a module that has no such output, has an output at Location 2 or above (Vulkan has one dual-source attachment), or already carries an Index.
  • runtime/shims/d3d12_vulkan_device.cpp: when an enabled target's blend uses D3D12_BLEND_(INV_)SRC1_COLOR/ALPHA, the fragment module is remapped at pipeline creation, beside the existing B4G4R4A4 output rewrite. A refused module refuses the PSO through stream_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 the SRC1 factors (SRC1_COLOR / INV_SRC1_COLOR read as their alpha forms in the alpha factors). Only the BOTH_* factors and an unknown COMB_FCN stay refused.
  • runtime/test/dual_source_fragment_test.cpp (portable): hand-built word streams test the rewrite and each refusal. The input at Location 1 and the FragDepth builtin are left alone. native_pso_blend_test covers the SRC1 mappings. The layout note in docs/fspx.md is 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 1 and nothing past it:

    • 1,378 have a module in the #1592 graphics census; each one, rewritten as above, passes spirv-val --target-env vulkan1.3;
    • the other 79 have no module because the translator refuses them for other reasons (v_interp_p2_f16 and 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.

    • The slot 57 dual-source pipelines, which the title creates at startup, are built with their decoded SRC1 blend: the "keeps blending off (CB_BLEND0 f1010f01)" lines are gone.
    • No pipeline is refused and the device isn't lost. The validation layer reported no pipeline or shader error; its one message is an unrelated, existing VUID-VkImageViewCreateInfo-image-12397 (a BC7 view of an RGBA16F image).
    • The first-run pages draw as with #1671.
    • These pipelines draw 3D content, so their visual effect can't be seen before a world frame.
  • ctest on Windows: dual_source_fragment, native_pso_blend, d3d12_pso_validation, xs_proxy_mock and xbox_native_base_draw pass.

GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase). It's stacked on #1671, as stated above.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not a translator change: the rewrite happens at pipeline creation; the measurement is in docs/fspx.md.)

🤖 Generated with Claude Code

**@⁠OreoFR** on GitHub · 2026-11-25 08:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703) `OreoFR:rt-dual-source-blend` → `main` · +752 −17 · 14 files · 11 commits · merged 2026-11-25 13:46 UTC Claimed in the coordination issue as: RT-DUAL-SOURCE-BLEND (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) 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 `#include` conflict 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 declares `SV_Target1` as the colour output at `Location 1`, which is right for two render targets. But Vulkan takes the second blend source from `Location 0, Index 1` (`VK_BLEND_FACTOR_SRC1_*`, `dualSrcBlend`). So no PSO that blends with a `SRC1` factor could be built correctly. #1671 therefore keeps the 1,937 slot 57 records that blend this way (`CB_BLEND0 0xf1010f01`: colour `ONE`/`SRC1_COLOR`, alpha `ONE`/`SRC1_ALPHA`, plus a few `INV_SRC1` forms) on blending off. - **`runtime/src/dual_source_fragment.h`** (standard library only), `dual_source::remap`: - moves the fragment module's non-builtin `Output` at `Location 1` to `Location 0` and adds `OpDecorate ... Index 1` next to it; - refuses, leaving the words unchanged, a module that has no such output, has an output at `Location 2` or above (Vulkan has one dual-source attachment), or already carries an `Index`. - **`runtime/shims/d3d12_vulkan_device.cpp`:** when an enabled target's blend uses `D3D12_BLEND_(INV_)SRC1_COLOR/ALPHA`, the fragment module is remapped at pipeline creation, beside the existing `B4G4R4A4` output rewrite. A refused module refuses the PSO through `stream_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 the `SRC1` factors (`SRC1_COLOR` / `INV_SRC1_COLOR` read as their alpha forms in the alpha factors). Only the `BOTH_*` factors and an unknown `COMB_FCN` stay refused. - **`runtime/test/dual_source_fragment_test.cpp`** (portable): hand-built word streams test the rewrite and each refusal. The input at `Location 1` and the `FragDepth` builtin are left alone. `native_pso_blend_test` covers the `SRC1` mappings. The layout note in `docs/fspx.md` is 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 1` and nothing past it: - 1,378 have a module in the #1592 graphics census; each one, rewritten as above, passes `spirv-val --target-env vulkan1.3`; - the other 79 have no module because the translator refuses them for other reasons (`v_interp_p2_f16` and 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. - The slot 57 dual-source pipelines, which the title creates at startup, are built with their decoded `SRC1` blend: the "keeps blending off (CB_BLEND0 f1010f01)" lines are gone. - No pipeline is refused and the device isn't lost. The validation layer reported no pipeline or shader error; its one message is an unrelated, existing `VUID-VkImageViewCreateInfo-image-12397` (a BC7 view of an RGBA16F image). - The first-run pages draw as with #1671. - These pipelines draw 3D content, so their visual effect can't be seen before a world frame. - **ctest on Windows:** `dual_source_fragment`, `native_pso_blend`, `d3d12_pso_validation`, `xs_proxy_mock` and `xbox_native_base_draw` pass. GPUs tested: NVIDIA GeForce RTX 4070 Laptop GPU, driver 591.59 (32.0.15.9159), Windows 11 AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). It's stacked on #1671, as stated above. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (Not a translator change: the rewrite happens at pipeline creation; the measurement is in `docs/fspx.md`.) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A library pipeline enables MAX on an R8_UINT target; the colour block bypasses
blending there, and D3D12 refuses the PSO.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On devices without renderable B4G4R4A4, the Vulkan layer refuses blending on the
RGBA8 stand-in (E_NOTIMPL). Turn blending off on those targets, then on every
target, before leaving the pipeline to the PC description path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A PSO whose blend state uses a SRC1 factor gets its fragment module's Location 1
colour output moved to Location 0 with Index 1, as Vulkan takes the second
source. Slot 57 native PSOs now map the SRC1 factors of state blob A.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A lazy graphics pipeline (the default) makes its stage words again in build()
through stage_words(), which replayed the B4G4R4A4 quantisation but not the
Location 0 / Index 1 remap. Both now go through rewrite_fragment(), the same at
creation and in a lazy build.

d3d12_translated_draw_test --dual-source draws ps_m15_dual (ps_m15 plus a
constant SV_Target1) with ONE + SRC1_COLOR / SRC1_ALPHA, lazy and at creation:
every covered pixel is exact. Without the lazy fix, NVIDIA still draws the
right colours but LEONIDA_VK_VALIDATION=1 reports 3 errors.

Found by kawaii-shakal's review of #1703.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The generic pixel-shader harness picked up the new fixture and lost the device on an RTX 4060: it has no second
colour target and no SRC1 blend. d3d12_translated_draw_test --dual-source owns that draw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
adrianmjim's review: the blend fallback ran on any E_NOTIMPL, which also stands for
refusals unrelated to blending (stream_unsupported, mesh limits, FullyCovered, and
#1703's dual-source refusal). Such a pipeline was retried with blending off, logged as
a blend refusal, and, if the retry succeeded, drew without the blend the title asked for.

Now only a pipeline with a blended B4G4R4A4 target is retried, with blending off on
those targets alone (without_stand_in_blend, its own header), and the line is printed
only when that retry succeeds. The "every target" step is gone: no real boot used it
(RTX 4070 Laptop and kawaii-shakal's RTX 5070 Ti only ever logged the B4G4R4A4 step).
native_pso_fallback_test covers the decision.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	docs/fspx.md
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:01:26 +00:00
github manually merged commit b19b00e88a into gh-pr/1703/base 2026-11-26 10:01:33 +00:00
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 09:45 UTC · original · reviewed

Review (read-only, not run): one likely bug in the lazy path.

Lazy pipelines lose the dual-source remap. PipelineState remaps the fragment module (dual_source::remap(stage.words)) at creation. But graphics pipelines are lazy by default (lazy_graphics_pipelines(), off only with LEONIDA_LAZY_PIPELINES=0). When a lazy pipeline is first drawn, build() gets its SPIR-V again through stage_words(), and stage_words() replays rgba4::quantize (rgba4_mask_), link_f16_halves and depth24_patch_fragment, but not the dual-source remap. With the default settings a dual-source pipeline is therefore built with SV_Target1 still at Location 1 and SRC1 blend factors, which is invalid in Vulkan (the second source has to come from Location 0, Index 1). The blend reads an undefined second source, or a driver refuses the pipeline.

Suggested fix: keep a dual_source_ flag next to rgba4_mask_ and apply leonida::dual_source::remap(words[i]) to the fragment stage (source.slot == 2) in stage_words(), failing the same way. A ctest that creates a dual-source PSO with lazy pipelines on and draws it once would catch it.

If the slot 57 factory's pipelines never take the lazy path, please say so in the PR; the PC CreateGraphicsPipelineState path does.

Checked and fine: spirv() returns a copy, so the in-place remap does not leak into other pipelines that share the pixel shader. dualSrcBlend is already required and enabled on main (d3d12_vulkan_device.cpp ~7705 and ~16450).

AI-assisted review (Claude Code, Claude Opus 5.5).

**@⁠kawaii-shakal** on GitHub · 2026-11-25 09:45 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#pullrequestreview-6055208114) · **reviewed** Review (read-only, not run): one likely bug in the lazy path. **Lazy pipelines lose the dual-source remap.** `PipelineState` remaps the fragment module (`dual_source::remap(stage.words)`) at creation. But graphics pipelines are lazy by default (`lazy_graphics_pipelines()`, off only with `LEONIDA_LAZY_PIPELINES=0`). When a lazy pipeline is first drawn, `build()` gets its SPIR-V again through `stage_words()`, and `stage_words()` replays `rgba4::quantize` (`rgba4_mask_`), `link_f16_halves` and `depth24_patch_fragment`, but not the dual-source remap. With the default settings a dual-source pipeline is therefore built with `SV_Target1` still at `Location 1` and `SRC1` blend factors, which is invalid in Vulkan (the second source has to come from `Location 0, Index 1`). The blend reads an undefined second source, or a driver refuses the pipeline. Suggested fix: keep a `dual_source_` flag next to `rgba4_mask_` and apply `leonida::dual_source::remap(words[i])` to the fragment stage (`source.slot == 2`) in `stage_words()`, failing the same way. A ctest that creates a dual-source PSO with lazy pipelines on and draws it once would catch it. If the slot 57 factory's pipelines never take the lazy path, please say so in the PR; the PC `CreateGraphicsPipelineState` path does. Checked and fine: `spirv()` returns a copy, so the in-place remap does not leak into other pipelines that share the pixel shader. `dualSrcBlend` is already required and enabled on main (`d3d12_vulkan_device.cpp` ~7705 and ~16450). AI-assisted review (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠OreoFR on GitHub · 2026-11-25 10:09 UTC · original

@⁠kawaii-shakal thanks, that was a real bug. Fixed in 1943a92f7:

  • One rewrite for both paths. The fragment rewrites are now one member, rewrite_fragment(): the B4G4R4A4 quantisation, then the Location 0, Index 1 remap under a new dual_source_ flag. Both the creation path and stage_words() call it, so a lazy build() makes the same words as creation, and a refusal fails the same way in both.
  • A draw test. d3d12_translated_draw_test --dual-source draws ps_m15_dual.asm, which is ps_m15 plus a constant SV_Target1 (0.5), with ONE + SRC1_COLOR / SRC1_ALPHA over the clear colour. Every covered pixel must be exact. It runs twice, lazily (d3d12_dual_source_draw) and at creation (d3d12_dual_source_draw_eager, LEONIDA_LAZY_PIPELINES=0). The test device now enables dualSrcBlend where the GPU has it, and the test exits 77 where it doesn't. ps_m15_dual carries one more FSSM data word, because the layer finds a PSO's shader by FSSM hash and it would otherwise collide with ps_m15's.
  • What the test shows. Without the fix, the RTX 4070 Laptop still drew the right colours: NVIDIA appears to take Location 1 as the second source. So the colours alone don't catch it, but LEONIDA_VK_VALIDATION=1 does, with 3 errors on the secondary-color-input / max Location rule. With the fix, it's clean and all 4,064 covered pixels are exact.

The slot 57 factory goes through the same PC CreatePipelineState path, so it was affected too.

AI-assisted.

**@⁠OreoFR** on GitHub · 2026-11-25 10:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7159298627) @⁠kawaii-shakal thanks, that was a real bug. Fixed in `1943a92f7`: - **One rewrite for both paths.** The fragment rewrites are now one member, `rewrite_fragment()`: the `B4G4R4A4` quantisation, then the `Location 0, Index 1` remap under a new `dual_source_` flag. Both the creation path and `stage_words()` call it, so a lazy `build()` makes the same words as creation, and a refusal fails the same way in both. - **A draw test.** `d3d12_translated_draw_test --dual-source` draws `ps_m15_dual.asm`, which is ps_m15 plus a constant `SV_Target1` (0.5), with `ONE` + `SRC1_COLOR` / `SRC1_ALPHA` over the clear colour. Every covered pixel must be exact. It runs twice, lazily (`d3d12_dual_source_draw`) and at creation (`d3d12_dual_source_draw_eager`, `LEONIDA_LAZY_PIPELINES=0`). The test device now enables `dualSrcBlend` where the GPU has it, and the test exits 77 where it doesn't. `ps_m15_dual` carries one more FSSM data word, because the layer finds a PSO's shader by FSSM hash and it would otherwise collide with ps_m15's. - **What the test shows.** Without the fix, the RTX 4070 Laptop still drew the right colours: NVIDIA appears to take `Location 1` as the second source. So the colours alone don't catch it, but `LEONIDA_VK_VALIDATION=1` does, with 3 errors on the secondary-color-input / max `Location` rule. With the fix, it's clean and all 4,064 covered pixels are exact. The slot 57 factory goes through the same PC `CreatePipelineState` path, so it was affected too. AI-assisted.
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 11:01 UTC · original

Tested 1943a92f7 merged onto main bcaa13dad (clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 RelWithDebInfo + Ninja, llvm-mc 21.1.8.

  • Full ctest -j 6: all pass, including d3d12_dual_source_draw, d3d12_dual_source_draw_eager, d3d12_translated_draw, dual_source_fragment and native_pso_blend.
  • run_gpu_tests.py: one new failure vs main. The new ps_m15_dual.asm is picked up by the generic pixel-shader harness, and on this GPU it ends in a lost device, every time (3 of 3):
    FAIL  ps_m15_dual           device: NVIDIA GeForce RTX 4060 (subgroup 32..32)
    FAILED vkQueueWaitIdle(q) -> -4 (line 1181)
    
    ps_m15 is listed in OTHER_HARNESS in scripts/run_gpu_tests.py (run by d3d12_translated_draw_test) but ps_m15_dual isn't. With "ps_m15_dual": "d3d12_translated_draw_test" added there locally, the suite is back to main's result: 209/264 passed, 54 skipped, SKIP ps_m15_dual (run by d3d12_translated_draw_test).

AI-assisted testing (non-developer tester).

**@⁠potatoe0100** on GitHub · 2026-11-25 11:01 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7160476784) Tested `1943a92f7` merged onto `main` `bcaa13dad` (clean), native Windows 11 Pro 26H2 (build 26300), NVIDIA GeForce RTX 4060, driver 621.14, VS 2022 RelWithDebInfo + Ninja, llvm-mc 21.1.8. - Full `ctest -j 6`: all pass, including `d3d12_dual_source_draw`, `d3d12_dual_source_draw_eager`, `d3d12_translated_draw`, `dual_source_fragment` and `native_pso_blend`. - `run_gpu_tests.py`: one new failure vs `main`. The new `ps_m15_dual.asm` is picked up by the generic pixel-shader harness, and on this GPU it ends in a lost device, every time (3 of 3): ``` FAIL ps_m15_dual device: NVIDIA GeForce RTX 4060 (subgroup 32..32) FAILED vkQueueWaitIdle(q) -> -4 (line 1181) ``` `ps_m15` is listed in `OTHER_HARNESS` in `scripts/run_gpu_tests.py` (run by `d3d12_translated_draw_test`) but `ps_m15_dual` isn't. With `"ps_m15_dual": "d3d12_translated_draw_test"` added there locally, the suite is back to `main`'s result: 209/264 passed, 54 skipped, `SKIP ps_m15_dual (run by d3d12_translated_draw_test)`. AI-assisted testing (non-developer tester).
Author
Owner

@⁠OreoFR on GitHub · 2026-11-25 11:10 UTC · original

@⁠potatoe0100 thanks, good catch. ps_m15_dual is now in OTHER_HARNESS next to ps_m15 (188207a9d): run_gpu_tests.py still assembles and translates it, and d3d12_translated_draw_test --dual-source judges the draw. The generic pixel-shader harness has no second colour target or SRC1 blend for it, which is presumably why the 4060 lost the device. tests/test_run_gpu_tests.py passes (68 tests).

AI-assisted.

**@⁠OreoFR** on GitHub · 2026-11-25 11:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7160683001) @⁠potatoe0100 thanks, good catch. `ps_m15_dual` is now in `OTHER_HARNESS` next to `ps_m15` (`188207a9d`): `run_gpu_tests.py` still assembles and translates it, and `d3d12_translated_draw_test --dual-source` judges the draw. The generic pixel-shader harness has no second colour target or `SRC1` blend for it, which is presumably why the 4060 lost the device. `tests/test_run_gpu_tests.py` passes (68 tests). AI-assisted.
Author
Owner

@⁠adrianmjim on GitHub · 2026-11-25 11:24 UTC · original

Tested 1943a92f7 applied onto main 42537e7b6; 188207a9d since then only adds the OTHER_HARNESS entry. The test machine is AMD: Radeon RX 7900 XT (RDNA3), AMD driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022 RelWithDebInfo. No game files.

The new draw tests pass on AMD. d3d12_dual_source_draw (lazy) and d3d12_dual_source_draw_eager both print SV_Target1 blended as the second source (ONE + SRC1_COLOR / SRC1_ALPHA), 4064 of 4096 pixels exact. With dual_source_fragment, native_pso_blend, d3d12_translated_draw, d3d12_pso_validation, d3d12_state_sweep and xbox_native_base_draw that makes 8 of 8 pass, plain and with LEONIDA_VK_VALIDATION=1 (validation on, no messages). So the rewrite_fragment() fix works on this driver in both modes.

Whole ctest -j 6: 401 of 406 pass or skip. Three failures are the same as on main: d3d12_texture_tiles, d3d12_clear and d3d12_geometry_views. xmem and xmem_write_watch failed once under -j 6 and pass 3 of 3 alone. They are load-sensitive and have failed like that on other trees here too.

I did not run ps_m15_dual through run_gpu_tests.py. The lost device on the RTX 4060 above comes from the generic pixel harness picking it up, and 188207a9d's OTHER_HARNESS entry fixes that.

One thing that is still there: the slot 57 blend fallback fires on any E_NOTIMPL. if (hr == E_NOTIMPL && plan.state.blend) retries with blending off on B4G4R4A4 targets, and then on every target. E_NOTIMPL is also what stream_unsupported() and a few direct returns give for refusals that have nothing to do with B4G4R4A4: rect lists without the geometryShader feature or whose geometry stage can't be generated, mesh limits, two stages reading their code base, FullyCovered. This PR's own "outputs do not fit Location 0 Index 1" refusal is caught too, and the retry then turns the SRC1 blend off.

For any of those, a pipeline whose decoded blend differs from the default is retried with blending off. If the refusal had nothing to do with blending, that retry fails the same way, but the log still says "the device refused this pipeline's blend state". If it does succeed, the pipeline draws without the blending the title asked for. Checking that the refusal was the B4G4R4A4 one, for example with a distinct HRESULT or a flag set where that refusal is made, would keep the fallback to the case it is meant for.

**@⁠adrianmjim** on GitHub · 2026-11-25 11:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7161006670) Tested `1943a92f7` applied onto `main` `42537e7b6`; `188207a9d` since then only adds the `OTHER_HARNESS` entry. The test machine is AMD: Radeon RX 7900 XT (RDNA3), AMD driver 32.0.32029.2010 (26.11.2), Windows 11 build 26300, VS 2022 RelWithDebInfo. No game files. **The new draw tests pass on AMD.** `d3d12_dual_source_draw` (lazy) and `d3d12_dual_source_draw_eager` both print `SV_Target1 blended as the second source (ONE + SRC1_COLOR / SRC1_ALPHA), 4064 of 4096 pixels exact`. With `dual_source_fragment`, `native_pso_blend`, `d3d12_translated_draw`, `d3d12_pso_validation`, `d3d12_state_sweep` and `xbox_native_base_draw` that makes 8 of 8 pass, plain and with `LEONIDA_VK_VALIDATION=1` (validation on, no messages). So the `rewrite_fragment()` fix works on this driver in both modes. **Whole `ctest -j 6`:** 401 of 406 pass or skip. Three failures are the same as on `main`: `d3d12_texture_tiles`, `d3d12_clear` and `d3d12_geometry_views`. `xmem` and `xmem_write_watch` failed once under `-j 6` and pass 3 of 3 alone. They are load-sensitive and have failed like that on other trees here too. I did not run `ps_m15_dual` through `run_gpu_tests.py`. The lost device on the RTX 4060 above comes from the generic pixel harness picking it up, and `188207a9d`'s `OTHER_HARNESS` entry fixes that. **One thing that is still there: the slot 57 blend fallback fires on any `E_NOTIMPL`.** `if (hr == E_NOTIMPL && plan.state.blend)` retries with blending off on B4G4R4A4 targets, and then on every target. `E_NOTIMPL` is also what `stream_unsupported()` and a few direct returns give for refusals that have nothing to do with B4G4R4A4: rect lists without the geometryShader feature or whose geometry stage can't be generated, mesh limits, two stages reading their code base, FullyCovered. This PR's own "outputs do not fit Location 0 Index 1" refusal is caught too, and the retry then turns the SRC1 blend off. For any of those, a pipeline whose decoded blend differs from the default is retried with blending off. If the refusal had nothing to do with blending, that retry fails the same way, but the log still says "the device refused this pipeline's blend state". If it does succeed, the pipeline draws without the blending the title asked for. Checking that the refusal was the B4G4R4A4 one, for example with a distinct HRESULT or a flag set where that refusal is made, would keep the fallback to the case it is meant for.
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-25 11:33 UTC · original · reviewed

Built and tested on Windows 11 with MSVC 19.44 (scripts\build_runtime.ps1, incremental on the same build tree, after #1691), NVIDIA GeForce RTX 4060, driver 610.88. Head 188207a9d (it carries #1671's commits; branch point main 3f81d46ac, not merged with current main 237deb64c).

ctest -R "native_pso|dual_source|translated_draw|xs_proxy_mock|xbox_native_base_draw": 15/15 passed, including dual_source_fragment, native_pso_blend, and the GPU draws d3d12_translated_draw, xbox_native_base_draw, d3d12_dual_source_draw and d3d12_dual_source_draw_eager.

Not checked: the dual-source result in a real world frame, which needs a world frame my setup does not reach yet.

AI-assisted: yes (Claude Code ran the build and the tests; I read the results).

**@⁠MoonEyes** on GitHub · 2026-11-25 11:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#pullrequestreview-6056846738) · **reviewed** Built and tested on Windows 11 with MSVC 19.44 (`scripts\build_runtime.ps1`, incremental on the same build tree, after #1691), NVIDIA GeForce RTX 4060, driver 610.88. Head 188207a9d (it carries #1671's commits; branch point main 3f81d46ac, not merged with current main 237deb64c). `ctest -R "native_pso|dual_source|translated_draw|xs_proxy_mock|xbox_native_base_draw"`: 15/15 passed, including `dual_source_fragment`, `native_pso_blend`, and the GPU draws `d3d12_translated_draw`, `xbox_native_base_draw`, `d3d12_dual_source_draw` and `d3d12_dual_source_draw_eager`. Not checked: the dual-source result in a real world frame, which needs a world frame my setup does not reach yet. AI-assisted: yes (Claude Code ran the build and the tests; I read the results).
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-25 11:57 UTC · original

Tested as part of the #1671 + #1691 + #1703 stack (188207a9d) on main bcaa13dad, in a real boot on an RTX 5070 Ti (NVIDIA 617.42, Windows 11). Menu text renders as glyphs instead of solid blocks, and no pipeline is refused. Details: #1671. AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠kawaii-shakal** on GitHub · 2026-11-25 11:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7161724830) Tested as part of the #1671 + #1691 + #1703 stack (188207a9d) on `main` bcaa13dad, in a real boot on an RTX 5070 Ti (NVIDIA 617.42, Windows 11). Menu text renders as glyphs instead of solid blocks, and no pipeline is refused. Details: https://git.gtahub.st/github/ubiquitarianism--leonida/pulls/1671. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠OreoFR on GitHub · 2026-11-25 12:03 UTC · original

@⁠adrianmjim thanks for the AMD run, and you're right about the fallback. Fixed in #1671 (668d65b4b), merged into this branch (b19b00e88) and #1691 (7a769396d):

  • Only a pipeline that blends a B4G4R4A4 target is retried, with blending off on those targets alone (without_stand_in_blend, in its own header d3d12_xs_native_pso_fallback.h). Any other E_NOTIMPL is returned as it is, with the blend the title asked for. That includes this PR's "does not fit Location 0 Index 1" refusal.
  • The "every target" step is gone. No real boot used it: my RTX 4070 Laptop runs and kawaii-shakal's RTX 5070 Ti boot only ever logged the B4G4R4A4 step.
  • The line is printed only when that retry succeeds, and it now names the stand-in rather than "this pipeline's blend state".
  • New native_pso_fallback test covers the decision: a blended B4G4R4A4 target is retried, while no B4G4R4A4 target, a B4G4R4A4 target that doesn't blend, or one past NumRenderTargets leaves the description untouched.

On main 0d80bc5df + the three PRs (RTX 4070 Laptop, NVIDIA 621.40), ctest -R "native_pso|dual_source|translated_draw|xs_proxy_mock|xbox_native_base_draw" passes 17/17, and gta6rt builds.

AI-assisted.

**@⁠OreoFR** on GitHub · 2026-11-25 12:03 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7161862577) @⁠adrianmjim thanks for the AMD run, and you're right about the fallback. Fixed in #1671 (`668d65b4b`), merged into this branch (`b19b00e88`) and #1691 (`7a769396d`): - Only a pipeline that blends a `B4G4R4A4` target is retried, with blending off on those targets alone (`without_stand_in_blend`, in its own header `d3d12_xs_native_pso_fallback.h`). Any other `E_NOTIMPL` is returned as it is, with the blend the title asked for. That includes this PR's "does not fit Location 0 Index 1" refusal. - The "every target" step is gone. No real boot used it: my RTX 4070 Laptop runs and kawaii-shakal's RTX 5070 Ti boot only ever logged the `B4G4R4A4` step. - The line is printed only when that retry succeeds, and it now names the stand-in rather than "this pipeline's blend state". - New `native_pso_fallback` test covers the decision: a blended `B4G4R4A4` target is retried, while no `B4G4R4A4` target, a `B4G4R4A4` target that doesn't blend, or one past `NumRenderTargets` leaves the description untouched. On `main` `0d80bc5df` + the three PRs (RTX 4070 Laptop, NVIDIA 621.40), `ctest -R "native_pso|dual_source|translated_draw|xs_proxy_mock|xbox_native_base_draw"` passes 17/17, and `gta6rt` builds. AI-assisted.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 13:46 UTC · original

Merged. Thank you, @⁠OreoFR, and thanks to @⁠kawaii-shakal, @⁠potatoe0100 and @⁠adrianmjim for the findings and to @⁠MoonEyes for the independent pass.

  • Merges cleanly on current main and with #1691; neither needs the other.
  • The SRC1 factor mapping, the Location 0 / Index 1 remap and the dualSrcBlend check look right. No translator change, so no contract row is needed.
  • Without this change, the new native_pso_blend checks fail on main's header.
  • Windows suite under Wine (lavapipe and an RDNA2 iGPU): no pass→fail against main + #1671. dual_source_fragment, d3d12_dual_source_draw and d3d12_dual_source_draw_eager pass on both.
  • Docs tests and the no-game-data check pass. Not checked here: a real boot.
  • Checked on main 5e95fa2f4 + b19b00e88: it merges cleanly; the semantic suite passes (489 files, 6,288 tests, 0 files failed); the 14 docs and writer tests pass; check_no_game_data.py is clean on the 12 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 13:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1703#issuecomment-7164278192) Merged. Thank you, @⁠OreoFR, and thanks to @⁠kawaii-shakal, @⁠potatoe0100 and @⁠adrianmjim for the findings and to @⁠MoonEyes for the independent pass. - Merges cleanly on current `main` and with #1691; neither needs the other. - The `SRC1` factor mapping, the `Location 0` / `Index 1` remap and the `dualSrcBlend` check look right. No translator change, so no contract row is needed. - Without this change, the new `native_pso_blend` checks fail on `main`'s header. - Windows suite under Wine (lavapipe and an RDNA2 iGPU): no pass→fail against `main` + #1671. `dual_source_fragment`, `d3d12_dual_source_draw` and `d3d12_dual_source_draw_eager` pass on both. - Docs tests and the no-game-data check pass. Not checked here: a real boot. - **Checked on `main` `5e95fa2f4` + `b19b00e88`:** it merges cleanly; the semantic suite passes (489 files, 6,288 tests, 0 files failed); the 14 docs and writer tests pass; `check_no_game_data.py` is clean on the 12 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.