Repository navigation
GPU+shader: clamp and place null buffer views within capped host descriptor heaps - #2177
n-romanovich wants to merge 6 commits into
Conversation
DenRakEiw
left a comment
There was a problem hiding this comment.
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 onmain940d32f)cargo test -p victory-shader --lib emit::stride_tests::— 5 passed, 1 failed on RTX 5090: directly fixesa_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 warningscargo 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).
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, 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.
Offline measurement on a retail dumpResult: no count change against I merged head 1a3261f onto 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). |
Shader tests on NVIDIA AdaI ran
So on Ada this PR fixes AI-assisted (Claude Code). |
|
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 For The fallback needs to allocate at least - match make(count + MIN_DYNAMIC) {
+ match make((count + MIN_DYNAMIC).max(views)) {I also tested this regression in #[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 Command: 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 ( 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 |
|
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 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 git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/structured-srv-readbacks
git cherry-pick 11504f7edafbc1382d7e9153c79c7fb9c7560a96The 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 |
|
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 On your reply: I checked the three points. The process-wide atomic is gone. Title slots kept are now monotonic in Generated by Claude Code |
1a3261f to
d15c68b
Compare
|
@Marvisak, updated
|
|
I retested the updated PR at 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 On the unmodified PR, the full |
|
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
With the PR reserve the game reached the yard and kept presenting until the 258 s cutoff. With 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 I used a local integration that reaches the yard and checked the allocator and capped layout against |
…heaps # Conflicts: # crates/victory-gpu/src/descriptor/host.rs
|
@Marvisak Updated
Note: I am also the author of #2178 and will reconcile whichever lands second immediately after the first merges. |
…fer views within capped host descriptor heaps
…atch merge Reconcile four cross-PR interactions across the 32 merged PRs: - Marvisak#2953/Marvisak#2975 vs Marvisak#2811: read `self.mode16.round` in `div_fixup.rs` and `div_scale.rs` - Marvisak#2841 vs Marvisak#2177: pass `host_heap_views` in `pipeline.rs` partial-dispatch translation and `dispatch_threads.rs` - Marvisak#2841 vs Marvisak#2999: use guest group dimensions (`self.rows.or(self.s.threads)`) in `dispatch_guard` - Marvisak#2177 vs merged test fixtures: add `host_heap_views: 0` to `Parts` test initializers
…fer views within capped host descriptor heaps
…atch merge Reconcile four cross-PR interactions across the 32 merged PRs: - Marvisak#2953/Marvisak#2975 vs Marvisak#2811: read `self.mode16.round` in `div_fixup.rs` and `div_scale.rs` - Marvisak#2841 vs Marvisak#2177: pass `host_heap_views` in `pipeline.rs` partial-dispatch translation and `dispatch_threads.rs` - Marvisak#2841 vs Marvisak#2999: use guest group dimensions (`self.rows.or(self.s.threads)`) in `dispatch_guard` - Marvisak#2177 vs merged test fixtures: add `host_heap_views: 0` to `Parts` test initializers
fuzeofficlal
left a comment
There was a problem hiding this comment.
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.rsis521,078bytes (< 524,288limit);cargo xtask policy(191 files ok) andcargo 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_releasedandmemory::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.
- Full
- On WARP (
--features diagnostics,VICTORY_D3D12_WARP=1):host_heap_views() == 2_097_152,null_buffer_view == 2_097_150, anddescriptor::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 tofalse, so no null buffer views are installed and dynamic slots directly overlap999_997..=999_999.- Even worse at
req = 737_854,pairs_endfalls back tototal(1_000_000), leavingpairsstarting at999_998— handing out the shader'snull_buffer_view(999_998) and clamp slot (999_999) as a livecrate::memorySRV/UAV pair. - For
req = 713_278..=737_853,pairs_roomshrinks down to0before jumping back up to131_068at737_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_856cleanly falls into theCAPPED_DYNAMICbranch with fullcount,131_072dynamic slots,131_069..=155_647pair slots, andnull_fits = trueacross every tested count from64to1_245_184. - On WARP (
views=2_097_152), behavior for64..=1_245_184is unchanged (all keepDYNAMIC = 262_144andnull_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().)
|
NVIDIA test report: RTX 4070 Ti (desktop, driver 621.01), Windows 11 Pro, rustc 1.98.1. Head Confirmed:
Not tested:
Synthetic tests only, no game files. AI-assisted (Claude Code). |
|
Follow-up to my report above: the one-line change from the changes-requested review, tried on the same card. RTX 4070 Ti (desktop, driver 621.01), Windows 11 Pro, rustc 1.98.1. Head
Confirmed:
Not tested: an uncapped host (WARP or AMD) with this change, whether 131,072 dynamic slots are enough for a title asking for 713,278 to 737,856 slots, and a title at all (needs the game). Synthetic tests only, no game files. AI-assisted (Claude Code). |
Summary
When a host GPU caps shader-visible
CBV_SRV_UAVdescriptor heaps belowHEAP_VIEWS(e.g.1_000_000on NVIDIA), two issues occurred:HEAP_VIEWS - 1(2_097_151) and routed invalid buffer views inbuffer_guardtoNULL_BUFFER_VIEW(2_097_150), reading out of bounds past the1_000_000-slot heap.PORTABLE_VIEWS(e.g.1_245_184slots),HostHeap::newallocatedPORTABLE_VIEWS - MIN_DYNAMICtitle slots +MIN_DYNAMICdynamic slots, leaving0slots forcrate::memorycopy view pairs (pairs_end == count + extra).This change:
host_heap_views(), up toHEAP_VIEWS) and propagates it tovictory_shader::emit::set_host_heap_viewsandshader_cache::key.host_heap_views()andnull_buffer_view()(host_heap_views() - 2) inheap_handleandbuffer_guardso clamped indices and null SRV/UAV slots stay inside the allocated heap.CAPPED_PAIRS(24_576) andCAPPED_DYNAMIC(1 << 17) plus the 3 top null/clamp slots when a title heap must be capped, and throttles past-heap diagnostics inHostHeap::mirrorto populatedVIEW_TAGentries.stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerosanddescriptor::host::tests::dynamic_slots_are_held_until_releasedto querymax_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 failedcargo test --release -p victory-gpu --lib -- descriptor::host::tests memory::tests shader_cache::tests:11 passed; 0 failed