Repository navigation
GPU: populate unbound table slots with typed null descriptors - #2128
fuzeofficlal wants to merge 3 commits into
Conversation
HostHeap initializes empty view slots to a null 2D texture SRV. When a shader writes an unbound or unmakeable table UAV (or reads an empty or mismatched slot as another buffer or texture dimension), indexing the shared slot directly executes unordered writes against an SRV descriptor, faulting RDNA GPUs and failing D3D12 validation. Record constant-offset table handle annotations (TableView) during DXIL lowering and in the shader cache, and rebuild tables whose accessed slots lack a compatible live view in dynamic slots populated with matching null UAV or SRV descriptors while clamping per-entry reads to the guest heap bounds and leaving shared empty title slots untouched. Closes Marvisak#508
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Unbound table slots populated with typed null descriptors — descriptor completeness fix; mixed gpu+shader, shader side untested here (Windows D3D12 descriptors).
|
One remaining case on 6498c28 is a live SRV in a slot the shader annotates as a UAV. The live-view check accepts the slot, and the dynamic-table path also copies the SRV if another slot already caused a rebuild. c4edbb5 checks the SRV/UAV access kind in both paths and uses the existing typed null for a mismatch. The test failed before submission because VIctory left the raw SRV bound in place. After, the same test kept the original slot live, reused the replacement table on a second lookup and dispatched with WARP GPU-based validation. The null raw UAV read back zero and the output buffer recorded the shader's completion sentinel. The GPU suite went from 148 passed, 1 failed and 2 ignored to 149 passed and 2 ignored. Your unbound-table compute and pixel test also passed with GPU-based validation. Strict GPU Clippy with diagnostics and staged asset policy passed. The check covers SRV versus UAV access kind. |
|
Thanks @andrewpozdnakov7-jpg — good catch. A live SRV in a slot the shader annotates as a UAV got through both the live-view check and the copy into a rebuilt dynamic table. Your commit c4edbb5 is now on the branch as-is with your authorship (it fast-forwarded from our head), plus a rustfmt-only follow-up (4ec3f5f). It leaves CBV entries, sampler heaps and read-only SRV tables unchanged. Your test passes on hardware, on WARP with diagnostics and under the D3D12 debug layer; clippy is clean in both modes. |
Xvania7
left a comment
There was a problem hiding this comment.
Verified locally merged onto origin/main (940d32f, head 4ec3f5f, Windows 10 x64 19045, NVIDIA GeForce RTX 5060, Rust 1.98.1 MSVC):
cargo test -p victory-gpu --lib -- --test-threads=1 descriptor::— 10 passed, 1 failed (unrelated baseline #1835 NVIDIA 1M heap limit indynamic_slots_are_held_until_released; newnull_desc_for_props_covers_buffers_and_texturespassed)cargo test -p victory-gpu --lib -- --test-threads=1 list::tests::— 4 passed, 0 failedcargo test -p victory-gpu --lib -- --test-threads=1 draw::tests::— 6 passed, 1 failed (unrelated baseline #1999 Win10 in-boxID3D12Device10failure ina_texture_written_in_one_format_reads_in_another_through_a_placed_view; newa_live_srv_in_a_uav_table_gets_a_typed_nullandunbound_table_uavs_and_shared_null_slots_execute_cleanlypassed)cargo test -p victory-shader --lib emit::lower::tests::— 21 passed, 0 failedcargo clippy -p victory-gpu --all-targets -- -D warnings— 0 warningscargo xtask policy— 182 files ok
Clean typed null descriptors for unbound table slots.
Offline measurement on a retail dumpResult: no count change against I merged head 4ec3f5f 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). |
|
Automated triage for the maintainers. Merge candidate. The shader now records which table entries it loads at constant offsets, and with what SRV/UAV kind ( Points for the reviewer:
Generated by Claude Code |
|
I measured the table-recording cost raised in triage. The same Windows/WARP synthetic fixture uses a direct table of live R8G8B8A8_UNORM Texture2D SRVs. On the PR, the constant-offset metadata describes those same slots. The timed section is CPU time in State::tables, with the list and textures already created and a check that the table uses its original slots. The GPU crate was built with opt-level=3.
These are the medians of five alternating process runs per revision. Each process warms up 1,000 calls and measures seven batches of 25,000 calls. This measures CPU recording for these tables. A trial that saved the first pass's descriptor record to skip a second mirror lock ran slower in a separate paired replay (1.31 → 1.55 µs and 12.44 → 13.90 µs). I also checked the overlap with #2158. The exact heads 4ec3f5f and f346d1d conflict in draw.rs. b91d430 retains both parents and resolves it by allowing either reason to create a fresh table and keeping both the typed-null annotations and placed-buffer backing in the key. All three focused WARP GPU tests passed with the D3D12 debug layer enabled. The full WARP GPU suite had 150 passed and 2 ignored. Both strict GPU Clippy modes and staged asset policy passed. If you reuse the conflict resolution in a squashed commit, please preserve our attribution with this trailer: Co-authored-by: andrewpozdnakov7-jpg andrewpozdnakov7-jpg@users.noreply.github.com |
Xvania7
left a comment
There was a problem hiding this comment.
Hardware verification on real hardware: NVIDIA GeForce RTX 5060, Windows 10 x64, Rust 1.98.1.
Tested 4ec3f5f checked out into an isolated tree:
cargo clippy -p victory-gpu -- -D warnings: 0 warnings, clean.cargo clippy -p victory-shader -- -D warnings: 0 warnings, clean.cargo run -p xtask -- policy: clean (asset policy: 182 files ok).cargo test -p victory-shader table_views: passed (emit::stride_tests::table_views_record_constant_entries_prefer_uav_and_skip_dynamic ... ok).cargo test -p victory-gpu descriptor::host::tests:null_desc_for_props_covers_buffers_and_textures: oknull_3d_uav_is_accepted_by_the_device: oknull_uavs_keep_the_titles_dimension: okdynamic_search_can_find_a_run_across_the_cursor: okempty_and_overlong_buffer_views_are_refused: ok
(Note on NVIDIA:dynamic_slots_are_held_until_releasedassertsNumDescriptors >= 1<<20, which fails on NVIDIA's 1,000,000 cap until #1777 lands; typed null descriptor allocation itself runs completely clean).
Populating unbound table slots with typed null descriptors accurately eliminates device removal on unmapped UAV/SRV table reads/writes. LGTM.
Problem
HostHeapinitializes empty view slots to a null 2D float texture SRV (null_view). WhileRootType::ResourceHeapdirect buffer accesses are guarded viaVIEW_STRIDES, descriptor-table (RootType::Table) accesses to unbound, unmakeable, or mismatched slots still bind the shared title slot directly when all indices lie belowhost.count(). When a compute or graphics shader writes or executes atomics on an unbound table UAV (or reads an empty/mismatched slot as another buffer or texture dimension), hardware executes unordered writes against a 2D SRV descriptor, removing the device on RDNA GPUs and failing D3D12 validation.Changes
victory-shader+shader_cache: Record constant-offset descriptor-table handle annotations (TableView { slot, dword, props }) duringLower::handle(includingPhi/Selectleaves, preferring UAV when annotated both ways, and skipping waterfall/dynamic offsets) and round-trip them throughshader_cache.descriptor::host: Addnull_desc_for_propsandHostHeap::make_null_forto synthesize matching null SRV and UAV descriptors across typed, raw, and structured buffers (StructureByteStride+VIEW_STRIDES) and 1D/2D/2DMS/3D/Cube/array texture dimensions (F32/SINT/UINT), and preserve raw/structured buffer UAV flags innull_for.draw::State::tables: Keep fully bound tables and plain 2D float SRV empty slots on the in-place zero-copy path (683ad7a), while rebuilding tables whose accessed entries lack a compatible live view in dynamic slots (deduplicated infresh_tables, withheap.index(at)bounds checks for tables near the end of a title heap) so shared empty title slots inHostHeapare never mutated.Verification
victory-shader:stride_tests::table_views_record_constant_entries_prefer_uav_and_skip_dynamic(dxil.dllvalidated).victory-gpu:descriptor::host::tests::null_desc_for_props_covers_buffers_and_textures,shader_cacheround-trip, anddraw::tests::unbound_table_uavs_and_shared_null_slots_execute_cleanly(in-place shared slot02D SRV read, 5 unbound compute UAVs + mismatched explicit-null SRV,PAGE_NOACCESSheap-tail guard page table, and pixel-shader unbound UAV draw) verified withVICTORY_D3D12_DEBUG=1andVICTORY_D3D12_DRED=1across AMD Radeon Graphics (RDNA2 iGPU), NVIDIA RTX 5090, and D3D12 WARP.Closes #508.