Shaders: five translation fixes from cool_fox and VIctory-NVIDIA-RT (image queries, scalar destinations, CalculateLOD on arrays, partial stores, LDS negated adds) #3064
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!3064
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3064"
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?
@Adriwin06 on GitHub · 2026-11-29 19:52 UTC · original
Adriwin06:shader-fixes→main· +587 −19 · 8 files · 7 commits · closed without mergingWhat it changes
5 small changes of the same kind, one commit each, so each can be reviewed, reverted or left out on its own:
Shaders: an image query's unused extents read zero on non-cube views
The size query lowered every extent a view lacks (
!present[ch]) toone, the cube depth fallback. The console returns zero for a non-cube
view's unused extents, and a shader that multiplies or tests them saw
one instead. Only cube views (kind 5) still read one there.
Ported from DoubleGhosty/cool_fox@0e525f1 (Dathinel), GPL-3.0-or-later.
Shaders: a VALU scalar destination past the machine's registers is refused at decode
A VOP3 compare's mask, and v_readlane_b32's and v_readfirstlane_b32's
value, are an 8-bit scalar destination. No register has a code from 128
on (the SGPRs, VCC, the trap temporaries, M0, null and EXEC end at 127),
so a compiler never writes one, and the IR would take such a code for a
parked scalar's. Decoding now refuses the instruction with an ISA error
instead of translating it into a wrong program.
Test: gfx10::a_scalar_destination_past_the_registers_is_refused.
Ported from DoubleGhosty/cool_fox@200319b, GPL-3.0-or-later.
Shaders: CalculateLOD on a 1D or 2D array takes spatial coordinates only
The LOD query was given every coordinate of the sample, the array slice
included. CalculateLOD takes the spatial coordinates only; array
samples still need the slice, but the query now leaves that operand
undefined.
Tests: cube_lod_tests (array CalculateLOD).
Ported from Kemerd/VIctory-NVIDIA-RT@7526692, GPL-3.0-or-later.
Shaders: image and typed-buffer stores of fewer channels write the rest as zero
An image store whose dmask leaves channels out, and a typed buffer
store of fewer than four channels, were refused ("an image store of
some channels", "a typed buffer store of some channels or at an
offset"), so their programs did not translate. The console writes the
channels the mask leaves out, and those past a typed store's last, as
zero rather than keeping the texel's old values, so no read of the texel
is needed: they are now filled with zero (a d16 image store packs the
channels it does write two to a VGPR, as before). Still refused: an
image store of no channels, a partial store into a view the program
also counts in, and a typed store at an offset. Also adds a test for
s_pack_ll_b32_b16.
Tests: size_tests (zero-padded partial stores), valu_tests (s_pack_ll_b32_b16).
Ported from Kemerd/VIctory-NVIDIA-RT@6d9c88a, GPL-3.0-or-later.
Shaders: an LDS atomic add of a negated value is lowered so NVIDIA cannot fold it into a subtract
A group-shared atomic add of
sub 0, xwas emitted as written, andNVIDIA's D3D12 compiler folds it back into a group-shared atomic
subtract, which it refuses (CreateComputePipelineState returns
E_OUTOFMEMORY, so the pipeline is never made). Such an add is now
written as an add of
x * WaveReadLaneFirst(-1), which the compilercannot see through. Explicit ds_sub_u32 keeps its compare-exchange loop
(#1623).
Tests: emit::lds_sub_tests (hardware GPU; skipped where none is present).
Ported from DoubleGhosty/cool_fox@5b8e20c, GPL-3.0-or-later.
How it was tested
cargo testpassed for the crates it touches:cargo test -p victory-shader --lib -- image size_tests: 10 passedcargo test -p victory-shader --lib -- gfx10::: 17 passedcargo test -p victory-shader --lib -- cube_lod: 3 passedcargo test -p victory-shader --lib -- size_tests s_pack_ll: 10 passedcargo test -p victory-shader --lib -- lds_sub: 2 passedcargo clippy --workspace --all-targets --locked: no finding that main does not already have (main has 34 of its own, which is why the Clippy step of CI is red on main itself).cargo xtask policy: no new finding (main fails it on crates/victory-loader/src/heap_sites/frame_users.rs).cargo clippyalso with--all-featuresadds no finding, andcargo test --workspace --lockedfails only tests main also fails on this machine: the five shader tests that fail on main here too (WARP's SM 6.2 and the validator) (barycentric_tests::first_half_values_render_on_hardware_and_warp, hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, rect::tests::rectangles_are_drawn_whole, rect::tests::the_rectangle_stage_is_a_geometry_shader) and xtask's repository_passes_policy (frame_users.rs). 2208 passed, including five that fail on main (three BCPack oracle tests, the menu save race, the shader key test).Checked for overlap
🤖 Generated with Claude Code
An image store whose dmask leaves channels out, and a typed buffer store of fewer than four channels, were refused ("an image store of some channels", "a typed buffer store of some channels or at an offset"), so their programs did not translate. The console writes the channels the mask leaves out, and those past a typed store's last, as zero rather than keeping the texel's old values, so no read of the texel is needed: they are now filled with zero (a d16 image store packs the channels it does write two to a VGPR, as before). Still refused: an image store of no channels, a partial store into a view the program also counts in, and a typed store at an offset. Also adds a test for s_pack_ll_b32_b16. Tests: size_tests (zero-padded partial stores), valu_tests (s_pack_ll_b32_b16). Ported from Kemerd/VIctory-NVIDIA-RT@6d9c88a, GPL-3.0-or-later. Co-Authored-By: Claude Opus 5.5 <[email protected]>@ -11996,3 +12012,2 @@let counter = *dmask == 1 && self.is_counter(src);if *dmask != 0xF && !counter {return Err("an image store of some channels");if !counter && *dmask == 0 {@Copilot on GitHub · 2026-11-29 19:56 UTC · original
The no-channel rejection is unreachable: line 11839 changes every zero dmask to 1 before this branch. Consequently, a zero-mask image_store now translates as an X-only store and clears Y/Z/W, or takes the counter-store path, instead of being refused. Check the original mask from inst.fields here, while preserving zero-mask normalization for loads and samples.
@ -13124,2 +13158,2 @@if count != 4 || *offen || *offset != 0 {return Err("a typed buffer store of some channels or at an offset");// shortcut: typed stores are taken to write a float format.if *offen || *offset != 0 {@Copilot on GitHub · 2026-11-29 19:56 UTC · original
The newly accepted partial typed stores can still have a byte offset even when
offenis false and the instruction offset is zero:soffsetandbuilt_offset(src)contribute tooffabove. This path discardsoffand passes onlyindextobufferStore, so such a store silently writes the wrong element rather than being refused. Extend the offset rejection to scalar and descriptor-derived offsets, or correctly incorporate the complete byte address into the typed element index.@copilot-pull-request-reviewer[bot] on GitHub · 2026-11-29 19:56 UTC · original · reviewed
🟡 Changes recommended
Zero-mask image stores bypass rejection and can clear unintended channels, while partial typed stores ignore scalar and descriptor-derived byte offsets and may write to the wrong element.
2 open issues
What changed in this PR
Ports five fixes into the RDNA2-to-DXIL shader translator, improving instruction validation, texture operations, and NVIDIA pipeline compatibility.
Changes:
crates/victory-shader/src/gfx10/mod.rscrates/victory-shader/src/emit/valu_tests.rscrates/victory-shader/src/emit/size_tests.rscrates/victory-shader/src/emit/mod.rscrates/victory-shader/src/emit/lower.rscrates/victory-shader/src/emit/lds_sub_tests.rscrates/victory-shader/src/emit/cube_lod_tests.rscrates/victory-shader/src/emit/bitcode.rsReview effort: Balanced
@Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original
Good catch, fixed in
58173c40: the store branch now checks the instruction's own mask (no_channels, taken before the normalisation), so a dmask-0image_storeis refused. Loads and samples still treat 0 as 1. Regression test:an_image_store_of_no_channels_is_refused.@Adriwin06 on GitHub · 2026-11-30 01:10 UTC · original
Fixed in
99cfa483: a typed store of fewer than four channels is now refused unless the whole byte offsetoffis the constant 0. That covers a scalarsoffsetand the descriptor's base as well asoffen/offset. An inline-0soffsetis still no offset, and four-channel stores keep their old rule. Regression test:typed_stores_of_some_channels_at_a_scalar_offset_are_refused(inline 0 accepted,s20refused).Pull request closed