Skip to content

d3d12: import non-contiguous XMem backings through a reserved buffer - #253

Open
DrArroway wants to merge 1 commit into
brcly:mainfrom
DrArroway:feat/d3d12-scattered-backing-reserved
Open

DrArroway wants to merge 1 commit into
brcly:mainfrom
DrArroway:feat/d3d12-scattered-backing-reserved

Conversation

@DrArroway

Copy link
Copy Markdown
Contributor

Summary

Extends #218 for #191 to support non-contiguous XMem physical backings using CreateReservedResource + synchronous UpdateTileMappings, for the multi-view GPU-alias imports where page orders disagree across imports (@gtb-sbe measured 16 of 131 imports / 277.6 MiB requiring this path in ProjectScarlett).

Changes

  • backing.rs: Keeps the existing TuxBoxAcquirePhysicalBacking + TuxBoxReleasePhysicalBacking contract unchanged and adds an optional fallback to TuxBoxAcquirePhysicalBackingRuns:
    struct BackingRun { UINT64 address; UINT64 bytes; }
    BOOL TuxBoxAcquirePhysicalBackingRuns(UINT64 address, UINT64 bytes, BackingRun* runs, UINT32* count, UINT64* hold);
    
    When TuxBoxAcquirePhysicalBacking fails with ERROR_NOT_SUPPORTED and TuxBoxAcquirePhysicalBackingRuns is exported, tries a 16-entry inline stack buffer (retrying on ERROR_MORE_DATA / ERROR_INSUFFICIENT_BUFFER), validates 64 KiB alignment and summed byte size while always releasing the hold on error, collapses single-run responses to contiguous, and otherwise returns AcquiredBacking::Scattered.
  • allocation.rs: Factored queue synchronization (wait_for_queue / with_init_transition) on InitTransition and added synchronous map_reserved_tiles (UpdateTileMappings).
  • import.rs:
    • Adds extra_heaps + ImportedHeap::scattered preserving drop order (native -> extra_heaps -> _pin -> _shadow -> _backing).
    • Adds import_scattered_buffer (requires offset == 0, ID3D12Device13, TiledResourcesTier >= 1, opens each piece via OpenExistingHeapFromAddress1, creates a buffer via CreateReservedResource, maps all piece heaps via map_reserved_tiles, attaches all heaps to the resource).
    • Wires acquire_backing into import_buffer_with_heap and guards reusable_for / buffer_alias on scattered heaps.
  • heap_backing.rs: Adds 4 unit tests covering multi-run acquisition/release, overflow retry (> 16 runs), hold release on invalid runs, and single-run collapse, plus a real-GPU test (scattered_alias_imports_through_reserved_buffer_and_aliases_cpu_and_gpu) verifying [c, a, b] and [b, c] scattered aliasing, non-64 KiB multiple width (2 * PAGE + 1024), ALLOW_UNORDERED_ACCESS, bidirectional CPU/GPU reads/writes, hold release, and post-drop submit survival.

Like #218, this stays dormant until xmem.dll exports TuxBoxAcquirePhysicalBackingRuns (and TuxBoxAcquirePhysicalBacking).

tuxbox-d3d12 tests

  • tuxbox-d3d12 on RX 6900 XT (GE-Proton11-14): 163 passed, 0 failed (11/11 device::heap::backing::tests).
  • tuxbox-d3d12 under offline Wine: 163 passed, 0 failed.

Verified on Lanes

A pull request is not merged until Lanes passes on a GPU. Run:

python tuxbox.py check
  • python tuxbox.py check passed on this branch
  • Changed or new behaviour is covered by a Lanes scenario, or the reason it cannot be is stated below

Dormant until xmem.dll exports TuxBoxAcquirePhysicalBackingRuns; covered on real GPU hardware by device::heap::backing::tests::scattered_alias_imports_through_reserved_buffer_and_aliases_cpu_and_gpu using FakeXmem, while all existing Lanes/fixtures (70/70) and D3D12 regression controls (19/19) pass.

GPU, driver and backend: AMD Radeon RX 6900 XT (1002:73bf), Mesa RADV 26.3.1, GE-Proton11-14 (vkd3d-proton), Windows DXC v1.9.2609.

  • This changes code both vendors run, and the check passed on an AMD and an NVIDIA card (why). Otherwise, say which vendor still needs to run it: NVIDIA still needs to run it.

Paste the summary printed at the end:

Summary
  passed   Build the shader compiler (0s)
  passed   Python tests (3s)
  passed   Shader compiler tests (0s)
  passed   DXBC tests (0s)
  passed   XG layout tests (1s)
  passed   D3D12 Windows typecheck (0s)
  passed   Build (20s)
  passed   Lanes and fixtures on the GPU (168s)
  passed   D3D12 regression controls (85s)
  passed   Shader translator on the GPU (226s)

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.

1 participant