D3D12.X: console mesh pipeline streams (MS as subobject 24), null stand-in shaders #167

Closed
Sr-0w wants to merge 7 commits from upstream-pr/170 into main
Sr-0w commented 2026-11-23 18:39:04 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Sr-0w on 2026-11-23T18:39:04Z.


Stacked on #163 (uses its pc_format); the first commit here is #163's. Review only the last commit, or merge #163 first.

Problem

The retail title's pipeline streams carry their mesh shader as subobject type 24, which is the PC's amplification shader. A diagnostic logging the DXIL program kind of each shader subobject showed:

refused PSO stream (0x2b0 bytes): subobjects ["0", "24:kind 13", "2:kind 0", "3", "4", "5", "8", "9", "10", "21", "17", "12", "14", "15", "16"]

(kind 13 = mesh). translated_mesh_stream looks for type 25, found no MS, and did not translate these pipelines. The stream then reached the driver as it was, and the D3D12 debug layer reported CreateAmplificationShader: … Shader version provided: ms_6_6 and then Cannot deduce Pipeline State type: neither VS, CS nor MS.

Second bug, found by the debug layer: fallback_stream writes b.as_ptr() for the shaders it drops (&[]), which is Rust's dangling pointer 0x1, not null. The driver refused the mesh stand-ins (0x80070057, so the title compiled them in its own call until its watchdog fired), and the debug layer crashed reading 0x19.

Change

  • pc_stream_types, applied first in dev_create_pipeline_state: renumbers AS/MS subobjects by the program kind in their bytecode (13 → 25, 14 → 24), maps console formats in DSV/RTV subobjects (pc_format, D16S8 → D24S8) and rect-list topology type 19 → TRIANGLE. It returns a copy only when something changed; PC streams are untouched.
  • fallback_stream: a dropped shader gets a null pointer.
  • log_stream_shapes: a stream refused even with stand-ins logs its subobject types and shader kinds (first 6).
  • Unit test console_mesh_streams_become_pc_ones.

Result

  • No more PSO stream rejected … the fallback version too; mesh stand-ins are created.
  • Before the null-pointer fix, the retail title ran 155 s (vs 19 s) before its watchdog fired on threads compiling mesh pipelines in the call.
  • On top of 956a476 (with #163), the retail title runs at 30 fps like main, its mesh streams now renumbered (made the PC's in the log). The device removal I reported earlier came from deferring compute pipelines in #162, not from this PR (bisected).

Test plan

  • cargo test --release -p xcl --lib: 536 passed; only gpu_wave64_ps_whole_wave_reductions fails, as on main
  • Retail title with XCL_D3D12_DEBUG=1: no stream errors, no debug-layer crash

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:6566280277 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/170). Originally posted by [Sr-0w](https://github.com/Sr-0w) on 2026-11-23T18:39:04Z. --- **Stacked on #163** (uses its `pc_format`); the first commit here is #163's. Review only the last commit, or merge #163 first. ## Problem The retail title's pipeline streams carry their **mesh shader as subobject type 24**, which is the PC's amplification shader. A diagnostic logging the DXIL program kind of each shader subobject showed: ``` refused PSO stream (0x2b0 bytes): subobjects ["0", "24:kind 13", "2:kind 0", "3", "4", "5", "8", "9", "10", "21", "17", "12", "14", "15", "16"] ``` (kind 13 = mesh). `translated_mesh_stream` looks for type 25, found no MS, and did not translate these pipelines. The stream then reached the driver as it was, and the D3D12 debug layer reported `CreateAmplificationShader: … Shader version provided: ms_6_6` and then `Cannot deduce Pipeline State type: neither VS, CS nor MS`. Second bug, found by the debug layer: `fallback_stream` writes `b.as_ptr()` for the shaders it drops (`&[]`), which is Rust's dangling pointer `0x1`, not null. The driver refused the mesh stand-ins (`0x80070057`, so the title compiled them in its own call until its watchdog fired), and the debug layer crashed reading `0x19`. ## Change - `pc_stream_types`, applied first in `dev_create_pipeline_state`: renumbers AS/MS subobjects by the program kind in their bytecode (13 → 25, 14 → 24), maps console formats in DSV/RTV subobjects (`pc_format`, D16S8 → D24S8) and rect-list topology type 19 → TRIANGLE. It returns a copy only when something changed; PC streams are untouched. - `fallback_stream`: a dropped shader gets a null pointer. - `log_stream_shapes`: a stream refused even with stand-ins logs its subobject types and shader kinds (first 6). - Unit test `console_mesh_streams_become_pc_ones`. ## Result - No more `PSO stream rejected … the fallback version too`; mesh stand-ins are created. - Before the null-pointer fix, the retail title ran 155 s (vs 19 s) before its watchdog fired on threads compiling mesh pipelines in the call. - On top of 956a476 (with #163), the retail title runs at 30 fps like `main`, its mesh streams now renumbered (`made the PC's` in the log). The device removal I reported earlier came from deferring compute pipelines in #162, not from this PR (bisected). ## Test plan - [x] `cargo test --release -p xcl --lib`: 536 passed; only `gpu_wave64_ps_whole_wave_reductions` fails, as on `main` - [x] Retail title with `XCL_D3D12_DEBUG=1`: no stream errors, no debug-layer crash 🤖 Generated with [Claude Code](https://claude.com/claude-code)
upstream-sync closed this pull request 2026-11-24 06:57:29 +00:00
TheHoracio commented 2026-11-24 07:04:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by TheHoracio on 2026-11-23T19:28:11Z.


Ran the test suite on AMD RDNA3: Radeon RX 7800 XT (16 GB), driver 32.0.32015.7029, Windows 11 Pro 10.0.26300, Rust 1.100.0 x86_64-pc-windows-msvc, DXC 1.9.2602.17. The PR head 8f2104b was tested, with #163's commit included as stacked. No retail data was used, so this only covers regressions.

cargo test --workspace --no-fail-fast: 569 passed, 1 failed, 39 ignored, 0 SKIPPED.

  • The new console_mesh_streams_become_pc_ones and console_depth_buffers_become_pc_ones pass.
  • The one failure is gpu_wave64_ps_whole_wave_reductions. It fails the same way on main 956a476 on this GPU and is fixed by #155. It is unrelated to this PR.
<!-- greyfinch-sync:ivall/xcl:comment:7111649665 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/170#issuecomment-7111649665). Originally posted by [TheHoracio](https://github.com/TheHoracio) on 2026-11-23T19:28:11Z. --- Ran the test suite on **AMD RDNA3: Radeon RX 7800 XT** (16 GB), driver 32.0.32015.7029, Windows 11 Pro 10.0.26300, Rust 1.100.0 `x86_64-pc-windows-msvc`, DXC 1.9.2602.17. The PR head `8f2104b` was tested, with #163's commit included as stacked. No retail data was used, so this only covers regressions. `cargo test --workspace --no-fail-fast`: **569 passed, 1 failed, 39 ignored**, 0 `SKIPPED`. - The new `console_mesh_streams_become_pc_ones` and `console_depth_buffers_become_pc_ones` pass. - The one failure is `gpu_wave64_ps_whole_wave_reductions`. It fails the same way on `main` 956a476 on this GPU and is fixed by #155. It is unrelated to this PR.
ethandepstein-del commented 2026-11-24 07:04:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ethandepstein-del on 2026-11-23T20:28:01Z.


Independent Windows + RTX 5080 GPU verification of aeadb23f0 (merge-base db5dc26cb) on NVIDIA GeForce RTX 5080 (Blackwell desktop, driver 617.42, D3D12 SM 6.6 + mesh shaders, 32-wide waves, Windows 11, Ryzen 7 9800X3D, Rust 1.100.0, DXC 1.9.2602.17, no XCL_SAMPLE_*, no game files):

Build & Tests

  • cargo build --workspace && cargo test --workspace -- --test-threads=4: 571 passed, 0 failed, 39 ignored (git diff --check clean; 2 expected no wave64 skips).
  • New tests passed: console_depth_buffers_become_pc_ones, console_mesh_streams_become_pc_ones, and console_depth_views_become_pc_ones.

Code notes (non-blocking)

  • pc_stream_types renumbering of subobjects 24/25 by DXBC/DXIL program kind, D16S8 -> D24S8 mapping, RECT_LIST -> TRIANGLE, and fallback_stream avoiding dangling 0x1 for empty shader slices all look clean.
  • Two minor notes: (1) the branch is based on db5dc26 and bundles the xbox-depth-uav merge commits alongside the mesh-stream changes; (2) in real.rs::depth_srv_format(), (r != (view, if stencil { 1 } else { 0 }) || r.0 != view) has a redundant second clause (both evaluate to r.0 != view since r.1 always matches stencil), and returning None when a caller passes stencil format 22/47 leaves PlaneSlice unchanged if it was 0.

(AI-assisted)

<!-- greyfinch-sync:ivall/xcl:comment:7113102423 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/170#issuecomment-7113102423). Originally posted by [ethandepstein-del](https://github.com/ethandepstein-del) on 2026-11-23T20:28:01Z. --- Independent Windows + RTX 5080 GPU verification of `aeadb23f0` (merge-base `db5dc26cb`) on **NVIDIA GeForce RTX 5080** (Blackwell desktop, driver `617.42`, D3D12 SM 6.6 + mesh shaders, 32-wide waves, Windows 11, Ryzen 7 9800X3D, Rust `1.100.0`, DXC `1.9.2602.17`, no `XCL_SAMPLE_*`, no game files): ### Build & Tests - `cargo build --workspace && cargo test --workspace -- --test-threads=4`: **571 passed, 0 failed, 39 ignored** (`git diff --check` clean; 2 expected `no wave64` skips). - New tests passed: `console_depth_buffers_become_pc_ones`, `console_mesh_streams_become_pc_ones`, and `console_depth_views_become_pc_ones`. ### Code notes (non-blocking) - `pc_stream_types` renumbering of subobjects `24`/`25` by DXBC/DXIL program kind, `D16S8 -> D24S8` mapping, `RECT_LIST -> TRIANGLE`, and `fallback_stream` avoiding dangling `0x1` for empty shader slices all look clean. - Two minor notes: (1) the branch is based on `db5dc26` and bundles the `xbox-depth-uav` merge commits alongside the mesh-stream changes; (2) in `real.rs::depth_srv_format()`, `(r != (view, if stencil { 1 } else { 0 }) || r.0 != view)` has a redundant second clause (both evaluate to `r.0 != view` since `r.1` always matches `stencil`), and returning `None` when a caller passes stencil format `22`/`47` leaves `PlaneSlice` unchanged if it was `0`. *(AI-assisted)*
Kalmarv commented 2026-11-24 07:04:13 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-23T20:28:20Z.


Tested the stacked PR head aeadb23f0a4c29c0297392266e3de1cd9453251b directly against main at 956a476bf738a098f39df4f4c8acef682e43030f. Windows x64 MSVC, Rust 1.99.0, RTX 5070 Ti, driver 610.74. Synthetic debug-profile lib tests.

Check main PR head
Existing hle::d3d12x:: tests, including each revision's own tests 54 pass 56 pass
fallback_stream drops a GS, serialized (pointer, length) (1, 0) (0, 0)
Kind 14 in slot 25 and kind 13 in slot 24, in the same stream New helper absent Both tags corrected, every payload byte and the original stream preserved

One diagnostics issue remains. In crates/xcl/src/hle/d3d12x/real.rs:3888, capture runs on the original stream before the rewrite. For the PR's own slot-24/kind-13 fixture, null.rs:370 passes as to shader capture, so the by-stage count and optional dump filename identify that mesh program as an amplification shader. Capturing after pc_stream_types would make the report match the stream passed onward. This observation follows the call path in source.

The verbatim PR test cannot compile on main because pc_stream_types and program_kind are absent. The dropped-stage check exercises the same existing function on both revisions. These checks cover stream encoding. I did not submit these synthetic mesh shaders to the driver, merge onto main or run retail content. AI-assisted review.

<!-- greyfinch-sync:ivall/xcl:comment:7113110282 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/170#issuecomment-7113110282). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-23T20:28:20Z. --- Tested the stacked PR head `aeadb23f0a4c29c0297392266e3de1cd9453251b` directly against `main` at `956a476bf738a098f39df4f4c8acef682e43030f`. Windows x64 MSVC, Rust 1.99.0, RTX 5070 Ti, driver 610.74. Synthetic debug-profile lib tests. | Check | main | PR head | |---|---:|---:| | Existing `hle::d3d12x::` tests, including each revision's own tests | 54 pass | 56 pass | | `fallback_stream` drops a GS, serialized (pointer, length) | (1, 0) | (0, 0) | | Kind 14 in slot 25 **and** kind 13 in slot 24, in the same stream | New helper absent | Both tags corrected, every payload byte and the original stream preserved | One diagnostics issue remains. In `crates/xcl/src/hle/d3d12x/real.rs:3888`, capture runs on the original stream before the rewrite. For the PR's own slot-24/kind-13 fixture, `null.rs:370` passes `as` to shader capture, so the by-stage count and optional dump filename identify that mesh program as an amplification shader. Capturing after `pc_stream_types` would make the report match the stream passed onward. This observation follows the call path in source. The verbatim PR test cannot compile on main because `pc_stream_types` and `program_kind` are absent. The dropped-stage check exercises the same existing function on both revisions. These checks cover stream encoding. I did not submit these synthetic mesh shaders to the driver, merge onto main or run retail content. AI-assisted review.
ivall commented 2026-11-24 07:04:18 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T20:57:10Z.


Closing - main has the pieces in another form. On main (38b05b7, eaa36b6) the retail game now reaches its first menu at 30 fps with ~19 GB of commit, checked on an RX 9070; cargo test --workspace is green (548 unit tests). One finding to note: pipelines whose console MS container sits in subobject 24 (no MS subobject) are refused on main on purpose. Translated as the mesh shader they are, which is what this PR does by renumbering them to 25, the title rendered nothing from then on - a black screen on every run on the RX 9070. Refused, it goes on to its menu. What it expects of those pipelines is still open (see HANDOFF). The null stand-in shader pointers (no dangling 0x1) are on main from #195.

<!-- greyfinch-sync:ivall/xcl:comment:7113791364 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/170#issuecomment-7113791364). Originally posted by [ivall](https://github.com/ivall) on 2026-11-23T20:57:10Z. --- Closing - main has the pieces in another form. On main (38b05b7, eaa36b6) the retail game now reaches its first menu at 30 fps with ~19 GB of commit, checked on an RX 9070; `cargo test --workspace` is green (548 unit tests). One finding to note: pipelines whose console MS container sits in subobject 24 (no MS subobject) are refused on main on purpose. Translated as the mesh shader they are, which is what this PR does by renumbering them to 25, the title rendered nothing from then on - a black screen on every run on the RX 9070. Refused, it goes on to its menu. What it expects of those pipelines is still open (see HANDOFF). The null stand-in shader pointers (no dangling 0x1) are on main from #195.

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
xcl-dev/xcl!167
No description provided.