Repository navigation
GPU+shader: clamp and place null buffer views within capped host descriptor heaps - #2177
n-romanovich wants to merge 1 commit 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 |
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