Shaders: lower gradient samples with an offset and LOD clamp #3493

Open
github-bot wants to merge 1 commit from github-bot/gh-3493 into main AGit
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 09:47 UTC · original
andrewpozdnakov7-jpg:codex2/gradient-sample-offset-lod-clamp → main · +120 −22 · 2 files · 1 commits · open

image_sample_d_cl_o already decodes, but main refuses it during lowering. Route it to DXIL sampleGrad, use the existing immediate-offset encoding, and take the LOD clamp after the gradient and coordinate operands. The current SM 6.6 path uses immediate offsets from -8 through 7. Cube gradient samples with an offset report an unsupported operation. Texture2D SampleGrad

The synthetic regression samples a texture whose texels encode mip, row and column. Four dispatch cases combine mip 0 or mip 2 with zero offset or (+1, -1). All 32 lanes write to their own output dword. On 63bcca4 the test stops at the unsupported opcode. On the patch, WARP reads the expected values 294, 263, 2066 and 2035 respectively.

All 36 VALU tests and all 33 lowerer tests passed on the final commit. Strict shader Clippy passed with default and all features. Asset policy and git diff checks passed.

Independent testing on RTX 4090 Laptop (driver 621.14) and WARP passed all 32 lanes in each of ten dispatches on 48e796a, including offsets −8 and +7 and additional LOD clamps. The RX 5700 XT run on the combined follow-up 102b5c2 also passed all 16 cases. RTX and WARP report · RX 5700 XT report

Related work on other sample and gather offset forms is in #1687. Synthetic textures and shaders only. AI-assisted with Codex.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 09:47 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493) `andrewpozdnakov7-jpg:codex2/gradient-sample-offset-lod-clamp` → `main` · +120 −22 · 2 files · 1 commits · open `image_sample_d_cl_o` already decodes, but `main` refuses it during lowering. Route it to DXIL `sampleGrad`, use the existing immediate-offset encoding, and take the LOD clamp after the gradient and coordinate operands. The current SM 6.6 path uses immediate offsets from -8 through 7. Cube gradient samples with an offset report an unsupported operation. [Texture2D SampleGrad](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/texture2d-samplegrad) The synthetic regression samples a texture whose texels encode mip, row and column. Four dispatch cases combine mip 0 or mip 2 with zero offset or (+1, -1). All 32 lanes write to their own output dword. On `63bcca4` the test stops at the unsupported opcode. On the patch, WARP reads the expected values 294, 263, 2066 and 2035 respectively. All 36 VALU tests and all 33 lowerer tests passed on the final commit. Strict shader Clippy passed with default and all features. Asset policy and git diff checks passed. Independent testing on RTX 4090 Laptop (driver 621.14) and WARP passed all 32 lanes in each of ten dispatches on `48e796a`, including offsets −8 and +7 and additional LOD clamps. The RX 5700 XT run on the combined follow-up `102b5c2` also passed all 16 cases. [RTX and WARP report](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3493) · [RX 5700 XT report](https://git.gtahub.st/github/Marvisak--VIctory/pulls/3493) Related work on other sample and gather offset forms is in #1687. Synthetic textures and shaders only. AI-assisted with Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 10:43:03 +00:00
Author
Owner

@⁠oddmaniv on GitHub · 2026-11-27 10:09 UTC · original

Independent verification of the PR author's concurrent WARP pipeline/draw test at 48e796ad3672d629050fba765e73baef68dc9e8c.

cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture

Tree Result
Unmodified PR head 1 passed, 0 failed, 0 ignored; native exit 0
Unmodified main 1 passed, 0 failed, 0 ignored; native exit 0
PR patch applied to pinned main 1 passed, 0 failed, 0 ignored; native exit 0

Main baseline pin: 63bcca43c6a00a758510398fa43096ce7e4f7df0.

Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits.
This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed.

AI-assisted verification.

**@⁠oddmaniv** on GitHub · 2026-11-27 10:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493#issuecomment-7215535040) Independent verification of the PR author's concurrent WARP pipeline/draw test at `48e796ad3672d629050fba765e73baef68dc9e8c`. `cargo test --locked -p victory-shader --lib emit::host::tests::parallel_warp_pipelines_and_draws -- --exact --nocapture` | Tree | Result | | --- | --- | | Unmodified PR head | 1 passed, 0 failed, 0 ignored; native exit 0 | | Unmodified main | 1 passed, 0 failed, 0 ignored; native exit 0 | | PR patch applied to pinned main | 1 passed, 0 failed, 0 ignored; native exit 0 | Main baseline pin: `63bcca43c6a00a758510398fa43096ce7e4f7df0`. Windows x86_64 MSVC native runs. Local and remote source snapshots matched before and after each check. The adaptation applies the PR diff without additional source edits. This is focused regression coverage, not the full workspace suite, a gameplay test, or an independent validation of every behavior in the PR. No new fix is claimed. AI-assisted verification.
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 12:52 UTC · original

I tested #3493 together with #1687, #1256 and #2372 on current main (63bcca4). The merge resolution at 102b5c2 preserves all four PR heads. It reads the offset from a whole VGPR and locates the LOD clamp after the independently packed gradients and coordinates. Both cube and cube-array gradient samples with an offset stop during translation.

The expanded 2D fixture fails on main with image_sample_d_cl_o unsupported. On the combined tree, app-local WARP 1.0.22 passed all 16 cases, checking all 32 lane writes per case. The matrix covers a16 and _g16 independently, offsets (0, 0) and (1, -1), and minimum LODs 0 and 2. The #1687 comparison-gather checks and #1256/#2372 cube readbacks also passed.

Full shader suite on the combined tree: 333 passed, 4 failed, 3 ignored. Each of those four failures also occurs on main in the same WARP setup. All-target/all-feature shader Clippy with warnings denied and the asset policy passed.

If folding the added regression or the merge resolution into another commit, please retain Git authorship or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. All shaders and textures were synthetic.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 12:52 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493#issuecomment-7218785421) I tested #3493 together with #1687, #1256 and #2372 on current main (63bcca4). [The merge resolution at 102b5c2](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/packed-gradient-offset-composition) preserves all four PR heads. It reads the offset from a whole VGPR and locates the LOD clamp after the independently packed gradients and coordinates. Both cube and cube-array gradient samples with an offset stop during translation. The expanded 2D fixture fails on main with `image_sample_d_cl_o` unsupported. On the combined tree, app-local WARP 1.0.22 passed all 16 cases, checking all 32 lane writes per case. The matrix covers `a16` and `_g16` independently, offsets (0, 0) and (1, -1), and minimum LODs 0 and 2. The #1687 comparison-gather checks and #1256/#2372 cube readbacks also passed. Full shader suite on the combined tree: 333 passed, 4 failed, 3 ignored. Each of those four failures also occurs on main in the same WARP setup. All-target/all-feature shader Clippy with warnings denied and the asset policy passed. If folding the added regression or the merge resolution into another commit, please retain Git authorship or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. All shaders and textures were synthetic.
Author
Owner

@⁠ColorMeBoom on GitHub · 2026-11-27 15:07 UTC · original

AMD hardware run: RX 5700 XT (RDNA1), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Head 48e796a merged onto main 63bcca4, no game files. So far this PR has only WARP reports.

  • gradient_samples_apply_the_offset_at_the_clamped_mip passes on the hardware adapter and on WARP. Neither printed a skip, so both ran the per-clamp assert_eq! over all 32 lanes.
  • Full victory-shader suite (--features host): 303 passed, 0 failed, 3 ignored. cargo clippy -p victory-shader --all-targets --features host -- -D warnings: clean.

This is the PR alone. @⁠andrewpozdnakov7-jpg's combined branch with #1687, #1256 and #2372 wasn't run here.

AI use: Claude Code (Claude Opus 5.5).

**@⁠ColorMeBoom** on GitHub · 2026-11-27 15:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493#issuecomment-7221644940) **AMD hardware run: RX 5700 XT** (RDNA1), driver 32.0.21045.29003, Windows 11 26200, Rust 1.98.1. Head `48e796a` merged onto `main` `63bcca4`, no game files. So far this PR has only WARP reports. - `gradient_samples_apply_the_offset_at_the_clamped_mip` **passes on the hardware adapter and on WARP**. Neither printed a skip, so both ran the per-clamp `assert_eq!` over all 32 lanes. - Full `victory-shader` suite (`--features host`): **303 passed, 0 failed, 3 ignored**. `cargo clippy -p victory-shader --all-targets --features host -- -D warnings`: clean. This is the PR alone. @⁠andrewpozdnakov7-jpg's combined branch with #1687, #1256 and #2372 wasn't run here. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-27 15:31 UTC · original

Thanks @⁠ColorMeBoom for checking 48e796a on the RX 5700 XT. The expanded case is in 102b5c2 under the same test name. If you have time for one more synthetic run on that card, please try cargo test --locked -p victory-shader --lib --features host gradient_samples_apply_the_offset_at_the_clamped_mip -- --nocapture. It checks all four coordinate/gradient packing combinations at two offsets and two clamped mip levels. Those 16 cases have passed on WARP here. Your run above covers the original PR fixture.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-27 15:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493#issuecomment-7222166966) Thanks @⁠ColorMeBoom for checking `48e796a` on the RX 5700 XT. The expanded case is in [`102b5c2`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/102b5c2fd805a062c9227e799fa357b6da2f6f0e) under the same test name. If you have time for one more synthetic run on that card, please try `cargo test --locked -p victory-shader --lib --features host gradient_samples_apply_the_offset_at_the_clamped_mip -- --nocapture`. It checks all four coordinate/gradient packing combinations at two offsets and two clamped mip levels. Those 16 cases have passed on WARP here. Your run above covers the original PR fixture.
Author
Owner

@⁠ColorMeBoom on GitHub · 2026-11-27 15:38 UTC · original

@⁠andrewpozdnakov7-jpg ran it: 102b5c2 as is (it already contains main 63bcca4), on the same RX 5700 XT, with VICTORY_WARP unset.

  • cargo test --locked -p victory-shader --lib --features host gradient_samples_apply_the_offset_at_the_clamped_mip -- --nocapture: passed. Neither adapter printed a skip, so all 16 cases (4 coordinate/gradient packings × 2 offsets × 2 clamped mips) were checked on the hardware adapter and on WARP.
  • Full victory-shader suite on that tree (--features host): 337 passed, 0 failed, 3 ignored. cargo clippy -p victory-shader --all-targets --features host -- -D warnings: clean.

AI use: Claude Code (Claude Opus 5.5).

**@⁠ColorMeBoom** on GitHub · 2026-11-27 15:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493#issuecomment-7222302414) @⁠andrewpozdnakov7-jpg ran it: [`102b5c2`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/102b5c2fd805a062c9227e799fa357b6da2f6f0e) as is (it already contains `main` `63bcca4`), on the same RX 5700 XT, with `VICTORY_WARP` unset. - `cargo test --locked -p victory-shader --lib --features host gradient_samples_apply_the_offset_at_the_clamped_mip -- --nocapture`: **passed**. Neither adapter printed a skip, so all 16 cases (4 coordinate/gradient packings × 2 offsets × 2 clamped mips) were checked on the hardware adapter and on WARP. - Full `victory-shader` suite on that tree (`--features host`): **337 passed, 0 failed, 3 ignored**. `cargo clippy -p victory-shader --all-targets --features host -- -D warnings`: clean. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠passerbyyhx on GitHub · 2026-11-27 18:56 UTC · original

Windows synthetic verification at 48e796ad3672d629050fba765e73baef68dc9e8c.

On RTX 4090 Laptop (621.14) and WARP I read every lane of ten dispatches using the production shader lowering. All 32 lanes in each dispatch matched. The original four words were 294, 263, 2066 and 2035. On an interior coordinate the independent cases held the gradients fixed, changed the LOD clamp and exercised both immediate offset endpoints (−8 and +7). The three LOD pairs returned 4762/12317, 5650/13205 and 3745/11300 on both adapters. No debug-layer errors in the measured dispatches. Parent 63bcca43c6a00a758510398fa43096ce7e4f7df0 declined this opcode during lowering at guest offset 104.

Reproducible fixture. GTA-VI-3/EIGHT-20261127. AI-assisted with Codex.

**@⁠passerbyyhx** on GitHub · 2026-11-27 18:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/3493#issuecomment-7226033582) Windows synthetic verification at `48e796ad3672d629050fba765e73baef68dc9e8c`. On RTX 4090 Laptop (621.14) and WARP I read every lane of ten dispatches using the production shader lowering. All 32 lanes in each dispatch matched. The original four words were 294, 263, 2066 and 2035. On an interior coordinate the independent cases held the gradients fixed, changed the LOD clamp and exercised both immediate offset endpoints (−8 and +7). The three LOD pairs returned 4762/12317, 5650/13205 and 3745/11300 on both adapters. No debug-layer errors in the measured dispatches. Parent `63bcca43c6a00a758510398fa43096ce7e4f7df0` declined this opcode during lowering at guest offset 104. [Reproducible fixture](https://github.com/passerbyyhx/VIctory/commit/86a23c08e44c6da0e722e74d2018a8672a54d6d5). GTA-VI-3/EIGHT-20261127. AI-assisted with Codex.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3493/head:github-bot/gh-3493'
git switch 'github-bot/gh-3493'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3493'
git switch 'github-bot/gh-3493'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3493'
git switch 'github-bot/gh-3493'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3493'
git switch 'main'
git merge --squash 'github-bot/gh-3493'
git switch 'main'
git merge --ff-only 'github-bot/gh-3493'
git switch 'main'
git merge 'github-bot/gh-3493'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3493
No description provided.