Skip to content

DirectStorage: submitted cancellation, intermediate_size, and physical-page destinations - #21

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:dstorage-enhancements
Nov 21, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
raylitebull:dstorage-enhancements

Conversation

@raylitebull

Copy link
Copy Markdown
Member

Summary

Implements three console DirectStorage (xcrdapi.dll) enhancements in crates/xcl/src/hle/dstorage.rs:

  1. Cancellation of already-submitted requests (CancelRequestsWithTag):

    • Assigns monotonically increasing sequence numbers to enqueued requests and tracks { up_to_seq, mask, value } cancellation rules in shared queue state (pruned as the worker advances).
    • Locks worker before pending in QueueInner::submit() so concurrent submissions preserve strict FIFO ordering.
    • Skips matching pending and queued-but-unexecuted requests cleanly without affecting IDStorageStatusArrayX or DSTORAGE_ERROR_RECORD, while leaving requests enqueued after CancelRequestsWithTag unaffected.
    • Wraps Entry::Signal in an RAII FenceRef so ID3D12Fence COM references are never leaked on close or error.
  2. Multi-stage decompression / intermediate_size:

    • Decodes the full Xbox DSTORAGE_REQUEST_OPTIONS bitfield (ZlibDecompress bit 0, BcpackMode bits 1..=4, SwizzleMode bits 5..=20, DestinationIsPhysicalPages bit 21, SourceType bit 22, SourceIsPhysicalPages bit 23).
    • Supports zlib inflation into an intermediate buffer when source_size < intermediate_size <= destination_size (zero-padding any trailing destination bytes), validates two-stage bounds (E_DESTINATION_SIZE), and refuses unsupported BCPack / hardware swizzle modes with E_DECOMPRESSION.
  3. Physical-page destinations and sources (DestinationIsPhysicalPages / SourceIsPhysicalPages):

    • On Xbox Series X|S (UMA), placed D3D12 buffers and textures live at virtual/UMA addresses (tracked via MEM_WRITE_WATCH), while the non-virtual mode in the 0x48-byte DSTORAGE_REQUEST targets 64 KiB physical page arrays (DestinationPageArray + DestinationPageOffset @0x10; SourcePageArray + SourcePageOffset @0x28).
    • Snapshots PULONG_PTR page arrays at enqueue time and exports PHYS_PAGE_SIZE, read_physical_pages, and write_physical_pages in crates/xcl/src/hle/kernelx.rs (obeying AWAY -> PHYS_BLOCKS lock order and validating all pages before copying, including pages mapped into reserved virtual address space).

Testing

  • Unit tests in crates/xcl/src/hle/dstorage.rs: cancel_pending_and_submitted_requests_by_tag, multi_stage_intermediate_size_validation_and_zlib, physical_page_destinations_and_sources.
  • Extended tests/testtitle/src/gpu.rs::direct_storage e2e check with DestinationIsPhysicalPages + DestinationPageOffset and CancelRequestsWithTag.
  • cargo build --workspace (0 new warnings) and cargo test --workspace -- --test-threads=4 all passing (243 lib + 12 console_dlls_e2e + 1 console_shaders + 1 e2e + 6 gpu_pso_e2e + 3 xg_oracle).

@ivall

ivall commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Reviewed and merged, thanks – the physical-page reads / writes follow XCL's page model (a page is at its home or where it is mapped), and BCPack / hardware swizzle modes are refused instead of faked. Checked together with #21, #22 and #25 on top of current main: full workspace tests pass (277 lib tests, e2e, console_dlls_e2e, gpu_pso_e2e, rpf_e2e), no new build warnings.

@ivall
ivall merged commit 72bb284 into xcl-dev:main Nov 21, 2026
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
…wports/scissors/topo) into ListDrawRecord

List slots xcl-dev#34 (SetGraphicsRootSignature), xcl-dev#50 (OMSetRenderTargets),
xcl-dev#47 (IASetIndexBuffer), plus PC-side xcl-dev#20/xcl-dev#21/xcl-dev#22 (topology, viewports,
scissors) store into ListDrawRecord. SetPipelineState (xcl-dev#25) now merges
instead of overwriting so PSO-first or state-first order both keep the
full record. Store-only: no draw, no validation, no execute; triangle/
bias FAILs stay failing.

Evidence: new draw_s2_list_state_recorded_pre_draw fails pre-change
(S2 symbols absent at HEAD: grep count 0) and passes post; full lib
806 passed, 0 failed, 1 ignored; both cargo checks clean; title null
4 FAILs identical to HEAD-baseline worktree run (triangle, present,
bias-xcl-dev#94, all D3D12.X GPU-only, + pre-existing files:delete also on
HEAD), delta 0; Vulkan 3 (triangle, bias-xcl-dev#94 + same files:delete);
retail HOLDS (exit 139 @ exe+0x2237320, SIGSEGV fault 0, 20 stubs,
xgr XAsync/XNetworking/XUser, 0 d3d12).
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