Repository navigation
GPU: page view heaps a host caps below the slots shaders index - #2121
0xkn0wh3r3 wants to merge 5 commits into
Conversation
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 capped heap kept 934,464 title slots and left the
rest out ("title slot past the host heap"): views there read null. Issue
reports put 61,000 to 173,000 live slots past the cap in the world
(Marvisak#1760), and two view-heap unit tests failed on NVIDIA (Marvisak#1835).
A host that refuses a view heap of every index shaders take and 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,
and the dynamic slots' pages are placed together after them (tables of
them are bound as host ranges). 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.
- Translated shaders take each view heap index through the table when
`Options::view_pages` is set (`Shader::heap_handle`: one table load, a
shift and an or per handle; 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), where the
stride table was taken from the title's heap only.
Pages are not given back yet, and the host has 3,906, of which 1,026 are
fixed (null, scratch, dynamic): 2,880 for the title's 4,864 virtual
pages. When they run out, further pages read null with a warning; the
pages in use are logged at each power of two, so a run shows whether a
title's live slots fit.
Tests:
- `descriptor::host::tests::pages_are_placed_once_on_first_write`: page
placement, its table entries, reads placing none, running out.
- `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 and WARP (expected values on 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); the second's HLSL stand-in for a translated shader
now indexes the heap as they do, through the page table.
…he heap `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` failed on NVIDIA before the program ran: `View::NullBuffers` made the test host's view heap `HEAP_VIEWS` (2^21) slots, to put the null buffer views at `NULL_BUFFER_VIEW`, and the driver takes at most 1,000,000. Where the device refuses that heap, the test host now puts them in one 256-slot page after the dispatch's other views, at their offsets in `NULL_BUFFER_VIEW`'s page (`Host::null_buffer_page` says which), and the test translates the program with view pages and maps that page there, as the runtime pages such heaps. A device that takes the whole heap (AMD, WARP) runs as before. On the RTX 5070 Ti the test now passes (it read through the page table to the null view: zeros); `a_heap_index_in_a_paged_view_heap_reads_where_its_page_is` still passes.
DenRakEiw
left a comment
There was a problem hiding this comment.
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_releasedandlists_share_a_table_and_copies_keep_their_views) onmain940d32f!cargo test -p victory-shader --lib emit::stride_tests::— 6 passed, 1 failed (directly fixesa_heap_buffer_read_where_no_buffer_view_is_reads_zeroson 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 warningscargo xtask policy— ok (183 files ok)
Huge NVIDIA/Blackwell compatibility win. Looks great!
AI-assisted (Gemini 4 Neon).
|
Independent owned texture check at One source-level failure case: the stride upload returns |
catminou4
left a comment
There was a problem hiding this comment.
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.
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.
|
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 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 A few things I checked that are not in the diff:
What I have not reviewed: the 212 lines of No game data is involved: counts from the title's own log. Written with an AI assistant. |
A paged heap's page table lives in the view-stride table's buffer. When that upload buffer could not be made, the paged setup took 0 as its address and wrote the table at `VIEW_PAGE_TABLE` from there. A paged heap is now refused (with a warning) when the buffer is missing, before its GPU range is recorded. A paged heap logs it when it is made, at info: "view heap paged", with the title's slots, the host's slots, its pages and how many are fixed. The probe's own line can come before logging is set up; this one comes when the title makes its heap.
|
Thanks both, this is very useful. @yualk: the missing-buffer case was real. In @fiestorra: thanks for the 4090 run, and for checking the merges with #2016 and #2027. The probe's line ( |
|
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, On clean main 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 The 1,245,184-slot title heap used 1,000,000 physical slots and logged 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. |
|
On Following @iGoldenNinja's fork replay above, the same on upstream
No game data attached: counters, timings and log warnings only. AI-assisted (Claude Code). |
The page-use log, the no-room warning and a new log of pages written with no room left say how many slots of the pages placed on a write were written: whether smaller pages would fit more of a title, or the title writes that many views.
|
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: 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. |
Clippy's manual_is_multiple_of lint (Rust 1.98) flags the % in the compile-time check of the page size.
|
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:
Separately, I compared unmodified 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. |
Offline measurement on a retail dumpResult: no count change against I merged head 40bd210 onto 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). |
|
Automated triage for the maintainers. The paging is consistent as I read it. What would change the verdict: a run with c5d33e8's Generated by Claude Code |
|
GTX 1650 (Turing, 4 GB, driver 32.0.16.2124), diag build, Series S,
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. |
Shader tests on NVIDIA AdaI ran
So on Ada this PR fixes Offline, on the retail dump, this PR does not change the counts (posted above). AI-assisted (Claude Code). |
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 slotiat host sloti, so the capped heap kept 934,464 title slots and left the rest out ("title slot past the host heap").HEAP_VIEWS)The fix
A host that refuses a view heap of every index shaders take plus the dynamic slots (
descriptor::host::view_pages, asked once; setVICTORY_VIEW_PAGES=1to page on any host) keeps the title's order in a virtual heap of 256-slot pages:VIEW_PAGE_TABLE), which shaders already have bound. A null made in a page with no place takes none.Options::view_pagesis 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.Limits:
Testing
descriptor::host::tests::pages_are_placed_once_on_first_write: page placement, its table entries, reads placing none, running out.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.dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_viewsnow pass (both fail on main there).emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosnow 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-gpuand-p victory-shader: all pass on the RTX 5070 Ti exceptemit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_strideandemit::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
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 slots the title actually writes fit in 2,880 host pages (737,280 slots).