Repository navigation
Translator: gather wrap/mirror use OpSRem + fix-up, not OpSMod (AMD Windows driver reads zeros) - #2105
Conversation
|
Tested
No game files. AI-assisted verification. |
|
Tested AI-assisted (Claude Code). |
|
Independent synthetic verification (AI-assisted with Codex) of head Windows 11, Ryzen 7 9800X3D integrated AMD Radeon Graphics (PCI device
All three base/head readback pairs were byte-identical, with zero validation diagnostics across the six draws. I assembled The base result confirms the earlier stock wrap pass on this adapter in #2025 and adds an exact base/head comparison with both LOD bounds. Driver 25.10.30.02 handled the stock |
|
Tested
AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine. |
|
Tested Full suite,
AI-assisted (Claude Code). No game files used. |
|
Tested da78e80 (applied on #2048's head dfc3c78) on Windows 11 Home 26300: pass. AI-assisted (Claude Code). Hardware: AMD Ryzen 5 7600X; iGPU AMD Radeon(TM) Graphics (RDNA2, subgroup 32..64), AMD driver 24.10.24 (Vulkan driver 2.0.302); NVIDIA GeForce RTX 5060 Ti, driver 610.88. MSVC 14.44, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (scripts\build_llvm_mc.ps1), Python 3.12.10. Implicit layers off. No game files.
This reproduces the failure on a second machine with the same driver and confirms the fix.
|
da78e80 to
c7e2fa4
Compare
|
Tested the rebased head
This is NVIDIA only: the No game files. AI-assisted verification. |
…up, not OpSMod (AMD Windows driver) On a Ryzen 5 7600's iGPU (RDNA2) with AMD's Windows driver 24.10.24, OpSMod of a negative coordinate came out with the dividend's sign, so ps_gather_wrap's three cases with a negative wrap or mirror coordinate fetched outside the image and read zeros. Gen.gather_addr now computes c mod n as OpSRem plus n when the remainder is negative, the same value for a positive period; the same module is then exact there, and still on an RTX 4070 SUPER. tests/test_translate.py counts the new instructions; docs/design.md records why. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c7e2fa4 to
35781d4
Compare
|
Tested 35781d4 on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
Claimed in the coordination issue as: new item, #1902 (comment) (from my finding just above it).
What and why
image_gather4_l(_o)maps each texel coordinate through the S#'s address mode inGen.gather_addr(SHADER-36, #341). Wrap tookOpSMod c n, and mirrorOpSMod c 2n.On a Ryzen 5 7600's iGPU (RDNA2) with AMD's Windows driver 24.10.24,
ps_gather_wrapfailed: the interior case and cases 3, 4 and 5 were exact, while cases 1, 2 and 6 came back all zero. Those are exactly the three cases where a coordinate going intoOpSModis negative:OpSModinputEvery passing case has only non-negative
OpSModinputs: case 5 mirrors x = 20, and cases 3 and 4 don't use it. The same module passes on an RTX 4070 SUPER. So the driver gaveOpSModthe dividend's sign, a negative coordinate reachedOpImageFetch, and the fetch read zeros.The fix:
gather_addrcomputesc mod masOpSRem c m, plusmwhen that remainder is negative. That's the same value asOpSModfor the positive periods used here (n, 2n), and noOpSModis left in the translator. The project already works around this driver family the same way (FClampon the run-time LOD path, #1032).tools/rdna2spirv.py:Gen.gather_addr's modulo, with the reason in its docstring.tests/test_translate.py: the gather tests countOpSRemand the fix-upOpSLessThaninstead ofOpSMod(literal modes per axis; all four modes at run time).docs/design.md: the gather row says why the modulo isn'tOpSMod.Tested
AI-assisted (Claude Code). Windows 11 (build 26200), Python 3.14.4, llvm-mc 21.1.8 (WSL), SPIRV-Tools v2026.4, test programs built with MSVC 14.44. No game files.
This test can only run on that AMD iGPU through #2048, because it has 128 bytes of push constants. So the GPU runs used #2048's branch with this change applied, and
--filter gather:OpSMod(before)OpSRem+ fix-up (this PR)LEONIDA_PC_TAIL_UBO=1ps_gather_wrapFAIL:out.gand half ofout.aare 0 (cases 1, 2, 6)ps_gather_wrap4096/4096 pixels exact;ps_gather_sampler_lodpassLEONIDA_PC_TAIL_UBO=1python -m pytest tests/test_translate.py tests/test_mesh_compute.py tests/test_shader_index.py: 530 passed, 2 skipped (the 48 gather tests among them).python -m unittest discover -s tests/semantic: 1671 OK.python -m compileall -q tools tests: clean.Not checked: whether newer AMD Windows drivers still do this. The design notes record
ps_gather_wrappassing on a Radeon 880M, which is RDNA3.5 on a newer driver.Checklist
docs/design.md, with how it was confirmed.🤖 Generated with Claude Code