Skip to content

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

Closed
Sr-0w wants to merge 7 commits into
ivall:mainfrom
Sr-0w:xbox-mesh-streams
Closed

Sr-0w wants to merge 7 commits into
ivall:mainfrom
Sr-0w:xbox-mesh-streams

Conversation

@Sr-0w

@Sr-0w Sr-0w commented Nov 23, 2026 •

Copy link
Copy Markdown

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

Problem

GTA VI'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

Test plan

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

🤖 Generated with Claude Code

https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B

Sr-0w and others added 2 commits November 23, 2026 19:02
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B
…nd-in shaders

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
gbuyssens pushed a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…offset (from ivall#169)

The retail game called ivall#10 (a stub returning E_NOTIMPL) and then wrote to address 0 at
+0x2215c35. ivall#10 / ivall#11 are GetSubresourceLayout / GetSubresourceOffsetBytes: the
XG_SUBRESOURCE_LAYOUT of a subresource, or its byte offset.

Only xg.rs of ivall#169 is taken: its DSV format 118 remap is covered more completely by
ivall#163 (merged with ivall#170: resource descs, pipelines, depth buffers that are UAVs).
gbuyssens added a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
gbuyssens pushed a commit to gbuyssens/xcl that referenced this pull request Nov 23, 2026
…offset (from ivall#169)

A title called ivall#10 (a stub returning E_NOTIMPL) and then wrote to address 0.
ivall#10 / ivall#11 are GetSubresourceLayout / GetSubresourceOffsetBytes: the
XG_SUBRESOURCE_LAYOUT of a subresource, or its byte offset.

Only xg.rs of ivall#169 is taken: its DSV format 118 remap is covered more completely by
ivall#163 (merged with ivall#170: resource descs, pipelines, depth buffers that are UAVs).
Sr-0w and others added 2 commits November 23, 2026 20:18
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTYmP6vKUQKatSiA2PC95B
theaustinayers added a commit to theaustinayers/xcl that referenced this pull request Nov 23, 2026
…-target and texture-address fixes

Open upstream pull requests applied as they are (their authors' work):
- ivall#151 (gbuyssens): clzero / clwb / rdpru / monitorx / mwaitx / rdpid emulated
  on CPUs that lack them (HANDOFF.md hunk left out, it did not apply).
- ivall#163, ivall#170 (Sr-0w): Xbox D16S8 depth formats, depth + UAV buffers, console
  mesh pipeline streams, null stand-in shaders.
- ivall#168 (ShyVortex): GetGPUVirtualAddress of a placed texture.

Local changes:
- xg: XGTextureAddressComputer ivall#10 as GetResourceTiling, from the layout model
  (not checked against the console's library).
- d3d12x: a UAV of a texture made without ALLOW_UNORDERED_ACCESS is a null UAV
  (the real call removed the device); a committed texture gets memory when the
  title asks for its address; clear values and view descriptions get pc_format;
  formats 86 / 115 -> R8G8B8A8, 116 / 117 -> R16G16B16A16_FLOAT.
- Debug layer log: 8 messages per id instead of 200 in all.
- The earlier "AS slot ignored" workaround stays but is no longer reached (ivall#170).
- CHANGES.txt, README status and installer version for build 3.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@TheHoracio

Copy link
Copy Markdown
Contributor

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.

Sr-0w and others added 3 commits November 23, 2026 20:59
… buffers

ivall#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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SKtJseucqXR6iuAE6HBtiA
…eams

# Conflicts:
#	crates/xcl/src/hle/d3d12x/real.rs
@RemingtonWilcox

Copy link
Copy Markdown
Contributor

Tested aeadb23 merged onto main 956a476 on an RTX 3090 (driver 616.92), Windows 11 26300, Ryzen 9 5950X.
cargo test --workspace --no-fail-fast -- --test-threads=2: 572 passed, 0 failed, 39 ignored (main: 569 / 0 / 39). console_mesh_streams_become_pc_ones, console_depth_buffers_become_pc_ones and console_depth_views_become_pc_ones pass. No regressions.

AI-assisted test report (Claude); tests run locally as stated; the diff was read in full before running.

@ethandepstein-del

Copy link
Copy Markdown

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

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Owner

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 ivall closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants