GPU: drop a draw whose table found no dynamic slots; more dynamic slots #134

Closed
github-bot wants to merge 1 commit from gh-pr/134/head into gh-pr/134/base
Owner

@⁠gmehru on GitHub · 2026-11-24 00:50 UTC · original
gmehru:fix/dynamic-slot-exhaustion → main · +15 −2 · 2 files · 1 commits · closed without merging

Problem

With indirect execution on (35b054e), the world ends on a host GPU page fault at a low address within a minute:

host GPU device removed after a submission of 1 lists; page fault at 0x2c04000; no title memory copy below it; ...

In both runs where I saw it, this warning came about one second earlier:

no free dynamic descriptor slots: a table is not made n=9

The world's frames bind thousands of tables that hold constant buffers, each made afresh in the dynamic slots, and the 65,536 slots of a view heap run out. When HostHeap::dynamic returns None, State::tables skips the table but the draw still runs. bind then gives the shader the title's own table offset, so it indexes the title's slots for that table, which hold whatever was mirrored there and not what the shader expects.

Change

  • draw.rs: a draw, mesh dispatch, dispatch or indirect execution whose bind could not make a table is dropped instead of executed. It is counted with the other dropped draws.
  • descriptor/host.rs: dynamic slots per view heap go from 2^16 to 2^19, so the world's frames fit and those draws are not dropped in practice.

Testing

One machine: Windows 11, AMD RX 9070, diagnostics build with VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_DRED=1.

Build Result in the world
35b054e Two runs ended on the low-address page fault, about 10 s and 45 s after the world's first frame, each about a second after the warning above
35b054e + this change The warning did not appear; the world ran 4 min 54 s and ended on a different fault (a read inside a freed 512x512 texture, in a list of mesh dispatches)

Not tested in the game on current main: there the change applies cleanly and cargo build --profile diag -p victory --features diagnostics succeeds. The victory-gpu descriptor tests pass on 35b054e with the change. On main at 9aef3d9 the victory-gpu test target did not compile for me (mod tests is defined twice in host.rs), which this change does not touch.

Notes for review

  • The larger DYNAMIC has a cost on a host that caps view heaps at 1,000,000 views: fewer slots mirror the title's (475,712 instead of 934,464), so more tables go through the dynamic slots there. I have no NVIDIA card to measure it. Dropping the draw is the part that fixes the fault; the size is yours to set.
  • The low-address page fault in a comment on #59 (another AMD card, indirect execution on) looks like the same symptom. I have not verified that it is the same cause.
  • #20 changes the same failure path the other way: on exhaustion it keeps the mirrored path.
  • This does not fix the read inside a freed texture that ended the last run.

🤖 Generated with Claude Code

**@⁠gmehru** on GitHub · 2026-11-24 00:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/134) `gmehru:fix/dynamic-slot-exhaustion` → `main` · +15 −2 · 2 files · 1 commits · closed without merging ## Problem With indirect execution on (35b054e), the world ends on a host GPU page fault at a low address within a minute: ``` host GPU device removed after a submission of 1 lists; page fault at 0x2c04000; no title memory copy below it; ... ``` In both runs where I saw it, this warning came about one second earlier: ``` no free dynamic descriptor slots: a table is not made n=9 ``` The world's frames bind thousands of tables that hold constant buffers, each made afresh in the dynamic slots, and the 65,536 slots of a view heap run out. When `HostHeap::dynamic` returns `None`, `State::tables` skips the table but the draw still runs. `bind` then gives the shader the title's own table offset, so it indexes the title's slots for that table, which hold whatever was mirrored there and not what the shader expects. ## Change - `draw.rs`: a draw, mesh dispatch, dispatch or indirect execution whose bind could not make a table is dropped instead of executed. It is counted with the other dropped draws. - `descriptor/host.rs`: dynamic slots per view heap go from 2^16 to 2^19, so the world's frames fit and those draws are not dropped in practice. ## Testing One machine: Windows 11, AMD RX 9070, diagnostics build with `VICTORY_D3D12_DEBUG=1` and `VICTORY_D3D12_DRED=1`. | Build | Result in the world | |-------|---------------------| | 35b054e | Two runs ended on the low-address page fault, about 10 s and 45 s after the world's first frame, each about a second after the warning above | | 35b054e + this change | The warning did not appear; the world ran 4 min 54 s and ended on a different fault (a read inside a freed 512x512 texture, in a list of mesh dispatches) | Not tested in the game on current `main`: there the change applies cleanly and `cargo build --profile diag -p victory --features diagnostics` succeeds. The `victory-gpu` descriptor tests pass on 35b054e with the change. On `main` at 9aef3d9 the `victory-gpu` test target did not compile for me (`mod tests` is defined twice in `host.rs`), which this change does not touch. ## Notes for review - The larger `DYNAMIC` has a cost on a host that caps view heaps at 1,000,000 views: fewer slots mirror the title's (475,712 instead of 934,464), so more tables go through the dynamic slots there. I have no NVIDIA card to measure it. Dropping the draw is the part that fixes the fault; the size is yours to set. - The low-address page fault in a comment on #59 (another AMD card, indirect execution on) looks like the same symptom. I have not verified that it is the same cause. - #20 changes the same failure path the other way: on exhaustion it keeps the mirrored path. - This does not fix the read inside a freed texture that ended the last run. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
With indirect execution on, the world takes more dynamic descriptor
slots than a view heap has (65,536): a frame binds thousands of tables
holding constant buffers, each made afresh. When `HostHeap::dynamic`
found none, `State::tables` left the table unmade and the draw ran
anyway, its shaders indexing the title's own slots for that table.
Those hold whatever was mirrored there, not what the shader expects,
and the host GPU page-faulted at a low address about a second after
the "no free dynamic descriptor slots" warning (device removed,
DXGI_ERROR_DEVICE_HUNG).

- A draw, mesh dispatch, dispatch or indirect execution whose bind
  could not make a table is dropped, counted with the other dropped
  draws.
- Dynamic slots per view heap go from 2^16 to 2^19, so the world's
  frames fit. On a host that caps view heaps at 1,000,000 views this
  leaves fewer slots mirroring the title's (475,712 instead of
  934,464).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:51:38 +00:00
github-bot closed this pull request 2026-11-26 03:51:38 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 00:53 UTC · original

The test build does not compile, so nothing in this PR can be exercised yet:

error[E0428]: the name `tests` is defined multiple times
   --> crates/victory-gpu/src/host.rs:1974:1
     |
 252 | mod tests {
     | --------- previous definition of the module `tests` here
1974 | mod tests {
     | ^^^^^^^^^ `tests` redefined here

The library itself builds (cargo xwin build -p victory-gpu is fine); only cargo test / --workspace fails, on every platform. It looks like the new test module was appended after main gained one in host.rs (the adapter tests); the new tests need to live in the existing mod tests.

Once that is fixed I can run the GPU suite under Wine + vkd3d-proton as with the other PRs.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 00:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/134#issuecomment-7118545532) The **test build does not compile**, so nothing in this PR can be exercised yet: ``` error[E0428]: the name `tests` is defined multiple times --> crates/victory-gpu/src/host.rs:1974:1 | 252 | mod tests { | --------- previous definition of the module `tests` here 1974 | mod tests { | ^^^^^^^^^ `tests` redefined here ``` The library itself builds (`cargo xwin build -p victory-gpu` is fine); only `cargo test` / `--workspace` fails, on every platform. It looks like the new test module was appended after main gained one in `host.rs` (the adapter tests); the new tests need to live in the existing `mod tests`. Once that is fixed I can run the GPU suite under Wine + vkd3d-proton as with the other PRs. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:05 UTC · original

Re-checked the new head 6d8d197 (after the force-push from 7831e92): still the same E0428, unchanged:

error[E0428]: the name `tests` is defined multiple times
    --> crates/victory-gpu/src/host.rs:1974:1
 252 | mod tests { ... }
1974 | mod tests { ... }

So the test target still does not compile and the GPU suite cannot run. Moving the new tests into the existing mod tests is the blocker.

No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).

**@⁠DaviTostes** on GitHub · 2026-11-24 01:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/134#issuecomment-7118737720) Re-checked the new head `6d8d197` (after the force-push from `7831e92`): still the same **E0428**, unchanged: ``` error[E0428]: the name `tests` is defined multiple times --> crates/victory-gpu/src/host.rs:1974:1 252 | mod tests { ... } 1974 | mod tests { ... } ``` So the test target still does not compile and the GPU suite cannot run. Moving the new tests into the existing `mod tests` is the blocker. No game data used. AI-assisted (DeepSeek V4.1 Flash coding agent).
Author
Owner

@⁠Sunkiller-qc on GitHub · 2026-11-24 01:05 UTC · original

Raising DYNAMIC to 1 << 19 (crates/victory-gpu/src/descriptor/host.rs:65) also changes the capped path at host.rs:94: on NVIDIA, where the view heap is capped at PORTABLE_VIEWS, the title keeps 1_000_000 - 524_288 = 475_712 slots instead of 934_464 today. A title heap that fit before then loses about half of its slots on the cards from #11/#16.

#135 makes the same change but keeps DYNAMIC_CAPPED = 1 << 16 for the capped heap, and it also drops the draw when no dynamic slots are left. The two conflict, so it may be simpler to continue in #135, or to add a capped value here.

Static review, not built or run.

**@⁠Sunkiller-qc** on GitHub · 2026-11-24 01:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/134#issuecomment-7118748809) Raising `DYNAMIC` to `1 << 19` (`crates/victory-gpu/src/descriptor/host.rs:65`) also changes the capped path at `host.rs:94`: on NVIDIA, where the view heap is capped at `PORTABLE_VIEWS`, the title keeps `1_000_000 - 524_288 = 475_712` slots instead of `934_464` today. A title heap that fit before then loses about half of its slots on the cards from #11/#16. #135 makes the same change but keeps `DYNAMIC_CAPPED = 1 << 16` for the capped heap, and it also drops the draw when no dynamic slots are left. The two conflict, so it may be simpler to continue in #135, or to add a capped value here. Static review, not built or run.
Author
Owner

@⁠gmehru on GitHub · 2026-11-24 02:01 UTC · original

Closing this in favour of #135, which makes the same two changes, keeps the smaller reserve when the host caps the view heap (the NVIDIA concern raised above), and also defers releasing replaced host resources.

On the test build: the E0428 reported above came from main, not from this PR, which adds no tests. mod tests was defined twice in src/host.rs at 9aef3d9, as the description says, and #129 has since fixed it. On main at d2a4bae with this change applied, cargo test -p victory-gpu passes (43 passed, 1 ignored).

Runs on main at d2a4bae, in case they help with #135. One machine: Windows 11, AMD RX 9070, diagnostics build with VICTORY_D3D12_DEBUG=1 and VICTORY_D3D12_DRED=1.

Build Time in the world How it ended
d2a4bae about 57 s Page fault at an address outside every allocation, 1.7 s after no free dynamic descriptor slots: a table is not made
d2a4bae + this PR 3 min 45 s The warning did not appear. Page fault inside a freed 1024x1024 texture, in a list stopped at an indirect execution
d2a4bae + this PR + released host textures kept 4 more frames (a local experiment, the same idea as the deferral in #135) 8 min 05 s No page fault. Device hung after one submission took 3.4 s on the GPU, stopped at a DispatchMesh

A second run of the last build, which skipped the intro and reached a heavier scene, ended the same way after one submission took 4.0 s. In both, the GPU had been taking 60 to 70 ms per frame until that submission, so it looks like one mesh dispatch running away rather than a slow frame. That is the failure left on this machine once the slots and the freed textures are dealt with.

No game data used. AI-assisted.

**@⁠gmehru** on GitHub · 2026-11-24 02:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/134#issuecomment-7119681192) Closing this in favour of #135, which makes the same two changes, keeps the smaller reserve when the host caps the view heap (the NVIDIA concern raised above), and also defers releasing replaced host resources. On the test build: the `E0428` reported above came from `main`, not from this PR, which adds no tests. `mod tests` was defined twice in `src/host.rs` at 9aef3d9, as the description says, and #129 has since fixed it. On `main` at d2a4bae with this change applied, `cargo test -p victory-gpu` passes (43 passed, 1 ignored). Runs on `main` at d2a4bae, in case they help with #135. One machine: Windows 11, AMD RX 9070, diagnostics build with `VICTORY_D3D12_DEBUG=1` and `VICTORY_D3D12_DRED=1`. | Build | Time in the world | How it ended | |-------|-------------------|--------------| | d2a4bae | about 57 s | Page fault at an address outside every allocation, 1.7 s after `no free dynamic descriptor slots: a table is not made` | | d2a4bae + this PR | 3 min 45 s | The warning did not appear. Page fault inside a freed 1024x1024 texture, in a list stopped at an indirect execution | | d2a4bae + this PR + released host textures kept 4 more frames (a local experiment, the same idea as the deferral in #135) | 8 min 05 s | No page fault. Device hung after one submission took 3.4 s on the GPU, stopped at a `DispatchMesh` | A second run of the last build, which skipped the intro and reached a heavier scene, ended the same way after one submission took 4.0 s. In both, the GPU had been taking 60 to 70 ms per frame until that submission, so it looks like one mesh dispatch running away rather than a slow frame. That is the failure left on this machine once the slots and the freed textures are dealt with. No game data used. AI-assisted.
Author
Owner

@⁠miniongk on GitHub · 2026-11-24 02:09 UTC · original

Tested head 6d8d197 rebased onto d2a4bae on Windows 11 26300, RTX 5080, driver 621.24, local 1.0.2.1 copy. The no free dynamic descriptor slots warning no longer appeared, but the world still removed the host device with DXGI_ERROR_DEVICE_HUNG during a mesh/indirect submission. This patch is not sufficient for #97 on NVIDIA. Menus and first-boot rendering remained stable. AI-assisted (Kimi Code).

**@⁠miniongk** on GitHub · 2026-11-24 02:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/134#issuecomment-7119808580) Tested head `6d8d197` rebased onto `d2a4bae` on Windows 11 26300, RTX 5080, driver 621.24, local 1.0.2.1 copy. The `no free dynamic descriptor slots` warning no longer appeared, but the world still removed the host device with `DXGI_ERROR_DEVICE_HUNG` during a mesh/indirect submission. This patch is not sufficient for #97 on NVIDIA. Menus and first-boot rendering remained stable. AI-assisted (Kimi Code).

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!134
No description provided.