Skip to content

dxil: keep the LOD clamp of image_sample_*_cl on cubes - #1939

Draft
mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/dxil-image-sample-cl-cube
Draft

mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/dxil-image-sample-cl-cube

Conversation

@mastrr9

@mastrr9 mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

In a pixel shader the direct translator dropped the clamp operand of image_sample_cl / _b_cl / _c_cl when the T# is a cube, so it sampled below the clamp. The HLSL path passes it for cubes like any other dimension.

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: keep the clamp for cubes
  • gpu/dxil/kernel.rs: TRANSLATOR_VERSION 8
  • gpu/recomp/tests.rs: gpu_ps_image_sample_cl_cube_on_both_backends

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_cl_cube_on_both_backends -- --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 new test without the fix.
  • The _b_cl and _c_cl cube forms are built on both backends by the test but not drawn.
  • dxil: emit MSAA textureLoad before getDimensions to avoid amdxc64 crash #1900 has changed lower_image.rs (MSAA loads) since the tested base; it merged without conflict.

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; it also trimmed one outdated sentence from the commit message.

The direct translator dropped the clamp operand of sample, sample_b and
sample_c (the implicit-LOD forms in a pixel shader) when the T# is a
cube, so image_sample_cl / _b_cl / _c_cl on a cube sampled below the
clamp. The HLSL path passes the clamp for cubes as for every other
dimension (TextureCubeArray Sample / SampleBias / SampleCmp with a
clamp, no offset), and the hardware applies the minimum LOD whatever
the dimension. No validator rule is known to forbid a clamp on a cube.

TRANSLATOR_VERSION 7 -> 8: the emitted containers change for these
programs. Open PR xcl-dev#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 test draws a pixel shader sampling a mipped cube at zero
derivatives with clamp 2.0 through both backends, and builds the
_b_cl and _c_cl cube forms on both backends (not drawn).
@upipibi

upipibi commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

NVIDIA run: RTX 3070 8 GB, driver 616.56, Windows 11, debug, 8eef6e4 merged onto main 20cf130. gpu_ps_image_sample_cl_cube_on_both_backends passes, with and without XCL_DIRECT_DXIL=1.

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

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants