Skip to content

GPU: drop draws whose fresh tables cannot be made; 2^18 dynamic slots - #336

Merged
Marvisak merged 2 commits into
Marvisak:mainfrom
hophaver:fix/dynamic-descriptor-exhaustion
Nov 24, 2026
Merged

Marvisak merged 2 commits into
Marvisak:mainfrom
hophaver:fix/dynamic-descriptor-exhaustion

Conversation

@hophaver

@hophaver hophaver commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Refs #59.

Problem

On an RX 9070 XT (RDNA4), the world removes the device about 60 s after start. The fault addresses are 0x7000037xxxxx, 0x8000037xxxxx, 0x33c4000 or 0x2610000, and the faulting pipeline is different on every run. I skipped 16 faulting pipelines one after another (VICTORY_SKIP_PIPELINES, VICTORY_GPU_TIMING), and the fault just moved to another one each time.

Every run with diagnostics (13 of them) logs this 1 to 25 s before the device removal:

no free dynamic descriptor slots: a table is not made

When HostHeap::dynamic returns None, State::tables continues. The stage's user data then falls back to user_value, which is the title's table offset. CBV tables are always made fresh and never mirrored, so the shader reads whatever host descriptor sits at those title slots as a constant buffer. On AMD, a texture or null descriptor read as a buffer descriptor gives a wild base address.

Change

  • bind now returns false when a fresh table of a stage could not be made. The draw, mesh dispatch, dispatch or indirect execution is then dropped instead of reading the wrong descriptors. A warning is logged at powers of two.
  • DYNAMIC goes from 1 << 16 to 1 << 18.

Tested

Windows 11, RX 9070 XT, game_scarlett_master.exe v1.0.2.1, diag build, VICTORY_KEYS=15:Enter, VICTORY_D3D12_DRED=1.

  • Before: device removed about 60 s in, every run, always after the exhaustion warning.
  • After, on this branch alone (main d2a4bae + this commit): the world loads, no exhaustion warning, no draws dropped, and the 60 s removal is gone. That run was removed later, at about 134 s, with a different signature: page fault ... inside freed ["texture 1024x1024 f99 ..." (type 34)]. That is a texture used after its release, which this PR does not address.
  • With other local changes on top, one run stayed in the world for 6+ minutes (about 0.4 fps, mostly black from untranslated shaders).
  • cargo test -p victory-gpu passes, and so does cargo xtask policy.

I also tried these, and none of them stopped the 60 s removal on this card: bounding root SRVs/CBVs, clamping buffer views to the host copy, re-binding heaps after the indirect clamp, and #185.

When HostHeap::dynamic ran out, State::tables skipped the fresh table and
the stage's user data fell back to the title's table offset. Constant
buffer tables are always made fresh and never mirrored, so the shader read
whatever host descriptor sat at those slots as a constant buffer; on AMD a
texture or null descriptor read as a buffer gives a wild base address and
the device is removed (Marvisak#59: faults at 0x7000037xxxxx, 0x8000037xxxxx,
0x33c4000, a different pipeline every run, about 60 s in).

bind now reports that a table could not be made, and the draw, mesh
dispatch, dispatch or indirect execution is dropped. The dynamic range grows
from 2^16 to 2^18 slots, which the world did not exhaust on an RX 9070 XT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jimokulou2-ops

Copy link
Copy Markdown

Tested 3c81420 on a second RX 9070 XT. It reproduces the description's result: no exhaustion warning, and the world lasts more than twice as long. The later removal is the same freed-texture fault. Written by Claude Code (Claude Opus 5.5), which ran the commands and read the logs; I drove the pad into the world on my machine.

Setup: Windows 11 Pro 10.0.26300, AMD Ryzen 7 9700X, RX 9070 XT (RDNA4, Adrenalin 26.11.2 / 32.0.32029.2010), Rust 1.98.1, --profile diag --features diagnostics, VICTORY_D3D12_DRED=1, v1.0.2.1, Series X mode. Baseline: main d2a4bae + #197 (input only). PR: the same tree + 3c81420 (local merge, no conflicts). I entered the world by hand, the same way in every run, and left it alone until the device was removed.

build time in the world before removal no free dynamic descriptor slots removal
baseline, run 1 ~57 s yes, 14 s before page fault at 0x32a9000
baseline, run 2 < 6 s yes, 2 s before page fault at 0x600002635000
baseline + #124 (unrelated) ~23 s yes, 7 s before page fault at 0x2bd5000
+ 3c81420 ~136 s (24 five-second intervals) none page fault at 0x3bf4c8000 inside freed ["texture 1024x1024 f98 flags 0x0 (type 34)"]

So, as in the description:

  • The exhaustion warning came before every baseline removal and is gone with this PR.
  • The run ends later with a different signature: a freed texture is used, which the description reports at ~134 s as f99. Here it is format 98. The same log line also says view heap ... 0x2bc5d8000 past its end.

World frame times are about the same: on average 1508 ms/frame with this PR over 24 intervals, against ~1400 ms/frame for the baseline over 10. The time goes to CPU preparation as before.

Tests (d2a4bae + #197 + 3c81420, debug): cargo test --workspace --no-fail-fast: 265 passed, 0 failed, 4 ignored (the same as without this PR).

The new drop path logged nothing in this run. Its warning fires at powers of two, starting at 1, so no draw was dropped.

Not tested: more than one run with the PR; #135 alongside this PR (it keeps replaced resources longer, which may be what the freed-texture fault needs); NVIDIA / Intel.

@tcurtsinger

Copy link
Copy Markdown

One measurement for the capped NVIDIA heap. On our RTX 4080 the 65,536-slot dynamic region had 136 slots free when a ten-slot request failed. The longest contiguous span was nine. That run used #135 and #251. Run report.

At the 1,000,000-descriptor host cap, this PR's 262,144-slot reserve leaves 737,856 slots mirrored directly, down from 934,464. That makes high-index tables worth covering when testing the larger reserve. A 4090 tester saw table references as high as slot 917,140, with null entries in that capture. Our 4080 run did not record its highest referenced slot or measure this split. RTX 4090 observations.

@GamingRipperDoc

Copy link
Copy Markdown

Windows 10 data point on a third RX 9070 XT: same result as the description, and one detail about the later freed-texture fault.

Setup: Windows 10 22H2 19045.7846, RX 9070 XT (driver 32.0.32015.7029), Ryzen 9 9900X. main d2a4bae + #175 (Agility SDK, needed on Windows 10) + this PR (3c81420), diag build, VICTORY_D3D12_DRED=1, Series X mode, driven with a pad into the first mission.

Before (d2a4bae + #175 only), 3 runs: the world lasted 38 s, 10 s and 8 s, and every run logged no free dynamic descriptor slots: a table is not made about 1 s before the device was removed (faults 0x2527000, 0x7000037a5000, 0x7000037a7000; details on #304).

After (+ this PR), 1 run: no exhaustion warning; the world lasted about 145 s, at 0.4–1.4 fps (1,000–2,500 draws per second dropped, most for shaders that don't translate yet). Then:

host GPU device removed after a submission of 7 lists; page fault at 0x408da3000;
inside freed ["texture 2048x512 f98 …", "texture 1024x1024 f98 …", "texture 2048x2048 f98 …", …];
the nearest title memory copy below it: 0xb92400000+0x400000 at host 0x408900000, offset 0x4a3000 …
a list stopped at command 216 of 1266 (op 42): mesh 1 [mesh 38ad582f523fd7cf, pixel d42a2d8a9d2c954a]
  | 38ad582f523fd7cf: … root3=0xb925e6000 host Some((0x408ae6000, 0x21a000))

The detail: the mesh draw on the GPU at the stop reads its vertex data through root SRV root3 (title 0xb925e6000). Its host copy is at 0x408ae6000 with 0x21a000 bytes left, which is exactly the end of that 4 MB title memory copy (0xb92400000+0x400000 ends at title 0xb92800000, host 0x408d00000). The fault is 0xa3000 past that end, in the gap before the next copy (host 0x409280000), where textures used to be. Root SRVs aren't bounds-checked, and vertex fetch reads them with no record limit, so this would fit a mesh shader reading its vertex stream past the end of the copied range: on the console the title's memory just continues there; on the host the next bytes belong to something else. That would make the "freed texture" only where the read happened to land, not the cause. One run, so this is a lead, not a result; it's the only in-flight draw reading from that copy.

No game data used.

AI-assisted (Claude Code); I played the runs, and the logs were read with the model.

A host that refuses the title's slots plus 2^18 dynamic ones (NVIDIA's
1,000,000-view cap) now gets 2^16 dynamic slots, as before, instead of
losing mirrored title slots to the larger range: at the cap, 2^18 left
737,856 title slots against 934,464, and titles were seen to index slots
up to 917,140. The cap itself is unchanged. Hosts that take the larger
heap (RX 9070 XT) keep 2^18.
@hophaver

hophaver commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Pushed e8d3b64 for the capped-heap case @tcurtsinger raised: the 2^18 dynamic range is now used only when the host takes the title's slots plus 2^18. Otherwise the heap falls back to 2^16 dynamic slots (the old size) before the existing 1,000,000 cap applies, so a capped NVIDIA heap mirrors the same 934,464 title slots as before this PR. The RX 9070 XT still gets 2^18. cargo test -p victory-gpu passes.

On the later freed-texture fault, @GamingRipperDoc's reading matches what I saw: a local build that binds root SRVs as one-view tables bounded to the end of the host copy (reads past it return zero instead of faulting) ran 6+ minutes in the world without that removal.

@upipibi upipibi mentioned this pull request Nov 24, 2026
Ludacris897 added a commit to Ludacris897/VIctory that referenced this pull request Nov 24, 2026
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
…t run short

A list kept the dynamic slots of its fresh tables until the title reset
it, because the title may submit it again. Submissions are waited for, so
those slots hold nothing the GPU still reads: on NVIDIA's capped heap
(65,536 dynamic slots) frames already drawn held them, the frame being
recorded found none free seconds into the world (4 of 4 runs on an RTX
4060 Ti), and its tables were not made. Before #336 such draws read the
title's slots past the heap's end and the device hung 30 to 90 s later;
since #336 they are dropped, world draws and the compute passes that feed
them alike.

After a submission each list lends its slots; a heap that runs short
takes them back, oldest list first. A list submitted again gets them back
first, or, if they were taken, is not run (warned once) until reset. The
5-second slot line also counts the slots taken back, the draws and
dispatches dropped for their tables, and the lists not run.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
aycow pushed a commit to aycow/VIctory that referenced this pull request Nov 24, 2026
Three conflicts:
- descriptor.rs: main (Marvisak#365) publishes the host heap only after replaying
  pending writes; Marvisak#185 stores it as an Arc. Main's order, wrapped in Arc.
- draw.rs: main (Marvisak#336) makes bind() return false when a table cannot be
  made; Marvisak#185 makes it pub(crate) for its tests. Both.
- host.rs: main (Marvisak#87) and Marvisak#185 both fixed the copy statistics' frame
  denominator (copy_stats_frames vs diagnostic_frames). Main's kept,
  Marvisak#185's duplicate counter removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PastiiJay pushed a commit to PastiiJay/klbf-lab-beta that referenced this pull request Nov 24, 2026
…heap runs short

Stacked on Marvisak#336.

A list keeps the dynamic slots its draws took until the title resets it.
Every submission is waited for, so once a list has run the GPU no longer
reads them, but a capped view heap (NVIDIA: 1,000,000 slots, 65,536 of them
dynamic) is full within seconds of the world and every later table is
refused: the draw or dispatch is dropped (Marvisak#336 drops it instead of reading
the title's slots).

When `HostHeap::dynamic` has no room, `State::take_dynamic` now takes back
the slots of the oldest list that already ran (`descriptor::lease`), one
list at a time, and retries. That list is marked lost; submitting it again
without a reset is refused (its draws are dropped, as a table that could not
be made already drops one) and it works again once the title resets it. A
list is not taken back while it runs: `start` and `reclaim` share one lock.
Nothing changes while the heap has room.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
edsuuu referenced this pull request in edsuuu/VI-BR-PORT Nov 24, 2026
The tester tree (upstream main ffe310e plus its PRs, update 8; see its
INTEGRATION.md) ran 11-25 minutes in the world on an RTX 5070 without a
device removal. Where both sides carry the same PR (the wave64 stack
#223/#233/#320 with #439 and #180, #454, #336, #259, #331 and others), the
tester tree's newer head is taken; our own work and the PRs only we
merged are kept.

Conflicts, file by file:

- descriptor/host.rs: the tester layout (`spare`, the guard slot after the
  dynamic slots, `free_table`, the capped sampler heap). A capped view
  heap keeps `capped_reserve()` dynamic slots, now 2^18 by default (the
  tester measurement, and our 91fed158), still `VICTORY_DYNAMIC_SLOTS` in
  diagnostics builds; uncapped hosts keep our 2^19. Our slot statistics
  (TAKEN/PEAK/SHORT), the bindless plan cache (`CommittedRegions`,
  `timed_valid_title_address`, `timed_find`, `title_bounds`) and the
  revision triple are kept beside the tester's `guard_slot`.
- Buffer states: the tester tree's buffer-state tracker (#334: every list
  moves host copies of title memory between GENERIC_READ and
  UNORDERED_ACCESS and back to common before it closes) and depth twins
  (#469) are taken. #40's enhanced/legacy indirect barriers (the indirect
  prelude, `use_indirect_buffers`, the title buffer handoff mirrored in
  `host_barrier`) cannot share buffers with that tracker and are dropped;
  #40's argument checks (`byte_len`, exact spans, overflow-safe clamp
  shader, aligned counts) stay. `indirect::bound` and #282's
  `rectangles` go through `buffer_state`, and `indirect::execute` (#334)
  replaces `done`. #178's DXC fallback compiles both of our passes.
  Our segments (#387: `close` ends the segment, `close_native` closes a
  native list) carry the tracker: each native list returns its buffers
  to common and its twins to their depth targets, and each prelude also
  holds our texture uploads.
- shadow.rs: our write flow (`queue_write`, one `snapshot` after the
  batch's refreshes, `finish_writes`, the unchanged-page cache) with
  #261's copy-back that also gives the snapshot the title's bytes; its
  tests run through our flow.
- pipeline/make.rs: #275's per-frame budget and per-pipeline wake pair,
  with our compute waits (a dispatch waits for its pipeline, up to 20 s).
- pipeline/library.rs: the tester version (#347, #275's saver thread);
  our concurrent-write test kept. shader_cache.rs: our byte-returning
  cache API with #358's "translated, only not kept".
- draw.rs: #493's root SRV tables; where no table can stand in, our
  drop of a draw whose root view is unset or outside title buffers. Our
  refusal of a table offset past the capped heap stays.
- resource.rs: `HostTexture` has both our `staged` generation and the
  depth twin.
- Shaders: the tester's lower.rs for the wave64 stack, #160's image
  sampling (it covers our #73 and #136 sample forms) and #453/#587; kept
  from our side: #136's preference for an image or buffer use of a
  descriptor read as data and its `s_buffer_` arm, #422's nearest-even
  narrowing (also for #169's d16 loads and #453's interpolation), #452's
  spin-wait limit, #391's LDS limit, #302's spilled root arguments (now in
  `NativeProgram::translation_ir`), #136's PSV0 interpolation beside the
  tester's row harmonisation. split_tests.rs, lane_read_loop_tests.rs and
  docs/wave64-on-wave32.md are the tester versions (the same PRs at newer
  heads).
- Tests: #483's heap guard dwords filled in our GPU tests of #200
  (v_div_scale) and #437 (scalar loads from a raw view), which read
  through the guard slot otherwise; #334's debug-layer test passes an
  offset to our `indirect::bound`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
GPU: drop draws whose fresh tables cannot be made; 2^18 dynamic slots
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
main moved under #193 and this branch. One conflict, in
HostHeap::new (descriptor/host.rs): #336 tries the heap with DYNAMIC
dynamic slots, then with MIN_DYNAMIC, then capped, and records the range it
got in `dynamic`; this branch puts ALIASES raw-view slots after the dynamic
ones. Both kept: each attempt asks for the alias slots too, the capped
count leaves room for them, the lease bitmap has `extra` entries as on
main, and `alias_base` stays `count + extra`. A merge rather than a rebase
so #193's commits keep their ids.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
#193 moved: buffer views are clamped to what is left of the host copy, a
shader that reads the stride table without a host view heap is not run,
and a known stride that is no multiple of four is refused. Conflicts were
with main, not with this branch's change: `bind` already returns whether
the draw may run (#336), with its doc comment and the dropped counter, and
main already renamed the second test module in host.rs. main's side kept
in all three; #193's `return false` in the stride-table branch is in.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
suirentakamura referenced this pull request in suirentakamura/victory-suiren Nov 24, 2026
…heap runs short

A list keeps the dynamic slots its draws took until the title resets it.
Every submission is waited for, so once a list has run the GPU no longer
reads them, but a capped view heap (NVIDIA: 1,000,000 slots, 65,536 of them
dynamic) is full within seconds of the world and every later table is
refused: the draw or dispatch is dropped (#336 drops it instead of reading
the title's slots).

When `HostHeap::dynamic` has no room, `State::take_dynamic` now takes back
the slots of the oldest list that already ran (`descriptor::lease`), one
list at a time, and retries. That list is marked lost; submitting it again
without a reset is refused (its draws are dropped, as a table that could not
be made already drops one) and it works again once the title resets it. A
list is not taken back while it runs: `start` and `reclaim` share one lock.
Nothing changes while the heap has room.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
This was referenced Nov 24, 2026
itsonlysimbo pushed a commit to itsonlysimbo/VIctory that referenced this pull request Nov 24, 2026
…exhaustion

GPU: drop draws whose fresh tables cannot be made; 2^18 dynamic slots
PastiiJay pushed a commit to PastiiJay/klbf-lab-beta that referenced this pull request Nov 25, 2026
…heap runs short

Stacked on Marvisak#336.

A list keeps the dynamic slots its draws took until the title resets it.
Every submission is waited for, so once a list has run the GPU no longer
reads them, but a capped view heap (NVIDIA: 1,000,000 slots, 65,536 of them
dynamic) is full within seconds of the world and every later table is
refused: the draw or dispatch is dropped (Marvisak#336 drops it instead of reading
the title's slots).

When `HostHeap::dynamic` has no room, `State::take_dynamic` now takes back
the slots of the oldest list that already ran (`descriptor::lease`), one
list at a time, and retries. That list is marked lost; submitting it again
without a reset is refused (its draws are dropped, as a table that could not
be made already drops one) and it works again once the title resets it. A
list is not taken back while it runs: `start` and `reclaim` share one lock.
Nothing changes while the heap has room.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
iurysf pushed a commit to iurysf/VIctory that referenced this pull request Nov 25, 2026
…heap runs short

A list keeps the dynamic slots its draws took until the title resets it.
Every submission is waited for, so once a list has run the GPU no longer
reads them, but a capped view heap (NVIDIA: 1,000,000 slots, 65,536 of them
dynamic) is full within seconds of the world and every later table is
refused: the draw or dispatch is dropped (Marvisak#336 drops it instead of reading
the title's slots).

When `HostHeap::dynamic` has no room, `State::take_dynamic` now takes back
the slots of the oldest list that already ran (`descriptor::lease`), one
list at a time, and retries. That list is marked lost; submitting it again
without a reset is refused (its draws are dropped, as a table that could not
be made already drops one) and it works again once the title resets it. A
list is not taken back while it runs: `start` and `reclaim` share one lock.
Nothing changes while the heap has room.

Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants