Direct DXIL: image_get_lod accepts static samplers #1796

Merged
bmjask merged 1 commit from upstream-pr/1806 into main 2026-11-24 21:13:06 +00:00
bmjask commented 2026-11-24 20:57:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-24T20:57:41Z.


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

<!-- greyfinch-sync:ivall/xcl:issue:6591262698 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1806). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-24T20:57:41Z. --- 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)
thehollowedone commented 2026-11-24 21:09:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-24T21:03:51Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7144426232 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1806#issuecomment-7144426232). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-24T21:03:51Z. --- **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.
Flyander commented 2026-11-24 21:09:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Flyander on 2026-11-24T21:04:33Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7144441895 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1806#issuecomment-7144441895). Originally posted by [Flyander](https://github.com/Flyander) on 2026-11-24T21:04:33Z. --- 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.
upstream-sync closed this pull request 2026-11-24 21:29:42 +00:00
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!1796
No description provided.