Repository navigation
Shaders: scalar loads through a heap buffer that vector accesses use read a buffer view - #1015
justrealyme wants to merge 2 commits into
Conversation
…e a buffer view A descriptor fetched from the resource heap by index has no used-resource entry, so a scalar buffer load (s_buffer_load_dword*) through it was lowered through a 64 KiB constant buffer handle. When vector buffer loads read the same descriptor, the slot holds a buffer SRV (the title made it one), and reading it through a CBV handle is a descriptor of the wrong type, which D3D12 leaves undefined. Such loads now read the slot as a raw buffer, as table SRVs already do. A descriptor also written through (a UAV) and one only scalar loads read are unchanged. In the title's shaders.rpf this changes 38,829 scalar loads in about 1,900 of 26,084 programs; emit and validation counts are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e a buffer view Upstream: Marvisak#1015 by @justrealyme
catminou4
left a comment
There was a problem hiding this comment.
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.
The first commit left a heap descriptor of no listed kind that a vector buffer store or atomic also uses on the constant buffer path, which is a CBV handle on the UAV the title made. Scalar loads through it now read a raw UAV (11 | 0x1000), as Marvisak#1055 does for a table's UAV; read-only use stays a raw SRV. The test's store case now expects no CBV handle. In the title's shaders.rpf no program has this case (all 38,829 changed loads are the read-only one); emit and validation counts are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
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 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. AI-assisted (Claude Code). |
|
Heads-up: this PR and #1055 both change the raw-view choice for a scalar buffer load of a descriptor in |
|
Verified on our runtime containers: gain 0 on the address/format class. Stack: main 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. |
… vector accesses use read a buffer view
… vector accesses use read a buffer view
|
Automated triage for the maintainers. Closing because this change is already in 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. |
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 Shaders: scalar buffer loads from a UAV read it raw #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+ GPU: refuse wave64 mesh and compute programs on hosts without 64-lane waves #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