Skip to content

GPU: view addresses for tables made afresh (dynamic slots) - #1906

Open
Slay326 wants to merge 2 commits into
Marvisak:mainfrom
Slay326:fix/view-addresses-dynamic-slots
Open

Slay326 wants to merge 2 commits into
Marvisak:mainfrom
Slay326:fix/view-addresses-dynamic-slots

Conversation

@Slay326

@Slay326 Slay326 commented Nov 25, 2026

Copy link
Copy Markdown

Problem

On an RTX 3070 the host view heap is capped at 1,000,000 descriptors (host view heap capped at 1000000 ... count=1245184), smaller than the title's. A table that reaches past the host heap is made afresh in the dynamic slots, and the shader gets that table's offset.

A shader that reads a view's address as data (HostHeap::view_addresses, e.g. the BVH builder's base) then indexes the view addresses at the fresh table's slots. That buffer had one entry per title slot only and is bound as a root view, which has no bounds. So the read went past the end of the buffer, and no address was ever entered for a dynamic slot.

A per-command fence diagnostic (local, not part of this PR) names the command that never finishes. It is the same indirect compute dispatch, with the same argument address, in two runs (one on main + #1763, one on main with a local format workaround instead of #1763):

fence-each: device removed, list stopped at command 18: indirect kind 2 max 1 at 0xd9358fe80 [compute f607780aa8e502d0] | f607780aa8e502d0: VIEWADDR entries=Some(934464) ... FRESH(root param, first heap index) [(1, 935376)]

The view-address buffer has 934,464 entries (1,000,000 minus 65,536 dynamic slots); the fresh table starts at slot 935,376.

Change

  • HostHeap::view_addresses has one entry per title slot and per dynamic slot (address_slots()); the dynamic ones start empty.
  • Every path that makes a dynamic slot writes its entry: make_at the view's address, make_null zero, and raw_view_at / raw_pair_at (our root views and view pairs) zero, so no entry of an earlier table stays. A slot given back keeps its entry until it is made again; every fresh table makes all of its slots. note_address ignores an index past the buffer.
  • State::bind creates the view addresses before the stage's tables are made, so a table made afresh in the same bind enters its addresses.
  • Test (second commit, synthetic only): descriptor::host::tests::view_addresses_cover_tables_made_afresh. It covers a dynamic slot's entry before and after make_at, its neighbour, the last dynamic slot, a slot given back, make_null, raw_view_at, raw_pair_at, and a write past the end. With the test and its helper address_at applied to main, it fails (not made yet: left None, right Some(0)); it passes with the change. It covers HostHeap only, not the State::bind part.

The buffer grows once by the dynamic slots (on this card from 934,464 to 1,000,000 entries, about 0.5 MB more).

Tested

Windows 11 (10.0.26200), RTX 3070 8 GB, driver 32.0.16.1088, Ryzen 7 7700, 32 GB. Title v1.0.2.1. VICTORY_KEYS sends Enter every 5 s from 15 s to 100 s, then every 10 s to 170 s; the world starts about 90 s in.

On this card main alone removes the device 12-14 s after start (B4G4R4A4 render targets and B5G5R5A1 typed UAVs, see #1753). All runs below therefore include #1763.

Before (main 70564ae + #1763):

Run Build and switches Result
1 diag, VICTORY_D3D12_DEBUG=1, VICTORY_D3D12_DRED=1 DXGI_ERROR_DEVICE_HUNG after 161 s
2 as 1, plus VICTORY_SHADER_LOOP_LIMIT=4096 DXGI_ERROR_DEVICE_HUNG after 118 s
3 diag with local diagnostics, VICTORY_DIAG_FENCE_EACH=1 DXGI_ERROR_DEVICE_HUNG after 123 s (the log line above)

After (main 70564ae + #1763 + this change):

Run Build and switches Result
4 diag, capture switches only no device removal; stopped by its 420 s time limit
5 release with diagnostics, earlier revision of this change (without the raw_view_at/raw_pair_at entries) no device removal; stopped at 420 s
6 release with diagnostics, this PR's head no device removal; stopped at 420 s

Before this change, removals on this card came 118-386 s in across several local bases, so 420 s runs are not a large margin; they are what I have.

  • cargo test -p victory-gpu: 77 passed, 2 failed, 1 ignored; with --features diagnostics 80 passed, 2 failed, 1 ignored. The two failures (descriptor::host::tests::dynamic_slots_are_held_until_released, memory::tests::lists_share_a_table_and_copies_keep_their_views) fail the same way on main on this card (NumDescriptors >= HEAP_VIEWS, past the dynamic slots).
  • cargo clippy --workspace --all-targets -- -D warnings: clean. cargo xtask policy: 174 files ok.

Not addressed

  • With this change alone the world on this card stays at about 0.07 fps: one compute dispatch per frame takes about 12 s, completes and does not remove the device. That is a separate problem (raw buffer loads through structured views read the wrong bytes on NVIDIA) and not part of this PR.
  • Only tested on one NVIDIA card. Hosts whose view heap holds the title's whole heap may never make these tables in the dynamic slots.

No game data is in this PR.

AI-assisted.

@xstraok

xstraok commented Nov 25, 2026

Copy link
Copy Markdown

Test report: RDNA4 on Linux (RADV/Proton). This fixes the world device loss I was hitting there too.

Tested

Merging

  • GPU: view addresses for tables made afresh (dynamic slots) #1906 conflicts with current main in crates/victory-gpu/src/descriptor/host.rs, against the view-mark table (marks, set_mark).
  • Keeping both sides works: every set_mark(...) stays, followed by this PR's note_address(...), and the field docs keep marks plus this PR's addresses text.

Not tested

  • Windows, NVIDIA.
  • Longer than about 3 min in the world.
  • The full test suite.

AI use

  • Claude Code (Claude Opus 5.5) ran the tests, found the fault with umr, and wrote this report.

@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 addresses for tables made afresh…: GPU table address fix. DRAFT — fine to iterate.

@mikoreal

Copy link
Copy Markdown

In-game on an RTX 5070 (Blackwell, 32-lane waves, view heap capped at 1,000,000): the removal this PR names is gone

NVIDIA GeForce RTX 5070, driver 32.0.16.1714, Windows 11 26200, Ryzen 5 7600X. diag build, VICTORY_D3D12_DRED=1. Tested c84cbaa merged onto VIctory-V2 main 15c28f6: upstream 70564ae plus the community PRs V2 carries. The merge had one conflict, a test added next to view_addresses_cover_tables_made_afresh; I kept both tests.

Before (V2 main, without this PR). The device was removed during the first cutscene after entering the world. DRED names the same command, shader and argument address as the description:

host view heap capped at 1000000 count=1245184
host GPU device removed after a submission of 7 lists; breadcrumbs ... "63/79 Some(6)"
a list stopped at command 63 of 79 (op 5), commands 62..64 between its barriers:
command 63 (op 5): indirect kind 2 max 1 at 0xd9358fe80 [compute f607780aa8e502d0] | f607780aa8e502d0: ... u5=0x1dda5e0 [rebuilt view table base 978223]

The table was rebuilt at slot 978,223, past the 934,464 title slots, in the dynamic slots the view addresses had no entry for.

After (with this PR). Same scene, same build flags. There was no device removal in 8½ minutes; the cutscene plays on past the point where it used to stop. The run ended in an out-of-commit abort, memory allocation of 570425344 bytes failed (#471), which is unrelated to this PR.

What still keeps that scene from looking right, for whoever picks it up next. None of it is in this PR's scope:

Tests on the merged branch, cargo test -p victory-gpu --lib --locked: 145 passed, 0 failed, 4 ignored. That includes view_addresses_cover_tables_made_afresh.

A table reaching past a host view heap smaller than the title's (NVIDIA: 1,000,000 slots) is made afresh in dynamic slots, and the shader gets that table's offset. A shader reading a view's address as data (e.g. the BVH builder's base) indexes the view addresses at the table's slots: past the buffer, which had an entry per title slot only, through a root view without bounds, and with no address entered there. The view addresses now have an entry per title and dynamic slot, entered whenever a dynamic slot is made: a view's address, zeros for a null view and for the raw views of ours that root views and host copies' view pairs put in dynamic slots, so no entry of an earlier table stays.
…slots

The test reads an entry only inside the view addresses' buffer (none past it, where the buffer had an entry per title slot only), checks the slot's entry before it is made, after, once it is given back (it stays until the slot is made again: every table made afresh makes all its slots) and once it is made null, checks that a root view and a host copy's view pair made in dynamic slots clear the entries an earlier table left there, and puts a mark past the last entry that a view address noted for a slot past the dynamic ones leaves as it is. It takes any heap size the host gives: a title heap of 4 slots has dynamic slots past it either way.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Reviewed at bcd0d3d, which now merges cleanly into main. HostHeap::view_addresses in crates/victory-gpu/src/descriptor/host.rs is bound as a root view, which has no bounds. Its buffer had entries for title slots only, while tables made afresh live in the dynamic slots after them. So on a host whose heap is smaller than the title's, a shader reading a view's address there read past the buffer.

The buffer is now sized by address_slots() (count + dynamic), and the dynamic entries start at zero. make_at, make_null, raw_view_at and raw_pair_at all write the slot's entry, and note_address ignores indices past the end. State::bind in draw.rs creates the buffer before the stage's tables, so entries for a table made in the same bind are not lost. The resolution keeps main's set_mark calls beside the new note_address calls. view_addresses_cover_tables_made_afresh covers the HostHeap side. Two other contributors' RTX 3070 / RTX 5080 runs back up the hang fix.

CI: passing.


Generated by Claude Code

@walterwallaceson

Copy link
Copy Markdown

In-game on an RTX 3070 (Ampere) on Windows 10, merged onto current main: the indirect dispatch this PR names no longer hangs, and the world runs 15 minutes without a removal.

Setup: RTX 3070 8 GB (32-lane waves, view heap capped at 1,000,000), driver 621.14, Windows 10 22H2 (19045). main 940d32f + #463 (Agility SDK runtime, needed on Windows 10) + #1775 + #1751. Diag build, VICTORY_SHADER_LOOP_LIMIT=4096. #1968's programs W and C skipped in both runs, since this PR is about A. 15-minute runs.

without this PR, A skipped with c84cbaa, A runs
end 15 min, no removal 15 min, no removal, no errors
A skipped first bound at frame 1502, runs to the end
slow submissions 18, slowest 844 ms 4, slowest 369 ms
world speed, end of run 0.7 fps 0.8 fps (up to 1.1)

Without this PR and with nothing skipped, the same stack hung within about 3 minutes, and DRED stopped at the same indirect kind 2 max 1 command and argument address as in your diagnostic (#1968).

The conflict with main is only in descriptor/host.rs. main added write marks in the same places this PR adds view-address entries, so each of the five hunks keeps both:

  • the struct gets main's marks field, then this PR's comment on addresses;
  • make_at calls self.set_mark(index, mark) and then self.note_address(index, Some(view));
  • raw_view_at, make_null and raw_pair_at call set_mark(…, None) and then note_address(…, None).

With that, cargo test --workspace gives the same results as without this PR (the failures are the known "no SM 6.6 device" skips, #362, and one texture test that also fails on main), and view_addresses_cover_tables_made_afresh passes.

I'm testing with Claude's help, and Claude drafted this comment.

@astrosteveo

Copy link
Copy Markdown

In case it saves you the rebase triage asked for: both commits on 940d32f, your authorship kept, https://github.com/astrosteveo/VIctory/tree/rebase/1906 (01ba70d). Each of the five hunks keeps both sides, as described above.

RTX 5080, driver 620.73.04, Wine 11.22: view_addresses_cover_tables_made_afresh passes, and fails if I size the table by count again. victory-gpu 139 passed, 5 failed (the 5 also fail on main here). MSVC-target clippy clean.

It also merges cleanly with #1779's rebase, with a capped-heap test of both: https://github.com/astrosteveo/VIctory/tree/test/1779-1906. Not tested: Windows, the title. AI-assisted (Claude).

@Slay326

Slay326 commented Nov 25, 2026

Copy link
Copy Markdown
Author

Rebased onto current main (940d32f); the head is now bcd0d3d. The fix itself is unchanged.

The only conflict was in descriptor/host.rs: main added write marks in the same places this PR adds view-address entries, so each of the five hunks keeps both sides:

  • the struct keeps main's marks field, followed by this PR's comment on addresses;
  • make_at calls self.set_mark(index, mark) and then self.note_address(index, Some(view));
  • raw_view_at, make_null and raw_pair_at call set_mark(…, None) and then note_address(…, None).

This is the same resolution as in the rebase offered above (01ba70d); the trees are identical.

On the rebased head (RTX 3070): cargo test -p victory-gpu gives 142 passed, 2 failed, the same two failures as on main on this card (dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views, both from the 1,000,000 view-heap cap), and view_addresses_cover_tables_made_afresh passes. cargo clippy --workspace --all-targets -- -D warnings is clean. The in-game runs in the description were on the earlier base; I have not repeated them on the rebased head.

Thanks to everyone who tested this: RX 9060 XT (Linux), RTX 5070 and RTX 3070.

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.

7 participants