dxil: emulate explicit-LOD gather4_l(_o) and support UNORM=1 non-cube sampling #1951

Manually merged
github merged 1 commit from gh-pr/1951/head into gh-pr/1951/base 2026-11-26 05:11:18 +00:00
Owner

@⁠raylitebull on GitHub · 2026-11-24 23:49 UTC · original
raylitebull:feat/dxil-gather4-lod-unorm → main · +615 −2 · 1 files · 1 commits · merged 2026-11-25 10:40 UTC

Emulates explicit-LOD image_gather4_l / image_gather4_l_o / image_gather4_c_l / image_gather4_c_l_o (plus _cl clamp, A16, D16, and UNORM=1 / FORCE_UNORMALIZED) in the direct RDNA2 -> DXIL translator across all 8 RDNA2 address modes, and adds non-cube UNORM=1 coordinate normalization for sample* and gather4*.

Part of #1269 and #1833.

What is in it

  • crates/xcl/src/gpu/dxil/lower_image.rs (mimg_gather4_lod, apply_rdna2_addr_mode, apply_depth_compare): emulate explicit-LOD gather4_l(_o) on Texture2D and Texture2DArray via 4 mip-level dx.op.textureLoad taps in hardware gather order (-,+), (+,+), (+,-), (-,-) honoring all 8 SQ_TEX_CLAMP address modes, S# signed S5.8 LOD_BIAS (s2[13:0] / 256.0), T# MIN_LOD (tw1[19:8], u4.8 / 256.0 — MIP_FILTER=none reads floor(T# MIN_LOD) at every LOD, and filtered samplers raise S#-clamped LOD to T# MIN_LOD before half-up rounding), S# [min_lod, max_lod] + mip_filter == 0 clamping, RDNA2 half-up mip rounding (floor(lod + 0.501953125) = 257/512, 0x3F00_8000) + GetDimensions mip count, signed 6-bit texel offsets (has_o), S# border color types (s3[31:30]), SQ_TEX_DEPTH_COMPARE (s0[14:12]), and #1969's MIMG heap-bounds guard (self.guarded(run, ...)).
  • crates/xcl/src/gpu/dxil/lower_image.rs (mimg_unorm_sample): normalize unnormalized texel coordinates (and optional signed 6-bit offsets) via mip GetDimensions for non-cube textures (D1, D2, D3, D1Array, D2Array) before DXIL sample/gather emission, with #1969 heap-bounds guard (safe_tw0 for implicit_lod).
  • gather4_lod_tests: gather4_lod_variants_translate_and_validate, gather4_lod_emits_bias_and_rdna2_half_up_rounding, gather4_lod_honors_tsharp_min_lod_and_mip_filter_none, and non_cube_unorm_sampling_translates_and_validate.

Tested

  • Toolchain: Windows 11 x64, rustc 1.99.1 (58cf8f9c3 2026-10-13), rebased cleanly onto ae0518c (ff184be).
  • ff184be integrates the T# MIN_LOD fix (@brothernog catch) and #1969 heap-bounds guard atop ae0518c via pure git during a local test hold; queued for GitHub Actions Build and test and fresh AMD / NVIDIA verification (gather4_lod_tests).
  • Earlier head e201efe passed cargo check --workspace --tests, gather4_lod_tests (3/3), and @upipibi's 5-case DXIL verification.
  • Exact-head 60 s scripts/smoke.ps1 regression pair on AMD Radeon RX 9070 (@Toons29): passed (0 device removals, 0 crashes).

Regression run
60 s scripts/smoke.ps1 pair on exact head ff184be vs main (AMD Radeon RX 9070, driver 32.0.32029.2010, Windows 11 26300, release, XCL_NETWORK=0 on a retail title), contributed by @Toons29:

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB

this PR:

xcl-smoke v1
commit: ff184bedd65af7d0e74a32a1515e0b7d591d8242
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Not tested

  • cargo check / gather4_lod_tests and scripts/smoke.ps1 on updated head ff184be, runtime GPU pixel comparison against HLSL on AMD / NVIDIA / Intel hardware, wave32-only adapters, and Linux/Wine/vkd3d-proton.

AI use

  • Antigravity assisted with implementation and DXIL validation tests; the author reviewed the diff.
**@⁠raylitebull** on GitHub · 2026-11-24 23:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951) `raylitebull:feat/dxil-gather4-lod-unorm` → `main` · +615 −2 · 1 files · 1 commits · merged 2026-11-25 10:40 UTC Emulates explicit-LOD `image_gather4_l` / `image_gather4_l_o` / `image_gather4_c_l` / `image_gather4_c_l_o` (plus `_cl` clamp, `A16`, `D16`, and `UNORM=1` / `FORCE_UNORMALIZED`) in the direct RDNA2 -> DXIL translator across all 8 RDNA2 address modes, and adds non-cube `UNORM=1` coordinate normalization for `sample*` and `gather4*`. Part of #1269 and #1833. **What is in it** - `crates/xcl/src/gpu/dxil/lower_image.rs` (`mimg_gather4_lod`, `apply_rdna2_addr_mode`, `apply_depth_compare`): emulate explicit-LOD `gather4_l(_o)` on `Texture2D` and `Texture2DArray` via 4 mip-level `dx.op.textureLoad` taps in hardware gather order `(-,+), (+,+), (+,-), (-,-)` honoring all 8 `SQ_TEX_CLAMP` address modes, S# signed S5.8 `LOD_BIAS` (`s2[13:0] / 256.0`), T# `MIN_LOD` (`tw1[19:8]`, u4.8 / `256.0` — `MIP_FILTER=none` reads `floor(T# MIN_LOD)` at every LOD, and filtered samplers raise S#-clamped LOD to `T# MIN_LOD` before half-up rounding), S# `[min_lod, max_lod]` + `mip_filter == 0` clamping, RDNA2 half-up mip rounding (`floor(lod + 0.501953125)` = `257/512`, `0x3F00_8000`) + `GetDimensions` mip count, signed 6-bit texel offsets (`has_o`), S# border color types (`s3[31:30]`), `SQ_TEX_DEPTH_COMPARE` (`s0[14:12]`), and `#1969`'s MIMG heap-bounds guard (`self.guarded(run, ...)`). - `crates/xcl/src/gpu/dxil/lower_image.rs` (`mimg_unorm_sample`): normalize unnormalized texel coordinates (and optional signed 6-bit offsets) via mip `GetDimensions` for non-cube textures (`D1`, `D2`, `D3`, `D1Array`, `D2Array`) before DXIL sample/gather emission, with `#1969` heap-bounds guard (`safe_tw0` for `implicit_lod`). - `gather4_lod_tests`: `gather4_lod_variants_translate_and_validate`, `gather4_lod_emits_bias_and_rdna2_half_up_rounding`, `gather4_lod_honors_tsharp_min_lod_and_mip_filter_none`, and `non_cube_unorm_sampling_translates_and_validate`. **Tested** - Toolchain: Windows 11 x64, `rustc 1.99.1 (58cf8f9c3 2026-10-13)`, rebased cleanly onto `ae0518c` (`ff184be`). - `ff184be` integrates the T# `MIN_LOD` fix (`@brothernog` catch) and `#1969` heap-bounds guard atop `ae0518c` via pure git during a local test hold; queued for GitHub Actions `Build and test` and fresh AMD / NVIDIA verification (`gather4_lod_tests`). - Earlier head `e201efe` passed `cargo check --workspace --tests`, `gather4_lod_tests` (`3/3`), and `@upipibi`'s 5-case DXIL verification. - Exact-head 60 s `scripts/smoke.ps1` regression pair on AMD Radeon RX 9070 (`@Toons29`): passed (0 device removals, 0 crashes). **Regression run** 60 s `scripts/smoke.ps1` pair on exact head `ff184be` vs `main` (AMD Radeon RX 9070, driver 32.0.32029.2010, Windows 11 26300, release, `XCL_NETWORK=0` on a retail title), contributed by `@Toons29`: main: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1566 (PresentX 1566) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14592 MB ``` this PR: ``` xcl-smoke v1 commit: ff184bedd65af7d0e74a32a1515e0b7d591d8242 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1633 (PresentX 1633) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14812 MB ``` **Not tested** - `cargo check` / `gather4_lod_tests` and `scripts/smoke.ps1` on updated head `ff184be`, runtime GPU pixel comparison against HLSL on AMD / NVIDIA / Intel hardware, wave32-only adapters, and Linux/Wine/vkd3d-proton. **AI use** - Antigravity assisted with implementation and DXIL validation tests; the author reviewed the diff.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:11:17 +00:00
github manually merged commit ff184bedd6 into gh-pr/1951/base 2026-11-26 05:11:18 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 00:06 UTC · original

Checked on an RTX 3070 (Ampere, driver 616.56, Windows 11, debug build) at 940c51b.

The batch run is clean: dxil:: and bvh:: units pass, and so do the gpu_ tests with XCL_DIRECT_DXIL=0 and 1 (110 passed each, same as main). None of the existing GPU tests reaches a gather4_l with a level above 0, though, so I ran a pixel-shader check. It has an 8×8 texture with 4 levels, where level k holds 100·k + x. The test reads the 2×2 footprint and goes through the direct translator (draw_console_views routed through direct_or).

case expected level this PR (direct) #1812 7f804be (direct / HLSL)
LOD 1.0, MIP_FILTER point 1 ok ok / ok
LOD 2.0, S# MAX_LOD 1.0 1 ok ok / ok
LOD 1.0, MIP_FILTER none 0 ok ok / ok
LOD 0.5, MIP_FILTER point 1 level 0 (all 256 pixels) ok / ok

The last row comes from l_rnd = ROUND_NE(l). RDNA2 picks the level as floor(lod + 0.501953125), measured on gfx1030/gfx1036 in boykopovar/AnyPS5's hardware-oracle runs. That is, it rounds half up, so LOD 0.5 reads level 1 and 2.5 reads level 3, where round-to-even gives 0 and 2. From reading only (not run): the S# LOD_BIAS isn't added before the clamp either.

Overlap: #1812 (brothernog, open and mergeable) already does explicit-LOD gather4_l/_l_o for 2D and 2D arrays on both backends. It applies the bias, uses the measured rounding, and has GPU tests. This PR's gather4_l half duplicates it for the direct path. The UNORM=1 non-cube sampling half is separate and could stand as its own PR.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-25 00:06 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7148154288) Checked on an RTX 3070 (Ampere, driver 616.56, Windows 11, debug build) at `940c51b`. The batch run is clean: `dxil::` and `bvh::` units pass, and so do the `gpu_` tests with `XCL_DIRECT_DXIL=0` and `1` (110 passed each, same as `main`). None of the existing GPU tests reaches a `gather4_l` with a level above 0, though, so I ran a pixel-shader check. It has an 8×8 texture with 4 levels, where level k holds `100·k + x`. The test reads the 2×2 footprint and goes through the direct translator (`draw_console_views` routed through `direct_or`). | case | expected level | this PR (direct) | #1812 `7f804be` (direct / HLSL) | |---|---|---|---| | LOD 1.0, `MIP_FILTER` point | 1 | ok | ok / ok | | LOD 2.0, S# `MAX_LOD` 1.0 | 1 | ok | ok / ok | | LOD 1.0, `MIP_FILTER` none | 0 | ok | ok / ok | | LOD 0.5, `MIP_FILTER` point | 1 | **level 0** (all 256 pixels) | ok / ok | The last row comes from `l_rnd = ROUND_NE(l)`. RDNA2 picks the level as `floor(lod + 0.501953125)`, measured on gfx1030/gfx1036 in boykopovar/AnyPS5's hardware-oracle runs. That is, it rounds half up, so LOD 0.5 reads level 1 and 2.5 reads level 3, where round-to-even gives 0 and 2. From reading only (not run): the S# `LOD_BIAS` isn't added before the clamp either. **Overlap:** #1812 (brothernog, open and mergeable) already does explicit-LOD `gather4_l`/`_l_o` for 2D and 2D arrays on both backends. It applies the bias, uses the measured rounding, and has GPU tests. This PR's `gather4_l` half duplicates it for the direct path. The `UNORM=1` non-cube sampling half is separate and could stand as its own PR. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 00:16 UTC · original

Thanks for the thorough pixel check and catch, @upipibi!

Updated #1951 cleanly on top of 80f4819 in commit e201efe to fix both points in crates/xcl/src/gpu/dxil/lower_image.rs (mimg_gather4_lod):

  1. S# LOD_BIAS (s2[13:0]): extracts the signed 14-bit S5.8 LOD_BIAS (((s2 << 18) as i32 >> 18) / 256.0) and adds it to lod before optional cl and [min_lod, max_lod] clamping.
  2. RDNA2 half-up mip rounding: switched from ROUND_NE to floor(lod + 0.501953125) (op::ROUND_NI, 257/512 / 0x3F00_8000) so LOD 0.5 selects level 1 and LOD 2.5 selects level 3 (with MIP_FILTER=none still collapsing max_lod = min_lod).

Verified locally with cargo check --workspace --tests and cargo test -p xcl --lib gather4_lod_tests (3 passed, 0 failed, dxil 1.8.2502.11 validated, including new gather4_lod_emits_bias_and_rdna2_half_up_rounding); GPU pixel checks have not been re-run on e201efe yet.

Re #1812: understood on the overlap for gather4_l/_l_o! If #1812 merges first (or if maintainers prefer keeping #1951 focused strictly on non-cube UNORM=1 normalization), I am happy to rebase #1951 down to just mimg_unorm_sample and its tests.

**@⁠raylitebull** on GitHub · 2026-11-25 00:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7148333495) Thanks for the thorough pixel check and catch, `@upipibi`! Updated `#1951` cleanly on top of `80f4819` in commit `e201efe` to fix both points in `crates/xcl/src/gpu/dxil/lower_image.rs` (`mimg_gather4_lod`): 1. **S# `LOD_BIAS` (`s2[13:0]`):** extracts the signed 14-bit S5.8 `LOD_BIAS` (`((s2 << 18) as i32 >> 18) / 256.0`) and adds it to `lod` before optional `cl` and `[min_lod, max_lod]` clamping. 2. **RDNA2 half-up mip rounding:** switched from `ROUND_NE` to `floor(lod + 0.501953125)` (`op::ROUND_NI`, `257/512` / `0x3F00_8000`) so `LOD 0.5` selects level `1` and `LOD 2.5` selects level `3` (with `MIP_FILTER=none` still collapsing `max_lod = min_lod`). Verified locally with `cargo check --workspace --tests` and `cargo test -p xcl --lib gather4_lod_tests` (`3 passed, 0 failed`, `dxil 1.8.2502.11` validated, including new `gather4_lod_emits_bias_and_rdna2_half_up_rounding`); GPU pixel checks have not been re-run on `e201efe` yet. Re `#1812`: understood on the overlap for `gather4_l`/`_l_o`! If `#1812` merges first (or if maintainers prefer keeping `#1951` focused strictly on non-cube `UNORM=1` normalization), I am happy to rebase `#1951` down to just `mimg_unorm_sample` and its tests.
Author
Owner

@⁠Anon64 on GitHub · 2026-11-25 00:18 UTC · original

Regression run for this PR: head 940c51b, based on main 62265d3. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, XCL_NETWORK=0, A pressed every 4 s from 20 s, scripts/smoke.ps1 on a retail title for 60 s, in one batch with the main run.

main 62265d3:

xcl-smoke v1
commit: 62265d3bbde2255f849fb650cc29872df91a4cf0
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1629 (PresentX 1629)
presents per 2 s (last 3): 60 60 47
device removals: 0
crashes: 0
peak commit: 23489 MB

this PR:

xcl-smoke v1
commit: 940c51b2d9c362802c924405abc606f2cd9ca82a
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1613 (PresentX 1614)
presents per 2 s (last 3): 60 49 50
device removals: 0
crashes: 0
peak commit: 24061 MB

No device removals or crashes; 99 % of main's frames, 102 % of its peak commit.

Not tested: the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, XCL_DIRECT_DXIL unset).

Written with Claude Code (Claude Opus 5.5) from runs on this machine.

**@⁠Anon64** on GitHub · 2026-11-25 00:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7148373027) Regression run for this PR: head `940c51b`, based on `main` `62265d3`. RTX 3060 12 GB (581.80, wave32), Windows 11 26200, release, `XCL_NETWORK=0`, A pressed every 4 s from 20 s, `scripts/smoke.ps1` on a retail title for 60 s, in one batch with the `main` run. main `62265d3`: ``` xcl-smoke v1 commit: 62265d3bbde2255f849fb650cc29872df91a4cf0 gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1629 (PresentX 1629) presents per 2 s (last 3): 60 60 47 device removals: 0 crashes: 0 peak commit: 23489 MB ``` this PR: ``` xcl-smoke v1 commit: 940c51b2d9c362802c924405abc606f2cd9ca82a gpu: NVIDIA GeForce RTX 3060 title: 21222967 seconds: 60 exit: 0x0 frames shown: 1613 (PresentX 1614) presents per 2 s (last 3): 60 49 50 device removals: 0 crashes: 0 peak commit: 24061 MB ``` No device removals or crashes; 99 % of main's frames, 102 % of its peak commit. **Not tested:** the whole suite; the direct DXIL path this PR changes (these runs use the default HLSL path, `XCL_DIRECT_DXIL` unset). Written with Claude Code (Claude Opus 5.5) from runs on this machine.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 00:47 UTC · original

Quick overlap note: full credit to #1812 (@⁠brothernog), which already implements explicit-LOD gather4_l(_o) across both the HLSL and Direct DXIL backends.

#1951 adds Direct DXIL support for UNORM=1 non-cube sampling (mimg_unorm_sample) as well as compare/clamp explicit-LOD gather4 forms (gather4_c_l / gather4_cl). Once #1812 lands, we will rebase and trim #1951 down to only the non-overlapping UNORM=1 and _c_ / _cl paths.

**@⁠raylitebull** on GitHub · 2026-11-25 00:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7148880257) Quick overlap note: full credit to **#1812** (@⁠brothernog), which already implements explicit-LOD `gather4_l(_o)` across both the HLSL and Direct DXIL backends. #1951 adds Direct DXIL support for `UNORM=1` non-cube sampling (`mimg_unorm_sample`) as well as compare/clamp explicit-LOD `gather4` forms (`gather4_c_l` / `gather4_cl`). Once #1812 lands, we will rebase and trim #1951 down to only the non-overlapping `UNORM=1` and `_c_` / `_cl` paths.
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 00:49 UTC · original

Re-checked e201efe on the RTX 3070 (driver 616.56, Windows 11, debug) with the same pixel test through the direct translator, plus one bias case:

case expected level 940c51b e201efe
LOD 1.0 1 ok ok
LOD 2.0, S# MAX_LOD 1.0 1 ok ok
LOD 1.0, MIP_FILTER none 0 ok ok
LOD 0.5 1 level 0 ok
LOD 2.0, S# LOD_BIAS −0.75 (0x3F40) → 1.25 1 level 2 ok

Both points are fixed on hardware. The overlap with #1812 for the gather4_l part still stands; that's for the maintainers to pick.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-25 00:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7148907173) Re-checked `e201efe` on the RTX 3070 (driver 616.56, Windows 11, debug) with the same pixel test through the direct translator, plus one bias case: | case | expected level | `940c51b` | `e201efe` | |---|---|---|---| | LOD 1.0 | 1 | ok | ok | | LOD 2.0, S# `MAX_LOD` 1.0 | 1 | ok | ok | | LOD 1.0, `MIP_FILTER` none | 0 | ok | ok | | LOD 0.5 | 1 | level 0 | ok | | LOD 2.0, S# `LOD_BIAS` −0.75 (`0x3F40`) → 1.25 | 1 | level 2 | ok | Both points are fixed on hardware. The overlap with #1812 for the `gather4_l` part still stands; that's for the maintainers to pick. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠brothernog on GitHub · 2026-11-25 01:09 UTC · original

Heads-up on overlap, from reading the diff, not from a run: #1812, opened earlier, emulates the same image_gather4_l / _l_o forms with four mip-level Loads and the S# address modes. It does this in both the HLSL and the direct DXIL backend, with GPU pixel tests on both: 18 S# / T# cases, plus @⁠upipibi's three review cases. The two PRs conflict in the same block of lower_image.rs, so whichever lands second needs to be rebuilt on the other.

Two differences:

  • Level. #1812 also raises the level to the T# MIN_LOD and reads floor(T# MIN_LOD) with MIP_FILTER none, per the gfx1036 measurement @⁠upipibi cited there. As I read mimg_gather4_lod, it doesn't read the T# MIN_LOD, and with MIP_FILTER none it collapses the range to the S# MIN_LOD.
  • Coverage. #1951 also covers the compare forms (gather4_c_l, _c_l_o) and UNORM=1, which #1812 leaves alone.

One way to split it: #1812 for the uncompared gather4_l level and taps on both backends, and this PR rebased on top of it for the compare forms and UNORM. The maintainers can decide.

This comment was AI-assisted.

**@⁠brothernog** on GitHub · 2026-11-25 01:09 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7149267727) Heads-up on overlap, from reading the diff, not from a run: #1812, opened earlier, emulates the same `image_gather4_l` / `_l_o` forms with four mip-level `Load`s and the S# address modes. It does this in both the HLSL and the direct DXIL backend, with GPU pixel tests on both: 18 S# / T# cases, plus @⁠upipibi's three review cases. The two PRs conflict in the same block of `lower_image.rs`, so whichever lands second needs to be rebuilt on the other. Two differences: - **Level.** #1812 also raises the level to the T# `MIN_LOD` and reads `floor(T# MIN_LOD)` with `MIP_FILTER` none, per the gfx1036 measurement @⁠upipibi cited there. As I read `mimg_gather4_lod`, it doesn't read the T# `MIN_LOD`, and with `MIP_FILTER` none it collapses the range to the S# `MIN_LOD`. - **Coverage.** #1951 also covers the compare forms (`gather4_c_l`, `_c_l_o`) and `UNORM=1`, which #1812 leaves alone. One way to split it: #1812 for the uncompared `gather4_l` level and taps on both backends, and this PR rebased on top of it for the compare forms and `UNORM`. The maintainers can decide. This comment was AI-assisted.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:13 UTC · original

Thanks for the detailed comparison, @⁠brothernog! Agreed on the clean split: once #1812 lands for uncompared explicit-LOD \gather4_l\ / _l_o\ across HLSL and Direct DXIL (including \T# MIN_LOD\ floor handling), we will rebase and trim #1951 strictly down to the non-overlapping \gather4_c_l\ / _c_l_o\ compare forms and non-cube \UNORM=1\ sampling paths.

**@⁠raylitebull** on GitHub · 2026-11-25 01:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7149324135) Thanks for the detailed comparison, @⁠brothernog! Agreed on the clean split: once #1812 lands for uncompared explicit-LOD \gather4_l\ / \_l_o\ across HLSL and Direct DXIL (including \T# MIN_LOD\ floor handling), we will rebase and trim #1951 strictly down to the non-overlapping \gather4_c_l\ / \_c_l_o\ compare forms and non-cube \UNORM=1\ sampling paths.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 01:54 UTC · original

Thanks for catching the missing T# MIN_LOD clamping, @brothernog!

Updated #1951 cleanly onto ae0518c (ff184be):

  • T# MIN_LOD (tw1[19:8], u4.8 / 256.0) in mimg_gather4_lod: MIP_FILTER=none now reads floor(T# MIN_LOD) at every LOD, and non-none MIP_FILTER raises the S#-clamped level to T# MIN_LOD before half-up + 0.501953125 rounding (added gather4_lod_honors_tsharp_min_lod_and_mip_filter_none test).
  • MIMG heap-bounds guard (#1969): wired self.guarded(run, ...) (plus safe_tw0 for implicit_lod) into both mimg_gather4_lod and mimg_unorm_sample (and we can still trim #1951 cleanly to gather4_c_l(_o) + UNORM=1 if #1812 lands first).

Pushed ff184be for GitHub Actions Build and test and fresh verification!

**@⁠raylitebull** on GitHub · 2026-11-25 01:54 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7150091369) Thanks for catching the missing T# `MIN_LOD` clamping, `@brothernog`! Updated `#1951` cleanly onto `ae0518c` (`ff184be`): - **T# `MIN_LOD` (`tw1[19:8]`, u4.8 / `256.0`) in `mimg_gather4_lod`:** `MIP_FILTER=none` now reads `floor(T# MIN_LOD)` at every LOD, and non-none `MIP_FILTER` raises the S#-clamped level to `T# MIN_LOD` before half-up `+ 0.501953125` rounding (added `gather4_lod_honors_tsharp_min_lod_and_mip_filter_none` test). - **MIMG heap-bounds guard (`#1969`):** wired `self.guarded(run, ...)` (plus `safe_tw0` for `implicit_lod`) into both `mimg_gather4_lod` and `mimg_unorm_sample` *(and we can still trim `#1951` cleanly to `gather4_c_l(_o)` + `UNORM=1` if `#1812` lands first)*. Pushed `ff184be` for GitHub Actions `Build and test` and fresh verification!
Author
Owner

@⁠upipibi on GitHub · 2026-11-25 02:38 UTC · original

Re-checked ff184be on the RTX 3070 (driver 616.56, Windows 11, debug) through the direct translator. The same six level cases as before all pass: LOD 1.0; LOD 2.0 under S# MAX_LOD 1.0; MIP_FILTER none; LOD 0.5; LOD 2.0 with S# LOD_BIAS −0.75; and LOD 0.499 (literal), which RDNA2 reads at level 1. For comparison, #1812 at b0f160f still reads level 0 for that last case.

AI-assisted (Claude Code). Synthetic tests only.

**@⁠upipibi** on GitHub · 2026-11-25 02:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7150989666) Re-checked `ff184be` on the RTX 3070 (driver 616.56, Windows 11, debug) through the direct translator. The same six level cases as before all pass: LOD 1.0; LOD 2.0 under S# `MAX_LOD` 1.0; `MIP_FILTER` none; LOD 0.5; LOD 2.0 with S# `LOD_BIAS` −0.75; and LOD 0.499 (literal), which RDNA2 reads at level 1. For comparison, #1812 at `b0f160f` still reads level 0 for that last case. AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 02:59 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 02:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7151470131) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠JJAutoCompare on GitHub · 2026-11-25 03:14 UTC · original

Tested

Verified PR #1951 from a clean checkout at ff184bedd65af7d0e74a32a1515e0b7d591d8242. GitHub showed the PR open at that SHA before and after the run.

  • Windows 11 Enterprise Evaluation 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175 (installed hardware). Rust and Cargo 1.100.0, x86_64-pc-windows-msvc, unoptimized test profile. The runtime log confirmed dxcompiler.dll and dxil.dll 1.9.2609.5 from %LOCALAPPDATA%\XclTooling\dxc-1.9.2609\bin\x64 via XCL_DXC_DIR.
  • Two Cargo jobs, incremental compilation off, dev and test debuginfo off, XCL_ADAPTER=A770, CARGO_TARGET_DIR=L:/XclTooling/pr2014-1c971de6/target. TEMP and TMP pointed to the run’s temp directory under L:/XclTooling/pr1951.
cargo test -p xcl --lib gpu::dxil::lower_image::gather4_lod_tests::non_cube_unorm_sampling_translates_and_validate -- --exact --nocapture

1 passed, 0 failed, 0 ignored, 0 skipped (1,066 filtered out, Cargo exit 0). The one fixture translated seven synthetic UNORM=1 RDNA2 shaders and DXC accepted all seven emitted DXIL containers. The cases cover samples on 1D, 2D, 3D, 1D-array, and 2D-array textures, plus 2D and 2D-array LOD-zero gathers, including a 3D sample offset and a 2D-array gather offset with D16 output.

Not tested

GPU execution, numerical sampling or pixel parity, bounds behavior, the explicit-mip gather4_l emulation covered separately by #1812, retail titles, smoke runs, and the broader suite.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and wrote this report.

**@⁠JJAutoCompare** on GitHub · 2026-11-25 03:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7151733786) **Tested** Verified PR #1951 from a clean checkout at `ff184bedd65af7d0e74a32a1515e0b7d591d8242`. GitHub showed the PR open at that SHA before and after the run. - Windows 11 Enterprise Evaluation 26200.9974, AMD Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175 (installed hardware). Rust and Cargo 1.100.0, `x86_64-pc-windows-msvc`, unoptimized test profile. The runtime log confirmed `dxcompiler.dll` and `dxil.dll` 1.9.2609.5 from `%LOCALAPPDATA%\XclTooling\dxc-1.9.2609\bin\x64` via `XCL_DXC_DIR`. - Two Cargo jobs, incremental compilation off, dev and test debuginfo off, `XCL_ADAPTER=A770`, `CARGO_TARGET_DIR=L:/XclTooling/pr2014-1c971de6/target`. `TEMP` and `TMP` pointed to the run’s `temp` directory under `L:/XclTooling/pr1951`. ```powershell cargo test -p xcl --lib gpu::dxil::lower_image::gather4_lod_tests::non_cube_unorm_sampling_translates_and_validate -- --exact --nocapture ``` **1 passed, 0 failed, 0 ignored, 0 skipped** (1,066 filtered out, Cargo exit 0). The one fixture translated seven synthetic `UNORM=1` RDNA2 shaders and DXC accepted all seven emitted DXIL containers. The cases cover samples on 1D, 2D, 3D, 1D-array, and 2D-array textures, plus 2D and 2D-array LOD-zero gathers, including a 3D sample offset and a 2D-array gather offset with D16 output. **Not tested** GPU execution, numerical sampling or pixel parity, bounds behavior, the explicit-mip `gather4_l` emulation covered separately by #1812, retail titles, smoke runs, and the broader suite. **AI use** T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture and wrote this report.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 10:32 UTC · original

Regression run of ff184bed on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: ff184bedd65af7d0e74a32a1515e0b7d591d8242
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

Against the limits in CONTRIBUTING.md: 104 % of main's frames, 102 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

**@⁠Toons29** on GitHub · 2026-11-25 10:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7159829780) Regression run of `ff184bed` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `568e7db7`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1566 (PresentX 1566) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14592 MB ``` ``` xcl-smoke v1 commit: ff184bedd65af7d0e74a32a1515e0b7d591d8242 gpu: AMD Radeon RX 9070 title: 34df7c50 seconds: 60 exit: 0x0 frames shown: 1633 (PresentX 1633) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14812 MB ``` Against the limits in CONTRIBUTING.md: 104 % of `main`'s frames, 102 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; a script posted this right after the run, with both blocks exactly as printed.
Author
Owner

@⁠raylitebull on GitHub · 2026-11-25 10:37 UTC · original

Thanks @⁠Toons29 for running and sharing the exact-head 60 s scripts/smoke.ps1 pair on ff184be (0 device removals, 0 crashes) — added to the PR description!

**@⁠raylitebull** on GitHub · 2026-11-25 10:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7159957778) Thanks @⁠Toons29 for running and sharing the exact-head 60 s `scripts/smoke.ps1` pair on `ff184be` (0 device removals, 0 crashes) — added to the PR description!
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 06:51 UTC · original

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

**@⁠DavidM1911** on GitHub · 2026-11-26 06:51 UTC · [original](https://github.com/xcl-dev/xcl/pull/1951#issuecomment-7184852770) Re-verification on RTX 3060 Ti (Windows 11), new head merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved. Thanks! — Devin
This discussion has been locked. Commenting is limited to contributors.
No description provided.