Recompiler: an S# word written with s_brev_b32 is a constant too #2290

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

@⁠Prime1997 on GitHub · 2026-11-25 12:29 UTC · original
Prime1997:contrib/static-sampler-brev → main · +62 −1 · 2 files · 1 commits · merged 2026-11-25 18:17 UTC

Requested by Prime · project thread

constant_samplers turns an S# whose four words the code sets from constants into a static sampler, and it followed s_mov_b32, s_movk_i32 and s_mov_b64 only. The console compiler writes a word with only high bits set bit-reversed (s_brev_b32 s66, 40 for 0x14000000), so such an S# was not recognised and its image instruction looked up SamplerDescriptorHeap[word 3 & 0x7FF]: entry 0 for a constant S#. This takes s_brev_b32 of a constant as the constant it is. Fixes #2284.

What is in it

  • crates/xcl/src/gpu/recomp/mod.rs: one more arm in constant_samplers (the direct translator calls the same function).
  • crates/xcl/src/gpu/recomp/tests.rs: static_sampler_word_from_s_brev_is_a_constant (no GPU) and gpu_static_sampler_word_from_s_brev (samples through the sampler).

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 617.14), Intel Core i5-10400, Windows 11 26200, Rust 1.100.0, debug.
  • cargo test -p xcl --lib -- static_sampler: 4 passed, 0 failed, no SKIPPED (the two new tests, gpu_static_samplers_from_constants_in_code, ps_get_lod_with_a_static_sampler). Without the change in mod.rs static_sampler_word_from_s_brev_is_a_constant fails (static_samplers is empty: left [], right [([146, 16773120, 335544320, 0], false)]).
  • In a seeded sample of 1244 programs of a retail title (xcl shaders … --direct --sample 1500 --seed 7 --dump, counted with constant_samplers over the decoded programs): 534 use a sampler in 4951 sample / gather instructions; 1253 of those are static on main, 1735 with this change. The 482 new ones are in 203 programs.
  • cargo test --workspace -- --test-threads=4: 1156 passed, 0 failed, 46 ignored (SKIPPED GPU tests: 25 – 20 need 64-lane waves, 3 are cases the direct per-lane form refuses, heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (needs Windows Developer Mode)).

Regression run

Seeded 60 s runs without input (the same copied profile and shader cache for each, release builds from clean checkouts of the two commits, XCL_HEAP_WINDOWS=1 XCL_LAZY_PSO=1 XCL_LAZY_COMPUTE=1 XCL_PSO_PRELOAD=0 XCL_DXC_THREADS=2). The main run is from earlier the same day, not back to back.

main:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 357 (PresentX 357)
presents per 2 s (last 3): 17 18 18
device removals: 0
crashes: 0
peak commit: 15226 MB

PR:

xcl-smoke v1
commit: 253bc79d0b46f7a58945c9aa0b3e03cb132ba13b
gpu: NVIDIA GeForce RTX 3060 Ti
title: 419239bf
seconds: 60
exit: 0x0
frames shown: 387 (PresentX 388)
presents per 2 s (last 3): 22 21 22
device removals: 0
crashes: 0
peak commit: 15164 MB

Not tested

  • The regression run reaches the title's start screen only. The frame counts differ by run-to-run noise; no performance claim.
  • What the picture of the title looks like with and without the change.
  • AMD / Intel GPUs.

AI use

  • Claude Code with Claude Fable 5.2 found the bug, wrote the fix, the tests and this description, and opened the PR at Prime's request. The runs were on Prime's machine.

🤖 Generated with Claude Code

**@⁠Prime1997** on GitHub · 2026-11-25 12:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/2290) `Prime1997:contrib/static-sampler-brev` → `main` · +62 −1 · 2 files · 1 commits · merged 2026-11-25 18:17 UTC <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime** · [project thread](https://claude.ai/code/project/chan_014ndQaTcZS9FWDAjYnDD1nA?thread=cmsg_014ndQaTcZS9FWDAjYnDD1nAP6bMmXPkAf9NWU5DUiM7bB)_ `constant_samplers` turns an S# whose four words the code sets from constants into a static sampler, and it followed `s_mov_b32`, `s_movk_i32` and `s_mov_b64` only. The console compiler writes a word with only high bits set bit-reversed (`s_brev_b32 s66, 40` for 0x14000000), so such an S# was not recognised and its image instruction looked up `SamplerDescriptorHeap[word 3 & 0x7FF]`: entry 0 for a constant S#. This takes `s_brev_b32` of a constant as the constant it is. Fixes #2284. **What is in it** - `crates/xcl/src/gpu/recomp/mod.rs`: one more arm in `constant_samplers` (the direct translator calls the same function). - `crates/xcl/src/gpu/recomp/tests.rs`: `static_sampler_word_from_s_brev_is_a_constant` (no GPU) and `gpu_static_sampler_word_from_s_brev` (samples through the sampler). **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: NVIDIA GeForce RTX 3060 Ti 8 GB (driver 617.14), Intel Core i5-10400, Windows 11 26200, Rust 1.100.0, debug. - `cargo test -p xcl --lib -- static_sampler`: 4 passed, 0 failed, no SKIPPED (the two new tests, `gpu_static_samplers_from_constants_in_code`, `ps_get_lod_with_a_static_sampler`). Without the change in `mod.rs` `static_sampler_word_from_s_brev_is_a_constant` fails (`static_samplers` is empty: left `[]`, right `[([146, 16773120, 335544320, 0], false)]`). - In a seeded sample of 1244 programs of a retail title (`xcl shaders … --direct --sample 1500 --seed 7 --dump`, counted with `constant_samplers` over the decoded programs): 534 use a sampler in 4951 sample / gather instructions; 1253 of those are static on `main`, 1735 with this change. The 482 new ones are in 203 programs. - `cargo test --workspace -- --test-threads=4`: 1156 passed, 0 failed, 46 ignored (SKIPPED GPU tests: 25 – 20 need 64-lane waves, 3 are cases the direct per-lane form refuses, `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows), `pso_measurement_compiles_an_exact_synthetic_record` (needs Windows Developer Mode)). **Regression run** Seeded 60 s runs without input (the same copied profile and shader cache for each, release builds from clean checkouts of the two commits, `XCL_HEAP_WINDOWS=1 XCL_LAZY_PSO=1 XCL_LAZY_COMPUTE=1 XCL_PSO_PRELOAD=0 XCL_DXC_THREADS=2`). The main run is from earlier the same day, not back to back. main: ``` xcl-smoke v1 commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 357 (PresentX 357) presents per 2 s (last 3): 17 18 18 device removals: 0 crashes: 0 peak commit: 15226 MB ``` PR: ``` xcl-smoke v1 commit: 253bc79d0b46f7a58945c9aa0b3e03cb132ba13b gpu: NVIDIA GeForce RTX 3060 Ti title: 419239bf seconds: 60 exit: 0x0 frames shown: 387 (PresentX 388) presents per 2 s (last 3): 22 21 22 device removals: 0 crashes: 0 peak commit: 15164 MB ``` **Not tested** - The regression run reaches the title's start screen only. The frame counts differ by run-to-run noise; no performance claim. - What the picture of the title looks like with and without the change. - AMD / Intel GPUs. **AI use** - Claude Code with Claude Fable 5.2 found the bug, wrote the fix, the tests and this description, and opened the PR at Prime's request. The runs were on Prime's machine. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The console compiler places a root signature's static samplers as S#
words built from constants in the code, and constant_samplers turns an
S# whose four words were all set that way into a static sampler. It
knew s_mov_b32, s_movk_i32 and s_mov_b64. A word with only high bits
set is written bit-reversed instead (`s_brev_b32 s66, 40` for
0x14000000, the filter word of a point sampler with a mip filter), so
such an S# was not recognised and its image instruction looked up the
sampler-heap entry that word 3 names – entry 0 for a constant S#, a
sampler the title made for something else.

In a seeded sample of 1244 programs of a retail title, 534 use a
sampler in 4951 instructions; 482 of those instructions, in 203
programs, have an S# that is constant but for one s_brev_b32 word.
They get their own static sampler now, in the HLSL and the direct
translator alike (both use constant_samplers).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:25:52 +00:00
github manually merged commit 253bc79d0b into gh-pr/2290/base 2026-11-26 05:25:55 +00:00
Author
Owner

@⁠Lum7nt on GitHub · 2026-11-25 12:59 UTC · original

AMD hardware test on clean head 253bc79d0b46f7a58945c9aa0b3e03cb132ba13b:

Windows 11 build 26300, Radeon RX 9070 XT (driver 32.0.32029.2010), Rust 1.100.0 MSVC, DXC/DXIL 1.9.2609.5. Set XCL_ADAPTER=9070 XT and XCL_REQUIRE_GPU=1, then ran:

cargo test --offline --locked --release -p xcl --lib static_sampler -- --nocapture --test-threads=1

Result: 4 passed, 0 failed, 0 ignored; no SKIPPED messages. This includes gpu_static_sampler_word_from_s_brev and the CPU constant-detection test.

Not tested: whole workspace, retail title or main/PR smoke comparison; this result does not establish a title rendering or loading improvement.

AI use: OpenAI Codex (GPT-6; exact variant unavailable) configured the tools, ran the test, and drafted this report.

**@⁠Lum7nt** on GitHub · 2026-11-25 12:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7163127194) **AMD hardware test** on clean head `253bc79d0b46f7a58945c9aa0b3e03cb132ba13b`: Windows 11 build 26300, Radeon RX 9070 XT (driver `32.0.32029.2010`), Rust 1.100.0 MSVC, DXC/DXIL 1.9.2609.5. Set `XCL_ADAPTER=9070 XT` and `XCL_REQUIRE_GPU=1`, then ran: `cargo test --offline --locked --release -p xcl --lib static_sampler -- --nocapture --test-threads=1` Result: **4 passed, 0 failed, 0 ignored; no SKIPPED messages**. This includes `gpu_static_sampler_word_from_s_brev` and the CPU constant-detection test. Not tested: whole workspace, retail title or main/PR smoke comparison; this result does not establish a title rendering or loading improvement. AI use: OpenAI Codex (GPT-6; exact variant unavailable) configured the tools, ran the test, and drafted this report.
Author
Owner

@⁠luckyteagirl on GitHub · 2026-11-25 13:01 UTC · original

Independent AMD verification of exact PR head 253bc79d0b46f7a58945c9aa0b3e03cb132ba13b on a Radeon RX 6800M, including the new s_brev_b32 static-sampler GPU fixture through both translation paths.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Debug cargo test --locked -p xcl --lib -j 2 static_sampler -- --test-threads=1 --show-output, with XCL_ADAPTER=6800M and XCL_REQUIRE_GPU=wave64. No runtime skips.

  • XCL_DIRECT_DXIL=1: 4 passed, 0 failed, 0 ignored. gpu_static_sampler_word_from_s_brev, the existing static-sampler GPU fixture, the non-GPU regression, and the DXIL static-sampler test all passed.
  • XCL_DIRECT_DXIL=0: 4 passed, 0 failed, 0 ignored on the same card. The new fixture samples the 4×4 texture through the static point sampler and checks the RGBA result in 64 lanes.

This adds RX 6800M coverage to the PR's NVIDIA result. I did not run the full workspace suite, a paired retail-title smoke, or inspect a title image on this head. The PR's own 60-second smoke pair is on NVIDIA; this report only verifies the focused synthetic path on AMD.

AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows GPU filters, checked the logs and clean head, and drafted this report. No game data was used.

**@⁠luckyteagirl** on GitHub · 2026-11-25 13:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7163192076) Independent AMD verification of exact PR head `253bc79d0b46f7a58945c9aa0b3e03cb132ba13b` on a Radeon RX 6800M, including the new `s_brev_b32` static-sampler GPU fixture through both translation paths. **Environment:** Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver `30.0.13002.13003`; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. Debug `cargo test --locked -p xcl --lib -j 2 static_sampler -- --test-threads=1 --show-output`, with `XCL_ADAPTER=6800M` and `XCL_REQUIRE_GPU=wave64`. No runtime skips. - `XCL_DIRECT_DXIL=1`: **4 passed, 0 failed, 0 ignored**. `gpu_static_sampler_word_from_s_brev`, the existing static-sampler GPU fixture, the non-GPU regression, and the DXIL static-sampler test all passed. - `XCL_DIRECT_DXIL=0`: **4 passed, 0 failed, 0 ignored** on the same card. The new fixture samples the 4×4 texture through the static point sampler and checks the RGBA result in 64 lanes. This adds RX 6800M coverage to the PR's NVIDIA result. I did not run the full workspace suite, a paired retail-title smoke, or inspect a title image on this head. The PR's own 60-second smoke pair is on NVIDIA; this report only verifies the focused synthetic path on AMD. **AI use:** OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows GPU filters, checked the logs and clean head, and drafted this report. No game data was used.
Author
Owner

@⁠Aniseto on GitHub · 2026-11-25 13:08 UTC · original

Ran the static-sampler tests at 253bc79 (clean head, base 1a0bbe3):

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib -- static_sampler -- --test-threads=1
4 passed; 0 failed; 0 ignored; 1122 filtered out      (exit 0)

All four pass here, including the two new ones:

  • static_sampler_word_from_s_brev_is_a_constant
  • gpu_static_sampler_word_from_s_brev

together with gpu_static_samplers_from_constants_in_code and ps_get_lod_with_a_static_sampler. The GPU tests run on the real adapter, so s_brev_b32 of a constant is recognised on this part too.

What this adds: the author's run was an Ampere RTX 3060 Ti (debug), and the AMD report in the thread is an RX 9070 XT (release); this is a Blackwell wave32 NVIDIA part on driver 32.0.16.2124, debug profile, single-threaded.

Not tested: native wave64, RDNA2/RDNA3 and Intel GPUs, Wine, release profile, retail titles.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-11-25 13:08 UTC · [original](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7163353283) Ran the static-sampler tests at `253bc79` (clean head, base `1a0bbe3`): Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. ``` XCL_ADAPTER=nvidia cargo test -p xcl --lib -- static_sampler -- --test-threads=1 4 passed; 0 failed; 0 ignored; 1122 filtered out (exit 0) ``` All four pass here, including the two new ones: - `static_sampler_word_from_s_brev_is_a_constant` - `gpu_static_sampler_word_from_s_brev` together with `gpu_static_samplers_from_constants_in_code` and `ps_get_lod_with_a_static_sampler`. The GPU tests run on the real adapter, so `s_brev_b32` of a constant is recognised on this part too. What this adds: the author's run was an Ampere RTX 3060 Ti (debug), and the AMD report in the thread is an RX 9070 XT (release); this is a Blackwell wave32 NVIDIA part on driver 32.0.16.2124, debug profile, single-threaded. Not tested: native wave64, RDNA2/RDNA3 and Intel GPUs, Wine, release profile, retail titles. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-25 15:13 UTC · original

Independent Windows test of 253bc79d0b46f7a58945c9aa0b3e03cb132ba13b. The new bit-reversed static sampler fixture picked the expected texel across all 64 logical lanes through both shader translation paths on Radeon integrated graphics and RTX 5090.

Tested

  • Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Radeon integrated graphics (32.0.21042.62), RTX 5090 (32.0.16.1742), Rust 1.100.0 x64 MSVC, Windows SDK DXC/DXIL 1.8.2502.11. Unoptimized test profile.
  • With the default translation path, ran cargo test --locked -p xcl --lib static_sampler -- --nocapture --test-threads=1 on each selected adapter. Each run reported 4 passed, 0 failed, 0 ignored, and no logged skips.
  • With XCL_DIRECT_DXIL=1, ran cargo test --locked -p xcl --lib gpu_static_sampler_word_from_s_brev -- --nocapture --test-threads=1 on each adapter. Each run reported 1 passed, 0 failed, 0 ignored, and no logged skips.

Not tested

Parent revision, retail titles, or the full workspace suite.

AI use

OpenAI Codex (GPT-6.2 Sol) ran the tests, verified the results, and wrote this report.

**@⁠nnonno91** on GitHub · 2026-11-25 15:13 UTC · [original](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7166495753) Independent Windows test of `253bc79d0b46f7a58945c9aa0b3e03cb132ba13b`. The new bit-reversed static sampler fixture picked the expected texel across all 64 logical lanes through both shader translation paths on Radeon integrated graphics and RTX 5090. **Tested** - Windows 11 25H2 (26200.9974), Ryzen 7 9800X3D, Radeon integrated graphics (32.0.21042.62), RTX 5090 (32.0.16.1742), Rust 1.100.0 x64 MSVC, Windows SDK DXC/DXIL 1.8.2502.11. Unoptimized test profile. - With the default translation path, ran `cargo test --locked -p xcl --lib static_sampler -- --nocapture --test-threads=1` on each selected adapter. Each run reported 4 passed, 0 failed, 0 ignored, and no logged skips. - With `XCL_DIRECT_DXIL=1`, ran `cargo test --locked -p xcl --lib gpu_static_sampler_word_from_s_brev -- --nocapture --test-threads=1` on each adapter. Each run reported 1 passed, 0 failed, 0 ignored, and no logged skips. **Not tested** Parent revision, retail titles, or the full workspace suite. **AI use** OpenAI Codex (GPT-6.2 Sol) ran the tests, verified the results, and wrote this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 17:17 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 17:17 UTC · [original](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7169290736) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.