dxil: image_sample_o under implicit LOD offsets each mip by its texels #1940

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

@⁠mastrr9 on GitHub · 2026-11-24 23:43 UTC · original
mastrr9:fix/dxil-image-sample-o-per-mip-lod → main · +138 −27 · 3 files · 1 commits · draft

For image_sample_o in a pixel shader with an implicit LOD and a linear mip filter, the HLSL path samples both blended mips, each offset by its own texels. The direct translator offset the coordinates once, by the rounded LOD's mip size, so the other mip could read a texel off. This ports the HLSL form.

TRANSLATOR_VERSION goes from 7 to 8. #1793 and other changes to the direct translator also set 8; identical edits merge silently, so whichever lands later should take the next free number.

Draft: the head commit has not been built or tested yet.

What is in it

  • gpu/dxil/lower_image.rs: the two-mip form, and a texel-offset helper shared with the existing path
  • gpu/dxil/kernel.rs: TRANSLATOR_VERSION 8
  • gpu/recomp/tests.rs: gpu_ps_image_sample_offset_implicit_lod_between_mips now also draws through the direct translator

Tested
These runs are from before the final rebase, on a combined branch (376f968, based on main 689f2db; it holds this change, both halves of the differential mode and five other direct-translator parity fixes; this change's code is the same there), not on this PR's head commit.

  • Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, cargo test debug build. Driver, CPU and Rust versions were not recorded.
  • cargo test -p xcl --lib gpu_ps_image_sample_offset_implicit_lod_between_mips -- --nocapture --test-threads=1: passed.

Regression run
Not run: there are no xcl-smoke blocks for this change.

Not tested

  • The head commit (rebased onto main f5136a6) has not been built or tested: it was rebased on macOS, with no Rust toolchain.
  • cargo test --workspace was not run for this change on its own.
  • AMD and Intel GPUs; release build.
  • A run of the updated test without the fix.
  • #1900 has changed lower_image.rs (MSAA loads) since the tested base; it merged without conflict.
  • #982 changes the same test and conflicts in tests.rs; whichever lands second should keep #982's weights and check both backends against them.

AI use

  • Code and tests: written by Claude Opus 5.5 in an agent session (Duet) with no Windows or GPU.
  • RTX 5080 test runs above: a Claude Sonnet 5.5 agent.
  • Overlap check, rebase and this description: Claude Code, Claude Sonnet 5.5.
**@⁠mastrr9** on GitHub · 2026-11-24 23:43 UTC · [original](https://github.com/xcl-dev/xcl/pull/1940) `mastrr9:fix/dxil-image-sample-o-per-mip-lod` → `main` · +138 −27 · 3 files · 1 commits · draft For `image_sample_o` in a pixel shader with an implicit LOD and a linear mip filter, the HLSL path samples both blended mips, each offset by its own texels. The direct translator offset the coordinates once, by the rounded LOD's mip size, so the other mip could read a texel off. This ports the HLSL form. `TRANSLATOR_VERSION` goes from 7 to 8. #1793 and other changes to the direct translator also set 8; identical edits merge silently, so whichever lands later should take the next free number. Draft: the head commit has not been built or tested yet. **What is in it** - `gpu/dxil/lower_image.rs`: the two-mip form, and a texel-offset helper shared with the existing path - `gpu/dxil/kernel.rs`: `TRANSLATOR_VERSION` 8 - `gpu/recomp/tests.rs`: `gpu_ps_image_sample_offset_implicit_lod_between_mips` now also draws through the direct translator **Tested** These runs are from before the final rebase, on a **combined branch** ([`376f968`](https://github.com/mastrr9/xcl/commit/376f968), based on main `689f2db`; it holds this change, both halves of the differential mode and five other direct-translator parity fixes; this change's code is the same there), **not on this PR's head commit**. - Windows 11 x64, NVIDIA GeForce RTX 5080 16 GB, `cargo test` debug build. Driver, CPU and Rust versions were not recorded. - `cargo test -p xcl --lib gpu_ps_image_sample_offset_implicit_lod_between_mips -- --nocapture --test-threads=1`: passed. **Regression run** Not run: there are no `xcl-smoke` blocks for this change. **Not tested** - The head commit (rebased onto main `f5136a6`) has not been built or tested: it was rebased on macOS, with no Rust toolchain. - `cargo test --workspace` was not run for this change on its own. - AMD and Intel GPUs; release build. - A run of the updated test without the fix. - #1900 has changed `lower_image.rs` (MSAA loads) since the tested base; it merged without conflict. - #982 changes the same test and conflicts in `tests.rs`; whichever lands second should keep #982's weights and check both backends against them. **AI use** - Code and tests: written by Claude Opus 5.5 in an agent session (Duet) with no Windows or GPU. - RTX 5080 test runs above: a Claude Sonnet 5.5 agent. - Overlap check, rebase and this description: Claude Code, Claude Sonnet 5.5.
The HLSL path's image_sample_o in a pixel shader with an implicit LOD and
a linear mip filter samples the two blended mips with SampleLevel, each
moved by the offset in its own texels, and blends them by the LOD's
fraction (20271d46). The direct translator still moved the coordinates
once, by the offset over the size of the rounded LOD's mip, so the
second mip read a texel off when the offset was half its texel or less.

Port that form: LOD = the clamped implicit LOD (raised by the _cl clamp,
capped at the view's last mip), mips floor(LOD) and the next one (capped
too), each with its own texel offset, lerp by the fraction. It is taken
under the same conditions read from the S#: MIP_FILTER linear, not
anisotropic, and LOD >= 1 or min = mag filter; otherwise the single
Sample as before. The texel-offset computation moves into a helper
shared with the existing path.

TRANSLATOR_VERSION 7 -> 8: the emitted containers change for these
programs. Open PR #1793 also bumps TRANSLATOR_VERSION. Identical
edits merge silently in git, so check the bump by hand at merge time:
the later change takes the next free number, or the pipeline cache
could serve containers of another translator under the same version.

The existing test gpu_ps_image_sample_offset_implicit_lod_between_mips
now also draws its pixel shader through the direct translator and
expects the same result.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:10:39 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 23:49 UTC · original

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 54269d7 merged onto main 20cf130. Tests matching sample_o: 3 passed, with and without XCL_DIRECT_DXIL=1. Merged together with #1935, its XCL_DXIL_DIFF=1 run of gpu_ps_image_sample_offset_implicit_lod_between_mips now finds no difference between the backends; on main alone it finds 48 of 256 pixels (details on #1935).

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

**@⁠upipibi** on GitHub · 2026-11-24 23:49 UTC · [original](https://github.com/xcl-dev/xcl/pull/1940#issuecomment-7147842533) NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, `54269d7` merged onto `main` `20cf130`. Tests matching `sample_o`: 3 passed, with and without `XCL_DIRECT_DXIL=1`. Merged together with #1935, its `XCL_DXIL_DIFF=1` run of `gpu_ps_image_sample_offset_implicit_lod_between_mips` now finds no difference between the backends; on `main` alone it finds 48 of 256 pixels (details on #1935). AI-assisted (Claude Code). Synthetic tests only.
Author
Owner

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

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 02:41 UTC · [original](https://github.com/xcl-dev/xcl/pull/1940#issuecomment-7151045690) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/dxil/kernel.rs
  • crates/xcl/src/gpu/dxil/lower_image.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1940'
git switch 'github-bot/gh-1940'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1940'
git switch 'github-bot/gh-1940'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1940'
git switch 'main'
git merge --squash 'github-bot/gh-1940'
git switch 'main'
git merge --ff-only 'github-bot/gh-1940'
git switch 'main'
git merge 'github-bot/gh-1940'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.