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

Merged
Prime1997 merged 1 commit from upstream-pr/2290 into main 2026-11-25 18:17:10 +00:00
Prime1997 commented 2026-11-25 12:29:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Prime1997 on 2026-11-25T12:29:35Z.


Requested by Prime

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

<!-- greyfinch-sync:ivall/xcl:issue:5491340155 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2290). Originally posted by [Prime1997](https://github.com/Prime1997) on 2026-11-25T12:29:35Z. --- <!-- claude-projects-attribution: {"github_login":"Prime1997"} --> _Requested by **Prime**_ `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)
Lum7nt commented 2026-11-25 13:05:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lum7nt on 2026-11-25T12:59:05Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7163127194 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7163127194). Originally posted by [Lum7nt](https://github.com/Lum7nt) on 2026-11-25T12:59:05Z. --- **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.
luckyteagirl commented 2026-11-25 13:05:20 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-25T13:01:50Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7163192076 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7163192076). Originally posted by [luckyteagirl](https://github.com/luckyteagirl) on 2026-11-25T13:01:50Z. --- 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.
Aniseto commented 2026-11-25 14:09:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-25T13:08:40Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7163353283 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7163353283). Originally posted by [Aniseto](https://github.com/Aniseto) on 2026-11-25T13:08:40Z. --- 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.
nnonno91 commented 2026-11-25 16:12:02 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by nnonno91 on 2026-11-25T15:13:21Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7166495753 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7166495753). Originally posted by [nnonno91](https://github.com/nnonno91) on 2026-11-25T15:13:21Z. --- 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.
DavidM1911 commented 2026-11-25 18:04:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T17:17:39Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7169290736 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2290#issuecomment-7169290736). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T17:17:39Z. --- 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!
upstream-sync closed this pull request 2026-11-25 19:08:05 +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!2280
No description provided.