shader: lower typed buffer stores of fewer than four channels #56
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/56"
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 LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-26T11:35:16Z.
What 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)Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T11:51:45Z.
Review: CHANGES_REQUESTED
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-26T12:30:39Z.
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:48:06Z.
Review: DISMISSED
Thanks, the earlier requests are addressed and the checks pass (tests incl. Metal, Windows clippy, policy). Approved.
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T12:59:07Z.
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.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T13:26:34Z.
Review: APPROVED
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.