GPU and shaders: a host that caps its view heaps gets heaps at its ca… #2461

Open
github-bot wants to merge 6 commits from github-bot/gh-2461 into main AGit
Owner

@⁠lhnizdo on GitHub · 2026-11-25 14:01 UTC · original
lhnizdo:pr/nvidia-heap-limit → main · +241 −44 · 7 files · 6 commits · open

Translated shaders clamp view indices below HEAP_VIEWS (2²¹) and read the null buffer views two below it. That assumes a host view heap that large, but NVIDIA caps shader-visible view heaps at 1,000,000. On such a card the current code:

  • falls back to a heap of 1,000,000 with 2¹⁶ dynamic slots;
  • finds no room for the null buffer views ("no room for the null buffer views");
  • leaves the title's slots past the heap's end, and lets shaders read view indices up to 2²¹ − 1, past it.

The comment in HostHeap::new already notes that such a host "faults on an index past them". On Windows 10 with an NVIDIA card, the device was removed (DXGI_ERROR_INVALID_CALL) about a minute in, while still loading.

The change:

  • probe_view_limit asks once whether the host takes a view heap of HEAP_VIEWS, before the first translation and before the first heap (the title makes pipelines before its heap).
  • If not, set_view_heap_limit lowers the limit to the host's cap. Shaders clamp below it, and null_buffer_view() (replacing the NULL_BUFFER_VIEW constant) is two below it.
  • The heap is made at exactly the cap:
    • the full 2¹⁸ dynamic range (2¹⁶ ran out in the world on that machine, dropping up to 16,384 draws at a time);
    • room for 8,192 copy view pairs;
    • the null buffer views and a last null slot at the top;
    • the title's slots below, 721,469 of them (the title's highest index seen is about 720,000).
  • The view limit is part of the shader cache key.

Hosts that take a heap of HEAP_VIEWS are unchanged.

Checked on Windows 10 with an NVIDIA wave32 card:

  • The cap is detected ("host view heaps capped at 1000000") and the heap is made at it.
  • Two victory-gpu tests that fail there on main now pass: dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views (142 pass instead of 140). The remaining failure, the placed-view format test, fails on main too.
  • Clippy is clean. The victory-shader tests fail in the same set as on main (no SM 6.6 device in that test harness).
  • In the game (with the Agility SDK change and the next PR's view check), the run went from frame 64 to past frame 1,700.

🤖 Generated with Claude Code. The change was written by Claude Code (Claude Opus 5.5) in my session; the commit carries a Co-Authored-By: Claude line.

**@⁠lhnizdo** on GitHub · 2026-11-25 14:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461) `lhnizdo:pr/nvidia-heap-limit` → `main` · +241 −44 · 7 files · 6 commits · open Translated shaders clamp view indices below `HEAP_VIEWS` (2²¹) and read the null buffer views two below it. That assumes a host view heap that large, but NVIDIA caps shader-visible view heaps at 1,000,000. On such a card the current code: - falls back to a heap of 1,000,000 with 2¹⁶ dynamic slots; - finds no room for the null buffer views ("no room for the null buffer views"); - leaves the title's slots past the heap's end, and lets shaders read view indices up to 2²¹ − 1, past it. The comment in `HostHeap::new` already notes that such a host "faults on an index past them". On Windows 10 with an NVIDIA card, the device was removed (`DXGI_ERROR_INVALID_CALL`) about a minute in, while still loading. **The change:** - `probe_view_limit` asks once whether the host takes a view heap of `HEAP_VIEWS`, before the first translation and before the first heap (the title makes pipelines before its heap). - If not, `set_view_heap_limit` lowers the limit to the host's cap. Shaders clamp below it, and `null_buffer_view()` (replacing the `NULL_BUFFER_VIEW` constant) is two below it. - The heap is made at exactly the cap: - the full 2¹⁸ dynamic range (2¹⁶ ran out in the world on that machine, dropping up to 16,384 draws at a time); - room for 8,192 copy view pairs; - the null buffer views and a last null slot at the top; - the title's slots below, 721,469 of them (the title's highest index seen is about 720,000). - The view limit is part of the shader cache key. Hosts that take a heap of `HEAP_VIEWS` are unchanged. **Checked** on Windows 10 with an NVIDIA wave32 card: - The cap is detected ("host view heaps capped at 1000000") and the heap is made at it. - Two `victory-gpu` tests that fail there on `main` now pass: `dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views` (142 pass instead of 140). The remaining failure, the placed-view format test, fails on `main` too. - Clippy is clean. The `victory-shader` tests fail in the same set as on `main` (no SM 6.6 device in that test harness). - In the game (with the Agility SDK change and the next PR's view check), the run went from frame 64 to past frame 1,700. 🤖 Generated with [Claude Code](https://claude.com/claude-code). The change was written by Claude Code (Claude Opus 5.5) in my session; the commit carries a `Co-Authored-By: Claude` line.
Translated shaders clamp view indices below HEAP_VIEWS (2^21) and read
the null buffer views two below it, which assumes a host heap that large.
NVIDIA caps shader-visible view heaps at 1,000,000: the heap fell back
to the cap with 2^16 dynamic slots, no room for the null buffer views
("no room for the null buffer views"), title slots past its end, and
indices up to 2^21 - 1 that read past the heap. On a Windows 10 machine
with an NVIDIA card the device was removed (DXGI_ERROR_INVALID_CALL)
about a minute in, still loading.

Whether the host takes a heap of HEAP_VIEWS is now asked once, before
the first translation and the first heap (probe_view_limit). A host
that does not lowers the view limit to its cap (set_view_heap_limit):
shaders clamp below it and read the null buffer views two below it, and
the heap is made at the cap with the full 2^18 dynamic range (2^16 ran
out in the world there), room for 8,192 copy view pairs, the null views
and a last null slot at its top, and the title's slots below them
(721,469; the title's highest index seen is about 720,000). The limit is
part of the shader cache key.

On that machine the heap and title-memory tests (dynamic slots,
lists_share_a_table) now pass; hosts that take HEAP_VIEWS are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTeDQ6Kc6DEkgPbAww8
Review of #2461: the limit was probed only by victory-gpu (shader cache
and runtime heaps), so emit::host, which the shader tests and
`translate --pipelines` use, still made heaps of HEAP_VIEWS on a capped
device (E_INVALIDARG on an RTX 5090 in
stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,
the device for a heap of HEAP_VIEWS and, if refused where 1,000,000 is
taken, sets the view limit to that, as the runtime does. Shaders
translated before the first Host::new keep the limit they were made with.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTeDQ6Kc6DEkgPbAww8
Review of #2461: translating before Host::new probed the device's heap
limit made the shader's fallback the null SRV of a 2^21 heap (2,097,150)
while the heap made on an NVIDIA device had it at 999,998. The test now
builds its shader after the host is made and checks that the fallback
slot is the dispatch heap's null SRV. Verified on an RTX 5080 Laptop
GPU: the check fails with the old order and passes with this one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Keep the existing title slot budget and reserve the top three slots from the runtime range. Use the remaining space for dynamic tables and host copy pairs.

Refs Marvisak/VIctory#2461
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:34 +00:00
Author
Owner

@⁠kotekompotek on GitHub · 2026-11-25 14:13 UTC · original

Reviewed — of the heap-cap PRs (#2185, #2121, #2189), this is the most complete take:

  • The probe happens at cache-key build (shader_cache::build → probe_view_limit), so the limit is set before translation and the key carries it — the exact ordering hole #2185 had (translate keyed at 2M, runtime heaps at 1M) is closed here.
  • Shader clamp lowered to the actual cap (view_heap_limit, atomic, set before translation) means indices past the NVIDIA 1M heap end can't fault the device even if a title computes one — previously they clamped to a heap that doesn't exist on capped hosts.
  • Capped layout keeps the full DYNAMIC range (2^16 ran out in the world, per the comment) + CAPPED_PAIRS + nulls, at the cost of title slots above ~983K — pragmatic given the highest title index seen is ~720K, and logged when it happens.
  • null_buffer_view() = limit - 2 keeps the null SRV/UAV pair at the heap top under both limits; pairs_end gating unchanged.

Subsumes #2185. One soft spot: "set before any translation" is documented but not enforced — a translate path that skips shader_cache::build and HostHeap::new before emitting would clamp at HEAP_VIEWS on a capped host. If translate --pipelines has such a path, worth a probe call there too.

**@⁠kotekompotek** on GitHub · 2026-11-25 14:13 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7164941985) Reviewed — of the heap-cap PRs (#2185, #2121, #2189), this is the most complete take: - The probe happens at cache-key build (`shader_cache::build` → `probe_view_limit`), so the limit is set before translation and the key carries it — the exact ordering hole #2185 had (translate keyed at 2M, runtime heaps at 1M) is closed here. - Shader clamp lowered to the actual cap (`view_heap_limit`, atomic, `set` before translation) means indices past the NVIDIA 1M heap end can't fault the device even if a title computes one — previously they clamped to a heap that doesn't exist on capped hosts. - Capped layout keeps the full `DYNAMIC` range (2^16 ran out in the world, per the comment) + `CAPPED_PAIRS` + nulls, at the cost of title slots above ~983K — pragmatic given the highest title index seen is ~720K, and logged when it happens. - `null_buffer_view() = limit - 2` keeps the null SRV/UAV pair at the heap top under both limits; `pairs_end` gating unchanged. Subsumes #2185. One soft spot: "set before any translation" is documented but not enforced — a translate path that skips `shader_cache::build` and `HostHeap::new` before emitting would clamp at `HEAP_VIEWS` on a capped host. If `translate --pipelines` has such a path, worth a probe call there too.
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-25 14:46 UTC · original

Thanks for the careful review and the RTX 5090 run. Both points had one root: victory_shader::emit::host, which the shader tests and translate --pipelines use, never probed the cap. I've pushed a commit where Host::new asks the device for a heap of HEAP_VIEWS and, if that's refused while 1,000,000 is taken, lowers the view limit as the runtime does. That should fix stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros (#1835) on the 5090. I can't run it here (no SM 6.6 device in my test harness), so a re-run there would confirm it.

One limit remains: shaders translated before the first Host::new keep the limit they were made with. That's noted in the code.

**@⁠lhnizdo** on GitHub · 2026-11-25 14:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7165783321) Thanks for the careful review and the RTX 5090 run. Both points had one root: `victory_shader::emit::host`, which the shader tests and `translate --pipelines` use, never probed the cap. I've pushed a commit where `Host::new` asks the device for a heap of `HEAP_VIEWS` and, if that's refused while 1,000,000 is taken, lowers the view limit as the runtime does. That should fix `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` (#1835) on the 5090. I can't run it here (no SM 6.6 device in my test harness), so a re-run there would confirm it. One limit remains: shaders translated before the first `Host::new` keep the limit they were made with. That's noted in the code.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 14:58 UTC · original

A small suggestion for probe_view_limit (victory-gpu/src/descriptor/host.rs:109 at this head). It learns the cap by creating a HEAP_VIEWS (2^21) heap and falling back to 1,000,000 when that fails. D3D12 can report the cap directly: D3D12_FEATURE_DATA_D3D12_OPTIONS19::MaxViewDescriptorHeapSize. This PR already calls CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, …) in pipeline/host.rs:374 and emit/host.rs:234, but reads only AnisoFilterWithPointMipSupported there.

  • xcl does it this way: crates/xcl/src/hle/d3d12x/console_heap.rs, global_cap takes MaxViewDescriptorHeapSize from OPTIONS19, with 1,000,000 when the runtime doesn't know OPTIONS19.
  • The probe misses some caps: it only tells 2^21 apart from 1,000,000. A host whose cap is somewhere else gets either a heap it can't create or a limit lower than needed. According to its source, vkd3d-proton reports the real cap under Proton: the D3D12 minimum, or more with descriptor heaps and ReBAR. That's relevant to the Linux/NVIDIA reports in #2138 and #1921.
  • No failed create: the query avoids a failed CreateDescriptorHeap at startup on NVIDIA.

Keeping the probe as a fallback for a runtime without OPTIONS19 would cover older systems. Read from the code only; not run.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-25 14:58 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7166110557) A small suggestion for `probe_view_limit` (`victory-gpu/src/descriptor/host.rs:109` at this head). It learns the cap by creating a `HEAP_VIEWS` (2^21) heap and falling back to 1,000,000 when that fails. D3D12 can report the cap directly: `D3D12_FEATURE_DATA_D3D12_OPTIONS19::MaxViewDescriptorHeapSize`. This PR already calls `CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS19, …)` in `pipeline/host.rs:374` and `emit/host.rs:234`, but reads only `AnisoFilterWithPointMipSupported` there. - **xcl does it this way:** `crates/xcl/src/hle/d3d12x/console_heap.rs`, `global_cap` takes `MaxViewDescriptorHeapSize` from OPTIONS19, with 1,000,000 when the runtime doesn't know OPTIONS19. - **The probe misses some caps:** it only tells 2^21 apart from 1,000,000. A host whose cap is somewhere else gets either a heap it can't create or a limit lower than needed. According to its source, vkd3d-proton reports the real cap under Proton: the D3D12 minimum, or more with descriptor heaps and ReBAR. That's relevant to the Linux/NVIDIA reports in #2138 and #1921. - **No failed create:** the query avoids a failed `CreateDescriptorHeap` at startup on NVIDIA. Keeping the probe as a fallback for a runtime without OPTIONS19 would cover older systems. Read from the code only; not run. AI-assisted (Claude Code).
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 16:39 UTC · original · edited 2026-11-26 00:23 UTC

Automated triage for the maintainers.

Merge candidate. Re-reviewed at 2b5f652, rebased onto current main (merges cleanly). probe_view_limit (crates/victory-gpu/src/descriptor/host.rs) runs before the shader cache key is built and before the first heap. On a host that refuses a 2^21 view heap, it lowers victory_shader::emit::view_heap_limit, so shaders clamp below the real heap and null_buffer_view() sits at the heap's top. The limit is part of the cache key (shader_cache::key). The shader crate's own create_device probes the same way. The capped branch in HostHeap::new now keeps min(count, 1,000,000 - MIN_DYNAMIC) = 934,464 title slots, the same as main's portable fallback. The dynamic range ends at the reserved null pair, and pair() falls back to dynamic slots. I checked that pairs_end and the null placement agree for the 1,245,184-slot case.

On your reply: taking yumaste's title-slots-first commit answers the remaining point from the earlier review. The new capped_view_heap_preserves_title_slots_and_reserves_nulls test passes on an RTX 2080 and an RTX 5080 per the thread. The 7-minute in-game run shows no dropped draw from a left-out slot and no device removal. upipibi's OPTIONS19::MaxViewDescriptorHeapSize suggestion would be a reasonable follow-up, but it does not block this. This subsumes the earlier heap-cap PRs (#2185 and related). CI: check passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 16:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7168330937) · edited 2026-11-26 00:23 UTC <!-- victory-triage v1 head=2b5f65282ebb0148d988980535aa9d52b8f196eb verdict=merge-candidate at=2026-11-26T00:23:45Z --> Automated triage for the maintainers. **Merge candidate.** Re-reviewed at `2b5f652`, rebased onto current `main` (merges cleanly). `probe_view_limit` (`crates/victory-gpu/src/descriptor/host.rs`) runs before the shader cache key is built and before the first heap. On a host that refuses a 2^21 view heap, it lowers `victory_shader::emit::view_heap_limit`, so shaders clamp below the real heap and `null_buffer_view()` sits at the heap's top. The limit is part of the cache key (`shader_cache::key`). The shader crate's own `create_device` probes the same way. The capped branch in `HostHeap::new` now keeps `min(count, 1,000,000 - MIN_DYNAMIC)` = 934,464 title slots, the same as `main`'s portable fallback. The dynamic range ends at the reserved null pair, and `pair()` falls back to dynamic slots. I checked that `pairs_end` and the null placement agree for the 1,245,184-slot case. On your reply: taking yumaste's title-slots-first commit answers the remaining point from the earlier review. The new `capped_view_heap_preserves_title_slots_and_reserves_nulls` test passes on an RTX 2080 and an RTX 5080 per the thread. The 7-minute in-game run shows no dropped draw from a left-out slot and no device removal. upipibi's `OPTIONS19::MaxViewDescriptorHeapSize` suggestion would be a reasonable follow-up, but it does not block this. This subsumes the earlier heap-cap PRs (#2185 and related). CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-25 18:07 UTC · original

Rebased onto current main (13f91ca). The only conflicts were in emit/mod.rs: a reworded doc line next to ours, and the new VIEW_* exports next to the heap-limit ones. Nothing else needed changing: no new code uses NULL_BUFFER_VIEW. Clippy is clean on victory-gpu and victory-shader.

**@⁠lhnizdo** on GitHub · 2026-11-25 18:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7170472518) Rebased onto current `main` (13f91ca). The only conflicts were in `emit/mod.rs`: a reworded doc line next to ours, and the new `VIEW_*` exports next to the heap-limit ones. Nothing else needed changing: no new code uses `NULL_BUFFER_VIEW`. Clippy is clean on `victory-gpu` and `victory-shader`.
Author
Owner

@⁠yumaste on GitHub · 2026-11-25 20:36 UTC · original

I verified cbbe8ac on Windows 11 (build 26300.9974) with an RTX 5080 Laptop GPU, NVIDIA driver 621.01, and Rust 1.98.1.

Both targeted victory-gpu heap tests passed with this PR. The existing a_heap_buffer_read_where_no_buffer_view_is_reads_zeros test also reported a pass, so I checked the documented initialization-order caveat directly. With translation first, lowering selected null SRV index 2,097,150, while the NVIDIA heap had 1,000,000 slots and its null SRV was at 999,998. An assertion before dispatch caught the mismatch. With the host probe first, lowering and the heap both used 999,998, and the test passed.

Here is a test-only patch that probes the host before translation and checks that the fallback slot agrees with the dispatch heap. I confirmed the assertion fails with the old order and passes with the patch on the RTX 5080 Laptop GPU.

Test patch against cbbe8ac
diff --git a/crates/victory-shader/src/emit/stride_tests.rs b/crates/victory-shader/src/emit/stride_tests.rs
index 20615b2..9c37956 100644
--- a/crates/victory-shader/src/emit/stride_tests.rs
+++ b/crates/victory-shader/src/emit/stride_tests.rs
@@ -309,16 +309,6 @@ fn a_heap_buffer_read_by_element_takes_the_views_stride() {
 /// indices"): a texture descriptor read as a buffer one is a wild address.
 #[test]
 fn a_heap_buffer_read_where_no_buffer_view_is_reads_zeros() {
-    let shader = build(
-        HEAP_ELEMENT_WAVE32,
-        vec![
-            param(RootType::Constants, 0),
-            param(RootType::ResourceHeap, 1),
-            param(RootType::Table, 2),
-        ],
-        vec![entry(ResourceType::Uav, 4, 2)],
-        32,
-    );
     let texel = [[1.0f32, 2.0, 3.0, 4.0]];
     let views = [View::RawUav(32), View::Texture(1, 1, &texel), View::NullBuffers];
     let _one = super::valu_tests::ONE_AT_A_TIME
@@ -330,6 +320,24 @@ fn a_heap_buffer_read_where_no_buffer_view_is_reads_zeros() {
             eprintln!("no SM 6.6 {label} device; skipped");
             continue;
         };
+        // Host::new probes the heap limit. Lowering embeds the null slot
+        // for that limit, so translate only after the probe.
+        let translated_null_slot = super::null_buffer_view();
+        let shader = build(
+            HEAP_ELEMENT_WAVE32,
+            vec![
+                param(RootType::Constants, 0),
+                param(RootType::ResourceHeap, 1),
+                param(RootType::Table, 2),
+            ],
+            vec![entry(ResourceType::Uav, 4, 2)],
+            32,
+        );
+        assert_eq!(
+            translated_null_slot,
+            super::null_buffer_view(),
+            "{label}: shader fallback descriptor must match the null SRV in the dispatch heap"
+        );
         let (root, pso) = host
             .compute_pipeline(&shader)
             .unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}"));

Test automation and write-up assisted by Codex.

**@⁠yumaste** on GitHub · 2026-11-25 20:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7173922152) I verified `cbbe8ac` on Windows 11 (build 26300.9974) with an RTX 5080 Laptop GPU, NVIDIA driver 621.01, and Rust 1.98.1. Both targeted `victory-gpu` heap tests passed with this PR. The existing `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` test also reported a pass, so I checked the documented initialization-order caveat directly. With translation first, lowering selected null SRV index **2,097,150**, while the NVIDIA heap had **1,000,000** slots and its null SRV was at **999,998**. An assertion before dispatch caught the mismatch. With the host probe first, lowering and the heap both used **999,998**, and the test passed. Here is a test-only patch that probes the host before translation and checks that the fallback slot agrees with the dispatch heap. I confirmed the assertion fails with the old order and passes with the patch on the RTX 5080 Laptop GPU. <details> <summary>Test patch against cbbe8ac</summary> ```diff diff --git a/crates/victory-shader/src/emit/stride_tests.rs b/crates/victory-shader/src/emit/stride_tests.rs index 20615b2..9c37956 100644 --- a/crates/victory-shader/src/emit/stride_tests.rs +++ b/crates/victory-shader/src/emit/stride_tests.rs @@ -309,16 +309,6 @@ fn a_heap_buffer_read_by_element_takes_the_views_stride() { /// indices"): a texture descriptor read as a buffer one is a wild address. #[test] fn a_heap_buffer_read_where_no_buffer_view_is_reads_zeros() { - let shader = build( - HEAP_ELEMENT_WAVE32, - vec![ - param(RootType::Constants, 0), - param(RootType::ResourceHeap, 1), - param(RootType::Table, 2), - ], - vec![entry(ResourceType::Uav, 4, 2)], - 32, - ); let texel = [[1.0f32, 2.0, 3.0, 4.0]]; let views = [View::RawUav(32), View::Texture(1, 1, &texel), View::NullBuffers]; let _one = super::valu_tests::ONE_AT_A_TIME @@ -330,6 +320,24 @@ fn a_heap_buffer_read_where_no_buffer_view_is_reads_zeros() { eprintln!("no SM 6.6 {label} device; skipped"); continue; }; + // Host::new probes the heap limit. Lowering embeds the null slot + // for that limit, so translate only after the probe. + let translated_null_slot = super::null_buffer_view(); + let shader = build( + HEAP_ELEMENT_WAVE32, + vec![ + param(RootType::Constants, 0), + param(RootType::ResourceHeap, 1), + param(RootType::Table, 2), + ], + vec![entry(ResourceType::Uav, 4, 2)], + 32, + ); + assert_eq!( + translated_null_slot, + super::null_buffer_view(), + "{label}: shader fallback descriptor must match the null SRV in the dispatch heap" + ); let (root, pso) = host .compute_pipeline(&shader) .unwrap_or_else(|e| panic!("{label}: compute_pipeline failed: {e}")); ``` </details> Test automation and write-up assisted by Codex.
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-25 21:01 UTC · original

Thanks @⁠yumaste, both for checking the ordering caveat directly and for the test patch. I've added it to this PR as is, with you as the commit's author (00c9c5b). Clippy is clean on victory-shader. I can't run the shader tests here (no SM 6.6 device in my test harness), so your RTX 5080 Laptop run is the check that counts.

**@⁠lhnizdo** on GitHub · 2026-11-25 21:01 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7174510335) Thanks @⁠yumaste, both for checking the ordering caveat directly and for the test patch. I've added it to this PR as is, with you as the commit's author (`00c9c5b`). Clippy is clean on `victory-shader`. I can't run the shader tests here (no SM 6.6 device in my test harness), so your RTX 5080 Laptop run is the check that counts.
Author
Owner

@⁠yumaste on GitHub · 2026-11-25 21:25 UTC · original

I tried the title-slot-first layout suggested in review. yumaste/VIctory@a06e33b is a single commit on top of 00c9c5b.

On a host capped at 1,000,000 descriptors, a large title heap now keeps the same 934,464 title slots as the portable fallback, up from 721,469 on this PR's current head. Slots 999,997 through 999,999 are reserved for the null UAV, SRV, and final null view. This leaves 65,533 dynamic slots at the maximum title size. Copy pairs share that range when dedicated space runs out. Smaller title heaps can still use the larger dynamic range and dedicate spare slots to copy pairs.

The new regression failed at 721,469 before the patch and passed at 934,464 with it on the capped hardware adapter. It also checks that table and pair allocations stop before the reserved slots and that a released pair can be reused. The diagnostics GPU suite passed 199 tests with one ignored on both hardware and WARP. Strict GPU Clippy and the shader null-buffer fallback test passed. In-game dynamic-slot pressure and frame time remain unmeasured. The tests used no game data. AI-assisted with Codex.

**@⁠yumaste** on GitHub · 2026-11-25 21:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7175049620) I tried the title-slot-first layout suggested in review. [yumaste/VIctory@a06e33b](https://github.com/yumaste/VIctory/commit/a06e33b0cc5d12e76e309148f8c083e3a5ef0b01) is a single commit on top of `00c9c5b`. On a host capped at 1,000,000 descriptors, a large title heap now keeps the same 934,464 title slots as the portable fallback, up from 721,469 on this PR's current head. Slots 999,997 through 999,999 are reserved for the null UAV, SRV, and final null view. This leaves 65,533 dynamic slots at the maximum title size. Copy pairs share that range when dedicated space runs out. Smaller title heaps can still use the larger dynamic range and dedicate spare slots to copy pairs. The new regression failed at 721,469 before the patch and passed at 934,464 with it on the capped hardware adapter. It also checks that table and pair allocations stop before the reserved slots and that a released pair can be reused. The diagnostics GPU suite passed 199 tests with one ignored on both hardware and WARP. Strict GPU Clippy and the shader null-buffer fallback test passed. In-game dynamic-slot pressure and frame time remain unmeasured. The tests used no game data. AI-assisted with Codex.
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-25 22:42 UTC · original

Thanks @⁠yumaste. I've added a06e33b to this PR as is, with you as the author (now 2b5f652), and rebased the branch onto current main (f3578e3), which conflicted after #2462 was merged.

  • The rebase: main has restructured emit::host (the shared WARP device, create_device), so the shader host's heap probe now sits at the end of create_device, and both the hardware device and the shared WARP device get it. Main had also added a View::NullBuffers use of NULL_BUFFER_VIEW, which is now null_buffer_view(). Your new test and main's new view_addresses_cover_tables_made_afresh landed at the same place in descriptor/host.rs; both are kept.
  • Tests on an RTX 2080 (Windows 10 19045, driver 32.0.16.1742):
    • cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings is clean.
    • cargo test -p victory-gpu --lib: 229 passed, 0 failed. Your test reports a 1,000,000 cap, 934,464 title slots, 65,533 dynamic slots and 999,997 as the first reserved null slot, the same as on your 5080.
    • cargo test -p victory-shader --lib: 299 passed, 3 failed, all three unrelated to this PR. Two fail identically on plain main on this card: pops_wait_loop_exits_immediately_for_inactive_lanes wants a shader model 6.6 WARP device, which Windows 10's WARP isn't, and gathers_at_a_level_match_the_hardware gets another texel on NVIDIA. The third, a_heap_buffer_read_by_element_takes_the_views_stride, is the NVIDIA structured-view read that #2464 addresses.
    • Windows 10 has no shader model 6.6 without the Agility SDK, and test binaries don't load it, so these runs used a local commit that exports D3D12SDKVersion and D3D12SDKPath from the test binaries. I'll propose that as a separate PR.
  • In the game, the part you noted as unmeasured: main + #2460 + this PR + #2464, plus #2851 locally (without it the world load crashes in alias_source, #2847). With a story save that loads straight into the world, about 7 minutes in the world at 1,000–3,000 draws a frame:
    • The title heap is 1,245,184 slots, of which 934,464 are kept (721,469 before your commit). Each slot past that warned once as the title first wrote it (310,720 warnings), all with for_draw=false: no draw needed a slot that was left out.
    • No dynamic-slot or copy-pair exhaustion was reported, and the device wasn't removed.
    • Frame time doesn't say anything yet: the shader cache was cold (main's translator changed), so about 2,000 draws a frame were still dropped while pipelines were built.
**@⁠lhnizdo** on GitHub · 2026-11-25 22:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7176687166) Thanks @⁠yumaste. I've added a06e33b to this PR as is, with you as the author (now `2b5f652`), and rebased the branch onto current `main` (`f3578e3`), which conflicted after #2462 was merged. - **The rebase:** main has restructured `emit::host` (the shared WARP device, `create_device`), so the shader host's heap probe now sits at the end of `create_device`, and both the hardware device and the shared WARP device get it. Main had also added a `View::NullBuffers` use of `NULL_BUFFER_VIEW`, which is now `null_buffer_view()`. Your new test and main's new `view_addresses_cover_tables_made_afresh` landed at the same place in `descriptor/host.rs`; both are kept. - **Tests on an RTX 2080 (Windows 10 19045, driver 32.0.16.1742):** - `cargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings` is clean. - `cargo test -p victory-gpu --lib`: 229 passed, 0 failed. Your test reports a 1,000,000 cap, 934,464 title slots, 65,533 dynamic slots and 999,997 as the first reserved null slot, the same as on your 5080. - `cargo test -p victory-shader --lib`: 299 passed, 3 failed, all three unrelated to this PR. Two fail identically on plain `main` on this card: `pops_wait_loop_exits_immediately_for_inactive_lanes` wants a shader model 6.6 WARP device, which Windows 10's WARP isn't, and `gathers_at_a_level_match_the_hardware` gets another texel on NVIDIA. The third, `a_heap_buffer_read_by_element_takes_the_views_stride`, is the NVIDIA structured-view read that #2464 addresses. - Windows 10 has no shader model 6.6 without the Agility SDK, and test binaries don't load it, so these runs used a local commit that exports `D3D12SDKVersion` and `D3D12SDKPath` from the test binaries. I'll propose that as a separate PR. - **In the game,** the part you noted as unmeasured: `main` + #2460 + this PR + #2464, plus #2851 locally (without it the world load crashes in `alias_source`, #2847). With a story save that loads straight into the world, about 7 minutes in the world at 1,000–3,000 draws a frame: - The title heap is 1,245,184 slots, of which 934,464 are kept (721,469 before your commit). Each slot past that warned once as the title first wrote it (310,720 warnings), all with `for_draw=false`: no draw needed a slot that was left out. - No dynamic-slot or copy-pair exhaustion was reported, and the device wasn't removed. - Frame time doesn't say anything yet: the shader cache was cold (main's translator changed), so about 2,000 draws a frame were still dropped while pipelines were built.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:38 UTC · original

Independent RTX 5090 (1M view-heap cap hardware) + WARP + DXIL verification at head 2b5f65282ebb merged cleanly onto main (63bcca43c6a0; emit/lower.rs = 520,572 B, safely under the 512 KiB cap):

  • RTX 5090 1M view-heap cap results (VICTORY_D3D12_DEBUG=1):
    • victory-gpu (descriptor::host::tests memory::tests descriptor::tests): 31/31 passed — both pre-existing main failures on RTX 5090 (descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views) plus the new capped_view_heap_preserves_title_slots_and_reserves_nulls now pass cleanly with 0 D3D12 Debug Layer errors.
    • victory-shader (stride_tests emit::lower::tests, dxil.dll 10.0.26100.0): 40/41 passed — fixes emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros (which failed with dispatch failed: E_INVALIDARG on main 63bcca43). The single remaining failure (a_heap_buffer_read_by_element_takes_the_views_stride) reproduces identically on clean main 63bcca43 on RTX 5090 and is unrelated to this PR.
  • WARP verification (--features diagnostics, VICTORY_D3D12_DEBUG=1 / VICTORY_WARP=1):
    • victory-gpu (descriptor::host::tests memory::tests descriptor::tests): 31/31 passed
    • victory-shader (stride_tests): 8/8 passed
  • Checks: cargo xtask policy (191 files ok), cargo clippy --locked -p victory-gpu -p victory-shader --tests -- -D warnings (default + --all-features, 0 warnings).

Confirmed to fix all three NVIDIA 1M view-heap cap failures on RTX 5090 hardware; LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7178967632) Independent RTX 5090 (1M view-heap cap hardware) + WARP + DXIL verification at head `2b5f65282ebb` merged cleanly onto `main` (`63bcca43c6a0`; `emit/lower.rs` = `520,572` B, safely under the 512 KiB cap): - **RTX 5090 1M view-heap cap results (`VICTORY_D3D12_DEBUG=1`)**: - `victory-gpu` (`descriptor::host::tests memory::tests descriptor::tests`): **31/31 passed** — both pre-existing `main` failures on RTX 5090 (`descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`) plus the new `capped_view_heap_preserves_title_slots_and_reserves_nulls` now pass cleanly with 0 D3D12 Debug Layer errors. - `victory-shader` (`stride_tests emit::lower::tests`, `dxil.dll` 10.0.26100.0): **40/41 passed** — fixes `emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` (which failed with `dispatch failed: E_INVALIDARG` on `main` `63bcca43`). The single remaining failure (`a_heap_buffer_read_by_element_takes_the_views_stride`) reproduces identically on clean `main` `63bcca43` on RTX 5090 and is unrelated to this PR. - **WARP verification (`--features diagnostics`, `VICTORY_D3D12_DEBUG=1` / `VICTORY_WARP=1`)**: - `victory-gpu` (`descriptor::host::tests memory::tests descriptor::tests`): **31/31 passed** - `victory-shader` (`stride_tests`): **8/8 passed** - **Checks**: `cargo xtask policy` (`191 files ok`), `cargo clippy --locked -p victory-gpu -p victory-shader --tests -- -D warnings` (default + `--all-features`, 0 warnings). Confirmed to fix all three NVIDIA 1M view-heap cap failures on RTX 5090 hardware; LGTM.
Measured in the world on an RTX 2080 (1,000,000-view cap), `main` +
#2460 #2461 #2464 and local work, 10 minutes each from a save that
loads into the world: with 65,533 dynamic slots the host ran out of
them and dropped draws (512 and more, and root views); with this PR's
layout before (721,469 title slots, 262,144 dynamic) none were dropped,
and no draw read a title slot past the kept ones (523,715 left out, all
for_draw=false). Back to that layout until a scene needs more title
slots.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Author
Owner

@⁠DenRakEiw on GitHub · 2026-11-25 14:04 UTC · original · approved these changes

Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) and WARP:

  • Fixes both pre-existing NVIDIA view-heap baseline failures (#1744) on RTX 5090!
  • cargo test -p victory-gpu descriptor::host::tests: 5/5 passed on RTX 5090, 5/5 passed on WARP (including dynamic_slots_are_held_until_released).
  • cargo test -p victory-gpu memory::tests: 3/3 passed on RTX 5090 (including lists_share_a_table_and_copies_keep_their_views).
  • cargo clippy -p victory-gpu -p victory-shader --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.
  • (Note: victory-shader's stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros still hits the pre-existing #1835 E_INVALIDARG on RTX 5090 because emit::host allocates HEAP_VIEWS slots directly.)

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 14:04 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#pullrequestreview-6059057814) · **approved these changes** Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 (Blackwell) and WARP: - Fixes both pre-existing NVIDIA view-heap baseline failures (`#1744`) on RTX 5090! - `cargo test -p victory-gpu descriptor::host::tests`: 5/5 passed on RTX 5090, 5/5 passed on WARP (including `dynamic_slots_are_held_until_released`). - `cargo test -p victory-gpu memory::tests`: 3/3 passed on RTX 5090 (including `lists_share_a_table_and_copies_keep_their_views`). - `cargo clippy -p victory-gpu -p victory-shader --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. - (Note: `victory-shader`'s `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` still hits the pre-existing `#1835` `E_INVALIDARG` on RTX 5090 because `emit::host` allocates `HEAP_VIEWS` slots directly.) AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 14:11 UTC · original · reviewed

Host that caps view heaps gets heaps at cap (CAPPED_PAIRS). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Overlaps #2451 in descriptor/host.rs; convergence needed.

**@⁠catminou4** on GitHub · 2026-11-25 14:11 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#pullrequestreview-6059180871) · **reviewed** Host that caps view heaps gets heaps at cap (CAPPED_PAIRS). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1. Overlaps #2451 in descriptor/host.rs; convergence needed.
Author
Owner

@⁠fyernald on GitHub · 2026-11-26 02:21 UTC · original · approved these changes

Ampere data point at 2b5f652: RTX 3080 (617.42, 1,000,000-view cap), Windows 10 19045, main 63bcca4 + #486 + #2596, with #2885 applied as well. The two merge cleanly onto main and with each other. --test-threads=1.

  • victory-gpu --lib: 230 passed, 3 failed. dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and capped_view_heap_preserves_title_slots_and_reserves_nulls pass. Both of the first two fail on this card without this PR, including with #2885 alone. The three left are the Windows 10 in-box-runtime failures (no SM 6.6 root flags, no ID3D12Device10) that are unrelated to this PR.
  • victory-shader --lib: 303 passed, 1 failed. a_heap_buffer_read_where_no_buffer_view_is_reads_zeros passes (it fails without this PR). The one left needs an SM 6.6 WARP, which Windows 10 doesn't have.
**@⁠fyernald** on GitHub · 2026-11-26 02:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#pullrequestreview-6067712995) · **approved these changes** Ampere data point at `2b5f652`: RTX 3080 (617.42, 1,000,000-view cap), **Windows 10 19045**, `main` `63bcca4` + #486 + #2596, with #2885 applied as well. The two merge cleanly onto `main` and with each other. `--test-threads=1`. - `victory-gpu --lib`: 230 passed, 3 failed. `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and `capped_view_heap_preserves_title_slots_and_reserves_nulls` pass. Both of the first two fail on this card without this PR, including with #2885 alone. The three left are the Windows 10 in-box-runtime failures (no SM 6.6 root flags, no `ID3D12Device10`) that are unrelated to this PR. - `victory-shader --lib`: 303 passed, 1 failed. `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` passes (it fails without this PR). The one left needs an SM 6.6 WARP, which Windows 10 doesn't have.
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-26 08:33 UTC · original

@⁠yumaste, thanks again for the layout. I measured it in the world, which neither of us had done yet, and it costs draws there, so I've reverted it on this PR (dae68bb, a plain revert commit). Here's the data so you can judge it yourself.

  • Setup: RTX 2080 (1,000,000-view cap), Windows 10 19045. main + #2460 #2461 #2464, plus local work (#1960 and an experimental console mode), so not plain main; the only difference between the two builds is a06e33b. Each build ran 10 minutes from a story save that loads straight into the world.
before a06e33b with a06e33b
title slots kept 721,469 934,464
dynamic slots 262,144 65,533
draws dropped: "no dynamic slots for its tables" 0 512+ (logged at powers of two)
"no dynamic slots for root views" 0 40 report lines of dropped mesh draws
draws reading a title slot past the kept ones 0 (523,715 left out, all for_draw=false) 0

So in the world, the 213,000 extra title slots weren't read by any draw, while the smaller dynamic range ran out once the scene got busy. I couldn't see it in the earlier world check because the cold shader cache was still dropping thousands of draws a frame for missing pipelines.

The GPU tests still pass with the revert (victory-gpu, 228 passed on this card). If a scene turns up that reads title slots past 721,469, a middle ground would be easy: for example 131,072 dynamic slots, leaving about 856,000 for the title. I'd rather see such a case first than guess.

AI-assisted (Claude Code); the runs were on my machine. No game data.

**@⁠lhnizdo** on GitHub · 2026-11-26 08:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7186742470) @⁠yumaste, thanks again for the layout. I measured it in the world, which neither of us had done yet, and it costs draws there, so I've reverted it on this PR (`dae68bb`, a plain revert commit). Here's the data so you can judge it yourself. - **Setup:** RTX 2080 (1,000,000-view cap), Windows 10 19045. `main` + #2460 #2461 #2464, plus local work (#1960 and an experimental console mode), so not plain `main`; the only difference between the two builds is a06e33b. Each build ran 10 minutes from a story save that loads straight into the world. | | before a06e33b | with a06e33b | |---|---:|---:| | title slots kept | 721,469 | 934,464 | | dynamic slots | 262,144 | 65,533 | | draws dropped: "no dynamic slots for its tables" | **0** | **512+** (logged at powers of two) | | "no dynamic slots for root views" | 0 | 40 report lines of dropped mesh draws | | draws reading a title slot past the kept ones | 0 (523,715 left out, all `for_draw=false`) | 0 | So in the world, the 213,000 extra title slots weren't read by any draw, while the smaller dynamic range ran out once the scene got busy. I couldn't see it in the earlier world check because the cold shader cache was still dropping thousands of draws a frame for missing pipelines. The GPU tests still pass with the revert (`victory-gpu`, 228 passed on this card). If a scene turns up that reads title slots past 721,469, a middle ground would be easy: for example 131,072 dynamic slots, leaving about 856,000 for the title. I'd rather see such a case first than guess. AI-assisted (Claude Code); the runs were on my machine. No game data.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 11:39 UTC · original · approved these changes

Reviewed and verified dae68bb7 on Windows 11 with an RTX 5090 (1,000,000 shader-visible view heap cap), WARP, D3D12 Debug Layer (VICTORY_D3D12_DEBUG=1), and Windows 11 SDK dxil.dll.

  • probe_view_limit() runs ahead of shader-cache key construction, shader translation, and heap creation; view_heap_limit() is folded into shader_cache::key, and victory-shader's create_device applies the same cap probe so offline/test shader compilation and runtime heaps agree.
  • Keeping the full 2^18 dynamic range in HostHeap::new (dae68bb7) gives a consistent capped layout on RTX 5090 (limit=1000000, null_view=999998, count=721469, dynamic=262144, pairs_end=999997) with no Debug Layer errors on heap creation.

Verification results:

  • cargo xtask policy (190 files ok) and cargo clippy -p victory-gpu -p victory-shader -p victory --tests -- -D warnings (default and --all-features): clean.
  • RTX 5090 (default and VICTORY_D3D12_DEBUG=1 with --features diagnostics): descriptor::host::tests 15/15, memory::tests 8/8, descriptor::tests 7/7, and shader_cache::tests 4/4 all pass — fixing both pre-existing NVIDIA view-heap baseline failures (dynamic_slots_are_held_until_released and lists_share_a_table_and_copies_keep_their_views).
  • WARP (VICTORY_D3D12_WARP=1 + VICTORY_D3D12_DEBUG=1 with --features diagnostics): descriptor::host::tests 15/15, memory::tests 8/8, shader_cache::tests 4/4 all pass.
  • victory-shader stride_tests (RTX 5090 + WARP + SDK dxil.dll): 7/8 pass, fixing a_heap_buffer_read_where_no_buffer_view_is_reads_zeros on both adapters (the remaining failure, a_heap_buffer_read_by_element_takes_the_views_stride, is the pre-existing NVIDIA structured-view failure on main).

One minor non-blocking note for a follow-up: under VICTORY_D3D12_DEBUG=1 on RTX 5090, the intentional CreateDescriptorHeap(2_097_152) probe logs a single startup Debug Layer error (NumDescriptors 2097152, but the limit for shader visible view heaps is 1000000). Checking D3D12_FEATURE_D3D12_OPTIONS19::MaxViewDescriptorHeapSize first (keeping the probe as fallback) would silence that and cover other hardware caps cleanly.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 11:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#pullrequestreview-6073507672) · **approved these changes** Reviewed and verified `dae68bb7` on Windows 11 with an RTX 5090 (1,000,000 shader-visible view heap cap), WARP, D3D12 Debug Layer (`VICTORY_D3D12_DEBUG=1`), and Windows 11 SDK `dxil.dll`. - `probe_view_limit()` runs ahead of shader-cache key construction, shader translation, and heap creation; `view_heap_limit()` is folded into `shader_cache::key`, and `victory-shader`'s `create_device` applies the same cap probe so offline/test shader compilation and runtime heaps agree. - Keeping the full `2^18` dynamic range in `HostHeap::new` (`dae68bb7`) gives a consistent capped layout on RTX 5090 (`limit=1000000`, `null_view=999998`, `count=721469`, `dynamic=262144`, `pairs_end=999997`) with no Debug Layer errors on heap creation. Verification results: - `cargo xtask policy` (`190 files ok`) and `cargo clippy -p victory-gpu -p victory-shader -p victory --tests -- -D warnings` (default and `--all-features`): clean. - RTX 5090 (default and `VICTORY_D3D12_DEBUG=1` with `--features diagnostics`): `descriptor::host::tests` 15/15, `memory::tests` 8/8, `descriptor::tests` 7/7, and `shader_cache::tests` 4/4 all pass — fixing both pre-existing NVIDIA view-heap baseline failures (`dynamic_slots_are_held_until_released` and `lists_share_a_table_and_copies_keep_their_views`). - WARP (`VICTORY_D3D12_WARP=1` + `VICTORY_D3D12_DEBUG=1` with `--features diagnostics`): `descriptor::host::tests` 15/15, `memory::tests` 8/8, `shader_cache::tests` 4/4 all pass. - `victory-shader` `stride_tests` (RTX 5090 + WARP + SDK `dxil.dll`): 7/8 pass, fixing `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` on both adapters (the remaining failure, `a_heap_buffer_read_by_element_takes_the_views_stride`, is the pre-existing NVIDIA structured-view failure on `main`). One minor non-blocking note for a follow-up: under `VICTORY_D3D12_DEBUG=1` on RTX 5090, the intentional `CreateDescriptorHeap(2_097_152)` probe logs a single startup Debug Layer error (`NumDescriptors 2097152, but the limit for shader visible view heaps is 1000000`). Checking `D3D12_FEATURE_D3D12_OPTIONS19::MaxViewDescriptorHeapSize` first (keeping the probe as fallback) would silence that and cover other hardware caps cleanly.
Review of #2461 (fuzeofficlal): under the debug layer the probe's heap of
`HEAP_VIEWS` slots logs an error at start on a capped host. Where the
runtime and driver report `MaxViewDescriptorHeapSize` (D3D12 options 19)
of at least 1,000,000 (the size every binding tier takes), that size is
the limit, and no heap is tried; otherwise the probe runs as before. The
same in victory-shader's test device.

Test: descriptor::host::tests::a_reported_view_heap_size_is_the_limit (the
limit is the reported size where there is one, and a heap of the limit is
made).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_018sSQTfPXZpSkjMMNa7RB5G
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-26 12:00 UTC · original

@⁠fuzeofficlal, thanks for the review and the debug-layer note. It's in 6544a52.

  • Where the runtime and driver report MaxViewDescriptorHeapSize (D3D12 options 19) of at least 1,000,000 (the size every binding tier takes), that's the limit, and no heap is tried. Otherwise the probe runs as before. Same in victory-shader's test device.
  • New test: descriptor::host::tests::a_reported_view_heap_size_is_the_limit. The limit is the reported size, a heap of it is made, and with VICTORY_D3D12_DEBUG=1 no debug-layer error mentions a heap that was tried.
  • On an RTX 2080 with the Agility SDK runtime, options 19 reports 1,000,000. With the report ignored (the old probe), the test fails with the message you saw: CreateDescriptorHeap: D3D12_DESCRIPTOR_HEAP_DESC.NumDescriptors 2097152, but the limit for shader visible view heaps is 1000000. With it, it passes. descriptor:: tests: 23 passed.
  • Without the Agility SDK, the Windows 10 runtime on this machine doesn't answer options 19, and the probe is used as before.

AI-assisted (Claude Code); tests on my machine. No game data.

**@⁠lhnizdo** on GitHub · 2026-11-26 12:00 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7191443766) @⁠fuzeofficlal, thanks for the review and the debug-layer note. It's in `6544a52`. - Where the runtime and driver report `MaxViewDescriptorHeapSize` (D3D12 options 19) of at least 1,000,000 (the size every binding tier takes), that's the limit, and no heap is tried. Otherwise the probe runs as before. Same in `victory-shader`'s test device. - New test: `descriptor::host::tests::a_reported_view_heap_size_is_the_limit`. The limit is the reported size, a heap of it is made, and with `VICTORY_D3D12_DEBUG=1` no debug-layer error mentions a heap that was tried. - On an RTX 2080 with the Agility SDK runtime, options 19 reports 1,000,000. With the report ignored (the old probe), the test fails with the message you saw: `CreateDescriptorHeap: D3D12_DESCRIPTOR_HEAP_DESC.NumDescriptors 2097152, but the limit for shader visible view heaps is 1000000`. With it, it passes. `descriptor::` tests: 23 passed. - Without the Agility SDK, the Windows 10 runtime on this machine doesn't answer options 19, and the probe is used as before. AI-assisted (Claude Code); tests on my machine. No game data.
Author
Owner

@⁠JurajSimicevic on GitHub · 2026-11-26 12:52 UTC · original

In the world on an RTX 5080 (Blackwell): A/B with and without this PR

Setup: RTX 5080, driver 617.42, Windows 11 26200.

  • Diag build of main 63bcca4 + #2178 (structured buffer reads on NVIDIA), with and without this PR at dae68bb. The only conflict was the cache key in shader_cache.rs, where I kept both settings.
  • #1968's program A skipped and VICTORY_D3D12_DRED=1.
  • Shader cache and pipeline library warmed for each build.
  • One run per build, about 7 minutes in the world from the first cell scene, camera turning.

The two builds differ only in this PR.

without with this PR
title slots kept / dynamic slots 934,464 / 65,536 721,469 / 262,144
per-frame drop reports in the world 67 68
draws dropped per frame for dynamic slots (no dynamic slots for root views / for its tables) median 1,167, p90 3,423, max 4,080 0 in every report
draws reading a left-out title slot (for_draw=true) 0 0
most draws in a frame 9,631 10,190
device removed no no

Without the PR, most of the dropped draws are mesh and indirect mesh draws. With the camera still, parts of the scene came and went from one frame to the next, which fits drops that vary from 0 to 4,080 per frame. With it, I saw no drop for dynamic slots in the world at all. As on lhnizdo's RTX 2080, no draw read one of the 523,715 title slots left out.

Since then 6544a52 takes the cap from options 19 instead of the probe. The heap layout is the same, so I don't expect it to change these numbers, but I haven't run that head.

What stays the same with and without the PR is the picture frozen in screen space described on #841. The lit target is never cleared, so this PR's extra draws are laid over older frames' content. That is a separate problem.

Local diagnostics only. No game data: log counts only.

AI-assisted.

**@⁠JurajSimicevic** on GitHub · 2026-11-26 12:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7192579052) **In the world on an RTX 5080 (Blackwell): A/B with and without this PR** Setup: RTX 5080, driver 617.42, Windows 11 26200. - Diag build of `main` `63bcca4` + #2178 (structured buffer reads on NVIDIA), with and without this PR at `dae68bb`. The only conflict was the cache key in `shader_cache.rs`, where I kept both settings. - #1968's program A skipped and `VICTORY_D3D12_DRED=1`. - Shader cache and pipeline library warmed for each build. - One run per build, about 7 minutes in the world from the first cell scene, camera turning. The two builds differ only in this PR. | | without | with this PR | |---|---:|---:| | title slots kept / dynamic slots | 934,464 / 65,536 | 721,469 / 262,144 | | per-frame drop reports in the world | 67 | 68 | | draws dropped per frame for dynamic slots (`no dynamic slots for root views` / `for its tables`) | median 1,167, p90 3,423, max 4,080 | 0 in every report | | draws reading a left-out title slot (`for_draw=true`) | 0 | 0 | | most draws in a frame | 9,631 | 10,190 | | device removed | no | no | Without the PR, most of the dropped draws are mesh and indirect mesh draws. With the camera still, parts of the scene came and went from one frame to the next, which fits drops that vary from 0 to 4,080 per frame. With it, I saw no drop for dynamic slots in the world at all. As on lhnizdo's RTX 2080, no draw read one of the 523,715 title slots left out. Since then `6544a52` takes the cap from options 19 instead of the probe. The heap layout is the same, so I don't expect it to change these numbers, but I haven't run that head. What stays the same with and without the PR is the picture frozen in screen space described on #841. The lit target is never cleared, so this PR's extra draws are laid over older frames' content. That is a separate problem. Local diagnostics only. No game data: log counts only. AI-assisted.
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-26 13:14 UTC · original

@⁠JurajSimicevic, thank you for running this in the world on Blackwell. It's the comparison the layout needed: 0 drops for dynamic slots with the PR against a median of 1,167 per frame without it, and still no draw reading a left-out title slot. It matches what I saw on the RTX 2080, on a second architecture.

You're right that 6544a52 shouldn't change the layout: options 19 reports the same 1,000,000 on NVIDIA, and the capped branch is unchanged. It only stops the probe's oversized heap from being tried.

AI-assisted (Claude Code). No game data.

**@⁠lhnizdo** on GitHub · 2026-11-26 13:14 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7193066328) @⁠JurajSimicevic, thank you for running this in the world on Blackwell. It's the comparison the layout needed: 0 drops for dynamic slots with the PR against a median of 1,167 per frame without it, and still no draw reading a left-out title slot. It matches what I saw on the RTX 2080, on a second architecture. You're right that `6544a52` shouldn't change the layout: options 19 reports the same 1,000,000 on NVIDIA, and the capped branch is unchanged. It only stops the probe's oversized heap from being tried. AI-assisted (Claude Code). No game data.
Author
Owner

@⁠potatoe0100 on GitHub · 2026-11-26 14:20 UTC · original · reviewed

RTX 4060 8 GB (Ada), driver 621.14, Windows 11 Pro 26300. Head 6544a52 merged onto main 63bcca4 (clean). cargo test -p victory-gpu -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index (#2571):

main + this PR
victory-gpu 229 passed, 2 failed 232 passed, 0 failed
victory-shader 298 passed, 3 failed 299 passed, 2 failed

Fixed here: dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and a_heap_buffer_read_where_no_buffer_view_is_reads_zeros. The two left fail on main too and are separate: a_heap_buffer_read_by_element_takes_the_views_stride (#2178 / #2464) and gathers_at_a_level_match_the_hardware. a_reported_view_heap_size_is_the_limit passes: options 19 reports 1,000,000 on this card, so no oversized heap is tried.

Two notes from reading the code:

  1. The triage note above describes 2b5f652 (934,464 title slots, 2^16 dynamic). That layout was reverted in dae68bb. The head keeps 721,469 title slots and 2^18 dynamic, which is the layout the RTX 2080 and RTX 5080 world runs in this thread measured.

  2. The capped branch takes 721,469 title slots for every title heap size, including heaps main mirrors whole. A throwaway test calling HostHeap::new(false, count) on this card:

title heap main kept / dynamic this PR kept / dynamic
800,000 800,000 / 65,536 721,469 / 262,144
933,888 933,888 / 65,536 721,469 / 262,144
1,245,184 934,464 / 65,536 721,469 / 262,144

For the retail heap (1,245,184) that is the intended trade. But 933,888 is the heap #1760 gets by lowering the title's page count so it fits the cap whole, and with this PR 212,419 of those slots would be left out again. Not a blocker for this PR. A follow-up could keep every title slot when the title plus at least MIN_DYNAMIC and the null slots fit under the cap, and use 721,469 only when they don't.

Minor: a title index read straight from the heap (not through a table) between 721,469 and 999,996 now lands on a dynamic or pair slot instead of null. On main that window was 934,464 to 999,999, and anything past 1,000,000 faulted, so this is still a net improvement. #2628 sends such indices to the null view if it turns out to matter.

AI-assisted (Claude). Unit tests only, no game data.

**@⁠potatoe0100** on GitHub · 2026-11-26 14:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#pullrequestreview-6075710369) · **reviewed** RTX 4060 8 GB (Ada), driver 621.14, Windows 11 Pro 26300. Head `6544a52` merged onto `main` `63bcca4` (clean). `cargo test -p victory-gpu -p victory-shader --lib --locked -- --test-threads=1 --skip heap_direct_texture_reads_mark_their_heap_index` (#2571): | | `main` | + this PR | |---|---|---| | victory-gpu | 229 passed, 2 failed | 232 passed, 0 failed | | victory-shader | 298 passed, 3 failed | 299 passed, 2 failed | Fixed here: `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`. The two left fail on `main` too and are separate: `a_heap_buffer_read_by_element_takes_the_views_stride` (#2178 / #2464) and `gathers_at_a_level_match_the_hardware`. `a_reported_view_heap_size_is_the_limit` passes: options 19 reports 1,000,000 on this card, so no oversized heap is tried. Two notes from reading the code: 1. The triage note above describes `2b5f652` (934,464 title slots, 2^16 dynamic). That layout was reverted in `dae68bb`. The head keeps 721,469 title slots and 2^18 dynamic, which is the layout the RTX 2080 and RTX 5080 world runs in this thread measured. 2. The capped branch takes 721,469 title slots for every title heap size, including heaps `main` mirrors whole. A throwaway test calling `HostHeap::new(false, count)` on this card: | title heap | `main` kept / dynamic | this PR kept / dynamic | |---:|---|---| | 800,000 | 800,000 / 65,536 | 721,469 / 262,144 | | 933,888 | 933,888 / 65,536 | 721,469 / 262,144 | | 1,245,184 | 934,464 / 65,536 | 721,469 / 262,144 | For the retail heap (1,245,184) that is the intended trade. But 933,888 is the heap #1760 gets by lowering the title's page count so it fits the cap whole, and with this PR 212,419 of those slots would be left out again. Not a blocker for this PR. A follow-up could keep every title slot when the title plus at least `MIN_DYNAMIC` and the null slots fit under the cap, and use 721,469 only when they don't. Minor: a title index read straight from the heap (not through a table) between 721,469 and 999,996 now lands on a dynamic or pair slot instead of null. On `main` that window was 934,464 to 999,999, and anything past 1,000,000 faulted, so this is still a net improvement. #2628 sends such indices to the null view if it turns out to matter. AI-assisted (Claude). Unit tests only, no game data.
Author
Owner

@⁠lhnizdo on GitHub · 2026-11-26 14:41 UTC · original

@⁠potatoe0100, thank you for the RTX 4060 run and the careful read. On the two notes:

  1. Right, the triage note describes 2b5f652, which dae68bb reverted. The head keeps 721,469 title slots and 2^18 dynamic slots, the layout the RTX 2080 and RTX 5080 world runs measured.

  2. Agreed, it's a real trade, and your table shows it well. What decided it here is that 2^16 dynamic slots run out in the world:

    • On the RTX 5080, JurajSimicevic measured a median of 1,167 dropped draws per frame (up to 4,080) for lack of dynamic slots without this PR, and 0 with it.
    • In both builds, no draw read a title slot past 721,469 (for_draw=true never appeared for the 523,715 left out).

    So keeping all 933,888 title slots, with only 2^16 dynamic slots left under the cap, would bring those drops back.

    A follow-up along the lines you suggest makes sense once #1760 lands and its title actually indexes past 721,469. The rule would be to keep every title slot whenever the title plus 2^18 dynamic slots, the pairs and the null slots fit, and only cut it when they don't. If such a title needs more of its slots than that leaves, a middle ground such as 2^17 dynamic slots (about 856,000 title slots) can be measured in the world then. I'd rather choose that point from a run than guess it now.

On the minor note: agreed, and #2628 sending such indices to the null view would close that window cleanly.

AI-assisted (Claude Code). No game data.

**@⁠lhnizdo** on GitHub · 2026-11-26 14:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7195187683) @⁠potatoe0100, thank you for the RTX 4060 run and the careful read. On the two notes: 1. Right, the triage note describes `2b5f652`, which `dae68bb` reverted. The head keeps 721,469 title slots and 2^18 dynamic slots, the layout the RTX 2080 and RTX 5080 world runs measured. 2. Agreed, it's a real trade, and your table shows it well. What decided it here is that 2^16 dynamic slots run out in the world: - On the RTX 5080, JurajSimicevic measured a median of 1,167 dropped draws per frame (up to 4,080) for lack of dynamic slots without this PR, and 0 with it. - In both builds, no draw read a title slot past 721,469 (`for_draw=true` never appeared for the 523,715 left out). So keeping all 933,888 title slots, with only 2^16 dynamic slots left under the cap, would bring those drops back. A follow-up along the lines you suggest makes sense once #1760 lands and its title actually indexes past 721,469. The rule would be to keep every title slot whenever the title plus 2^18 dynamic slots, the pairs and the null slots fit, and only cut it when they don't. If such a title needs more of its slots than that leaves, a middle ground such as 2^17 dynamic slots (about 856,000 title slots) can be measured in the world then. I'd rather choose that point from a run than guess it now. On the minor note: agreed, and #2628 sending such indices to the null view would close that window cleanly. AI-assisted (Claude Code). No game data.
Author
Owner

@⁠neonbyte1 on GitHub · 2026-11-26 18:20 UTC · original

Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton.

Build: main plus a few unmerged PRs this setup needs, with this PR (6544a52) merged on top. Two files conflicted with our base (descriptor/host.rs, shader_cache.rs); I kept this PR's capped branch, CAPPED_PAIRS and the probe_view_limit call. 10-minute runs in the opening yard.

without this PR with this PR (2 runs)
host view cap 1,000,000 (assumed) 1,041,451 (as reported, OPTIONS19 through vkd3d-proton)
title slots kept 713,280 762,920 of 1,245,184
no room for the null buffer views warnings 2 0
title slot past the host heap (all for_draw=false) 531,904 482,264
dynamic-slot shortages, device removed, Xid 0 0
dropped draws/frame (median) 372 379 / 377
ms/frame, min / median 831 / 871 817 / 873 and 815 / 993

So on vkd3d-proton the reported cap works. The null views now have their slots, and about 50k more title slots are mirrored.

The pictures at frames 1500 and 1700 match the run without this PR (mean difference about 2/255). The second run's higher median frame time is GPU time in a slow middle stretch (up to 1,126 ms) before it settled at 815–852 ms; the first run starts at about 1,000 ms the same way. The minimums match, so I read it as this scene's run-to-run variation, not as a cost of this PR. Nothing past the cap is read by a draw in this scene, so the gain here is correctness, not frame time.

AI-assisted (Claude); measured on my machine, no game data shared.

**@⁠neonbyte1** on GitHub · 2026-11-26 18:20 UTC · [original](https://github.com/Marvisak/VIctory/pull/2461#issuecomment-7200338349) Tested in game on an RTX 5090 (driver 620.73.04), Linux, GE-Proton11-14 Wine with its vkd3d-proton. **Build:** `main` plus a few unmerged PRs this setup needs, with this PR (`6544a52`) merged on top. Two files conflicted with our base (`descriptor/host.rs`, `shader_cache.rs`); I kept this PR's capped branch, `CAPPED_PAIRS` and the `probe_view_limit` call. 10-minute runs in the opening yard. | | without this PR | with this PR (2 runs) | |---|---|---| | host view cap | 1,000,000 (assumed) | **1,041,451** (`as reported`, OPTIONS19 through vkd3d-proton) | | title slots kept | 713,280 | **762,920** of 1,245,184 | | `no room for the null buffer views` warnings | 2 | **0** | | `title slot past the host heap` (all `for_draw=false`) | 531,904 | 482,264 | | dynamic-slot shortages, device removed, Xid | 0 | 0 | | dropped draws/frame (median) | 372 | 379 / 377 | | ms/frame, min / median | 831 / 871 | 817 / 873 and 815 / 993 | So on vkd3d-proton the reported cap works. The null views now have their slots, and about 50k more title slots are mirrored. The pictures at frames 1500 and 1700 match the run without this PR (mean difference about 2/255). The second run's higher median frame time is GPU time in a slow middle stretch (up to 1,126 ms) before it settled at 815–852 ms; the first run starts at about 1,000 ms the same way. The minimums match, so I read it as this scene's run-to-run variation, not as a cost of this PR. Nothing past the cap is read by a draw in this scene, so the gain here is correctness, not frame time. _AI-assisted (Claude); measured on my machine, no game data shared._
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2461/head:github-bot/gh-2461'
git switch 'github-bot/gh-2461'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2461'
git switch 'github-bot/gh-2461'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2461'
git switch 'github-bot/gh-2461'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2461'
git switch 'main'
git merge --squash 'github-bot/gh-2461'
git switch 'main'
git merge --ff-only 'github-bot/gh-2461'
git switch 'main'
git merge 'github-bot/gh-2461'
git push origin 'main'
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!2461
No description provided.