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

Merged
Olima34 merged 2 commits from upstream-pr/92 into main 2026-11-26 15:19:55 +00:00
Olima34 commented 2026-11-26 14:29:21 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Olima34 on 2026-11-26T14:29:21Z.


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)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:6628803619 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/92). Originally posted by [Olima34](https://github.com/Olima34) on 2026-11-26T14:29:21Z. --- ## 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)
LakshanSivakumar commented 2026-11-26 14:54:49 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T14:54:49Z.

Review: APPROVED


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6076250744 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/92#pullrequestreview-6076250744). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-26T14:54:49Z. **Review:** APPROVED --- Address order and offset handling match the ISA, and the red-only gather guess is clearly marked. Thanks.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS!92
No description provided.