Skip to content

Direct DXIL: image_get_lod accepts static samplers - #1806

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
bmjask:dxil/coverage-full
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
bmjask:dxil/coverage-full

Conversation

@bmjask

@bmjask bmjask commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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 (Direct DXIL: geometry mode, MSAA loads and directed f32 rounding #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

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

… the sweep report

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 <noreply@anthropic.com>
@bmjask bmjask changed the title Direct DXIL: image_get_lod accepts static samplers (whole GTA VI pack translates except GS) Direct DXIL: image_get_lod accepts static samplers Nov 24, 2026
@thehollowedone

Copy link
Copy Markdown

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.

@bmjask bmjask changed the title Direct DXIL: image_get_lod accepts static samplers Direct DXIL: image_get_lod accepts static samplers Nov 24, 2026
@Flyander

Copy link
Copy Markdown

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.

@raylitebull
raylitebull merged commit 266b845 into xcl-dev:main Nov 24, 2026
5 checks passed
anoyarou added a commit to anoyarou/xcl that referenced this pull request Nov 24, 2026
…v#1791, xcl-dev#605, xcl-dev#1806, xcl-dev#1745)

Merges 60 upstream commits through c4d37be, incorporating:
- PR xcl-dev#1747 (raylitebull): eliminate multi-heap UpdateTileMappings and per-texture Signal stalls in vram::Pages via contiguous TilePool
- PR xcl-dev#1791 (wondercrash): D3D12.X an ExecuteIndirect reads arguments written before it
- PR xcl-dev#605 (0x6461726B): promote R9G9B9E5_SHAREDEXP render/UAV targets to R11G11B10_FLOAT
- PR xcl-dev#1806 (bmjask): Direct DXIL image_get_lod accepts static samplers
- PR xcl-dev#1745 (gefydev): direct per-lane DXIL recompiler lowering backend

Assisted-by: Antigravity
mastrr9 added a commit to mastrr9/xcl that referenced this pull request Nov 24, 2026
Brings xcl-dev#1747, xcl-dev#1791, xcl-dev#605, xcl-dev#1679, xcl-dev#1806, xcl-dev#1745, xcl-dev#1307, xcl-dev#1321 among others.

Resolutions:
- dxil/kernel.rs: upstream's Lw::new / Lw::finish; the safe s_barrier state
  and policy and xcl-dev#1741's single-wave bounded exchange move into Lw::new, with
  a safe_barrier flag (false for the per-lane lowering).
- dxil/lower.rs: VAR_BAR_DEAD moves to VAR_BUDGET + 6 (+5 is VAR_F32_MODE).
- TRANSLATOR_VERSION 9.
- d3d12x/bind.rs: the bounded ExecuteIndirect call runs inside
  fresh_indirect_arguments.
- d3d12x/list_x.rs: tracked_list_type, and transition (pub(super)) over the
  batched transitions.
- recomp/mod.rs: compact backend and per-lane modules both kept; the
  oversized-structured-code fallback applies to translate after prepare.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

4 participants