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

Closed
github-bot wants to merge 7 commits from gh-pr/170/head into gh-pr/170/base
Owner

@⁠Sr-0w on GitHub · 2026-11-23 18:39 UTC · original
Sr-0w:xbox-mesh-streams → main · +336 −5 · 2 files · 7 commits · closed without merging

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

**@⁠Sr-0w** on GitHub · 2026-11-23 18:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/170) `Sr-0w:xbox-mesh-streams` → `main` · +336 −5 · 2 files · 7 commits · closed without merging **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)
The console's DXGI_FORMAT_D16_UNORM_S8_UINT family (118, 119, 120) does not exist on the PC: it
becomes the D24_UNORM_S8_UINT family (45, 46, 47) in resource descs and in pipelines' DSV / RTV
formats (pc_format). The console allows a depth-stencil resource that is also a UAV; the PC
refuses that pair, so pc_resource_desc keeps the depth flag and drops unordered access, and a
placed depth buffer's UNORDERED_ACCESS initial state becomes DEPTH_WRITE.

GTA VI stopped on assertions at +0x344196 (its 2560x1440 D16S8 depth buffer got no size from
GetResourceAllocationInfo) and +0x14a6390 (its 768x768x6 shadow maps, placed with the UAV state,
were refused). Resources that still get no size or are refused are logged with their PC desc.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B
GTA VI's pipeline streams carry their mesh shader (DXIL program kind 13) as subobject type 24,
the PC's amplification shader. translated_mesh_stream found no MS, did not translate them and
the driver refused the stream ("CreateAmplificationShader: ms_6_6", then "neither VS, CS nor
MS"). pc_stream_types renumbers AS / MS subobjects by the program kind in their bytecode and
makes the stream's console formats (D16S8 DSV / RTV) and rect-list topology type the PC's,
before any other path reads the stream.

fallback_stream wrote an empty slice's dangling pointer (0x1) for the shaders it drops: the
driver refused the mesh stand-ins (0x80070057) and the debug layer crashed reading 0x19. It
now writes a null pointer.

A stream refused even with stand-ins logs its subobject types and shader kinds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B
pc_resource_desc drops ALLOW_UNORDERED_ACCESS from a console depth buffer that is also a UAV.
GTA VI still creates UAVs of its 768x768 shadow maps: the driver was handed an invalid view
(debug layer: "CreateUnorderedAccessView … did not specify ALLOW_UNORDERED_ACCESS") and the
device was removed once a dispatch used it. The PC descriptor is now a null view of the same
dimension; the console descriptor XCL writes for translated shaders is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B
#163 makes the console's D16S8 depth buffers D24S8 on the PC; what refers to them kept the
console's formats and the PC refused them (GTA VI, with the D3D12 debug layer):
- a clear value of format 118 on a D24S8 resource: E_INVALIDARG, then the title's assertion;
- CreateDepthStencilView with format 118 (now hooked): the device was removed (~55 s in);
- SRVs of depth / stencil planes as R16_UNORM, R8_UINT, and of a D32S8 (R32G8X24_TYPELESS)
  as R32_FLOAT – also the SRV XCL makes next to a texture UAV: now
  R24_UNORM_X8_TYPELESS / X24_TYPELESS_G8_UINT / R32_FLOAT_X8X24_TYPELESS /
  X32_TYPELESS_G8X24_UINT with the matching plane slice (`depth_srv_format`);
- the null UAV of a depth buffer kept the console view's plane slice 1.
RTVs and SRVs with 118–120 go through `pc_format` too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA
# Conflicts:
#	crates/xcl/src/hle/d3d12x/real.rs
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:13:32 +00:00
github-bot closed this pull request 2026-11-26 04:13:32 +00:00
Author
Owner

@⁠TheHoracio on GitHub · 2026-11-23 19:28 UTC · original

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.
**@⁠TheHoracio** on GitHub · 2026-11-23 19:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/170#issuecomment-7111649665) 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.
Author
Owner

@⁠mastrr9 on GitHub · 2026-11-23 20:28 UTC · original

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)

**@⁠mastrr9** on GitHub · 2026-11-23 20:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/170#issuecomment-7113102423) 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)*
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-23 20:28 UTC · original

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.

**@⁠Kalmarv** on GitHub · 2026-11-23 20:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/170#issuecomment-7113110282) 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.
Author
Owner

@⁠ivall on GitHub · 2026-11-23 20:57 UTC · original

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.

**@⁠ivall** on GitHub · 2026-11-23 20:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/170#issuecomment-7113791364) 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

This discussion has been locked. Commenting is limited to contributors.
No description provided.