Skip to content

D3D12.X: fix async compute PSO tracking, initial PSO binding, DrawIndexedX, and KickoffX MRT restore - #102

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:fix/d3d12x-async-compute-and-bind
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:fix/d3d12x-async-compute-and-bind

Conversation

@raylitebull

Copy link
Copy Markdown
Member

Summary

Fixes 4 D3D12.X command-list binding and async compute PSO bugs in crates/xcl/src/hle/d3d12x/{real.rs, bind.rs, device_x.rs, list_x.rs, console_list.rs}:

  1. Async compute PSO registration & failure handling (real.rs, bind.rs, console_list.rs):

    • Previously, dev_create_compute_pso registered the stand-in PSO S in TRANSLATED_COMPUTE on cache miss, while translated_compute_pso never registered the real compiled PSO R (unlike translated_graphics_pso). As a result:
      • bind::execute_indirect resolved S -> R, saw is_translated_compute(R) == false, and skipped bind_abi completely.
      • If background build_compute failed (real == 0), S remained in TRANSLATED_COMPUTE so bind::dispatch bound XCL's ABI root signature + 6 UAVs onto stand-in S (which uses the title's root signature).
    • Moved note_translated_compute(hr, ppv) into translated_compute_pso (matching translated_graphics_pso), removed stand-in registration, and resolved pso_async::resolve_wait before is_translated_compute so completed async compute PSOs bind the ABI cleanly and failed builds skip safely.
  2. Initial PSO & root-arg state tracking on CreateCommandList, Reset, and ClearState (bind.rs, device_x.rs, list_x.rs, real.rs):

    • bind::reset(list, allocator, initial_pso) now sets s.pso = initial_pso and clears stale compute/graphics root layouts & arguments.
    • Added bind::clear_state(list, pso) wired into real::cl_clear_state, resolved pso via pso_async::resolve_for_bind in device_x::create_list and real::cl_reset, and called bind::forget(this) on final command-list Release.
  3. DrawIndexedX (hle/dstorage: fix queue error reset, event handle duplication, close/release races, and pointer validation #81) routing through bind.rs (list_x.rs):

    • Routed list_x::draw_indexed_x through super::bind::draw_indexed_instanced(this, count, 1, 0, 0, 0) instead of invoking raw PC DrawIndexedInstanced directly, ensuring translated console graphics pipelines bind the XCL ABI root signature and user SGPRs on DrawIndexedX.
  4. KickoffX MRT render-target restoration for RTsSingleHandleToDescriptorRange != 0 (list_x.rs):

    • Preserved the requested target count (clamped to D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT = 8) in RenderTargets when single != 0, so restore_bindings passes rt.num_targets instead of hardcoding 1 and dropping MRTs 1..N.

Testing

  • Added 6 targeted unit & GPU E2E tests:
    • bind::tests::reset_and_clear_state_track_initial_pso_and_clear_root_args
    • bind::tests::async_compute_pso_success_and_failure_in_dispatch_and_execute_indirect
    • bind::tests::create_list_reset_and_clear_state_track_initial_pso_on_d3d12
    • list_x::tests::draw_indexed_x_routes_through_bind_and_restores_index_buffer
    • list_x::tests::kickoff_x_render_targets_preserve_mrt_count_for_single_descriptor_range
    • gpu_compute_e2e::async_compute_pso_registers_real_pso_and_not_standin (cold-cache DXC + real D3D12 compute dispatch)
  • GPU / Driver: AMD Radeon RX 9070 XT, driver 32.0.32015.2008 (D3D12 GPU tests verified on AMD only).
  • Verified after rebasing onto origin/main (60599a9): cargo build --workspace and cargo test --workspace -- --test-threads=4 pass with 0 failures and 0 new warnings.

@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged. It conflicted with #99 in list_x.rs tests (both appended tests at the end of the module); resolved keeping both. Merged together with #95–#102 and checked on Windows 11 with an RX 9070: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; XDefiant (title screen, a scripted A reaches its "Xbox network unavailable" dialog), Unicorn Overlord and Minecraft run. Thanks!

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.

2 participants