Skip to content

Translator: gather wrap and mirror without OpSMod (SHADER-369) - #2115

Closed
airp1ane wants to merge 1 commit into
ItsNotRexed:mainfrom
airp1ane:shader-369-gather-wrap-srem
Closed

airp1ane wants to merge 1 commit into
ItsNotRexed:mainfrom
airp1ane:shader-369-gather-wrap-srem

Conversation

@airp1ane

Copy link
Copy Markdown
Contributor

SHADER-369 (claimed in #1902).

ps_gather_wrap returns all-zero gathers on an AMD iGPU (Windows driver 24.10.24) in exactly the cases where the wrap or mirror coordinate gives OpSMod a negative dividend. NVIDIA passes the same module. Gen.gather_addr now computes wrap (n) and mirror (2n) as ((c srem n) + n) srem n, with OpSRem only. The sum is positive because OpSRem's sign follows the dividend and n >= 1, so the result is the same floor modulo with no reliance on the driver's OpSMod sign handling.

  • tests/test_translate.py: the two gather address-mode tests count OpSRem (2 per remainder) and assert no OpSMod.
  • docs/design.md: the gather contract row records the rule and why.

Tested on Windows 11, NVIDIA RTX 4060 Ti (Ada, subgroup 32), driver 621.24, llvm-mc 21.1.8:

  • tests/test_translate.py: 498 passed, 2 skipped. python -m unittest discover -s tests/semantic: 1644 OK.
  • run_gpu_tests.py --filter gather: ps_gather_wrap 4096/4096 pixels exact, ps_gather_sampler_lod exact.

Not tested: the AMD iGPU from the finding. A rerun of ps_gather_wrap there is what confirms the fix. This change doesn't touch the border modes in #2025 (SHADER-348).

AI-assisted (Claude Code).

🤖 Generated with Claude Code

ps_gather_wrap returned all-zero gathers on an AMD iGPU (Windows driver
24.10.24) exactly where OpSMod's dividend was negative. Gen.gather_addr now
takes ((c srem n) + n) srem n, OpSRem only, for both wrap (n) and mirror (2n).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@airp1ane

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate of #2105, which @whoalin1 opened two minutes earlier and has already checked on the AMD iGPU from the finding. I tested #2105 on an RTX 4060 Ti: it passes. Sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant