shader: translate sample and gather variants with offsets and comparisons #92

Manually merged
github merged 2 commits from github-bot/gh-92 into gh-pr/92/base 2026-11-26 15:22:31 +00:00 AGit
Owner

@⁠Olima34 on GitHub · 2026-11-26 14:29 UTC · original
Olima34:fix/shader-sample-offsets → main · +382 −41 · 5 files · 2 commits · merged 2026-11-26 15:19 UTC

What this changes

The translator refused by name the sample variants with texel offsets (image_sample_lz_o, _l_o, _b_o, _c_o, _c_lz_o, _d_o…) and the comparison gather image_gather4_c_lz (_o), used for shadow filtering. The offset was read for image_sample_o only, and the level and bias by exact name.

  • _o is now a suffix of any sample or gather: the offset is the first address VGPR, then the bias, the comparison value, the derivatives, the coordinates and the level, in the RDNA2 ISA reference's MIMG order (8.2.5). Every sample op takes the offsets (6-bit signed per axis on the console, immediate -8..7 in DXIL); a computed offset, one past -8..7, or one on a cube is refused.
  • image_gather4_c_lz lowers to textureGatherCmp (op 74), with the reference value before the coordinates. Guess, marked: a comparison gather compares the channel dmask picks while DXIL's compares red, so only red is taken and other channels are refused.

Tests: a new sample_tests.rs translates each variant from hand-assembled GFX10 code and checks the DXIL call and its constant arguments (opcode, offsets, level, bias, comparison). There are no Windows value tests yet.

How it was tested

  • cargo test -p victory-shader and arm64 cargo test --workspace (value probes run only in the Windows CI)
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings, also with --all-features
  • cargo xtask policy
  • Ran the game: not done, no copy of it here

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Olima34** on GitHub · 2026-11-26 14:29 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/92) `Olima34:fix/shader-sample-offsets` → `main` · +382 −41 · 5 files · 2 commits · merged 2026-11-26 15:19 UTC ## What this changes The translator refused by name the sample variants with texel offsets (`image_sample_lz_o`, `_l_o`, `_b_o`, `_c_o`, `_c_lz_o`, `_d_o`…) and the comparison gather `image_gather4_c_lz` (`_o`), used for shadow filtering. The offset was read for `image_sample_o` only, and the level and bias by exact name. - `_o` is now a suffix of any sample or gather: the offset is the first address VGPR, then the bias, the comparison value, the derivatives, the coordinates and the level, in the RDNA2 ISA reference's MIMG order (8.2.5). Every sample op takes the offsets (6-bit signed per axis on the console, immediate -8..7 in DXIL); a computed offset, one past -8..7, or one on a cube is refused. - `image_gather4_c_lz` lowers to `textureGatherCmp` (op 74), with the reference value before the coordinates. Guess, marked: a comparison gather compares the channel dmask picks while DXIL's compares red, so only red is taken and other channels are refused. Tests: a new `sample_tests.rs` translates each variant from hand-assembled GFX10 code and checks the DXIL call and its constant arguments (opcode, offsets, level, bias, comparison). There are no Windows value tests yet. ## How it was tested - [x] `cargo test -p victory-shader` and arm64 `cargo test --workspace` (value probes run only in the Windows CI) - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`, also with `--all-features` - [x] `cargo xtask policy` - [ ] Ran the game: not done, no copy of it here ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
The translator refused image_sample_lz_o, _l_o, _b_o, _c_o, _c_lz_o,
_d_o and image_gather4_c_lz(_o) by name: offsets were read for plain
image_sample only, and the bias and level positions assumed no offset.
The suffix now picks the address VGPRs in the RDNA2 ISA order (8.2.5:
offset, bias, z-compare, derivatives, coordinates, level or clamp), so
every sample takes `_o` (constant offsets in -8..7, not on cubes), and
the comparison gather at level 0 becomes textureGatherCmp. A comparison
gather of another channel than red stays refused (DXIL compares red; the
console's channel choice is a guess), as do comparisons at an explicit
level, with bias or gradients.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:45:48 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-26 14:54 UTC · original · approved these changes

Address order and offset handling match the ISA, and the red-only gather guess is clearly marked. Thanks.

**@⁠LakshanSivakumar** on GitHub · 2026-11-26 14:54 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/92#pullrequestreview-6076250744) · **approved these changes** Address order and offset handling match the ISA, and the red-only gather guess is clearly marked. Thanks.
github-bot changed target branch from main to gh-pr/92/base 2026-11-26 15:22:31 +00:00
github manually merged commit dbae31dc71 into gh-pr/92/base 2026-11-26 15:22:31 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.