runtime: respect IndependentBlendEnable=FALSE in B4G4R4A4 stand-in blend fallback #2038
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2038"
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?
Imported from ubiquitarianism/leonida. Originally posted by IlyassRS3 on 2026-11-25T18:44:59Z.
Coordination item:
RT-NATIVE-PSO-FALLBACK-INDEPENDENT-BLEND(claimed on #1608).Why
In D3D12, when
D3D12_BLEND_DESC::IndependentBlendEnable == FALSE,RenderTarget[0]governs every active render target (0..NumRenderTargets-1) andRenderTarget[1..7]are ignored (typically left zero-initialized by the title).rt::d3d12_xs::native_pipeline_detail::without_stand_in_blend()inruntime/shims/d3d12_xs_native_pso_fallback.hpreviously inspectedRenderTarget[i].BlendEnabledirectly and then setIndependentBlendEnable = TRUEwithout replicatingRenderTarget[0]intoRenderTarget[1..7], causing three bugs wheneverIndependentBlendEnable == FALSE:B4G4R4A4_UNORMand slot 1 isR8G8B8A8_UNORMwithRenderTarget[1]zero-initialized, flippingIndependentBlendEnable = TRUEleaves slot 1 withBlendEnable = FALSEandRenderTargetWriteMask = 0(masking out all colour writes to slot 1).E_NOTIMPL): if slot 0 isR8G8B8A8_UNORMand slot 1 isB4G4R4A4_UNORMwithRenderTarget[0].BlendEnable = TRUEandRenderTarget[1]zero-initialized, slot 1 is effectively blended by D3D12 rules, yetwithout_stand_in_blend()sawRenderTarget[1].BlendEnable == FALSEand returnedfalse.RenderTarget[1..7]: ifRenderTarget[0].BlendEnable == FALSEand ignoredRenderTarget[1].BlendEnable == TRUEon aB4G4R4A4_UNORMtarget, it falsely triggered the fallback even though blending was off.Changes
runtime/shims/d3d12_xs_native_pso_fallback.h: check effective blend (RenderTarget[independent ? i : 0].BlendEnable), replicateRenderTarget[0]toRenderTarget[1..7]before settingIndependentBlendEnable = TRUEwhen!independent, and then turn offBlendEnableonly on activeDXGI_FORMAT_B4G4R4A4_UNORMtargets.runtime/test/native_pso_fallback_test.cpp: add 4 regression cases covering all threeIndependentBlendEnable == FALSEbugs plus distinct per-target write-mask preservation whenIndependentBlendEnable == TRUE.Verification
d3d12.hblend/PSO struct stubs; Windows CTest builds against real Windows SDK headers).runtime/test/native_pso_fallback_test.cppdirectly withclang++ -std=c++20 -Wall -Wextra -Werror:-O1 -g -fsanitize=address,undefined):native_pso_fallback: ok.-O1 -g -fsanitize=thread):native_pso_fallback: ok.-O2):native_pso_fallback: ok.main'sd3d12_xs_native_pso_fallback.h: fails all 3 newIndependentBlendEnable == FALSEregression tests (exit 1).python3 -I scripts/check_no_game_data.py runtime/shims/d3d12_xs_native_pso_fallback.h runtime/test/native_pso_fallback_test.cpp: clean.python3 -I tests/test_text_write_line_endings.py: 3/3 OK.Imported from ubiquitarianism/leonida. Originally posted by copilot-pull-request-reviewer[bot] on 2026-11-25T18:45:12Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.
Imported from ubiquitarianism/leonida. Originally posted by ERROR890 on 2026-11-26T19:14:01Z.
Review note from a duplicate pull request I opened before I found this one (#2368, now closed):
The layer's refusal at the stand-in checks both fields:
so a stand-in target whose blend is a logic op (
BlendEnable = FALSE,LogicOpEnable = TRUE) is refused as well, andwithout_stand_in_blendshould treat it as the stand-in's refusal and clear it:A test case that pins it:
IndependentBlendEnable = FALSE,RenderTarget[0].BlendEnable = FALSE,RenderTarget[0].LogicOpEnable = TRUE,RTVFormats = {B4G4R4A4_UNORM, R8G8B8A8_UNORM}. Expecttrue, the logic op cleared on the stand-in, andRenderTarget[1]keeping the state it inherited fromRenderTarget[0](a logic op, sinceBlendEnablewas false). Without theLogicOpEnableclause the helper returns false and the pipeline stays missing.There is a branch with exactly that on it,
fix/native-pso-standin-blendin ERROR890/leonida, if it is useful; take it or ignore it. Everything else here looks right to me.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:35:32Z.
Verified on Windows 11 (
10.0.26200.9974) with MSVC19.44.35228(x64,/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) againstmain4a54aedcb+52d768a0d(claim#2570#issuecomment-7238618828):runtime/shims/d3d12_xs_native_pso_fallback.h,runtime/test/native_pso_fallback_test.cpp); evaluates effective target blend viaRenderTarget[independent ? i : 0]and replicatesRenderTarget[0]acrossRenderTarget[1..7]before settingIndependentBlendEnable = TRUEwhenIndependentBlendEnable == FALSE, preserving non-B4G4R4A4blend state and write masks while ignoring staleRenderTarget[1..7]entries whenRenderTarget[0].BlendEnable == FALSE.check_no_game_data.pyclean.4a54aedcb+ PR test):native_pso_fallback_test.exefails (rc=1, 6 failures onIndependentBlendEnable == FALSEshared blend / staleRenderTarget[1].BlendEnable).4a54aedcb+52d768a0dmerge): Merges cleanly (rc=0), compiles with0/W4warnings, andnative_pso_fallback_test.exepasses (native_pso_fallback: ok,rc=0).AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:53:10Z.
Red/green: On main native_pso_fallback_test fails 6 checks (with IndependentBlendEnable=FALSE the stand-in fallback reads stale RenderTarget[1..7] instead of RenderTarget[0]), and with the PR ctest -R "^native_pso_fallback$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main
c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:58:42Z.
Verified by OreoFR
c1ecf04ed+ PR head52d768a0d; green run in a merge package of 16 PRs, no new ctest failure vs mainctest -R ^native_pso_fallback$AI-assisted (Claude Code, Claude Opus 5.5).