GPU: keep heap indices and the null views inside a host heap the driver caps #1848
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!1848
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1848/head"
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?
@fiestorra on GitHub · 2026-11-24 23:23 UTC · original
fiestorra:gpu/clamp-bound-fits-the-capped-heap→main· +23 −3 · 2 files · 1 commits · closed without mergingThe null views did not exist on a capped heap, and that is now fixed and measured
Following the numbers in this issue: the emitted clamp bound and the null buffer views are
HEAP_VIEWS - 1andHEAP_VIEWS - 2withHEAP_VIEWS = 2^21 = 2,097,152, while the host heap is capped at 1,000,000 and its dynamic slots were set to fill it exactly. So on a capped heap the null views the clamp is supposed to fall back to were outside the heap, which is whatno room for the null buffer viewswas saying, and any computed index between the cap and the clamp read a descriptor that was not there.Two changes, both about fitting inside the heap the driver allows:
HEAP_VIEWSis now 1,000,000 — the smallest cap the host meets in practice — so the clamp and the null slots are inside any heap we can bind;Measured on the machine that caps (integrated
AMD Radeon(TM) Graphics, driver32.0.21045.29003, session 1, real window 3840×2160, empty cache), same scenario before and after:no room for the null buffer viewstitle slot past the host heapmain70564aeso the null views now exist and the shader's fallback has somewhere to land. Everything else in that log is unchanged, including the device removal — which is the chain in #1754 (the UAV description's id 599 and the sampler heap's id 1419), not this. This change is about the heap being consistent with itself, not about the removal.
Verification:
cargo test -p victory-shader209 passed,cargo test -p victory-gpu78 passed / 1 ignored,cargo clippy --workspace --all-targetswith and without--all-featuresclean,rustfmt --checkon both files at the same hunk counts asmain(2 and 33 before, 32 after because two were mine).What it does not do, and I would rather say than imply: it does not remap the 310,722 title slots above the cap. Those slots still have no host descriptor, so a shader that computes such an index still reads the null instead of its real descriptor — the design's stated behaviour for a slot that has none, and a real rendering loss on a title heap this large. Making them work needs the heap remapped (or the clamp given a runtime bound), which is a bigger change than this one.
Pull request: #1837
No game data is involved: counts and warnings only.
Written with an AI assistant.
@0xKaji on GitHub · 2026-11-24 23:26 UTC · original
Verified
a3caa6bon Linux + Wine11.22+vkd3d-proton 3.2.0(GE-Proton11-14) + NVIDIA RTX 3060 8 GB, cross-built withcargo xwin(x86_64-pc-windows-msvc,VKD3D_DISABLE_EXTENSIONS=VK_NV_raw_access_chains):Verification
cargo xtask policy:asset policy: 174 files okcargo test -p victory-shader --offline: 118 passed, 0 failed, 1 ignoredcargo xwin clippy -p victory-gpu -p victory-shader --tests --target x86_64-pc-windows-msvc --offline -- -D warnings: 0 warningsdescriptor::host::tests --test-threads=1): 4 passed, 0 failed (0.62s) —dynamic_slots_are_held_until_releasedflips from FAIL on70564aeto PASS ona3caa6b.Code review note
HostHeap::new(crates/victory-gpu/src/descriptor/host.rs:217), when capped atPORTABLE_VIEWS(1_000_000),count + extra = (1_000_000 - MIN_DYNAMIC - 2) + MIN_DYNAMIC = 999_998andnull = HEAP_VIEWS - 1 = 999_999. Sincenull > count + extraalready holds (999_999 > 999_998, matchingpairs_endat line 189), changing>to>=isn't needed — and ifnull == count + extrawere ever reached,h.raw_view_at(null - 1, ...)would overwrite the last dynamic slot (count + extra - 1). Keeping>(matchingpairs_end) is slightly safer.a3caa6bbringsHEAP_VIEWSandNULL_BUFFER_VIEWinside1_000_000withMIN_DYNAMIC, whereas #1751 keepsHEAP_VIEWSat2^21and preservesDYNAMIC).@upipibi on GitHub · 2026-11-24 23:26 UTC · original
On an NVIDIA host with the 1,000,000 cap: RTX 3070 8 GB, driver 616.56, Windows 11, debug,
a3caa6b(onmain70564ae).cargo test -p victory-gpu --locked: 78 passed, 0 failed, 1 ignored (main: 76 passed, 2 failed, #1744).cargo test -p victory-shader --locked: 207 passed, 2 failed, 2 ignored. Of #1744's three,a_heap_buffer_read_where_no_buffer_view_is_reads_zerosnow passes.a_heap_buffer_read_by_element_takes_the_views_strideandgathers_at_a_level_match_the_hardwarestill fail, with the same values as onmain.That is exactly what #1779 gives here, also on
70564ae. Both keep the indices and null views inside the capped heap: this PR in 23 lines across 2 files, #1779 more broadly acrossvictory-gpuandvictory-shader.AI-assisted (Claude Code). Synthetic tests only.
@fiestorra on GitHub · 2026-11-24 23:37 UTC · original
Withdrawing in favour of #1779, which does more, and here is the measurement that says so
I ran both on the machine that caps (integrated
AMD Radeon(TM) Graphics, driver32.0.21045.29003, session 1, real window 3840×2160, empty cache, release build,main70564aeas the base):no room for the null buffer viewstitle slot past the host heapmaina63eb93)So #1779 covers what this one does and the slots above the cap, which mine left in place (I said so in the body: remapping them was the bigger change I was not doing). Two pull requests for the same constant is exactly what should not be in the queue, so I am closing this one rather than asking a reviewer to compare them.
What I would keep from here, if you want it in #1779 or in a follow-up: the fault I had written down — a capped heap is created with its dynamic slots filling it to the last descriptor, so the null views at
HEAP_VIEWS - 2fall outside it even whenHEAP_VIEWSitself is small enough. That is the shape of theno roomwarning, and the two-slot reservation is the smallest change that fixes it. Your branch fixes it a better way; I am just noting the mechanism in case a regression test is worth having for it, since the warning is easy to reintroduce by charging the heap to the last descriptor.Also, since it may be useful as a second data point: on this machine #1779's build still removes the device (twice, in the same window), and that is expected — the removal here is the id 599 in #1754 (a
B5G5R5A1_UNORMdescription withALLOW_UNORDERED_ACCESSpassed toGetResourceAllocationInfo), which is a different fix (#1832). Yourtitle slot past the host heapgoing from 310,720 to 0 is the part I can independently confirm.No game data is involved: counts and warnings only.
Written with an AI assistant.
Pull request closed