Skip to content

GPU: page view heaps a host caps below the slots shaders index - #2121

Open
0xkn0wh3r3 wants to merge 16 commits into
Marvisak:mainfrom
0xkn0wh3r3:gpu/view-heap-pages
Open

0xkn0wh3r3 wants to merge 16 commits into
Marvisak:mainfrom
0xkn0wh3r3:gpu/view-heap-pages

Conversation

@0xkn0wh3r3

@0xkn0wh3r3 0xkn0wh3r3 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Towards #1835, #1808 and #1760.

The problem

On NVIDIA, views the title puts in the upper part of its descriptor heap read null. Issue reports put 61,000 to 173,000 live slots past the cap in the world (#1760), and two view-heap unit tests failed on NVIDIA (#1835).

The mechanism: NVIDIA takes shader-visible view heaps of at most 1,000,000 descriptors. The title lays out 1,245,184 slots, and translated shaders index up to HEAP_VIEWS (2^21). The host heap holds title slot i at host slot i, so the capped heap kept 934,464 title slots and left the rest out ("title slot past the host heap").

slots
NVIDIA's cap on a shader-visible view heap 1,000,000
title's heap 1,245,184
indices translated shaders take (HEAP_VIEWS) 2^21
title slots the capped heap kept on main 934,464

The fix

A host that refuses a view heap of every index shaders take plus the dynamic slots (descriptor::host::view_pages, asked once; set VICTORY_VIEW_PAGES=1 to page on any host) keeps the title's order in a virtual heap of 256-slot pages:

  • The host heap is 1,000,000 slots. Host page 0 stays null (where pages with no place read). Page 1 takes writes once there is no room left. The dynamic slots' pages are placed together after them (tables of them are bound as host ranges).
  • Placement: any other page is placed in turn when a slot of it is first written, and entered in the page table: a dword per page past the view-stride table (VIEW_PAGE_TABLE), which shaders already have bound. A null made in a page with no place takes none.
  • Shaders: translated shaders take each view heap index through the table when Options::view_pages is set (Shader::heap_handle: per handle, one table load plus a shift, a multiply and an add to address it and a shift, an and and an or to place the slot; samplers are not paged). The host sets it where it pages (shader_cache::options), and the shader cache key carries it, so a host that does not page translates as before.
  • Draws bind the stride (and page) table of whichever view heap they bind: the title's, else our own (as write marks already do). Before, the stride table was taken from the title's heap only.

Limits:

  • The host has 3,906 pages, of which 1,026 are fixed (null, scratch, dynamic): 2,880 for the title's 4,864 virtual pages, that is 737,280 slots at a time.
  • When they run out and nothing can be taken back (below), further pages read null with a warning. The pages in use are logged at each power of two.
  • A title heap whose slots plus the 2^18 dynamic slots would reach the null buffer views at HEAP_VIEWS - 2 is capped at PAGED_TITLE_VIEWS (NULL_BUFFER_VIEW - 1 - DYNAMIC, 1,835,005 title slots), with the warning paged view heap capped at ... title slots, as the unpaged heap is capped at the host's limit. Title slots past it are left out ("title slot past the host heap"). The title's 1,245,184 slots are well below it.

Reclaiming pages

In-world runs on an RTX 4090 and 5080 filled all 3,906 host pages within minutes. At the overflow, "view heap pages written with no room left" reached pages=1024 with about 231,000 slots written, about 226 of 256 a page, so smaller pages would not fit more. The title writes fresh descriptors over most of its 1,245,184 slots during a run, and placing on first write without ever giving back runs out. Pages not used lately are now taken back.

  • Use. Each virtual page has a last-used stamp (submissions run). A page is used when a slot of it is written, when HostHeap::gpu hands out a handle in it, when a draw binds a slot of it through a table, and when its read mark comes in.
  • Page read marks (shaders). With view pages and marks, every instruction that reads or writes through a view taken from the heap (the heap itself or a table) sets bit VIEW_PAGE_READS + page (VIEW_PAGE_READS = VIEW_READS + HEAP_VIEWS) in the view-writes bitmap, where it is still clear. That is one load, a test and a branch per page and console block (about 10 instructions, the atomic only the first time in a submission). A handle first used inside guarded code that an instruction made is marked there, with the atomic alone. The host bitmap grows by 8,192 bits, and shadow::take_page_reads takes and clears the marks of both bitmaps after each submission. The shader cache key changes with the translator's sources.
  • When. Between submissions (the GPU idle), after the read marks are taken: if fewer than 1/32 of the host pages are free (the free list plus pages never given out), pages are taken back until 1/16 are free, least recently used first. Only pages unused for at least 300 submissions and 10 s qualify (the strict ages). If a write, or a page read again, found no host page since the last pass, that one pass also takes pages unused for more than 32 submissions, with no time minimum, still least recently used first and up to the same mark, so pages old by the strict ages go first (979e3a7, suggested by @kawaii-shakal). 32 is more than a frame's submissions, so pages read every frame stay. Otherwise the strict ages alone apply. Only pages placed on a write that hold title slots only can be taken back. The dynamic slots' pages and the host's own pair and null-view pages never are.
  • Taking back. The page table entry goes to the null page. What the slots viewed is retired (released after the submission, as for any rewritten slot), their write marks are cleared, their read marks are forgotten (a shader's next read of a slot is taken again; a mark cleared so still counts as a read for eviction, since marks are by slot and another heap may have read it), and null views are copied over the host page before it goes on the free list. A heap whose page of null views could not be made takes no page back. Writes take pages from the free list before pages never given out. Slot records stay noted, so heap syncs (which walk every slot of a 64 KiB title page with a write in it) don't re-place the page because a neighbour was written.
  • Placing again. A taken-back page gets a place again when the title changes a record in it, when a draw binds any slot of it, or when its read mark comes in after a submission. In each case its slots are made from the title's records before the next submission, or made null where the title no longer holds a view; slots already made in the page since it was placed (a texture made for the draw) keep their views. After a submission, pages are turned before the textures read are made, so a placed texture read in a page placed again is made there for the next submission; one whose view went to the scratch page (no room) has its read taken again. A page written while there was no room is handled the same way once it gets a place. So a wrong guess costs one submission of null reads, not the rest of the session.
  • Logs (info, at power-of-two totals): view heap pages unused lately taken back (pages, total, free, in_use, and relaxed (whether that pass took pages younger than the strict ages) with relaxed_total) and view heap pages placed again (pages, taken_back, refused, in_use). The placed-again line keeps two counts apart (6f8b588): taken_back is pages taken back by reclaiming and then read, written or drawn through (a wrong guess); refused is pages written when no host page was free that got a place later. A page taken back and then written with no room counts under taken_back. pages is their sum, and the line is logged where either count reaches a power of two. host view heap pages in use, no room left in the host view heap and view heap pages written with no room left keep their meaning: the last two now appear only if nothing old enough can be taken back, and a refusal makes the next pass relaxed. view heap dynamic slots in use (248e4c3, on paged and unpaged hosts) gives peak, the most dynamic slots taken at once since the heap was made, of, the heap's dynamic slots (262,144 = 1,024 host pages on a paged host), and run, the longest run of them a table asked for; it is logged where peak or run reaches a power of two. It measures whether the dynamic region could be smaller on paged hosts to leave the title more of the 3,906 host pages.
  • Shortcut (// shortcut: in take_back_pages): a handle from gpu() for a slot of a page placed on a write, recorded into a list that stays unsubmitted longer than pages are kept unused (32 submissions once a write found no room), would read whatever that host page holds by then. Lists bind title slots through the page table, and gpu() stamps the page. No list of ours bakes a title slot's handle today: the unordered access clear uses a dynamic slot.

The page code moves to descriptor/pages.rs.

Testing

Review fixes (0bc5edb), the full heap and the eviction window (found by @passerbyyhx):

  • draw::tests::a_placed_texture_read_with_no_page_free_is_made_after_one_submission (GPU, through Host::execute): no host page free; page 3's placed texture was taken back and page 2 took its host page since. A shader reads the texture in four submissions: page 2 is taken back in the first pass and page 3 placed in the same host page. Per submission, (texture held, buffer view in the page held): [(true, true); 4], a placed texture not read stays unmade. At fedb38d: [(false, true), (true, true), (true, true), (true, true)], the texture held a submission after its neighbour.
  • draw::tests::a_placed_texture_read_with_no_room_before_is_made_after_one_submission: the texture was read once while its page found no room (made in the scratch page), then read again in four submissions once another page is old enough: [true; 4]. At fedb38d: [false; 4] (its read was already taken, and nothing pressed for room). With the reorder and the read pressure but without re-taking its read: [false, true, true, true].
  • descriptor::pages::tests::a_page_read_again_with_no_room_presses_the_next_pass (no GPU): with no host page free and none old by the strict ages, a pass takes nothing; after a read of a taken-back page, the next pass takes back the page unused longest and the page read is placed in its host page.
  • draw::tests::a_page_taken_back_keeps_another_heaps_read_of_its_slot_for_eviction: two paged heaps with placed textures at the same slot, the second's read (and slot 7's) marked; the first takes back the page with its own record there. reads_since returns both slots and names the second heap's texture. At fedb38d: [7].
  • cargo test -p victory-gpu --lib: 254 passed, 0 failed, 1 ignored (this NVIDIA host pages view heaps). With --features diagnostics: 268 passed; pipeline::placed_uav_tests::placed_uav_dispatch_writes_its_texture fails, as at fedb38d. Clippy with and without --features diagnostics: 0 warnings. cargo xtask policy ok.

Review fixes (fedb38d):

  • draw::tests::a_placed_texture_in_a_page_taken_back_is_made_after_one_submission_reads_it (GPU, through Host::execute): a compute shader sets the slot's and page's read marks in each submission. After the page is taken back, the slot holds its texture again after the first submission that reads it. Before: [false, false, true, true] over four submissions.
  • host::tests::view_heap_pages_placed_by_a_read_keep_the_texture_made_for_it: make_read then turn_pages (the order Host::execute had at fedb38d; a texture made for a draw before the heap sync is in the same place). Before, the remake nulled the texture make_read had just made.
  • host::tests::view_heap_pages_taken_back_make_their_buffer_views_again: a constant buffer, a buffer SRV and a buffer UAV in a page taken back are made again when a read mark places the page (this passed before too), and a draw binding one of them places the page at once (before: it stayed unplaced).
  • host::tests::view_heap_slots_written_with_no_room_are_made_when_their_page_is_placed: a view written to the scratch page holds nothing and is made once its page is placed.
  • cargo test -p victory-gpu --lib: 250 passed, 0 failed, 1 ignored (RTX 5070 Ti, which pages). With --features diagnostics: 263 passed; frame::tests::waits_end_on_ticks_and_count_frames (flaky) and pipeline::placed_uav_tests::placed_uav_dispatch_writes_its_texture fail, and both fail at c23f708 too. Clippy with and without --features diagnostics: 0 warnings. cargo xtask policy ok.

The paged title-heap cap (07a132db):

  • host::tests::a_paged_heap_of_every_slot_shaders_index_is_capped (GPU, paged host): a title heap of HEAP_VIEWS slots is capped at PAGED_TITLE_VIEWS. The first title-or-dynamic page, the last dynamic slot and both null buffer views have their pages placed in the page table, within its 8,192 entries. All dynamic slots can be taken, and a title slot past the cap has no mirror. Without the cap the same test panics in HostHeap::new (index out of bounds: the len is 8192 but the index is 8192, the dynamic slots' pages past the page table).
  • cargo test -p victory-gpu --lib: 241 passed (at 6f8b588), 0 failed, 1 ignored, both with and without VICTORY_VIEW_PAGES=1. At 979e3a7: 244 passed, 1 ignored with VICTORY_VIEW_PAGES=1; without it, 243 passed and views_bound_while_another_slot_gets_its_texture_do_not_wait failed, which fails on main on this card too. Clippy with and without --features diagnostics: 0 warnings. cargo xtask policy ok.

The dynamic-slot peak (248e4c3):

  • host::tests::the_dynamic_peak_follows_takes_and_releases (GPU): three runs taken (10, 30, 20) give a peak of 60; giving back the 30 leaves 30 in use and the peak at 60, and giving them back again changes nothing; taking 25 leaves the peak at 60, then 15 more raises it to 70. The longest run asked for is 30, then the whole region once a request for all of it fails. dynamic_powers_of_two_are_passed_once checks when the line is logged.
  • cargo test -p victory-gpu --lib: 246 passed, 0 failed, 1 ignored, both with and without VICTORY_VIEW_PAGES=1. Clippy with and without --features diagnostics: 0 warnings. cargo xtask policy ok.

Reclaiming (cae596c, a12b972), on an NVIDIA card that pages automatically, and with VICTORY_VIEW_PAGES=1:

  • descriptor::pages unit tests (no GPU):
    • pages unused past the age are taken back oldest first, down to the high-water mark, and only once they are old by both counts;
    • the dynamic pages and the host's own pages never are;
    • a taken-back page's table entry is null and its host page goes to the next page written;
    • recently used pages stay (written, read mark, gpu() handle, draw stamp);
    • taken-back pages read or written are placed again and queued to be remade;
    • a page refused room is placed and remade once there is room;
    • the two placed-again counts move only for their own case: taken-back pages placed again count under taken_back only, pages refused room and placed later under refused only, and a page taken back then refused room under taken_back (6f8b588);
    • under pressure (979e3a7): with no refused write, pages younger than the strict ages stay however few host pages are free; after one, pages unused for more than 32 submissions are taken back oldest first up to the high-water mark though younger than 10 s, while a page used exactly 32 submissions before and one used now stay; a refusal relaxes one pass only, including a pass that had room enough.
  • host::tests::view_heap_pages_taken_back_are_placed_again_when_read (GPU, real paged host heap): a placed texture's slot in page 1 is taken back (table entry null, slot holds nothing, record still noted, a heap sync leaves it). Its page read mark through take_page_reads and turn_pages places it again with the slot made from the title's record, and a read of the slot then makes its texture.
  • emit::stride_tests::views_read_in_a_paged_view_heap_mark_their_pages (hardware and WARP): a program translated with pages and marks reads virtual slot 1,099,777 and writes its table's UAV at slot 0. Exactly bits VIEW_PAGE_READS + 4296 and VIEW_PAGE_READS + 0 are set.
  • cargo test -p victory-gpu --lib: 203 passed, 0 failed, both with and without VICTORY_VIEW_PAGES=1. cargo test -p victory-shader --lib: all pass except a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware, as before. dxil.dll isn't installed here, so the new DXIL was checked by pipeline creation on hardware and WARP, not by the validator.
  • Clippy with and without --features diagnostics: 0 warnings. cargo xtask policy ok.

Earlier:

  • New test descriptor::host::tests::pages_are_placed_once_on_first_write: page placement, its table entries, reads placing none, running out.
  • New test emit::stride_tests::a_heap_index_in_a_paged_view_heap_reads_where_its_page_is: a program translated with pages reads its buffer at virtual slot 1,099,777 through the table exactly as the plain program reads slot 1, on an RTX 5070 Ti (driver 621.24) and WARP.
  • On the RTX 5070 Ti, which pages, dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views now pass (both fail on main there).
  • Upstream's memory::tests::a_submission_that_missed_leaves_the_copies_at_once is paged the same way: its WRITE shader looks its slot up in the page table, and its root layout binds the whole host heap and the view-stride table.
  • emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros now passes on NVIDIA too. The shader test host made a 2^21-slot heap for its null buffer views, which the driver refuses. It now pages them where the device caps the heap, and the test translates with view pages there (Host::null_buffer_page, second commit).
  • cargo test -p victory-gpu and -p victory-shader: all pass on the RTX 5070 Ti except emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride and emit::synthetic_tests::gathers_at_a_level_match_the_hardware, which fail on main there too (the test host's structured views, Shader tests: the test host's structured buffer views are raw (#1835) #1887).

Not verified

  • No title run here with reclaiming. kawaii-shakal's run (RTX 5070 Ti, 0.5–2 fps, about 20 submissions a frame, with GPU: title threads recording lists no longer wait on descriptor and buffer-copy locks #2821) still ran out of host pages about 2 minutes in under the strict ages alone. Their version of the relaxed pass (16 submissions) cut pages written with no room from ≥2048 to ≥512 over similar runs. 979e3a7 (32 submissions) has not been measured in the title yet. Whether the pages a world uses at once fit in 2,880 host pages, and how often a taken-back page is read again, is what view heap pages unused lately taken back, view heap pages placed again (its taken_back= against its refused=) and (if it still appears) no room left in the host view heap will show. Whether the dynamic region can be smaller on paged hosts is what the largest peak= of view heap dynamic slots in use in a title run will show.

Related: how this differs from the open heap PRs

#1751, #1133, #1548, #1777, #1779 and #1349 change how the capped heap is laid out or clamp indices past the cap. None maps title slots past it to host slots, so 300,000+ title slots still have no descriptor under each (measured in #1760). This one keeps every title slot addressable, as long as the pages the title uses within about 10 s and 300 submissions (32 submissions once room runs out) fit in 2,880 host pages (737,280 slots). Older pages are taken back and placed again when used.

Rebased onto 13f91ca

  • Upstream 850b66f makes heap handles per descriptor at a fixed address and per join. All of those paths go through Shader::heap_handle, so they are paged too.
  • Upstream's test a_submission_that_missed_leaves_the_copies_at_once is adjusted for paging, as described under Testing.

Rebased onto 842b0cb

  • Upstream GPU: view addresses for tables made afresh (dynamic slots) #1906 (2bba792) gives the view addresses an entry per dynamic slot. Those entries are indexed by virtual slot, so paging leaves them as they are. Its test view_addresses_cover_tables_made_afresh sits next to the paging tests in descriptor/host.rs (the paging tests move to descriptor/pages.rs in the last commit, as before). It passes on the RTX 5070 Ti, which pages.
  • Upstream's test compute_view_marks_rebind_after_depth_twin_conversion (GPU: rebind compute view-mark root descriptors after depth-twin conversion #2155) translates with shader_cache::options(), which is how the runtime translates, instead of building Options itself. Options now has the view_pages field.
  • No other conflicts. lower.rs is still under the 512 KiB policy limit.

Rebased onto 63bcca4

  • Upstream's only new commit changes README.md. No conflicts.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • cargo test -p victory-gpu — 144 passed, 0 failed (2 ignored) on NVIDIA RTX 5090! Directly resolves both NVIDIA 1M view-heap cap failures (dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views) on main 940d32f!
  • cargo test -p victory-shader --lib emit::stride_tests:: — 6 passed, 1 failed (directly fixes a_heap_buffer_read_where_no_buffer_view_is_reads_zeros on RTX 5090; the 1 remaining failure, a_heap_buffer_read_by_element_takes_the_views_stride, is the separate NVIDIA structured-view issue covered by #1887)
  • cargo clippy -p victory-gpu -p victory-shader -p victory --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Huge NVIDIA/Blackwell compatibility win. Looks great!

AI-assisted (Gemini 4 Neon).

@yualk

yualk commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent owned texture check at 442632413ce4 on Windows RTX 5070 Ti (10de:2c05, driver 610.88, auto-paged) and explicit WARP (1414:008c, forced paging). Used the real HostHeap::new(false, 1245184) with a 1,000,000-slot physical heap, and its normal cpu(index) page allocator/write destination. Two same-shaped RGBA8 textures with distinct bit patterns occupied virtual slots 17 and 1,126,417 (same in-page offset). A DXC 6.6 shader read the actual upload-backed page table and echoed the chosen physical slots plus sampled texels in each fence-completed arm. The upper slot returned the correct typed null until publication, then its own texel cb683b2e, with low 617fa5c3 unchanged. After reducing the allocator's remaining capacity to zero (only in the fixture), a real third texture descriptor write went to scratch and the third virtual slot still read zero; neither admitted neighbor changed. This check doesn't fill a title's real page capacity and doesn't measure title frames or use translated shader code.

One source-level failure case: the stride upload returns None on Create/Map failure, but paged initialization substitutes zero for the base and writes at VIEW_PAGE_TABLE. Could reject a paged heap with no mapped stride/page table before publishing its GPU range. I did not induce OOM. Also, the unplaced page is filled with a Texture2D null; my test deliberately used that dimension and doesn't establish safe null fallbacks for other resource kinds (D3D12 null descriptor rules). AI-assisted; no title data or captures used.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

View heaps paged when a host caps below shader-indexed slots — paging for capped heaps; mixed gpu+shader+apps, Windows-only overall.

RecompLive added a commit to RecompLive/victory-fork that referenced this pull request Nov 25, 2026
Ported Marvisak/VIctory#2121 (GPL-3.0-or-later), commits fb770da and
4426324. A host that refuses a view heap of every index shaders take
(NVIDIA takes 1,000,000 slots; the title lays out 1,245,184 and shaders
index up to HEAP_VIEWS = 2^21) now keeps the title's order in a virtual
heap of 256-slot pages:

- each page the title first writes is placed in the host heap and entered
  in a page table past the view-stride table, which shaders already bind;
- translated shaders take every view heap index through that table when
  `Options::view_pages` is set; the cache key carries it;
- draws bind the stride (and page) table of the heap they bind.

Our earlier host-cap clamp is kept: `probe_view_count` still sets the
non-paged clamp, and a paged heap clamps at HEAP_VIEWS before the page
lookup. The test host pages its null buffer views where the device caps
the heap (`Host::null_buffer_page`).

Adaptation: the PR's two hardware tests assert a device exists; here they
skip as every other hardware test does, because this PC has no SM 6.6
device. No game run: the page-count log lines are the check on a title.
@fiestorra

Copy link
Copy Markdown
Contributor

Measured on the card the cap affects: the slots past the heap go from 310,720 to zero, and the cap line disappears

I ran this branch on the machine where the problem reproduces — RTX 4090, driver 32.0.16.2124, session 1, release build, empty cache, 70 s, no other pull request applied:

title slot past the host heap      0        (main: 310,720)
host view heap capped              0        (main: 1)
device removed                     2
no host texture … 2560x1440 …      1
dropping unordered access          0
frame=64 draws=96

So both symptoms the description is about are gone here: no slot is left outside the host heap, and the "capped" line does not appear at all — the heap is not capped from the title's point of view, which is a stronger result than the fix I had measured before (#1779 took the same 310,720 to 0 but still logged the cap).

The remaining lines are the ones this pull request is not about, and I would keep them out of the review: the device removal and the missing 1440p B5G5R5A1_UNORM/format-115 texture are the format ground (#1630 and #1832). Worth knowing when someone measures this branch: on main they hide its value, because the boot dies at frame 64 regardless. With those two applied, the boot reaches 2,048 frames and 13,312 draws in 120 s — which is where this change's effect on the world would actually be visible, and where I would look next.

A few things I checked that are not in the diff:

  • it merges cleanly with the two open changes that touch the same emitter files (Shaders: a vertex shader that declares a UAV says so in its flags and SFI0 (fixes #1987) #2016, the vertex UAV flag; Shaders: a compute shader samples at level 0, not with derivatives (735 programs) #2027, sampling in compute) — I merged both orders, they apply and build. That matters because this change adds to emit/host.rs, emit/mod.rs and emit/shader.rs, which is the same corner, and a conflict there would be a reason to sequence the three.
  • the fixed 256-slot page and the emitter's baked page maths are the risk I would want stated: an index computed a page wrong reads null silently, and the symptom of a wrong page is "some views read zero", which is exactly what the cap looked like before. If there is a log line or counter that says the heap is paged (and how many pages are placed), it did not appear at info on this run — view pages was 0 matches. I would ask for one: it is the difference between "we think it paged" and "the log said so", and this week has shown how much a missing line costs.

What I have not reviewed: the 212 lines of descriptor/host.rs and the paging algebra itself, in any depth. I measured the outcome; the reasoning inside would take a session of its own, and the outcome is the part I can be sure of here.

No game data is involved: counts from the title's own log.

Written with an AI assistant.

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks both, this is very useful.

@yualk: the missing-buffer case was real. In 907922c, when the stride buffer can't be made, a paged heap is now refused with a warning before its GPU range is recorded. Before, it wrote the page table relative to address 0. On the null descriptors: unplaced pages read slots filled with a Texture2D null. That's the same as every unwritten slot on main today (fill_null), so this PR doesn't change it. Matching the null to the kind a shader reads would be a separate change, and I'd keep it out of this one.

@fiestorra: thanks for the 4090 run, and for checking the merges with #2016 and #2027. The probe's line (host view heaps, paged=true) can come before logging is set up, which is probably why nothing matched. 907922c adds a line when the title's heap is made: view heap paged: the host caps view heaps, title slots are placed by page, with slots, host_slots, pages and fixed. After that, host view heap pages in use logs the count at each power of two, and no room left in the host view heap warns if pages run out. A run with #1630 and #1832 applied should show whether the world's pages fit.

@iGoldenNinja

iGoldenNinja commented Nov 25, 2026 •

Copy link
Copy Markdown

Independent RTX 5080 hardware check. Driver 617.14, Windows 11 Pro 25H2 build 26200.9974, Ryzen 9 5900X, Rust 1.98.1 MSVC, DXIL 1.9.2609.5, diag, paging and WARP overrides unset.

On clean main 940d32f69b22265690a0b5a15d6ded572ba33baf, dynamic_slots_are_held_until_released failed the NumDescriptors >= HEAP_VIEWS assertion. On clean PR head 442632413ce4e8b081b8c4ae4174a51a3682e7f4 it passed, along with pages_are_placed_once_on_first_write, the high-virtual-slot translated shader read on hardware and WARP, and the null buffer read. In total, 4 passed, 0 failed or ignored on the PR. These were synthetic fixtures.

Test commands and per-fixture outcomes

OpenAI Codex (GPT-6) ran the tests and drafted this report.

Title replay follow-up on RTX 5080 / 617.14 and Windows 11 26200.9974. I adapted 907922c onto the NVIDIA fork's 7e7bb18 diagnostics build with the previous integer-blend and descriptor-read fixes. The local port binds the page table through its own root view to preserve that fork's buffer refresh behavior.

The 1,245,184-slot title heap used 1,000,000 physical slots and logged pages=3906 fixed=1026. The available 2,880 title pages filled during world loading, 150.5 s after player selection, followed by the heap-exhaustion warning. The port retains allocated pages for the heap lifetime. This observes saturation on this fork and route.

It reached player control in the prison. The five-minute replay averaged 4.007 presented FPS, 658.550 ms P99, compared with 4.543 FPS and 435.072 ms on the unpaged control. Ten of 54 host samples still reported pending pipelines on the paged run. Wall and ceiling gaps persisted. The run ended deliberately with no DRED device removal logged.

Reproduction, capacity math and timing split

@JurajSimicevic

JurajSimicevic commented Nov 25, 2026 •

Copy link
Copy Markdown

On main 940d32f (RTX 5080) the pages also fill as the world loads; afterwards the device was removed within 1-3 minutes in both runs

Following @iGoldenNinja's fork replay above, the same on upstream main with no fork. RTX 5080, driver 32.0.16.1742, Windows 11 26200, diag build, VICTORY_D3D12_DRED=1, shader cache and pipeline library made first. Base: 940d32f + #1775's typed-UAV check (to boot, #1753) + #1762 + this PR at 907922c. The second run adds #1906 (astrosteveo's rebase 01ba70d) and #2098. Nothing skipped. One run each.

base + #1906 + #2098
pages in use 2,049 before the world; all 3,906 two seconds into it, then "no room left in the host view heap" the same: 2,049, then all 3,906 three seconds before the first world frame
title slot past the host heap, draws dropped for dynamic slots 0, 0 0, 0
end 0x887A0006 188 s into the world; DRED stops at #1968's program C (the one #984 addresses) 0x887A0006 70 s into the world; DRED stops at a mesh program's indirect draw
#1968's program A runs for the 3 minutes, never in a slow submission runs, never in a slow submission

No game data attached: counters, timings and log warnings only.

AI-assisted (Claude Code).

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks both, this is the measurement the PR needed.

What I take from it:

Whether a different page size helps depends on how full the placed pages are. If most placed pages hold only a few written slots, smaller pages (64 slots) would fit far more of the title. If they're mostly full, the title really writes more than about 740k distinct descriptors, and the next step is reclaiming pages, or growing the title's share at the dynamic region's expense, not resizing them. I'd rather measure than guess. c5d33e8 adds that count: host view heap pages in use and the no room left warning now carry written (slots written in pages placed on a write) and of / of_slots (slots in those pages). A new view heap pages written with no room left log counts the pages and slots that missed out. If either of you can run it again, the ratio at the warning settles it in one run.

On the removals: in the first run DRED stops at #1968's program C, which #984 addresses. In the second it stops at a mesh program's indirect draw. Neither points at a null descriptor read; a null SRV/UAV reads zeros and drops writes. With one run each, though, I agree it can't be ruled out yet.

Thanks for the conflict notes with #1762, #1906 and #2098. I'll resolve them in whichever order those land.

@GaussianGuaicai

Copy link
Copy Markdown
Contributor

Independent title smoke test on a Windows Hyper-V guest with an RTX 5070 Ti, using diagnostic builds, the same save snapshot and input, and separate cold caches:

  • Baseline 940d32f: Only frame 1 was logged before the 110 s watchdog. The run emitted 262,329 title slot past the host heap warnings.
  • Paging build 907922c: Paging activated automatically for the 1,245,184-slot title heap on the 1,000,000-slot host heap. I saw zero instances of that warning. The page-use log reported 2049 of 3906, and no page exhaustion was logged before exit. The run reached at least frame 1625, then exited on D3D12 device removal.

Separately, I compared unmodified 907922c with the same revision plus a local workaround excluding the R32_UINT to R9G9B9E5_SHAREDEXP cast. With matched debug-layer and capture settings, the unmodified build reproduced the rejected SRV and device removal. The workaround build reached the first detected world frame and ran until the watchdog without either error in that run, but the captured final image remained dark. The format workaround is not part of this PR.

This confirms automatic paging and provides one in-game page-use sample. It does not establish long-run page capacity, playable rendering, or a performance gain.

Test report prepared with assistance from GitHub Copilot.

@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 40bd210 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Needs work: needs the maintainer's decision. Reviewed head c23f708. Three small commits since 248e4c3:

  • c1d5a3a gives a paged heap MIN_DYNAMIC (65,536) dynamic slots instead of DYNAMIC (HostHeap::new, descriptor/host.rs). PAGED_TITLE_VIEWS follows, which leaves 3,648 host pages for title slots. latentdev's RTX 4090 peak (16,384 to 32,767) still fits.
  • c2e5ebc adds VICTORY_VIEW_PAGES_KEEP=1 (diagnostics builds only), which skips Pages::take_back.
  • c23f708 makes the shared-table test use dynamic_end().

The logic reads correctly. passerbyyhx's fixture checked page reuse on hardware.

The open question is the new in-game evidence. bittertea0323's A/B on 248e4c3 shows the paged tree drawing the world black where an un-paged tree draws it, and pages are taken back inside the frame loop. Whether c23f708 fixes that needs the run you proposed (defaults and KEEP=1, to the first world frame). Beyond that, a maintainer still has to decide whether to take paging at all. It changes translated shaders and the shader cache key, and it competes with #1751, #1777 and #2461. The HostHeap::mirror clash with #2821 also remains.

CI: passing.


Generated by Claude Code

@crissuper20

Copy link
Copy Markdown

GTX 1650 (Turing, 4 GB, driver 32.0.16.2124), diag build, Series S, 940d32f + #2016 #1775 #454 #1731, with and without this PR at 40bd210, 18 min each, same save and input:

without with
paging no on automatically (paged=true)
title slot past the host heap 310,720 0
reaches the world yes yes
device removed (~11 min in the world) no no

So on Turing there's no device removal in the world, unlike the 5080 report above. The world image is black on this card with or without the PR. One run each.

AI-assisted (Claude Code); measured on my own machine.

@sinan-cmyk

Copy link
Copy Markdown

Shader tests on NVIDIA Ada

I ran cargo test --locked -p victory-shader --lib on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, VICTORY_WARP unset.

Build Passed Failed
main 940d32f 244 3: stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware
this PR (head 40bd210) merged onto 940d32f 246 2: a_heap_buffer_read_by_element_takes_the_views_stride, gathers_at_a_level_match_the_hardware

So on Ada this PR fixes a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, one of the three NVIDIA failures that #1835 tracks. #2177 fixes the same test, and #2178 fixes the stride one (details in #1835).

Offline, on the retail dump, this PR does not change the counts (posted above).

AI-assisted (Claude Code).

@passerbyyhx

Copy link
Copy Markdown

Tested the 65,536-slot dynamic region on Windows with an RTX 4090 Laptop (driver 621.14). On c23f7085, both title heap layouts completed A → B → A on physical slot 66,311 (page 259, offset 7), using synthetic textures and the runtime D3D12 queue.

Title slots Allocatable physical pages Physical slot of the blue control
1,048,576 3,648 519
2,031,613 (new cap) 3,647 772

The unaligned cap costs one additional fixed page. In both layouts, the old submission read red / transparent black / blue (A / B / control) after its fence completed. On each transfer the first demand read transparent black. After retry, B read green from slot 66,311. When A got that same slot back, it read red. The control stayed blue throughout.

Both the short pressure window (fence 32 → 33) and the strict window (301 → 302) passed. With VICTORY_VIEW_PAGES_KEEP=1, renewed pressure and strict aging both left A red and B unmapped, with zero pages reclaimed or restored. I also repeated the short-window round trip on the integrated demo 11a24276 with #2821 and #3052. Both layouts gave the same slot and colors. This covers descriptor reuse on this device. Whether 3,648 pages hold the world’s live set still needs the in-game measurement.

Fixture on the PR head · Fixture on the integrated demo

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks, this checks the reuse path on c23f708 directly: the old submission keeps its colors after the take-back, the page goes back and forth on one host page, and VICTORY_VIEW_PAGES_KEEP=1 leaves everything placed.

On the extra fixed page at the cap: it only costs anything for a title whose slot count isn't a multiple of 256. This title's 1,245,184 slots are exactly 4,864 pages, so its dynamic range starts on a page boundary and it gets all 3,648. I've left the cap as it is.

@bittertea0323

Copy link
Copy Markdown

A/B on the same machine, same title, same Agility opt-in: the un-paged tree draws the world and the paged one draws black

I built a control to answer the one thing my earlier comments could not: is the black screen the take-back, or something this tree cannot fix anyway (ray-tracing structures never built, dropped draws, untranslated shaders)? Yesterday I assumed the latter and said so in #1627. That was wrong, and here is the measurement that shows it.

The two builds

Both on this host (RTX 4070 SUPER 12 GB, driver 591.74, Windows 10.0.19045), same retail title build 7952987A, Xbox Series X, both with the Agility SDK export and D3D12Core.dll beside the exe (nothing heap-indexed gets a root signature on Windows 10 without it):

build view heap first world frame reached draws/frame ms/frame picture
try/wave64 (fork, pre-bindless) not paged, no heap-indexing shaders ~50 s after the last keypress 2,260 1,567 correct
248e4c3 + 2e0ea66 (this PR + Agility) paged, slots=1245184 host_slots=1000000 pages=3906 fixed=1026 same point in the title 3,510 ~9,000 black

The un-paged tree renders the title's opening caption card correctly — two lines of large type and the localized subtitle underneath, both legible, both in the right place, on a plain background. I am not posting the picture (it is title content) but the point is that it is a rendered frame of world content, not a menu, and everything in it is where it should be.

The paged tree, at the same point in the title with the same keypresses, draws black at 3,510 draws.

Why this is the take-back and not my three excuses

The earlier candidates are all present in both runs, so none of them can explain the difference:

  • Ray-tracing structures: never built in either tree (the README says so for main, and try/wave64 predates even that). The caption card needs no ray-traced shadows, and it renders correctly on the un-paged tree.
  • Dropped draws: both trees drop draws for missing host pipelines; the un-paged one still puts the caption card on screen.
  • Untranslated compute shaders: try/wave64 translates more programs (it is the older base), so if anything it has fewer refusals — yet the paged tree, with fewer refusals, is the black one.

What differs is exactly one thing: fixed=1026 pages are held by the dynamic range, 2,880 host pages are left for a title that wants 4,864, and the take-back fires 325 times in the run.

The strongest single line from the paged run

view heap pages unused lately taken back: they read null until placed again
    pages=172  total=172  free=244  in_use=2636
...
view heap pages placed again: pages=16  taken_back=16  refused=0  in_use=269

in_use 2764 → 269 in one take-back, with free=244 still available. The page set collapses and is rebuilt while the frame loop is running through it, so slots a draw read in one frame read null 40 frames later. That is a black picture that flickers, which is what I see.

What I am not claiming

I have not proven the take-back is the only defect in the paged path — only that removing the paging removes the black, on identical builds of the same title on the same machine. It is possible the page table entries or the shader-side page lookup have their own problem that a longer run would show after the take-back stops.

I also do not have a run of the paged build that both avoided the take-back and reached the world: my two attempts at shrinking the dynamic range (extra = half, then MIN_DYNAMIC) kept taken back at 0 but did not finish compiling pipelines inside my 200–220 s windows, so they never reached the world to be judged. That experiment is still open and I flagged it as such in my previous comment.

What would settle it

Raising the take-back age past anything a world frame reaches — one run, same build, 45 s to the caption card — tells us in one number whether the black is purely the take-back. The world's descriptor cycle is long enough that 32 submissions is inside it, and this build's own peak of 8192 of 262144 dynamic slots says the pages being taken back are not the ones the take-back was designed to reclaim.

Environment and method as in my earlier comments. Counts and log lines only; no title content, assets or shader bytes in this report.

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks, the A/B against the un-paged tree is the comparison that was missing. Both changes it calls for are on the current head, c23f708, which is past the 248e4c3 you ran:

  • Smaller dynamic range (c1d5a3a): 258 fixed pages instead of 1,026, so 3,648 for the title.
  • VICTORY_VIEW_PAGES_KEEP=1 (c2e5ebc, diagnostics builds): turns the take-back off entirely. It goes further than raising the age: nothing is ever taken back, and a write past the free pages is refused instead.

So the run that would settle it is c23f708 to the caption card, once with defaults and once with VICTORY_VIEW_PAGES_KEEP=1. The pipeline library cache should be warm from your full-range runs, since the pipelines don't change, so it shouldn't need the long compile your earlier reduced-range runs hit. If the caption card draws with the defaults, the page budget was the problem. If it only draws with KEEP=1, the take-back still fires in the world even with 3,648 pages, and the relaxed= field on those lines will say which age rule took them.

@nathanbzrr nathanbzrr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed c23f708 on Windows 11 (AMD Radeon RX 7600 + D3D12 Debug + WARP):

  • cargo run -p xtask --locked -- policy: 192 files ok
  • cargo clippy -p victory-gpu --all-targets --locked -- -D warnings (default & --all-features): clean
  • cargo test -p victory-gpu --lib --locked descriptor -- --test-threads=1 (RX 7600): 36 passed; 0 failed
  • VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked descriptor -- --test-threads=1 (RX 7600 + Debug): 36 passed; 0 failed
  • VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-gpu --features diagnostics --lib --locked descriptor -- --test-threads=1 (WARP + Debug): 36 passed; 0 failed

Two issues found in the reclaim/remake interaction need fixes before merge:

  1. Host::execute (crates/victory-gpu/src/host.rs:1466-1472) runs make_read before turn_pages, letting remakes() null out newly recreated placed textures.
    In Host::execute, crate::descriptor::make_read(&read) runs before crate::descriptor::turn_pages(...). When a previously taken-back page (made[index] == key, slot replaced by page_nulls, kept cleared) is read again in the same submission:
    • make_read first recreates the placed texture in that slot;
    • turn_pages -> place_page -> remakes() then fills made[first..last] with REMAKE, and sync_slots calls mirror(..., false) where later = !for_draw && is_placed_texture(&view) (true), overwriting placed textures back to null_for right after make_read populated them.
    • Notably, view_heap_pages_taken_back_are_placed_again_when_read (crates/victory-gpu/src/host.rs:506-520) invokes turn_pages before make_read, which masks the Host::execute ordering. Running turn_pages before make_read (or preserving placed textures created/kept for the current submission across remakes) and testing the Host::execute order would fix this.
  2. needs_remake() (crates/victory-gpu/src/descriptor/host.rs:1067) returns false for non-texture views on taken-back pages.
    take_back_pages replaces the host page with page_nulls while leaving made[index] == key. When a taken-back page is later placed again via remake_pages (descriptor.rs:212, 236, 244) -> sync_slots -> mirror(..., true), needs_remake() short-circuits when !for_draw || !is_texture(&view). As a result, View::Constant (CBVs), buffer View::Shader (SRVs), and non-texture View::Unordered (UAVs) whose records still match key are skipped instead of being rebuilt into the newly placed host page.

(Side note on descriptor/pages.rs:41, 394: under pressure PRESSED_AGE_SUBMISSIONS = 32 evicts pages unused for 32 submissions regardless of MIN_AGE = 10s, so any long-lived descriptor not re-bound/stamped every frame can still churn if the heap stays near LOW_WATER.)

AI-assisted; synthetic tests only, no game files.

@pickles976

Copy link
Copy Markdown

Wine/NVIDIA offscreen verification:19 owner checks pass; reclamation recovery probe fails

Exact production head c23f70853f3c9887642b0345b127aa08498eef14, reference checkout VIctory-pr2121. Linux6.17, Wine11.0, RTX4060 Laptop8GiB, NVIDIA590.48.1, DXVK3.1.1. Diagnostic-relaxed vkd3d-proton3.2.0 2576c0b4adfae4a+: assertions disabled and allocator/list vtable identity checks removed, null checks retained. Not stock-runtime certification. Rust1.98.1 Windows-MSVC target, one test thread,9GiB/512MiB scope, bounded180s gate/120s probe deadlines.

VICTORY_VIEW_PAGES and VICTORY_VIEW_PAGES_KEEP unset: automatic paging on this capped NVIDIA host. Local changes: selected test skip guards made fail-closed, plus the isolated synthetic probe below; production code unchanged. Shared build freshness verified with explicit compilation from this checkout.

Gate Passed Time(s)
descriptor::pages::tests 11 0.01
paged heap cap 1 0.74
dynamic-slot accounting 1 0.60
owner take-back/remake fixture 1 0.63
paged_view_heap shader dispatch/readback pair 2 1.44
shared tables and stable copy views 1 0.69
submission-miss/write retention 1 0.64
paged null-buffer readback 1 1.16

Fresh GPU builds9.42s/8.87s and shader test builds5.95s/5.99s. No skipped device accepted in the selected hardware gates. DXGI explicitly reports WARP not supported, returning first hardware adapter, so the WARP-labelled passes are not independent software coverage. Logs: verify-pr2121-paging-gates.log, verify-pr2121-paging-dispatch.log under .compat-runtime/logs/.

Reproduced: three null submissions, not one

A local memory::tests::a_reclaimed_texture_returns_after_one_missed_submission probe uses synthetic cs_5_1 HLSL, a real placed RGBA8 texture, the production page table, real GPU-written slot/page feedback, HostList::defer_heap, and the normal Host::execute completion path. It does not inject feedback from the CPU or drain take_reads between submissions.

  1. Place texel [17,34,51,255] at logical slot44325 (page173, offset37); mark its texture used for the normal upload path.
  2. Two actual GPU readbacks return that texel, establishing the slot-read state.
  3. With the GPU idle, force the owner's reclaim policy by raising the water marks and advancing400 synthetic policy ticks/time increments. This is not400 real seconds of title execution. Confirm page-table entry0 and slot no longer kept.
  4. Restore ordinary low water marks and submit the same shader four times, without CPU feedback edits.

Observed GPU readbacks:

[[0,0,0,0], [0,0,0,0], [0,0,0,0], [17,34,51,255]]

Expected under the documented one-submission miss: the second post-reclaim read returns the texel. The assertion fails: left:[0,0,0,0], right:[17,34,51,255]. 0passed/1failed,0.70s, fresh5.78s compile. Log verify-pr2121-texture-recovery-uploaded.log. An earlier probe omitted normal heap upload tracking and failed its pre-reclaim control; that result is not counted as a reclamation defect.

Code path consistent with this readback: HostHeap::take_back_pages drops the texture without invalidating its already-seen slot read. On the first miss, Host::execute consumes slot reads before turn_pages; restoration leaves the placed texture lazy and queues forget_read. The next completion drains that queued forget and clears the new GPU bit; only another submission gets a fresh slot-read event. The existing owner lifecycle fixture manually drains take_reads before injecting its next slot mark, so it misses this order.

Separate allocation-failure hazard (source inspection, not fault-injection tested)

page_nulls creation at descriptor/host.rs:312-329 is fallible. take_back_pages skips its clearing copy when that option is absent (950-960) but still returns the physical pages to Pages::free (963). Pages::place_at reuses them (289-306); a never-before-placed logical page is not queued for a whole-page remake. [INFERENCE] Untouched offsets can retain old resource descriptors instead of nulls. Reclamation should not release an uncleared page for reuse. I did not manufacture memory exhaustion to test this branch.

No title run, world-entry, FPS or full-suite claim for this PR. Both concerns are in the take-back path; the owner-provided diagnostics VICTORY_VIEW_PAGES_KEEP=1 avoids that path by construction, but its runtime control is not yet verified here. Do not interpret the19 passing gates as reclamation correctness certification.

AI use: omp, harness model openai-codex/gpt-6-astra, ran the checks and drafted this report. No upstream code changes or assets attached.

A page placed again has its slots made from the title's records at the
next heap sync or page turn. That remake now leaves the slots made since
the page was placed: a placed texture made for a read (make_read runs
before turn_pages after a submission) or for a draw was nulled again by
it, so the texture read null one more submission. A view made where its
page found no room went to the scratch page and was held as if made; its
slot now holds nothing, so the remake makes it once the page is placed.

A draw binding a slot of a page taken back places the page at once, for
every kind of view: constant buffers and buffer views were left null for
that submission (only textures placed the page), the page placed again
after it from the shaders' read marks.

Taking a page back forgets the read marks of its slots, and marks
forgotten since the last submission are cleared before the next one
runs instead of after it. A placed texture's slot read again after its
page was taken back was taken as read only two submissions later: its
mark was still seen, and the forget queued by the remake cleared the
next submission's mark. It now reads null in one submission and is made
for the next. Evicted textures read again gain the same submission.

A paged heap without its page of null views (its creation failed) takes
no page back: the host pages it gave back were not cleared.

Tests: the remake in Host::execute's order and through Host::execute
itself, buffer views of a page taken back made again on a read and
placed by a draw, a view written with no room made when its page is
placed.

Found in review by @nathanbzrr (the remake after make_read, buffer
views on a draw) and @pickles976 (the read marks, the null page).
@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks @nathanbzrr and @pickles976. All four are addressed in fedb38d (head of gpu/view-heap-pages), each with a test that failed before it, except where noted.

1. make_read before turn_pages nulls the texture it just made (@nathanbzrr). Real. make_read's mirror(.., true) placed the page and made the texture, then turn_pages -> remakes() filled the whole page with REMAKE, and sync_slots -> mirror(.., false) nulled the placed texture again. A draw that placed a page while recording hit the same thing in the heap sync before the submission. I kept the order and changed remakes() instead: it marks only slots that hold no view. A slot made since the page was placed keeps its view, so both orders work. A view written to the scratch page (no room for its page) used to be kept as if made, so it now holds nothing and is still remade. Tests: host::tests::view_heap_pages_placed_by_a_read_keep_the_texture_made_for_it (make_read then turn_pages, as in Host::execute; failed before) and draw::tests::a_placed_texture_in_a_page_taken_back_is_made_after_one_submission_reads_it (through Host::execute itself).

2. needs_remake() skips non-texture views on taken-back pages (@nathanbzrr). The path you describe doesn't happen. remake_pages calls remakes() before sync_slots, and that fills made[first..last] with REMAKE (descriptor/host.rs, remakes). So made[index] != key and mirror rebuilds the slot without consulting needs_remake; sync_slots also passes for_draw = false. The new test confirms it: a CBV, a buffer SRV and a buffer UAV in a page taken back are all made again when a read mark places the page, and that part passed before the fix. The gap is in the draw path. table_entry -> mirror(.., true) on a CBV or buffer view in a page taken back returned early (made == key, not a texture), so the page stayed unplaced and the draw read null until the read marks placed it after the submission. Only textures placed it at once. Now a draw binding any slot of a taken-back page places it, and the heap sync makes its slots before the submission. Test: host::tests::view_heap_pages_taken_back_make_their_buffer_views_again (the draw step failed before, "placed again for the draw").

A. Placed texture back after three null submissions (@pickles976). Real, and the same mechanism you describe. take_back_pages left the slot's read "seen", so the first read after take-back wasn't taken. The remake then queued forget_read, and take_reads cleared the forgotten marks after the next submission had run, which erased that submission's read too. Now taking a page back forgets its slots' read marks, and Host::execute clears forgotten marks before the submission runs (shadow::forget_reads_now), not after. The draw test above runs your sequence: read twice, take back, then four submissions through Host::execute, with a compute shader setting the slot and page read bits on the GPU and no draining between them. Whether the slot holds its texture after each: [false, false, true, true] before, [true, true, true, true] after. So only the first submission after the take-back reads null. Evicted textures that are read again get the same one-submission gain.

B. page_nulls creation failing (@pickles976). Real on inspection. Without the null page, take_back_pages skipped the clear but still put the host pages on the free list. It now returns early when page_nulls (or the host) is missing, so such a heap takes nothing back and refuses writes past the free pages, as before take-back existed. No test: a CPU-only 256-descriptor heap can't be made to fail here.

Side note (32 submissions). PRESSED_AGE_SUBMISSIONS applies only on the first pass after a write found no free host page (pressed is set by the refused write and cleared by that pass). Without a refusal only the strict ages apply (300 submissions and 10 s). For an A/B, VICTORY_VIEW_PAGES_KEEP=1 (diagnostics builds) turns take-back off.

Tests (RTX 5070 Ti, which pages): cargo test -p victory-gpu --lib 250 passed, 0 failed. With --features diagnostics, 263 passed; frame::tests::waits_end_on_ticks_and_count_frames (flaky) and pipeline::placed_uav_tests::placed_uav_dispatch_writes_its_texture failed, and both fail at c23f708 too. Clippy with and without diagnostics: 0 warnings. cargo xtask policy ok.

@bittertea0323: the draw-path gap in point 2 fits what you saw in the world. A draw binding a constant buffer or buffer view in a page that had been taken back read null until a later submission placed the page; only textures placed it at once. With take-back running inside the frame loop, that leaves a lot of a frame reading null. If you can, rerun fedb38d to the caption card with defaults, and once with VICTORY_VIEW_PAGES_KEEP=1 for comparison.

@passerbyyhx

Copy link
Copy Markdown

I checked both points in the review of c23f7085 on Windows with an RTX 4090 Laptop and WARP.

Placed texture. In both directions of A → B → A on physical slot 66311 (4090), the original placed SRV read transparent black on three consecutive GPU submissions and green on the fourth. The neighboring committed SRV was already yellow on the second. This matches the 4060 Laptop result. The earlier round trip I reported here used ordinary committed SRVs and did not exercise this path.

Author-branch fix #8 gets the placed texture back on the second submission on both adapters, including after a demand made while no page was free. Simply moving page restoration ahead of view creation still left the returning A black until the fourth demand. A third, unread placed slot stayed lazy throughout. Failing fixture · Passing fixture.

Buffers. Once the page is placed again, the remake pass rebuilds all three physical buffer slots. The author-branch regression #7 reads separate CBV/SRV values and writes them with a per-dispatch tag through the UAV. A and B got their own data on all three legs and the guard word stayed intact. With the page-wide REMAKE fill removed the test went red before dispatch 3 on both devices. This fixture supplies a page mark explicitly. Separately, the existing translated compute test passed and observed GPU page marks for both its table UAV and direct SRV.

These are synthetic readbacks. The 4070 SUPER default vs. VICTORY_VIEW_PAGES_KEEP=1 caption-card comparison is still open.

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Thanks, that matches what fedb38d fixes. Your readings were against c23f708, before it. Both points are covered there with this repo's own tests:

  • Placed texture back after three submissions. Taking a page back now forgets its slots' read marks, and Host::execute clears forgotten marks before the submission instead of after. remakes() also leaves slots made since the page was placed alone. draw::tests::a_placed_texture_in_a_page_taken_back_is_made_after_one_submission_reads_it drives Host::execute with GPU-set read bits: [false, false, true, true] before the fix, all true after.
  • Buffers. The remake pass rebuilds them once the page is placed, as you saw. The gap was a draw binding a CBV or buffer view in a taken-back page, which didn't place the page until later. That's fixed and covered by host::tests::view_heap_pages_taken_back_make_their_buffer_views_again.

I wrote the fix separately, so the fork PRs aren't needed for this. A rerun of your fixtures against fedb38d would confirm it on the 4090 and WARP.

0xkn0wh3r3 added a commit to 0xkn0wh3r3/VIctory that referenced this pull request Nov 26, 2026
# Conflicts:
#	crates/victory-gpu/src/descriptor/host.rs
#	crates/victory-gpu/src/shadow.rs
@passerbyyhx

Copy link
Copy Markdown

I reran the fixtures on fedb38db as requested, on the RTX 4090 Laptop (native paging) and Microsoft WARP (forced paging). Your three new tests passed on both. Our CBV/SRV/UAV physical readback also passed on both, and I closed fork PR #7.

One full-heap case remains. With no physical page free before the demand, A → B → A reused slot 66311. In both directions the placed SRV returned black, black, green, green. The committed neighbor returned black, yellow, yellow, yellow, and the third, unread placed slot stayed lazy. After D1 the page was mapped but only the committed view was held. After D2 both were held. With A resident from the outset, the placed view already read green on D2. These are successive GPU pixel readbacks, including the distinct case where B had previously been sampled while no page was free and its title record was never rewritten.

On the same fixtures, moving make_read after turn_pages fixed the freshly written B and returning A, but the B that had already been sampled with no space still needed D3. Re-arming that one mark when a placed texture had gone to scratch recovered B on D2 as well. The results per adapter were 0/2 on fedb38d, 1/2 with just the reorder, 2/2 with both changes. Unchanged production plus fixtures · Passing fixtures.

The standalone two-file follow-up applies directly on top of your fix. I updated the existing fork PR #8 to contain just that diff. This synthetic test does not establish what happens at the 4070 SUPER caption card.

@passerbyyhx

Copy link
Copy Markdown

Two additional controls distinguish descriptor restoration from a late texture upload in the full-heap result above. On unchanged fedb38db, three outputs in the same D2 submission were black through the recovering slot, yellow through its ordinary neighbor, and green through a permanently resident alias of the very same placed texture. In a separate run without the alias, I changed the title texel from green to blue while A was unmapped, without rewriting its descriptor. The upload count advanced on D1 on both versions. A returned black, black, blue, blue on the author head and black, blue, blue, blue with the two-file follow-up. RTX 4090 Laptop and WARP agreed, with and without the early no-space demand. Reproducible alias and changed-texel controls.

We also found a separate change in the eviction read window. H2 sampled yellow through slot 561 and still held that live resource. If H1 retired a page containing its own record at 561, fedb38db returned only slot 7 for the window. If H1 lacked that record or retired a different page, the result was [7, 561]. On c23f7085, and with the single-file window fix, all three cases returned [7, 561] and the H2 resource. This checks the input to the eviction decision. Actual eviction and game impact were not measured.

Combining the two follow-ups in one binary passed both placed-texture cases and the independent two-heap case on each adapter (3/3 on each).

…e next submission

With no host page free, a placed texture read in a page taken back was
made after the submission before any page was taken back for it: its
view went to the scratch page, and the page placed just after had the
slot made lazily again, so the texture read null for one more
submission than the page's other views. Pages are now turned before the
views read are made (the read marks are taken first), so those views are
made in the pages placed for them.

A page read again with no host page free presses the next pass of take
back as a write refused room does, so a page unused lately is taken back
for it in the same pass. Only the placed texture's refused write pressed
it before.

A placed texture whose view goes to the scratch page has its read mark
forgotten, so its next read is taken: one read while no page was free
was taken once, and the slot was left null when its page was placed.

Read marks forgotten are kept for the eviction pass's window of slots
read: marks are by slot for every heap, and a page taken back in one
heap cleared another heap's read of the same slot, whose texture could
then be given up as unused.

Tests: through Host::execute with no host page free, a placed texture
read in a page taken back (its host page given to another page since)
and one read earlier with no room are made after the first submission,
as a buffer view in the page is; a page read again with no room presses
the next pass; two heaps with records at one slot keep the second's
read for eviction when the first takes its page back.

Found in review by @passerbyyhx (the full heap, the eviction window).
@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

@passerbyyhx thanks for the full-heap case and the eviction-window regression, both are fixed in 0bc5edb. We wrote the fix and the tests ourselves rather than taking your fork PRs (0xkn0wh3r3#8 and #9), so those can be closed.

Full heap. The cause was as you found: make_read ran before turn_pages, so with no page free the texture went to the scratch page, and the remake of the page placed right after left it lazy again. Three changes:

  • Host::execute now takes the read marks, turns pages, then makes the views read. That's safe since fedb38d, because the remake leaves made slots alone.
  • A page read again with no host page free now presses the next take-back pass, as a refused write does. Without this, after the reorder nothing pressed in the same pass and the page was placed a submission later.
  • A placed texture whose view goes to the scratch page has its read mark forgotten, so its next read is taken (your sampled-while-full B).

Tests run through Host::execute. Each of D1..D4 is a submission whose compute shader sets the slot and page read bits; the value is whether the slot holds its view after each submission, so true after D1 means it reads correctly from D2:

  • Returning A, with page 2 taken back for it into the same host page. (A, buffer view in the page), fedb38d: (false, true), (true, true), (true, true), (true, true). Now: (true, true) x4. A placed texture in the page that no shader reads stays unmade.
  • B read earlier with no room. fedb38d: false, false, false, false; in this test nothing else asks for room, so the page is never placed. With only the reorder and the read pressure: false, true, true, true. Now: true x4.

Eviction window. Read marks are one bit per slot for every heap, so a take-back in H1 cleared H2's read of the same slot. Marks are still forgotten at take-back, which keeps the one-submission recovery. Any set bit that a forget clears is now kept for reads_since, so it still counts as a read for eviction. This applies to every forget path, not just take-back. draw::tests::a_page_taken_back_keeps_another_heaps_read_of_its_slot_for_eviction uses two paged heaps with placed textures at the same slot, marks the second heap's read and slot 7's, then has the first heap take its page back. reads_since returns [7] at fedb38d and both slots now, and it names the second heap's texture.

cargo test -p victory-gpu --lib: 254 passed (NVIDIA, which pages view heaps). With diagnostics, only placed_uav_dispatch_writes_its_texture fails, as it does at fedb38d. Clippy both ways is clean and cargo xtask policy passes.

0xkn0wh3r3 added a commit to 0xkn0wh3r3/VIctory that referenced this pull request Nov 26, 2026
…w round)

# Conflicts:
#	crates/victory-gpu/src/host.rs
#	crates/victory-gpu/src/shadow.rs
@passerbyyhx

Copy link
Copy Markdown

Thanks for fixing both cases. I verified 0bc5edbd on an RTX 4090 Laptop with native paging and Microsoft WARP with forced paging, then closed fork PRs #8 and #9 as requested.

With the physical pool full, both directions of A → B → A reused slot 66311. B returned transparent black on its first submission and green on its second. In a separate run I changed A’s texel from green to blue while its descriptor was unmapped. On the way back, A returned transparent black on its first submission and the new blue on its second, with its committed neighbor yellow. Both adapters agreed. Fresh-texel fixture.

The two-heap eviction window retained H2’s sampled slot 561 and its live owner with each of the three H1 controls, including retiring H1’s overlapping record. The second drain was empty in all three cases.

I also isolated the new read-only pressure condition by consuming the earlier refused-write signal before measuring. At age 32 a GPU demand for B still read null and left A mapped. A fresh demand at age 33 reclaimed the slot, and the following read was green. With an empty submission at 33, A stayed mapped until a fresh demand at 34. No new title descriptor writes in either measurement. Read-pressure boundary fixture.

@pickles976

Copy link
Copy Markdown

Re-verified on 0bc5edb (Wine 11.0/Linux 6.17, RTX 4060 Laptop 8 GB, NVIDIA 590.48.1, DXVK 3.1.1): the reclamation recovery window I reported at c23f7085 (#2121 (comment), three null submissions) is fixed. Same probe, unchanged: real placed RGBA8 texture, real GPU-written slot/page readback marks, HostList::defer_heap + the normal texture upload path, forced reclaim via set_page_water(u32::MAX, u32::MAX) + 400 idle-locked take_back_pages ticks, four submissions through Host::execute with no take_reads draining between them.

GPU texels after reclamation, c23f7085 → 0bc5edb:

[[0,0,0,0],[0,0,0,0],[0,0,0,0],[17,34,51,255]]   c23f7085: three null submissions
[[0,0,0,0],[17,34,51,255],[17,34,51,255],[17,34,51,255]]   0bc5edb: one, as documented

My local samples[1] == texel assertion — the exact condition that failed at c23f7085 — now passes 1/1 in 0.69 s after a fresh 9.01 s compile. The rest of the battery also passes: descriptor::pages::tests 12/12 (grown by one on this head), the paged-heap cap fixture (now asserting the PAGED_TITLE_VIEWS clamp), dynamic-slot accounting, your take-back/remake fixture, lists_share_a_table_and_copies_keep_their_views, the missed-submission copies pair, and the three stride_tests dispatch/readbacks — 23 checks, 0 failures, log verify-pr2121-fixed-recovery.log / verify-pr2121-fixed-gates.log (kept locally with the probe).

Your four new take-back tests (view_heap_pages_taken_back_make_their_buffer_views_again, a_placed_texture_in_a_page_taken_back_is_made_after_one_submission_reads_it, a_page_taken_back_keeps_another_heaps_read_of_its_slot_for_eviction, and the read-back remake) all pass on this host too.

Environment caveats, unchanged from the first report: locally built diagnostic-relaxed vkd3d-proton 3.2.0 (2576c0b4adfae4a+; assertions disabled, allocator/list from_iface vtable identity checks removed, null checks kept) — not stock-runtime certification; skip guards in the battery made fail-closed locally; one test thread; 9 GiB/512 MiB cgroup scope. DXGI under Wine reports "WARP not supported, returning first hardware adapter", so any WARP-labelled run here is the NVIDIA adapter, not independent software coverage. No title run, world-entry, or FPS claim for this PR; the probe and the fail-closed guard edits remain local to my checkout.

AI use: omp, harness model openai-codex/gpt-6-astra, ran the checks and drafted this report. No upstream code changes or assets attached.

@bittertea0323

Copy link
Copy Markdown

The 0.5-2 fps figure matches what I measured, and it is the number that decides between paging and capped heaps

@kawaii-shakal's run on an RTX 5070 Ti (0.5-2 fps in the world, ~20 submissions a frame, this PR merged with #2821) is the third independent host that puts paging here in the same range. Mine agreed at a lower resolution and a smaller background load, so the two are comparable in kind:

host approach picture fps
RTX 4070 SUPER 12 GB, Win10 19045 this PR, paged, extra=DYNAMIC black 0.1
RTX 4070 SUPER 12 GB, Win10 19045 this PR, paged, extra=MIN_DYNAMIC black did not pass the loader
RTX 4070 SUPER 12 GB, Win10 19045 un-paged tree, capped_dynamic_slots (393,215 title / 606,784 dynamic) correct 5-7
RTX 5070 Ti, Win11 this PR + #2821 ? 0.5-2

That A/B on one machine is in this thread above and is what led me to write it up separately: the un-paged tree with the capped split draws the world at 5-7 fps on the same host, same title, same Agility opt-in, same keypresses, where the paged one draws black.

The take-back is not the only cost; the pages themselves are. With 2,880 usable pages against the 4,864 the title's 1,245,184 slots need, every frame re-places what the age rule dropped, and at 0.5-2 fps nothing the title writes reaches the age threshold before room runs out — which is exactly what @kawaii-shakal saw. At 5-7 fps on my host the arithmetic is no better; the reason the capped split works is that it does not need those pages at all, because the title only ever writes 92,113 of its slots.

What I would suggest, if paging is going to continue

Measure the capped split as the control on the same host and scene, the way I did. If a paged heap cannot beat a heap that simply gives the title fewer slots, the work here is solving a problem the title does not have.

I am not asking for this PR to be closed — it fixes a real truncation, and the reclaim work in a12b972/fedb38d is careful. I am saying the comparison that decides it has not been posted in this thread yet, and on the one host where I could run both, it is not close.

Numbers only; no title content. RTX 4070 SUPER 12 GB / driver 591.74 / Windows 10.0.19045 / Ryzen 7 7800X3D / 31 GB. The write-up and the raw measurements are at https://github.com/bittertea0323/gta6-win10-notes

@0xkn0wh3r3

Copy link
Copy Markdown
Contributor Author

Agreed that the capped split is the control this needs, on one host and scene. Two things about the paged rows, though:

Both paged measurements predate the fixes that bear on them. Your black world was at 248e4c3. Since then, fedb38d fixed draws that bound a constant buffer or buffer view in a taken-back page: they read null until a later submission placed the page, and only textures placed it at once. 0bc5edb fixed placed textures coming back a submission late with no free page. Both happen inside the frame loop and leave parts of a frame null. @kawaii-shakal's 0.5–2 fps was at 979e3a7, before the smaller dynamic range (c1d5a3a: 3,648 title pages instead of 2,880) and before both review fixes. So none of the paged numbers in your table are from the current head.

How many slots the title writes differs between runs. Your run logged written=92113, and a 393,215-slot title region holds that. But @kawaii-shakal's run on the RTX 5070 Ti logged no room left in the host view heap at 2:02 with written=684297 of=737280: 684,297 distinct title slots written by then. A capped heap drops every write past its title region; on main that's the 310,720 title slot past the host heap lines you measured. Paging keeps them as long as the live set fits. Which approach is right depends on which of those two cases the world usually is, and the 92k run alone can't settle that.

The run that would decide it, on your host and scene: 0bc5edb (or later), once with defaults and once with VICTORY_VIEW_PAGES_KEEP=1, against your capped split. Please include the host view heap pages in use ... written= lines, so we can see how many slots that scene writes. If paging at 0bc5edb still loses to the capped split there, that's a clear result, and I'd rather know it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.