Shaders: extend image_gather4_l(_o) to all address modes, borders, a16, d16, unorm, and 2D arrays #1853
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!1853
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1853"
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?
@ESAT586 on GitHub · 2026-11-24 23:29 UTC · original
ESAT586:shader/gather-at-level-modes→main· +1810 −99 · 3 files · 3 commits · openSummary
Extends image_gather4_l and image_gather4_l_o emulation (Lower::gather_at_level) on top of
70564aebeyond 2D transparent-black-border 32 gathers:@upipibi on GitHub · 2026-11-24 23:42 UTC · original
NVIDIA run: RTX 3070 8 GB, driver 616.56, plus WARP, Windows 11, debug,
0ec4750(onmain70564ae).cargo test -p victory-shader --locked: 209 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA failures onmain.On the cases left refused ("a gather at a level that may not be whole", fractional LOD limits and bias): the level rule for a fractional LOD has now been measured on RDNA2 (gfx1036) in boykopovar/AnyPS5#23856 and #23666. LOD bias is added first, then the S#
MIN_LOD/MAX_LODclamp, then the T#MIN_LOD. The LOD is rounded to 1/256 with halves up, and the nearest level is taken with ties up, i.e. levelfloor(lod + 0.501953125). A linearMIP_FILTERgathers that single level too. That would let those cases be accepted rather than refused.AI-assisted (Claude Code). Synthetic tests only.
@AlanQiang0418 on GitHub · 2026-11-24 23:53 UTC · original
Two independent follow-ups on
0ec4750.Null texture and an opaque border. I dispatched the PR's existing address-mode shader twice, keeping the sampler, input coordinates and output layout identical. The second dispatch bound a typed RGBA32F null Texture2D SRV. With opaque white/red or opaque black/alpha, both explicit-level gathers returned four
1.0values on all 32 lanes. The native level-zero gather in the same shader returned four zeros. I reproduced this on an RTX 5080 (621.14) and Microsoft WARP. The runtime creates typed null texture descriptors in null_like and null_view. D3D12 null descriptor behaviorNull-texture fix and regression. The emulation checks the mip-zero width before calculating a footprint or applying a border color. All 11 sampler configurations now return zero for the null view on both backends, with the original live-texture checks still passing.
Whole-LOD check for packed A16 array coordinates. For
v_lshl_or_b32 dst, src0, 16, src2, the upper half issrc0.low | src2.high. Withsrc0 = 0x3c00, changingsrc2from0x00003c00to0x02003c00keeps the array slice at 1 but changes the half-float LOD from 1.0 to 1.5. The original proof accepts both. Packed-LOD fix and four synthetic cases. The literal and per-lane fractional cases are now rejected, and a per-lane whole LOD and a constant −1 remain accepted.Both commits apply together. Five gather tests passed with both applied, and shader all-targets Clippy passed. The sixth gather test,
gathers_at_a_level_match_the_hardware, still differs on RTX lane 0 ([0, 1, 0, 0]vs[0, 0, 0, 0]). I got the same result on clean upstream70564ae, clean PR head0ec4750, and both commits combined. Previous hardware report@ESAT586 on GitHub · 2026-11-25 00:09 UTC · original
Thanks @AlanQiang0418 and @upipibi for the thorough hardware runs and exact catches!
Both bugs reported by @AlanQiang0418 are now fixed in the latest commit on this branch:
gather_at_levelnow checks mip-0 width (w0 == 0fromgetDimensions(h, 0)), guardsURemdivisors against zero onWRAP/MIRROR, clamps null-view mip level to0, and forces0.0across all 4 gather results (matching native D3D12textureGathereven underOpaqueWhiteandOpaqueBlackalpha). AddedView::NullTexture(#[cfg(test)]) andgathers_at_a_level_return_zero_on_null_texture_even_with_opaque_bordertesting all 11 sampler configs on hardware + WARP.whole_f16soundness forv_lshl_or_b32 dst, src0, 16, src2: when inspecting the packed high half (hi == true),whole_f16now evaluates constant(src0, src2)pairs together or requireshigh16_zero_op(src2)to provesrc2[31:16] == 0(and decodes inline float constants240..=248as f16 bits for 16-bit float ops). Addedgathers_at_a_level_a16_packed_lshl_or_validates_src2_high_halfcovering literal fractionalsrc2, per-lane unmaskedsrc2, per-lane whole + maskedsrc2, and constant-1.0f16.Regarding @upipibi's note on fractional LOD rounding (
floor(lod + 0.501953125)): keeping fractional-LOD acceptance out of this PR to stay focused and preserve the existing scope; happy to follow up separately if desired.Re-verified on Windows 11 with NVIDIA GeForce RTX 3060 Ti + Microsoft D3D12 WARP +
dxil.dll:cargo test -p victory-shader --lib emit::synthetic_tests::gathers_at_a_level_ -- --test-threads=1 --skip gathers_at_a_level_match_the_hardware: 6 passed, 0 failedcargo clippy --workspace --all-targets -- -D warnings&--all-features: 0 warningscargo xtask policy: ok(Clean-room synthetic tests only, zero game data. AI-assisted with Gemini 4 Neon (Extra High Mode).)
@upipibi on GitHub · 2026-11-25 00:25 UTC · original
Re-checked
59b8454on the RTX 3070 (driver 616.56, Windows 11, debug).cargo test -p victory-shader --lockedgives 211 passed, 3 failed, 2 ignored. The 3 are #1744's NVIDIA failures onmain(the twostride_testsheap-buffer reads andgathers_at_a_level_match_the_hardware). The new null-texture test passes here, so this matchesmainplus the new tests.AI-assisted (Claude Code).
@AlanQiang0418 on GitHub · 2026-11-25 00:30 UTC · original
Retested your integrated
59b8454on RTX 5080 (621.14) and WARP. The null-texture and packed-LOD cases pass. With #1887 atbb5acbaapplied, the previously failing legacy gather also passes: 7/7 gather tests.I found one remaining way for a fractional LOD to pass the updated proof. Take the existing loaded slice word
v13, copy it withv_and_b32 v16, v13, v13, and usev16as the final operand of the shift-OR. The AND preserves bit 25, which can change the packed half from 1.0 to 1.5. On this head the checker fails to prove the first operand has zero high bits, then accepts the same value on its second visit. The synthetic shader consequently translates.Follow-up commit on your new head caches the proof result and scopes loop assumptions to the incoming edges of each phi. The regression rejects the unmasked copy, accepts a copy masked to 16 bits, and checks both outcomes with a two-iteration loop. With the follow-up and #1887's view change applied, all seven gather tests, the indexed-buffer read test and shader all-targets Clippy passed.
@andrewpozdnakov7-jpg on GitHub · 2026-11-25 00:50 UTC · original
I checked the gather coordinate product on your current head,
59b8454a8f. It sets Int64ShaderOps even though the final coordinate fits in 32 bits for every D3D12 texture dimension. DirectX feature requirements16a4e77 is one commit directly on that head. It splits the signed product at bit 16 and preserves the exact footprint rounding. I ran the same test before and after on WARP, including a 16,381-texel-wide 2D array plus the A16, D16 and unnormalized cases. The texel readbacks matched on both builds. The SFI0 assertion failed with 0x8000 before and passed with zero after.
Full forced-WARP suite: 211 passed / 3 failed / 2 ignored before, 212 / 2 / 2 after. The legacy native gather comparison and lane permute produced the same failures in both runs. Strict shader Clippy and asset policy passed.
@AlanQiang0418 on GitHub · 2026-11-25 02:27 UTC · original
I compared the 32-bit coordinate patch with its parent
59b8454on RTX 5080 (621.14) and Microsoft WARP. For each adapter and build I compared 1,408 four-texel gathers against the CPU reference (widths 16,381 and 16,384; 11 sampler configurations; 32 lanes; with and without offsets). All 1,408 matched. The patch cleared the generated shader's Int64 feature flag; the wider A16/D16/unnormalized array fixture also passed.One detail for reproducing boundary comparisons: at width 16,384, normalized
u = f32::from_bits(0x3d800ff0),v = 0.25, wrap, level zero, the reference and both translated versions returned[33793, 33794, 17410, 17409]. Native gather returned[33792, 33793, 17409, 17408]. Both backends differed from the translated footprint in 28/108 native level-zero comparisons at this width, with the same differences before and after the change. At width 16,381 the corresponding counts were 0/108 for RTX and 7/108 for WARP. The old and new code agreed even at the neighboring f32 values on either side of the tested thresholds.@Marvisak on GitHub · 2026-11-25 07:25 UTC · original · edited 2026-11-25 22:18 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main(conflict incrates/victory-shader/src/emit/synthetic_tests.rs). It will be reviewed again once it is rebased.From the earlier needs-work note, still open: fix the CI compile error (
view_marksmissing insynthetic_tests.rs), say which title shaders need which gather modes and keep only those, and ideally split out the null-texture andv_lshl_or_b32proof work.Generated by Claude Code
@Dathinel on GitHub · 2026-11-25 08:21 UTC · original
I tested the two suggested follow-ups together on Windows. The 32-bit footprint change and the packed LOD proof fix merged cleanly on
59b8454. With the test-host delta from #1887 (ccfb029..62bd980), all 7 tests passed with cargo test --locked -p victory-shader --lib synthetic_tests::gathers_at_a_level, including the 16,381-wide array and packed-LOD loop cases.As a control, keeping the combined tests and restoring only lower.rs from the 32-bit patch made the repeated-operand regression fail: translation accepted the unknown upper half. The two fixes can be evaluated together; the coordinate change alone still needs the LOD fix for that case. These synthetic results leave the requested evidence about which modes the title uses open. AI-assisted validation.
@sinan-cmyk on GitHub · 2026-11-25 12:11 UTC · original
Offline measurement on a retail dump
Result: no count change against
main.I merged head
59b8454aontomain940d32f(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).
@ESAT586 on GitHub · 2026-11-25 15:19 UTC · original
Thanks for the thorough reviews, bug catches, and testing @andrewpozdnakov7-jpg, @AlanQiang0418, @Dathinel, and @sinan-cmyk!
Addressed all three concrete review findings in
dc26c73:Re-verified on RTX 3060 Ti and WARP (VICTORY_WARP=1): all 6 PR gathers_at_a_level* tests pass on both backends (with legacy gathers_at_a_level_match_the_hardware showing only the pre-existing #1744/#1887 baseline diff), strict Clippy (--all-targets -- -D warnings) clean, and cargo xtask policy (174 files ok).
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.