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

Open
mastrr9 wants to merge 1 commit from upstream-pr/1940 into main
mastrr9 commented 2026-11-24 23:43:57 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by mastrr9 on 2026-11-24T23:43:57Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5482270378 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1940). Originally posted by [mastrr9](https://github.com/mastrr9) on 2026-11-24T23:43:57Z. --- 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.
upipibi commented 2026-11-25 00:09:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by upipibi on 2026-11-24T23:49:51Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7147842533 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1940#issuecomment-7147842533). Originally posted by [upipibi](https://github.com/upipibi) on 2026-11-24T23:49:51Z. --- 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.
DavidM1911 commented 2026-11-25 03:05:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T02:41:12Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7151045690 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1940#issuecomment-7151045690). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T02:41:12Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
github-actions[bot] commented 2026-11-28 08:01:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:01:25Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7236311036 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1940#issuecomment-7236311036). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T08:01:25Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 07:08:25 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:08:25Z.


Triage (#1607) – head 54269d7

This is the direct DXIL version of the HLSL per-mip offset blend merged in #229. No open or merged PR does it for gpu/dxil; #3341 only clamps the mip level for the offset.

  • The sampler decoding in the new arm of lower_image.rs mimg is out of date. It treats mag >= 2 || min >= 2 as anisotropic and aniso point (2) as linear. Since #1117, desc::sampler_d3d12 and the HLSL arm on main make only aniso bilinear (3) anisotropic and treat aniso point as point. Update the aniso and lin_of tests to match.
  • Main has moved this code into the sample_body closure and is at TRANSLATOR_VERSION 12, so the PR needs a rebase.
    Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7303691221 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1940#issuecomment-7303691221). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T07:08:25Z. --- **Triage (#1607)** – head 54269d7 This is the direct DXIL version of the HLSL per-mip offset blend merged in #229. No open or merged PR does it for `gpu/dxil`; #3341 only clamps the mip level for the offset. - The sampler decoding in the new arm of `lower_image.rs` `mimg` is out of date. It treats `mag >= 2 || min >= 2` as anisotropic and aniso point (2) as linear. Since #1117, `desc::sampler_d3d12` and the HLSL arm on main make only aniso bilinear (3) anisotropic and treat aniso point as point. Update the `aniso` and `lin_of` tests to match. - Main has moved this code into the `sample_body` closure and is at `TRANSLATOR_VERSION` 12, so the PR needs a rebase. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
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/1940:upstream-pr/1940'
git switch 'upstream-pr/1940'

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/1940'
git switch 'upstream-pr/1940'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1940'
git switch 'upstream-pr/1940'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1940'
git switch 'main'
git merge --squash 'upstream-pr/1940'
git switch 'main'
git merge --ff-only 'upstream-pr/1940'
git switch 'main'
git merge 'upstream-pr/1940'
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
xcl-dev/xcl!1930
No description provided.