Keep a retail title loading: DSP, Xbox formats, and a pipeline cache #150

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

@⁠Yeetbot159 on GitHub · 2026-11-23 16:39 UTC · original
Yeetbot159:xdsp-chad → main · +1450 −165 · 15 files · 5 commits · closed without merging

Summary

  • Answer chad.dll XDsp calls so a missing DSP returns success instead of a breakpoint.
  • Map Xbox-only formats onto formats a PC driver accepts. D16 with stencil becomes D24 with stencil, and its typeless parent and shader views stay in that same family. The small float colour formats become a PC float format.
  • Stop translating every shader a second time just to write dumps (XCL_SHADER_DUMP=1 still does that). Keep thousands of translated shaders in memory, and save each finished shader and the driver's compiled pipeline blob so the next launch does not compile them again.

Test plan

  • cargo test --release -p xcl --lib
  • A retail title gets past DSP connect, and pipelines that used Xbox depth format 118 are created
  • A second launch reuses %LOCALAPPDATA%\xcl\dxil\blob-*.xsh and %LOCALAPPDATA%\xcl\pso\*.blob instead of recompiling those shaders and pipelines
**@⁠Yeetbot159** on GitHub · 2026-11-23 16:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/150) `Yeetbot159:xdsp-chad` → `main` · +1450 −165 · 15 files · 5 commits · closed without merging ## Summary - Answer `chad.dll` XDsp calls so a missing DSP returns success instead of a breakpoint. - Map Xbox-only formats onto formats a PC driver accepts. D16 with stencil becomes D24 with stencil, and its typeless parent and shader views stay in that same family. The small float colour formats become a PC float format. - Stop translating every shader a second time just to write dumps (`XCL_SHADER_DUMP=1` still does that). Keep thousands of translated shaders in memory, and save each finished shader and the driver's compiled pipeline blob so the next launch does not compile them again. ## Test plan - [ ] `cargo test --release -p xcl --lib` - [ ] A retail title gets past DSP connect, and pipelines that used Xbox depth format 118 are created - [ ] A second launch reuses `%LOCALAPPDATA%\xcl\dxil\blob-*.xsh` and `%LOCALAPPDATA%\xcl\pso\*.blob` instead of recompiling those shaders and pipelines
Connect, activate, submit, deactivate and disconnect succeed. Each command finishes in the call, and an output block inside the registered buffer is silence.
Keep chad.dll on the audio processor. Drop the separate XDsp module so the two implementations do not both claim the DLL.
A cold load translated every shader twice and kept only 128 of them, and the driver recompiled every pipeline on the next launch. Xbox D16-with-stencil was also rejected as an unknown format.
A console depth buffer that is also a UAV is created as D16, and a UAV view of a resource without unordered access is a null view. New pipeline compiles stay off the title thread. xcl shaders --precompile --gentle fills the DXIL and driver caches a few at a time.

Co-authored-by: Cursor <[email protected]>
Upstream shares one deadline across frame-event types and runs ExecuteCommandListsX, which is what gets a retail title to a steady 30 fps. An amplification shader is still not translated; the mesh shader is, so the pipeline is created instead of refused.

Co-authored-by: Cursor <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:12:45 +00:00
github-bot closed this pull request 2026-11-26 04:12:45 +00:00
Author
Owner

@⁠ShyVortex on GitHub · 2026-11-23 17:33 UTC · original

I ran into the same 118 depth format independently while bringing up a retail game on an NVIDIA laptop. One piece this PR doesn't have might be worth adding: xg.rs doesn't know 118, so GetResourceAllocationInfo doesn't get the console's size for these textures.

The game I tested creates a 2560×1440 depth buffer in 118 and asks GetResourceAllocationInfo (#25) for its size. xg::Texture::new fails on 118, so get_resource_allocation_info_x falls back to the PC driver:

  • Without format mapping: the driver answers UINT64_MAX, and the game stops at its own assertion that the size fits in 32 bits.
  • With this PR's pc_resource_format (118 → 45): the call succeeds, but it returns the PC's D24S8 size (a 4-byte depth plane) instead of the console's (a 2-byte depth plane). The title places resources in its own memory using that size.

XG already models the D24S8 family as two planes, so 118 fits in with a 2-byte depth plane. On my branch it's this, plus a test that a 2560×1440 depth buffer in 118 has the same planes as one in 45 and is smaller:

// depth + stencil formats: a 4-byte depth plane and a 1-byte stencil plane – a 2-byte
// depth plane in the console's own D16_UNORM_S8_UINT (118) and its plane views (119, 120)
let planar = matches!(format, 19..=22 | 44..=47 | 118..=120);
let (e, side) = if planar { (if format >= 118 { 1 } else { 2 }, 1) } else { element(format).ok_or(E_INVALIDARG)? };

The 2-byte depth plane is inferred from the format's name and from how XG lays out the D24S8 family, not checked against the console's own XG output. Happy to open it as a separate PR on top of this one if you'd rather.

**@⁠ShyVortex** on GitHub · 2026-11-23 17:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/150#issuecomment-7108823017) I ran into the same 118 depth format independently while bringing up a retail game on an NVIDIA laptop. One piece this PR doesn't have might be worth adding: `xg.rs` doesn't know 118, so `GetResourceAllocationInfo` doesn't get the console's size for these textures. The game I tested creates a 2560×1440 depth buffer in 118 and asks `GetResourceAllocationInfo` (#25) for its size. `xg::Texture::new` fails on 118, so `get_resource_allocation_info_x` falls back to the PC driver: - **Without format mapping:** the driver answers `UINT64_MAX`, and the game stops at its own assertion that the size fits in 32 bits. - **With this PR's `pc_resource_format` (118 → 45):** the call succeeds, but it returns the PC's D24S8 size (a 4-byte depth plane) instead of the console's (a 2-byte depth plane). The title places resources in its own memory using that size. XG already models the D24S8 family as two planes, so 118 fits in with a 2-byte depth plane. On my branch it's this, plus a test that a 2560×1440 depth buffer in 118 has the same planes as one in 45 and is smaller: ```rust // depth + stencil formats: a 4-byte depth plane and a 1-byte stencil plane – a 2-byte // depth plane in the console's own D16_UNORM_S8_UINT (118) and its plane views (119, 120) let planar = matches!(format, 19..=22 | 44..=47 | 118..=120); let (e, side) = if planar { (if format >= 118 { 1 } else { 2 }, 1) } else { element(format).ok_or(E_INVALIDARG)? }; ``` The 2-byte depth plane is inferred from the format's name and from how XG lays out the D24S8 family, not checked against the console's own XG output. Happy to open it as a separate PR on top of this one if you'd rather.
Author
Owner

@⁠Yeetbot159 on GitHub · 2026-11-23 19:49 UTC · original

Follow-up

Depth buffers the console also marks as UAVs are created as D16, and a UAV view of a resource without unordered access is a null view, so that create does not remove the device. New driver compiles stay off the title thread. xcl shaders --precompile --gentle fills the DXIL cache and the driver pipeline cache a few at a time.

**@⁠Yeetbot159** on GitHub · 2026-11-23 19:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/150#issuecomment-7112152475) ## Follow-up Depth buffers the console also marks as UAVs are created as D16, and a UAV view of a resource without unordered access is a null view, so that create does not remove the device. New driver compiles stay off the title thread. `xcl shaders --precompile --gentle` fills the DXIL cache and the driver pipeline cache a few at a time.
Author
Owner

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

Explicit color RTVs still reach the driver in the console format. On PR head f924174fe0759378bdd2d961eb76b59f0a47b125, formats 116/117 become R16G16B16A16_FLOAT (10) in both the resource and graphics PSO. At crates/xcl/src/hle/d3d12x/real.rs:4104, dev_create_rtv forwards the original descriptor unchanged.

I created a synthetic 16×16 format-10 render target and called the hook on an adopted D3D12 device with explicit Texture2D views. Windows x64 MSVC, RTX 5070 Ti, driver 610.74, native D3D12 debug layer. Main was 956a476bf738a098f39df4f4c8acef682e43030f; both revisions ran directly.

Input RTV format on the format-10 resource main PR head
10 No debug-layer errors No debug-layer errors
116 IDs 38, 38, 38, 232 IDs 38, 38, 38, 232

A second issue concerns shader updates. In crates/xcl/src/gpu/recomp/pso.rs:301, a miss in the existing build-keyed translation cache can hit the new blob-*.xsh cache. Its key at line 232 includes the program and translation parameters but omits the translator build. With the same input on a new XCL build, a cached translation from the previous build can therefore be returned and stored under the new build identity. This follows from the lookup order; I did not perform a two-build cache migration test.

The selected D3D12.X, DXC/PSO cache, shader and HLE modules passed 81 tests on head and 80 on main, plus the synthetic launcher selection test on each. The copied PR unit-test changes as a group could not compile on main because helpers and the PSO disk module are new; the RTV check runs independently on both. The RTV was never bound or drawn. No retail content, full workspace run or warm-launch performance measurement. AI-assisted review.

**@⁠Kalmarv** on GitHub · 2026-11-23 20:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/150#issuecomment-7113412364) **Explicit color RTVs still reach the driver in the console format.** On PR head `f924174fe0759378bdd2d961eb76b59f0a47b125`, formats 116/117 become `R16G16B16A16_FLOAT` (10) in both the resource and graphics PSO. At `crates/xcl/src/hle/d3d12x/real.rs:4104`, `dev_create_rtv` forwards the original descriptor unchanged. I created a synthetic 16×16 format-10 render target and called the hook on an adopted D3D12 device with explicit Texture2D views. Windows x64 MSVC, RTX 5070 Ti, driver 610.74, native D3D12 debug layer. Main was `956a476bf738a098f39df4f4c8acef682e43030f`; both revisions ran directly. | Input RTV format on the format-10 resource | main | PR head | |---|---|---| | 10 | No debug-layer errors | No debug-layer errors | | 116 | IDs 38, 38, 38, 232 | IDs 38, 38, 38, 232 | A second issue concerns shader updates. In `crates/xcl/src/gpu/recomp/pso.rs:301`, a miss in the existing build-keyed translation cache can hit the new `blob-*.xsh` cache. Its key at line 232 includes the program and translation parameters but omits the translator build. With the same input on a new XCL build, a cached translation from the previous build can therefore be returned and stored under the new build identity. This follows from the lookup order; I did not perform a two-build cache migration test. The selected D3D12.X, DXC/PSO cache, shader and HLE modules passed 81 tests on head and 80 on main, plus the synthetic launcher selection test on each. The copied PR unit-test changes as a group could not compile on main because helpers and the PSO disk module are new; the RTV check runs independently on both. The RTV was never bound or drawn. No retail content, full workspace run or warm-launch performance measurement. AI-assisted review.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-24 10:43 UTC · original

Closing as a stale, conflicting ~1,600-line monolith missing required template sections; its format and pipeline-cache pieces have since landed via #210, #634, and #690. If any standalone piece is still needed, please open a small single-purpose PR against current main.

**@⁠raylitebull** on GitHub · 2026-11-24 10:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/150#issuecomment-7129153747) Closing as a stale, conflicting ~1,600-line monolith missing required template sections; its format and pipeline-cache pieces have since landed via #210, #634, and #690. If any standalone piece is still needed, please open a small single-purpose PR against current `main`.

Pull request closed

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