d3d12x: implement KickoffX, Wait32/64BitValueX, and RSSetDepthBiasX #22
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-21T21:59:12Z.
Implements three D3D12.X command list extensions in
crates/xcl/src/hle/d3d12x/:Summary
KickoffX(command list slot #93):(device, list_type)(withReleasecleanup on lists, queues, and allocators).ExecuteCommandLists, resetting the list on the same allocator (preserving XCL's vtable on copy lists), and restoring tracked state.Close+ExecuteCommandLists.Wait32BitValueX(#71) andWait64BitValueX(#72):(va, comparison, value, mask, flags)withD3D12_COMPARISON_FUNC(1..=8) and(mem & mask) <op> valuesemantics.ALWAYSas a no-op and logs/skipsNEVERto prevent hangs.execute_with_waits(splitting multi-listExecuteCommandListsbatches before an unsatisfied list, with spin+sleep polling and a 2 s timeout cap).RSSetDepthBiasX(command list slot #94):(depthBias: f32, depthBiasClamp: f32, slopeScaledDepthBias: f32)with non-finite sanitization and an atomic fast-path guard.device_x::depth_bias_pso, patchingRasterizerState.{DepthBias, DepthBiasClamp, SlopeScaledDepthBias}at verified offsets0x1D0..0x1DC, capped at 1024 entries and COM-released outside locks inforget_base).DrawInstanced,DrawIndexedInstanced,DrawIndexedX,ExecuteIndirect) and restores the base PSO when reset to(0, 0, 0)(or onReset/ClearState).Testing
device_x.rsandlist_x.rscoveringDepthBiasdesc patching/offsets,compare_u64, 32/64-bit masked cross-thread waits + timeout, written-range overlap,execute_with_waitsbatch splitting, queue picking/release, and depth-bias state transitions.tests/testtitle/src/gpu.rscoveringKickoffX(verifying GPU write completes beforeClose()and post-kickoff recording succeeds), cross-threadWait32BitValueX/Wait64BitValueX, andRSSetDepthBiasXon a real depth buffer.cargo build --workspace: 0 new warnings.cargo test --workspace -- --test-threads=4: all tests passed (xcllib 247 passed,console_dlls_e2e12 passed,console_shaders1 passed,e2e1 passed,gpu_pso_e2e6 passed,xg_oracle3 passed).Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-21T22:04:49Z.
Transparency note on what is grounded vs. inferred in this PR, since this touches the D3D12.X submission path and was written without a real console executable or live capture:
What is grounded in the repo
#71Wait32BitValueX,#72Wait64BitValueX,#93KickoffX,#94depth bias X) match what is already documented inHANDOFF.md.D3D12_GRAPHICS_PIPELINE_STATE_DESCRasterizerStatedepth-bias offsets (0x1D0..0x1DC) match standard PC D3D12 layout.What was inferred and needs verification against real title call sites
Wait32BitValueX(#71) /Wait64BitValueX(#72) assume(va: u64, comparison: u32, value: u32/u64, mask: u32/u64, flags: u32)withD3D12_COMPARISON_FUNC(1..=8) and(mem & mask) <op> value. Argument order, parameter count, and enum numbering (1-basedD3D12_COMPARISON_FUNCvs. 0-based PM4) should be checked against an actual call site.RSSetDepthBiasX(#94) assumes(depthBias: f32, depthBiasClamp: f32, slopeScaledDepthBias: f32)(roundingdepthBiastoi32forD3D12_RASTERIZER_DESC::DepthBias); the console ABI may passi32or a different parameter layout.KickoffX(#93) assumes 0 arguments (fn(this)).KickoffX(#93) PC state-loss & queue-ordering caveats:Close()->ExecuteCommandLists()->Reset()on a PC command list clears all D3D12 dynamic state. Currently this only restoresbound_pso,index_buffer, anddepth_bounds— it does not restore descriptor heaps, root signatures/arguments, render targets, viewports, scissors, vertex buffers, primitive topology, blend factor, or stencil ref. Any draw recorded afterKickoffXthat relies on previously bound state will drop it unless those are also tracked and rebound.last_queueis unknown,pick_queuepicks the most recently active compatible live queue, which can guess wrong if a title uses multiple queues of the same type or submits batches in a specific order across lists.Wait32BitValueX/Wait64BitValueX(#71/#72) CPU wait inExecuteCommandListsvs. GPU CP wait:ExecuteCommandLists, and same-listlist_xmemory writes skip waiting), so recording itself won't deadlock.ExecuteCommandLists(with a 2 s timeout cap) is still an approximation of a GPU command-processor stall: it will time out if (a) a shader/UAV write earlier in the same unsubmitted list is the producer (not tracked inwritten_ranges), or (b) the title submits a wait on Queue A before submitting the producer on Queue B from the same thread.Happy to adjust any signatures once checked against a real trace, keep parts behind a flag/opt-in, or trim this down if you'd rather keep these slots as logged no-ops until real call sites are observed.
Imported from ivall/xcl. Originally posted by oskpzme on 2026-11-21T22:20:43Z.
you're amazing man, keep it up just don't burn yourself out 😭
Imported from ivall/xcl. Originally posted by ivall on 2026-11-22T10:15:30Z.
Merged in
7e74038(conflicts with main resolved by hand), thanks.One change on top: KickoffX resets the PC list mid-recording, and the Reset also clears state the title had set and keeps using afterwards - descriptor heaps, topology, viewports, scissors, blend factor, stencil ref, vertex buffers, render targets. On the console a kickoff leaves the list as it was. Without the heaps, a translated draw or dispatch after a kickoff indexes whatever heap is bound (garbage descriptors). That state is now tracked per list (console #20-#24, #32, #48, OMSetRenderTargets) and set again right after the Reset (
restore_bindingsin list_x.rs). Your test-title checks (KickoffX, Wait32/64, depth bias across KickoffX) all pass with it.