Skip to content

D3D12.X: video-memory arenas never overlap - #122

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:d3d12x-vram-arenas
Nov 23, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
gefydev:d3d12x-vram-arenas

Conversation

@gefydev

@gefydev gefydev commented Nov 23, 2026

Copy link
Copy Markdown
Member

#104 item 1.

arena_for reused an arena only if it held the whole placement. A new arena took the 32 MiB blocks from below the address up to 128 MiB, with no check against the arenas already there. So a placement that straddled an arena, or a new arena that grew into one, gave two heaps over the same title addresses. Resources at one address could then land in different heaps and stop aliasing.

The layout is now a pure function, plan, over the arena ranges. arena_for applies it:

  • A placement inside an arena reuses that arena.
  • A new arena that overlaps no other still grows to 128 MiB, but it stops at the next arena.
  • A placement that overlaps arenas gets one new arena. It covers the union of the placement's range and all the arenas it overlaps; the union is taken again until no new arena joins. The old arenas leave the list. Placed resources hold a reference to their heap, so the old heaps live as long as their resources do. Later placements at those addresses use the new arena. Resources already in a replaced arena no longer alias later ones; that case is logged.

I picked merging over "allocate the remainder" because a D3D12 resource must sit in one heap. A straddling resource cannot be split between the old arena and a remainder heap.

Tests in vram::tests, CPU only:

Each step also checks that no two arenas overlap. With the old rule the first test's second step gives [0x1_0200_0000, +128 MiB) over the first arena. The other lib tests pass on a GTX 1650 under Wine. Not run with a retail title.

arena_for reused an arena only if it held the whole placement, and a new
one took the 32 MiB blocks below the address up to 128 MiB with no regard
for the arenas already there. A placement straddling an arena (or a new
arena growing into one) gave two heaps over the same title addresses, so
resources at one address could land in different heaps and stop aliasing.

The layout is now a pure function (plan) over the arena ranges:
- a placement inside an arena reuses it;
- a new arena that overlaps none grows to 128 MiB but stops at the next
  arena;
- a placement that overlaps arenas gets one arena over the union of its
  range and all of them (to closure), and those leave the list. Their
  resources keep their heaps; later placements at those addresses use the
  new arena.

Tests (vram::tests): the straddling sequence from xcl-dev#104, a new arena
stopping at the next one, a placement merging two arenas over a gap.
@ivall
ivall merged commit 5231403 into xcl-dev:main Nov 23, 2026
@ivall

ivall commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Merged. XDefiant hits it in practice: ~78 s in it logs one straddling placement merged into a new arena, and runs on. Checked on Windows 11 with an RX 9070 (RDNA4), merged together with the rest of #110–#129: cargo test --workspace green with the retail samples (shader pack, console DLLs, texture archive), lib tests also with XCL_SPLIT_WAVE64=1; the retail pack still translates 26 698 / 26 698; the FSR4 GPU probe passes; Unicorn Overlord and XDefiant 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