GPU: title memory in place instead of copied, opt-in (VICTORY_IN_PLACE=1; stacked on #2088, towards #880) #2112

Open
github-bot wants to merge 35 commits from github-bot/gh-2112 into main AGit
Owner

@⁠desplmfao on GitHub · 2026-11-25 05:12 UTC · original
desplmfao:perf/loose-windows-in-place → main · +1262 −16 · 5 files · 35 commits · draft

Stacked on #2088, which is itself stacked on #402. The new commits are the last two here. This is a first, opt-in step towards #880 (reading title memory in place instead of copying it). It covers loose windows (memory outside every buffer object) and, since the third commit, title buffer objects.

Change

With VICTORY_IN_PLACE=1, a loose window is the title's memory itself. The allocation holding it is opened as a host heap with ID3D12Device3::OpenExistingHeapFromAddress (under vkd3d-proton that is VK_EXT_external_memory_host), and a buffer is placed at the window's offset. Nothing is copied to the host or back, and the window needs no page guards: every copy path of Shadow returns early for such a window.

  • Only the committed part of the window around the requested range, cut to 64 KiB (D3D12's placement granularity), is used. A range that isn't inside one committed allocation keeps the copy from #2088. Opening a heap has to start at the allocation's base; the buffer is placed at the window's offset in it.
  • watch::title_memory_remapped drops in-place windows and heaps over the remapped range, so a later lookup opens the new pages. Lists that still hold an old window keep its pinned pages until they are reset.
  • It's off by default, so nothing changes unless the variable is set.

Measured

RTX 5080, Linux, proton-cachyos 11.0, vkd3d-proton 3.2.0, main + #1849. Grand Theft Auto VI, Series X 1.0.2.1, from start into world loading:

loose windows at the same point of loading host memory
main (4 MiB copies) about 3.4 GB
#2088 (256 KiB copies) about 2.2 GB
this PR, VICTORY_IN_PLACE=1 79 MB (1,448 windows in place, none refused)

No device-removed errors or GPU faults in any of these runs. Before the patch above, a quick probe showed that process memory opens as a heap here for a plain VirtualAlloc, a write-watched one and a view of a section (also a second view of the same section). The GPU wrote to such memory, and the CPU read the result at the right offset.

Released title memory

Most of what goes in place (about 570 of 572 MB here) is private memory the title allocates and frees itself, partly through calls VIctory doesn't see. A heap opened over an allocation that is no longer the same (released, another size, or not all committed) is let go, together with the in-place windows and buffers in it. That's checked both when the heap would be reused and once per frame for all opened heaps. Test: a_heap_over_a_released_allocation_is_let_go. Known gap: an allocation that is released and made again at the same address with the same size can't be told apart. Under vkd3d-proton, the GPU would then read the old, still pinned pages: stale data, not someone else's memory. This is one reason the switch is opt-in.

Not measured / limits

  • Under Wine these runs stop at world entry: they hit my video-memory limit (driver memory, not these windows) or the title's watchdog freeze, the same as without this PR. So there are no in-world frames, no frame-time comparison, and no picture comparison yet.
  • Title buffer objects in place (third commit): a copy starts at the 64 KiB boundary at or below the buffer; views find their bytes by address, so the extra bytes in front are never read. Measured: 3,335 title buffers and 2,117 loose windows in place, none refused, no device errors.
  • Still copied: buffers over many separately mapped 64 KiB views (MEM_MAPPED, each its own allocation). Here that's 8 large buffers, 378 MB. One heap can't span them, and tile mappings into heaps opened over process memory weren't reliable under vkd3d-proton (a probe worked once, then not).
  • Not tested on Windows or on AMD.

Tested

  • Three new tests (the third, for released memory, is above): the_committed_part_of_a_window_holds_the_range_or_is_none (pure CPU, a reservation with a committed middle) and committed_memory_opens_as_a_buffer_in_place (GPU; skipped where the host can't open process memory as a heap).
  • cargo test -p victory-gpu -- --test-threads 1: 136 passed, 14 failed. Plain main fails the same 14 on this machine.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean for these files.

AI-assisted (Claude Code).

🤖 Generated with Claude Code

**@⁠desplmfao** on GitHub · 2026-11-25 05:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112) `desplmfao:perf/loose-windows-in-place` → `main` · +1262 −16 · 5 files · 35 commits · draft Stacked on #2088, which is itself stacked on #402. The new commits are the last two here. This is a first, opt-in step towards #880 (reading title memory in place instead of copying it). It covers loose windows (memory outside every buffer object) and, since the third commit, title buffer objects. ## Change With `VICTORY_IN_PLACE=1`, a loose window is the title's memory itself. The allocation holding it is opened as a host heap with `ID3D12Device3::OpenExistingHeapFromAddress` (under vkd3d-proton that is `VK_EXT_external_memory_host`), and a buffer is placed at the window's offset. Nothing is copied to the host or back, and the window needs no page guards: every copy path of `Shadow` returns early for such a window. - Only the committed part of the window around the requested range, cut to 64 KiB (D3D12's placement granularity), is used. A range that isn't inside one committed allocation keeps the copy from #2088. Opening a heap has to start at the allocation's base; the buffer is placed at the window's offset in it. - `watch::title_memory_remapped` drops in-place windows and heaps over the remapped range, so a later lookup opens the new pages. Lists that still hold an old window keep its pinned pages until they are reset. - It's off by default, so nothing changes unless the variable is set. ## Measured RTX 5080, Linux, proton-cachyos 11.0, vkd3d-proton 3.2.0, `main` + #1849. Grand Theft Auto VI, Series X 1.0.2.1, from start into world loading: | loose windows at the same point of loading | host memory | |---|---| | `main` (4 MiB copies) | about 3.4 GB | | #2088 (256 KiB copies) | about 2.2 GB | | this PR, `VICTORY_IN_PLACE=1` | **79 MB** (1,448 windows in place, none refused) | No device-removed errors or GPU faults in any of these runs. Before the patch above, a quick probe showed that process memory opens as a heap here for a plain `VirtualAlloc`, a write-watched one and a view of a section (also a second view of the same section). The GPU wrote to such memory, and the CPU read the result at the right offset. ## Released title memory Most of what goes in place (about 570 of 572 MB here) is private memory the title allocates and frees itself, partly through calls VIctory doesn't see. A heap opened over an allocation that is no longer the same (released, another size, or not all committed) is let go, together with the in-place windows and buffers in it. That's checked both when the heap would be reused and once per frame for all opened heaps. Test: `a_heap_over_a_released_allocation_is_let_go`. **Known gap:** an allocation that is released and made again at the same address with the same size can't be told apart. Under vkd3d-proton, the GPU would then read the old, still pinned pages: stale data, not someone else's memory. This is one reason the switch is opt-in. ## Not measured / limits - Under Wine these runs stop at world entry: they hit my video-memory limit (driver memory, not these windows) or the title's watchdog freeze, the same as without this PR. So there are no in-world frames, no frame-time comparison, and no picture comparison yet. - Title buffer objects in place (third commit): a copy starts at the 64 KiB boundary at or below the buffer; views find their bytes by address, so the extra bytes in front are never read. Measured: 3,335 title buffers and 2,117 loose windows in place, none refused, no device errors. - Still copied: buffers over many separately mapped 64 KiB views (`MEM_MAPPED`, each its own allocation). Here that's 8 large buffers, 378 MB. One heap can't span them, and tile mappings into heaps opened over process memory weren't reliable under vkd3d-proton (a probe worked once, then not). - Not tested on Windows or on AMD. ## Tested - Three new tests (the third, for released memory, is above): `the_committed_part_of_a_window_holds_the_range_or_is_none` (pure CPU, a reservation with a committed middle) and `committed_memory_opens_as_a_buffer_in_place` (GPU; skipped where the host can't open process memory as a heap). - `cargo test -p victory-gpu -- --test-threads 1`: 136 passed, 14 failed. Plain `main` fails the same 14 on this machine. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean for these files. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
`shadow::find` looked at only the 64 buffers starting closest below an
address. A big buffer with more than 64 smaller buffers placed in it
before the address was missed, and the range fell through to `loose`,
which made a second 4 MiB host copy of memory the big buffer's copy
already had, not aliased with it. The search now goes back as far as the
longest buffer registered so far (`MAX_SPAN`): one starting further below
cannot hold the range.

`loose` reused a window only for the exact same (start, length), so a
range inside a window made for a range spanning two windows got another
copy. It now reuses any window holding the range. It also gives no copy
for null-page addresses, or for memory that is not committed when a new
window would be made, instead of 4 MiB of zeros.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`shadow::find` looked at only the 64 buffers starting closest below an
address. A big buffer with more than 64 smaller buffers placed in it
before the address was missed, and the range fell through to `loose`,
which made a second 4 MiB host copy of memory the big buffer's copy
already had, not aliased with it. The search now goes back as far as the
longest buffer registered so far (`MAX_SPAN`): one starting further below
cannot hold the range.

`loose` reused a window only for the exact same (start, length), so a
range inside a window made for a range spanning two windows got another
copy. It now reuses any window holding the range. It also gives no copy
for null-page addresses, or for memory that is not committed when a new
window would be made, instead of 4 MiB of zeros.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Memory outside every buffer object gets host copies of the aligned
windows lookups touch. While Grand Theft Auto VI loads its world, about
700 such 4 MiB windows (3.4 GB of host memory) were live; the lookups
touched about 30% of their bytes (in 64 KiB pieces). With 256 KiB
windows, at the same point of loading: 5,713 windows, 2.2 GB, and the
process 15.4 GB instead of 17.3 to 20.4 GB. No descriptor-slot warnings
for the extra windows' page-table entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With VICTORY_IN_PLACE=1, a loose window is the title's memory itself:
the allocation holding it is opened as a host heap
(OpenExistingHeapFromAddress; VK_EXT_external_memory_host under
vkd3d-proton) and a buffer is placed at the window's offset. Nothing is
copied to the host or back, and the window needs no page guards. Only the
committed part of the window around the asked range, cut to 64 KiB, is
used; ranges that are not one committed allocation keep the copy. A
remap of title memory drops the in-place windows and heaps over it, so a
later lookup opens the new pages; lists still holding an old window keep
its (pinned) pages until they are reset.

Off by default. RTX 5080, proton-cachyos 11.0, vkd3d-proton 3.2.0, Grand
Theft Auto VI loading its world: 1,448 windows in place, none refused,
no device errors; loose-window host memory at the same point of loading
79 MB instead of 2.2 GB (256 KiB copies) or 3.4 GB (4 MiB copies).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title buffer object's copy is, with VICTORY_IN_PLACE=1, the title's
memory too: placed from the 64 KiB boundary at or below the buffer
(views find their bytes by address), past its end by 256 bytes where the
allocation has them. A placed buffer's end only needs to be committed
pages, not 64 KiB. A remap drops in-place title buffers over it as well.

Buffers over many separately mapped 64 KiB views (MEM_MAPPED, one
allocation each) are still copied: one heap cannot span them, and tile
mappings into heaps opened over process memory were not reliable under
vkd3d-proton here.

Measured (RTX 5080, proton-cachyos 11.0, the title loading its world,
with #259, #177 and #1849 on top for NVIDIA under Wine): 3,335 title
buffers and 2,117 loose windows in place, none refused, no device
errors; 8 large buffers (378 MB) over separate views still copied.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The title releases some of its memory itself, which we do not see. A
heap opened over an allocation that is no longer the same (released,
another size, or not all committed) is now let go, with the in-place
windows and title buffers placed in it: when the heap would be reused,
and once a frame for all opened heaps. What this cannot tell is an
allocation released and made again at the same address with the same
size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Windows did not release memory a heap was opened over while the heap
lived (CI: the allocation was still there after VirtualFree); Wine
releases it at once. The test now lets go of the heap in that case and
checks that the release succeeds then.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
find holds BUFFERS and loose holds LOOSE when they call
in_place_buffer, and letting go of what is placed in a stale heap takes
both locks again (found by yualk in review). in_place_buffer now only
drops the stale heap from the cache and queues it; check_in_place lets
go of its windows and buffers at the next frame, outside those locks.
Test: a_stale_heap_is_replaced_under_the_callers_locks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
They share the heap cache and the queue of stale heaps, and a parallel
test can get the same address back (CI). The stale-heap test now makes
the cached entry stale itself: Windows does not decommit memory a heap
was opened over while the heap lives, so the decommit did nothing there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Opening a title allocation as a host heap makes all of it resident: the
host memory import pins every page, also committed pages the title never
touched. Grand Theft Auto VI keeps most buffers in two large pools that
were 10% and 31% resident (2.3 and 1.2 GB), so in place cost 1.9 GB more
anonymous memory for 1.4 GB fewer copies.

An allocation now goes in place only if at least 90% of its pages are
already in memory (QueryWorkingSetEx, at most 64Ki pages sampled; asked
again after 10 s; VICTORY_IN_PLACE_DENSITY sets the percentage). Sparse
ones keep their copies. In the world: anonymous memory as without in
place (4.9 GB), 0.3 GB fewer copies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Where the device has ID3D12Device13, a buffer in place is a heap over
its own pages (OpenExistingHeapFromAddress1) instead of the whole
allocation: nothing else of the allocation becomes resident, so no
density check applies, and the placed buffer holds its heap, which goes
with it. vkd3d-proton has no ID3D12Device13 and keeps the whole-
allocation heaps with the density check.

The density decisions are keyed by allocation base and size: an
allocation made again at the same address is a new one. Tests: a sparse
allocation is not opened whole; a sub-range heap covers only its
buffer (where the host has one); the heap-cache tests take the
whole-allocation path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A range in one window, then a range across its end, which gets a window
of its own over both: the title's writes reach both copies at their
refresh, and a shader's write through the spanning copy goes back to
title memory and into the first copy at its next refresh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One run at 70% hung while the world loaded; a later run without in-place
hung the same way, so the hang is not shown to come from the threshold.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shaders reach memory in place over the bus; for small, often-touched
buffers (atomics, constants) that costs more than the copy: sirrus98
measured a once-a-frame compute pass over a tiny buffer in host memory
at 19-67 ms of GPU time instead of 1-6 ms (RTX 4090, for the in-place
work of fxceless/victory-fork#772, which keeps the same 1 MiB floor).
VICTORY_IN_PLACE_MIN_KB sets it. Loose windows are not affected.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A heap found stale is queued for the frame's check, and by then a new
heap may be open at the same base with buffers placed in it. Letting go
by address range dropped those too. Each opened heap now has an id; the
queue and the periodic check let go of that heap and of what is placed
in it only. Remaps still let go by address.

Reported by nathanbzrr on #2112.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refreshing a copy also keeps it alive until the list is reset; an
in-place buffer has nothing to refresh, so `refresh` and `gpu_writes`
returned before anything held it. The title releasing the buffer, or a
stale heap being let go, between recording and submission then freed a
resource whose GPU address the list names. Both now keep the placed
buffer once per list (`HostList::keep_once`); a placed resource holds
its heap, so the heap lives as long.

Reported by nathanbzrr on #2112.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The argument clamp writes the records where it reads them. For a copy
that is our memory; for a buffer in place it is the title's own, which
the clamp changed under it. In-place records are now copied on the GPU
(after the title's passes that wrote them) into one buffer per list,
clamped and executed there. Copies keep the clamp in place as before.

Reported by nathanbzrr on #2112.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A copy-back writes title memory under `watch::writing`, so other copies
of the same pages (title buffers under the in-place floor, a structured
view's own copy, textures) see them changed and copy again. A buffer in
place has nothing to copy back: the shaders' writes land in title memory
unseen by guards and write watch, and those other copies kept their
older bytes. After the submission, the ranges written in place (declared,
or marked through the memory page table, withheld or not) are now marked
changed the same way.

Reported by nathanbzrr on #2112.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since stale heaps are let go by id, `a_stale_heap_is_replaced_under_the_
callers_locks` left the heap opened in place of the stale one cached at
its base, and freed the memory. A later test given that address back
(`a_sub_range_heap_covers_only_the_buffer`, run after it) found the
entry and failed. The address-based let-go hid this by also dropping the
new heap, which was the bug. The test now lets go of its memory's heaps
before freeing it, and the sub-range test checks that its call adds
nothing to the cache rather than that the cache has nothing at the base.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A miss in the buffer lookup scanned every buffer starting within the
longest buffer's length below the address (MAX_SPAN, 174 MB in the
world): about 480 entries per miss on average, at most 2,842, and some
330,000 misses every 5 s, all under BUFFERS' lock (measured in Grand
Theft Auto VI's world, RTX 5080 under Proton).

Buffers of 1 MiB or more are now also kept in a small map of their own.
A lookup scans BUFFERS only within the longest smaller buffer's length
below the address, then the big buffers further below, back to
MAX_SPAN. Only a big buffer can hold the range from further below, so
the result is the same innermost buffer.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit b73bb8b. With it, Grand Theft Auto VI's world showed
spikes out of the player character's head and triangles stretched across
the scene in two runs; the same build without it is clean. A stale entry
in the map of big buffers (a key registered again shorter) explains the
spikes, but with that fixed the triangles stayed, so the change goes until
it is understood. The lookup cost it targeted is back as before (about 480
entries per miss).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Main's indirect clamp (315cea18) now reads the title's records through a
root view and writes the clamped ones into an argument buffer of the
list's own, so it no longer writes title memory: the in-place copy of the
records (indirect::copied, HostList::arguments(len), Shadow::in_place and
their test) is dropped and draw.rs, indirect.rs follow main as is. Copies
sharing a buffer (6cc6aa35): Shadow keeps both main's base/slice and the
in-place flag and heap; new, new_at and new_with all build through one
constructor, and in-place buffers (own buffer, base 0) stay untracked
(track_copy for copies). Shadow::update returns early in place as well as
when clean. keep_once, check_in_place at present and the landed marks
after withheld submissions sit unchanged beside main's drop_withheld.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

# Conflicts:
#	crates/victory-gpu/src/shadow.rs
Conflicts in crates/victory-gpu/src/shadow.rs: main's copies now come
back as Arc from Shadow::new and bump GENERATION through changed(); kept
that and added #402's MAX_SPAN search, the loose-window reuse
(LOOSE_SPAN, enclosing_window) and the committed/null-page checks on top.
#402's tests join main's `pub(crate) mod tests`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
update/402-main is #402 with main merged in. Its shadow.rs replaces this
branch's copy of #402's commit (same change on an older main); this
branch's own changes go on top: 256 KiB windows and the
overlapping-windows test. The two-step lookup stays reverted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clean merge: brings the overlapping-windows test and moves MAX_SPAN's
place; the in-place code is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
r4tedx's in-game A/B of this branch (RTX 5070) measured the 256 KiB
windows at +428 ms median frame time: host copies grew from about 0.55 GB
to about 6 GB per frame in the open world, for about 2.9 GB of host
memory saved. Loose windows are 4 MiB again (main's size) unless
VICTORY_LOOSE_WINDOW_KIB asks for a power of two from 64 to 4096 KiB.
#402's window reuse stays as it is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Clean merge: 256 KiB windows only with VICTORY_LOOSE_WINDOW_KIB=256; the
in-place code is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
No range: sizes far from the default are the user's own experiment. Only
a value that is not a power of two, or one whose bytes overflow, falls
back to 4 MiB.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:55:11 +00:00
landed() used watch::writing, which is for kernel writes into title
memory: every tracker holding a page saved its bytes first, and the
guards were opened, so the pages had to be compared at every refresh
after. In place, every submission marks the whole ranges its shaders may
write, so that was GBs a frame: on Windows with VICTORY_IN_PLACE=1 the
watches took 5.7-7.7 s a frame against 13-19 ms, checking 11-13 GB (9-11
GB unchanged).

watch::gpu_wrote marks the pages (and their aliases) changed in every
tracker, as before, with nothing saved (the write happened; there is no
'before' to keep) and no guard opened (a GPU write does not go through
the CPU's page protection, so the title's writes stay seen).

Found from kawaii-shakal's copystat lines on #2112 (RTX 5070 Ti,
Windows 11, native D3D12).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 05:22 UTC · original · edited 2026-11-25 05:41 UTC

A note on why this is opt-in and untested in the world: on this machine I currently can't get into the world at all. On the RTX 5080 (16 GB) under Wine, every run fills video memory while the world loads, before the first world frame. That's mostly driver memory that grows while pipelines are created, not these copies, and it's what I'm working on next. So the missing world test is a limit of my setup, not something this PR has been seen to break.

Once the world loads here, I'll:

  • check the picture and frame time with VICTORY_IN_PLACE=1 against without it;
  • cover title memory that is released while an in-place heap is still open over it. Remaps are handled; a plain release isn't yet.
  • then propose making it the default.

Tests on a machine that already reaches the world (Windows or AMD in particular) would help a lot before that.

**@⁠desplmfao** on GitHub · 2026-11-25 05:22 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7153712303) · edited 2026-11-25 05:41 UTC A note on why this is opt-in and untested in the world: on this machine I currently can't get into the world at all. On the RTX 5080 (16 GB) under Wine, every run fills video memory while the world loads, before the first world frame. That's mostly driver memory that grows while pipelines are created, not these copies, and it's what I'm working on next. So the missing world test is a limit of my setup, not something this PR has been seen to break. Once the world loads here, I'll: - check the picture and frame time with `VICTORY_IN_PLACE=1` against without it; - cover title memory that is released while an in-place heap is still open over it. Remaps are handled; a plain release isn't yet. - then propose making it the default. Tests on a machine that already reaches the world (Windows or AMD in particular) would help a lot before that.
Author
Owner

@⁠RKouchoo on GitHub · 2026-11-25 05:29 UTC · original

#2112 did map real game memory on Windows. In my last loading sample, 243 MiB used that path and 1.11 GiB still used copies. That sample took 2.8 seconds per frame.

**@⁠RKouchoo** on GitHub · 2026-11-25 05:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7153823912) #2112 did map real game memory on Windows. In my last loading sample, 243 MiB used that path and 1.11 GiB still used copies. That sample took 2.8 seconds per frame.
Author
Owner

@⁠yualk on GitHub · 2026-11-25 05:38 UTC · original

Scoped native Windows result on RTX 5070 Ti 10de:2c05 (610.88) and explicit WARP 1414:008c. The #2112 allocation-base import and COMMON / ALLOW_CROSS_ADAPTER | ALLOW_UNORDERED_ACCESS 128 KiB placement at a 64 KiB offset worked for fully committed private memory, private MEM_WRITE_WATCH, and a fully committed view in an otherwise reserved pagefile section. GetResourceAllocationInfo required exactly 128 KiB/64 KiB. Two different 4,096-byte CPU patterns per class were read and XOR-written by a real root-UAV dispatch. Each fence completed; the CPU saw all exact words and all 258,048 surrounding canary bytes stayed unchanged. For the section, phase 2 wrote through a separate CPU view; both views received the correct GPU result. These were authored stable allocations held until the placed resource and heap died. No guest release, lifetime transplant, title, commit reduction or timing claim.

Separate hold on 1bcef8016a21: find holds BUFFERS and loose holds LOOSE when calling in_place_buffer. On a stale cached extent it calls let_go_in_place synchronously; that function takes both locks. Either caller can reenter its own lock. The current release test calls the helper directly, not these locked callers. This is a source-level finding, not a hung title repro. Consider separating stale detection from eviction/retry outside the caller locks, with a generation comparison on re-entry. Extent polling alone also cannot distinguish a same-address/same-size reuse. Keep the mode off pending ownership tests. AI-assisted; no title files or captures used.

**@⁠yualk** on GitHub · 2026-11-25 05:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7153998798) Scoped native Windows result on RTX 5070 Ti `10de:2c05` (610.88) and explicit WARP `1414:008c`. The #2112 allocation-base import and `COMMON / ALLOW_CROSS_ADAPTER | ALLOW_UNORDERED_ACCESS` 128 KiB placement at a 64 KiB offset worked for fully committed private memory, private `MEM_WRITE_WATCH`, and a fully committed view in an otherwise reserved pagefile section. `GetResourceAllocationInfo` required exactly 128 KiB/64 KiB. Two different 4,096-byte CPU patterns per class were read and XOR-written by a real root-UAV dispatch. Each fence completed; the CPU saw all exact words and all 258,048 surrounding canary bytes stayed unchanged. For the section, phase 2 wrote through a separate CPU view; both views received the correct GPU result. These were authored stable allocations held until the placed resource and heap died. No guest release, lifetime transplant, title, commit reduction or timing claim. Separate hold on `1bcef8016a21`: [`find`](https://github.com/Marvisak/VIctory/blob/1bcef8016a21cd7e8d0adac5ef7a8f388f9b7f30/crates/victory-gpu/src/shadow.rs#L883-L909) holds `BUFFERS` and [`loose`](https://github.com/Marvisak/VIctory/blob/1bcef8016a21cd7e8d0adac5ef7a8f388f9b7f30/crates/victory-gpu/src/shadow.rs#L1198-L1219) holds `LOOSE` when calling `in_place_buffer`. On a stale cached extent it calls `let_go_in_place` synchronously; that function takes both locks. Either caller can reenter its own lock. The current release test calls the helper directly, not these locked callers. This is a source-level finding, not a hung title repro. Consider separating stale detection from eviction/retry outside the caller locks, with a generation comparison on re-entry. Extent polling alone also cannot distinguish a same-address/same-size reuse. Keep the mode off pending ownership tests. AI-assisted; no title files or captures used.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 05:41 UTC · original

Update: CI on Windows showed that Windows doesn't release memory that a heap was opened over while that heap exists; Wine releases it at once. The test now accounts for that (1bcef80). For the title this means something too: on Windows, its own VirtualFree of such memory could fail while VIctory holds a heap over it. That's another reason to keep this opt-in until releases are seen and heaps let go first.

@⁠RKouchoo thanks for the Windows sample (243 MiB in place, 1.11 GiB still copied, 2.8 s per frame). Two things would help:

  • the same point of loading without VICTORY_IN_PLACE, so the 2.8 s can be compared;
  • if your log has them, the reasons memory stayed copied. Here on Wine almost all of it went in place, so the share on Windows is much lower than I expected. Is it memory spread over several allocations (mapped views), or partly uncommitted?

@⁠yualk thanks, both very useful. It's good to have the native Windows placements confirmed, and the reentrancy is a real bug: my release test called the helper directly, without the locks find and loose hold. Fixed in 97503f9: in_place_buffer now only drops a stale heap from the cache and queues it, and check_in_place lets go of its windows and buffers at the next frame, outside BUFFERS and LOOSE. The new test a_stale_heap_is_replaced_under_the_callers_locks calls it while holding both locks. Agreed on the rest: extent polling can't tell a same-address, same-size reuse apart, so the mode stays off until ownership is tracked properly (a generation per allocation, as you suggest).

**@⁠desplmfao** on GitHub · 2026-11-25 05:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7154050899) **Update:** CI on Windows showed that Windows doesn't release memory that a heap was opened over while that heap exists; Wine releases it at once. The test now accounts for that (`1bcef80`). For the title this means something too: on Windows, its own `VirtualFree` of such memory could fail while VIctory holds a heap over it. That's another reason to keep this opt-in until releases are seen and heaps let go first. @⁠RKouchoo thanks for the Windows sample (243 MiB in place, 1.11 GiB still copied, 2.8 s per frame). Two things would help: - the same point of loading without `VICTORY_IN_PLACE`, so the 2.8 s can be compared; - if your log has them, the reasons memory stayed copied. Here on Wine almost all of it went in place, so the share on Windows is much lower than I expected. Is it memory spread over several allocations (mapped views), or partly uncommitted? @⁠yualk thanks, both very useful. It's good to have the native Windows placements confirmed, and the reentrancy is a real bug: my release test called the helper directly, without the locks `find` and `loose` hold. Fixed in `97503f9`: `in_place_buffer` now only drops a stale heap from the cache and queues it, and `check_in_place` lets go of its windows and buffers at the next frame, outside `BUFFERS` and `LOOSE`. The new test `a_stale_heap_is_replaced_under_the_callers_locks` calls it while holding both locks. Agreed on the rest: extent polling can't tell a same-address, same-size reuse apart, so the mode stays off until ownership is tracked properly (a generation per allocation, as you suggest).
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 06:46 UTC · original

World result, and it's not a gain yet on Linux/NVIDIA. With #2143 (code tables) I can now get into the world, so here's an A/B on the same build, with and without VICTORY_IN_PLACE=1. Grand Theft Auto VI in the world, RTX 5080, proton-cachyos 11.0, with #2153, #2099 and #2071 applied as well:

process memory in the world without with VICTORY_IN_PLACE=1
anonymous 4.9 GB 6.8 GB (+1.9)
GPU-mapped (host copies) 4.1 GB 2.7 GB (−1.4)
memfd (title memory) 4.5 GB 4.0 GB
RSS 13.5 GB 13.6 GB

In-place works as intended: every loose window and title buffer went in place, refused=0 in all six reasons, with no crash or corruption over several minutes in the world and the same frame time. But the copies it saves come back as anonymous memory. With in-place, 5.7 GB of the anonymous memory sits in 140 regions that are 100% resident.

The likely cause: OpenExistingHeapFromAddress has to start at the allocation base and covers the whole committed allocation. Importing that as host memory makes the driver pin every page of it, including committed pages the title never touched, which would otherwise take no memory on Linux. So for sparsely used allocations, opening the heap costs more than the copy it replaces.

Next, on this branch: before going in place, check how much of the allocation is already resident (QueryWorkingSetEx), and open the heap only for densely used allocations. Sparse ones keep the copy. I'll post the A/B again once that's in.

**@⁠desplmfao** on GitHub · 2026-11-25 06:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7155150129) **World result, and it's not a gain yet on Linux/NVIDIA.** With #2143 (code tables) I can now get into the world, so here's an A/B on the same build, with and without `VICTORY_IN_PLACE=1`. Grand Theft Auto VI in the world, RTX 5080, proton-cachyos 11.0, with #2153, #2099 and #2071 applied as well: | process memory in the world | without | with `VICTORY_IN_PLACE=1` | |---|---|---| | anonymous | 4.9 GB | 6.8 GB (+1.9) | | GPU-mapped (host copies) | 4.1 GB | 2.7 GB (−1.4) | | memfd (title memory) | 4.5 GB | 4.0 GB | | RSS | 13.5 GB | 13.6 GB | In-place works as intended: every loose window and title buffer went in place, `refused=0` in all six reasons, with no crash or corruption over several minutes in the world and the same frame time. But the copies it saves come back as anonymous memory. With in-place, 5.7 GB of the anonymous memory sits in 140 regions that are 100% resident. The likely cause: `OpenExistingHeapFromAddress` has to start at the allocation base and covers the whole committed allocation. Importing that as host memory makes the driver pin every page of it, including committed pages the title never touched, which would otherwise take no memory on Linux. So for sparsely used allocations, opening the heap costs more than the copy it replaces. Next, on this branch: before going in place, check how much of the allocation is already resident (`QueryWorkingSetEx`), and open the heap only for densely used allocations. Sparse ones keep the copy. I'll post the A/B again once that's in.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 07:05 UTC · original

Update: two changes for the residency problem from my last comment.

1. Density check (0ae1d5c, keyed per allocation in fcfecd1). With QueryWorkingSetEx, the two pools that held most buffers were far from resident:

allocation size pages resident
0xd89c00000 2.3 GB 10%
0xd40800000 1.2 GB 31%

Opening those whole pinned about 2.9 GB that the title had committed but never touched. A whole allocation now goes in place only if at least 90% of its pages are already resident (VICTORY_IN_PLACE_DENSITY changes the threshold). Sparse allocations keep their copies.

Same build, in the world, average of 9 samples per run:

density RSS anonymous GPU-mapped copies memfd in place
off (no in-place) 12.77 GB 5.03 3.95 3.70 none
90 12.84 GB 4.88 3.87 3.98 11,200 buffers, 729 windows
70 — — — — the GPU hung while the world loaded, and the title's watchdog ended the process; none of 8 other runs did

So on Linux this is now no worse than copies (anonymous memory stays where it is without in-place), but the gain is small. The buffers that matter live in the sparse pools. 70% matches what MrEjecutor saw in #880: putting more in place hangs the GPU.

2. Sub-range heaps where the host has them (fcfecd1, c79c031). If the device has ID3D12Device13, a buffer goes in place through OpenExistingHeapFromAddress1 over its own pages only, so nothing else of the allocation becomes resident and no density check is needed. The placed buffer holds its heap, so the heap goes away with the buffer (and with it on a remap). vkd3d-proton has no ID3D12Device13 (only the interface declaration in its IDL), so Linux keeps the whole-allocation path with the density check. That's also what Witredd measured on AMD/Windows in #880: shared memory grew by the whole 2.15 GiB on each heap opened, and they concluded the sub-range variant is needed. I can't run the Windows path here. The new test a_sub_range_heap_covers_only_the_buffer covers it and skips on hosts without ID3D12Device13. A Windows run with VICTORY_IN_PLACE=1 would be very welcome.

Tests on the RTX 5080 under Proton: victory-gpu 139 passed, 13 failed, the same 13 as main here. All in-place tests pass, including the new a_sparse_allocation_is_not_opened_whole. Clippy is clean. (fcfecd1 alone fails clippy over a missing safety comment; c79c031 fixes it.)

**@⁠desplmfao** on GitHub · 2026-11-25 07:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7155475955) **Update: two changes for the residency problem from my last comment.** **1. Density check (`0ae1d5c`, keyed per allocation in `fcfecd1`).** With `QueryWorkingSetEx`, the two pools that held most buffers were far from resident: | allocation | size | pages resident | |---|---|---| | `0xd89c00000` | 2.3 GB | 10% | | `0xd40800000` | 1.2 GB | 31% | Opening those whole pinned about 2.9 GB that the title had committed but never touched. A whole allocation now goes in place only if at least 90% of its pages are already resident (`VICTORY_IN_PLACE_DENSITY` changes the threshold). Sparse allocations keep their copies. Same build, in the world, average of 9 samples per run: | density | RSS | anonymous | GPU-mapped copies | memfd | in place | |---|---|---|---|---|---| | off (no in-place) | 12.77 GB | 5.03 | 3.95 | 3.70 | none | | 90 | 12.84 GB | 4.88 | 3.87 | 3.98 | 11,200 buffers, 729 windows | | 70 | — | — | — | — | the GPU hung while the world loaded, and the title's watchdog ended the process; none of 8 other runs did | So on Linux this is now no worse than copies (anonymous memory stays where it is without in-place), but the gain is small. The buffers that matter live in the sparse pools. 70% matches what MrEjecutor saw in #880: putting more in place hangs the GPU. **2. Sub-range heaps where the host has them (`fcfecd1`, `c79c031`).** If the device has `ID3D12Device13`, a buffer goes in place through `OpenExistingHeapFromAddress1` over its own pages only, so nothing else of the allocation becomes resident and no density check is needed. The placed buffer holds its heap, so the heap goes away with the buffer (and with it on a remap). vkd3d-proton has no `ID3D12Device13` (only the interface declaration in its IDL), so Linux keeps the whole-allocation path with the density check. That's also what Witredd measured on AMD/Windows in #880: shared memory grew by the whole 2.15 GiB on each heap opened, and they concluded the sub-range variant is needed. I can't run the Windows path here. The new test `a_sub_range_heap_covers_only_the_buffer` covers it and skips on hosts without `ID3D12Device13`. A Windows run with `VICTORY_IN_PLACE=1` would be very welcome. Tests on the RTX 5080 under Proton: `victory-gpu` 139 passed, 13 failed, the same 13 as `main` here. All in-place tests pass, including the new `a_sparse_allocation_is_not_opened_whole`. Clippy is clean. (`fcfecd1` alone fails clippy over a missing safety comment; `c79c031` fixes it.)
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 07:19 UTC · original

Correction to my last two comments here and on #407: I wrote that a 70% density threshold hung the GPU while the world loaded. That rested on one run. A later run without in-place (a different vkd3d build, cold pipeline cache) hung at the same point the same way: a long stall during world load until the title's watchdog ended the process. So the hang is intermittent at world load and isn't shown to come from in-place or the threshold. I've taken the claim out of the README (cd079af follows c79c031). The A/B numbers at 90% and the sub-range change stand.

**@⁠desplmfao** on GitHub · 2026-11-25 07:19 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7155727025) **Correction to my last two comments here and on #407:** I wrote that a 70% density threshold hung the GPU while the world loaded. That rested on one run. A later run **without** in-place (a different vkd3d build, cold pipeline cache) hung at the same point the same way: a long stall during world load until the title's watchdog ended the process. So the hang is intermittent at world load and isn't shown to come from in-place or the threshold. I've taken the claim out of the README (`cd079af` follows `c79c031`). The A/B numbers at 90% and the sub-range change stand.
Author
Owner

@⁠nathanbzrr on GitHub · 2026-11-25 08:40 UTC · original

Verified head cd079affdbb52b9a8b25ca63dc22751e18d49339 natively on Windows 11 x64 (10.0.26340) / AMD Radeon RX 7600 (ID3D12Device13, --features diagnostics + VICTORY_D3D12_DEBUG=1):

  • Default (VICTORY_IN_PLACE unset): shadow::tests 14/14 passed under D3D12 Debug Layer, including a_sub_range_heap_covers_only_the_buffer (ID3D12Device13::OpenExistingHeapFromAddress1 succeeds cleanly on RX 7600).
  • VICTORY_IN_PLACE=1 + VICTORY_D3D12_DEBUG=1: committed_memory_opens_as_a_buffer_in_place, a_sub_range_heap_covers_only_the_buffer, memory::tests (3/3), and bindless::tests (3/3) pass; the 3 existing copy-tracking shadow::tests fail as expected because in_place shadows bypass tracking/copy-back.

Live Repro & Blocking Findings (Confirming Why Mode Must Stay Opt-In)

  1. Live Repro — STALE_IN_PLACE over-evicts replacement heaps at the same base (shadow.rs:check_in_place / let_go_in_place):
    When Path B replaces a stale heap (base, S1) with a brand-new heap (base, S2) and queues (base, S1) in STALE_IN_PLACE, calling check_in_place() calls let_go_in_place(base, S1) which evicts by address overlap with no generation/heap-ID check — evicting the newly created valid heap S2 (stale_queue_does_not_evict_replacement_heap_at_same_base failed with survived=false).
  2. WDDM Pinning Blocks VirtualProtect & Placeholder Remaps (err=87):
    Measured directly on RX 7600 and WARP (#1905 probes): on Windows, while an OpenExistingHeapFromAddress heap is alive (both MEM_WRITE_WATCH and plain VirtualAlloc), VirtualProtect (PAGE_GUARD / PAGE_READONLY / PAGE_NOACCESS) and UnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER) fail with ERROR_INVALID_PARAMETER (87) until the ID3D12Heap is released.
  3. Source-level correctness & lifetime blockers before default-on:
    • GPU resource UAF (Shadow::refresh / gpu_writes): Early return skips list.keep(&self.buffer). Any unregister / let_go_in_place / Upload::drop before GPU completion drops the ID3D12Resource (and Path A's sole ID3D12Heap) while command lists hold raw GPU VAs (draw.rs:195,...).
    • Title RAM corruption (indirect::bound): Indirect clamping dispatches a compute shader writing directly to args.buffer (draw.rs:1588-1593), mutating live title RAM in place.
    • Path A (ID3D12Device13) gaps: Path A never records into IN_PLACE_HEAPS, making check_in_place() a no-op on Windows/RX 7600, and committed_part truncates hi to 4 KiB instead of 64 KiB (CreatePlacedResource buffer placement granularity).
    • Shadow coherency & missed safety: s0 = key.0 / 64KiB * 64KiB shifts alignment so structured views in for_view spill into tracked exact() copies on the same 64 KiB pages (remaining stale against GPU UAV writes), and withheld / missed protection (memory.rs:438) is bypassed when GPU writes directly into title RAM.

(Proposed / uncompiled fix directions:) add list.keep(&self.buffer) in Shadow::refresh/gpu_writes, align committed_part hi to 64 KiB, check info.Protect == PAGE_READWRITE, clear None entries in let_go_in_place, tag IN_PLACE_HEAPS with monotonic generation IDs, track Path A allocations/windows in check_in_place(), and route indirect::bound / exact() coherency safely.

AI-assisted; synthetic tests only, no game files, dumps, or captures used.

**@⁠nathanbzrr** on GitHub · 2026-11-25 08:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7157336488) Verified head `cd079affdbb52b9a8b25ca63dc22751e18d49339` natively on Windows 11 x64 (`10.0.26340`) / **AMD Radeon RX 7600** (`ID3D12Device13`, `--features diagnostics` + `VICTORY_D3D12_DEBUG=1`): - **Default (`VICTORY_IN_PLACE` unset):** `shadow::tests` **14/14 passed** under D3D12 Debug Layer, including `a_sub_range_heap_covers_only_the_buffer` (`ID3D12Device13::OpenExistingHeapFromAddress1` succeeds cleanly on RX 7600). - **`VICTORY_IN_PLACE=1` + `VICTORY_D3D12_DEBUG=1`:** `committed_memory_opens_as_a_buffer_in_place`, `a_sub_range_heap_covers_only_the_buffer`, `memory::tests` (**3/3**), and `bindless::tests` (**3/3**) pass; the 3 existing copy-tracking `shadow::tests` fail as expected because `in_place` shadows bypass tracking/copy-back. ### Live Repro & Blocking Findings (Confirming Why Mode Must Stay Opt-In) 1. **Live Repro — `STALE_IN_PLACE` over-evicts replacement heaps at the same base (`shadow.rs:check_in_place` / `let_go_in_place`):** When Path B replaces a stale heap `(base, S1)` with a brand-new heap `(base, S2)` and queues `(base, S1)` in `STALE_IN_PLACE`, calling `check_in_place()` calls `let_go_in_place(base, S1)` which evicts by address overlap with no generation/heap-ID check — **evicting the newly created valid heap `S2`** (`stale_queue_does_not_evict_replacement_heap_at_same_base` failed with `survived=false`). 2. **WDDM Pinning Blocks `VirtualProtect` & Placeholder Remaps (`err=87`):** Measured directly on RX 7600 and WARP (#1905 probes): on Windows, while an `OpenExistingHeapFromAddress` heap is alive (both `MEM_WRITE_WATCH` and plain `VirtualAlloc`), `VirtualProtect` (`PAGE_GUARD` / `PAGE_READONLY` / `PAGE_NOACCESS`) and `UnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER)` fail with `ERROR_INVALID_PARAMETER (87)` until the `ID3D12Heap` is released. 3. **Source-level correctness & lifetime blockers before default-on:** - **GPU resource UAF (`Shadow::refresh` / `gpu_writes`):** Early return skips `list.keep(&self.buffer)`. Any `unregister` / `let_go_in_place` / `Upload::drop` before GPU completion drops the `ID3D12Resource` (and Path A's sole `ID3D12Heap`) while command lists hold raw GPU VAs (`draw.rs:195,...`). - **Title RAM corruption (`indirect::bound`):** Indirect clamping dispatches a compute shader writing directly to `args.buffer` (`draw.rs:1588-1593`), mutating live title RAM in place. - **Path A (`ID3D12Device13`) gaps:** Path A never records into `IN_PLACE_HEAPS`, making `check_in_place()` a no-op on Windows/RX 7600, and `committed_part` truncates `hi` to 4 KiB instead of 64 KiB (`CreatePlacedResource` buffer placement granularity). - **Shadow coherency & `missed` safety:** `s0 = key.0 / 64KiB * 64KiB` shifts alignment so structured views in `for_view` spill into tracked `exact()` copies on the same 64 KiB pages (remaining stale against GPU UAV writes), and `withheld` / `missed` protection (`memory.rs:438`) is bypassed when GPU writes directly into title RAM. *(Proposed / uncompiled fix directions:)* add `list.keep(&self.buffer)` in `Shadow::refresh`/`gpu_writes`, align `committed_part` `hi` to 64 KiB, check `info.Protect == PAGE_READWRITE`, clear `None` entries in `let_go_in_place`, tag `IN_PLACE_HEAPS` with monotonic generation IDs, track Path A allocations/windows in `check_in_place()`, and route `indirect::bound` / `exact()` coherency safely. AI-assisted; synthetic tests only, no game files, dumps, or captures used.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 08:44 UTC · original

@⁠nathanbzrr thank you, this is a very useful review, and good to see both paths (whole allocation and OpenExistingHeapFromAddress1) pass on an RX 7600.

I agree with the blockers and I'm fixing them as new commits on this branch:

  1. Stale heap at the same base: let_go_in_place goes by address only, so a stale (base, S1) can evict the replacement (base, S2). Heaps get an identity, and only the queued heap and the shadows placed in it are let go. Your stale_queue_does_not_evict_replacement_heap_at_same_base becomes a test.
  2. Lifetime: the in-place early returns in refresh/gpu_writes skip list.keep, so a placed buffer (and its heap) can go while a recorded list still holds its GPU address. In-place shadows will be kept by the lists that use them.
  3. indirect::bound writing into title memory: when the arguments buffer is in place, the clamp will go to a copy instead.

I'm also checking the rest: Path A and check_in_place, committed_part's end granularity, coherence with exact() copies on the same pages, and withheld/missed. And it stays opt-in. The WDDM point (VirtualProtect and remaps failing while an opened heap lives) is a hard reason for that on Windows. I'll reply again with the commits and test results.

**@⁠desplmfao** on GitHub · 2026-11-25 08:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7157415188) @⁠nathanbzrr thank you, this is a very useful review, and good to see both paths (whole allocation and `OpenExistingHeapFromAddress1`) pass on an RX 7600. I agree with the blockers and I'm fixing them as new commits on this branch: 1. **Stale heap at the same base:** `let_go_in_place` goes by address only, so a stale `(base, S1)` can evict the replacement `(base, S2)`. Heaps get an identity, and only the queued heap and the shadows placed in it are let go. Your `stale_queue_does_not_evict_replacement_heap_at_same_base` becomes a test. 2. **Lifetime:** the in-place early returns in `refresh`/`gpu_writes` skip `list.keep`, so a placed buffer (and its heap) can go while a recorded list still holds its GPU address. In-place shadows will be kept by the lists that use them. 3. **`indirect::bound` writing into title memory:** when the arguments buffer is in place, the clamp will go to a copy instead. I'm also checking the rest: Path A and `check_in_place`, `committed_part`'s end granularity, coherence with `exact()` copies on the same pages, and `withheld`/`missed`. And it stays opt-in. The WDDM point (VirtualProtect and remaps failing while an opened heap lives) is a hard reason for that on Windows. I'll reply again with the commits and test results.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 09:28 UTC · original

@⁠nathanbzrr all four code findings were real, and they're fixed in new commits:

  • Stale queue over-evicting (9e723e8): every opened heap now has an id. The stale queue and the per-frame check let go of that heap and only what was placed in it, so a new heap at the same base and its buffers stay. Your test is in as stale_queue_does_not_evict_replacement_heap_at_same_base.
  • Use after free (2eb3aa8): refresh/gpu_writes on an in-place buffer now make the list keep the placed buffer until the list is reset. A placed resource holds its heap, so path A's heap lives as long. Test: a_list_keeps_the_in_place_buffers_it_uses.
  • Indirect clamp writing title memory (d25abb7): in-place arguments are copied on the GPU into a per-list buffer, then clamped and executed from there. It's a GPU copy, so it sees what the title's own passes wrote earlier in the same submission. Test: indirect::tests::records_in_place_are_clamped_in_a_copy.
  • Coherence (d6ada9b): writes through in-place buffers now mark their pages changed for every other tracker (small-buffer copies, exact() view copies, textures), as a copy-back does. Test: writes_in_place_mark_other_copies_of_the_page_changed.
  • 2a22bd4: one existing test left a heap cached that a later test tripped over once let-go went by id. Tests only.

On the rest:

  • Path A needs no cache entry. Its buffer holds its heap, unregister drops it, and remaps let go by address, which covers path A.
  • committed_part ending at 4 KiB isn't a correctness issue. Only the offset has to be 64 KiB aligned, and a runtime that refuses a short tail leaves the buffer on its copy.
  • withheld/missed can't apply in place, since the writes are already in title memory.

Together with the WDDM behaviour you measured, that's why the mode stays opt-in. On WDDM: a failing VirtualProtect is already tolerated (the page stays "changed" and is copied every time). The real blocker is the title releasing or remapping memory a heap is open over, and that needs heaps let go before the title releases, so VICTORY_IN_PLACE stays off by default.

Also pushed: fc37315, buffers under 1 MiB keep their copies in place mode (VICTORY_IN_PLACE_MIN_KB).

A correction to what I said earlier: vkd3d-proton 3.2.0 does expose ID3D12Device13. a_sub_range_heap_covers_only_the_buffer runs the sub-range path here instead of returning early. So the OpenExistingHeapFromAddress1 path is live on Linux too, not only on Windows.

Tested on RTX 5080, Linux, Proton with vkd3d-proton 3.2.0: cargo test -p victory-gpu --lib -- --test-threads 1 shadow:: indirect:: gives 23 passed, 0 failed. The full victory-gpu suite fails only tests that also fail on main on this machine. Clippy is clean with and without --features diagnostics.

**@⁠desplmfao** on GitHub · 2026-11-25 09:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7158371955) @⁠nathanbzrr all four code findings were real, and they're fixed in new commits: - **Stale queue over-evicting** (`9e723e8`): every opened heap now has an id. The stale queue and the per-frame check let go of that heap and only what was placed in it, so a new heap at the same base and its buffers stay. Your test is in as `stale_queue_does_not_evict_replacement_heap_at_same_base`. - **Use after free** (`2eb3aa8`): `refresh`/`gpu_writes` on an in-place buffer now make the list keep the placed buffer until the list is reset. A placed resource holds its heap, so path A's heap lives as long. Test: `a_list_keeps_the_in_place_buffers_it_uses`. - **Indirect clamp writing title memory** (`d25abb7`): in-place arguments are copied on the GPU into a per-list buffer, then clamped and executed from there. It's a GPU copy, so it sees what the title's own passes wrote earlier in the same submission. Test: `indirect::tests::records_in_place_are_clamped_in_a_copy`. - **Coherence** (`d6ada9b`): writes through in-place buffers now mark their pages changed for every other tracker (small-buffer copies, `exact()` view copies, textures), as a copy-back does. Test: `writes_in_place_mark_other_copies_of_the_page_changed`. - `2a22bd4`: one existing test left a heap cached that a later test tripped over once let-go went by id. Tests only. On the rest: - Path A needs no cache entry. Its buffer holds its heap, `unregister` drops it, and remaps let go by address, which covers path A. - `committed_part` ending at 4 KiB isn't a correctness issue. Only the offset has to be 64 KiB aligned, and a runtime that refuses a short tail leaves the buffer on its copy. - `withheld`/`missed` can't apply in place, since the writes are already in title memory. Together with the WDDM behaviour you measured, that's why the mode stays opt-in. On WDDM: a failing `VirtualProtect` is already tolerated (the page stays "changed" and is copied every time). The real blocker is the title releasing or remapping memory a heap is open over, and that needs heaps let go before the title releases, so `VICTORY_IN_PLACE` stays off by default. Also pushed: `fc37315`, buffers under 1 MiB keep their copies in place mode (`VICTORY_IN_PLACE_MIN_KB`). A correction to what I said earlier: vkd3d-proton 3.2.0 **does** expose `ID3D12Device13`. `a_sub_range_heap_covers_only_the_buffer` runs the sub-range path here instead of returning early. So the `OpenExistingHeapFromAddress1` path is live on Linux too, not only on Windows. Tested on RTX 5080, Linux, Proton with vkd3d-proton 3.2.0: `cargo test -p victory-gpu --lib -- --test-threads 1 shadow:: indirect::` gives 23 passed, 0 failed. The full `victory-gpu` suite fails only tests that also fail on `main` on this machine. Clippy is clean with and without `--features diagnostics`.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 10:42 UTC · original · edited 2026-11-26 05:46 UTC

Automated triage for the maintainers.

The branch merges cleanly again (head ab2b7ef), so I reviewed it again. Needs work, and you've already said the same: it's a draft and parked.

  • Stacked: it still carries #402 and #2088 (e.g. 022e9c8, b670a33, 2f0590a, 6ebed99, none of them in main). It can only be judged on its own once those land and it's rebased.
  • Correctness with the switch on: your own A/B shows skinned characters breaking (stretched arms, a tilted NPC). The native Windows/NVIDIA run in the latest comment shows flat cutscenes, about half the draws, and frames going from about 0.7–2 s to 6–8 s. Almost all of that extra time is in watches: about 2.5× the bytes checked, at about 400× the time. So in-place memory still seems to go through watch page checking somewhere (shadow.rs, the in-place early returns vs. the watch/tracking paths, and the new memory::bind landed loop are where I'd look). This should be explained and fixed before the mode is offered, even opt-in.
  • Open from the review: an allocation released and made again at the same address and size still can't be told apart (no generation per allocation yet). And on Windows the title's own VirtualFree/VirtualProtect can fail while a heap is open over its memory.

In favour: it's off by default (VICTORY_IN_PLACE), the review findings (stale-heap identity, keep_once lifetime, coherence marking) were fixed with tests, and 0xKaji measured a real memory saving on a 16 GiB / 8 GB machine. What would change the verdict: the stack landing, plus the watch-cost and mid-write artifacts fixed and shown on a Windows run.

CI: passing (01:37 UTC run).


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 10:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7160063457) · edited 2026-11-26 05:46 UTC <!-- victory-triage v1 head=ab2b7ef7a30ba575e32149a8a42ab4b874d98b2e verdict=needs-work at=2026-11-26T05:46:42Z --> Automated triage for the maintainers. The branch merges cleanly again (head `ab2b7ef`), so I reviewed it again. **Needs work**, and you've already said the same: it's a draft and parked. - **Stacked:** it still carries #402 and #2088 (e.g. `022e9c8`, `b670a33`, `2f0590a`, `6ebed99`, none of them in `main`). It can only be judged on its own once those land and it's rebased. - **Correctness with the switch on:** your own A/B shows skinned characters breaking (stretched arms, a tilted NPC). The native Windows/NVIDIA run in the latest comment shows flat cutscenes, about half the draws, and frames going from about 0.7–2 s to 6–8 s. Almost all of that extra time is in `watches`: about 2.5× the bytes checked, at about 400× the time. So in-place memory still seems to go through `watch` page checking somewhere (`shadow.rs`, the in-place early returns vs. the watch/tracking paths, and the new `memory::bind` `landed` loop are where I'd look). This should be explained and fixed before the mode is offered, even opt-in. - **Open from the review:** an allocation released and made again at the same address and size still can't be told apart (no generation per allocation yet). And on Windows the title's own `VirtualFree`/`VirtualProtect` can fail while a heap is open over its memory. In favour: it's off by default (`VICTORY_IN_PLACE`), the review findings (stale-heap identity, `keep_once` lifetime, coherence marking) were fixed with tests, and 0xKaji measured a real memory saving on a 16 GiB / 8 GB machine. What would change the verdict: the stack landing, plus the watch-cost and mid-write artifacts fixed and shown on a Windows run. CI: passing (01:37 UTC run). --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 10:51 UTC · original

Thanks for the triage. I agree, and I've marked this as a draft until the following are done:

  1. Order: #2088 (and #402 with it) first. Then I'll rebase so the diff shows only the in-place work.
  2. Allocation ownership: a generation per allocation, so memory released and made again at the same address and size can't leave a heap reading stale pinned pages.
  3. A benefit shown: my Linux A/B at the 90% threshold showed no clear gain, and there's no in-world Windows A/B yet. I'll take it out of draft only with a Windows world run that shows one.

Until then it's parked. The review fixes stay in, since the mode is off by default.

**@⁠desplmfao** on GitHub · 2026-11-25 10:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7160261381) Thanks for the triage. I agree, and I've marked this as a draft until the following are done: 1. **Order:** #2088 (and #402 with it) first. Then I'll rebase so the diff shows only the in-place work. 2. **Allocation ownership:** a generation per allocation, so memory released and made again at the same address and size can't leave a heap reading stale pinned pages. 3. **A benefit shown:** my Linux A/B at the 90% threshold showed no clear gain, and there's no in-world Windows A/B yet. I'll take it out of draft only with a Windows world run that shows one. Until then it's parked. The review fixes stay in, since the mode is off by default.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 15:26 UTC · original

First in-title A/B of this PR with the switch on, on top of #2389 and our other open GPU fixes.

Setup: Grand Theft Auto VI Series X, the prison yard. RTX 5080 on Linux, Proton with vkd3d-proton 3.2.0. One exe, run without and with VICTORY_IN_PLACE=1. Medians of the last 10 frame lines after the pipeline queue emptied.

off VICTORY_IN_PLACE=1
ms per frame 933 (900–983) 817 (650–1,617)
preparing: copies 438 ms 331 ms
on the GPU 338 ms 331 ms
host copies of title memory 14,244 (5,458 MB) 15,565 (5,019 MB)
  • Copies drop by about 100 ms a frame (−25 %), with no extra video memory.
  • Only about 440 MB of the roughly 5.5 GB of host copies goes in place. vkd3d-proton logs Failed to allocate 65536/262144 bytes on memory type 3 for some imports, which then fall back to the copy. To see the reasons, 62d8f2f counts in diagnostics builds why a range stays copied (not committed, several allocations, offset, sparse, heap refused, placement refused) and logs it with the views status line.
  • Skinned characters break with the switch on. The player character's arm and several prisoners' arms are stretched into dark wedges, and one prisoner in the background is tilted about 45° instead of sitting. None of this shows in runs without the switch. Static geometry looks right. This looks like skinning data (bone matrices or skinned vertices) read in place while the title is already writing the next frame into the same memory; a copy gives each submission a consistent snapshot, in place doesn't. So with the switch on, buffers the title rewrites every frame shouldn't go in place, or they need to be read through a copy.

How it was found: A/B runs of one exe with the switch off and on, compared on the fps line's preparing/copies and host copies of title memory figures. The user judged the picture by eye.

**@⁠desplmfao** on GitHub · 2026-11-25 15:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7166844948) First in-title A/B of this PR with the switch on, on top of #2389 and our other open GPU fixes. **Setup:** Grand Theft Auto VI Series X, the prison yard. RTX 5080 on Linux, Proton with vkd3d-proton 3.2.0. One exe, run without and with `VICTORY_IN_PLACE=1`. Medians of the last 10 frame lines after the pipeline queue emptied. | | off | `VICTORY_IN_PLACE=1` | |---|---|---| | ms per frame | 933 (900–983) | **817** (650–1,617) | | preparing: copies | 438 ms | **331 ms** | | on the GPU | 338 ms | 331 ms | | host copies of title memory | 14,244 (5,458 MB) | 15,565 (5,019 MB) | - **Copies drop by about 100 ms a frame** (−25 %), with no extra video memory. - **Only about 440 MB of the roughly 5.5 GB of host copies goes in place.** vkd3d-proton logs `Failed to allocate 65536/262144 bytes on memory type 3` for some imports, which then fall back to the copy. To see the reasons, `62d8f2f` counts in diagnostics builds why a range stays copied (not committed, several allocations, offset, sparse, heap refused, placement refused) and logs it with the views status line. - **Skinned characters break with the switch on.** The player character's arm and several prisoners' arms are stretched into dark wedges, and one prisoner in the background is tilted about 45° instead of sitting. None of this shows in runs without the switch. Static geometry looks right. This looks like skinning data (bone matrices or skinned vertices) read in place while the title is already writing the next frame into the same memory; a copy gives each submission a consistent snapshot, in place doesn't. So with the switch on, buffers the title rewrites every frame shouldn't go in place, or they need to be read through a copy. **How it was found:** A/B runs of one exe with the switch off and on, compared on the fps line's `preparing`/`copies` and `host copies of title memory` figures. The user judged the picture by eye.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-25 16:18 UTC · original

Merged main (merge commits, no rebase). main's indirect rework (315cea18) reads the title's records through a root view and writes the clamped ones into a buffer the list owns, so it never writes title memory any more. That makes this PR's "clamp in-place indirect arguments in a copy" commit unnecessary: draw.rs and indirect.rs are now exactly main's. In shadow.rs, main's copies that share one large buffer and this PR's in-place buffers now go through one constructor; in-place buffers stay untracked.

Clippy is clean with and without --features diagnostics, and shadow:: and watch:: pass under Wine. Four or five indirect:: tests fail here, but the same ones fail on plain main under vkd3d-proton, so they don't come from this branch. Still open, as noted above: the skinning artifacts with VICTORY_IN_PLACE=1. A fix for those (a buffer goes in place only once the title has left it unwritten for a while) is next, after an in-title check.

**@⁠desplmfao** on GitHub · 2026-11-25 16:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7167775748) Merged `main` (merge commits, no rebase). `main`'s indirect rework (`315cea18`) reads the title's records through a root view and writes the clamped ones into a buffer the list owns, so it never writes title memory any more. That makes this PR's "clamp in-place indirect arguments in a copy" commit unnecessary: `draw.rs` and `indirect.rs` are now exactly `main`'s. In `shadow.rs`, `main`'s copies that share one large buffer and this PR's in-place buffers now go through one constructor; in-place buffers stay untracked. Clippy is clean with and without `--features diagnostics`, and `shadow::` and `watch::` pass under Wine. Four or five `indirect::` tests fail here, but the same ones fail on plain `main` under vkd3d-proton, so they don't come from this branch. Still open, as noted above: the skinning artifacts with `VICTORY_IN_PLACE=1`. A fix for those (a buffer goes in place only once the title has left it unwritten for a while) is next, after an in-title check.
Author
Owner

@⁠0xKaji on GitHub · 2026-11-25 19:40 UTC · original · edited 2026-11-25 20:26 UTC

Tested on Linux + Wine 11.22 + vkd3d-proton + NVIDIA RTX 3060 (8 GB VRAM, 16 GiB system RAM) in Series S mode:

  • Default VICTORY_IN_PLACE=1 (MIN_KB=1024, DENSITY=90): reduced world-entry memory from 15.67 GiB RSS (17,367 MB working set, 4,757 MB system memory) down to 11.25 GiB RSS (12,898 MB working set, 3,078 MB system memory).
  • Combined with VICTORY_PIPELINE_WORKERS=1 (and #2723), a full 4-minute run completed without OOM/crash (exit=124) at 8.51 GiB peak RSS (~4.9 GiB available).
  • Threshold check: lowering to VICTORY_IN_PLACE_DENSITY=60 / VICTORY_IN_PLACE_MIN_KB=256 made memory worse (earlier exit=137 at ~63 s), confirming the premature-pinning trade-off noted in dense(). The default 1024 KB / 90% works much better here.
**@⁠0xKaji** on GitHub · 2026-11-25 19:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7172614158) · edited 2026-11-25 20:26 UTC Tested on Linux + Wine 11.22 + vkd3d-proton + NVIDIA RTX 3060 (8 GB VRAM, 16 GiB system RAM) in Series S mode: - **Default `VICTORY_IN_PLACE=1` (`MIN_KB=1024`, `DENSITY=90`):** reduced world-entry memory from **15.67 GiB RSS** (17,367 MB working set, 4,757 MB system memory) down to **11.25 GiB RSS** (12,898 MB working set, 3,078 MB system memory). - Combined with `VICTORY_PIPELINE_WORKERS=1` (and #2723), a full 4-minute run completed without OOM/crash (`exit=124`) at **8.51 GiB peak RSS** (~4.9 GiB available). - **Threshold check:** lowering to `VICTORY_IN_PLACE_DENSITY=60` / `VICTORY_IN_PLACE_MIN_KB=256` made memory worse (earlier `exit=137` at ~63 s), confirming the premature-pinning trade-off noted in `dense()`. The default `1024 KB` / `90%` works much better here.
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 02:34 UTC · original

@⁠0xKaji thanks, this is the measurement this PR was missing. With 8 GB of video memory and 16 GiB RAM in Series S mode, 15.67 GiB RSS down to 11.25 GiB at world entry, and a 4-minute run without running out of memory, is a real benefit on exactly the kind of machine that needs it. The threshold check helps too: it confirms that the 1 MiB / 90 % defaults are the right side of the trade-off.

Still open before this leaves draft: the skinning artifacts with the switch on (stretched arms, a tilted NPC; see the A/B above). Did you see anything like that on characters in your runs?

**@⁠desplmfao** on GitHub · 2026-11-26 02:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7180925146) @⁠0xKaji thanks, this is the measurement this PR was missing. With 8 GB of video memory and 16 GiB RAM in Series S mode, 15.67 GiB RSS down to 11.25 GiB at world entry, and a 4-minute run without running out of memory, is a real benefit on exactly the kind of machine that needs it. The threshold check helps too: it confirms that the 1 MiB / 90 % defaults are the right side of the trade-off. Still open before this leaves draft: the skinning artifacts with the switch on (stretched arms, a tilted NPC; see the A/B above). Did you see anything like that on characters in your runs?
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-26 03:52 UTC · original · edited 2026-11-26 03:55 UTC

A data point from Windows with native D3D12, not vkd3d-proton: RTX 5070 Ti, Windows 11. I merged #2112 with #402 and #2088 on top of current main plus #2870 (copies in GPU upload heaps), and ran it with VICTORY_IN_PLACE=1.

  • Very little went in place. The log shows only refused={"sparse": 1} and refused={"heap refused": 1}, and host copies in system memory went from 6.4 GB to just 4.6 GB.
  • CPU copy time per frame went from 70–90 ms (~420 MB) to ~2.8 s (~1.6 GB), and the frame went from ~1.5 s to ~3.8 s.
  • Cutscenes rendered as a flat white-to-grey screen.

The same build without the variable renders normally. So on Windows/NVIDIA the opt-in currently costs far more than it saves. I'm happy to run a diagnostics build of a newer revision if that helps.

🤖 Generated with Claude Code (Claude Opus 5.5)

**@⁠kawaii-shakal** on GitHub · 2026-11-26 03:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7182097560) · edited 2026-11-26 03:55 UTC A data point from Windows with native D3D12, not vkd3d-proton: RTX 5070 Ti, Windows 11. I merged #2112 with #402 and #2088 on top of current main plus #2870 (copies in GPU upload heaps), and ran it with `VICTORY_IN_PLACE=1`. - Very little went in place. The log shows only `refused={"sparse": 1}` and `refused={"heap refused": 1}`, and host copies in system memory went from 6.4 GB to just 4.6 GB. - CPU copy time per frame went from 70–90 ms (~420 MB) to ~2.8 s (~1.6 GB), and the frame went from ~1.5 s to ~3.8 s. - Cutscenes rendered as a flat white-to-grey screen. The same build without the variable renders normally. So on Windows/NVIDIA the opt-in currently costs far more than it saves. I'm happy to run a diagnostics build of a newer revision if that helps. 🤖 Generated with [Claude Code](https://claude.com/claude-code) (Claude Opus 5.5)
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 04:16 UTC · original · edited 2026-11-26 04:34 UTC

@⁠kawaii-shakal thanks, the first native D3D12 numbers for this, and they're clear. With the switch on, copies per frame go from ~420 MB to ~1.6 GB while almost nothing goes in place, and cutscenes go flat. So on a discrete NVIDIA card under Windows the opt-in costs far more than it saves. That matches my Linux A/B (no clear gain at 90 %). The benefit so far has only shown up where system RAM is the limit (0xKaji's 16 GiB RAM machine with an 8 GB card: RSS down from 15.67 to 11.25 GiB) and on shared-memory hosts (#2945). The switch stays off by default, and this PR stays a draft.

Three things would help pin down where the extra 1.2 GB per frame comes from:

  1. Which #2112 head did you build? Since 2f0590a (#2088), loose windows are 4 MiB by default again. The 256 KiB ones copy several times the bytes per frame, which looks a lot like your numbers. The current head is ab2b7ef.
  2. The same run without #2870, if that's easy. In-place buffers are left out of the copy tracking, and I haven't checked how that interacts with copies placed in upload heaps.
  3. From a diagnostics build: the copies per frame lines (copystat) with the switch on and off, and the in place: refusal counts.

The flat cutscenes are probably the same problem as the stretched arms I saw: a buffer the title writes every frame, read in place mid-write. The fix I have in mind keeps a buffer copied until the title has left it unwritten for a few seconds.

**@⁠desplmfao** on GitHub · 2026-11-26 04:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7182445247) · edited 2026-11-26 04:34 UTC @⁠kawaii-shakal thanks, the first native D3D12 numbers for this, and they're clear. With the switch on, copies per frame go from ~420 MB to ~1.6 GB while almost nothing goes in place, and cutscenes go flat. So on a discrete NVIDIA card under Windows the opt-in costs far more than it saves. That matches my Linux A/B (no clear gain at 90 %). The benefit so far has only shown up where system RAM is the limit (0xKaji's 16 GiB RAM machine with an 8 GB card: RSS down from 15.67 to 11.25 GiB) and on shared-memory hosts (#2945). The switch stays off by default, and this PR stays a draft. Three things would help pin down where the extra 1.2 GB per frame comes from: 1. **Which #2112 head did you build?** Since `2f0590a` (#2088), loose windows are 4 MiB by default again. The 256 KiB ones copy several times the bytes per frame, which looks a lot like your numbers. The current head is `ab2b7ef`. 2. **The same run without #2870**, if that's easy. In-place buffers are left out of the copy tracking, and I haven't checked how that interacts with copies placed in upload heaps. 3. **From a diagnostics build:** the `copies per frame` lines (`copystat`) with the switch on and off, and the `in place:` refusal counts. The flat cutscenes are probably the same problem as the stretched arms I saw: a buffer the title writes every frame, read in place mid-write. The fix I have in mind keeps a buffer copied until the title has left it unwritten for a few seconds.
Author
Owner

@⁠kawaii-shakal on GitHub · 2026-11-26 05:04 UTC · original

@⁠desplmfao answers in order:

  1. Head: it was ab2b7ef, so the 4 MiB loose windows were the default and the 256 KiB windows aren't the cause.
  2. Without #2870: I reran on plain current main merged with ab2b7ef (a fast-forward), with nothing else in the tree: no #2870, none of the other PRs from my first run. RTX 5070 Ti, Windows 11, native D3D12, diagnostics build, same save, ~3 min each into the world. The cost is the same without #2870.
  3. copystat and refusals, three consecutive 5 s lines each:
per frame VICTORY_IN_PLACE unset VICTORY_IN_PLACE=1
frame 0.67–2.0 s 6.3–8.3 s
preparing: copies 69–118 ms, 456–529 MB 7.6–10.9 s, 2.3–2.4 GB
refreshes 14,925–15,442, 11.5–12.1 GB 4,950–5,282, 5.1–5.2 GB
watches 13–19 ms, 4.1–5.6 GB checked (3.6–5.1 GB unchanged) 5.7–7.7 s, 11.3–13.2 GB checked (9.0–10.9 GB unchanged)
snapshots 646–957 MB in 72–76 ms 38–53 MB in 1.3–1.8 ms
on the GPU 0.23–1.7 s 0.21–0.24 s
draws / dropped / dropped indirect 2,095–2,717 / 827–1,311 / 420–1,282 1,140–1,222 / 228–269 / 42
host copies of title memory at the end 5,023 (6,032 MB) 6,157 (4,992 MB)

The only in place refusal line in the whole run is title memory kept as a copy, not in place (since the line before) refused={"sparse": 1}.

So almost all of the extra time is in watches: about 2.5× as many bytes checked per frame, at roughly 400× the time. Refreshes and snapshots actually go down. That looks like whatever the in-place buffers still go through in watch (checking or guarding pages of memory that is now read in place) rather than copies proper. Also, with the switch on the frame draws about half as much, which fits the flat cutscenes you suspect come from buffers read mid-write.

🤖 Generated with Claude Code (Claude Opus 5.5)

**@⁠kawaii-shakal** on GitHub · 2026-11-26 05:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7183159392) @⁠desplmfao answers in order: 1. **Head:** it was `ab2b7ef`, so the 4 MiB loose windows were the default and the 256 KiB windows aren't the cause. 2. **Without #2870:** I reran on plain current `main` merged with `ab2b7ef` (a fast-forward), with nothing else in the tree: no #2870, none of the other PRs from my first run. RTX 5070 Ti, Windows 11, native D3D12, `diagnostics` build, same save, ~3 min each into the world. The cost is the same without #2870. 3. **`copystat` and refusals**, three consecutive 5 s lines each: | per frame | `VICTORY_IN_PLACE` unset | `VICTORY_IN_PLACE=1` | |---|---|---| | frame | 0.67–2.0 s | 6.3–8.3 s | | preparing: copies | 69–118 ms, 456–529 MB | **7.6–10.9 s**, 2.3–2.4 GB | | refreshes | 14,925–15,442, 11.5–12.1 GB | 4,950–5,282, 5.1–5.2 GB | | watches | **13–19 ms**, 4.1–5.6 GB checked (3.6–5.1 GB unchanged) | **5.7–7.7 s**, 11.3–13.2 GB checked (9.0–10.9 GB unchanged) | | snapshots | 646–957 MB in 72–76 ms | 38–53 MB in 1.3–1.8 ms | | on the GPU | 0.23–1.7 s | 0.21–0.24 s | | draws / dropped / dropped indirect | 2,095–2,717 / 827–1,311 / 420–1,282 | 1,140–1,222 / 228–269 / 42 | | host copies of title memory at the end | 5,023 (6,032 MB) | 6,157 (4,992 MB) | The only `in place` refusal line in the whole run is `title memory kept as a copy, not in place (since the line before) refused={"sparse": 1}`. So almost all of the extra time is in **watches**: about 2.5× as many bytes checked per frame, at roughly 400× the time. Refreshes and snapshots actually go down. That looks like whatever the in-place buffers still go through in `watch` (checking or guarding pages of memory that is now read in place) rather than copies proper. Also, with the switch on the frame draws about half as much, which fits the flat cutscenes you suspect come from buffers read mid-write. 🤖 Generated with [Claude Code](https://claude.com/claude-code) (Claude Opus 5.5)
Author
Owner

@⁠desplmfao on GitHub · 2026-11-26 05:24 UTC · original

@⁠kawaii-shakal thanks, the watches line pinned it down. It was this PR, in Shadow::landed. After every submission, a buffer in place marks the whole range its shaders may write as changed, and it did that through watch::writing. That function is meant for kernel writes into title memory: every tracker holding a page saves its bytes first, and the guards are opened, so those pages get compared again at every later refresh. Over whole buffer ranges, every submission, that is the 11–13 GB checked (9–11 GB unchanged) and the 5.7–7.7 s in your table.

29decb3 adds watch::gpu_wrote. It marks the pages, and pages aliased to them, as changed in every tracker, as before. It saves nothing, because the write has already happened and there is no "before" to keep. It opens no guards, because a GPU write doesn't go through the CPU's page protection, so the title's own writes stay seen. shadow:: and watch:: give 40 passed under Wine, including writes_in_place_mark_other_copies_of_the_page_changed, and clippy is clean.

If you can, the same A/B on 29decb3 would show whether the watch time is back near the switch-off level. Your table also shows the switch-on frame drawing about half as much (1,140–1,222 draws against 2,095–2,717). This fix doesn't explain that, and it fits the buffers read mid-write. That part is still open.

**@⁠desplmfao** on GitHub · 2026-11-26 05:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7183456989) @⁠kawaii-shakal thanks, the watches line pinned it down. It was this PR, in `Shadow::landed`. After every submission, a buffer in place marks the whole range its shaders may write as changed, and it did that through `watch::writing`. That function is meant for kernel writes into title memory: every tracker holding a page saves its bytes first, and the guards are opened, so those pages get compared again at every later refresh. Over whole buffer ranges, every submission, that is the 11–13 GB checked (9–11 GB unchanged) and the 5.7–7.7 s in your table. `29decb3` adds `watch::gpu_wrote`. It marks the pages, and pages aliased to them, as changed in every tracker, as before. It saves nothing, because the write has already happened and there is no "before" to keep. It opens no guards, because a GPU write doesn't go through the CPU's page protection, so the title's own writes stay seen. `shadow::` and `watch::` give 40 passed under Wine, including `writes_in_place_mark_other_copies_of_the_page_changed`, and clippy is clean. If you can, the same A/B on `29decb3` would show whether the watch time is back near the switch-off level. Your table also shows the switch-on frame drawing about half as much (1,140–1,222 draws against 2,095–2,717). This fix doesn't explain that, and it fits the buffers read mid-write. That part is still open.
Author
Owner

@⁠MeMako on GitHub · 2026-11-26 07:16 UTC · original

Tested #2112 (29decb3, VICTORY_IN_PLACE=1) on native Windows 11 (10.0.26200) + AMD Radeon RX 9070 XT (RDNA 4, driver 32.0.32029.2010, Ryzen 9 7950X, 32 GB RAM).

Unit Tests

  • cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings: clean.
  • cargo test -p victory-gpu --lib --locked -- --test-threads=1: 287/287 passed, 0 failed (10 ignored benchmarks), including committed_memory_opens_as_a_buffer_in_place, a_sub_range_heap_covers_only_the_buffer, a_heap_over_a_released_allocation_is_let_go, a_list_keeps_the_in_place_buffers_it_uses, writes_in_place_mark_other_copies_of_the_page_changed, and stale_queue_does_not_evict_replacement_heap_at_same_base.

Live Title Run (VICTORY_IN_PLACE=1, default 1 MiB min)

  • Setup: Local integration stack on main 63bcca4 + #2051 + #2472 + #2918 (shadow.rs/watch.rs) + #1010 + #2130 (VRAM upload flags off, shadow.rs) + #3055 (shadow.rs/descriptor) + #2914 (shadow.rs) + #2985 + #2849 (watch.rs) + #3035 (watch.rs) + #2958 (no xmem.rs changes). Comparing VICTORY_IN_PLACE unset (0 crashes across 65 world frames) vs. VICTORY_IN_PLACE=1 on the same tree:
  1. Crash during world load (0xc0000005 in title) preceded by 21× xmem os error 487:
    • Baseline (VICTORY_IN_PLACE unset): 0 xmem remap warnings.
    • With VICTORY_IN_PLACE=1: 21× WARN victory_hle::modules::xmem: mapping physical pages failed (not a placeholder?) address=0x717c10000 len=65536 error=Attempt to access invalid address. (os error 487), followed shortly by a title access violation (0xc0000005).
    • Likely cause: on native Windows D3D12, OpenExistingHeapFromAddress1 pins the virtual pages until the underlying ID3D12Heap and placed ID3D12Resource COM objects are actually destroyed. title_memory_remapped() removes entries from BUFFERS/LOOSE, but either a recorded HostList (keep_in_place) or an in-flight/retired resource still sitting in RETIRED waiting on a GPU fence keeps those COM objects alive when xmem calls UnmapViewOfFile2(..., MEM_PRESERVE_PLACEHOLDER) (whose return value is unchecked), preventing the range from reverting to a placeholder unless the GPU is drained and those objects are dropped first.
  2. Large copy blow-up still occurs on 29decb3:
    • On the two world-entry frames right before the crash, preparing: copies jumped from ~468 MB to 2,295–3,478 MB/frame (local profiler stage timers: deferred 1,455–2,490 ms, flush 2,366–3,840 ms, post-copy-back after covering check_in_place 123–156 ms; total 4,683–7,081 ms/frame). Even without opening guards or saving bytes in watch::gpu_wrote, marking whole in-place written ranges changed still appears to trigger massive re-refreshes on overlapping copied buffers.

Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.

**@⁠MeMako** on GitHub · 2026-11-26 07:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7185289390) Tested `#2112` (`29decb3`, `VICTORY_IN_PLACE=1`) on native Windows 11 (`10.0.26200`) + AMD Radeon RX 9070 XT (RDNA 4, driver `32.0.32029.2010`, Ryzen 9 7950X, 32 GB RAM). ### Unit Tests - `cargo clippy -p victory-gpu -p victory --all-targets --locked -- -D warnings`: clean. - `cargo test -p victory-gpu --lib --locked -- --test-threads=1`: **287/287 passed**, 0 failed (10 ignored benchmarks), including `committed_memory_opens_as_a_buffer_in_place`, `a_sub_range_heap_covers_only_the_buffer`, `a_heap_over_a_released_allocation_is_let_go`, `a_list_keeps_the_in_place_buffers_it_uses`, `writes_in_place_mark_other_copies_of_the_page_changed`, and `stale_queue_does_not_evict_replacement_heap_at_same_base`. ### Live Title Run (`VICTORY_IN_PLACE=1`, default `1 MiB` min) - **Setup:** Local integration stack on `main` `63bcca4` + `#2051` + `#2472` + `#2918` (`shadow.rs`/`watch.rs`) + `#1010` + `#2130` (VRAM upload flags off, `shadow.rs`) + `#3055` (`shadow.rs`/`descriptor`) + `#2914` (`shadow.rs`) + `#2985` + `#2849` (`watch.rs`) + `#3035` (`watch.rs`) + `#2958` (no `xmem.rs` changes). Comparing `VICTORY_IN_PLACE` unset (0 crashes across 65 world frames) vs. `VICTORY_IN_PLACE=1` on the same tree: 1. **Crash during world load (`0xc0000005` in title) preceded by 21× `xmem` `os error 487`:** - Baseline (`VICTORY_IN_PLACE` unset): **0** `xmem` remap warnings. - With `VICTORY_IN_PLACE=1`: **21×** ``WARN victory_hle::modules::xmem: mapping physical pages failed (not a placeholder?) address=0x717c10000 len=65536 error=Attempt to access invalid address. (os error 487)``, followed shortly by a title access violation (`0xc0000005`). - Likely cause: on native Windows D3D12, `OpenExistingHeapFromAddress1` pins the virtual pages until the underlying `ID3D12Heap` and placed `ID3D12Resource` COM objects are actually destroyed. `title_memory_remapped()` removes entries from `BUFFERS`/`LOOSE`, but either a recorded `HostList` (`keep_in_place`) or an in-flight/retired resource still sitting in `RETIRED` waiting on a GPU fence keeps those COM objects alive when `xmem` calls `UnmapViewOfFile2(..., MEM_PRESERVE_PLACEHOLDER)` (whose return value is unchecked), preventing the range from reverting to a placeholder unless the GPU is drained and those objects are dropped first. 2. **Large copy blow-up still occurs on `29decb3`:** - On the two world-entry frames right before the crash, `preparing: copies` jumped from ~468 MB to **2,295–3,478 MB/frame** (local profiler stage timers: `deferred` **1,455–2,490 ms**, `flush` **2,366–3,840 ms**, post-copy-back `after` covering `check_in_place` **123–156 ms**; total **4,683–7,081 ms/frame**). Even without opening guards or saving bytes in `watch::gpu_wrote`, marking whole in-place written ranges changed still appears to trigger massive re-refreshes on overlapping copied buffers. *Hardware runs were performed by me on my 7950X / RX 9070 XT; comment drafted with Antigravity.*
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 05:18 UTC · original · approved these changes

Verified locally merged onto origin/main (940d32f, Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu --lib shadow:: — 10 passed, 0 failed
  • cargo clippy -p victory-gpu --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean opt-in VICTORY_IN_PLACE=1 loose title-memory mapping with remap tracking and solid shadow:: test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 05:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#pullrequestreview-6052218381) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu --lib shadow::` — **10 passed, 0 failed** - `cargo clippy -p victory-gpu --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean opt-in `VICTORY_IN_PLACE=1` loose title-memory mapping with remap tracking and solid `shadow::` test coverage. Looks good. AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 05:48 UTC · original · reviewed

Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.

Title memory in place instead of copied, opt-in via VICTORY_* env — zero-copy path behind a flag; risky default-off is right, needs Windows validation.

**@⁠catminou4** on GitHub · 2026-11-25 05:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#pullrequestreview-6052483627) · **reviewed** Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff. Title memory in place instead of copied, opt-in via VICTORY_* env — zero-copy path behind a flag; risky default-off is right, needs Windows validation.
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-26 02:55 UTC · original · approved these changes

LGTM — reviewed the delta over #2088 (8aef2dd9f..f83faa761).

The coherence story holds at every seam:

  • in_place no-ops the whole copy pipeline (refresh/gpu_writes/writing/copy_back*/update) except two deliberate paths: keep_in_place retains the placed buffer — hence its heap, hence the pinned pages — for any list whose commands name the GPU address, and landed marks title pages changed so other shadows (sub-floor buffers, view copies, textures) refresh from memory the shaders wrote in place. memory::bind calls landed on computed-address writes even while withholding — the one path that must not be skipped.
  • committed_part: the VirtualQuery walk down/up one AllocationBase with the 64 KiB floor / 4 KiB ceiling cut and lo <= address && end <= hi guard is exact — including the alignment push-up being guarded rather than clamped silently.
  • in_place_buffer: single-allocation verification walks every region (refuses multi-allocation), offset%64KiB enforced, sub-range opens via OpenExistingHeapFromAddress1 keep heap lifetime bound to the placed buffer, whole-allocation path goes through the cache with extent staleness + the dense() working-set gate (64Ki-page sampling, 10 s cache, 90 % default — the GTA6-on-Linux measurement justifies it).
  • Stale-heap sweep: check_in_place once a frame drains the deferred STALE list plus a fresh extent scan; let_go_heap(id) filters by HeapId so a new heap at the same base survives; deferral under STALE_IN_PLACE correctly avoids re-entering BUFFERS/LOOSE from callers that hold them.
  • keep_once's raw-pointer key contract is documented and keep_in_place uses the buffer pointer — no aliasing.
  • The in_place_remapped hook on title_memory_remapped closes the runtime-map/unmap hole; pin_heap (from #2945) closes the title-side free/protect one — the two halves compose correctly.
  • Tests serialize on IN_PLACE_TESTS and cover committed-part geometry, real heap opens, stale eviction, and overlapping windows.

Noting scope: this reviews #2112's own commits; the 256 KiB loose-window lookup rework is #2088's.

**@⁠kotekompotek** on GitHub · 2026-11-26 02:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#pullrequestreview-6067933873) · **approved these changes** LGTM — reviewed the delta over #2088 (8aef2dd9f..f83faa761). The coherence story holds at every seam: - **`in_place` no-ops the whole copy pipeline** (refresh/gpu_writes/writing/copy_back*/update) except two deliberate paths: `keep_in_place` retains the placed buffer — hence its heap, hence the pinned pages — for any list whose commands name the GPU address, and `landed` marks title pages changed so *other* shadows (sub-floor buffers, view copies, textures) refresh from memory the shaders wrote in place. `memory::bind` calls `landed` on computed-address writes even while withholding — the one path that must not be skipped. - **`committed_part`**: the VirtualQuery walk down/up one AllocationBase with the 64 KiB floor / 4 KiB ceiling cut and `lo <= address && end <= hi` guard is exact — including the alignment push-up being guarded rather than clamped silently. - **`in_place_buffer`**: single-allocation verification walks every region (refuses multi-allocation), offset%64KiB enforced, sub-range opens via `OpenExistingHeapFromAddress1` keep heap lifetime bound to the placed buffer, whole-allocation path goes through the cache with extent staleness + the `dense()` working-set gate (64Ki-page sampling, 10 s cache, 90 % default — the GTA6-on-Linux measurement justifies it). - **Stale-heap sweep**: `check_in_place` once a frame drains the deferred STALE list plus a fresh extent scan; `let_go_heap(id)` filters by HeapId so a new heap at the same base survives; deferral under STALE_IN_PLACE correctly avoids re-entering BUFFERS/LOOSE from callers that hold them. - **`keep_once`**'s raw-pointer key contract is documented and `keep_in_place` uses the buffer pointer — no aliasing. - The `in_place_remapped` hook on `title_memory_remapped` closes the runtime-map/unmap hole; `pin_heap` (from #2945) closes the title-side free/protect one — the two halves compose correctly. - Tests serialize on IN_PLACE_TESTS and cover committed-part geometry, real heap opens, stale eviction, and overlapping windows. Noting scope: this reviews #2112's own commits; the 256 KiB loose-window lookup rework is #2088's.
Author
Owner

@⁠crashbashash on GitHub · 2026-11-26 10:20 UTC · original

A data point from AMD on Linux, where this ends differently than on the 5080 or on Windows: RX 6800 XT, RADV
(Mesa 26.2.6), vkd3d-proton 71cae091b in GE-Proton11-14, this PR merged onto main 219878a plus our Linux
commits, diag build, start from a save in the prison.

head VICTORY_IN_PLACE runs result
ab2b7ef unset 2 into the world, 120 s, normal
ab2b7ef 1 2 device removed about 50 s in, before the world
29decb3 unset 1 into the world, 120 s, normal
29decb3 1 2 device removed about 45 s in, before the world

All four in-place runs end the same way, with no GPU fault and no reset in the kernel log:

vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e     (1,594 to 2,054 times a run)
radv/amdgpu: The CS has been rejected, see dmesg for more information (-1).
d3d12_command_queue_execute: Failed to submit queue(s), vr -4.
d3d12_device_mark_as_removed: ... VK_ERROR_DEVICE_LOST

The crate's tests pass under Wine at 29decb3, the in-place ones included
(committed_memory_opens_as_a_buffer_in_place, a_list_keeps_the_in_place_buffers_it_uses,
writes_in_place_mark_other_copies_of_the_page_changed): a fresh private allocation imports fine.

So the kernel refuses a submission instead of the GPU faulting. What I think happens, from the sources (I have not
traced the failing BO itself):

  • RADV imports host memory through libdrm's amdgpu_create_bo_from_user_mem, which always asks for
    AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER | AMDGPU_GEM_USERPTR_VALIDATE
    (amdgpu_bo.c).
  • With ANONONLY, amdgpu_ttm_tt_get_user_pages returns -EPERM when the range is file-backed or does not lie
    inside a single VMA
    (amdgpu_ttm.c).
    That check runs at import and again when a submission revalidates the pages after they changed.
  • Under Wine, an mprotect of a single page splits the VMA. vkd3d-proton imports the whole allocation (the PR notes
    this), so one page guarded anywhere in it (a buffer under VICTORY_IN_PLACE_MIN_KB that keeps its copy and its
    guard, or another copy's tracker) leaves the imported range across several VMAs. Memory mapped as a section view is
    file-backed under Wine, which ANONONLY refuses outright.

That fits the fresh allocation in the tests importing fine (one anonymous VMA), the failed imports in the game, and a
later submission being refused once a guard or a remap touches an allocation that was imported earlier. NVIDIA's
driver doesn't have this restriction, which fits your runs getting further.

If that's right, on amdgpu an allocation can only go in place if nothing guards any page of it for as long as it's
imported, and it must be private memory (no section views). Happy to test a change on this card.

AI-assisted (Claude Code). No game data attached.

**@⁠crashbashash** on GitHub · 2026-11-26 10:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7189224750) A data point from AMD on Linux, where this ends differently than on the 5080 or on Windows: RX 6800 XT, RADV (Mesa 26.2.6), vkd3d-proton `71cae091b` in GE-Proton11-14, this PR merged onto `main` `219878a` plus our Linux commits, `diag` build, start from a save in the prison. | head | `VICTORY_IN_PLACE` | runs | result | |---|---|---|---| | `ab2b7ef` | unset | 2 | into the world, 120 s, normal | | `ab2b7ef` | `1` | 2 | device removed about 50 s in, before the world | | `29decb3` | unset | 1 | into the world, 120 s, normal | | `29decb3` | `1` | 2 | device removed about 45 s in, before the world | All four in-place runs end the same way, with no GPU fault and no reset in the kernel log: ``` vkd3d_import_host_memory: Failed to import host memory, hr 0x8007000e (1,594 to 2,054 times a run) radv/amdgpu: The CS has been rejected, see dmesg for more information (-1). d3d12_command_queue_execute: Failed to submit queue(s), vr -4. d3d12_device_mark_as_removed: ... VK_ERROR_DEVICE_LOST ``` The crate's tests pass under Wine at `29decb3`, the in-place ones included (`committed_memory_opens_as_a_buffer_in_place`, `a_list_keeps_the_in_place_buffers_it_uses`, `writes_in_place_mark_other_copies_of_the_page_changed`): a fresh private allocation imports fine. So the kernel refuses a submission instead of the GPU faulting. What I think happens, from the sources (I have not traced the failing BO itself): - RADV imports host memory through libdrm's `amdgpu_create_bo_from_user_mem`, which always asks for `AMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER | AMDGPU_GEM_USERPTR_VALIDATE` ([amdgpu_bo.c](https://gitlab.freedesktop.org/mesa/drm/-/blob/main/amdgpu/amdgpu_bo.c)). - With `ANONONLY`, `amdgpu_ttm_tt_get_user_pages` returns `-EPERM` when the range is file-backed **or does not lie inside a single VMA** ([amdgpu_ttm.c](https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c)). That check runs at import and again when a submission revalidates the pages after they changed. - Under Wine, an `mprotect` of a single page splits the VMA. vkd3d-proton imports the whole allocation (the PR notes this), so one page guarded anywhere in it (a buffer under `VICTORY_IN_PLACE_MIN_KB` that keeps its copy and its guard, or another copy's tracker) leaves the imported range across several VMAs. Memory mapped as a section view is file-backed under Wine, which `ANONONLY` refuses outright. That fits the fresh allocation in the tests importing fine (one anonymous VMA), the failed imports in the game, and a later submission being refused once a guard or a remap touches an allocation that was imported earlier. NVIDIA's driver doesn't have this restriction, which fits your runs getting further. If that's right, on amdgpu an allocation can only go in place if nothing guards any page of it for as long as it's imported, and it must be private memory (no section views). Happy to test a change on this card. AI-assisted (Claude Code). No game data attached.
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-26 14:48 UTC · original

Unit-test run on native Windows with NVIDIA, the combination the description lists as untested: RTX 4060 8 GB (PCIe 4.0 x8, Resizable BAR on), driver 621.14, Windows 11 Pro 26300. Head 29decb3 merged onto main 63bcca4, cargo test -p victory-gpu --lib --locked -- --test-threads=1. No game files.

  • 244 passed, 2 failed. The 2 are the known capped-heap failures that main also has on this card (#1835).
  • All the in-place tests pass on the hardware adapter: committed_memory_opens_as_a_buffer_in_place, a_sub_range_heap_covers_only_the_buffer, a_heap_over_a_released_allocation_is_let_go, a_list_keeps_the_in_place_buffers_it_uses, writes_in_place_mark_other_copies_of_the_page_changed. So OpenExistingHeapFromAddress over process memory works on this driver.

A cost data point for in place on a discrete card, from #3102's synthetic benchmark on the same 4060 (its in-place path also opens title memory as heaps; comment there). 200 dispatches over 320 MiB of title buffers, ms per submission: copies in system memory 160.8, in place 113-122, copies in video memory 53-106. On a narrow link, shaders reading title memory across the bus cost more than keeping a VRAM copy. That fits #2734 putting hot buffers in VRAM on top of this.

AI-assisted (Claude)

**@⁠potatoe0100** on GitHub · 2026-11-26 14:48 UTC · [original](https://github.com/Marvisak/VIctory/pull/2112#issuecomment-7195353863) Unit-test run on native Windows with NVIDIA, the combination the description lists as untested: **RTX 4060 8 GB** (PCIe 4.0 x8, Resizable BAR on), driver 621.14, Windows 11 Pro 26300. Head `29decb3` merged onto `main` `63bcca4`, `cargo test -p victory-gpu --lib --locked -- --test-threads=1`. No game files. - 244 passed, 2 failed. The 2 are the known capped-heap failures that `main` also has on this card (#1835). - All the in-place tests pass on the hardware adapter: `committed_memory_opens_as_a_buffer_in_place`, `a_sub_range_heap_covers_only_the_buffer`, `a_heap_over_a_released_allocation_is_let_go`, `a_list_keeps_the_in_place_buffers_it_uses`, `writes_in_place_mark_other_copies_of_the_page_changed`. So `OpenExistingHeapFromAddress` over process memory works on this driver. A cost data point for in place on a discrete card, from #3102's synthetic benchmark on the same 4060 (its in-place path also opens title memory as heaps; [comment there](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3102)). 200 dispatches over 320 MiB of title buffers, ms per submission: copies in system memory 160.8, **in place 113-122**, copies in video memory 53-106. On a narrow link, shaders reading title memory across the bus cost more than keeping a VRAM copy. That fits #2734 putting hot buffers in VRAM on top of this. AI-assisted (Claude)
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2112/head:github-bot/gh-2112'
git switch 'github-bot/gh-2112'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2112'
git switch 'github-bot/gh-2112'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2112'
git switch 'github-bot/gh-2112'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2112'
git switch 'main'
git merge --squash 'github-bot/gh-2112'
git switch 'main'
git merge --ff-only 'github-bot/gh-2112'
git switch 'main'
git merge 'github-bot/gh-2112'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!2112
No description provided.