GPU: clamp view-heap indices below what the host device takes (#3330) #3476
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!3476
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3476"
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?
@Koaio on GitHub · 2026-11-27 06:17 UTC · original
Koaio:fix/nvidia-view-heap-cap→main· +117 −45 · 7 files · 1 commits · openNVIDIA caps shader-visible view heaps at 10^6 slots, while translated shaders clamped their indices below HEAP_VIEWS (2^21): an index past the capped heap hung the device on entering the world.
The host device is probed at creation for a heap of HEAP_VIEWS; where it refuses one, shaders clamp below PORTABLE_HEAP_VIEWS (10^6) instead. The limit is part of the shader cache key. A capped heap keeps its last slots for the null buffer views and the clamped index, and a fallback heap is never smaller than the limit shaders index. Hosts that take 2^21 slots (AMD) are unchanged.
@oni-swr on GitHub · 2026-11-27 06:48 UTC · original
WARP test report (independent)
VICTORY_WARP=1,VICTORY_D3D12_WARP=1,victory-gpuwithdiagnostics), dxil.dll 10.0.26100 (Windows SDK). No physical GPU used.63bcca4(merge base on main). Head:8fe7719f.cargo test -p victory-shader -p victory-gpu:emit::synthetic_tests(lane-mask/permute/gather) fail on base and head under WARP, so they predate this PR. The changedthe_key_covers_translator_encoding_and_settingsand the heap tests pass.heap_views()= 2097152). So WARP covers only the uncapped path. The capped path (PORTABLE_HEAP_VIEWS, fallback heap branch) is not reached; doing so needsset_heap_views(1_000_000)before the first translation or a host that refuses the heap, so a test would need a code change.key(..., heap_views()), with a test);host()runs first, so the value is set before hashing.max(count + MIN_DYNAMIC, views), so it is never below the limit.views-2(SRV) andviews-3(UAV), the clamp lands onviews-1, and the capped branch limits title and dynamic slots to belowviews-3, so there is no collision.count + MIN_DYNAMICbetweenviews-3andviews, the null views are skipped (null > count+extrafails) while shaders still read them, so they could land on a live slot. This needs about 10^6 title slots and is unlikely.AI-assisted (Claude Sonnet 5.5).
@AurumCarlos on GitHub · 2026-11-27 08:34 UTC · original · reviewed
This is the same fix as #2461 (lhnizdo), which changes the same files and was marked a merge candidate after triage re-reviewed it on current
main. Worth linking it and saying what this adds, or closing in its favour; several other open PRs target the same cap too (#2185, #2628, #2683…).Two differences either way:
set_heap_viewsis only called fromvictory_gpu::host::create.victory-shader's owncreate_device(emit/host.rs) never sets it, so invictory-shadertestsheap_views()stays 2^21 andView::NullBuffersstill asks for a 2^21-slot heap on NVIDIA; the stride/synthetic failures from #1835 stay. #2461 probes in thatcreate_deviceas well.Errbranch. Withviewsat 10^6,make((count + MIN_DYNAMIC).max(views))succeeds whenevercount + MIN_DYNAMIC≤ 10^6. A title heap of 934,462–934,464 slots then puts its last dynamic slots on 999,997–999,999 (null UAV, null SRV, clamp target), and thenull > count + extracheck skips writing the null views. Checkingcount + MIN_DYNAMIC > roombefore thatmakewould cover it.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.