Skip to content

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

Closed
Yeetbot159 wants to merge 5 commits into
xcl-dev:mainfrom
Yeetbot159:xdsp-chad
Closed

Yeetbot159 wants to merge 5 commits into
xcl-dev:mainfrom
Yeetbot159:xdsp-chad

Conversation

@Yeetbot159

@Yeetbot159 Yeetbot159 commented Nov 23, 2026 •

Copy link
Copy Markdown

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

BED added 3 commits November 23, 2026 17:39
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.
…formats.

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.
@Yeetbot159 Yeetbot159 changed the title Answer chad.dll XDsp calls so a missing DSP is not fatal Keep a retail title loading: DSP, Xbox formats, and a pipeline cache Nov 23, 2026
@ShyVortex

Copy link
Copy Markdown

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.

…shaders beside other work.

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 <cursoragent@cursor.com>
@Yeetbot159

Copy link
Copy Markdown
Author

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.

…pelines that carry an amplification shader.

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 <cursoragent@cursor.com>
@Kalmarv

Kalmarv commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

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.

@raylitebull

Copy link
Copy Markdown
Member

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.

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.

4 participants