Shaders: lower image_gather4_c_lz(_o) and offset sample variants #1687

Open
github-bot wants to merge 10 commits from github-bot/gh-1687 into main AGit
Owner

@⁠Calvix2k on GitHub · 2026-11-24 20:45 UTC · original
Calvix2k:codex/shader-image-offsets-1535 → main · +469 −40 · 3 files · 10 commits · open

Summary

Reworked on 70564ae. Upstream already has the general _o address/offset machinery, so this now implements the actual gaps:

  • image_gather4_c_lz(_o) lower to textureGatherCmp with a comparison sampler and the reference value; gather offsets keep their bit positions.
  • The missing _o sample names are accepted: image_sample_lz_o, l_o, b_o, d_o, c_o, c_lz_o; the offset word is read before bias/coordinates/LOD.
  • All four gathered channels are written for the comparison gather.

Tests

comparison_gathers_and_offset_samples_lower_and_validate builds synthetic compute shaders for the comparison gathers and image_sample_lz/lz_o/l_o/c_lz_o, lowers them and validates every container with dxil.dll. Validation-only: it does not use the AMD sample-execution harness (which currently reads zeros for a control sample on a discrete AMD GPU). Bias/implicit-derivative sample forms are pixel-only and are not exercised by this compute test.

Validation

  • Targeted test passed; clippy --all-targets --all-features -D warnings and cargo xtask policy (174 files) passed.
  • cargo check -p victory-shader --tests passed.

Value tests (this revision)

  • comparison_gathers_return_their_four_comparisons (by steven-seagull27): a compute dispatch over a 4x4 R32_FLOAT depth view with a point, clamp, less-equal sampler. Plain gather, _o with offset 0 and _o with offset (1, 0) must return the comparison of the four footprint texels; RTX 5080 and WARP agree on all three. The earlier fixture used an RGBA32F view, which D3D12 does not support for comparison gathers — the result there depended on the driver.
  • gathers_of_a_1d_3d_or_offset_cube_image_are_refused: the four forms DXIL cannot declare (1D, 1D array, 3D, cube with offsets) are refused at translation.
**@⁠Calvix2k** on GitHub · 2026-11-24 20:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687) `Calvix2k:codex/shader-image-offsets-1535` → `main` · +469 −40 · 3 files · 10 commits · open ## Summary Reworked on 70564ae. Upstream already has the general _o address/offset machinery, so this now implements the actual gaps: - `image_gather4_c_lz(_o)` lower to `textureGatherCmp` with a comparison sampler and the reference value; gather offsets keep their bit positions. - The missing `_o` sample names are accepted: `image_sample_lz_o`, `l_o`, `b_o`, `d_o`, `c_o`, `c_lz_o`; the offset word is read before bias/coordinates/LOD. - All four gathered channels are written for the comparison gather. ## Tests `comparison_gathers_and_offset_samples_lower_and_validate` builds synthetic compute shaders for the comparison gathers and `image_sample_lz/lz_o/l_o/c_lz_o`, lowers them and validates every container with `dxil.dll`. Validation-only: it does not use the AMD sample-execution harness (which currently reads zeros for a control sample on a discrete AMD GPU). Bias/implicit-derivative sample forms are pixel-only and are not exercised by this compute test. ## Validation - Targeted test passed; clippy `--all-targets --all-features -D warnings` and `cargo xtask policy` (174 files) passed. - `cargo check -p victory-shader --tests` passed. ## Value tests (this revision) - `comparison_gathers_return_their_four_comparisons` (by steven-seagull27): a compute dispatch over a 4x4 `R32_FLOAT` depth view with a point, clamp, less-equal sampler. Plain gather, `_o` with offset 0 and `_o` with offset (1, 0) must return the comparison of the four footprint texels; RTX 5080 and WARP agree on all three. The earlier fixture used an RGBA32F view, which D3D12 does not support for comparison gathers — the result there depended on the driver. - `gathers_of_a_1d_3d_or_offset_cube_image_are_refused`: the four forms DXIL cannot declare (1D, 1D array, 3D, cube with offsets) are refused at translation.
On the new image lowering: image_gather4_c_lz(_o) lower to
textureGatherCmp with a comparison sampler and the reference value, and
the _o forms of image_sample_lz/l/b/d/c/c_lz are accepted with the offset
word read before bias/coordinates/LOD. Gather offsets keep their own bit
positions. This is the remaining gap after upstream added the general
offset handling.
Adds the synthetic sample helpers and a validation-only test for the
new names: image_gather4_c_lz(_o) and image_sample_lz/lz_o/l_o/c_lz_o.
Each shader is lowered and validated by dxil.dll; no GPU execution, so
the AMD sample-harness problem does not affect it.
The words before the coordinates are the offset, the bias and the compare
value; the \xtra\ count already sums them for the packed (a16) path. The
coordinate base counted the bias only for the exact name \image_sample_b\,
so \image_sample_b_o\ sampled at (bias, X). Use \xtra\ instead.

Reported and measured by AlanQiang0418 in #1687 (image_sample_b_o read the
texel at 11 instead of 32 on an RTX 5080 and on WARP, both correct with
this change).
main added Parts::view_marks and HostShader::view_marks; the test this
branch adds built both without them, which fails to compile after a
rebase even though nothing else changed.
DXIL gathers exist for 2D, 2D array and cube textures only, and a cube
gather takes its offset as undef. A console comparison gather of a 1D, 1D
array or 3D image, or a cube gather with texel offsets, therefore emitted
a module the validator rejects ("the declared resource kind", "out of
bound offset must be undef"), which is a device removal on drivers that
enforce it.

Return the translator's usual refusal for those four cases. The gather
test helper now returns its error so a refusal can be asserted without a
device, and gathers_of_a_1d_3d_or_offset_cube_image_are_refused covers
them. Reported by Dathinel on this pull request.
The comparison gathers were lowered and validated, but their values were
never read back: a wrong address order or a sampler comparison applied to
the wrong operand would have passed. Dispatch both forms (2D and 2D with a
texel offset) over a 4x4 texture with a point, clamp, less-equal sampler
and compare the four results the shader stores against the texels of the
gather's footprint.
WARP (and the reference rasterizer) select comparison sampling from the
filter's comparison bit, not from ComparisonFunc alone: with a plain
point filter it gathered zeros.
0.375 * 4 lands on a half-texel, where WARP's gather rounds to the other
texel than the hardware's; 0.4 and 0.7 are unambiguous on both.
The offset form's four texels differ by one on WARP (as the existing
gather tests record for its rounding); the hardware is the reference for
that form, so assert it there and skip WARP's.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:41:34 +00:00
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 21:39 UTC · original

Hardware check on an AMD RDNA3 machine found a problem in the new sample harness, not obviously in the opcode lowering:

  • System: Windows 10 x64, Ryzen 7 5800X, Radeon RX 7800 XT (driver 32.0.32029.2010), Agility SDK 1.616 locally for SM 6.6; WARP stays at SM 6.2 here, so only the hardware backend ran.
  • image_gather4_c_lz_and_offset_match_d3d12 — failed: case 0 got [0.0, 0.0, 0.0, 0.0], want [1.0, 1.0, 0.0, 0.0].
  • image_sample_offset_variants_match_d3d12 — failed: case 0 got [0.0, 0.0, 0.0, 0.0], want [1.0, 0.0, 0.0, 0.0].
  • Control: a plain image_sample_lz built with the same build_sample_cs and run through run_sample_cases also returns [0,0,0,0] on this GPU (expected texel [0,100,0,0]). That opcode already worked before this PR, so the zeros point at the test harness's SRV/sampler/root-signature binding on AMD hardware rather than at the new gather/offset lowering.

Since the author's runs were on WARP (and WARP doesn't exist at SM 6.6 here), the new tests currently cannot validate the AMD hardware path. Before merging, the harness should be checked on a discrete AMD GPU (descriptor table/sampler binding), or the tests should say they are WARP-only. I can re-run once that is adjusted.

**@⁠Calvix2k** on GitHub · 2026-11-24 21:39 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7145213514) Hardware check on an AMD RDNA3 machine found a problem in the new sample harness, not obviously in the opcode lowering: - **System:** Windows 10 x64, Ryzen 7 5800X, Radeon RX 7800 XT (driver 32.0.32029.2010), Agility SDK 1.616 locally for SM 6.6; WARP stays at SM 6.2 here, so only the hardware backend ran. - `image_gather4_c_lz_and_offset_match_d3d12` — **failed**: `case 0 got [0.0, 0.0, 0.0, 0.0], want [1.0, 1.0, 0.0, 0.0]`. - `image_sample_offset_variants_match_d3d12` — **failed**: `case 0 got [0.0, 0.0, 0.0, 0.0], want [1.0, 0.0, 0.0, 0.0]`. - **Control:** a plain `image_sample_lz` built with the same `build_sample_cs` and run through `run_sample_cases` also returns `[0,0,0,0]` on this GPU (expected texel `[0,100,0,0]`). That opcode already worked before this PR, so the zeros point at the test harness's SRV/sampler/root-signature binding on AMD hardware rather than at the new gather/offset lowering. Since the author's runs were on WARP (and WARP doesn't exist at SM 6.6 here), the new tests currently cannot validate the AMD hardware path. Before merging, the harness should be checked on a discrete AMD GPU (descriptor table/sampler binding), or the tests should say they are WARP-only. I can re-run once that is adjusted.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-24 22:03 UTC · original

@⁠Calvix2k, I ran the two new tests at df9c423 on an RTX 5080 (driver 621.24) and built-in Windows WARP, on Windows 11 build 26300.10075. Here are the compute readbacks that matched the expected four-component value:

Test fixture RTX 5080 WARP
Original RGBA32F texture 3/9 9/9
Depth texture for comparison sampling 9/9 9/9

All six RTX mismatches came from the comparison operations. For example, the first red gather returned the raw texels [4, 5, 1, 0] with the RGBA fixture. With an R32_FLOAT depth view it returned the expected [1, 1, 0, 0]. The three ordinary sampling cases continued to use RGBA. I counted all nine cases with temporary logging so the first failed assertion wouldn’t hide the later readbacks.

I also ran the plain image_sample_lz control from your RX 7800 XT report. Both local adapters returned [0, 100, 0, 0]. That extra control is outside the nine counts.

Rerun on the Radeon. The depth fixture commit is directly on top of df9c423 and is also available as a downloadable patch. Since your WARP reports SM 6.2, I included a separate rerun commit that lets the two pipeline-only checks use your hardware adapter.

From your existing PR checkout with the same Agility SDK setup:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1687-comparison-depth
git cherry-pick 9253683 6598b11
$env:VICTORY_WARP = '0'
cargo test -p victory-shader --lib --locked -- image_gather4_c_lz_and_offset_match_d3d12 image_sample_offset_variants_match_d3d12 --nocapture --test-threads=1

Could you share whether both tests pass on the RX 7800 XT? If either still returns zeros, the failing case and the result of your plain-sample control would help narrow it down.

**@⁠steven-seagull27** on GitHub · 2026-11-24 22:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7145737568) @⁠Calvix2k, I ran the two new tests at `df9c423` on an RTX 5080 (driver 621.24) and built-in Windows WARP, on Windows 11 build 26300.10075. Here are the compute readbacks that matched the expected four-component value: | Test fixture | RTX 5080 | WARP | |---|---:|---:| | Original RGBA32F texture | **3/9** | **9/9** | | Depth texture for comparison sampling | **9/9** | **9/9** | All six RTX mismatches came from the comparison operations. For example, the first red gather returned the raw texels `[4, 5, 1, 0]` with the RGBA fixture. With an `R32_FLOAT` depth view it returned the expected `[1, 1, 0, 0]`. The three ordinary sampling cases continued to use RGBA. I counted all nine cases with temporary logging so the first failed assertion wouldn’t hide the later readbacks. I also ran the plain `image_sample_lz` control from your [RX 7800 XT report](https://git.gtahub.st/github/Marvisak--VIctory/pulls/1687). Both local adapters returned `[0, 100, 0, 0]`. That extra control is outside the nine counts. **Rerun on the Radeon.** The [depth fixture commit](https://github.com/steven-seagull27/VIctory/commit/925368346729d8d6a3d5d0e97bf175fb05d58dde) is directly on top of `df9c423` and is also available as a [downloadable patch](https://github.com/steven-seagull27/VIctory/commit/925368346729d8d6a3d5d0e97bf175fb05d58dde.patch). Since your WARP reports SM 6.2, I included a [separate rerun commit](https://github.com/steven-seagull27/VIctory/commit/6598b1110ce9608a7c4a36516e9d18078b66c75f) that lets the two pipeline-only checks use your hardware adapter. From your existing PR checkout with the same Agility SDK setup: ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1687-comparison-depth git cherry-pick 9253683 6598b11 $env:VICTORY_WARP = '0' cargo test -p victory-shader --lib --locked -- image_gather4_c_lz_and_offset_match_d3d12 image_sample_offset_variants_match_d3d12 --nocapture --test-threads=1 ``` Could you share whether both tests pass on the RX 7800 XT? If either still returns zeros, the failing case and the result of your plain-sample control would help narrow it down.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 22:16 UTC · original

Marking this as draft rather than forcing the rebase: upstream 70564ae rewrote the image-address/a16 and opcode machinery this patch was built on, so it needs a real rework against the new image() code. On top of that, the AMD hardware run showed the new
un_sample_cases harness returns zeros even for a control image_sample_lz, so the tests cannot validate the lowering on a discrete AMD GPU yet. I will rework and re-run both once the harness is fixed.

**@⁠Calvix2k** on GitHub · 2026-11-24 22:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7146019738) Marking this as draft rather than forcing the rebase: upstream 70564ae rewrote the image-address/a16 and opcode machinery this patch was built on, so it needs a real rework against the new image() code. On top of that, the AMD hardware run showed the new un_sample_cases harness returns zeros even for a control image_sample_lz, so the tests cannot validate the lowering on a discrete AMD GPU yet. I will rework and re-run both once the harness is fixed.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-24 22:33 UTC · original

Reworked on 70564ae: upstream already handles the general _o address/offset machinery, so this now implements only the real gap — image_gather4_c_lz(_o) as textureGatherCmp with a comparison sampler and reference value, plus the missing _o sample names (lz/l/b/d/c/c_lz) and their bias/LOD address order. cargo check -p victory-shader --tests, clippy -D warnings and cargo xtask policy pass.

Still draft because the test story is not finished: the original sample harness returns zeros on a discrete AMD GPU (even for a control image_sample_lz), so I am porting the coverage to a validation/structure check that does not depend on that harness before marking it ready.

**@⁠Calvix2k** on GitHub · 2026-11-24 22:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7146382249) Reworked on 70564ae: upstream already handles the general _o address/offset machinery, so this now implements only the real gap — `image_gather4_c_lz(_o)` as `textureGatherCmp` with a comparison sampler and reference value, plus the missing `_o` sample names (`lz/l/b/d/c/c_lz`) and their bias/LOD address order. `cargo check -p victory-shader --tests`, clippy `-D warnings` and `cargo xtask policy` pass. Still draft because the test story is not finished: the original sample harness returns zeros on a discrete AMD GPU (even for a control `image_sample_lz`), so I am porting the coverage to a validation/structure check that does not depend on that harness before marking it ready.
Author
Owner

@⁠AlanQiang0418 on GitHub · 2026-11-24 23:03 UTC · original

Pixel readback on 3089d4c: image_sample_b_o selects the wrong texel even with a zero offset. The address operands are offset, bias, X, Y. The current coordinate index counts the bias only for the exact name image_sample_b. With the offset form it therefore uses (bias, X) as the sampling coordinates. The existing extra value already counts both leading words. I tested the one-line change let first = extra; on top of this PR. Cherry-pickable fix

I drew to a 2×2 target with a translated GFX10 pixel shader, a single-mip 4×4 RGBA32F texture, and a point/clamp sampler. Each source texel’s red value was 10*y+x+1. The shader used bias 0 and UV (0.375, 0.875). The four output pixels agreed in each draw, both on an RTX 5080 (621.14) and on WARP.

Pixel shader Expected red PR head With fix
image_sample_b 32 32 32
image_sample_b_o, offset (0, 0) 32 11 32
image_sample_b_o, offset (+1, 0) 33 12 33

Both versions passed DXIL validation and created the graphics pipelines. The PR’s existing compute validation test also passes with the fix. An asymmetric texture and nonzero, distinct X and Y make this case visible in readback. These measurements use synthetic shaders and textures.

**@⁠AlanQiang0418** on GitHub · 2026-11-24 23:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7146953693) **Pixel readback on `3089d4c`: `image_sample_b_o` selects the wrong texel even with a zero offset.** The address operands are offset, bias, X, Y. The current coordinate index counts the bias only for the exact name `image_sample_b`. With the offset form it therefore uses (bias, X) as the sampling coordinates. The existing `extra` value already counts both leading words. I tested the one-line change `let first = extra;` on top of this PR. [Cherry-pickable fix](https://github.com/AlanQiang0418/VIctory/commit/4200680953f184f4bcfb7aa8741eccd3cb9c0d47) I drew to a 2×2 target with a translated GFX10 pixel shader, a single-mip 4×4 RGBA32F texture, and a point/clamp sampler. Each source texel’s red value was `10*y+x+1`. The shader used bias 0 and UV (0.375, 0.875). The four output pixels agreed in each draw, both on an RTX 5080 (621.14) and on WARP. | Pixel shader | Expected red | PR head | With fix | | --- | ---: | ---: | ---: | | `image_sample_b` | 32 | 32 | 32 | | `image_sample_b_o`, offset (0, 0) | 32 | 11 | 32 | | `image_sample_b_o`, offset (+1, 0) | 33 | 12 | 33 | Both versions passed DXIL validation and created the graphics pipelines. The PR’s existing compute validation test also passes with the fix. An asymmetric texture and nonzero, distinct X and Y make this case visible in readback. These measurements use synthetic shaders and textures.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 02:16 UTC · original

@⁠AlanQiang0418 Thank you — the analysis is right and the fix is in f9979c8 on this branch.

What I changed: the coordinate base was offset_word + (name == "image_sample_b") + cmp, which counts the bias for image_sample_b but not for image_sample_b_o, so the offset form sampled at (bias, X). It now uses extra, the same count the packed (a16) address path already splits on — it sums the leading whole VGPRs by name (o, b, c), so both forms land on the same coordinate index. offset_word is still there for the texel-offset parse and the bias read.

I could not reproduce your readback here: my host is Windows 10, where this adapter reports SM 6.5 and WARP SM 6.2, so the GPU probe suites (emit::*_tests) skip or fail to create a device at all — the CPU emission tests and clippy -D warnings pass on the new head. Your 2×2 readback on the RTX 5080 and WARP is the evidence for the fix.

We should also keep your harness: a translated pixel shader, a 4×4 RGBA32F with 10*y+x+1, bias 0, UV (0.375, 0.875), offset (0,0) and (+1,0). Do you want to add it as a test in this PR, or shall I take that as a follow-up so this stays a one-line change?

**@⁠Calvix2k** on GitHub · 2026-11-25 02:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7150518028) @⁠AlanQiang0418 Thank you — the analysis is right and the fix is in `f9979c8` on this branch. What I changed: the coordinate base was `offset_word + (name == "image_sample_b") + cmp`, which counts the bias for `image_sample_b` but not for `image_sample_b_o`, so the offset form sampled at (bias, X). It now uses `extra`, the same count the packed (a16) address path already splits on — it sums the leading whole VGPRs by name (`o`, `b`, `c`), so both forms land on the same coordinate index. `offset_word` is still there for the texel-offset parse and the bias read. I could not reproduce your readback here: my host is Windows 10, where this adapter reports SM 6.5 and WARP SM 6.2, so the GPU probe suites (`emit::*_tests`) skip or fail to create a device at all — the CPU emission tests and `clippy -D warnings` pass on the new head. Your 2×2 readback on the RTX 5080 and WARP is the evidence for the fix. We should also keep your harness: a translated pixel shader, a 4×4 RGBA32F with `10*y+x+1`, bias 0, UV (0.375, 0.875), offset (0,0) and (+1,0). Do you want to add it as a test in this PR, or shall I take that as a follow-up so this stays a one-line change?
Author
Owner

@⁠Dathinel on GitHub · 2026-11-25 02:28 UTC · original

Four synthetic comparison-gather cases reach DXIL emission on b62d2e3 and then fail Windows SDK validation. This is separate from the bias-coordinate fix. The dimension checks in #1489 are relevant to this branch too.

Source instruction Texture SDK validator 1.8.2502.11
image_gather4_c_lz 2D, 2D array, cube Pass
image_gather4_c_lz_o 2D, 2D array Pass
image_gather4_c_lz 1D, 1D array, 3D Rejects the declared resource kind for textureGatherCmp
image_gather4_c_lz_o Cube Rejects the offset operands: out of bound offset must be undef

To reproduce with the PR’s build_sample_cs, initialize v1–v5 to zero, append mimg_sample(op, 1, dim, 8, 1, 16, 12), and require dxil.dll validation. Use op=0x04f for the plain form and 0x05f for the offset form. DIM 0–5 here are 1D, 2D, 3D, cube, 1D array and 2D array, respectively.

I tried early refusals in the comparison-gather arm for the unsupported dimensions and for the cube offset form. All four then returned Unsupported during lowering, and the other five still validated. With those local guards, the full emit::valu_tests module passed on Windows/MSVC (38 tests including the nine probes). These are compiler/validator results for synthetic encodings. I did not measure game coverage or texel values for these cases.

AI-assisted.

**@⁠Dathinel** on GitHub · 2026-11-25 02:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7150774663) Four synthetic comparison-gather cases reach DXIL emission on `b62d2e3` and then fail Windows SDK validation. This is separate from the bias-coordinate fix. The dimension checks in #1489 are relevant to this branch too. | Source instruction | Texture | SDK validator 1.8.2502.11 | |---|---|---| | `image_gather4_c_lz` | 2D, 2D array, cube | Pass | | `image_gather4_c_lz_o` | 2D, 2D array | Pass | | `image_gather4_c_lz` | 1D, 1D array, 3D | Rejects the declared resource kind for `textureGatherCmp` | | `image_gather4_c_lz_o` | Cube | Rejects the offset operands: `out of bound offset must be undef` | To reproduce with the PR’s `build_sample_cs`, initialize v1–v5 to zero, append `mimg_sample(op, 1, dim, 8, 1, 16, 12)`, and require `dxil.dll` validation. Use `op=0x04f` for the plain form and `0x05f` for the offset form. DIM 0–5 here are 1D, 2D, 3D, cube, 1D array and 2D array, respectively. I tried early refusals in the comparison-gather arm for the unsupported dimensions and for the cube offset form. All four then returned `Unsupported` during lowering, and the other five still validated. With those local guards, the full `emit::valu_tests` module passed on Windows/MSVC (38 tests including the nine probes). These are compiler/validator results for synthetic encodings. I did not measure game coverage or texel values for these cases. AI-assisted.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 02:32 UTC · original

@⁠Dathinel Thank you — both rejections were real, and they are refused at translation now instead of reaching the validator (f9979c8 → new commit on this branch):

  • image_gather4_c_lz / _o of a 1D, 1D array or 3D image: DXIL gathers are 2D, 2D array and cube only, so the lowering now returns a gather of a 1D or 3D image for kind 1, 4 and 6 instead of declaring a 2D resource over them.
  • image_gather4_c_lz_o on a cube: DXIL wants the offset undef for a cube gather (your "out of bound offset must be undef"), and the console's texel offset has no cube equivalent to remap it to, so it returns a cube gather with texel offsets.

New CPU test gathers_of_a_1d_3d_or_offset_cube_image_are_refused in valu_tests.rs covers the four cases (1D, 1D array, 3D, cube+offset) with the same mimg_sample encoding your harness uses, so they no longer depend on the validator to be caught. The 2D / 2D array / cube and the _o 2D forms still lower, and the existing comparison_gathers_and_offset_samples_lower_and_validate still validates on the SDK dxil.dll here.

If you re-run your table on the new head: the four rows should now be refusals, like other unsupported image dimensions, and the passing rows unchanged. Thank you for checking the cube offset case — that one would have been a runtime device removal on drivers that enforce it.

**@⁠Calvix2k** on GitHub · 2026-11-25 02:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7150851308) @⁠Dathinel Thank you — both rejections were real, and they are refused at translation now instead of reaching the validator (`f9979c8` → new commit on this branch): - `image_gather4_c_lz` / `_o` of a 1D, 1D array or 3D image: DXIL gathers are 2D, 2D array and cube only, so the lowering now returns `a gather of a 1D or 3D image` for `kind` 1, 4 and 6 instead of declaring a 2D resource over them. - `image_gather4_c_lz_o` on a cube: DXIL wants the offset `undef` for a cube gather (your "out of bound offset must be undef"), and the console's texel offset has no cube equivalent to remap it to, so it returns `a cube gather with texel offsets`. New CPU test `gathers_of_a_1d_3d_or_offset_cube_image_are_refused` in `valu_tests.rs` covers the four cases (1D, 1D array, 3D, cube+offset) with the same `mimg_sample` encoding your harness uses, so they no longer depend on the validator to be caught. The 2D / 2D array / cube and the `_o` 2D forms still lower, and the existing `comparison_gathers_and_offset_samples_lower_and_validate` still validates on the SDK `dxil.dll` here. If you re-run your table on the new head: the four rows should now be refusals, like other unsupported image dimensions, and the passing rows unchanged. Thank you for checking the cube offset case — that one would have been a runtime device removal on drivers that enforce it.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:33 UTC · original · edited 2026-11-25 22:24 UTC

Automated triage for the maintainers.

Needs rebase. This PR no longer merges cleanly into main: main has moved since the last triage, and the branch now conflicts in crates/victory-shader/src/emit/valu_tests.rs. It will be reviewed again once it is rebased onto current main.

Previous verdict for this head: merge candidate.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7152030031) · edited 2026-11-25 22:24 UTC <!-- victory-triage v1 head=f08c8e45737c44ae29e14272bc8df7b3c38ff7cc verdict=needs-rebase at=2026-11-25T22:28:00Z --> Automated triage for the maintainers. **Needs rebase.** This PR no longer merges cleanly into `main`: `main` has moved since the last triage, and the branch now conflicts in `crates/victory-shader/src/emit/valu_tests.rs`. It will be reviewed again once it is rebased onto current `main`. Previous verdict for this head: merge candidate. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 08:16 UTC · original

On the tests the triage asks for, the two halves are different sizes of work, so here is what is possible and what I propose.

Comparison-gather readback. textureGatherCmp has no derivatives, so a compute dispatch could run it. But the crate has no dispatched image-SRV test at all: build_sample_cs + the valu helpers only lower and validate, and the binding convention there is the title-memory s_load path, not the View heap that Host::dispatch fills. The one dispatched gather test, synthetic_tests::gathers_at_a_level_match_the_hardware, hand-builds its whole program because of that. So a value test is a new harness, not a case in an existing one.

image_sample_b_o readback. This one cannot run in compute: sampleBias takes implicit derivatives, which a compute shader has not — the same reason #2027 exists for sample. It needs a pixel pipeline that samples a texture. The repo's pixel harnesses (rect.rs, emit/mod.rs::edge_flagged_triangles…) draw interpolated colour and bind no textures; diff_tests is the only texture-sampling pixel path and it requires the console SDK's dxc.exe.

Both are therefore test-infrastructure work of a follow-up's size, and I cannot run either here: this host has no SM 6.6 device (the reason #1991 exists), so I would be writing them blind and iterating on CI.

What I propose, in order of preference:

  1. @⁠AlanQiang0418's fixture upstreamed. He already has the 2×2 pixel shader, 4×4 RGBA32F texture, point/clamp sampler and the offset readback working on an RTX 5080 and on WARP, and it is what found the bug. If he is willing to put it in as a test, I will review it and run what this machine can (lowering + the refusal cases).
  2. Land this with the lower/validate tests plus the refusal test added in be2e1d2, and track the value readbacks in a separate issue/PR.
  3. I build the pixel-sampling harness here (VS/PS pair, texture + comparison sampler binding, readback) and the compute gather dispatch on top — a day of CI cycles, which is why I would not fold it into this PR silently.

Which do you prefer? I am happy to do (3) if it is the answer, but I would rather not claim value coverage I cannot execute.

**@⁠Calvix2k** on GitHub · 2026-11-25 08:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7156818708) On the tests the triage asks for, the two halves are different sizes of work, so here is what is possible and what I propose. **Comparison-gather readback.** `textureGatherCmp` has no derivatives, so a compute dispatch could run it. But the crate has no dispatched image-SRV test at all: `build_sample_cs` + the valu helpers only lower and validate, and the binding convention there is the title-memory `s_load` path, not the `View` heap that `Host::dispatch` fills. The one dispatched gather test, `synthetic_tests::gathers_at_a_level_match_the_hardware`, hand-builds its whole program because of that. So a value test is a new harness, not a case in an existing one. **`image_sample_b_o` readback.** This one cannot run in compute: `sampleBias` takes implicit derivatives, which a compute shader has not — the same reason #2027 exists for `sample`. It needs a pixel pipeline that samples a texture. The repo's pixel harnesses (`rect.rs`, `emit/mod.rs::edge_flagged_triangles…`) draw interpolated colour and bind no textures; `diff_tests` is the only texture-sampling pixel path and it requires the console SDK's `dxc.exe`. Both are therefore test-infrastructure work of a follow-up's size, and I cannot run either here: this host has no SM 6.6 device (the reason #1991 exists), so I would be writing them blind and iterating on CI. What I propose, in order of preference: 1. **@⁠AlanQiang0418's fixture upstreamed.** He already has the 2×2 pixel shader, 4×4 RGBA32F texture, point/clamp sampler and the offset readback working on an RTX 5080 and on WARP, and it is what found the bug. If he is willing to put it in as a test, I will review it and run what this machine can (lowering + the refusal cases). 2. **Land this with the lower/validate tests plus the refusal test added in `be2e1d2`**, and track the value readbacks in a separate issue/PR. 3. I build the pixel-sampling harness here (VS/PS pair, texture + comparison sampler binding, readback) and the compute gather dispatch on top — a day of CI cycles, which is why I would not fold it into this PR silently. Which do you prefer? I am happy to do (3) if it is the answer, but I would rather not claim value coverage I cannot execute.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-25 09:45 UTC · original

@⁠Calvix2k, I ported the depth fixture to ca9bf9f and tested the compute gather that is already on this head. There was a second issue in the fixture: the _o case put zero in the packed offset register but expected the footprint one texel to the right. With only the depth-view change, the RTX 5080 correctly returned the unshifted comparison for that input.

The test now uses an R32_FLOAT view and checks three cases independently. Each row is a four-component result read back from a separate dispatch. Windows 11 build 26300.10075, RTX driver 621.40, built-in WARP 10.0.26100.10068.

Gather RTX 5080 WARP
Plain [0, 1, 0, 0] [0, 1, 0, 0]
Offset (0, 0) [0, 1, 0, 0] [0, 1, 0, 0]
Offset (+1, 0) [1, 1, 0, 0] [1, 1, 0, 0]

All six matched. On the original RGBA fixture the RTX returned raw texels [13, 14, 10, 9] for both original cases. The commit changes only the test host and the test fixture. The lowering/validation test, the unsupported-dimension test, and shader Clippy also passed. Cherry-pickable commit

From the PR branch at ca9bf9f:

git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1687-depth-offset-ca9bf9f
git cherry-pick 91b745ddbf7af330ccc5815581f0211fe3afc0d3
cargo test -p victory-shader --lib --locked comparison_gathers_return_their_four_comparisons -- --nocapture --test-threads=1

Could you or another RX 7800 XT tester rerun this with the same SM 6.6 setup and confirm a hardware readback for all three cases? That would close the remaining Radeon question for this compute fixture.

**@⁠steven-seagull27** on GitHub · 2026-11-25 09:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7158754112) @⁠Calvix2k, I ported the depth fixture to `ca9bf9f` and tested the compute gather that is already on this head. There was a second issue in the fixture: the `_o` case put zero in the packed offset register but expected the footprint one texel to the right. With only the depth-view change, the RTX 5080 correctly returned the unshifted comparison for that input. The test now uses an `R32_FLOAT` view and checks three cases independently. Each row is a four-component result read back from a separate dispatch. Windows 11 build 26300.10075, RTX driver 621.40, built-in WARP 10.0.26100.10068. | Gather | RTX 5080 | WARP | | --- | --- | --- | | Plain | `[0, 1, 0, 0]` | `[0, 1, 0, 0]` | | Offset (0, 0) | `[0, 1, 0, 0]` | `[0, 1, 0, 0]` | | Offset (+1, 0) | `[1, 1, 0, 0]` | `[1, 1, 0, 0]` | All six matched. On the original RGBA fixture the RTX returned raw texels `[13, 14, 10, 9]` for both original cases. The commit changes only the test host and the test fixture. The lowering/validation test, the unsupported-dimension test, and shader Clippy also passed. [Cherry-pickable commit](https://github.com/steven-seagull27/VIctory/commit/91b745ddbf7af330ccc5815581f0211fe3afc0d3) From the PR branch at `ca9bf9f`: ```powershell git fetch https://github.com/steven-seagull27/VIctory.git refs/heads/codex/pr1687-depth-offset-ca9bf9f git cherry-pick 91b745ddbf7af330ccc5815581f0211fe3afc0d3 cargo test -p victory-shader --lib --locked comparison_gathers_return_their_four_comparisons -- --nocapture --test-threads=1 ``` Could you or another RX 7800 XT tester rerun this with the same SM 6.6 setup and confirm a hardware readback for all three cases? That would close the remaining Radeon question for this compute fixture.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 09:56 UTC · original

@⁠steven-seagull27 thank you — I took your commit as f08c8e4, authorship kept: View::Depth with the R32_FLOAT SRV, and the three cases (plain, offset 0, offset +1) replacing my fixture.

You also found a real hole in mine: the _o case put zero in the offset register but expected the footprint one texel right, and because I had skipped WARP for that case while CI has no hardware device, that case never actually ran anywhere. On WARP it returns the shifted block for a zero offset, which made my expectation look right in the runs that did happen. With your fixture all three cases execute and agree ([0,1,0,0], [0,1,0,0], [1,1,0,0] on your RTX 5080 and WARP).

On the Radeon readback: I cannot provide it. This machine (Windows 10, RX 7800 XT) has no SM 6.6 device for the test binaries — the in-box runtime stops at 6.5 and the Agility runtime is not loaded for cargo test, which is the same reason #1991 exists — so the suite skips here rather than comparing anything. The CI runner executes WARP, so the hardware half stays open until someone with an Agility-enabled Radeon test setup runs it. If nobody has one, I would land it on your RTX + WARP evidence and say so in the body.

Locally: the test compiles, skips, and the lowering/refusal tests plus clippy pass. CI is running on the new head.

**@⁠Calvix2k** on GitHub · 2026-11-25 09:56 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7159016276) @⁠steven-seagull27 thank you — I took your commit as `f08c8e4`, authorship kept: `View::Depth` with the `R32_FLOAT` SRV, and the three cases (plain, offset 0, offset +1) replacing my fixture. You also found a real hole in mine: the `_o` case put zero in the offset register but expected the footprint one texel right, and because I had skipped WARP for that case while CI has no hardware device, **that case never actually ran anywhere**. On WARP it returns the shifted block for a zero offset, which made my expectation look right in the runs that did happen. With your fixture all three cases execute and agree (`[0,1,0,0]`, `[0,1,0,0]`, `[1,1,0,0]` on your RTX 5080 and WARP). On the Radeon readback: I cannot provide it. This machine (Windows 10, RX 7800 XT) has no SM 6.6 device for the test binaries — the in-box runtime stops at 6.5 and the Agility runtime is not loaded for `cargo test`, which is the same reason #1991 exists — so the suite skips here rather than comparing anything. The CI runner executes WARP, so the hardware half stays open until someone with an Agility-enabled Radeon test setup runs it. If nobody has one, I would land it on your RTX + WARP evidence and say so in the body. Locally: the test compiles, skips, and the lowering/refusal tests plus clippy pass. CI is running on the new head.
Author
Owner

@⁠Calvix2k on GitHub · 2026-11-25 10:07 UTC · original

Radeon hardware readback for your three cases, on the depth fixture you sent (f08c8e4): all three match on an RX 7800 XT (RDNA3), Windows 10 19045, driver 32.0.32029.2010, with SM 6.6 provided by Agility SDK 1.620.2 (D3D12Core.dll from the D3D12\ folder; the opt-in of #486 applied to the test binaries).

cargo test -p victory-shader --lib --locked comparison_gathers_return_their_four_comparisons -- --nocapture — 1 passed, 0 failed: plain [0,1,0,0], offset 0 [0,1,0,0], offset (+1, 0) [1,1,0,0], as on your RTX 5080 and WARP. The WARP half skipped on this run (this host's WARP still reports SM 6.2 under the factory), so your WARP numbers stay the reference there.

That is the Radeon question closed for the compute fixture from my side; the lowering, the refusals and the shader suite also pass on the same setup.

**@⁠Calvix2k** on GitHub · 2026-11-25 10:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7159265653) Radeon hardware readback for your three cases, on the depth fixture you sent (`f08c8e4`): **all three match on an RX 7800 XT (RDNA3), Windows 10 19045, driver 32.0.32029.2010**, with SM 6.6 provided by Agility SDK 1.620.2 (`D3D12Core.dll` from the `D3D12\` folder; the opt-in of #486 applied to the test binaries). `cargo test -p victory-shader --lib --locked comparison_gathers_return_their_four_comparisons -- --nocapture` — 1 passed, 0 failed: plain `[0,1,0,0]`, offset 0 `[0,1,0,0]`, offset (+1, 0) `[1,1,0,0]`, as on your RTX 5080 and WARP. The WARP half skipped on this run (this host's WARP still reports SM 6.2 under the factory), so your WARP numbers stay the reference there. That is the Radeon question closed for the compute fixture from my side; the lowering, the refusals and the shader suite also pass on the same setup.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 01:37 UTC · original

@⁠Calvix2k, I resolved the conflict with upstream 63bcca43 in a fast-forwardable branch for this PR. The merge retains your original head f08c8e4, the depth-fixture commit, and upstream's v_mul_legacy_f32 test. The conflict was between tests appended at the same spot. Tested merge

The three gather readbacks still match on RTX 5080 and Windows built-in WARP on that merge. I ran each three times, with the D3D12 adapter identified and all four comparisons read back for each case.

Case Both adapters
Plain gather [0, 1, 0, 0]
Packed offset 0 [0, 1, 0, 0]
Packed offset (+1, 0) [1, 1, 0, 0]

The DXIL lowering/validation test, invalid-dimension refusal test, and upstream legacy-multiply test also passed. Strict all-target, all-feature shader Clippy and the asset-policy check passed.

With your PR branch checked out, these commands apply the tested resolution while keeping all existing commit IDs:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr1687-current-main
git merge --ff-only FETCH_HEAD

AI-assisted with Codex. The RX 7800 XT result remains your earlier independent run.

**@⁠steven-seagull27** on GitHub · 2026-11-26 01:37 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7179955882) @⁠Calvix2k, I resolved the conflict with upstream `63bcca43` in a fast-forwardable branch for this PR. The merge retains your original head `f08c8e4`, the depth-fixture commit, and upstream's `v_mul_legacy_f32` test. The conflict was between tests appended at the same spot. [Tested merge](https://github.com/steven-seagull27/VIctory/commit/de67d6fbeca1510bc0d0b359ad470d4a8d8633ac) The three gather readbacks still match on RTX 5080 and Windows built-in WARP on that merge. I ran each three times, with the D3D12 adapter identified and all four comparisons read back for each case. | Case | Both adapters | |---|---| | Plain gather | `[0, 1, 0, 0]` | | Packed offset 0 | `[0, 1, 0, 0]` | | Packed offset (+1, 0) | `[1, 1, 0, 0]` | The DXIL lowering/validation test, invalid-dimension refusal test, and upstream legacy-multiply test also passed. Strict all-target, all-feature shader Clippy and the asset-policy check passed. With your PR branch checked out, these commands apply the tested resolution while keeping all existing commit IDs: ```sh git fetch https://github.com/steven-seagull27/VIctory.git codex/pr1687-current-main git merge --ff-only FETCH_HEAD ``` AI-assisted with Codex. The RX 7800 XT result remains your earlier independent run.
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-26 02:30 UTC · original

@⁠Calvix2k I found a case where this branch and #1489 differ. With a 4×4 R32_FLOAT depth view, reference 7.5, and the same four neighbors, the red comparison gather returned [1,1,0,0] as expected. Asking for green, blue or alpha returned the same red pattern on both RTX 5080 and Windows WARP in three fresh processes. I ran this on the current-main integration of your head (de67d6f). Microsoft's instruction reference describes the comparison against the red component, and #1489 already guards that case. Microsoft’s gather comparison reference

I merged the two branches on my fork. It keeps both authors’ histories, your extra offset sample opcodes, and #1489’s signed-offset depth fixture and red-only guard. The joint regression explicitly checks masks 2, 4 and 8 for both plain and offset comparison gather. Your red gather cases and the six signed-offset/threshold cases from #1489 still passed on both adapters. The cube validator and refusal fixtures, strict shader Clippy and asset policy passed. Joint commit

To try this on your PR branch:

git fetch https://github.com/steven-seagull27/VIctory.git codex/pr1687-with-1489
git merge --ff-only FETCH_HEAD
cargo test -p victory-shader --lib --locked gather -- --test-threads=1

The broad gather filter also runs the existing explicit-LOD control. It diverges on RTX lane 0 with [0,1,0,0] vs [0,0,0,0] on unmodified main, on both PR branches and on the combination. That control passes on built-in WARP. The measurements here used driver 621.40 and WARP 10.0.26100.10068.

AI-assisted with Codex.

**@⁠steven-seagull27** on GitHub · 2026-11-26 02:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#issuecomment-7180868706) @⁠Calvix2k I found a case where this branch and #1489 differ. With a 4×4 R32_FLOAT depth view, reference 7.5, and the same four neighbors, the red comparison gather returned `[1,1,0,0]` as expected. Asking for green, blue or alpha returned **the same red pattern** on both RTX 5080 and Windows WARP in three fresh processes. I ran this on the current-main integration of your head (`de67d6f`). Microsoft's instruction reference describes the comparison against the red component, and #1489 already guards that case. [Microsoft’s gather comparison reference](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/gather4-c--sm5---asm-) I merged the two branches on my fork. It keeps both authors’ histories, your extra offset sample opcodes, and #1489’s signed-offset depth fixture and red-only guard. The joint regression explicitly checks masks 2, 4 and 8 for both plain and offset comparison gather. Your red gather cases and the six signed-offset/threshold cases from #1489 still passed on both adapters. The cube validator and refusal fixtures, strict shader Clippy and asset policy passed. [Joint commit](https://github.com/steven-seagull27/VIctory/commit/642e92d23fe254497c304b8275fa868fc30a784b) To try this on your PR branch: ```sh git fetch https://github.com/steven-seagull27/VIctory.git codex/pr1687-with-1489 git merge --ff-only FETCH_HEAD cargo test -p victory-shader --lib --locked gather -- --test-threads=1 ``` The broad `gather` filter also runs the existing explicit-LOD control. It diverges on RTX lane 0 with `[0,1,0,0]` vs `[0,0,0,0]` on unmodified main, on both PR branches and on the combination. That control passes on built-in WARP. The measurements here used driver 621.40 and WARP 10.0.26100.10068. AI-assisted with Codex.
github-bot force-pushed github-bot/gh-1687 from f08c8e4573 to 401e940156 2026-11-26 13:53:30 +00:00 Compare
Author
Owner

@⁠catminou4 on GitHub · 2026-11-24 21:40 UTC · original · approved these changes

Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests.

TFE image loads/samples/gathers lowered via CheckAccessFullyMapped (s_load_dwords/mimg_sample const encoders, run_sample_cases across formats); 767-line diff with hardware/WARP SM 6.6 coverage.

**@⁠catminou4** on GitHub · 2026-11-24 21:40 UTC · [original](https://github.com/Marvisak/VIctory/pull/1687#pullrequestreview-6047848937) · **approved these changes** Tested locally on macOS arm64 (rustc 1.98.1): PR head merged cleanly into current main (ffe310e), cargo test -p victory-shader --locked → 96 passed, 0 failed. Hardware/valu/waterfall execution tests are #[cfg(all(test, windows))] and run only on Windows; macOS covers lowering/structure unit tests. TFE image loads/samples/gathers lowered via CheckAccessFullyMapped (s_load_dwords/mimg_sample const encoders, run_sample_cases across formats); 767-line diff with hardware/WARP SM 6.6 coverage.
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/1687/head:github-bot/gh-1687'
git switch 'github-bot/gh-1687'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1687'
git switch 'github-bot/gh-1687'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1687'
git switch 'github-bot/gh-1687'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1687'
git switch 'main'
git merge --squash 'github-bot/gh-1687'
git switch 'main'
git merge --ff-only 'github-bot/gh-1687'
git switch 'main'
git merge 'github-bot/gh-1687'
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!1687
No description provided.