GPU: populate unbound table slots with typed null descriptors #2126
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2128"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T05:42:10Z.
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.
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T05:49:00Z.
Review: COMMENTED
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).
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T06:25:47Z.
One remaining case on
6498c28392is 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.
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T08:21:11Z.
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
c4edbb5is 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.Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T09:25:49Z.
Review: APPROVED
Verified locally merged onto
origin/main(940d32f, head4ec3f5f, 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 okClean typed null descriptors for unbound table slots.
Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-25T10:09:38Z.
Offline measurement on a retail dump
Result: no count change against
main.I merged head
4ec3f5f9ontomain940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 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).
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T10:47:59Z.
Automated triage for the maintainers.
Verdict: merge candidate. Re-reviewed at
08d02e7, which merges cleanly intomain. The change since the last review is a rebase plus one fix:host_shaderincrates/victory-gpu/src/pipeline/depth_bounds_test.rs(a test added tomainafter this PR was reviewed) now setstable_views: Vec::new(), so the test module compiles with the newHostShaderfield. OtherHostShaderinitializers in the tree already set the field. The substance is unchanged: typed nulls for unbound or access-mismatched table slots inState::tables, constant-offsetTableViewannotations fromLower::handle, and theshader_cacheencoding that invalidates old entries.On your reply: confirmed. For the maintainer, the earlier note still stands: about 2x CPU cost in
State::tableson fully bound tables (0.8 to 1.6 µs for 4 SRVs, 6.4 to 13.8 µs for 32).CI: passing (
check).Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by Xvania7 on 2026-11-25T13:11:39Z.
Review: APPROVED
Hardware verification on real hardware: NVIDIA GeForce RTX 5060, Windows 10 x64, Rust 1.98.1.
Tested
4ec3f5fchecked 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.
Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-25T13:08:17Z.
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.
940d32f4ec3f5fThese 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
4ec3f5fandf346d1dconflict 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 [email protected]
Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:52:21Z.
Rebased onto
main(63bcca43) in08d02e76and updatedcrates/victory-gpu/src/pipeline/depth_bounds_test.rswithtable_views: Vec::new()(fixing a silent test-compilation failure introduced after #158 landed). Verifiedpipeline::depth_bounds,clippy --features diagnostics --tests, andxtask policy.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.