No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2112
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2112"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@desplmfao on GitHub · 2026-11-25 05:12 UTC · original
desplmfao:perf/loose-windows-in-place→main· +1262 −16 · 5 files · 35 commits · draftStacked 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 withID3D12Device3::OpenExistingHeapFromAddress(under vkd3d-proton that isVK_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 ofShadowreturns early for such a window.watch::title_memory_remappeddrops 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.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:main(4 MiB copies)VICTORY_IN_PLACE=1No 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
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).Tested
the_committed_part_of_a_window_holds_the_range_or_is_none(pure CPU, a reservation with a committed middle) andcommitted_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. Plainmainfails 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
github-bot referenced this pull request2026-11-26 05:07:28 +00:00
@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:
VICTORY_IN_PLACE=1against without it;Tests on a machine that already reaches the world (Windows or AMD in particular) would help a lot before that.
@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.
@yualk on GitHub · 2026-11-25 05:38 UTC · original
Scoped native Windows result on RTX 5070 Ti
10de:2c05(610.88) and explicit WARP1414:008c. The #2112 allocation-base import andCOMMON / ALLOW_CROSS_ADAPTER | ALLOW_UNORDERED_ACCESS128 KiB placement at a 64 KiB offset worked for fully committed private memory, privateMEM_WRITE_WATCH, and a fully committed view in an otherwise reserved pagefile section.GetResourceAllocationInforequired 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:findholdsBUFFERSandlooseholdsLOOSEwhen callingin_place_buffer. On a stale cached extent it callslet_go_in_placesynchronously; 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.@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 ownVirtualFreeof 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:
VICTORY_IN_PLACE, so the 2.8 s can be compared;@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
findandloosehold. Fixed in97503f9:in_place_buffernow only drops a stale heap from the cache and queues it, andcheck_in_placelets go of its windows and buffers at the next frame, outsideBUFFERSandLOOSE. The new testa_stale_heap_is_replaced_under_the_callers_lockscalls 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 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:VICTORY_IN_PLACE=1In-place works as intended: every loose window and title buffer went in place,
refused=0in 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:
OpenExistingHeapFromAddresshas 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 07:05 UTC · original
Update: two changes for the residency problem from my last comment.
1. Density check (
0ae1d5c, keyed per allocation infcfecd1). WithQueryWorkingSetEx, the two pools that held most buffers were far from resident:0xd89c000000xd40800000Opening 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_DENSITYchanges the threshold). Sparse allocations keep their copies.Same build, in the world, average of 9 samples per run:
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 hasID3D12Device13, a buffer goes in place throughOpenExistingHeapFromAddress1over 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 noID3D12Device13(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 testa_sub_range_heap_covers_only_the_buffercovers it and skips on hosts withoutID3D12Device13. A Windows run withVICTORY_IN_PLACE=1would be very welcome.Tests on the RTX 5080 under Proton:
victory-gpu139 passed, 13 failed, the same 13 asmainhere. All in-place tests pass, including the newa_sparse_allocation_is_not_opened_whole. Clippy is clean. (fcfecd1alone fails clippy over a missing safety comment;c79c031fixes it.)@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 (
cd079affollowsc79c031). The A/B numbers at 90% and the sub-range change stand.@nathanbzrr on GitHub · 2026-11-25 08:40 UTC · original
Verified head
cd079affdbb52b9a8b25ca63dc22751e18d49339natively on Windows 11 x64 (10.0.26340) / AMD Radeon RX 7600 (ID3D12Device13,--features diagnostics+VICTORY_D3D12_DEBUG=1):VICTORY_IN_PLACEunset):shadow::tests14/14 passed under D3D12 Debug Layer, includinga_sub_range_heap_covers_only_the_buffer(ID3D12Device13::OpenExistingHeapFromAddress1succeeds 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), andbindless::tests(3/3) pass; the 3 existing copy-trackingshadow::testsfail as expected becausein_placeshadows bypass tracking/copy-back.Live Repro & Blocking Findings (Confirming Why Mode Must Stay Opt-In)
STALE_IN_PLACEover-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)inSTALE_IN_PLACE, callingcheck_in_place()callslet_go_in_place(base, S1)which evicts by address overlap with no generation/heap-ID check — evicting the newly created valid heapS2(stale_queue_does_not_evict_replacement_heap_at_same_basefailed withsurvived=false).VirtualProtect& Placeholder Remaps (err=87):Measured directly on RX 7600 and WARP (#1905 probes): on Windows, while an
OpenExistingHeapFromAddressheap is alive (bothMEM_WRITE_WATCHand plainVirtualAlloc),VirtualProtect(PAGE_GUARD/PAGE_READONLY/PAGE_NOACCESS) andUnmapViewOfFile2(MEM_PRESERVE_PLACEHOLDER)fail withERROR_INVALID_PARAMETER (87)until theID3D12Heapis released.Shadow::refresh/gpu_writes): Early return skipslist.keep(&self.buffer). Anyunregister/let_go_in_place/Upload::dropbefore GPU completion drops theID3D12Resource(and Path A's soleID3D12Heap) while command lists hold raw GPU VAs (draw.rs:195,...).indirect::bound): Indirect clamping dispatches a compute shader writing directly toargs.buffer(draw.rs:1588-1593), mutating live title RAM in place.ID3D12Device13) gaps: Path A never records intoIN_PLACE_HEAPS, makingcheck_in_place()a no-op on Windows/RX 7600, andcommitted_parttruncateshito 4 KiB instead of 64 KiB (CreatePlacedResourcebuffer placement granularity).missedsafety:s0 = key.0 / 64KiB * 64KiBshifts alignment so structured views infor_viewspill into trackedexact()copies on the same 64 KiB pages (remaining stale against GPU UAV writes), andwithheld/missedprotection (memory.rs:438) is bypassed when GPU writes directly into title RAM.(Proposed / uncompiled fix directions:) add
list.keep(&self.buffer)inShadow::refresh/gpu_writes, aligncommitted_parthito 64 KiB, checkinfo.Protect == PAGE_READWRITE, clearNoneentries inlet_go_in_place, tagIN_PLACE_HEAPSwith monotonic generation IDs, track Path A allocations/windows incheck_in_place(), and routeindirect::bound/exact()coherency safely.AI-assisted; synthetic tests only, no game files, dumps, or captures used.
@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:
let_go_in_placegoes 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. Yourstale_queue_does_not_evict_replacement_heap_at_same_basebecomes a test.refresh/gpu_writesskiplist.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.indirect::boundwriting 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 withexact()copies on the same pages, andwithheld/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 09:28 UTC · original
@nathanbzrr all four code findings were real, and they're fixed in new commits:
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 asstale_queue_does_not_evict_replacement_heap_at_same_base.2eb3aa8):refresh/gpu_writeson 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.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.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:
unregisterdrops it, and remaps let go by address, which covers path A.committed_partending 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/missedcan'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
VirtualProtectis 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, soVICTORY_IN_PLACEstays 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_bufferruns the sub-range path here instead of returning early. So theOpenExistingHeapFromAddress1path 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 fullvictory-gpusuite fails only tests that also fail onmainon this machine. Clippy is clean with and without--features diagnostics.@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.022e9c8,b670a33,2f0590a,6ebed99, none of them inmain). It can only be judged on its own once those land and it's rebased.watches: about 2.5× the bytes checked, at about 400× the time. So in-place memory still seems to go throughwatchpage checking somewhere (shadow.rs, the in-place early returns vs. the watch/tracking paths, and the newmemory::bindlandedloop are where I'd look). This should be explained and fixed before the mode is offered, even opt-in.VirtualFree/VirtualProtectcan 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_oncelifetime, 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
@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:
Until then it's parked. The review fixes stay in, since the mode is off by default.
@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.VICTORY_IN_PLACE=1Failed to allocate 65536/262144 bytes on memory type 3for some imports, which then fall back to the copy. To see the reasons,62d8f2fcounts 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.How it was found: A/B runs of one exe with the switch off and on, compared on the fps line's
preparing/copiesandhost copies of title memoryfigures. The user judged the picture by eye.@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.rsandindirect.rsare now exactlymain's. Inshadow.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, andshadow::andwatch::pass under Wine. Four or fiveindirect::tests fail here, but the same ones fail on plainmainunder vkd3d-proton, so they don't come from this branch. Still open, as noted above: the skinning artifacts withVICTORY_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.@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:
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).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).VICTORY_IN_PLACE_DENSITY=60/VICTORY_IN_PLACE_MIN_KB=256made memory worse (earlierexit=137at ~63 s), confirming the premature-pinning trade-off noted indense(). The default1024 KB/90%works much better here.@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?
@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.refused={"sparse": 1}andrefused={"heap refused": 1}, and host copies in system memory went from 6.4 GB to just 4.6 GB.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)
@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:
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 isab2b7ef.copies per framelines (copystat) with the switch on and off, and thein 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.
@kawaii-shakal on GitHub · 2026-11-26 05:04 UTC · original
@desplmfao answers in order:
ab2b7ef, so the 4 MiB loose windows were the default and the 256 KiB windows aren't the cause.mainmerged withab2b7ef(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,diagnosticsbuild, same save, ~3 min each into the world. The cost is the same without #2870.copystatand refusals, three consecutive 5 s lines each:VICTORY_IN_PLACEunsetVICTORY_IN_PLACE=1The only
in placerefusal line in the whole run istitle 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)
@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 throughwatch::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.29decb3addswatch::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::andwatch::give 40 passed under Wine, includingwrites_in_place_mark_other_copies_of_the_page_changed, and clippy is clean.If you can, the same A/B on
29decb3would 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.@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, driver32.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), includingcommitted_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, andstale_queue_does_not_evict_replacement_heap_at_same_base.Live Title Run (
VICTORY_IN_PLACE=1, default1 MiBmin)main63bcca4+#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(noxmem.rschanges). ComparingVICTORY_IN_PLACEunset (0 crashes across 65 world frames) vs.VICTORY_IN_PLACE=1on the same tree:0xc0000005in title) preceded by 21×xmemos error 487:VICTORY_IN_PLACEunset): 0xmemremap warnings.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).OpenExistingHeapFromAddress1pins the virtual pages until the underlyingID3D12Heapand placedID3D12ResourceCOM objects are actually destroyed.title_memory_remapped()removes entries fromBUFFERS/LOOSE, but either a recordedHostList(keep_in_place) or an in-flight/retired resource still sitting inRETIREDwaiting on a GPU fence keeps those COM objects alive whenxmemcallsUnmapViewOfFile2(..., 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.29decb3:preparing: copiesjumped from ~468 MB to 2,295–3,478 MB/frame (local profiler stage timers:deferred1,455–2,490 ms,flush2,366–3,840 ms, post-copy-backaftercoveringcheck_in_place123–156 ms; total 4,683–7,081 ms/frame). Even without opening guards or saving bytes inwatch::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.
@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 failedcargo clippy -p victory-gpu --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean opt-in
VICTORY_IN_PLACE=1loose title-memory mapping with remap tracking and solidshadow::test coverage. Looks good.AI-assisted (Gemini 4 Neon).
@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.
@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_placeno-ops the whole copy pipeline (refresh/gpu_writes/writing/copy_back*/update) except two deliberate paths:keep_in_placeretains the placed buffer — hence its heap, hence the pinned pages — for any list whose commands name the GPU address, andlandedmarks title pages changed so other shadows (sub-floor buffers, view copies, textures) refresh from memory the shaders wrote in place.memory::bindcallslandedon 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 andlo <= address && end <= higuard 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 viaOpenExistingHeapFromAddress1keep heap lifetime bound to the placed buffer, whole-allocation path goes through the cache with extent staleness + thedense()working-set gate (64Ki-page sampling, 10 s cache, 90 % default — the GTA6-on-Linux measurement justifies it).check_in_placeonce 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 andkeep_in_placeuses the buffer pointer — no aliasing.in_place_remappedhook ontitle_memory_remappedcloses the runtime-map/unmap hole;pin_heap(from #2945) closes the title-side free/protect one — the two halves compose correctly.Noting scope: this reviews #2112's own commits; the 256 KiB loose-window lookup rework is #2088's.
@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
71cae091bin GE-Proton11-14, this PR merged ontomain219878aplus our Linuxcommits,
diagbuild, start from a save in the prison.VICTORY_IN_PLACEab2b7efab2b7ef129decb329decb31All four in-place runs end the same way, with no GPU fault and no reset in the kernel log:
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):
amdgpu_create_bo_from_user_mem, which always asks forAMDGPU_GEM_USERPTR_ANONONLY | AMDGPU_GEM_USERPTR_REGISTER | AMDGPU_GEM_USERPTR_VALIDATE(amdgpu_bo.c).
ANONONLY,amdgpu_ttm_tt_get_user_pagesreturns-EPERMwhen the range is file-backed or does not lieinside a single VMA (amdgpu_ttm.c).
That check runs at import and again when a submission revalidates the pages after they changed.
mprotectof a single page splits the VMA. vkd3d-proton imports the whole allocation (the PR notesthis), so one page guarded anywhere in it (a buffer under
VICTORY_IN_PLACE_MIN_KBthat keeps its copy and itsguard, or another copy's tracker) leaves the imported range across several VMAs. Memory mapped as a section view is
file-backed under Wine, which
ANONONLYrefuses 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.
@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
29decb3merged ontomain63bcca4,cargo test -p victory-gpu --lib --locked -- --test-threads=1. No game files.mainalso has on this card (#1835).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. SoOpenExistingHeapFromAddressover 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)
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.