native_pso: a single-sided stencil PSO keeps its depth/stencil/raster state (RT-STATE-DEPTH-RASTER-BACKFACE-MASK) #2473
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2473"
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 Tyrannys on 2026-11-27T15:41:39Z.
Claimed in the coordination issue as: RT-STATE-DEPTH-RASTER-BACKFACE-MASK (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7222238523)
What and why
Item 1 of @kevincommits'
RT-STATE-AUDIT-PIPELINEfinding in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7221587976), part of #2464 Part B. Thanks for the audit and the repro values.np::d3d12_depth_raster(runtime/src/native_pso.h) refused any stencil state whoseDB_STENCILREFMASK_BFread/write masks differ fromDB_STENCILREFMASK, even whenDB_DEPTH_CONTROL.BACKFACE_ENABLEis clear. In that case RDNA2 ignores the_BFregister and the back face uses the front one, which the function already did for the back face's ops and function. The empty result madefill_depth_raster_state(d3d12_xs_native_pso.h) fall back to its defaults for the whole PSO: depthALWAYSwith writes, cullNONE, stencil off.The masks are now compared only when
BACKFACE_ENABLEis set. Two-sided stencil with differing masks is still refused, becauseD3D12_DEPTH_STENCIL_DESChas one pair of masks.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
mainec91d695c.native_pso_depth_testgains two checks: kevincommits' values (STENCIL_ENABLE=1,BACKFACE_ENABLE=0,DB_STENCILREFMASK=0x01ffff00,DB_STENCILREFMASK_BF=0) and a differing back write mask (0x01f0ff00) must build the state with its depth (GEQUAL, no writes), cull (BACK) and front stencil ops on both faces.main'snative_pso.h, both new checks fail; with the fix, all 28 checks pass. The two-sided "front and back write masks that differ are not built" check still passes.ctest -R "native_pso|pso_stream|pso_validation": 5/5 pass (pso_stream,native_pso_blend,native_pso_depth,native_pso_fallback,d3d12_pso_validation).scripts/check_no_game_data.py: clean.GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 (the tests here are CPU-only)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by Tauwni on 2026-11-27T16:17:45Z.
Tested on a Mac, natively (Apple clang 17) and under Wine:
native_pso_depthmainnative_pso_depth_test.cpponmain, no fixsingle-sided stencil: the back-face mask register is ignored, depth and raster state keptand... a differing back write mask is ignored, natively and under Winemain+ this PRnative_pso_blendandnative_pso_fallbackpass on all three.GPUs tested: Apple M3 (profile S), macOS 26.5.1, Wine 11.0 (WineHQ macOS build) with its MoltenVK 1.4.1, clang-cl/lld-link 23.1.6 cross build,
mainec91d695c. No game files. MEASURED, 1 run each.AI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T18:40:44Z.
Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked.
Reading (marked):
Limits: one machine, one run for the PR, one run for each main witness.
AI-assisted (Claude Code, Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:23Z.
Reviewed at head
8aaea30c7on Windows 11 (MSVC 202219.44).Verification
native_pso_depth_test.native_pso_depth_test: passed.Notes
BACKFACE_ENABLEis set (native_pso.h:358-392) avoids dropping depth/stencil/raster state on single-sided stencil PSOs whose unused back-face register differs, while keeping the unsupported two-sided mismatch fallback intact.Approve.
AI-assisted review + local MSVC verification.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T10:37:45Z.
Review: APPROVED
Reviewed
8aaea30c7and verified the native PSO depth/stencil tests.Code audit:
runtime/shims/d3d12_xs_native_pso.h: gating theDB_STENCILREFMASK_BFmask equality check ontwo_sided = ((d >> 7) & 1) != 0(BACKFACE_ENABLE) matches hardware single-sided stencil semantics so stale/unrelated backface mask bits no longer cause the PSO's depth/stencil/raster state to be rejected.Verification (Windows 11, MSVC 19.44, Ninja Release):
native_pso_depth_test.ctest -R '^native_pso_depth$': 1/1 passed.python -I scripts/check_no_game_data.py: passed.AI-assisted (Antigravity, Gemini).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:52:24Z.
Red/green: On main native_pso_depth_test fails 2 checks (a single-sided stencil PSO loses its depth/stencil/raster state over an unused back-face mask), and with the PR ctest -R "^native_pso_depth$" 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-28T22:02:39Z.
Verified by OreoFR
c1ecf04ed+ PR head8aaea30c7; green run in a merge package of 11 PRs, no new ctest failure vs mainctest -R "^native_pso_depth$"AI-assisted (Claude Code, Claude Opus 5.5).