shader: lower typed buffer stores of fewer than four channels #56
No reviewers
Labels
No labels
accessibility
bug
claimed
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
tester report
urgent
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LakshanSivakumar--Native-Victory-macOS!56
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/56/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?
@Sandile-0511 on GitHub · 2026-11-26 11:35 UTC · original
Sandile-0511:fix/typed-store-channels→main· +230 −6 · 5 files · 4 commits · merged 2026-11-26 13:26 UTCWhat this changes
A compute shader was refused at world load with
a typed buffer store of some channels or at an offset is not supported. The refusal covered MUBUFbuffer_store_format_{x,xy,xyz}and the_d16_forms.On GFX11 and older the hardware writes 0 to the channels a buffer store does not name (LLVM commit 88421ea "Trim zero components from buffer and image stores"; Mesa "aco: shrink buffer stores with undef/zero components"). So no read-modify-write is needed: the missing
bufferStorearguments are padded with 0.0.Stores at an offset stay refused, now as
a typed buffer store at an offset: a typed view cannot address bytes inside an element.One behaviour change to review: a typed store whose computed offset is not constant is now refused too, as on the load side. Before, such an offset was silently dropped for xyzw stores, so a shader that used to translate (wrongly) may now be refused. Drop the
matches!(off, V::Inst(_))clause if you would rather keep the old behaviour.How it was tested
cargo test -p victory-shader: 221 passed, 0 failed, 2 ignored. New teststyped_buffer_stores_of_some_channels_lowerandtyped_buffer_stores_at_an_offset_remain_refused.typed_buffer_stores_of_some_channels_zero_the_othersinstride_testsis Windows-only; type-checked only.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings(clean, run on a Mac)cargo xtask policy(365 files ok)Checklist
VICTORY_*variable and documented (none added)@LakshanSivakumar on GitHub · 2026-11-26 11:51 UTC · original · requested changes
I reproduced a regression with
buffer_store_format_xyzwusings2as its scalar offset afters_mov_b32 s2, 0. Main lowers it, but the new guard refuses it. Please preserve stores with a provably zero offset, keep the refusal for unsupported offsets, and add a regression for the zero-SGPR case. Please also record the zero-fill and offset behavior indocs/native-host.md.@Sandile-0511 on GitHub · 2026-11-26 12:30 UTC · original
Reproduced the regression and fixed it: a typed store whose scalar offset register is proved to hold 0 by constant moves (
s_mov_b32 s2, 0,s_movk_i32, chains of them) lowers again.typed_buffer_stores_at_a_zero_sgpr_offset_lowerfailed before the change. A non-zero offset (s_mov_b32 s2, 4) and an unknown one (s_mov_b32 s2, s0) stay refused, with a test.One difference from
mainremains, on purpose: an offset that may be 0 at run time but is not proved so is still refused, wheremaindropped it. A zero reached through a phi, arithmetic or a load is not proved. Say if you want that loosened. The zero-fill and offset behaviour are recorded indocs/native-host.md, andmainis merged in.@LakshanSivakumar on GitHub · 2026-11-26 12:48 UTC · original · review (dismissed)
Thanks, the earlier requests are addressed and the checks pass (tests incl. Metal, Windows clippy, policy). Approved.
@LakshanSivakumar on GitHub · 2026-11-26 12:59 UTC · original
Approved, but #55 just landed and both add tests at the same spot in
gfx_refusal_tests.rs(and this changes itsuseline), so this now conflicts. Please rebase on main and keep both blocks; I'll merge once CI is green.@LakshanSivakumar on GitHub · 2026-11-26 13:26 UTC · original · approved these changes
Rebase cleanly preserves both the #55
v_cvt_pknorm_*tests and the typed-store tests,s_mov_b32 s2, 0zero-offset handling and docs look good, and CI is green. Merging.