Direct DXIL: image_get_lod accepts static samplers #1806

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

@⁠bmjask on GitHub · 2026-11-24 20:57 UTC · original
bmjask:dxil/coverage-full → main · +67 −25 · 3 files · 1 commits · merged 2026-11-24 21:13 UTC

Follow-up to #1426. image_get_lod with a static sampler (an S# built from constants in the shader) fell back to HLSL; Lw::mimg_sampler in crates/xcl/src/gpu/dxil/lower_image.rs now resolves it the same way sampling does, which fixes 79 a retail title pixel shaders. With that, every program in the pack translates directly except geometry shaders (geometry mode is in #1679). The sweep report also lists the 10 slowest programs.

What is in it

  • Lw::mimg_sampler: image_get_lod accepts static samplers, sharing the s<i>, space1 binding with samples of the same S#.

  • Regression test core_tests::ps_get_lod_with_a_static_sampler (translates, one shared static sampler, validates).

  • Sweep report: the 10 slowest programs.

Full-pack sweep (26,698 programs):

  • total 26,229 (98.2%) → 26,308 (98.5%)

  • PS 12,022 → 12,101 / 12,101; CS/MS/VS 100%; GS 0/390 (#1679)

  • 0 validator failures, panics, or timeouts

  • translation p50/p95/max: 84 ms / 1.29 s / 20.4 s → 50 ms / 0.86 s / 17.9 s (depends on machine load)

  • size on a 1,500-program sample: direct 218.3 MB vs HLSL+DXC 174.1 MB (1.25×)

Tested

  • RTX 4090, i9-12900K, Windows 11, rustc 1.100.0, debug + release

  • cargo test --workspace -- --test-threads=4: 892 passed, 0 failed, 42 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows))

  • gpu::dxil: 83 passed, 0 failed; gpu::recomp with XCL_DIRECT_DXIL=1: 197 passed, 0 failed; with XCL_DIRECT_DXIL=all: 197 passed, 0 failed

Regression run

main:


xcl-smoke v1

commit: 4178e888c0b5be50a2887eda45cdb832763b68a4

gpu: NVIDIA GeForce RTX 4090

title: game

seconds: 60

exit: 0x0

frames shown: 1471 (PresentX 1472)

presents per 2 s (last 3): 52 29 28

device removals: 0

crashes: 0

peak commit: 20808 MB

PR:


xcl-smoke v1

commit: 7a84e7a7d6b5d4ce50302fd2a8bf65fdd1b0ba54

gpu: NVIDIA GeForce RTX 4090

title: game

seconds: 60

exit: 0x0

frames shown: 1403 (PresentX 1403)

presents per 2 s (last 3): 59 28 37

device removals: 0

crashes: 0

peak commit: 21006 MB

Not tested

  • Geometry shaders (they need #1679).

  • Other GPU vendors.

AI use

  • Claude Code (Claude Opus 5.5): wrote the fix, the test, and the sweep-report change, ran the sweeps, tests and smoke runs, and wrote this description.

🤖 Generated with Claude Code

**@⁠bmjask** on GitHub · 2026-11-24 20:57 UTC · [original](https://github.com/xcl-dev/xcl/pull/1806) `bmjask:dxil/coverage-full` → `main` · +67 −25 · 3 files · 1 commits · merged 2026-11-24 21:13 UTC Follow-up to #1426. `image_get_lod` with a static sampler (an S# built from constants in the shader) fell back to HLSL; `Lw::mimg_sampler` in `crates/xcl/src/gpu/dxil/lower_image.rs` now resolves it the same way sampling does, which fixes 79 a retail title pixel shaders. With that, every program in the pack translates directly except geometry shaders (geometry mode is in #1679). The sweep report also lists the 10 slowest programs. **What is in it** - `Lw::mimg_sampler`: `image_get_lod` accepts static samplers, sharing the `s<i>, space1` binding with samples of the same S#. - Regression test `core_tests::ps_get_lod_with_a_static_sampler` (translates, one shared static sampler, validates). - Sweep report: the 10 slowest programs. Full-pack sweep (26,698 programs): - total 26,229 (98.2%) → 26,308 (98.5%) - PS 12,022 → 12,101 / 12,101; CS/MS/VS 100%; GS 0/390 (#1679) - 0 validator failures, panics, or timeouts - translation p50/p95/max: 84 ms / 1.29 s / 20.4 s → 50 ms / 0.86 s / 17.9 s (depends on machine load) - size on a 1,500-program sample: direct 218.3 MB vs HLSL+DXC 174.1 MB (1.25×) **Tested** - RTX 4090, i9-12900K, Windows 11, rustc 1.100.0, debug + release - `cargo test --workspace -- --test-threads=4`: 892 passed, 0 failed, 42 ignored (SKIPPED GPU tests: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64), `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows)) - `gpu::dxil`: 83 passed, 0 failed; `gpu::recomp` with `XCL_DIRECT_DXIL=1`: 197 passed, 0 failed; with `XCL_DIRECT_DXIL=all`: 197 passed, 0 failed **Regression run** main: ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: NVIDIA GeForce RTX 4090 title: game seconds: 60 exit: 0x0 frames shown: 1471 (PresentX 1472) presents per 2 s (last 3): 52 29 28 device removals: 0 crashes: 0 peak commit: 20808 MB ``` PR: ``` xcl-smoke v1 commit: 7a84e7a7d6b5d4ce50302fd2a8bf65fdd1b0ba54 gpu: NVIDIA GeForce RTX 4090 title: game seconds: 60 exit: 0x0 frames shown: 1403 (PresentX 1403) presents per 2 s (last 3): 59 28 37 device removals: 0 crashes: 0 peak commit: 21006 MB ``` **Not tested** - Geometry shaders (they need #1679). - Other GPU vendors. **AI use** - Claude Code (Claude Opus 5.5): wrote the fix, the test, and the sweep-report change, ran the sweeps, tests and smoke runs, and wrote this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
image_get_lod rejected MIMGs whose S# the console built from constants (79 PS
of the GTA VI pack, the only non-geometry gap of a full sweep). The static/heap
sampler choice moves into Lw::mimg_sampler, shared by sample/gather and get_lod.
The coverage report also keeps the 10 slowest programs (text output), to chase
the translation-time tail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:05:48 +00:00
github manually merged commit 7a84e7a7d6 into gh-pr/1806/base 2026-11-26 05:05:48 +00:00
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 21:03 UTC · original

Tested

On 7a84e7a, I drew a synthetic 16×16 target with IMAGE_GET_LOD and IMAGE_SAMPLE sharing one static sampler. The fixture bound that sampler through XCL’s D3D12 root-signature helper and supplied no heap samplers. Both draws matched HLSL exactly across all 256 pixels each and matched the expected values for the four-mip texture.

  • With the sampler's maximum LOD above the requested 1.25, the clamped and unclamped LODs both read 1.25 and the sample read 125.
  • With the maximum LOD set to 0.75, the clamped LOD read 0.75, the unclamped LOD still read 1.25, and the sample read 75.

RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. cargo test --offline --locked -p xcl --lib <filter> -- --nocapture --test-threads=1 passed 1/1 each for the stock ps_get_lod_with_a_static_sampler and the local scratch_gpu_static_sampler_lod_matches_hlsl fixture, with zero skips. Replacing only the image lowering file with the base revision made the same fixture fail at translation with image_get_lod with a static sampler.

Not tested

This was a focused synthetic pixel-shader test. No whole-suite run, retail smoke, or other GPU vendors in this check.

AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the local fixture and drafted this report.

**@⁠thehollowedone** on GitHub · 2026-11-24 21:03 UTC · [original](https://github.com/xcl-dev/xcl/pull/1806#issuecomment-7144426232) **Tested** On [`7a84e7a`](https://github.com/xcl-dev/xcl/commit/7a84e7a7d6b5d4ce50302fd2a8bf65fdd1b0ba54), I drew a synthetic 16×16 target with `IMAGE_GET_LOD` and `IMAGE_SAMPLE` sharing one static sampler. The fixture bound that sampler through XCL’s D3D12 root-signature helper and supplied no heap samplers. Both draws matched HLSL exactly across all 256 pixels each and matched the expected values for the four-mip texture. - With the sampler's maximum LOD above the requested 1.25, the clamped and unclamped LODs both read 1.25 and the sample read 125. - With the maximum LOD set to 0.75, the clamped LOD read 0.75, the unclamped LOD still read 1.25, and the sample read 75. RTX 3080 Ti / 621.35, Ryzen 7 9800X3D, Windows 11 build 26300, Rust 1.99.1 MSVC debug, DXC 1.8.2502.11. `cargo test --offline --locked -p xcl --lib <filter> -- --nocapture --test-threads=1` passed 1/1 each for the stock `ps_get_lod_with_a_static_sampler` and the local `scratch_gpu_static_sampler_lod_matches_hlsl` fixture, with zero skips. Replacing only the image lowering file with the [base revision](https://github.com/xcl-dev/xcl/commit/4178e888c0b5be50a2887eda45cdb832763b68a4) made the same fixture fail at translation with `image_get_lod with a static sampler`. **Not tested** This was a focused synthetic pixel-shader test. No whole-suite run, retail smoke, or other GPU vendors in this check. AI-assisted. Codex (GPT-6 family, exact variant unavailable) wrote and ran the local fixture and drafted this report.
Author
Owner

@⁠Flyander on GitHub · 2026-11-24 21:04 UTC · original

One complement to the translation-only regression: #1775 exercised image_get_lod with a static sampler end to end in a synthetic pixel draw on an RTX 5070 Ti, checking clamped LOD 0 and unclamped LOD -2. I am closing #1775 to avoid duplicating this implementation. Its runtime harness and GPU test (runner.rs, recomp/tests.rs) could be a focused follow-up after this translator change lands. I have not run that test against this PR head.

**@⁠Flyander** on GitHub · 2026-11-24 21:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1806#issuecomment-7144441895) One complement to the translation-only regression: #1775 exercised `image_get_lod` with a static sampler end to end in a synthetic pixel draw on an RTX 5070 Ti, checking clamped LOD 0 and unclamped LOD -2. I am closing #1775 to avoid duplicating this implementation. Its runtime harness and GPU test (`runner.rs`, `recomp/tests.rs`) could be a focused follow-up after this translator change lands. I have not run that test against this PR head.
This discussion has been locked. Commenting is limited to contributors.
No description provided.