d3d12_xs: the stand-in blend fallback reads the blend state D3D12 applies #2368

Closed
ERROR890 wants to merge 2 commits from upstream-pr/2368 into main
ERROR890 commented 2026-11-26 16:11:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ERROR890 on 2026-11-26T16:11:06Z.


Claimed in the coordination issue as: NATIVE-PSO-STANDIN-BLEND
(https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197231884)

Depends on: none.

Fixes: none.

What and why

without_stand_in_blend (runtime/shims/d3d12_xs_native_pso_fallback.h) decides whether a graphics pipeline is
retried with blending off on its B4G4R4A4 stand-in targets. It read BlendState.RenderTarget[i] for the target's own
index, but D3D12 only gives every target its own entry when IndependentBlendEnable is TRUE; with it FALSE,
RenderTarget[0] describes all of them and the rest are ignored. Two consequences:

  • a pipeline that does blend a stand-in target at index > 0 was never retried, because the ignored entry usually
    says no blend, so the pipeline stayed missing;
  • a pipeline that does not blend one could be retried because an ignored entry said it did.

The rewrite had the matching problem: it set IndependentBlendEnable = TRUE to turn blending off on the stand-in
alone, without first giving the other targets the state they inherited from RenderTarget[0], so turning the flag on
made each of them read its own (usually zeroed) entry and silently stop blending.

What changes:

  • the entry that applies to a target is RenderTarget[IndependentBlendEnable ? i : 0], and a target whose blend is a
    logic op counts too, since the layer's refusal tests BlendEnable || LogicOpEnable;
  • when the flag has to go on, RenderTarget[0] is copied into all eight entries first, and only then are blending and
    logic ops turned off on the stand-in targets;
  • independent blending on input behaves as before: only the stand-in target changes.

native_pso_fallback_test gains the cases: the stand-in at index > 0 under non-independent blending; the ignored
entry that must not cause a retry; the inherited state every other target keeps once the flag goes on; the independent
case where only the stand-in changes; and a stand-in whose blend is a logic op. The existing four cases still pass.

Testing

Built native_pso_fallback_test with MSVC 19.44 (Windows SDK 10.0.26100) on Windows 11 26H2, Ninja build.
With this change:  native_pso_fallback: ok  (exit 0)
On main:           7 assertions fail (the new cases), exit 1.
ctest -R "native_pso_fallback|native_pso_blend|native_pso_depth|pso_stream|process_cmdline" --output-on-failure:
100% tests passed, 0 tests failed out of 5.
Synthetic descriptor fixtures only. AI-assisted.

GPUs tested: n/a. This is a pure decision-logic change in a header plus its unit test; no Vulkan device, no D3D12
object and no game files are involved.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • 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. (No translator
    change in this pull request.)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5513422331 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2368). Originally posted by [ERROR890](https://github.com/ERROR890) on 2026-11-26T16:11:06Z. --- Claimed in the coordination issue as: NATIVE-PSO-STANDIN-BLEND (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7197231884) Depends on: none. Fixes: none. ### What and why `without_stand_in_blend` (`runtime/shims/d3d12_xs_native_pso_fallback.h`) decides whether a graphics pipeline is retried with blending off on its B4G4R4A4 stand-in targets. It read `BlendState.RenderTarget[i]` for the target's own index, but D3D12 only gives every target its own entry when `IndependentBlendEnable` is TRUE; with it FALSE, `RenderTarget[0]` describes all of them and the rest are ignored. Two consequences: - a pipeline that **does** blend a stand-in target at index > 0 was never retried, because the ignored entry usually says no blend, so the pipeline stayed missing; - a pipeline that does **not** blend one could be retried because an ignored entry said it did. The rewrite had the matching problem: it set `IndependentBlendEnable = TRUE` to turn blending off on the stand-in alone, without first giving the other targets the state they inherited from `RenderTarget[0]`, so turning the flag on made each of them read its own (usually zeroed) entry and silently stop blending. What changes: - the entry that applies to a target is `RenderTarget[IndependentBlendEnable ? i : 0]`, and a target whose blend is a logic op counts too, since the layer's refusal tests `BlendEnable || LogicOpEnable`; - when the flag has to go on, `RenderTarget[0]` is copied into all eight entries first, and only then are blending and logic ops turned off on the stand-in targets; - independent blending on input behaves as before: only the stand-in target changes. `native_pso_fallback_test` gains the cases: the stand-in at index > 0 under non-independent blending; the ignored entry that must not cause a retry; the inherited state every other target keeps once the flag goes on; the independent case where only the stand-in changes; and a stand-in whose blend is a logic op. The existing four cases still pass. ### Testing ``` Built native_pso_fallback_test with MSVC 19.44 (Windows SDK 10.0.26100) on Windows 11 26H2, Ninja build. With this change: native_pso_fallback: ok (exit 0) On main: 7 assertions fail (the new cases), exit 1. ctest -R "native_pso_fallback|native_pso_blend|native_pso_depth|pso_stream|process_cmdline" --output-on-failure: 100% tests passed, 0 tests failed out of 5. Synthetic descriptor fixtures only. AI-assisted. ``` GPUs tested: n/a. This is a pure decision-logic change in a header plus its unit test; no Vulkan device, no D3D12 object and no game files are involved. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [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. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (No translator change in this pull request.)
ERROR890 commented 2026-11-26 19:14:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ERROR890 on 2026-11-26T19:14:03Z.


Closing as a duplicate of #2038 ("runtime: respect IndependentBlendEnable=FALSE in B4G4R4A4 stand-in blend fallback"), which was opened first, covers the same three cases in the same two files, and has a more thorough write-up. Per CONTRIBUTING.md, the earlier pull request is the one that lands; mine adds nothing that #2038 does not already do in the read and the rewrite.

One gap in #2038 that is worth folding in (posted there as a review note): the layer's refusal tests blend.BlendEnable || blend.LogicOpEnable, so a stand-in target whose blend is a logic op is refused too, and without_stand_in_blend has to look for LogicOpEnable as well when it decides whether the refusal was the stand-in's, and turn it off on the stand-in target. My branch did that, along with the existing four cases:

const D3D12_RENDER_TARGET_BLEND_DESC& entry = blend.RenderTarget[blend.IndependentBlendEnable ? i : 0];
if (entry.BlendEnable || entry.LogicOpEnable) changed = true;
...
rewritten.RenderTarget[i].BlendEnable = FALSE;
rewritten.RenderTarget[i].LogicOpEnable = FALSE;

with a test case where RenderTarget[0] has BlendEnable = FALSE, LogicOpEnable = TRUE on a B4G4R4A4 target: without_stand_in_blend must return true, clear the logic op on the stand-in, and leave the inherited state on the target that is not a stand-in. Feel free to take it from branch fix/native-pso-standin-blend in this fork if that is easier.

Thanks for the prior art — I missed it when checking the open pull requests before writing mine.

No further work is planned on this branch.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7201344447 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2368#issuecomment-7201344447). Originally posted by [ERROR890](https://github.com/ERROR890) on 2026-11-26T19:14:03Z. --- Closing as a duplicate of #2038 ("runtime: respect IndependentBlendEnable=FALSE in B4G4R4A4 stand-in blend fallback"), which was opened first, covers the same three cases in the same two files, and has a more thorough write-up. Per CONTRIBUTING.md, the earlier pull request is the one that lands; mine adds nothing that #2038 does not already do in the read and the rewrite. One gap in #2038 that is worth folding in (posted there as a review note): the layer's refusal tests `blend.BlendEnable || blend.LogicOpEnable`, so a stand-in target whose blend is a logic op is refused too, and `without_stand_in_blend` has to look for `LogicOpEnable` as well when it decides whether the refusal was the stand-in's, and turn it off on the stand-in target. My branch did that, along with the existing four cases: ```cpp const D3D12_RENDER_TARGET_BLEND_DESC& entry = blend.RenderTarget[blend.IndependentBlendEnable ? i : 0]; if (entry.BlendEnable || entry.LogicOpEnable) changed = true; ... rewritten.RenderTarget[i].BlendEnable = FALSE; rewritten.RenderTarget[i].LogicOpEnable = FALSE; ``` with a test case where `RenderTarget[0]` has `BlendEnable = FALSE, LogicOpEnable = TRUE` on a `B4G4R4A4` target: `without_stand_in_blend` must return true, clear the logic op on the stand-in, and leave the inherited state on the target that is not a stand-in. Feel free to take it from branch `fix/native-pso-standin-blend` in this fork if that is easier. Thanks for the prior art — I missed it when checking the open pull requests before writing mine. No further work is planned on this branch.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2368
No description provided.