Repository navigation
GPU: page view heaps a host caps below the slots shaders index - #2121
0xkn0wh3r3 wants to merge 16 commits into
Conversation
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.
|
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. |
|
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). |
|
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. |
|
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. Needs work: needs the maintainer's decision. Reviewed head
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 CI: passing. 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). |
…hetic milestone
…nd skipped release build
…release build not run
… release executable SHA
…xecutable hash
…d release build; preserve stride failure
…tart native visual gate
…cutable and visual A/B gate
… with no native output
…y captured output
… direct CLI diagnostics
…aging activity, log quality caveats
…ented frames with active paging
…quest visual evidence next
…e frame/paging runtime and visual unknowns
…nks and shader-cache semantic risks
…and third-worktree source recovery plan
|
RTX 5080 (Blackwell), in the title with #439's console flow, this PR at
Setup: RTX 5080, driver 617.42, Windows 11 26200.
In the world:
In the tree with #2628, the passes of the cell's indirect-lighting chain read many of their views from slots past the cap:
With this PR none are, and the cast is still there, so for that symptom the missing slots are ruled out. Details of the cast are on #2711. A test that fails at
Not tested: more than one run, other scenes, this PR without #439. Local diagnostics only. No game data: counts and pixel statistics. AI-assisted. |
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:
HEAP_VIEWS - 2is capped atPAGED_TITLE_VIEWS(NULL_BUFFER_VIEW - 1 - DYNAMIC, 1,835,005 title slots), with the warningpaged 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.
HostHeap::gpuhands out a handle in it, when a draw binds a slot of it through a table, and when its read mark comes in.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, andshadow::take_page_readstakes and clears the marks of both bitmaps after each submission. The shader cache key changes with the translator's sources.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.view heap pages unused lately taken back(pages,total,free,in_use, andrelaxed(whether that pass took pages younger than the strict ages) withrelaxed_total) andview heap pages placed again(pages,taken_back,refused,in_use). The placed-again line keeps two counts apart (6f8b588):taken_backis pages taken back by reclaiming and then read, written or drawn through (a wrong guess);refusedis pages written when no host page was free that got a place later. A page taken back and then written with no room counts undertaken_back.pagesis 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 heapandview heap pages written with no room leftkeep 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) givespeak, 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), andrun, the longest run of them a table asked for; it is logged wherepeakorrunreaches 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:intake_back_pages): a handle fromgpu()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, andgpu()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, throughHost::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. Atfedb38d:[(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]. Atfedb38d:[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_sincereturns both slots and names the second heap's texture. Atfedb38d:[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_texturefails, as atfedb38d. Clippy with and without--features diagnostics: 0 warnings.cargo xtask policyok.Review fixes (
fedb38d):draw::tests::a_placed_texture_in_a_page_taken_back_is_made_after_one_submission_reads_it(GPU, throughHost::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_readthenturn_pages(the orderHost::executehad atfedb38d; a texture made for a draw before the heap sync is in the same place). Before, the remake nulled the texturemake_readhad 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) andpipeline::placed_uav_tests::placed_uav_dispatch_writes_its_texturefail, and both fail atc23f708too. Clippy with and without--features diagnostics: 0 warnings.cargo xtask policyok.The paged title-heap cap (
07a132db):host::tests::a_paged_heap_of_every_slot_shaders_index_is_capped(GPU, paged host): a title heap ofHEAP_VIEWSslots is capped atPAGED_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 inHostHeap::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 (at6f8b588), 0 failed, 1 ignored, both with and withoutVICTORY_VIEW_PAGES=1. At979e3a7: 244 passed, 1 ignored withVICTORY_VIEW_PAGES=1; without it, 243 passed andviews_bound_while_another_slot_gets_its_texture_do_not_waitfailed, which fails on main on this card too. Clippy with and without--features diagnostics: 0 warnings.cargo xtask policyok.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_oncechecks when the line is logged.cargo test -p victory-gpu --lib: 246 passed, 0 failed, 1 ignored, both with and withoutVICTORY_VIEW_PAGES=1. Clippy with and without--features diagnostics: 0 warnings.cargo xtask policyok.Reclaiming (
cae596c,a12b972), on an NVIDIA card that pages automatically, and withVICTORY_VIEW_PAGES=1:descriptor::pagesunit tests (no GPU):gpu()handle, draw stamp);taken_backonly, pages refused room and placed later underrefusedonly, and a page taken back then refused room undertaken_back(6f8b588);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 throughtake_page_readsandturn_pagesplaces 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 bitsVIEW_PAGE_READS + 4296andVIEW_PAGE_READS + 0are set.cargo test -p victory-gpu --lib: 203 passed, 0 failed, both with and withoutVICTORY_VIEW_PAGES=1.cargo test -p victory-shader --lib: all pass excepta_heap_buffer_read_by_element_takes_the_views_strideandgathers_at_a_level_match_the_hardware, as before.dxil.dllisn't installed here, so the new DXIL was checked by pipeline creation on hardware and WARP, not by the validator.--features diagnostics: 0 warnings.cargo xtask policyok.Earlier:
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).memory::tests::a_submission_that_missed_leaves_the_copies_at_onceis paged the same way: itsWRITEshader 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_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
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 whatview heap pages unused lately taken back,view heap pages placed again(itstaken_back=against itsrefused=) and (if it still appears)no room left in the host view heapwill show. Whether the dynamic region can be smaller on paged hosts is what the largestpeak=ofview heap dynamic slots in usein 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
Shader::heap_handle, so they are paged too.a_submission_that_missed_leaves_the_copies_at_onceis adjusted for paging, as described under Testing.Rebased onto 842b0cb
view_addresses_cover_tables_made_afreshsits next to the paging tests indescriptor/host.rs(the paging tests move todescriptor/pages.rsin the last commit, as before). It passes on the RTX 5070 Ti, which pages.compute_view_marks_rebind_after_depth_twin_conversion(GPU: rebind compute view-mark root descriptors after depth-twin conversion #2155) translates withshader_cache::options(), which is how the runtime translates, instead of buildingOptionsitself.Optionsnow has theview_pagesfield.lower.rsis still under the 512 KiB policy limit.Rebased onto 63bcca4
README.md. No conflicts.