GPU+shader: clamp and place null buffer views within capped host descriptor heaps #2177

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

@⁠n-romanovich on GitHub · 2026-11-25 07:06 UTC · original
n-romanovich:pr/capped-descriptor-heaps → main · +237 −69 · 17 files · 6 commits · open

Summary

When a host GPU caps shader-visible CBV_SRV_UAV descriptor heaps below HEAP_VIEWS (e.g. 1_000_000 on NVIDIA), two issues occurred:

  1. Translated shaders still clamped heap indices to HEAP_VIEWS - 1 (2_097_151) and routed invalid buffer views in buffer_guard to NULL_BUFFER_VIEW (2_097_150), reading out of bounds past the 1_000_000-slot heap.
  2. When a title heap exceeded PORTABLE_VIEWS (e.g. 1_245_184 slots), HostHeap::new allocated PORTABLE_VIEWS - MIN_DYNAMIC title slots + MIN_DYNAMIC dynamic slots, leaving 0 slots for crate::memory copy view pairs (pairs_end == count + extra).

This change:

  • Probes the device's actual shader-visible view heap limit (host_heap_views(), up to HEAP_VIEWS) and propagates it to victory_shader::emit::set_host_heap_views and shader_cache::key.
  • Uses host_heap_views() and null_buffer_view() (host_heap_views() - 2) in heap_handle and buffer_guard so clamped indices and null SRV/UAV slots stay inside the allocated heap.
  • Reserves CAPPED_PAIRS (24_576) and CAPPED_DYNAMIC (1 << 17) plus the 3 top null/clamp slots when a title heap must be capped, and throttles past-heap diagnostics in HostHeap::mirror to populated VIEW_TAG entries.
  • Updates stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros and descriptor::host::tests::dynamic_slots_are_held_until_released to query max_views() / host_heap_views().

Verification

Tested on NVIDIA GeForce RTX 5060 Ti:

  • cargo test --release -p victory-shader --lib -- stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: 1 passed; 0 failed
  • cargo test --release -p victory-gpu --lib -- descriptor::host::tests memory::tests shader_cache::tests: 11 passed; 0 failed
**@⁠n-romanovich** on GitHub · 2026-11-25 07:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177) `n-romanovich:pr/capped-descriptor-heaps` → `main` · +237 −69 · 17 files · 6 commits · open ## Summary When a host GPU caps shader-visible `CBV_SRV_UAV` descriptor heaps below `HEAP_VIEWS` (e.g. `1_000_000` on NVIDIA), two issues occurred: 1. Translated shaders still clamped heap indices to `HEAP_VIEWS - 1` (`2_097_151`) and routed invalid buffer views in `buffer_guard` to `NULL_BUFFER_VIEW` (`2_097_150`), reading out of bounds past the `1_000_000`-slot heap. 2. When a title heap exceeded `PORTABLE_VIEWS` (e.g. `1_245_184` slots), `HostHeap::new` allocated `PORTABLE_VIEWS - MIN_DYNAMIC` title slots + `MIN_DYNAMIC` dynamic slots, leaving `0` slots for `crate::memory` copy view pairs (`pairs_end == count + extra`). This change: - Probes the device's actual shader-visible view heap limit (`host_heap_views()`, up to `HEAP_VIEWS`) and propagates it to `victory_shader::emit::set_host_heap_views` and `shader_cache::key`. - Uses `host_heap_views()` and `null_buffer_view()` (`host_heap_views() - 2`) in `heap_handle` and `buffer_guard` so clamped indices and null SRV/UAV slots stay inside the allocated heap. - Reserves `CAPPED_PAIRS` (`24_576`) and `CAPPED_DYNAMIC` (`1 << 17`) plus the 3 top null/clamp slots when a title heap must be capped, and throttles past-heap diagnostics in `HostHeap::mirror` to populated `VIEW_TAG` entries. - Updates `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros` and `descriptor::host::tests::dynamic_slots_are_held_until_released` to query `max_views()` / `host_heap_views()`. ## Verification Tested on NVIDIA GeForce RTX 5060 Ti: - `cargo test --release -p victory-shader --lib -- stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`: `1 passed; 0 failed` - `cargo test --release -p victory-gpu --lib -- descriptor::host::tests memory::tests shader_cache::tests`: `11 passed; 0 failed`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:57:30 +00:00
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 07:55 UTC · original

Offline measurement on a retail dump

Result: no count change against main.

I merged head 1a3261fe onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 07:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7156413485) ### Offline measurement on a retail dump **Result: no count change against `main`.** I merged head 1a3261fe onto `main` 940d32f (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 23,918 on `main`, 23,918 with this PR. No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-25 08:05 UTC · original

Shader tests on NVIDIA Ada

I ran cargo test --locked -p victory-shader --lib on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, VICTORY_WARP unset.

Build Passed Failed
main 940d32f 244 3: stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, synthetic_tests::gathers_at_a_level_match_the_hardware
this PR (head 1a3261f9) merged onto 940d32f 245 2: stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride, synthetic_tests::gathers_at_a_level_match_the_hardware

So on Ada this PR fixes stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, one of the three failures #1835 tracks. #2178 fixes stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride. The two PRs conflict with each other in victory-gpu/src/shader_cache.rs (each one adds its own parameter to key) and in victory-shader/src/emit/mod.rs, so I could not test them together. synthetic_tests::gathers_at_a_level_match_the_hardware still fails with both (lane 0 gives [0, 1, 0, 0], expected [0, 0, 0, 0]).

AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-25 08:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7156597469) ### Shader tests on NVIDIA Ada I ran `cargo test --locked -p victory-shader --lib` on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, `VICTORY_WARP` unset. | Build | Passed | Failed | |---|---|---| | `main` 940d32f | 244 | 3: `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `synthetic_tests::gathers_at_a_level_match_the_hardware` | | this PR (head 1a3261f9) merged onto 940d32f | 245 | 2: `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`, `synthetic_tests::gathers_at_a_level_match_the_hardware` | So on Ada this PR fixes `stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, one of the three failures #1835 tracks. #2178 fixes `stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride`. **The two PRs conflict with each other** in `victory-gpu/src/shader_cache.rs` (each one adds its own parameter to `key`) and in `victory-shader/src/emit/mod.rs`, so I could not test them together. `synthetic_tests::gathers_at_a_level_match_the_hardware` still fails with both (lane 0 gives `[0, 1, 0, 0]`, expected `[0, 0, 0, 0]`). AI-assisted (Claude Code).
Author
Owner

@⁠Venom2054 on GitHub · 2026-11-25 09:16 UTC · original

I found a remaining allocation-bound issue in this PR on an RTX 5070 Ti (16 GB, NVIDIA 621.01, Windows 11 Pro 26200).

Tested base: main 940d32f69b22265690a0b5a15d6ded572ba33baf + this PR at 1a3261fe2e2c054c7f93060958f7888316370703.

For HostHeap::new(false, 800_000) on a device capped at 1,000,000 views, the first allocation of 1,062,144 is rejected. The smaller fallback succeeds with 865,536 descriptors, but the shader clamp still reaches 999,999 and the null SRV index is 999,998. Both can lie beyond the actual allocation.

The fallback needs to allocate at least views:

-            match make(count + MIN_DYNAMIC) {
+            match make((count + MIN_DYNAMIC).max(views)) {

I also tested this regression in descriptor/host.rs:

    #[test]
    fn a_capped_heap_keeps_the_shader_clamp_and_null_views_in_bounds() {
        let Some(heap) = HostHeap::new(false, 800_000) else {
            return; // no host GPU
        };
        // SAFETY: a plain query of a live descriptor heap.
        let total = unsafe { heap.heap.GetDesc() }.NumDescriptors;
        assert!(
            total >= victory_shader::emit::host_heap_views(),
            "the fallback heap has {total} slots, fewer than the shader clamp",
        );
        assert!(victory_shader::emit::null_buffer_view() < total);
    }

Before the fix, the new test failed with the fallback heap has 865536 slots, fewer than the shader clamp. After it, the GPU suite passed: 147 passed, 0 failed, 2 ignored on this isolated integration.

Command:

cargo test -p victory-gpu --lib --profile diag --all-features --locked -- --test-threads=1

Build, Clippy and asset policy also passed. The full workspace at this stage had 704 passed, 2 failed, 10 ignored; both failures also reproduced on original main (a_heap_buffer_read_by_element_takes_the_views_stride and gathers_at_a_level_match_the_hardware). These numbers describe this PR plus the small fix, not my later integration with additional PRs.

The test uses synthetic allocations and no game data. This fixes the allocation bound; it does not establish a fix for a separate title GPU crash.

Prepared and tested with assistance from OpenAI Codex. Feel free to incorporate the correction and regression test into this PR.

Venom

**@⁠Venom2054** on GitHub · 2026-11-25 09:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7158105837) I found a remaining allocation-bound issue in this PR on an RTX 5070 Ti (16 GB, NVIDIA 621.01, Windows 11 Pro 26200). Tested base: main `940d32f69b22265690a0b5a15d6ded572ba33baf` + this PR at `1a3261fe2e2c054c7f93060958f7888316370703`. For `HostHeap::new(false, 800_000)` on a device capped at 1,000,000 views, the first allocation of 1,062,144 is rejected. The smaller fallback succeeds with 865,536 descriptors, but the shader clamp still reaches 999,999 and the null SRV index is 999,998. Both can lie beyond the actual allocation. The fallback needs to allocate at least `views`: ```diff - match make(count + MIN_DYNAMIC) { + match make((count + MIN_DYNAMIC).max(views)) { ``` I also tested this regression in `descriptor/host.rs`: ```rust #[test] fn a_capped_heap_keeps_the_shader_clamp_and_null_views_in_bounds() { let Some(heap) = HostHeap::new(false, 800_000) else { return; // no host GPU }; // SAFETY: a plain query of a live descriptor heap. let total = unsafe { heap.heap.GetDesc() }.NumDescriptors; assert!( total >= victory_shader::emit::host_heap_views(), "the fallback heap has {total} slots, fewer than the shader clamp", ); assert!(victory_shader::emit::null_buffer_view() < total); } ``` Before the fix, the new test failed with `the fallback heap has 865536 slots, fewer than the shader clamp`. After it, the GPU suite passed: **147 passed, 0 failed, 2 ignored** on this isolated integration. Command: ```text cargo test -p victory-gpu --lib --profile diag --all-features --locked -- --test-threads=1 ``` Build, Clippy and asset policy also passed. The full workspace at this stage had 704 passed, 2 failed, 10 ignored; both failures also reproduced on original main (`a_heap_buffer_read_by_element_takes_the_views_stride` and `gathers_at_a_level_match_the_hardware`). These numbers describe this PR plus the small fix, not my later integration with additional PRs. The test uses synthetic allocations and no game data. This fixes the allocation bound; it does not establish a fix for a separate title GPU crash. Prepared and tested with assistance from OpenAI Codex. Feel free to incorporate the correction and regression test into this PR. Venom
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-25 10:49 UTC · original

I reproduced Venom2054’s allocation finding on a second NVIDIA model, an RTX 5080 with driver 621.40. With 800,000 title entries, the real HostHeap fallback allocated 865,536 descriptors while the shader expected 1,000,000 and selected null SRV slot 999,998. A host-side assertion caught the discrepancy before dispatch.

With Venom2054’s one-line correction, the same allocation returned 1,000,000 descriptors and a missing buffer slot read back 32/32 zeros. Built-in WARP allocated 2,097,152 descriptors in both builds, with null SRV slot 2,097,150. The A/B held #2178 and the rest of the combined tree fixed. Original finding · One-line commit directly on this PR head

To pick it onto 1a3261f:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/structured-srv-readbacks
git cherry-pick 11504f7edafbc1382d7e9153c79c7fb9c7560a96

The corrected allocation also let me check 12-byte structured subviews through the production heap. Their offset-dependent read failures and the separate SRV fix are documented on #2178. Full paired results and runnable tests

**@⁠steven-seagull27** on GitHub · 2026-11-25 10:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7160224667) I reproduced Venom2054’s allocation finding on a second NVIDIA model, an RTX 5080 with driver 621.40. With 800,000 title entries, the real `HostHeap` fallback allocated **865,536 descriptors** while the shader expected 1,000,000 and selected null SRV slot 999,998. A host-side assertion caught the discrepancy before dispatch. With Venom2054’s one-line correction, the same allocation returned **1,000,000 descriptors** and a missing buffer slot read back **32/32 zeros**. Built-in WARP allocated 2,097,152 descriptors in both builds, with null SRV slot 2,097,150. The A/B held #2178 and the rest of the combined tree fixed. [Original finding](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2177) · [One-line commit directly on this PR head](https://github.com/steven-seagull27/VIctory/commit/11504f7edafbc1382d7e9153c79c7fb9c7560a96) To pick it onto `1a3261f`: ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/structured-srv-readbacks git cherry-pick 11504f7edafbc1382d7e9153c79c7fb9c7560a96 ``` The corrected allocation also let me check 12-byte structured subviews through the production heap. Their offset-dependent read failures and the separate SRV fix are documented on #2178. [Full paired results and runnable tests](https://git.gtahub.st/github/Marvisak--VIctory/pulls/2178)
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 13:28 UTC · original · edited 2026-11-26 00:22 UTC

Automated triage for the maintainers.

Merge candidate (worth a look). On a host that caps shader-visible view heaps (NVIDIA, 1,000,000), translated shaders clamped indices and placed null buffer views at HEAP_VIEWS, past the heap. The head 0497f58 passes the probed limit (host::host_heap_views) through a new emit::Options::host_heap_views field (0 = HEAP_VIEWS) into Shader::heap_handle / buffer_guard, and puts it in shader_cache::key only when it differs, so uncapped hosts keep their cache. In HostHeap::new (descriptor/host.rs) the capped branch now reserves CAPPED_DYNAMIC dynamic slots plus CAPPED_PAIRS copy pairs below the null slots. CI check passes and it merges cleanly.

On your reply: I checked the three points. The process-wide atomic is gone. Title slots kept are now monotonic in count: they grow with count up to cap - CAPPED_DYNAMIC - CAPPED_PAIRS - 3 (844,349 on a 1M heap) and stay there. That is below main's 934,464 for counts in between, a trade the RTX 5070 Ti prologue measurement in the thread supports (peak 101,530 dynamic slots held; 3,763 failed allocations and a hang with 1 << 16). Remaining notes for the maintainer, not blockers: victory translate still passes the default (uncapped) options, so offline output on a capped host differs from what the runtime emits; CAPPED_PAIRS has not been exercised by a measured workload yet (per the tester). This overlaps #2176 in Options and shader_cache::key; whichever lands second needs a rebase.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 13:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7163823334) · edited 2026-11-26 00:22 UTC <!-- victory-triage v1 head=0497f58408a446e7d86566a141e39d6a7da63237 verdict=merge-candidate at=2026-11-26T00:22:43Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** On a host that caps shader-visible view heaps (NVIDIA, 1,000,000), translated shaders clamped indices and placed null buffer views at `HEAP_VIEWS`, past the heap. The head `0497f58` passes the probed limit (`host::host_heap_views`) through a new `emit::Options::host_heap_views` field (0 = `HEAP_VIEWS`) into `Shader::heap_handle` / `buffer_guard`, and puts it in `shader_cache::key` only when it differs, so uncapped hosts keep their cache. In `HostHeap::new` (`descriptor/host.rs`) the capped branch now reserves `CAPPED_DYNAMIC` dynamic slots plus `CAPPED_PAIRS` copy pairs below the null slots. CI `check` passes and it merges cleanly. On your reply: I checked the three points. The process-wide atomic is gone. Title slots kept are now monotonic in `count`: they grow with `count` up to `cap - CAPPED_DYNAMIC - CAPPED_PAIRS - 3` (844,349 on a 1M heap) and stay there. That is below `main`'s 934,464 for counts in between, a trade the RTX 5070 Ti prologue measurement in the thread supports (peak 101,530 dynamic slots held; 3,763 failed allocations and a hang with `1 << 16`). Remaining notes for the maintainer, not blockers: `victory translate` still passes the default (uncapped) options, so offline output on a capped host differs from what the runtime emits; `CAPPED_PAIRS` has not been exercised by a measured workload yet (per the tester). This overlaps #2176 in `Options` and `shader_cache::key`; whichever lands second needs a rebase. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-25 14:03 UTC · original

@⁠Marvisak, updated pr/capped-descriptor-heaps (d15c68b) to address the triage points:

  1. .max(views) in the MIN_DYNAMIC fallback: HostHeap::new in crates/victory-gpu/src/descriptor/host.rs now calls make((count + MIN_DYNAMIC).max(views)) instead of make(count + MIN_DYNAMIC), so heaps like 800,000 (865,536 with MIN_DYNAMIC) are still sized to at least host_heap_views() and keep the clamp / null-view slots in bounds.
  2. Regression test: added descriptor::host::tests::min_dynamic_fallback_keeps_at_least_host_heap_views (HostHeap::new(false, 800_000)).
  3. Coordination with #2178: both PRs touch shader_cache::key and emit/mod.rs; whichever lands second will rebase cleanly onto the first.
**@⁠n-romanovich** on GitHub · 2026-11-25 14:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7164697789) @⁠Marvisak, updated `pr/capped-descriptor-heaps` (`d15c68b`) to address the triage points: 1. **`.max(views)` in the `MIN_DYNAMIC` fallback**: `HostHeap::new` in `crates/victory-gpu/src/descriptor/host.rs` now calls `make((count + MIN_DYNAMIC).max(views))` instead of `make(count + MIN_DYNAMIC)`, so heaps like `800,000` (`865,536` with `MIN_DYNAMIC`) are still sized to at least `host_heap_views()` and keep the clamp / null-view slots in bounds. 2. **Regression test**: added `descriptor::host::tests::min_dynamic_fallback_keeps_at_least_host_heap_views` (`HostHeap::new(false, 800_000)`). 3. **Coordination with #2178**: both PRs touch `shader_cache::key` and `emit/mod.rs`; whichever lands second will rebase cleanly onto the first.
Author
Owner

@⁠Venom2054 on GitHub · 2026-11-25 14:56 UTC · original

I retested the updated PR at d15c68bc on an RTX 5070 Ti, NVIDIA 621.01, Windows 11 build 26200. For 800,000 requested entries, the live D3D12 heap reported 1,000,000 descriptors. The shader limit was 1,000,000 and the null SRV index was 999,998.

As a control, I restored the previous allocation expression in a scratch copy of the same commit. The heap then reported 865,536 descriptors and the new min_dynamic_fallback_keeps_at_least_host_heap_views test failed its size assertion. Both measurements used the same test-only print of the heap descriptor count, shader limit, and null SRV index.

On the unmodified PR, the full victory-gpu library suite passed (147 passed, 0 failed, 2 ignored benchmarks). The separate missing-buffer shader test also passed on hardware and WARP, reading back 32 zeros on each. This verifies the allocation fix I reported earlier on this card.

**@⁠Venom2054** on GitHub · 2026-11-25 14:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7166045916) I retested the updated PR at `d15c68bc` on an RTX 5070 Ti, NVIDIA 621.01, Windows 11 build 26200. For 800,000 requested entries, the live D3D12 heap reported 1,000,000 descriptors. The shader limit was 1,000,000 and the null SRV index was 999,998. As a control, I restored the previous allocation expression in a scratch copy of the same commit. The heap then reported 865,536 descriptors and the new `min_dynamic_fallback_keeps_at_least_host_heap_views` test failed its size assertion. Both measurements used the same test-only print of the heap descriptor count, shader limit, and null SRV index. On the unmodified PR, the full `victory-gpu` library suite passed (147 passed, 0 failed, 2 ignored benchmarks). The separate missing-buffer shader test also passed on hardware and WARP, reading back 32 zeros on each. This verifies the allocation fix I reported earlier on this card.
Author
Owner

@⁠Venom2054 on GitHub · 2026-11-25 15:17 UTC · original

I measured the dynamic reserve on an RTX 5070 Ti (621.01, Windows 11 build 26200) during the prologue. The title requested 1,245,184 descriptors from a host heap capped at 1,000,000. The first request that failed with MIN_DYNAMIC needed just 9 consecutive slots, 58.9 seconds after launch.

Capped view heap PR reserve MIN_DYNAMIC
Dynamic slots reserved 131,072 65,536
Title slots mirrored 844,349 909,885
Peak dynamic slots held simultaneously 101,530 65,500
Calls that found no contiguous range 0 of 960,545 3,763 of 124,885
Peak dedicated SRV/UAV pairs used 0 0

With the PR reserve the game reached the yard and kept presenting until the 258 s cutoff. With MIN_DYNAMIC, D3D12 reported DXGI_ERROR_DEVICE_HUNG at 107.0 s and the process exited at 111.7 s. The refusals came first. One run per layout leaves the cause of the hang open.

This supports keeping more than 65,536 dynamic slots for this workload. The largest single request was 256 slots in both runs. Neither run exercised the separate 24,576-slot reserve (12,288 pairs) or spilled a pair into the dynamic pool on this heap, so sizing CAPPED_PAIRS still needs a different workload.

I used a local integration that reaches the yard and checked the allocator and capped layout against d15c68bc. Both runs used the same executable, initial save, pipeline cache and scripted inputs. Only the reserve setting changed. Counters tracked individual allocations and releases and were logged every eight presents. Final samples were at 253.3 s and 99.6 s respectively. Failed calls can include retries.

**@⁠Venom2054** on GitHub · 2026-11-25 15:17 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7166599466) I measured the dynamic reserve on an RTX 5070 Ti (621.01, Windows 11 build 26200) during the prologue. The title requested 1,245,184 descriptors from a host heap capped at 1,000,000. The first request that failed with `MIN_DYNAMIC` needed just **9 consecutive slots**, 58.9 seconds after launch. | Capped view heap | PR reserve | `MIN_DYNAMIC` | | --- | ---: | ---: | | Dynamic slots reserved | 131,072 | 65,536 | | Title slots mirrored | 844,349 | 909,885 | | Peak dynamic slots held simultaneously | **101,530** | 65,500 | | Calls that found no contiguous range | **0** of 960,545 | **3,763** of 124,885 | | Peak dedicated SRV/UAV pairs used | 0 | 0 | With the PR reserve the game reached the yard and kept presenting until the 258 s cutoff. With `MIN_DYNAMIC`, D3D12 reported `DXGI_ERROR_DEVICE_HUNG` at 107.0 s and the process exited at 111.7 s. The refusals came first. One run per layout leaves the cause of the hang open. This supports keeping more than 65,536 dynamic slots for this workload. The largest single request was 256 slots in both runs. Neither run exercised the separate 24,576-slot reserve (12,288 pairs) or spilled a pair into the dynamic pool on this heap, so sizing `CAPPED_PAIRS` still needs a different workload. I used a local integration that reaches the yard and checked the allocator and capped layout against `d15c68bc`. Both runs used the same executable, initial save, pipeline cache and scripted inputs. Only the reserve setting changed. Counters tracked individual allocations and releases and were logged every eight presents. Final samples were at 253.3 s and 99.6 s respectively. Failed calls can include retries.
Author
Owner

@⁠n-romanovich on GitHub · 2026-11-25 22:57 UTC · original

@⁠Marvisak Updated pr/capped-descriptor-heaps (0497f58):

  • Moved host_heap_views into emit::Options (and lower::Parts / Shader), removing the process-wide HOST_HEAP_VIEWS atomic so offline victory translate and runtime translation are pure functions of Options.
  • Fixed the discontinuity in HostHeap::new so title_slots is monotonic in count on capped heaps (CAPPED_DYNAMIC is used consistently in the capped branch).
  • Added doc comments for CAPPED_DYNAMIC and noted the RTX 4060 / 1M-slot prologue measurement for CAPPED_PAIRS.
  • Merged main; victory-gpu / victory-shader tests and CI check pass.

Note: I am also the author of #2178 and will reconcile whichever lands second immediately after the first merges.

**@⁠n-romanovich** on GitHub · 2026-11-25 22:57 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#issuecomment-7176982597) @⁠Marvisak Updated `pr/capped-descriptor-heaps` (`0497f58`): - Moved `host_heap_views` into `emit::Options` (and `lower::Parts` / `Shader`), removing the process-wide `HOST_HEAP_VIEWS` atomic so offline `victory translate` and runtime translation are pure functions of `Options`. - Fixed the discontinuity in `HostHeap::new` so `title_slots` is monotonic in `count` on capped heaps (`CAPPED_DYNAMIC` is used consistently in the capped branch). - Added doc comments for `CAPPED_DYNAMIC` and noted the RTX 4060 / 1M-slot prologue measurement for `CAPPED_PAIRS`. - Merged `main`; `victory-gpu` / `victory-shader` tests and CI `check` pass. Note: I am also the author of #2178 and will reconcile whichever lands second immediately after the first merges.
Author
Owner

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

Verified locally merged onto origin/main (940d32f, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC):

  • cargo test -p victory-gpu — 143 passed, 0 failed (2 ignored) on NVIDIA RTX 5090 (resolves both 1M view-heap cap failures on main 940d32f)
  • cargo test -p victory-shader --lib emit::stride_tests:: — 5 passed, 1 failed on RTX 5090: directly fixes a_heap_buffer_read_where_no_buffer_view_is_reads_zeros! (The 1 remaining failure, a_heap_buffer_read_by_element_takes_the_views_stride, is the separate NVIDIA structured-view issue covered by #2178.)
  • cargo clippy -p victory-gpu -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok (183 files ok)

Clean clamping and null-buffer view placement within capped host descriptor heaps. (Note for triage: overlaps #2185 and #2121.)

AI-assisted (Gemini 4 Neon).

**@⁠DenRakEiw** on GitHub · 2026-11-25 07:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#pullrequestreview-6053418434) · **approved these changes** Verified locally merged onto `origin/main` (`940d32f`, Windows 11 x64, NVIDIA GeForce RTX 5090, Rust 1.98.1 MSVC): - `cargo test -p victory-gpu` — **143 passed, 0 failed** (2 ignored) on NVIDIA RTX 5090 (resolves both 1M view-heap cap failures on `main` `940d32f`) - `cargo test -p victory-shader --lib emit::stride_tests::` — **5 passed, 1 failed** on RTX 5090: directly fixes `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`! (The 1 remaining failure, `a_heap_buffer_read_by_element_takes_the_views_stride`, is the separate NVIDIA structured-view issue covered by #2178.) - `cargo clippy -p victory-gpu -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok (`183 files ok`) Clean clamping and null-buffer view placement within capped host descriptor heaps. (Note for triage: overlaps #2185 and #2121.) AI-assisted (Gemini 4 Neon).
Author
Owner

@⁠catminou4 on GitHub · 2026-11-25 07:30 UTC · original · approved these changes

Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, cargo test -p victory-shader --locked (shader half; the GPU half is Windows-only).

144 passed / 0 failed / 2 ignored. Null buffer views clamped and placed within capped host heaps — heap-cap safety for null views; mixed gpu+shader.

**@⁠catminou4** on GitHub · 2026-11-25 07:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#pullrequestreview-6053477207) · **approved these changes** Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f69b, `cargo test -p victory-shader --locked` (shader half; the GPU half is Windows-only). 144 passed / 0 failed / 2 ignored. Null buffer views clamped and placed within capped host heaps — heap-cap safety for null views; mixed gpu+shader.
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 16:52 UTC · original · requested changes

Verified 0497f58408a446e7d86566a141e39d6a7da63237 merged cleanly onto 63bcca43 on Windows 11 with both an RTX 5090 (1,000,000-slot view heap cap, VICTORY_D3D12_DEBUG=1) and WARP (uncapped 2,097,152 slots via --features diagnostics, VICTORY_D3D12_WARP=1, VICTORY_D3D12_DEBUG=1).

What already works well

  • Clean merge onto 63bcca43; crates/victory-shader/src/emit/lower.rs is 521,078 bytes (< 524,288 limit); cargo xtask policy (191 files ok) and cargo clippy --locked -p victory-gpu -p victory-shader -p victory --all-targets -- -D warnings (default and --all-features) are clean.
  • On the RTX 5090 with D3D12 Debug Layer enabled:
    • Full cargo test --locked -p victory-gpu --lib -- --test-threads=1: 232 passed, 0 failed, 1 ignored — resolves both pre-existing 1M view-heap cap failures (descriptor::host::tests::dynamic_slots_are_held_until_released and memory::tests::lists_share_a_table_and_copies_keep_their_views).
    • cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: 1 passed, 0 failed.
  • On WARP (--features diagnostics, VICTORY_D3D12_WARP=1): host_heap_views() == 2_097_152, null_buffer_view == 2_097_150, and descriptor::host::tests:: memory::tests:: shader_cache::tests:: bindless::tests:: pass 31/31 with uncapped cache keys preserved (shader_cache.rs:80).

Blocking issue: HostHeap::new DYNAMIC branch drops null buffer views and pairs room for count in 713_278..=737_856 on 1M-capped heaps (crates/victory-gpu/src/descriptor/host.rs:160)

At crates/victory-gpu/src/descriptor/host.rs:160:

} else if let Ok(heap) = make((count + DYNAMIC).max(views)) {
    (heap, count, DYNAMIC)
} else {
    let cap = views.max(PORTABLE_VIEWS);
    let reserve = CAPPED_PAIRS + 3;
    ...

Because views is now 1_000_000 on 1M-capped adapters, make((count + DYNAMIC).max(views)) succeeds without accounting for CAPPED_PAIRS + 3 (24_579 slots for memory pairs plus the 3 top null UAV / null SRV / clamp slots at 999_997..=999_999). Probing HostHeap::new(false, req) directly on the RTX 5090 (host_heap_views=1_000_000, null_buffer_view=999_998):

Requested count total count dynamic pairs_room null_fits (null > count + dynamic && null < total)
713_277 1_000_000 713_277 262_144 24_576 true
737_853 1_000_000 737_853 262_144 0 true
737_854 1_000_000 737_854 262_144 2 (slots 999_998..=999_999!) false
737_856 1_000_000 737_856 262_144 0 false
737_857 1_000_000 737_857 131_072 131_068 true

At req = 737_854..=737_856:

  • null > count + extra (descriptor/host.rs:218, 242) evaluates to false, so no null buffer views are installed and dynamic slots directly overlap 999_997..=999_999.
  • Even worse at req = 737_854, pairs_end falls back to total (1_000_000), leaving pairs starting at 999_998 — handing out the shader's null_buffer_view (999_998) and clamp slot (999_999) as a live crate::memory SRV/UAV pair.
  • For req = 713_278..=737_853, pairs_room shrinks down to 0 before jumping back up to 131_068 at 737_857.

Suggested 1-line fix

Account for CAPPED_PAIRS + 3 in the DYNAMIC branch at crates/victory-gpu/src/descriptor/host.rs:160:

} else if let Ok(heap) = make(count.saturating_add(DYNAMIC + CAPPED_PAIRS + 3).max(views)) {
    (heap, count, DYNAMIC)

Tested locally with that one-line change on both RTX 5090 (views=1_000_000) and WARP (views=2_097_152):

  • On RTX 5090, req = 713_278..=737_856 cleanly falls into the CAPPED_DYNAMIC branch with full count, 131_072 dynamic slots, 131_069..=155_647 pair slots, and null_fits = true across every tested count from 64 to 1_245_184.
  • On WARP (views=2_097_152), behavior for 64..=1_245_184 is unchanged (all keep DYNAMIC = 262_144 and null_fits = true).

(Minor non-blocking nit: the safety comment at crates/victory-gpu/src/descriptor/host.rs:542 still says HEAP_VIEWS where line 537 was updated to host_heap_views().)

**@⁠fuzeofficlal** on GitHub · 2026-11-26 16:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/2177#pullrequestreview-6077867407) · **requested changes** Verified `0497f58408a446e7d86566a141e39d6a7da63237` merged cleanly onto `63bcca43` on Windows 11 with both an RTX 5090 (1,000,000-slot view heap cap, `VICTORY_D3D12_DEBUG=1`) and WARP (uncapped 2,097,152 slots via `--features diagnostics`, `VICTORY_D3D12_WARP=1`, `VICTORY_D3D12_DEBUG=1`). ### What already works well - Clean merge onto `63bcca43`; `crates/victory-shader/src/emit/lower.rs` is `521,078` bytes (`< 524,288` limit); `cargo xtask policy` (`191 files ok`) and `cargo clippy --locked -p victory-gpu -p victory-shader -p victory --all-targets -- -D warnings` (default and `--all-features`) are clean. - On the RTX 5090 with D3D12 Debug Layer enabled: - Full `cargo test --locked -p victory-gpu --lib -- --test-threads=1`: **232 passed, 0 failed, 1 ignored** — resolves both pre-existing 1M view-heap cap failures (`descriptor::host::tests::dynamic_slots_are_held_until_released` and `memory::tests::lists_share_a_table_and_copies_keep_their_views`). - `cargo test --locked -p victory-shader --lib -- --test-threads=1 emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`: **1 passed, 0 failed**. - On WARP (`--features diagnostics`, `VICTORY_D3D12_WARP=1`): `host_heap_views() == 2_097_152`, `null_buffer_view == 2_097_150`, and `descriptor::host::tests:: memory::tests:: shader_cache::tests:: bindless::tests::` pass **31/31** with uncapped cache keys preserved (`shader_cache.rs:80`). ### Blocking issue: `HostHeap::new` `DYNAMIC` branch drops null buffer views and `pairs` room for `count` in `713_278..=737_856` on 1M-capped heaps (`crates/victory-gpu/src/descriptor/host.rs:160`) At `crates/victory-gpu/src/descriptor/host.rs:160`: ```rust } else if let Ok(heap) = make((count + DYNAMIC).max(views)) { (heap, count, DYNAMIC) } else { let cap = views.max(PORTABLE_VIEWS); let reserve = CAPPED_PAIRS + 3; ... ``` Because `views` is now `1_000_000` on 1M-capped adapters, `make((count + DYNAMIC).max(views))` succeeds without accounting for `CAPPED_PAIRS + 3` (`24_579` slots for memory pairs plus the 3 top null UAV / null SRV / clamp slots at `999_997..=999_999`). Probing `HostHeap::new(false, req)` directly on the RTX 5090 (`host_heap_views=1_000_000`, `null_buffer_view=999_998`): | Requested `count` | `total` | `count` | `dynamic` | `pairs_room` | `null_fits` (`null > count + dynamic && null < total`) | | ---: | ---: | ---: | ---: | ---: | :---: | | `713_277` | `1_000_000` | `713_277` | `262_144` | `24_576` | `true` | | `737_853` | `1_000_000` | `737_853` | `262_144` | **`0`** | `true` | | **`737_854`** | `1_000_000` | `737_854` | `262_144` | **`2`** (slots `999_998..=999_999`!) | **`false`** | | **`737_856`** | `1_000_000` | `737_856` | `262_144` | **`0`** | **`false`** | | `737_857` | `1_000_000` | `737_857` | `131_072` | `131_068` | `true` | At `req = 737_854..=737_856`: - `null > count + extra` (`descriptor/host.rs:218, 242`) evaluates to `false`, so no null buffer views are installed and dynamic slots directly overlap `999_997..=999_999`. - Even worse at `req = 737_854`, `pairs_end` falls back to `total` (`1_000_000`), leaving `pairs` starting at `999_998` — handing out the shader's `null_buffer_view` (`999_998`) and clamp slot (`999_999`) as a live `crate::memory` SRV/UAV pair. - For `req = 713_278..=737_853`, `pairs_room` shrinks down to `0` before jumping back up to `131_068` at `737_857`. #### Suggested 1-line fix Account for `CAPPED_PAIRS + 3` in the `DYNAMIC` branch at `crates/victory-gpu/src/descriptor/host.rs:160`: ```rust } else if let Ok(heap) = make(count.saturating_add(DYNAMIC + CAPPED_PAIRS + 3).max(views)) { (heap, count, DYNAMIC) ``` Tested locally with that one-line change on both RTX 5090 (`views=1_000_000`) and WARP (`views=2_097_152`): - On RTX 5090, `req = 713_278..=737_856` cleanly falls into the `CAPPED_DYNAMIC` branch with full `count`, `131_072` dynamic slots, `131_069..=155_647` pair slots, and `null_fits = true` across every tested count from `64` to `1_245_184`. - On WARP (`views=2_097_152`), behavior for `64..=1_245_184` is unchanged (all keep `DYNAMIC = 262_144` and `null_fits = true`). *(Minor non-blocking nit: the safety comment at `crates/victory-gpu/src/descriptor/host.rs:542` still says `HEAP_VIEWS` where line 537 was updated to `host_heap_views()`.)*
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/2177/head:github-bot/gh-2177'
git switch 'github-bot/gh-2177'

Merge

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