GPU and shaders: keep clamp and null views within capped heaps (rebased #2177) #2682
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2682
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2682"
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?
@SinisterRob on GitHub · 2026-11-25 18:05 UTC · original
gpu/capped-view-layout→main· +199 −71 · 8 files · 2 commits · closed without mergingCurrent main fails the missing-buffer shader test on an RX 7900 GRE under Wine/RADV. The test asks for 2,097,152 shader-visible views and the device rejects that allocation. The device accepts 1,000,000. The translated shader's clamp and null-buffer indices also assume the larger heap.
This carries #2177 at
d15c68bonto current main and preserves its author and commit. I resolved the conflict indescriptor/host.rsby budgeting the title slots, dynamic slots and view pairs against the same probed limit used by translation. Both dynamic ranges leave room for view pairs and the three slots reserved at the end of the heap. The host keeps a separate shader cache for the probed limit.The allocation regression exercises 800,000 and 1,245,184 requested title views and checks the actual heap size, first view pair and null-view boundary. On the RX 7900 GRE:
On this branch, 22 descriptor, title-memory and shader-cache tests passed under Wine 11.22 with RADV and vkd3d-proton. The missing-buffer shader returned all 32 expected zeros on hardware. The capped layout still mirrors only the title slots that fit. No title run or game data. AI-assisted.
@Vedoxdev123 on GitHub · 2026-11-25 18:14 UTC · original
RTX 4060 test (AI-assisted)
Windows 64-bit, Ryzen 5 5600X, GeForce RTX 4060 (8 GB).
cargo test -p victory-gpu --lib: 196 passed, 0 failed, 1 ignored on this PR.mainhas 193 passed, 2 failed (descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views). Both pass with this PR.cargo test -p victory-shader: segfaults on bothmainand this PR, so there is no summary line. No change from this PR.@kotekompotek on GitHub · 2026-11-25 18:46 UTC · original
Well-constructed: the probe is cached (OnceLock), hostless paths (offline translate, no-GPU tests) fall back to HEAP_VIEWS so their output keeps today's key, and the shader-cache key covers heap_views only when it differs - so cached translates stay valid on 2M-capable hosts while 1M hosts retranslate with their own clamp. Ordering is safe too: host_shader() settles build() before translating, so the atomic is set before any translation that would bake the wrong constant.
Note the overlap with #2683: same root fix (clamp must not exceed the heap). This one is more general (probing, explicit CAPPED_PAIRS budget, bigger capped dynamic), that one is a small constant change; they rewrite the same HostHeap::new block so whichever lands second needs a rebase. One edge in the probe: [2M, 1<<20, 1M] returns 1M even if the host could only take, say, 500K - such hosts don't exist for shader-visible CBV_SRV_UAV on any shipping tier, so fine, but the fallback after all-probes-fail could equally return a smaller safe number.
@Mericas77 on GitHub · 2026-11-25 18:51 UTC · original
Tested on NVIDIA: RTX 4070 (the only adapter), driver 621.01, Windows 11, rustc 1.98.1. Head
b53e4c6.main13f91caon the same machine:victory-gpu193 passed / 2 failed (dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_views, the 1,000,000-view cap);victory-shader --lib(with--skip heap_direct_texture_reads_mark_their_heap_index, #2571) 266 / 3 failed (a_heap_buffer_read_by_element_takes_the_views_stride,a_heap_buffer_read_where_no_buffer_view_is_reads_zeroswithdispatch failed: E_INVALIDARG,gathers_at_a_level_match_the_hardware).With this PR:
victory-gpu: 196 passed, 0 failed. Both heap-cap failures are gone, andlarger_heaps_leave_room_for_pairs_and_null_viewspasses.victory-shader: 267 passed, 2 failed.a_heap_buffer_read_where_no_buffer_view_is_reads_zerosnow passes on NVIDIA hardware (no moreE_INVALIDARGat dispatch).mainand outside this PR:a_heap_buffer_read_by_element_takes_the_views_stride(hardware reads[101, 104, 107, …, 131, then 0s]instead of[200..231], the structured-view stride, #2178) andgathers_at_a_level_match_the_hardware.So on NVIDIA this fixes 3 of the 5 known hardware failures, which complements the AMD/Wine numbers in the description. #2683 goes after the same problem with a fixed
HEAP_VIEWS = 1,000,000. I ran it on the same machine and it fixes the same three tests, so this branch's runtime probe gives the same result on NVIDIA while keeping the 2^21 heap on hosts that accept it. No game data; the title was not run.AI-assisted.
@Vedoxdev123 on GitHub · 2026-11-25 18:57 UTC · original
RTX 4060 test (AI-assisted)
Windows 64-bit, Ryzen 5 5600X, GeForce RTX 4060 (8 GB), on
main13f91ca+ this PR (b53e4c6).emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros: fails onmain(hardware: dispatch failed: The parameter is incorrect.), passes with this PR.cargo test -p victory-gpu --lib: 196 passed, 0 failed, 1 ignored (main: 193 passed, 2 failed).cargo test -p victory-shader --libwith--skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index(it crashes the process onmain, #2571): 267 passed, 2 failed, 3 ignored (main: 266 passed, 3 failed). The 2 left area_heap_buffer_read_by_element_takes_the_views_strideandgathers_at_a_level_match_the_hardware.@fuzeofficlal on GitHub · 2026-11-25 19:19 UTC · original
Independent Windows 11 + NVIDIA GeForce RTX 5090 + WARP +
dxil.dllverification and code review ofb53e4c6(on13f91ca):Verification (
rustc 1.98.1MSVC, Windows SDK10.0.26100.0dxil.dll)cargo clippy --locked -p victory-gpu -p victory-shader --all-targets -- -D warnings(and--features diagnostics): 0 warnings;cargo xtask policy: 184 files ok.cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1-> 199 passed, 0 failed, 1 ignored. Fixes both pre-existing #1744 baseline failures (dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views);larger_heaps_leave_room_for_pairs_and_null_viewsconfirmedslots 1000000, title slots 844349, dynamic 131072, first pair 975421, null SRV 999998.VICTORY_D3D12_WARP=1): 199 passed, 0 failed, 1 ignored (slots 2097152, title slots 1245184, dynamic 262144, first pair 1507328, null SRV 2097150).victory-shader:emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zerospasses on both RTX 5090 and WARP withdxil.dllactive.Code Review Notes
909_885slots (e.g.1_245_184) on a 1M-capped host,kept = 844_349, live dynamic table slots occupy[844_349..975_421), and live title-memorypairsoccupy[975_421..999_997). Because translated shaders clamp heap indices toviews - 1 = 999_999, any bindless title index in[844_349..999_997)will not clamp to a null descriptor — it will read live dynamic descriptors or title-memory pairs (whose non-zero stride also bypassesbuffer_guard). In addition,HostHeap::view_addressesstill allocatesself.count * 16bytes rather than covering up toviews.HOST_HEAP_VIEWSis a process-global atomic (rather than#[cfg(test)] thread_local, sostride_testssets it once fromHost::new(false)across the hardware+WARP loop); and dynamic-slot allocation is non-monotonic around the cap (count = 900_000gets65_536dynamic slots whilecount = 910_000truncates to844_349and gets131_072).git merge-treeconflicts indescriptor/host.rsandemit/shader.rs). #2682 preserves full 2M support on Tier-3/WARP (unlike #2683), while #2650's sparseVIEW_BLOCKStable also isolates dynamic/pair slots and reaches sparse title views past844K(once itssync_slotsbug is fixed).@pablogonz12 on GitHub · 2026-11-25 19:41 UTC · original
AMD/RADV offline check of the head commit (no game run).
origin/main13f91caee.victory-shader --example retranslate, then dxil-spirv (master),spirv-val --target-env vulkan1.3, and a realvkCreateCompute/GraphicsPipelineson RADV (vkpipe, one process per program, so a driver crash or hang is recorded per program rather than stopping the batch).Result, base
13f91caeevs headb53e4c6ce: both translate 749 / 751 (the same 2 refused in both:a lane mask read as data is not supported). 0 of the 751 programs' DXIL bytes change, no pipeline result or time differs.The capped-heap and null-view paths are descriptor-side, and the dump set does not hit them (all 751 keep their DXIL), so offline translation cannot tell main and this branch apart. The unit tests are the evidence;
victory-shader's test target does not build on Linux here (Windows validator module), andvictory-gpuneeds Direct3D, so I could not run them. No objection from this side.Not tested in a game run; not tested on NVIDIA.
@Marvisak on GitHub · 2026-11-25 22:15 UTC · original
Automated triage for the maintainers.
Needs rebase. This branch no longer merges cleanly into
main: the conflict is incrates/victory-gpu/src/descriptor/host.rs. No content review was done yet; it will be reviewed once it is rebased onto currentmain.Generated by Claude Code
Pull request closed