gpu: remap title view slots past capped host heaps #3518
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3518"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-11-27T12:27:12Z.
Hosts whose shader-visible CBV/SRV/UAV heaps stop at 1,000,000 descriptors (resource binding tier 2, e.g. NVIDIA) lost every title descriptor past the cap (the old
shortcut: descriptors past the host's limit are left out).What changes
Hostdetects a capped device once (aHEAP_VIEWSshader-visible heap fails;VICTORY_CAPPED_HEAP=1forces it).HostHeapon such hosts keeps 672,320 title slots 1:1 and maps active higher title slots into 262,144 physical overflow slots (LIFO free list, recycled when the title clears a slot). Strides, view marks, view addresses, read marks and deferred placed textures (make_read) all follow the physical slot.emit::Options::capped_heap: direct resource-heap indices (root type 5) go through a virtual→physical table, root SRVt254in the root CBV space (next toVIEW_STRIDES; noHostShaderfield or cache-format change), and heap indices / null buffer views clamp below 1,000,000. Uncapped hosts translate exactly as before.Tests (RTX 4070 + WARP)
emit::remap_tests: compute shader reading/writing at virtual heap slots 1,150,000 / 1,500,000 through the remap table; unmapped slot reads the null view.descriptor::host::remap_test: 1,245,184-slot title heap: overflow allocation, placed texture materialised through its physical slot, clear + reuse.diagnostics) andcargo xtask policyclean. (The fullvictory-shaderlib suite crashes locally indxil.dllvalidation onorigin/maintoo.)Imported from Marvisak/VIctory. Originally posted by oni-swr on 2026-11-27T13:25:54Z.
Independent WARP/CPU verification of #3518 at head
df88467b(base: main63bcca43, merge-base of this PR). Head re-checked unchanged just before posting.Setup: Windows 11 Pro 10.0.26200, AMD Ryzen 7 5700X3D, D3D12 WARP only (
VICTORY_WARP=1 VICTORY_D3D12_WARP=1, dxil.dll from the Windows SDK on PATH). Base and head were built in separate worktrees with separate target dirs, so the head binary is a fresh build. Test commands:cargo test -p victory-gpu --features diagnosticsandcargo test -p victory-shader --features diagnostics. Note thatvictory-gpuonly honoursVICTORY_D3D12_WARPwith--features diagnostics; without it the tests use the real adapter.VICTORY_CAPPED_HEAP=1The 4 victory-shader failures are the same set on both sides (
a_mask_joined_with_data_at_a_uniform_loop_is_its_number,gathers_at_a_level_match_the_hardware,permutes_mask_high_address_bits_and_divergent_branches,permutes_read_the_lane_named_and_zero_from_lanes_left_out), so they are baseline WARP lane failures, not caused by this PR. The two new tests pass:remapped_high_heap_indices_execute_above_portable_views_limitin victory-shader, andcapped_view_heap_remaps_high_slots_and_recycles_overflow_entriesin victory-gpu.Finding 1 (CI will fail): clippy
-D warningsfails on dead code.cargo clippy -p victory-shader --features diagnostics --all-targets -- -D warningsfails on the head and passes on base:emit_withnow callslower_with, so the non-test build has no caller forlower(only tests use it). CI runscargo clippy --workspace --all-targets --locked -- -D warnings, so it should fail there too. Fix: markloweras#[cfg(test)], or move it into the test modules.cargo clippy -p victory-gpupasses on the head.Finding 2 (test coverage): the victory-gpu cap test only runs the cap logic on a capped host.
descriptor/remap_test.rs:14returns early when!host.capped_heap. On WARP that flag only becomes true when the 2^21-slot probe heap fails to create, or whenVICTORY_CAPPED_HEAP=1is set. The test passes in the capped lane, where its asserts oncount,overflowanddynamicrun. A plain WARP run may therefore skip the body. Running CI-style lanes withVICTORY_CAPPED_HEAP=1would prevent a silent no-op. The victory-shader test does exercise the clamp and null-slot path on WARP, because the remap table is supplied directly.Diff review for the question "can remapped slots alias or index out of range": I found no bug.
direct..direct+OVERFLOW_VIEWS(direct = 1,000,000 - 65,536 - 262,144). Dynamic slots start above that, andNULL_RESERVEplus the null views stay at the top. The ranges are disjoint, andkept,strides,marksandaddressesare all sized tocount + overflow + dynamic.to_phys/to_titlepair kept under oneslotsmutex.write_remapis only called under that lock, so a slot cannot map to two titles. A freed slot resets itsremapentry toCAPPED_HEAP_VIEWS - 1(null).REMAP_VIEWS - 1before the table read, and the physical result clamps toheap_views - 1.AI-assisted: Claude Code, Claude Sonnet 5.5 (build/test orchestration and diff review; results above are from the actual runs).
Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-27T13:48:20Z.
Linux/Wine verification of exact head
df88467(base63bcca43), clean worktree. RTX 4060 Laptop 8 GiB (resource binding tier 2), NVIDIA 590.48.1, Wine 11.0, vkd3d-proton 3.2.0 diagnostic build2576c0b4adfae4a+(relaxed-vtable; not stock certification), DXVK vendor masking disabled. No title run.Leg 1 —
descriptor::host::remap_test::capped_view_heap_remaps_high_slots_and_recycles_overflow_entries1/1 pass (fresh 9.36 s compile, 0.74 s test;verify-pr3518-descriptor-natural-df88467-20261127T134719Z). Two silent-skip paths were made fail-closed for this run only (absent host panics;host.capped_heapprinted) and the source was restored afterwards: natural capped detection fires on this stack — the 1,000,000HEAP_VIEWSshader-visible heap creation fails andhost.capped_heap=truewithoutVICTORY_CAPPED_HEAP. Full body executed on the real adapter: 1,245,184-slot title heap; high slots 737,856 / 950,000 / 1,200,000 each mapped into the 262,144-slot overflow pool with correct stride/address/read state; placed texture at 1,210,000 deferred onmirror(false)and materialized through its physical overflow slot bymake_read; clear resets the virtual entry toCAPPED_HEAP_VIEWS - 1and returns the physical slot; next high slot reuses it (LIFO). No device removal.Leg 2 —
emit::remap_tests::remapped_high_heap_indices_execute_above_portable_views_limit1/1 pass (fresh 5.91 s compile, 1.31 s test;verify-pr3518-emit-remap-df88467-20261127T134738Z). Same fail-closed strengthening applied and restored. Both hardware legs created the remapped compute PSO and dispatched: virtual slot 1,150,000 read back[101, 202, 303, 404]through the remap table, unmapped virtual slot 1,800,000 read back zeros via the null view. Caveat: thewarp=trueleg is not real WARP here — Wine'sEnumWarpAdapterreturns the first hardware adapter, so it is a repeat NVIDIA leg, and theWARP must be availableassertion was unchanged.Scale context from this machine's title trials (context, not a matched measurement): a previous guarded run on a different stack measured
room=737853 views=1000000with 507,331title slot past the host heapevents, so a frame can plausibly want more than 262,144 simultaneously-live past-cap slots. The exhaustion path (descriptor/host.rs:983-993) warns once and returnsNone— the slot reads null, i.e. the pre-PR behavior — so degradation beyond the pool is bounded and observable via thehost view heap overflow slots exhaustedwarning. If title logs on tier-2 hosts show that warning, it would indicate the 1 << 18 pool needs to grow or spill to a second heap.Test-only probes restored; worktree left clean at the exact head. Evidence dirs and per-run
resources.jsonlunder.compat-runtime/logs/. Guarded scope: peak GPU 250 MiB, min available RAM 10,828 MiB, min disk 15.19 GiB. No gameplay, frame-time or black-frame claim — this PR removes the past-cap data loss, it does not establish that capped-heap nulls caused the black scene.AI-assisted verification, review-only; no direct PR contributions.
Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-27T14:04:41Z.
Review: COMMENTED
UsedResource::lower_boundis used as a descriptor count, but it is the shader register (native.rs:416: "Shader register of the first descriptor read"; the FSPX test there readsu11at offset0x58withlower_bound: 11). Two places indraw.rsnow depend on the register number:draw.rs:1279:span = lower_bound - 1movesendforward byregister - 1slots. An entry whose own slot is belowhost.count()is still markedfresh(made again in dynamic slots on every draw) when its register is high, which uses up dynamic slots a capped host has few of.draw.rs:1318:n = offset / 8 + lower_bound. For thatu11entry,maincopies 12 records and this copies 22. In general it copiesregister - 1extra records past the last one the shader reads.Nothing in
UsedResourcegives a range's length, somain'soffset / 8 + 1is what's known. Suggested fix: go back tomain's two expressions in one helper used by both places, and add a test:with
let end = table + u64::from(u.table_offset_dwords) * 4;and.map(entry_slots). If the remap needs ranges longer than one record (arrays), that needs a count from the program's resource table, not the register.Imported from Marvisak/VIctory. Originally posted by pickles976 on 2026-11-27T14:16:30Z.
Follow-up title-path evidence on the same Wine/RTX 4060 Laptop host. This is not an exact PR-head run: local dirty integration = #3147
2eb38bb1+ #21014d8c89a+ this PRdf88467b, manually conflict-resolved to retain Wave64 lowering, format filtering, and capped-heap remapping. Relaxed-vtable diagnostic vkd3d build; unchanged 6,000 MiB GPU / 2,048 MiBMemAvailable/ 9 GiB scope guards.Before launch, the combined stack passed:
emit::wave64_tests: 11/11Fresh diagnostics release, reported 1920×1080, scripted A at 55 s. Run
20261127T141340Zstopped deliberately on the RAM guard at 88.31 s: 1,982.5 MiB available, 3,370 MiB GPU, 7,827.7 MiB scope (5,922.2 anon / 1,858.8 file including 1,837.9 shmem), 14.976 GiB disk, exit 137. The 45 s capture is the account picker; after A, DirectStorage openedshared_minigame000andstory000packs, but the 90 s capture missed the already-killed client. No recognizable 3D scene/gameplay or performance claim.Descriptor observation: the prior same-lineage run had 507,331
title slot past the host heapevents. With this PR integrated, the log has oneand zero old past-cap warnings, zero
host view heap overflow slots exhausted, and zero dynamic-slot-exhaustion warnings. So remapping is active on the title path and the pool did not visibly exhaust before the RAM stop. This does not establish that past-cap nulls caused the missing scene; 74 distinct compute translation refusals remain, and the log records two black-after-nonblack transitions.I also saw AurumCarlos's new
UsedResource::lower_boundreview. Absence of exhaustion in this bounded run does not clear that register-vs-count defect. I would not promote or repeat the title stack until those two range expressions are corrected and covered by the proposedu11test.Local evidence:
.compat-runtime/logs/20261127T141340Z-{console.log,resources.csv,guard-events.jsonl}, capturemenu-20261127T141425337179Z.png, focused logsverify-scene3147-pr2101-pr3518-{shader-remap,gpu-remap,wave64,packed-lighting}.log.AI-assisted verification; review-only, no code contribution.
Imported from Marvisak/VIctory. Originally posted by oddmaniv on 2026-11-27T14:22:52Z.
Independent verification of the PR author's concurrent WARP pipeline/draw test at
df88467bb8a9f97b1cb4f0a9da83ea5be335b074.cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocaptureMain baseline pin:
63bcca43c6a00a758510398fa43096ce7e4f7df0.Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.
AI-assisted verification.
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T16:19:02Z.
Numbers from a capped host that is not NVIDIA, in case they're useful for the body's "e.g. NVIDIA".
Intel Arc B580 12 GB, Windows 11 x64,
--console series-x. This device caps too, with the same error, and the title asks for more than one heap holds:In a single four-minute run through the prologue into the prison yard: 310,720
title slot past the host heapwarnings, one per newly-seen index, contiguous from 934,464 to the title's 1,245,183. That is 24.9 % of the title's view slots never bound — on this machine it is the class of failure behind missing textures, not a performance question at all.One interaction worth deciding before either merges, since you own both: on the same machine and the same tree, #3419's
capped_heap_slotsgiveskept=737856 extra=262144, i.e. refusals go 310,720 → 507,328 (it reserves 262,144 dynamic slots out of the same 1,000,000). #3518's own split is 672,320 1:1 plus a 262,144 overflow for title slots, so the two PRs put different arithmetic in the same place. If #3419 lands first, a capped host loses a further 196,608 title slots until this lands; if this lands first, #3419's sizing needs rewriting on top of it.If a run on this Arc at your head would help — bound/refused counts before and after, plus a screenshot of the yard — say the word and I'll do it. I'm not touching the code: the remap is yours.
AI use: Mistral Vibe (agent) — log counts on the machine above, no code.
Imported from Marvisak/VIctory. Originally posted by borosf on 2026-11-27T16:36:05Z.
Two things from the Arc, both reproducible: the red
check, and one bug in the remap.The failing test is not your logic — it is a race on frame.rs's globals.
frame::tests::waits_end_on_ticks_and_count_framesfails atframe.rs:231,left: 0, right: 1. Isolated, it passes 10/10 on your head (df88467) and 10/10 on its parent (63bcca4). In the full-p victory-gpu --libsuite it fails 2 of 8 runs on your head, and never in isolation. The counters it asserts on —FRAME,PRESENT_TICK,WAITS,LASTinframe.rs— are process-global, and yourdescriptor/remap_test.rstests make lists and frames on other test threads, so whichever runs alongside it moves the numbers. Astatic TEST_LOCKaround the frame tests, or reading only this thread's increments (the idiom #3224 just added forcopystat), would settle it. Worth saying: on this machine your head is cleaner than its parent, which fails 8/8 ondescriptor::host::tests::dynamic_slots_are_held_until_released(host.rs:2226) — your change fixes that one.The overflow pool runs out well before your title's space does. From a four-minute run through the prologue into the prison yard on the Arc:
Zero
title slot past the host heapwarnings — the remap does what it says, the old failure is gone. But the title's space reaches 1,245,183 and the pool is exhausted at 892,146, so roughly 353,000 high slots never map, now silently: recycled overflow is sized for the active set, and the active set here is larger than 262,144. Either the pool needs to grow out of the 1,000,000 budget the direct slots don't use, or exhaustion should log a rate-limited count of the slots it left unmapped rather than one line.AI use: Mistral Vibe (agent) — builds, suite runs and in-world log counts on Windows 11 x64, Intel Arc B580.
Imported from Marvisak/VIctory. Originally posted by Jishnuraj07 on 2026-11-27T18:18:37Z.
Verification on NVIDIA GeForce RTX 5060 8 GB (Blackwell), driver 32.0.16.2112, native Windows 11 Pro 10.0.26200, rustc 1.98.1 (MSVC). Head
df88467, basemain63bcca4. No game files; library tests only.main63bcca4df88467cargo clippy -p victory-gpu -p victory-shader --all-targets --locked -- -D warningscargo test -p victory-gpu --lib --lockedcargo test -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_indexmain(dynamic_slots_are_held_until_releasedathost.rs:2226,lists_share_a_table_and_copies_keep_their_viewsat "past the dynamic slots") pass here, and so does the newremap_test.mainfails with this PR.victory-shaderfailures are the same on both, with identical output:a_heap_buffer_read_by_element_takes_the_views_stride([101, 104, 107, …]),a_heap_buffer_read_where_no_buffer_view_is_reads_zeros("The parameter is incorrect") andgathers_at_a_level_match_the_hardware(lane 0). These are the ones in #3445. The second one uses the test host's own heap (emit/host.rs), notHostHeap, so this PR isn't expected to change it.heap_direct_texture_reads_mark_their_heap_indexis skipped because it crashes the test binary with0xc0000005onmaintoo (the zero-length root-constants pointer reported in #3445). Without the skip, the binary stops after 78 tests.No title run.
Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T03:56:00Z.
A sizing point for the capped branch (read from this head
df88467band another tree's notes; not run here).When the title's heap leaves no room for
MIN_DYNAMICon a 1,000,000 host, which is the case for the retail heap of a little over 1,000,000 views, this branch splits the heap into 672,320 direct slots, 262,144 overflow slots and 64,512 dynamic slots (descriptor/host.rs:229-240).mainthere gives 934,464 title slots and 65,536 dynamic ones.trustno1-coder/VIctory-NVIDIA has measured both sides of that split on capped NVIDIA hosts (its
descriptor/host.rs, the notes onDYNAMIC):main's own note onDYNAMIC(host.rs:94) says the same about 2^16 on an RX 9070 XT.On those numbers, this branch's 64,512 dynamic slots are the budget that ran out there. Only slots from 672,320 to about 720,000 (some 48,000) would go through the overflow table, so 262,144 overflow slots are far more than they need. Taking 2^18 dynamic slots out of the overflow pool, with the remap kept for title slots past that, would follow both measurements. One caveat: the 720,000 figure comes from one fork's sessions.
AI-assisted (Claude Code, Claude Opus 5.5 read this head and that tree's notes).
Imported from Marvisak/VIctory. Originally posted by omarsaifuddin on 2026-11-28T12:43:22Z.
Ran this on an RTX 3070 Ti (Windows 11) from the first boot screen into the prologue world: main
63bcca4+ #3226 + #2323 + #2885 + this PR. (This PR conflicts with #2885 indescriptor/host.rs,emit/lower.rsandemit/mod.rs; I merged by hand, keeping both sides, andvictory-gpuis 235/0.) The remap works: 0 "title slot past the host heap" warnings, no device removal, and the world load ran for 15 to 38 minutes in my runs without a crash. Two things in the diff cost it most of its draws, though.1.
State::tablessizes a fresh table with the shader register. main hastable_offset_dwords / 8 + 1; this PR hastable_offset_dwords / 8 + u.lower_bound.max(1), and the "reaches past the host heap" check useslower_bound - 1as a span too.UsedResource::lower_boundis the shader register of the descriptor (base_registerinRootParam; nothing in the emitter reads it as an extent, andmemory_tests.rsbuilds entries withlower_bound: kat table slotk). Added up with the entry offset, a table with 4 entries at offsets 0..3 gets n=108, 3 entries gets 71, and a single entry at offset 1 gets 278.Counted over 80,000 fresh tables on this stack: 8,579,260 dynamic slots taken for 361,283 entries used, about 24 times too many. The dynamic pool was full whenever the world started drawing (
used=261117 of=261120, longest free run 2, so it is exhaustion and not fragmentation), and roughly 70% of the dropped draws wereno dynamic slots for its tables/for root views: mostly indirect mesh draws, so the G-buffer-like targets stayed almost empty (flat grey) and the world came out mostly white.With the two lines back to
+ 1and a span of 0, same binary otherwise: 43.9M slots for 32.7M entries (1.34x) over 7.3M fresh tables, 0 failed dynamic requests, 0no dynamic slotsdrops, held slots 85k..175k of 261k instead of full, and the prologue prison yard (chain-link fence, guard tower, what looks like a figure behind the fence) is recognisable in the presented frame, still ghosted. Dropped draws: 1.4k after 15 minutes, against 12k after 20 minutes with the old sizing; most of what is left is root view offsets and refused shaders.2. On the capped path the dynamic pool is
MIN_DYNAMIC - NULL_RESERVE= 64,512 slots. The comment aboveDYNAMICsays 2^16 ran out seconds into the world on an RX 9070 XT. With the table sizes fixed it still peaked at 208,900 of 261,120 (2^18) here, so a capped host needs about the uncapped size. I used 2^18 dynamic, 410,176 direct and 327,680 overflow (in one run about 287k of the 606k direct slots were live at once; here the overflow pool reached its 327,680 limit and the exhausted warning fired once). I haven't checked that split on another card or title scene.I have not run it without the
+ 1change on a stack where the pools are the stock sizes, so I can't say how much of (1) alone the old sizes would have survived. Everything above is one card and one scene.Imported from Marvisak/VIctory. Originally posted by danielibabet on 2026-12-01T09:28:26Z.
Thanks @AurumCarlos, @upipibi, and @omarsaifuddin for the catch and measurements!
Updated on pr/capped-heap-remap:
Verified with cargo test -p victory-gpu descriptor::host::, draw::tests::a_table_entry, cargo test -p victory-shader remap_tests, cargo clippy --all-targets -- -D warnings, and cargo xtask policy.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.