Shaders: query a buffer's size through a handle of its own #2122
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!2122
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2122"
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?
@imjustprism on GitHub · 2026-11-25 05:31 UTC · original
imjustprism:shader/rdna4-compiler-crash→main· +275 −2 · 3 files · 1 commits · openamd's driver 32.0.32029.2010 on an rx 9070 xt faults in its shader compiler
when one buffer handle feeds both a size query whose result is used and a
load. a buffer's size query now always takes a handle of its own, from caches
of its own, so no load shares it. a query nothing reads is dropped by the
writer together with its handle.
rewritten on
13f91ca: with 850b66f's entry-block handle cache the old branchno longer compiled against main, and the size query was back on the loads'
handle. the uses analysis is gone, the writer's liveness does that job now.
rebased again onto
63bcca4(bf526d7). the lowering change is the one from6ff2361, line for line. the five unit tests moved toemit/lower/tests/size_handles.rs, unchanged: with them in lower.rs the file
was 528,047 bytes on the new main, over the 524,288 of cargo xtask policy.
it is 522,494 now.
the new gpu test runs on hardware and warp. with the size query forced back
onto the loads' handle it kills the test process on the 9070 xt at pipeline
creation. translate --cache --pipelines and the title were not run on this
head.
the extra handle is emitted on every host, so this is how far it reaches:
translate --list with VICTORY_EMIT_DUMP, release builds of
13f91caand6ff2361, one run each, dumps compared file by file. 25,752 programs make25,734 files because some share a dump file name. the other 25,068 files are
byte for byte the same, and refusals are the same on both, reason by reason.
the shader cache is keyed by the translator's source, so every program is
translated again once, as after any translator change.
fixes #1783
fixes #1785
refs #2124
refs #2517
6ff236148btobf526d765f@upipibi on GitHub · 2026-11-25 05:36 UTC · original · edited 2026-11-25 21:33 UTC
Ran on Windows 11 with an RTX 3070 (Ampere, driver 616.56), debug build, at
e14ee3d.victory-shader: 250 passed, 3 failed, 3 ignored. The 6 newstride_testspass (a_buffers_size_query_does_not_share_its_handle_with_the_loads,a_buffers_unread_size_shares_the_handle_of_the_loads,a_buffers_size_read_as_its_loads_offset_has_a_handle_of_its_own,an_images_size_read_as_data_shares_the_handle_of_its_sample,a_buffers_base_in_a_scalar_load_is_not_a_read_of_its_size,a_raw_buffer_is_sized_and_read_through_one_descriptor_load). The 3 failures are #1744's NVIDIA failures onmain. Two of them are in the same file,a_heap_buffer_read_by_element_takes_the_views_strideanda_heap_buffer_read_where_no_buffer_view_is_reads_zeros, and they still fail here, so this PR doesn't change them. Same asmainon this hardware.Added 21:33Z: re-run at the current head
6ff2361(base13f91ca), same RTX 3070, driver 616.56, debug,cargo test --locked -p victory-shaderwithheap_direct_texture_reads_mark_their_heap_indexskipped (it crashes the test process on this card onmain, #2571): 272 passed, 3 failed, no SKIPPED lines. The PR's six new tests all pass:a_buffers_size_query_does_not_share_its_handle_with_the_loads,a_buffer_at_a_computed_table_offset_is_sized_through_its_own_handle,a_buffer_sized_at_each_of_its_reloads_has_one_size_handle,a_buffers_unread_size_query_writes_no_handle,an_images_size_read_as_data_shares_the_handle_of_its_sample(lower::tests) andstride_tests::a_raw_buffers_size_beside_its_loads_reads_its_byte_count. The 3 failures are the #1744 NVIDIA ones that fail onmainon this card too (stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride,stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros,synthetic_tests::gathers_at_a_level_match_the_hardware).AI-assisted (Claude Code, Claude Opus 5.5).
@fiestorra on GitHub · 2026-11-25 06:16 UTC · original
Verified the "census is unchanged" claim here, and two things I would add before it lands
Measured on this machine (RTX 4090,
32.0.16.2124, release build, local 1.0.2.1 archive, 26,503 containers, validator SDK 10.0.26100dxil.dll1.9):So the claim holds, and it is the right claim for this change — the fix is about what the driver's compiler is handed, not about whether modules validate.
First, the workaround should carry the reason in the code. The description names it precisely — AMD's
32.0.32029.2010on an RX 9070 XT faults when one buffer heap handle feeds both a size query whose result is used and a load — but a reader oflower.rsin six months will see an extra handle and no way to know it is not redundant. A comment naming the driver version, the card and the crash is what stops it being removed by someone tidying up, and this repository has already lost time this week to a missing line of explanation.Second, the number I would want in the description: how many programs' emitted DXIL changes. The extra handle is emitted wherever the pattern occurs, on every host, not only on the one with the faulty compiler — so:
createHandleFromHeapper program" is worth a sentence on cost, because this is the path that runs for every buffer size query in the title.Your
heap_handlescounter under#[cfg(test)]suggests you already have that number — it just is not in the description, and "census unchanged" does not cover it, because a module can validate identically while its code differs.Two smaller things I checked and like:
soffsetcase handled — that is the part that would have been easy to get subtly wrong, and the helper is written so it can be tested on its own;heap_handlesis test-only, so nothing in a release build pays for the instrumentation.What I could not check: the crash itself, since this machine has neither the card nor that driver. The evidence for the fix's purpose is yours, and I am reviewing the shape of it rather than re-running your failure.
No game data is involved: counts, a driver version and code.
Written with an AI assistant.
@imjustprism on GitHub · 2026-11-25 07:30 UTC · original
thanks for running the census on the 4090. the reason is already in the code: the rustdoc on the size query in lower.rs names the driver, the card and the fault, and what does and does not trip it. the count was missing, it is in the description now: 333 of 25,678 emitted programs change, about 100 bytes each. the cache is keyed by the translator's source, so it retranslates once like after any translator change.
@sinan-cmyk on GitHub · 2026-11-25 08:31 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head e14ee3d8 onto
main940d32f(clean merge) and ranvictory translate --validate --listonshaders.rpf(1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result withmainprogram by program (25,889 programs). Validated: 23,918 onmain, 23,918 with this PR.No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.
No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 10:46 UTC · original · edited 2026-11-26 07:21 UTC
Automated triage for the maintainers.
Merge candidate. Thanks for answering the request. Head
bf526d7is rebased onto63bcca4with the same lowering as6ff2361.Lower::descriptor_data(crates/victory-shader/src/emit/lower.rs) makes a buffer's size handle throughswap_size_caches, so no load shares it, and image handles stay shared. The five unit tests moved unchanged intoemit/lower/tests/size_handles.rs, which themod size_handles;insidelower.rs's test module points to. That keepslower.rsat 522,494 bytes, under the 524,288-byte policy limit.The RX 9070 XT check I asked for is covered twice. MeMako's independent run at
6ff2361created 25,665 of 25,665 pipelines with noamdxc64.dllfault, and your run on this head passed. Linking #2124 and #2517 as refs rather than fixes is the right call. A structured-buffer case in the GPU test would still be a useful follow-up, but it shouldn't block this.CI: passing.
Generated by Claude Code
amdxc64.dllwhile a translated compute pipeline is created #2517@MeMako on GitHub · 2026-11-26 00:21 UTC · original
Independent RX 9070 XT verification at current head
6ff2361(AMD Radeon RX 9070 XT adapter 0, driver32.0.32029.2010, Windows 1110.0.26200x64, SDK10.0.26100.0dxil.dll).Tests & CI checks on
6ff2361:cargo clippy --workspace --all-targets --locked -- -D warnings: passcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passcargo test --workspace --locked: pass (victory-shader: 276 passed, 0 failed, 3 ignored — all 6 new tests pass on RX 9070 XT, WARP, anddxil.dll)Offline pipeline stress test on
6ff2361(release build,translate --validate --pipelines --jobs 8on the 1.0.2.1 shader pack, 26,503 containers, 1,134 s):amdxc64.dll+0x861b9fcrashes.Not run on
6ff2361:translate --cache --pipelineslibrary pre-build or a live title run.Notes before landing on current
main(63bcca4):lower.rs: A dry-run merge of6ff2361withmain(63bcca4) auto-merges cleanly, but growscrates/victory-shader/src/emit/lower.rsfrom520,563B to528,047B, exceedingxtask/src/policy.rs's524,288B limit (repository_passes_policywill fail once rebased/merged). Moving the 5 new unit tests out oflower.rsinto a test submodule (leaving the 6th test instride_tests.rs) would keep it under 512 KiB.stride_tests.rscurrently tests a raw buffer (Stride::Raw); adding a structured-buffer size+load case (e.g., stride 60) would also cover structured buffers, which hit the sameamdxc64.dll+0x861b9ffault on this driver.amdxc64.dll+0x861b9fcrash on RX 9070 XT (32.0.32029.2010) and look like candidates to link alongside #1783 and #1785.No game data, shader names, or screenshots are included, per
docs/asset-policy.md. Hardware runs and dry-run merge were performed by me on my RX 9070 XT; comment drafted with Antigravity.@imjustprism on GitHub · 2026-11-26 07:09 UTC · original
rebased onto
63bcca4, the head isbf526d7now. the five unit tests movedunchanged to emit/lower/tests/size_handles.rs, so lower.rs is 522,494 bytes
and cargo xtask policy passes. the lowering change is the one from
6ff2361,line for line. both clippy runs, cargo test --workspace and the policy check
are green on the new head on an rx 9070 xt.
@MeMako thanks for the pipeline run and for catching the size limit. #2124
and #2517 show the same fault address on the same driver, so the description
names them now, as refs and not fixes: i have not checked that they are this
cause. the gpu test still covers a raw buffer only, no structured one.
query a buffer's size through a handle of its ownto Shaders: query a buffer's size through a handle of its own@catminou4 on GitHub · 2026-11-25 06:40 UTC · original · approved these changes
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main
940d32f69b,cargo test -p victory-shader --locked.149 passed / 0 failed / 2 ignored. Buffer size queried through its own handle (+5 tests) — descriptor-handle-based sizing; biggest test addition of this wave.
@DenRakEiw on GitHub · 2026-11-25 06:46 UTC · original · approved these changes
Verified locally merged onto
origin/main(940d32f, Windows 11 x64, Rust 1.98.1 MSVC):cargo test -p victory-shader --lib a_buffers_— 4 passed, 0 failed (a_buffers_size_query_does_not_share_its_handle_with_the_loads,a_buffers_unread_size_shares_the_handle_of_the_loads, etc.)cargo clippy -p victory-shader --all-targets— 0 warningscargo xtask policy— ok (183 files ok)Clean separation of buffer size-query handles when the buffer size is read as data. Looks good.
AI-assisted (Gemini 4 Neon).
@fuzeofficlal on GitHub · 2026-11-26 12:40 UTC · original · approved these changes
Reviewed and verified
bf526d76:swap_size_caches(crates/victory-shader/src/emit/lower.rs:4256-4262, 4404-4426) cleanly separatessize_handlesandsize_entry_handlesfor buffer size queries and restores both caches before propagating errors, while keeping image queries on the access handle. Becausedescriptor_dataconstructsSource::Loaded, queries stay within those two caches rather thanjoin_handles.emit/lower.rsis 522,494 bytes (1,794 bytes under the 524,288-byte limit).Local verification:
xtask policy(192 files ok),cargo clippy -p victory-shader --all-targets -- -D warnings(default &--all-features),emit::lower::tests(38 passed, including all 5size_handlestests), andemit::stride_tests(9 passedonVICTORY_WARP=1;7 passed, 2 failedon RTX 5090 witha_raw_buffers_size_beside_its_loads_reads_its_byte_countpassing and the two pre-existing NVIDIA 1M view-heap-cap failures). Adding a structured-buffer GPU readback later would cover element-count queries too. Approve.github-bot referenced this pull request2026-11-26 12:50:22 +00:00
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.