d3d12_xs: derived PSO overlays reach DEPTH_STENCIL2 and RASTERIZER1/2 (RT-STATE-PSO-OVERLAY-DS2-RS12) #2476

Merged
Tyrannys merged 1 commit from upstream-pr/2476 into main 2026-11-28 17:52:15 +00:00
Tyrannys commented 2026-11-27 15:58:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-27T15:58:27Z.


Claimed in the coordination issue as: RT-STATE-PSO-OVERLAY-DS2-RS12 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7222238523)

What and why

Item 6 of @kevincommits' RT-STATE-AUDIT-PIPELINE finding in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7221587976), part of #2464 Part B. Thanks for the audit.

derive_stream (runtime/shims/d3d12_xs_pso_stream.cpp, device slot 55) patches a base PSO stream with records that carry D3D12 v0 descriptions: tag 0 a D3D12_DEPTH_STENCIL_DESC, tag 1 a D3D12_RASTERIZER_DESC, tag 5 the two stencil masks. These matched only DEPTH_STENCIL/DEPTH_STENCIL1 and RASTERIZER. On a base that uses DEPTH_STENCIL2 or RASTERIZER1/2, the derive failed as missing_state.

Those later versions have other layouts, so the record is converted, not copied:

  • Tag 0 on DEPTH_STENCIL2: the depth fields and face ops are set, the record's one pair of masks goes on both faces, and the base's DepthBoundsTestEnable is kept (as it already is for DEPTH_STENCIL1).
  • Tag 5 on DEPTH_STENCIL2: both faces' masks.
  • Tag 1 on RASTERIZER1: DepthBias as a float. On RASTERIZER2: the same, plus LineRasterizationMode from MultisampleEnable/AntialiasedLineEnable (QUADRILATERAL_WIDE, ALPHA_ANTIALIASED or ALIASED, as D3D12 maps them).

DEPTH_STENCIL, DEPTH_STENCIL1 and RASTERIZER are patched as before. Tags 2 and 3 are unchanged.

Does not conflict with #2399 (VIEW_INSTANCING in the same files); checked with git merge-tree.

Tested

Windows 11, MSVC (VS 18), RelWithDebInfo, on main ec91d695c.

  • pso_stream_test gains test_later_subobject_versions: bases with DEPTH_STENCIL2 plus RASTERIZER1, and DEPTH_STENCIL2 plus RASTERIZER2, take tags 0, 1 and 5, with every converted field checked. With main's d3d12_xs_pso_stream.cpp, all 14 new checks fail (the derives return missing_state); with the fix, all checks pass, the old ones included.
  • ctest -R "^(pso_stream|d3d12_mesh|d3d12_mesh_heavy_cache|xbox_depth_storage|d3d12_depth24_draw)$": 5/5 pass (d3d12_mesh covers slot 55 on a real layer device).
  • scripts/check_no_game_data.py: clean.

GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11

AI-assisted: yes (Claude Code)

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. (n/a: no translator change)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5529532489 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2476). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-27T15:58:27Z. --- Claimed in the coordination issue as: RT-STATE-PSO-OVERLAY-DS2-RS12 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7222238523) ### What and why Item 6 of @kevincommits' `RT-STATE-AUDIT-PIPELINE` finding in #1608 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7221587976), part of #2464 Part B. Thanks for the audit. `derive_stream` (`runtime/shims/d3d12_xs_pso_stream.cpp`, device slot 55) patches a base PSO stream with records that carry D3D12 v0 descriptions: tag 0 a `D3D12_DEPTH_STENCIL_DESC`, tag 1 a `D3D12_RASTERIZER_DESC`, tag 5 the two stencil masks. These matched only `DEPTH_STENCIL`/`DEPTH_STENCIL1` and `RASTERIZER`. On a base that uses `DEPTH_STENCIL2` or `RASTERIZER1/2`, the derive failed as `missing_state`. Those later versions have other layouts, so the record is converted, not copied: - Tag 0 on `DEPTH_STENCIL2`: the depth fields and face ops are set, the record's one pair of masks goes on both faces, and the base's `DepthBoundsTestEnable` is kept (as it already is for `DEPTH_STENCIL1`). - Tag 5 on `DEPTH_STENCIL2`: both faces' masks. - Tag 1 on `RASTERIZER1`: `DepthBias` as a float. On `RASTERIZER2`: the same, plus `LineRasterizationMode` from `MultisampleEnable`/`AntialiasedLineEnable` (`QUADRILATERAL_WIDE`, `ALPHA_ANTIALIASED` or `ALIASED`, as D3D12 maps them). `DEPTH_STENCIL`, `DEPTH_STENCIL1` and `RASTERIZER` are patched as before. Tags 2 and 3 are unchanged. Does not conflict with #2399 (VIEW_INSTANCING in the same files); checked with `git merge-tree`. ### Tested Windows 11, MSVC (VS 18), RelWithDebInfo, on `main` `ec91d695c`. - `pso_stream_test` gains `test_later_subobject_versions`: bases with `DEPTH_STENCIL2` plus `RASTERIZER1`, and `DEPTH_STENCIL2` plus `RASTERIZER2`, take tags 0, 1 and 5, with every converted field checked. With `main`'s `d3d12_xs_pso_stream.cpp`, all 14 new checks fail (the derives return `missing_state`); with the fix, all checks pass, the old ones included. - `ctest -R "^(pso_stream|d3d12_mesh|d3d12_mesh_heavy_cache|xbox_depth_storage|d3d12_depth24_draw)$"`: 5/5 pass (`d3d12_mesh` covers slot 55 on a real layer device). - `scripts/check_no_game_data.py`: clean. GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11 AI-assisted: yes (Claude Code) ### 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
djrolfes commented 2026-11-27 17:15:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by djrolfes on 2026-11-27T17:15:03Z.


Independent Linux/Wine + NVIDIA check at head bede0e73e (merged cleanly onto origin/main c0201a806 alongside #2480, #2478, #2477, #2474).

  • Environment: Linux 7.2.15, wine-11.22, clang-cl + xwin cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver 620.73.04, Ryzen 7 5800X, 32 GB RAM. No game files.
  • CTest: pso_stream passed (5.51 s) under Wine.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7224196682 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2476#issuecomment-7224196682). Originally posted by [djrolfes](https://github.com/djrolfes) on 2026-11-27T17:15:03Z. --- Independent Linux/Wine + NVIDIA check at head `bede0e73e` (merged cleanly onto `origin/main` `c0201a806` alongside `#2480`, `#2478`, `#2477`, `#2474`). - **Environment:** Linux `7.2.15`, `wine-11.22`, `clang-cl` + `xwin` cross-build, NVIDIA GeForce RTX 3070 Ti 8 GB, driver `620.73.04`, Ryzen 7 5800X, 32 GB RAM. No game files. - **CTest:** `pso_stream` **passed** (`5.51 s`) under Wine. AI-assisted.
MoonEyes commented 2026-11-27 18:40:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T18:40:49Z.


Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked.

RUN pr2476-court | 2026-11-27 | MoonEyes | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        main ec91d695c + PR #2476 (head bede0e73e), merged locally without conflict, nothing pushed | shaders: main's own translation
MACHINE:     RTX 4060 8 GB, desktop, only GPU, display attached | NVIDIA 610.88 | Windows 11 Pro 26300 | Ryzen 5 3600 | 32 GB | Windows GPU timeout at the default (2 s)
RECIPE:      short recipe: docs/running.md Windows NVIDIA recipe, pipeline cache warm, 330 s cap, scripted button presses from 60 s | build RelWithDebInfo, only the PR's targets built
TESTS:
  - pso_stream_test (ctest pso_stream): pass on the PR (0 failures) | fails on main: yes (exit 1, 14 failures, e.g. the depth-stencil face masks are not set; PR's test file on top of main's sources)
GAME:        session=1 at 90 s | world entered at 135 s | last window >= 1 img/s ends at 212 s | 0 frames after world entry + 240 s | end: stopped by my local stall guard at 212 s (no new frame line for 180 s, during a compute pipeline build of about 11 s), not by the cap | device loss: no (no fault report) | private RAM max 17661 MB
COMPARED TO: w77 (main ec91d695c, same short recipe): session=1 at 145 s, world at 195 s, last window >= 1 img/s at 293 s, private RAM max 16043 MB, ended by the time limit (337 s)
             w79 (main, same short recipe): world at 200 s, last window >= 1 img/s at 286 s, private RAM max 16583 MB, ended by the time limit (350 s)
             one run each (n=1); on main the spread of world entry on this recipe is about 165 to 200 s, so no conclusion on timings
VERDICT:     unit test passes and fails on main; game reached the world, stopped by the stall guard, no device loss; inconclusive for the game (n=1)

Reading (marked):

  • MEASURED: the display stops after the world is entered (77 s after world entry for the last window >= 1 img/s here; 98 s on w77, 86 s on w79). Present on main too, not caused by this PR (finding https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7224692645).
  • MEASURED: the run was ended by my local stall guard, not by a crash or a device loss. A stall guard end is not comparable with the time-limit end of the main runs; compare the last-window figure, not the end time. I do not attribute the stop to this PR.
  • The game logs of this run were deleted by a disk cleanup before this write-up; the figures above were extracted before that and cannot be re-checked from the logs now.

Limits: one machine, one run for the PR, one run for each main witness.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7225749860 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2476#issuecomment-7225749860). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T18:40:49Z. --- Tested for #2464 as Aslanek asked: unit tests and a game run on my machine; CI ignored for now as asked. ``` RUN pr2476-court | 2026-11-27 | MoonEyes | AI-assisted: Claude Code (Claude Opus 5.5) BASE: main ec91d695c + PR #2476 (head bede0e73e), merged locally without conflict, nothing pushed | shaders: main's own translation MACHINE: RTX 4060 8 GB, desktop, only GPU, display attached | NVIDIA 610.88 | Windows 11 Pro 26300 | Ryzen 5 3600 | 32 GB | Windows GPU timeout at the default (2 s) RECIPE: short recipe: docs/running.md Windows NVIDIA recipe, pipeline cache warm, 330 s cap, scripted button presses from 60 s | build RelWithDebInfo, only the PR's targets built TESTS: - pso_stream_test (ctest pso_stream): pass on the PR (0 failures) | fails on main: yes (exit 1, 14 failures, e.g. the depth-stencil face masks are not set; PR's test file on top of main's sources) GAME: session=1 at 90 s | world entered at 135 s | last window >= 1 img/s ends at 212 s | 0 frames after world entry + 240 s | end: stopped by my local stall guard at 212 s (no new frame line for 180 s, during a compute pipeline build of about 11 s), not by the cap | device loss: no (no fault report) | private RAM max 17661 MB COMPARED TO: w77 (main ec91d695c, same short recipe): session=1 at 145 s, world at 195 s, last window >= 1 img/s at 293 s, private RAM max 16043 MB, ended by the time limit (337 s) w79 (main, same short recipe): world at 200 s, last window >= 1 img/s at 286 s, private RAM max 16583 MB, ended by the time limit (350 s) one run each (n=1); on main the spread of world entry on this recipe is about 165 to 200 s, so no conclusion on timings VERDICT: unit test passes and fails on main; game reached the world, stopped by the stall guard, no device loss; inconclusive for the game (n=1) ``` Reading (marked): - MEASURED: the display stops after the world is entered (77 s after world entry for the last window >= 1 img/s here; 98 s on w77, 86 s on w79). Present on main too, not caused by this PR (finding https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7224692645). - MEASURED: the run was ended by my local stall guard, not by a crash or a device loss. A stall guard end is not comparable with the time-limit end of the main runs; compare the last-window figure, not the end time. I do not attribute the stop to this PR. - The game logs of this run were deleted by a disk cleanup before this write-up; the figures above were extracted before that and cannot be re-checked from the logs now. Limits: one machine, one run for the PR, one run for each main witness. AI-assisted (Claude Code, Claude Opus 5.5)
timbot103 commented 2026-11-28 02:02:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-28T02:02:17Z.


Reviewed at head bede0e73e on Windows 11 (MSVC 2022 19.44).

Verification

  • Built pso_stream_test.
  • pso_stream_test: passed.

Notes (non-blocking)

  • Stream bounds validation, preserving subobject sizes and record order across DEPTH_STENCIL2 and RASTERIZER1/2 overlays, and tag-0/tag-5 mask propagation (d3d12_xs_pso_stream.cpp:49-99, 185-257, 438-463) all look solid.
  • Minor follow-up note (d3d12_xs_pso_stream.cpp:241-257; d3d12_vulkan_device.cpp:11070-11090): Tag 1 converts integer r.DepthBias to FLOAT in versioned rasterizers, which the Vulkan parser later converts back with INT(bias); for DepthBias = INT_MAX, rounding to 2147483648.0f overflows INT. Clamping against signed INT bounds in the Vulkan parser (pre-existing) would guard that edge case.

Approve.

AI-assisted review + local MSVC verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232085691 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2476#issuecomment-7232085691). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-28T02:02:17Z. --- Reviewed at head `bede0e73e` on Windows 11 (MSVC 2022 `19.44`). ### Verification - Built `pso_stream_test`. - `pso_stream_test`: **passed**. ### Notes (non-blocking) - Stream bounds validation, preserving subobject sizes and record order across `DEPTH_STENCIL2` and `RASTERIZER1/2` overlays, and tag-0/tag-5 mask propagation (`d3d12_xs_pso_stream.cpp:49-99`, `185-257`, `438-463`) all look solid. - **Minor follow-up note (`d3d12_xs_pso_stream.cpp:241-257`; `d3d12_vulkan_device.cpp:11070-11090`):** Tag 1 converts integer `r.DepthBias` to `FLOAT` in versioned rasterizers, which the Vulkan parser later converts back with `INT(bias)`; for `DepthBias = INT_MAX`, rounding to `2147483648.0f` overflows `INT`. Clamping against signed `INT` bounds in the Vulkan parser (pre-existing) would guard that edge case. Approve. AI-assisted review + local MSVC verification.
lixonik commented 2026-11-28 10:37:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T10:37:26Z.

Review: APPROVED


Reviewed bede0e73e and verified the PSO stream and XS proxy mock tests.

Code audit:

  • runtime/shims/d3d12_xs_pso_stream.cpp: derived PSO overlay tags 0 (DEPTH_STENCIL), 1 (RASTERIZER), and 5 (stencil masks) cleanly extend to DEPTH_STENCIL2, RASTERIZER1, and RASTERIZER2 without corrupting subobject headers or trailing fields.
  • Unit tests in pso_stream_test and xs_proxy_mock_test cover the new subobject variants.

Verification (Windows 11, MSVC 19.44, Ninja Release):

  • Built pso_stream_test and xs_proxy_mock_test.
  • ctest -R '^(pso_stream|xs_proxy_mock)$': 2/2 passed.
  • python -I scripts/check_no_game_data.py: passed.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6097268035 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2476#pullrequestreview-6097268035). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T10:37:26Z. **Review:** APPROVED --- Reviewed `bede0e73e` and verified the PSO stream and XS proxy mock tests. Code audit: - `runtime/shims/d3d12_xs_pso_stream.cpp`: derived PSO overlay tags 0 (`DEPTH_STENCIL`), 1 (`RASTERIZER`), and 5 (stencil masks) cleanly extend to `DEPTH_STENCIL2`, `RASTERIZER1`, and `RASTERIZER2` without corrupting subobject headers or trailing fields. - Unit tests in `pso_stream_test` and `xs_proxy_mock_test` cover the new subobject variants. Verification (Windows 11, MSVC 19.44, Ninja Release): - Built `pso_stream_test` and `xs_proxy_mock_test`. - `ctest -R '^(pso_stream|xs_proxy_mock)$'`: 2/2 passed. - `python -I scripts/check_no_game_data.py`: passed. AI-assisted (Antigravity, Gemini).
MoonEyes commented 2026-11-28 17:52:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T17:52:12Z.


Red/green: On main pso_stream_test fails 15 checks (derived PSO overlays do not reach DEPTH_STENCIL2 and RASTERIZER1/2), and with the PR ctest -R "^pso_stream$" 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243350771 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2476#issuecomment-7243350771). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T17:52:12Z. --- Red/green: On main pso_stream_test fails 15 checks (derived PSO overlays do not reach DEPTH_STENCIL2 and RASTERIZER1/2), and with the PR ctest -R "^pso_stream$" 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.
OreoFR commented 2026-11-28 22:02:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T22:02:44Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head bede0e73e; green run in a merge package of 11 PRs, no new ctest failure vs main
  • Test: ctest -R "^pso_stream$"
  • Red on main: 15 failures (DEPTH_STENCIL2, RASTERIZER1/2 of derived PSOs)
  • Green with the PR: OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246456482 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2476#issuecomment-7246456482). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T22:02:44Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `bede0e73e`; green run in a merge package of 11 PRs, no new ctest failure vs main - Test: `ctest -R "^pso_stream$"` - Red on main: 15 failures (DEPTH_STENCIL2, RASTERIZER1/2 of derived PSOs) - Green with the PR: OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
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!2476
No description provided.