Repository navigation
Shaders, GPU: clamp descriptor heap indices to bound host heap guard slot - #955
MartinIndra02 wants to merge 1 commit into
Conversation
|
Five existing waterfall readbacks with valid bindings passed on both One integration detail from source review: on a capped view heap, the mirrored title descriptors and the host's fresh table allocations have different extents. #483 checks direct title indices against the mirrored descriptor count, while allowing translated table indices to use the dynamic region up to the physical guard. Keeping those bounds distinct preserves both kinds of binding. The readbacks above exercise valid views. The effect on title rendering was not measured in this comparison. |
|
Tested at head
The >1M case on AMD. The new heap test uses 64 title slots, so it never reaches the size this PR is about. With a local, unpublished test making a view heap of 1,100,000 title slots, the AMD driver accepted the full Not done: an unclamped control on the AMD device (an out-of-bounds index past a 3-slot heap could hang the driver), and no in-title run. A question on samplers: when |
|
@shortselow-byte Thanks a lot for testing on AMD RDNA2 (RX 6900 XT) and especially for verifying the >1M title-slot allocation ( Yes,
|
|
Correction to my comment above: "also with |
|
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at 05c681c: Tested with AI assistance (Claude). |
|
Numbers from a Linux/RADV run that fit this diagnosis (Mesa 26.3.1, RX 7600 XT, Wine 11.22 on a Proton prefix, vkd3d-proton from Proton):
With this PR on top of #994 the artifacts on the loading screen are unchanged: reads are clamped to the guard slot now, but the descriptors in those slots were never mirrored, so a shader that reaches them reads a null view instead of the title's. Happy to test a follow-up that pages the tail of the heap in. |
|
Automated triage for the maintainers. Closing because another open pull request covers the same change. See #1133. Replacement for #584. Main has the static clamp to HEAP_VIEWS-1; the remaining capped-host case is done more simply by #1133 (the cap as a translation constant, in the cache key) than by a new root-constant space. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution. |
Follow-up / replacement for #584 (fixing the AMD >1M heap black screen diagnosed in #584 and confirmed on RDNA3 by
@d1ll3x3).Summary
Clamps
ResourceDescriptorHeapandSamplerDescriptorHeapindices at runtime to the bound host heap's dedicated permanently-null guard slot instead of hardcoding1_000_000 -> 0:b0inHEAP_LIMITS_SPACE = 4):ResourceDescriptorHeaporSamplerDescriptorHeapload[view_guard, sampler_guard]once in the entry block from a 2-dword root constant (HEAP_LIMITS_SPACE = 4, leaving spaces2/3free for#710/#704).HostShader::heap_limits == false, zero root-signature overhead).HostPipelineadds oneD3D12_SHADER_VISIBILITY_ALL2-dword root constant parameter when any stage setsheap_limits,State::bindsupplies[view_heap.guard(), sampler_heap.guard()], andshader_cache.rsencodes/decodesheap_limits.HostHeapreserves the final slottotal - 1on view heaps (dynamic = DYNAMIC - 1orMIN_DYNAMIC - 1, staying withinPORTABLE_VIEWSwhen capped and coveringcount + dynamicon >1M Tier 3 AMD heaps) and appends 1 guard slot on sampler heaps below D3D12's 2048-slot cap (make(count + 1)withcount.saturating_sub(1)fallback at 2048).fill_nullinitializes alltotalslots (including the guard slot), and neithermirrornordynamiccan ever overwrite it.select(index <u guard, index, guard)leaves every valid title & dynamic slot (0..guard) untouched and maps every OOB/wrapped index to the dedicated null guard slot (never aliasing live slot0).Verification (Windows 11, RTX 3080
621.24, WARP, Rust1.98.1)emit::waterfall_tests::out_of_bounds_heap_index_clamps_to_null_guard_not_slot_zero(RTX 3080 + WARP): verifies valid slot0(1.0) and OOB slot16384(0.0from null guard slot, no page fault, no aliasing to slot0).descriptor::host::tests::host_heap_guard_covers_title_and_dynamic_slots(RTX 3080 +VICTORY_D3D12_DEBUG=1).cargo test -p victory-shader --lib -- --test-threads=1: 121 passed, 0 failed, 1 ignoredcargo test -p victory-gpu --lib -- --test-threads=1: 51 passed, 0 failed, 1 ignoredcargo clippy -p victory-shader -p victory-gpu --all-targets -- -D warnings(default +--features diagnostics): 0 warningscargo xtask policy: 154 files okNo game data used. AI-assisted; all builds and GPU tests executed on my machine.