Shaders: scalar loads through a heap buffer that vector accesses use read a buffer view #1015
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1015"
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 justrealyme on 2026-11-24T15:04:18Z.
What
A descriptor fetched from the resource heap by an index the program computes (
s_load_dwordx4 s[n:n+3], <ResourceHeap root>, <index * 32>) has no used-resource entry, soused_kindreturnsNone. A scalar buffer load (s_buffer_load_dword*) through such a descriptor was therefore lowered through a 64 KiB constant buffer handle (annotateHandle {13, 65536}+cbufferLoadLegacy).On the console a scalar load works through any buffer descriptor, and titles read the same bindless buffer both ways: scalar loads for its header, vector loads (
buffer_load_*) for its contents. In the title's heap that slot holds the buffer SRV the title made. Reading it through a CBV handle is a descriptor of the wrong type, which D3D12 leaves undefined (the host takes the SRV's bits as a CBV's address and size).smemnow reads such a descriptor (no listed kind) as a raw buffer, as it already does for table SRVs, when vector buffer accesses use the same descriptor source:buffer_load_*,tbuffer_load_*): a raw SRV ({11, 0}+rawBufferLoad);{11 | 0x1000, 0}), as #1055 does for a table's UAV.A descriptor that only scalar loads read is lowered as before. Nothing says it isn't a CBV.
Example
compute eeed82b877b44b5f(the program behind the NVIDIA world hang in #578 / #71) reads two mesh buffers it fetches from the heap by index, with 33 + 8 vector loads and 21 scalar loads. All 21 went through CBV handles. With this change, none do.This does not fix that hang: it still hangs on an RTX 5070 Ti with this change (details in #578). This is a correctness fix of its own.
Scope
victory translate --validateon the title'sshaders.rpf(26,084 programs), with and without the change:Related: #1055 fixes the neighbouring case, a descriptor whose listed kind is a UAV. Both touch the same lines of
smem, so whichever lands second needs a small rebase.Verification
scalar_loads_through_a_heap_buffer_that_vector_accesses_use_read_a_buffer_view: a heap descriptor at an index from a root constant, read bys_buffer_load_dwordalone, with abuffer_load_dword, or with abuffer_store_dword. It asserts 1 / 0 / 0 CBV heap handles. It fails onmain(the load case gives 1) and passes with the change. Synthetic code, assembled withllvm-mc -mcpu=gfx1013.Shader/Loweredget a test-onlycbuffer_handlescounter next tononuniform_handles.cargo clippy --workspace --all-targets --locked -- -D warningsand the same with--all-featuresare clean.cargo test --workspace --lockedpasses (343 passed, 0 failed).cargo xtask policypasses (154 files ok). rustfmt adds no new differences to the two files.VICTORY_D3D12_DRED=1. On top ofmain+ #578 + @JFIREonFIRE'sfix/refuse-unsized-wave64-compute(to get past the hang above), the first commit ran 14.2 min in the world with no device removal, 0 refused pipelines and no errors. Without the change: 18.7 min, also with no removal. Draws per frame were 376 with the change and 350 without.AI-assisted (Claude Code). No game data in the change or the test.
🤖 Generated with Claude Code
Imported from Marvisak/VIctory. Originally posted by Zipettte on 2026-11-24T15:40:23Z.
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
cb7115a:cargo test -p victory-shaderpasses, 121 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T16:29:00Z.
Review: APPROVED
Scalar loads through a heap descriptor of unknown kind are typed as SRV when only vector buffer loads read it (buffer_loads_only scans descriptor uses; any store disqualifies -> unchanged CBV path). Conservative and well-tested with the three-way Nothing/Load/Store case. Same lower.rs hunk as #1055 — merge order will need a rebase for the second one. Local verification: macOS arm64, rustc 1.98.1, PR head merged into main
ffe310e,cargo test -p <crate> --locked. Shader execution tests (valu_tests/host) are#[cfg(all(test, windows))], so macOS covers lowering/decode/unit tests only. victory-shader: 97 passed, 0 failed.[PR #1015] Shaders: scalar loads through a heap buffer that vector loads read use a buffer viewto [PR #1015] Shaders: scalar loads through a heap buffer that vector accesses use read a buffer viewImported from Marvisak/VIctory. Originally posted by justrealyme on 2026-11-24T17:10:40Z.
Thanks for checking it. You're right about the overlap with #1055: it fixes the neighbouring case (a listed UAV) on the same lines of
smem, so whichever lands second needs a small rebase. I've linked it in the description.Your summary also points at the gap I'd left: a heap descriptor that a store also uses stayed on the CBV path, which is a CBV handle on a UAV slot, the case #1055 shows removing the device on WARP.
b8cfe8creads that case as a raw UAV (11 | 0x1000, the same props #1055 uses), and the test's store case now expects 0 CBV handles. A descriptor that only scalar loads read is unchanged. In this title'sshaders.rpfno program has the store case (all 38,829 changed loads are read-only), and emit/validation and failure counts are still identical tomain. Re-checked: clippy (both configurations),cargo test --workspace --locked343 passed, policy ok, and the test fails onmain.AI-assisted (Claude Code).
Imported from Marvisak/VIctory. Originally posted by MamaLeVrai on 2026-11-24T17:23:49Z.
Heads-up: this PR and #1055 both change the raw-view choice for a scalar buffer load of a descriptor in
emit/lower.rsand conflict with each other. The resolution (SRV range reads a raw SRV view, UAV range a raw UAV view, descriptor of no listed kind the heap buffer view) is in the bundle #1319, with both PRs' tests kept; clippy and tests pass on it. AI-assisted (Claude Code); no game data.Imported from Marvisak/VIctory. Originally posted by justlovett0 on 2026-11-24T18:48:35Z.
Verified on our runtime containers: gain 0 on the address/format class. Stack: main
ffe310e+ #175/#994/#747/#302/#193/#704/#309/#953/#1067/#986/#1260/#1267/#1254/#1276/#189 (wave64 emulation), RTX 3080 10 GB / Win10 21H2 (19044.7846) / driver 621.24 (32.0.16.2124). Re-census of captured runtime containers; world stable ~9 min, 0 device removals.Tested by re-census of our captured runtime refusals: this PR (and #1055; #995 conflicts) does not clear our largest class, "a descriptor's address or format read as data" (50 shaders). Those shaders read descriptor address/format dwords as data (which have no host value); the scalar-load fixes here target buffer-data loads through heap descriptors, a different pattern. Useful negative result so the offline count isn't read as covering this class.
AI use: Qwen Code; local measurements. No game data posted.
Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:30:12Z.
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Scalar loads through a descriptor taken from the resource heap read a raw buffer view in main (emit/lower.rs smem(): heap_constants; module notes 'Constant buffers in the heap').
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.
Pull request closed