Shaders: lower image_gather4_c_lz(_o) and remaining offset sample variants #123
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!123
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-123"
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?
@davi713albano-coder on GitHub · 2026-11-24 21:39 UTC · original
davi713albano-coder:shader/image-gather-cmp-and-sample-offsets→main· +595 −38 · 3 files · 1 commits · openSummary
Extends
emit::lower::imageto cover the remaining comparison-gather and offset-sample MIMG instructions:image_gather4_c_lz(0x04f) andimage_gather4_c_lz_o(0x05f) to DXILdx.op.textureGatherCmp.f32(opcode74), marking the sampler as a comparison sampler (0x8000), extracting programmable 2D offsets when_ois set, passingdmask.trailing_zeros()and the comparison reference, and writing all four gathered channels._o) sample variants:image_sample_l_o,image_sample_b_o,image_sample_d_o,image_sample_c_o(pixel shaders), andimage_sample_c_lz_o.addr_u32(self, 0)(instead ofaddr_val, which masks with0xFFFFundera16), support alloffsetsaxes including 3D Z (bits 16..21), reject cube samples with texel offsets, and emit immediate-8..=7offsets for all non-gather sample ops when the offset word is a constant in range (keeping the runtime sign-extension fallback for non-constant offsets and gathers).Changes
crates/victory-shader/src/emit/lower.rs: addimage_gather4_c_lz(_o)(op 74) andimage_sample_{l,b,d,c,c_lz}_o, unify constant/runtime texel-offset decoding withaddr_u32and 3D Z support, and fiximage_sample_l_oLOD lookup.crates/victory-shader/src/emit/valu_tests.rs:image_gather4_c_lz_and_offset_match_d3d12: synthetic compute tests forimage_gather4_c_lz(dmask:0x1anddmask:0x2) andimage_gather4_c_lz_o(runtime positive and negative offsets) withdxil.dllvalidation and D3D12 WARP readback.image_sample_offset_variants_match_d3d12: synthetic compute tests with D3D12 WARP readback forimage_sample_l_o,image_sample_c_lz_o, andimage_sample_d_o, plus pixel-shaderdxil.dllvalidation and D3D12 graphics PSO creation forimage_sample_b_oandimage_sample_c_o.Verification
windows-latest): https://github.com/davi713albano-coder/victory-fork/actions/runs/45492007121cargo clippy --workspace --all-targets --locked -- -D warnings: passedcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passedcargo test --workspace --locked(includingxtaskasset-policy check,dxil.dllvalidation, and D3D12 WARP tests): 498 passed, 0 failed (image_gather4_c_lz_and_offset_match_d3d12 ... ok,image_sample_offset_variants_match_d3d12 ... ok)(No title data used. AI-assisted.)
@adriaespii on GitHub · 2026-11-24 21:52 UTC · original
Independent test run on commit
46ea6e5(AMD RDNA4) — both new hardware GPU tests fail:x86_64-pc-windows-msvc)cargo clippy --workspace --all-targets -- -D warnings: 0 warningscargo test --workspace:victory-shaderfails with 210 passed, 2 failed, 2 ignored:AI use: Antigravity (Gemini 4 Neon) ran clippy/tests locally and wrote this report.
@ezbyDev on GitHub · 2026-11-24 21:52 UTC · original
The two new tests fail on AMD hardware at this PR's head (
46ea6e5), with nothing else applied:Both fail at case 0 with all zeros, which looks like the translated program reading nothing rather than a precision difference. The rest of
victory-shader(227 tests) passes on the same machine.Setup: AMD Radeon RX 9060 XT 16 GB (RDNA4, native 64-lane waves), Adrenalin 32.0.32029.2010; i7-9700K; Windows 11 Pro 26300; Rust 1.98.1 (pinned); DXC from the Windows SDK 10.0.26100.
Not tested: NVIDIA (if they pass there, it would point at a wave-size or AMD driver difference); which of the cases after case 0 fail.
AI-assisted (Claude Code, Claude Opus 5.5): ran the tests on my machine and wrote this.
@arminkhaleghirod on GitHub · 2026-11-24 22:23 UTC · original
Merged onto main
90228a7and ranvictory translate --validateover the full title (26,148 programs) on Windows 11 / RTX 4080.No change: every failure count matches main, and no new reason appears. What it changes at run time isn't covered by this check.
@davi713albano-coder on GitHub · 2026-11-25 04:08 UTC · original
Thanks @adriaespii and @ezbyDev for testing on RX 9070 / RX 9060 XT!
Root cause of the hardware failures:
sample_l_o(regular point sampler) passed on both GPUs, whileimage_gather4_c_lz,image_gather4_c_lz_o, andimage_sample_c_lz_oreturned[0.0, 0.0, 0.0, 0.0].View::Texture(DXGI_FORMAT_R32G32B32A32_FLOAT) to a comparison sampler. Per D3D12 format support rules,SHADER_SAMPLE_COMPARISON/SHADER_GATHER_COMPARISONare only guaranteed on single-channel float/depth formats (such asDXGI_FORMAT_R32_FLOAT); AMD hardware returns0.0for comparison filtering onR32G32B32A32_FLOATwhile WARP permits it.Fix in the rebased commit (
7871ce7):main(310c6eb).View::FloatTexture(u32, u32, &[f32])(DXGI_FORMAT_R32_FLOAT) to the test harness incrates/victory-shader/src/emit/host.rs.image_gather4_c_lz,image_gather4_c_lz_o,image_sample_c_lz_o) to bindView::FloatTexturewhile keeping non-comparison offset sampling tests onView::Texture.clippy,clippy --all-features, andcargo test --workspace --lockedonwindows-latest(DXIL validation + WARP execution). Would appreciate a re-test on AMD hardware when you have a moment!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.