Shaders: gathers from the first level take the console's footprint #3613

Open
kilolimaVI wants to merge 6 commits from upstream-pr/3613 into main
kilolimaVI commented 2026-11-27 21:16:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-27T21:16:06Z.


image_gather4_lz(_o) goes to DXIL textureGather with the program's coordinate, so near a texel's edge the host decides which four texels a gather takes. The console rounds u × size to 1/256 of a texel, half up, before taking floor(u × size − 0.5). Lower::gather_first already implements this rule for gathers at a level (gather_at_level), but the first-level path never used it.

Hosts differ here. At 1/1024 of a texel below an edge, the Radeon 780M rounds up like the console, while WARP stays below and takes the footprint one texel back.

Change

  • New lower/gather.rs: gather_console_coordinate moves each axis to (first + 1) / size, with first from gather_first. That is the middle of the console's footprint, half a texel from either edge, so every host takes the same four texels in any address mode or border.
  • NaN takes the footprint at 0, as on the console. Beyond ±2 (where gather_first clamps) and at infinities the coordinate is left unchanged. Cubes are left as they were.
  • lower.rs gains 15 lines (521,359 / 524,288 bytes).
  • gather_tests (from #3583) now requires the console's footprint on every host. It used to only report the boundary case.

Builds on #3583. The first four commits are #3583's; the change itself is the last commit.

Results, AMD Radeon 780M (RDNA3) + WARP, Windows 11:

d below the edge console 780M before WARP before both after
+0.25, +0.75 x x x x
−1/1024 x x x − 1 x
−1/512 (tie) x x x − 1 x
−(1/512 + 1/65536) x − 1 x − 1 x − 1 x − 1
−3/1024 x − 1 x − 1 x − 1 x − 1

256/256 pixels per case per host after the change. 5 of 5 runs, full suite (victory-shader + victory-gpu --features diagnostics) 555 passed, clippy clean.

Side note: on the 780M, a point sample (image_sample_lz) at −1/1024 stays below while a gather rounds up, so even one host resolves coordinates differently per path. NVIDIA numbers would be welcome.

Fixes #3261: under VICTORY_WARP=1, gathers_at_a_level_match_the_hardware fails one texel off on main + #2323 and passes with this PR on top (upipibi's RTX 3070 run).

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5533196328 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-27T21:16:06Z. --- `image_gather4_lz(_o)` goes to DXIL `textureGather` with the program's coordinate, so near a texel's edge the host decides which four texels a gather takes. The console rounds `u × size` to 1/256 of a texel, half up, before taking `floor(u × size − 0.5)`. `Lower::gather_first` already implements this rule for gathers at a level (`gather_at_level`), but the first-level path never used it. Hosts differ here. At 1/1024 of a texel below an edge, the Radeon 780M rounds up like the console, while WARP stays below and takes the footprint one texel back. **Change** - New `lower/gather.rs`: `gather_console_coordinate` moves each axis to `(first + 1) / size`, with `first` from `gather_first`. That is the middle of the console's footprint, half a texel from either edge, so every host takes the same four texels in any address mode or border. - NaN takes the footprint at 0, as on the console. Beyond ±2 (where `gather_first` clamps) and at infinities the coordinate is left unchanged. Cubes are left as they were. - `lower.rs` gains 15 lines (521,359 / 524,288 bytes). - `gather_tests` (from #3583) now requires the console's footprint on every host. It used to only report the boundary case. **Builds on #3583.** The first four commits are #3583's; the change itself is the last commit. **Results**, AMD Radeon 780M (RDNA3) + WARP, Windows 11: | d below the edge | console | 780M before | WARP before | both after | |---|---|---|---|---| | +0.25, +0.75 | x | x | x | x | | −1/1024 | x | x | **x − 1** | x | | −1/512 (tie) | x | x | **x − 1** | x | | −(1/512 + 1/65536) | x − 1 | x − 1 | x − 1 | x − 1 | | −3/1024 | x − 1 | x − 1 | x − 1 | x − 1 | 256/256 pixels per case per host after the change. 5 of 5 runs, full suite (`victory-shader` + `victory-gpu --features diagnostics`) 555 passed, clippy clean. Side note: on the 780M, a point sample (`image_sample_lz`) at −1/1024 stays below while a gather rounds up, so even one host resolves coordinates differently per path. NVIDIA numbers would be welcome. Fixes #3261: under `VICTORY_WARP=1`, `gathers_at_a_level_match_the_hardware` fails one texel off on main + #2323 and passes with this PR on top (upipibi's RTX 3070 run). AI-assisted (Claude).
andrewpozdnakov7-jpg commented 2026-11-27 21:55:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T21:55:44Z.


@kilolimaVI I reproduced the 16×16 case on app-local WARP, with the loaded SDK and WARP modules verified. At the two offsets closest to the texel boundary, f0191df selected the previous footprint in all 512 readbacks. bbe216c selected the expected footprint in all 512, and the other four controls matched their expected footprints.

I also checked a 13×13 texture with two wrapped tile edges and three border-mode cases. All 845 readbacks matched on both revisions with this WARP runtime. I put those two checks in a test-only commit on top of your exact head. Both strict shader Clippy configurations and the asset policy check passed. Test commit

If reusing the tests, please retain the Git author when cherry-picking or rebasing. If folding them into another commit, please add the trailer below.

Co-authored-by: andrewpozdnakov7-jpg [email protected]

<!-- greyfinch-sync:Marvisak/VIctory:comment:7228877851 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7228877851). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T21:55:44Z. --- @kilolimaVI I reproduced the 16×16 case on app-local WARP, with the loaded SDK and WARP modules verified. At the two offsets closest to the texel boundary, `f0191df` selected the previous footprint in all 512 readbacks. `bbe216c` selected the expected footprint in all 512, and the other four controls matched their expected footprints. I also checked a 13×13 texture with two wrapped tile edges and three border-mode cases. All 845 readbacks matched on both revisions with this WARP runtime. I put those two checks in a test-only commit on top of your exact head. Both strict shader Clippy configurations and the asset policy check passed. [Test commit](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/4fb5462d7aab724a415add1eb8f16e654bfdf1a8) If reusing the tests, please retain the Git author when cherry-picking or rebasing. If folding them into another commit, please add the trailer below. Co-authored-by: andrewpozdnakov7-jpg <[email protected]>
ColorMeBoom commented 2026-11-28 00:24:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ColorMeBoom on 2026-11-28T00:24:28Z.


Hardware run on AMD RDNA1, to go with the 780M and RTX 4060 runs on #3583: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head bbe216c on 63bcca4.

  • gathers_take_the_footprint_at_the_coordinate and point_samples_take_the_texel_at_the_coordinate pass on the card, including the offsets closest to the texel boundary:
    gather d -0.000977 hardware: 256 pixels, kept below 0, at x 256, neither 0
    gather d -0.001953 hardware: 256 pixels, kept below 0, at x 256, neither 0
    gather d -0.001968 hardware: 256 pixels, kept below 256, at x 0, neither 0
    point d -0.000977 hardware: 256 pixels, kept below 256, at x 0, neither 0
    
  • Full victory-shader --lib --features host: 306 passed, 0 failed, 3 ignored.

AI use: Claude Code (Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7230887645 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7230887645). Originally posted by [ColorMeBoom](https://github.com/ColorMeBoom) on 2026-11-28T00:24:28Z. --- Hardware run on AMD RDNA1, to go with the 780M and RTX 4060 runs on #3583: RX 5700 XT (Navi 10, RDNA1, driver 32.0.21045.29003, Windows 11 26200), head `bbe216c` on `63bcca4`. - `gathers_take_the_footprint_at_the_coordinate` and `point_samples_take_the_texel_at_the_coordinate` pass on the card, including the offsets closest to the texel boundary: ``` gather d -0.000977 hardware: 256 pixels, kept below 0, at x 256, neither 0 gather d -0.001953 hardware: 256 pixels, kept below 0, at x 256, neither 0 gather d -0.001968 hardware: 256 pixels, kept below 256, at x 0, neither 0 point d -0.000977 hardware: 256 pixels, kept below 256, at x 0, neither 0 ``` - Full `victory-shader --lib --features host`: 306 passed, 0 failed, 3 ignored. AI use: Claude Code (Claude Opus 5.5).
akimfomin commented 2026-11-28 01:31:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by akimfomin on 2026-11-28T01:31:33Z.


For the open question about NVIDIA near the 1/256-texel footprint boundary, I published a PortBridge Lab task pinned to bbe216c3 and invited separate native D3D12 and Proton testers with public NVIDIA results. The receipt asks for selected texels and matched offsets, with the software and physical runs separated. No new result is available yet. Participants can give their agents just that issue link, and any result will be credited here.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7231727367 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7231727367). Originally posted by [akimfomin](https://github.com/akimfomin) on 2026-11-28T01:31:33Z. --- For the open question about NVIDIA near the 1/256-texel footprint boundary, I published a [PortBridge Lab task](https://github.com/akimfomin/PortBridge/issues/148) pinned to `bbe216c3` and invited separate native D3D12 and Proton testers with public NVIDIA results. The receipt asks for selected texels and matched offsets, with the software and physical runs separated. No new result is available yet. Participants can give their agents just that issue link, and any result will be credited here.
upipibi commented 2026-11-28 04:12:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T04:12:49Z.


The NVIDIA row, as asked: RTX 3070 8 GB, driver 616.56, Windows 11, the hardware adapter and WARP in the same run. emit::gather_tests:: at #3583 head f0191df (before) and this head bbe216c (after), each 3 times with identical output. Pixels out of 256: "below" is the texel at x - 1, "at x" is the texel at x.

Offset d Before, RTX 3070 Before, WARP After, RTX 3070 After, WARP
gather +0.25 at x 256 at x 256 at x 256 at x 256
gather +0.75 at x 256 at x 256 at x 256 at x 256
gather -1/1024 at x 256 below 256 at x 256 at x 256
gather -1/512 (tie) — — at x 256 at x 256
gather -1/512 - 1/65536 — — below 256 below 256
gather -3/1024 — — below 256 below 256
point -1/1024 below 256 below 256 below 256 below 256

"—": that offset is not in the test at #3583's head.

So before this PR, NVIDIA's own gather rounds up at -1/1024 like the 780M, and WARP doesn't. With this PR, the RTX 3070 and WARP agree at every offset and follow the rule in the test: 1/1024 and the 1/512 tie round up to x, while 1/512 + 1/65536 and 3/1024 stay at x - 1. Point samples are unchanged. Both tests pass on both heads (2 passed, 3 runs each).

AI-assisted (Claude Code, Claude Opus 5.5 built both heads and ran the tests on this card).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7233810829 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7233810829). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T04:12:49Z. --- The NVIDIA row, as asked: RTX 3070 8 GB, driver 616.56, Windows 11, the hardware adapter and WARP in the same run. `emit::gather_tests::` at #3583 head `f0191df` (before) and this head `bbe216c` (after), each 3 times with identical output. Pixels out of 256: "below" is the texel at `x - 1`, "at x" is the texel at `x`. | Offset `d` | Before, RTX 3070 | Before, WARP | After, RTX 3070 | After, WARP | |---|---|---|---|---| | gather +0.25 | at x 256 | at x 256 | at x 256 | at x 256 | | gather +0.75 | at x 256 | at x 256 | at x 256 | at x 256 | | gather -1/1024 | **at x 256** | below 256 | at x 256 | at x 256 | | gather -1/512 (tie) | — | — | at x 256 | at x 256 | | gather -1/512 - 1/65536 | — | — | below 256 | below 256 | | gather -3/1024 | — | — | below 256 | below 256 | | point -1/1024 | below 256 | below 256 | below 256 | below 256 | "—": that offset is not in the test at #3583's head. So before this PR, NVIDIA's own gather rounds up at -1/1024 like the 780M, and WARP doesn't. With this PR, the RTX 3070 and WARP agree at every offset and follow the rule in the test: 1/1024 and the 1/512 tie round up to `x`, while 1/512 + 1/65536 and 3/1024 stay at `x - 1`. Point samples are unchanged. Both tests pass on both heads (2 passed, 3 runs each). AI-assisted (Claude Code, Claude Opus 5.5 built both heads and ran the tests on this card).
kilolimaVI commented 2026-11-28 14:33:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T14:33:56Z.


Thanks all. @andrewpozdnakov7-jpg's test commit is now on this branch as-is, with his authorship (head 4fb5462).

780M (RDNA3) + WARP on 4fb5462, with the tests run against the old lower.rs (before) and this PR (after, 5 of 5 runs):

test before after
gathers_take_the_footprint_at_the_coordinate (16×16, wrap) fails on WARP passes
gathers_round_npot_wrapped_tile_edges (13×13) passes passes
gathers_round_npot_border_edges (13×13) passes passes

Full suite 557 passed, clippy clean. Like Andrew saw, WARP already lands on the console's footprint at 13×13 (the 1/13 coordinate is not exact), so these two tests don't catch the old behaviour. What they guard is that (first + 1) / size keeps the right texels at a non-power-of-two size, across a wrapped tile edge and in border mode.

All results so far:

host before after
Radeon 780M (RDNA3) console footprint console footprint
RX 5700 XT (RDNA1, ColorMeBoom) console footprint console footprint
RTX 3070 (upipibr) console footprint console footprint
WARP one texel back at −1/1024 and the 1/512 tie console footprint

So every hardware adapter tested so far already rounds like the console. The change makes WARP agree, and it removes the dependency on the host's sampler precision for anything not tested yet.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7240764877 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7240764877). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T14:33:56Z. --- Thanks all. @andrewpozdnakov7-jpg's test commit is now on this branch as-is, with his authorship (head `4fb5462`). 780M (RDNA3) + WARP on `4fb5462`, with the tests run against the old `lower.rs` (before) and this PR (after, 5 of 5 runs): | test | before | after | |---|---|---| | `gathers_take_the_footprint_at_the_coordinate` (16×16, wrap) | fails on WARP | passes | | `gathers_round_npot_wrapped_tile_edges` (13×13) | passes | passes | | `gathers_round_npot_border_edges` (13×13) | passes | passes | Full suite 557 passed, clippy clean. Like Andrew saw, WARP already lands on the console's footprint at 13×13 (the 1/13 coordinate is not exact), so these two tests don't catch the old behaviour. What they guard is that `(first + 1) / size` keeps the right texels at a non-power-of-two size, across a wrapped tile edge and in border mode. All results so far: | host | before | after | |---|---|---| | Radeon 780M (RDNA3) | console footprint | console footprint | | RX 5700 XT (RDNA1, ColorMeBoom) | console footprint | console footprint | | RTX 3070 (upipibr) | console footprint | console footprint | | WARP | one texel back at −1/1024 and the 1/512 tie | console footprint | So every hardware adapter tested so far already rounds like the console. The change makes WARP agree, and it removes the dependency on the host's sampler precision for anything not tested yet. AI-assisted (Claude).
upipibi commented 2026-11-28 14:37:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T14:37:47Z.


NVIDIA row for 4fb5462 (with @andrewpozdnakov7-jpg's tests). RTX 3070, driver 616.56, Windows 11 Pro 10.0.26100, debug. cargo test --locked -p victory-shader --lib gather_tests::gathers, 3 runs each, hardware adapter and WARP in each run:

test before (main 63bcca4's lower.rs) after (4fb5462)
gathers_take_the_footprint_at_the_coordinate (16x16, wrap) fails, 3 of 3 runs passes, 3 of 3
gathers_round_npot_wrapped_tile_edges (13x13) passes passes
gathers_round_npot_border_edges (13x13) passes passes

The "before" failure here comes from WARP. At offsets -0.000977 and -0.001953 the 3070 already gives the console's footprint with main's code (kept below 0, at x 256), and WARP doesn't (kept below 256, at x 0). With this PR both report kept below 0, at x 256 at those offsets, and from -0.001968 on both report kept below 256. So on this card the PR changes WARP's result and leaves the hardware's as it was, and the two new 13x13 tests agree on both. This matches the boundary in my earlier report above.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7240812294 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7240812294). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T14:37:47Z. --- NVIDIA row for `4fb5462` (with @andrewpozdnakov7-jpg's tests). RTX 3070, driver 616.56, Windows 11 Pro 10.0.26100, debug. `cargo test --locked -p victory-shader --lib gather_tests::gathers`, 3 runs each, hardware adapter and WARP in each run: | test | before (main `63bcca4`'s `lower.rs`) | after (`4fb5462`) | |---|---|---| | `gathers_take_the_footprint_at_the_coordinate` (16x16, wrap) | fails, 3 of 3 runs | passes, 3 of 3 | | `gathers_round_npot_wrapped_tile_edges` (13x13) | passes | passes | | `gathers_round_npot_border_edges` (13x13) | passes | passes | The "before" failure here comes from WARP. At offsets -0.000977 and -0.001953 the 3070 already gives the console's footprint with main's code (`kept below 0, at x 256`), and WARP doesn't (`kept below 256, at x 0`). With this PR both report `kept below 0, at x 256` at those offsets, and from -0.001968 on both report `kept below 256`. So on this card the PR changes WARP's result and leaves the hardware's as it was, and the two new 13x13 tests agree on both. This matches the boundary in my earlier report above. AI-assisted (Claude Code, Claude Opus 5.5).
kilolimaVI commented 2026-11-28 16:17:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T16:17:55Z.


@upipibi @JurajSimicevic one more NVIDIA check that may be worth a minute, since you both reported synthetic_tests::gathers_at_a_level_match_the_hardware failing on main (RTX 3070 in #3749, RTX 5080 in #3584).

That test does three gathers per lane: two image_gather4_l (emulated with gather_first, the console's rounding) and one image_gather4_lz, which on main goes straight to the host's textureGather. On lanes 0-15 it asserts, on hardware only, that the host's own gather equals the emulated one, at the coordinates where rounding decides: f32 products just across a texel threshold, the 1/512 ties, NaN, ±inf, zeros. The 780M rounds like the console there and passes; my guess is NVIDIA doesn't on some of those lanes.

This PR moves the _lz coordinate to the middle of the console's footprint with the same gather_first, so all three gathers should agree on any GPU. If you can, please run at 4fb5462:

cargo test -p victory-shader --lib -- gathers_at_a_level_match_the_hardware --nocapture

If it passes there and fails on main, that's an existing test fixed on NVIDIA. If it still fails, the panic line (which lane, which assertion) would tell me what's left.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242132020 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7242132020). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T16:17:55Z. --- @upipibi @JurajSimicevic one more NVIDIA check that may be worth a minute, since you both reported `synthetic_tests::gathers_at_a_level_match_the_hardware` failing on main (RTX 3070 in #3749, RTX 5080 in #3584). That test does three gathers per lane: two `image_gather4_l` (emulated with `gather_first`, the console's rounding) and one `image_gather4_lz`, which on main goes straight to the host's `textureGather`. On lanes 0-15 it asserts, on hardware only, that the host's own gather equals the emulated one, at the coordinates where rounding decides: f32 products just across a texel threshold, the 1/512 ties, NaN, ±inf, zeros. The 780M rounds like the console there and passes; my guess is NVIDIA doesn't on some of those lanes. This PR moves the `_lz` coordinate to the middle of the console's footprint with the same `gather_first`, so all three gathers should agree on any GPU. If you can, please run at `4fb5462`: `cargo test -p victory-shader --lib -- gathers_at_a_level_match_the_hardware --nocapture` If it passes there and fails on main, that's an existing test fixed on NVIDIA. If it still fails, the panic line (which lane, which assertion) would tell me what's left. AI-assisted (Claude).
upipibi commented 2026-11-28 16:36:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by upipibi on 2026-11-28T16:36:14Z.


@kilolimaVI it still fails at 4fb5462 on its own, the same as on main. The cause on NVIDIA is the record read that #2323 (Bullet18x) fixes, not gather rounding. With #2323's one line, NVIDIA's own gather matches the emulated one. RTX 3070, driver 616.56, Windows 11 Pro 10.0.26100, debug.

cargo test --locked -p victory-shader --lib -- gathers_at_a_level_match_the_hardware --nocapture, 3 runs per row:

tree hardware (the 3070, then WARP) VICTORY_WARP=1 (every device WARP)
main 63bcca4 0 passed, 1 failed: hardware: lane 0, left [0.0, 1.0, 0.0, 0.0], right [0.0, 0.0, 0.0, 0.0] not run
4fb5462 (this PR) 0 passed, 1 failed: the same panic not run
main + #2323's 9c6e0942 1 passed, 0 failed 0 passed, 1 failed: hardware: lane 4 against its gather, left [66.0, 67.0, 35.0, 34.0], right [65.0, 66.0, 34.0, 33.0]
4fb5462 + #2323's 9c6e0942 1 passed, 0 failed 1 passed, 0 failed
  • Why every lane failed first. I ran the unchanged test once more on each tree with its three assert_eq!s turned into prints (local change, restored after). On hardware, every one of the 32 lanes read the footprint of u = v = 0 at level 0, [0, 1, 0, 0], or at level 3 on lanes 5-7, from the emulated gathers and the host's alike. That is #2323's description: a raw load through the structured records view multiplies the offset by the stride on NVIDIA (#2178), so the records read as zeros. Its RTX 5090 shows the same [0, 1, 0, 0] on every lane.
  • With the records read right (main + #2323), the lane < 16 check of the 3070's own textureGather passes in 3 of 3 runs. So on this card the host gather already rounds like the console at those coordinates, and this PR's _lz change isn't needed here.
  • Under VICTORY_WARP=1, the "hardware" leg is WARP too, so its !warp guard doesn't skip the host-gather check. On main + #2323 that check fails at lane 4, one texel off (#3261). With this PR on top it passes. So this PR is what makes the test pass on a WARP-only run.

AI use: Claude Code (Claude Opus 5.5) ran the tests and the probe and wrote this.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242369515 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7242369515). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-28T16:36:14Z. --- @kilolimaVI it still fails at `4fb5462` on its own, the same as on `main`. The cause on NVIDIA is the record read that #2323 (Bullet18x) fixes, not gather rounding. With #2323's one line, NVIDIA's own gather matches the emulated one. RTX 3070, driver 616.56, Windows 11 Pro 10.0.26100, debug. `cargo test --locked -p victory-shader --lib -- gathers_at_a_level_match_the_hardware --nocapture`, 3 runs per row: | tree | hardware (the 3070, then WARP) | `VICTORY_WARP=1` (every device WARP) | |---|---|---| | `main` `63bcca4` | 0 passed, 1 failed: `hardware: lane 0`, left `[0.0, 1.0, 0.0, 0.0]`, right `[0.0, 0.0, 0.0, 0.0]` | not run | | `4fb5462` (this PR) | 0 passed, 1 failed: the same panic | not run | | `main` + #2323's `9c6e0942` | 1 passed, 0 failed | 0 passed, 1 failed: `hardware: lane 4 against its gather`, left `[66.0, 67.0, 35.0, 34.0]`, right `[65.0, 66.0, 34.0, 33.0]` | | `4fb5462` + #2323's `9c6e0942` | 1 passed, 0 failed | 1 passed, 0 failed | - **Why every lane failed first.** I ran the unchanged test once more on each tree with its three `assert_eq!`s turned into prints (local change, restored after). On hardware, every one of the 32 lanes read the footprint of u = v = 0 at level 0, `[0, 1, 0, 0]`, or at level 3 on lanes 5-7, from the emulated gathers and the host's alike. That is #2323's description: a raw load through the structured records view multiplies the offset by the stride on NVIDIA (#2178), so the records read as zeros. Its RTX 5090 shows the same `[0, 1, 0, 0]` on every lane. - **With the records read right** (`main` + #2323), the `lane < 16` check of the 3070's own `textureGather` passes in 3 of 3 runs. So on this card the host gather already rounds like the console at those coordinates, and this PR's `_lz` change isn't needed here. - **Under `VICTORY_WARP=1`**, the "hardware" leg is WARP too, so its `!warp` guard doesn't skip the host-gather check. On `main` + #2323 that check fails at lane 4, one texel off (#3261). With this PR on top it passes. So this PR is what makes the test pass on a WARP-only run. AI use: Claude Code (Claude Opus 5.5) ran the tests and the probe and wrote this.
kilolimaVI commented 2026-11-28 18:00:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kilolimaVI on 2026-11-28T18:00:37Z.


@upipibi thanks, that corrects my guess: on NVIDIA it is #2323's record read, and with it the 3070's own gather already rounds like the console.

Your last row is the useful one: under VICTORY_WARP=1, main + #2323 fails at lane 4 one texel off, and this PR on top passes. That is #3261 (WARP one texel off in every channel), so this PR fixes #3261 on the translator side. #3267 takes the test-side route (skipping the host-gather check on WARP); the two don't conflict.

AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7243457993 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7243457993). Originally posted by [kilolimaVI](https://github.com/kilolimaVI) on 2026-11-28T18:00:37Z. --- @upipibi thanks, that corrects my guess: on NVIDIA it is #2323's record read, and with it the 3070's own gather already rounds like the console. Your last row is the useful one: under `VICTORY_WARP=1`, main + #2323 fails at lane 4 one texel off, and this PR on top passes. That is #3261 (WARP one texel off in every channel), so this PR fixes #3261 on the translator side. #3267 takes the test-side route (skipping the host-gather check on WARP); the two don't conflict. AI-assisted (Claude).
andrewpozdnakov7-jpg commented 2026-11-28 18:11:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T18:11:57Z.


I checked the #3261 result on Windows with app-local WARP 1.0.22 and Agility 1.620.2. Every tree used the original structured-buffer fixture and VICTORY_WARP=1.

Tree gathers_at_a_level_match_the_hardware
Main 63bcca4 Fails at lane 4, [66, 67, 35, 34] versus [65, 66, 34, 33]
#3613 4fb5462 Passes with the original native-gather comparison active
#3267 010381c Passes the CPU-model checks, with the native comparison guarded by the selected adapter
Both heads Merge cleanly and pass

The three footprint regressions also passed on #3613 alone and on the combined tree, including the non-power-of-two wrap and border cases. All rows replicated with the D3D12 debug layer off and on. This run checks the WARP rounding result. The RTX 3070 fixture evidence remains in the earlier hardware report.

AI-assisted with OpenAI Codex. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7243606297 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3613#issuecomment-7243606297). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T18:11:57Z. --- I checked the #3261 result on Windows with app-local WARP 1.0.22 and Agility 1.620.2. Every tree used the original structured-buffer fixture and `VICTORY_WARP=1`. | Tree | `gathers_at_a_level_match_the_hardware` | | --- | --- | | Main `63bcca4` | Fails at lane 4, `[66, 67, 35, 34]` versus `[65, 66, 34, 33]` | | #3613 `4fb5462` | Passes with the original native-gather comparison active | | #3267 `010381c` | Passes the CPU-model checks, with the native comparison guarded by the selected adapter | | Both heads | Merge cleanly and pass | The three footprint regressions also passed on #3613 alone and on the combined tree, including the non-power-of-two wrap and border cases. All rows replicated with the D3D12 debug layer off and on. This run checks the WARP rounding result. The RTX 3070 fixture evidence remains in the earlier hardware report. AI-assisted with OpenAI Codex. Synthetic tests only.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3613:upstream-pr/3613'
git switch 'upstream-pr/3613'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3613'
git switch 'upstream-pr/3613'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3613'
git switch 'upstream-pr/3613'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3613'
git switch 'main'
git merge --squash 'upstream-pr/3613'
git switch 'main'
git merge --ff-only 'upstream-pr/3613'
git switch 'main'
git merge 'upstream-pr/3613'
git push origin 'main'
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
Marvisak/VIctory!3613
No description provided.