Recompiler: read shader rodata on sub-dword global/flat loads in HLSL and Direct DXIL #3368

Merged
Kalmarv merged 1 commit from upstream-pr/3368 into main 2026-12-01 22:07:21 +00:00
Kalmarv commented 2026-11-29 10:37:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T10:37:51Z.


What changed

  • crates/xcl/src/gpu/dxil/lower_mem.rs: pass rodata: bool into ld_raw_u32_guarded so flat sub-dword loads (global_load_ubyte, global_load_sbyte, global_load_ushort, global_load_sshort, global_load_short_d16, global_load_short_d16_hi, and the corresponding flat_load_* ops) route their aligned dword reads through rodata_loads before sub-dword shift/merge, while keeping mubuf callers on rodata = false.
  • crates/xcl/src/gpu/recomp/emit.rs: emit an xcl_gload_u32 helper in rodata_loader that combines xcl_gload2(a & ~3u) across aligned and unaligned byte offsets, and use it in flat sub-dword loads whenever shader .rodata is present.
  • crates/xcl/src/gpu/recomp/tests.rs: add subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil, covering HLSL codegen (with and without .rodata), Direct DXIL translation and validation (1-window and 2-window), and GPU execution across all six sub-dword load opcodes, aligned and unaligned 4-byte boundary crossings, .rodata hits, and non-rodata global memory on HLSL and Direct DXIL paths.

Why

Dword-wide global/flat loads (global_load_dword*, flat_load_dword*) already checked embedded shader .rodata (xcl_gload* in HLSL and rodata_loads in Direct DXIL) when reading constant tables placed after the shader program, because on PC those addresses are not backed by the shader binary in VRAM. Sub-dword global/flat loads (flat_small) bypassed that lookup and read ld_raw directly, returning wrong bytes whenever a shader indexed a byte or 16-bit constant table in .rodata (including unaligned 16-bit loads spanning two dwords).

Tested

Hardware: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), rustc 1.99.0, DXC 1.9.2609.5 (dxil 1.9.2609.5).

  • cargo check --workspace --all-targets: passed with 0 errors and 0 new warnings.
  • Targeted GPU tests (cargo test -p xcl --lib rodata_in_hlsl_and_direct_dxil gpu_loads_read_the_constant_data_after_the_program): 2 passed, 0 failed.
  • Full workspace test suite (cargo test --workspace -- --test-threads=4, GPU enabled): exited 0 (0 failed).
  • Release build (cargo build --release -p xcl): succeeded.
  • 150 s real-title smoke run on 8645f312c3c868b40f25774e3f0055f74db12123 (XCL_DIRECT_DXIL=all, XCL_HEAP_WINDOWS=1, XCL_DRED=1; 0 minidumps, 0 System display events):
xcl-smoke v1
commit: 8645f312c3c868b40f25774e3f0055f74db12123
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1587 (PresentX 1587)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 33496 MB
  • 150 s main ancestor baseline smoke run (f0e8fdd5c3942ddd399d5ee11384c8595c5aacff):
xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB

Not tested

  • AMD or Intel GPUs, native Wave64 hardware (RTX 5070 Ti runs split wave64), and titles beyond the single 150 s smoke title.
  • Sub-dword flat_load_* hitting LDS via the flat aperture (unchanged; rodata check only matches the shader binary's .rodata GPU VA range).

AI use

Used an AI coding assistant to audit lower_mem.rs and emit.rs, draft the fix and unit/GPU tests, and run the verification suite. All diffs, test assertions, and hardware results were reviewed and verified locally.

<!-- greyfinch-sync:ivall/xcl:issue:5549898200 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T10:37:51Z. --- **What changed** - `crates/xcl/src/gpu/dxil/lower_mem.rs`: pass `rodata: bool` into `ld_raw_u32_guarded` so `flat` sub-dword loads (`global_load_ubyte`, `global_load_sbyte`, `global_load_ushort`, `global_load_sshort`, `global_load_short_d16`, `global_load_short_d16_hi`, and the corresponding `flat_load_*` ops) route their aligned dword reads through `rodata_loads` before sub-dword shift/merge, while keeping `mubuf` callers on `rodata = false`. - `crates/xcl/src/gpu/recomp/emit.rs`: emit an `xcl_gload_u32` helper in `rodata_loader` that combines `xcl_gload2(a & ~3u)` across aligned and unaligned byte offsets, and use it in `flat` sub-dword loads whenever shader `.rodata` is present. - `crates/xcl/src/gpu/recomp/tests.rs`: add `subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil`, covering HLSL codegen (with and without `.rodata`), Direct DXIL translation and validation (1-window and 2-window), and GPU execution across all six sub-dword load opcodes, aligned and unaligned 4-byte boundary crossings, `.rodata` hits, and non-rodata global memory on HLSL and Direct DXIL paths. **Why** Dword-wide global/flat loads (`global_load_dword*`, `flat_load_dword*`) already checked embedded shader `.rodata` (`xcl_gload*` in HLSL and `rodata_loads` in Direct DXIL) when reading constant tables placed after the shader program, because on PC those addresses are not backed by the shader binary in VRAM. Sub-dword global/flat loads (`flat_small`) bypassed that lookup and read `ld_raw` directly, returning wrong bytes whenever a shader indexed a byte or 16-bit constant table in `.rodata` (including unaligned 16-bit loads spanning two dwords). **Tested** Hardware: NVIDIA GeForce RTX 5070 Ti (driver `32.0.16.1074`), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), `rustc 1.99.0`, DXC `1.9.2609.5` (`dxil 1.9.2609.5`). - `cargo check --workspace --all-targets`: passed with 0 errors and 0 new warnings. - Targeted GPU tests (`cargo test -p xcl --lib rodata_in_hlsl_and_direct_dxil gpu_loads_read_the_constant_data_after_the_program`): 2 passed, 0 failed. - Full workspace test suite (`cargo test --workspace -- --test-threads=4`, GPU enabled): exited 0 (0 failed). - Release build (`cargo build --release -p xcl`): succeeded. - 150 s real-title smoke run on `8645f312c3c868b40f25774e3f0055f74db12123` (`XCL_DIRECT_DXIL=all`, `XCL_HEAP_WINDOWS=1`, `XCL_DRED=1`; 0 minidumps, 0 System display events): ``` xcl-smoke v1 commit: 8645f312c3c868b40f25774e3f0055f74db12123 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1587 (PresentX 1587) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 33496 MB ``` - 150 s `main` ancestor baseline smoke run (`f0e8fdd5c3942ddd399d5ee11384c8595c5aacff`): ``` xcl-smoke v1 commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1695 (PresentX 1695) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31546 MB ``` **Not tested** - AMD or Intel GPUs, native Wave64 hardware (RTX 5070 Ti runs split wave64), and titles beyond the single 150 s smoke title. - Sub-dword `flat_load_*` hitting LDS via the flat aperture (unchanged; `rodata` check only matches the shader binary's `.rodata` GPU VA range). **AI use** Used an AI coding assistant to audit `lower_mem.rs` and `emit.rs`, draft the fix and unit/GPU tests, and run the verification suite. All diffs, test assertions, and hardware results were reviewed and verified locally.
tiagonleal commented 2026-11-30 03:55:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T03:55:11Z.


merge-check
base: f97120dc19
head: 8645f312c3
merge: clean
build: cargo build --workspace -> ok (also cargo build --release -p xcl)
tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2842 passed, 0 failed, 51 ignored; SKIPPED: 24 lines (22 no wave64, 2 no heap windows), the same as on the base; failing: none. Base alone on this PC: 2841 passed, 0 failed, 51 ignored. The new test gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil ran on this card (no SKIPPED line for it) and passed.
review: whole diff read (+122/-6, gpu/dxil/lower_mem.rs, gpu/recomp/emit.rs, the test). Byte and word global and flat loads now go through the embedded rodata in both backends, as the dword loads already did; before they read plain memory. Both backends take the two dwords from the aligned address and select the bytes little-endian, and each of the two dwords gets its own rodata range check, so a load at the end of the rodata window reads its upper bytes from memory in both. MUBUF and scratch loads are left alone. The test compiles and runs the HLSL and the direct DXIL explicitly, with 1 and 2 windows and with heap windows, so it covers both backends here. It does not depend on #3434.
performance: one extra branch per sub-dword global load, only in programs that have rodata. Measured with scripts/smoke.ps1, 60 s of a retail title, release: 1707 frames and 16127 MB peak commit against 1635 and 1680 frames, 15366 and 16673 MB on the base. No device removal, no crash.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite, tests and smoke and wrote this; Claude Opus 5.5 read the diff first, and I checked its main points in the merged source)

  • Tiago
<!-- greyfinch-sync:ivall/xcl:comment:7268310095 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7268310095). Originally posted by [tiagonleal](https://github.com/tiagonleal) on 2026-11-30T03:55:11Z. --- merge-check base: f97120dc196ca05e7f47e919d3675f7d5a2b478a head: 8645f312c3c868b40f25774e3f0055f74db12123 merge: clean build: cargo build --workspace -> ok (also `cargo build --release -p xcl`) tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2842 passed, 0 failed, 51 ignored; SKIPPED: 24 lines (22 `no wave64`, 2 `no heap windows`), the same as on the base; failing: none. Base alone on this PC: 2841 passed, 0 failed, 51 ignored. The new test `gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil` ran on this card (no `SKIPPED` line for it) and passed. review: whole diff read (+122/-6, `gpu/dxil/lower_mem.rs`, `gpu/recomp/emit.rs`, the test). Byte and word global and flat loads now go through the embedded rodata in both backends, as the dword loads already did; before they read plain memory. Both backends take the two dwords from the aligned address and select the bytes little-endian, and each of the two dwords gets its own rodata range check, so a load at the end of the rodata window reads its upper bytes from memory in both. MUBUF and scratch loads are left alone. The test compiles and runs the HLSL and the direct DXIL explicitly, with 1 and 2 windows and with heap windows, so it covers both backends here. It does not depend on #3434. performance: one extra branch per sub-dword global load, only in programs that have rodata. Measured with `scripts/smoke.ps1`, 60 s of a retail title, release: 1707 frames and 16127 MB peak commit against 1635 and 1680 frames, 15366 and 16673 MB on the base. No device removal, no crash. verdict: safe to merge hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite, tests and smoke and wrote this; Claude Opus 5.5 read the diff first, and I checked its main points in the merged source) - Tiago
Edgaras0404 commented 2026-11-30 13:11:26 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Edgaras0404 on 2026-11-30T13:11:26Z.


Tested

  • Hardware & OS: AMD Radeon RX 6700 XT (RDNA2, driver 32.0.21045.29003), AMD Ryzen 5 5600X 6-Core Processor, Windows 10 Pro 22H2 (build 19045)
  • Toolchain & build: rustc 1.100.1 (20ddd0171 2026-11-25), dxcompiler 1.9.2609.5 (01b62ad4) / dxil 1.9.2609.5, D3D12 Agility SDK, debug
  • Commits: PR #3368 head 8645f312 trial-merged onto main 9dfbe3ea (crates/xcl/src/gpu/dxil/lower_mem.rs, crates/xcl/src/gpu/recomp/emit.rs, crates/xcl/src/gpu/recomp/tests.rs: 3 files changed, 122 insertions(+), 6 deletions(-))
  • cargo test -p xcl --lib subdword -- --test-threads=1 --nocapture: 1 passed; 0 failed; 0 ignored; 0 measured; 2769 filtered out (0 SKIPPED — gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil ran on RX 6700 XT via DXC)
  • Single-threaded GPU module reruns (--test-threads=1):
    • cargo test -p xcl --lib gpu::dxil -- --test-threads=1: 305 passed; 2 failed; 3 ignored; 0 measured; 2460 filtered out (failures match main 9dfbe3ea baseline: gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu_direct_image_get_resinfo_d16)
    • cargo test -p xcl --lib gpu::recomp -- --test-threads=1: 521 passed; 3 failed; 21 ignored; 0 measured; 2225 filtered out (failures match main 9dfbe3ea baseline: f32_programs_on_the_gpu, gpu_f32_compares_with_nan, gpu_float_compares_random)
  • cargo test --workspace --no-fail-fast -- --test-threads=4:
    • All passing workspace binaries finished with 0 failed (including tests\gpu_compute_e2e.rs: 9 passed; 0 failed with SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; tests\console_shaders.rs: 3 passed; 0 failed; 4 ignored; tests\heap_probe.rs: 0 passed; 0 failed; 4 ignored; tests\xg_oracle.rs: 6 passed; 0 failed; 12 ignored).
    • tests\gpu_two_pass_cache_e2e.rs: 0 passed; 1 failed; 0 ignored (two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, pre-existing failure on main 9dfbe3ea).
    • -p xcl --lib (2770 tests): under --test-threads=4, exited abnormally after gpu::dxil::cfg::tests::loop_parents_of_a_loop_at_the_entry (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION); when rerun single-threaded above, gpu::dxil and gpu::recomp both completed with only the 5 pre-existing 9dfbe3ea failures.

Not tested

  • Remaining non-gpu::dxil/non-gpu::recomp -p xcl --lib tests on the merged tree (since -p xcl --lib exited early under --test-threads=4)
  • Opt-in XCL_HEAP_WINDOWS=1 tests
  • Release build and scripts/smoke.ps1
  • NVIDIA, Intel, RDNA3, and RDNA4 GPUs

AI use

  • Gemini formatted this test report from the author's directly run commands and outputs (no code or diffs written).
<!-- greyfinch-sync:ivall/xcl:comment:7279483860 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7279483860). Originally posted by [Edgaras0404](https://github.com/Edgaras0404) on 2026-11-30T13:11:26Z. --- **Tested** - **Hardware & OS:** AMD Radeon RX 6700 XT (RDNA2, driver `32.0.21045.29003`), AMD Ryzen 5 5600X 6-Core Processor, Windows 10 Pro 22H2 (build 19045) - **Toolchain & build:** `rustc 1.100.1 (20ddd0171 2026-11-25)`, `dxcompiler 1.9.2609.5` (`01b62ad4`) / `dxil 1.9.2609.5`, D3D12 Agility SDK, `debug` - **Commits:** PR `#3368` head `8645f312` trial-merged onto `main` `9dfbe3ea` (`crates/xcl/src/gpu/dxil/lower_mem.rs`, `crates/xcl/src/gpu/recomp/emit.rs`, `crates/xcl/src/gpu/recomp/tests.rs`: `3 files changed, 122 insertions(+), 6 deletions(-)`) - `cargo test -p xcl --lib subdword -- --test-threads=1 --nocapture`: `1 passed; 0 failed; 0 ignored; 0 measured; 2769 filtered out` (`0 SKIPPED` — `gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil` ran on RX 6700 XT via DXC) - Single-threaded GPU module reruns (`--test-threads=1`): - `cargo test -p xcl --lib gpu::dxil -- --test-threads=1`: `305 passed; 2 failed; 3 ignored; 0 measured; 2460 filtered out` (failures match `main` `9dfbe3ea` baseline: `gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form`, `gpu_direct_image_get_resinfo_d16`) - `cargo test -p xcl --lib gpu::recomp -- --test-threads=1`: `521 passed; 3 failed; 21 ignored; 0 measured; 2225 filtered out` (failures match `main` `9dfbe3ea` baseline: `f32_programs_on_the_gpu`, `gpu_f32_compares_with_nan`, `gpu_float_compares_random`) - `cargo test --workspace --no-fail-fast -- --test-threads=4`: - All passing workspace binaries finished with `0 failed` (including `tests\gpu_compute_e2e.rs`: `9 passed; 0 failed` with `SKIPPED heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`; `tests\console_shaders.rs`: `3 passed; 0 failed; 4 ignored`; `tests\heap_probe.rs`: `0 passed; 0 failed; 4 ignored`; `tests\xg_oracle.rs`: `6 passed; 0 failed; 12 ignored`). - `tests\gpu_two_pass_cache_e2e.rs`: `0 passed; 1 failed; 0 ignored` (`two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs`, pre-existing failure on `main` `9dfbe3ea`). - `-p xcl --lib` (`2770` tests): under `--test-threads=4`, exited abnormally after `gpu::dxil::cfg::tests::loop_parents_of_a_loop_at_the_entry` (`exit code: 0xc0000005, STATUS_ACCESS_VIOLATION`); when rerun single-threaded above, `gpu::dxil` and `gpu::recomp` both completed with only the 5 pre-existing `9dfbe3ea` failures. **Not tested** - Remaining non-`gpu::dxil`/non-`gpu::recomp` `-p xcl --lib` tests on the merged tree (since `-p xcl --lib` exited early under `--test-threads=4`) - Opt-in `XCL_HEAP_WINDOWS=1` tests - Release build and `scripts/smoke.ps1` - NVIDIA, Intel, RDNA3, and RDNA4 GPUs **AI use** - Gemini formatted this test report from the author's directly run commands and outputs (no code or diffs written).
saintwolf commented 2026-11-30 15:02:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:02:01Z.


merge-check claim
head: 8645f312c3

<!-- greyfinch-sync:ivall/xcl:comment:7282320843 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7282320843). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T15:02:01Z. --- merge-check claim head: 8645f312c3c868b40f25774e3f0055f74db12123
saintwolf commented 2026-11-30 15:16:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by saintwolf on 2026-11-30T15:16:36Z.


merge-check
base: 9dfbe3ea66
head: 8645f312c3
merge: clean (trial merge 6be33c1741cc1432b36f8b2325493bcf9506fd72; git diff --check clean; +122/-6 in crates/xcl/src/gpu/dxil/lower_mem.rs, crates/xcl/src/gpu/recomp/emit.rs, tests.rs)
build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files)
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (fails identically on base 9dfbe3ea, same "2D D16 resinfo clobbered v2/v3" assertion). The new test subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil ran and passed here (wave64 in split two-wave32 form, 1-window and 2-window, heap windows on and off, decoy bytes planted at the rodata offset in window 0).
review: read the whole diff and rodata_loads in the merged tree. Sub-dword global/flat loads (ubyte/sbyte/ushort/sshort/short_d16/short_d16_hi) now go through the embedded shader .rodata like the dword loads already did: in Direct DXIL, ld_raw_u32_guarded takes the loaded dword pair to rodata_loads only for the FLAT_GLBL path (the MUBUF and d16-store callers pass false, unchanged); rodata_loads range-checks each of the two dwords individually, so a load straddling the rodata window boundary reads its out-of-range dword from memory. In HLSL, the d16 global-load path uses a new xcl_gload_u32 (aligned xcl_gload2 + rotate, identical to ld_raw's unaligned extraction) only when a non-empty rodata blob exists; the test asserts xcl_gload_u32 is absent without rodata and present with it. The test's decoy bytes prove the values come from the rodata table, not the raw window. No unsafe, no new dependencies. #3434 (same author, straddling multi-dword rodata loads) is a distinct change that touches the same rodata_loader/lower_window region and will need a small rebase against this one, whichever lands second.
performance: none measurable beyond one extra branch per sub-dword global load in programs that have rodata; author's smoke pair 1707 vs 1635 frames.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B

<!-- greyfinch-sync:ivall/xcl:comment:7282727113 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7282727113). Originally posted by [saintwolf](https://github.com/saintwolf) on 2026-11-30T15:16:36Z. --- merge-check base: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b head: 8645f312c3c868b40f25774e3f0055f74db12123 merge: clean (trial merge 6be33c1741cc1432b36f8b2325493bcf9506fd72; git diff --check clean; +122/-6 in crates/xcl/src/gpu/dxil/lower_mem.rs, crates/xcl/src/gpu/recomp/emit.rs, tests.rs) build: cargo build --workspace -> ok (39 pre-existing warnings, none from the PR's files) tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2886 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 "no wave64" — wave32-only GPU, 2 "no heap windows", 1 "cannot disable the driver cache (Developer Mode)", 2 "no xgameruntime.dll"); failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, pre-existing on this machine (fails identically on base 9dfbe3ea, same "2D D16 resinfo clobbered v2/v3" assertion). The new test subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil ran and passed here (wave64 in split two-wave32 form, 1-window and 2-window, heap windows on and off, decoy bytes planted at the rodata offset in window 0). review: read the whole diff and rodata_loads in the merged tree. Sub-dword global/flat loads (ubyte/sbyte/ushort/sshort/short_d16/short_d16_hi) now go through the embedded shader .rodata like the dword loads already did: in Direct DXIL, ld_raw_u32_guarded takes the loaded dword pair to rodata_loads only for the FLAT_GLBL path (the MUBUF and d16-store callers pass false, unchanged); rodata_loads range-checks each of the two dwords individually, so a load straddling the rodata window boundary reads its out-of-range dword from memory. In HLSL, the d16 global-load path uses a new xcl_gload_u32 (aligned xcl_gload2 + rotate, identical to ld_raw's unaligned extraction) only when a non-empty rodata blob exists; the test asserts xcl_gload_u32 is absent without rodata and present with it. The test's decoy bytes prove the values come from the rodata table, not the raw window. No unsafe, no new dependencies. #3434 (same author, straddling multi-dword rodata loads) is a distinct change that touches the same rodata_loader/lower_window region and will need a small rebase against this one, whichever lands second. performance: none measurable beyond one extra branch per sub-dword global load in programs that have rodata; author's smoke pair 1707 vs 1635 frames. verdict: safe to merge hardware / tool and model: RTX 4070 SUPER (driver 32.0.16.2140), Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 / OpenCode, Qwen 3.8 27B
andresd-cerebras commented 2026-11-30 21:49:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andresd-cerebras on 2026-11-30T21:49:31Z.

Code review location: crates/xcl/src/gpu/recomp/emit.rs; line 5979

@@ -5975,6 +5976,7 @@ fn rodata_loader(rodata: &[(u32, Vec<u32>)], windows: bool) -> String {
     let inside = format!("{w0}({})", inside.join(" || "));
     let _ = writeln!(s, "uint2 xcl_gload2(uint a) {{ [branch] if ({inside}) {{ return uint2(xcl_gload(a), xcl_gload(a + 4u)); }} return mem.Load2(a); }}");
     let _ = writeln!(s, "uint4 xcl_gload4(uint a) {{ [branch] if ({inside}) {{ return uint4(xcl_gload(a), xcl_gload(a + 4u), xcl_gload(a + 8u), xcl_gload(a + 12u)); }} return mem.Load4(a); }}");
+    let _ = writeln!(s, "uint xcl_gload_u32(uint a) {{ uint b = a & ~3u; uint s = (a & 3u) * 8u; uint2 w = xcl_gload2(b); return select(s == 0u, w.x, (w.x >> s) | (w.y << ((32u - s) & 31u))); }}");

xcl_gload2(b) decides with only b: for an unaligned 16-bit load at at - 1 the second dword (at) is rodata, but inside is false for b = at - 4, so this reads it from mem, while Direct DXIL (rodata_loads) checks each dword and reads xcl_rodata. Suggest uint2 w = uint2(xcl_gload(b), xcl_gload(b + 4u));.

<!-- greyfinch-sync:ivall/xcl:review-comment:4745983352 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#discussion_r4745983352). Originally posted by [andresd-cerebras](https://github.com/andresd-cerebras) on 2026-11-30T21:49:31Z. **Code review location:** `crates/xcl/src/gpu/recomp/emit.rs`; line 5979 ~~~~diff @@ -5975,6 +5976,7 @@ fn rodata_loader(rodata: &[(u32, Vec<u32>)], windows: bool) -> String { let inside = format!("{w0}({})", inside.join(" || ")); let _ = writeln!(s, "uint2 xcl_gload2(uint a) {{ [branch] if ({inside}) {{ return uint2(xcl_gload(a), xcl_gload(a + 4u)); }} return mem.Load2(a); }}"); let _ = writeln!(s, "uint4 xcl_gload4(uint a) {{ [branch] if ({inside}) {{ return uint4(xcl_gload(a), xcl_gload(a + 4u), xcl_gload(a + 8u), xcl_gload(a + 12u)); }} return mem.Load4(a); }}"); + let _ = writeln!(s, "uint xcl_gload_u32(uint a) {{ uint b = a & ~3u; uint s = (a & 3u) * 8u; uint2 w = xcl_gload2(b); return select(s == 0u, w.x, (w.x >> s) | (w.y << ((32u - s) & 31u))); }}"); ~~~~ --- `xcl_gload2(b)` decides with only `b`: for an unaligned 16-bit load at `at - 1` the second dword (`at`) is rodata, but `inside` is false for `b = at - 4`, so this reads it from `mem`, while Direct DXIL (`rodata_loads`) checks each dword and reads `xcl_rodata`. Suggest `uint2 w = uint2(xcl_gload(b), xcl_gload(b + 4u));`.
andresd-cerebras commented 2026-11-30 21:49:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andresd-cerebras on 2026-11-30T21:49:31Z.

Code review location: crates/xcl/src/gpu/recomp/tests.rs; line 4994

@@ -4932,6 +4932,118 @@ fn gpu_loads_read_the_constant_data_after_the_program() {
     }
 }
 
+/// Sub-dword `global_load_*` instructions (`ubyte`, `sbyte`, `ushort`, `sshort`, `short_d16`,
+/// `short_d16_hi`, including unaligned 16-bit loads crossing a 4-byte boundary) read shader
+/// `.rodata` in both HLSL (`xcl_gload_u32`) and Direct DXIL (`rodata_loads`) while keeping
+/// non-code memory addresses on regular memory.
+#[test]
+fn subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil() {
+    use crate::gpu::dxil::{kernel, validate};
+
+    let body = |table: u32| {
+        prog(&[
+            ("S_GETPC_B64", "ENC_SOP1", &[("SDST", 0)], None), // s[0:1] = 4
+            ("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 255)], Some(table.wrapping_sub(4))),
+            ("S_ADDC_U32", "ENC_SOP2", &[("SDST", 1), ("SSRC0", 1), ("SSRC1", 128)], None),
+            // sub-dword loads from rodata at byte offset v10 (crossing a 4-byte boundary at v10=3,7,11)
+            ("GLOBAL_LOAD_UBYTE", "ENC_FLAT_GLBL", &[("VDST", 2), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None),
+            ("GLOBAL_LOAD_SBYTE", "ENC_FLAT_GLBL", &[("VDST", 3), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None),
+            ("GLOBAL_LOAD_USHORT", "ENC_FLAT_GLBL", &[("VDST", 4), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None),
+            ("GLOBAL_LOAD_SSHORT", "ENC_FLAT_GLBL", &[("VDST", 5), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None),
+            ("GLOBAL_LOAD_SHORT_D16", "ENC_FLAT_GLBL", &[("VDST", 6), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None),
+            ("GLOBAL_LOAD_SHORT_D16_HI", "ENC_FLAT_GLBL", &[("VDST", 7), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None),
+            // non-rodata memory load at v[12:13]
+            ("GLOBAL_LOAD_USHORT", "ENC_FLAT_GLBL", &[("VDST", 8), ("ADDR", 12), ("SADDR", 0x7D), ("OFFSET", 0)], None),
+        ])
+    };
+    let block = body(0).len() as u32 + 4;
+    let code = body(block + 4);
+    let table: [u32; 4] = [0x83_12_F0_05, 0x7F_A4_91_23, 0xC2_55_00_EE, 0x11_22_33_44];
+    let bytes: Vec<u8> = table.iter().flat_map(|w| w.to_le_bytes()).collect();
+    let mut data = vec![table.len() as u32];
+    data.extend_from_slice(&table);
+    let rodata = vec![(block, data)];
+
+    // Without rodata, HLSL must keep `ld_raw` and omit `xcl_gload_u32`.
+    let no_ro = translate(&code, &Options::default()).unwrap();
+    assert!(no_ro.complete(), "{:?}", no_ro.unsupported_why);
+    assert!(!no_ro.hlsl.contains("xcl_gload_u32"), "unexpected xcl_gload_u32 without rodata");
+    // With rodata, HLSL must emit `xcl_gload_u32` and Direct DXIL must translate (and validate when DXC is present).
+    let with_ro = translate(&code, &Options { rodata: rodata.clone(), ..Options::default() }).unwrap();
+    assert!(with_ro.complete(), "{:?}", with_ro.unsupported_why);
+    assert!(with_ro.hlsl.contains("xcl_gload_u32("), "expected xcl_gload_u32 in HLSL:\n{}", with_ro.hlsl);
+    for mw in [1u32, 2] {
+        let k = kernel::translate_entry_rodata(
+            &code,
+            kernel::KernelOptions { wave64: true, split: false, mem_windows: mw, sampler_base: 0 },
+            kernel::Entry::Kernel,
+            &rodata,
+        )
+        .expect("direct DXIL translate sub-dword rodata");
+        if super::dxc::location().is_ok() {
+            validate::validate(&k.dxil).expect("direct DXIL validate sub-dword rodata");
+        }
+    }
+
+    if !gpu_ready() {
+        return;
+    }
+
+    let check = |r: &runner::KernelResult, what: &str| {
+        for l in 0..64usize {
+            let off = l % 15; // exercises all alignments 0..3, including boundary crossings 3, 7, 11

All offsets stay inside the block, so the start/end straddles aren't covered. A lane at block - 1 would show the HLSL/DXIL mismatch above.

<!-- greyfinch-sync:ivall/xcl:review-comment:4745983369 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#discussion_r4745983369). Originally posted by [andresd-cerebras](https://github.com/andresd-cerebras) on 2026-11-30T21:49:31Z. **Code review location:** `crates/xcl/src/gpu/recomp/tests.rs`; line 4994 ~~~~diff @@ -4932,6 +4932,118 @@ fn gpu_loads_read_the_constant_data_after_the_program() { } } +/// Sub-dword `global_load_*` instructions (`ubyte`, `sbyte`, `ushort`, `sshort`, `short_d16`, +/// `short_d16_hi`, including unaligned 16-bit loads crossing a 4-byte boundary) read shader +/// `.rodata` in both HLSL (`xcl_gload_u32`) and Direct DXIL (`rodata_loads`) while keeping +/// non-code memory addresses on regular memory. +#[test] +fn subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil() { + use crate::gpu::dxil::{kernel, validate}; + + let body = |table: u32| { + prog(&[ + ("S_GETPC_B64", "ENC_SOP1", &[("SDST", 0)], None), // s[0:1] = 4 + ("S_ADD_U32", "ENC_SOP2", &[("SDST", 0), ("SSRC0", 0), ("SSRC1", 255)], Some(table.wrapping_sub(4))), + ("S_ADDC_U32", "ENC_SOP2", &[("SDST", 1), ("SSRC0", 1), ("SSRC1", 128)], None), + // sub-dword loads from rodata at byte offset v10 (crossing a 4-byte boundary at v10=3,7,11) + ("GLOBAL_LOAD_UBYTE", "ENC_FLAT_GLBL", &[("VDST", 2), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None), + ("GLOBAL_LOAD_SBYTE", "ENC_FLAT_GLBL", &[("VDST", 3), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None), + ("GLOBAL_LOAD_USHORT", "ENC_FLAT_GLBL", &[("VDST", 4), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None), + ("GLOBAL_LOAD_SSHORT", "ENC_FLAT_GLBL", &[("VDST", 5), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None), + ("GLOBAL_LOAD_SHORT_D16", "ENC_FLAT_GLBL", &[("VDST", 6), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None), + ("GLOBAL_LOAD_SHORT_D16_HI", "ENC_FLAT_GLBL", &[("VDST", 7), ("ADDR", 10), ("SADDR", 0), ("OFFSET", 0)], None), + // non-rodata memory load at v[12:13] + ("GLOBAL_LOAD_USHORT", "ENC_FLAT_GLBL", &[("VDST", 8), ("ADDR", 12), ("SADDR", 0x7D), ("OFFSET", 0)], None), + ]) + }; + let block = body(0).len() as u32 + 4; + let code = body(block + 4); + let table: [u32; 4] = [0x83_12_F0_05, 0x7F_A4_91_23, 0xC2_55_00_EE, 0x11_22_33_44]; + let bytes: Vec<u8> = table.iter().flat_map(|w| w.to_le_bytes()).collect(); + let mut data = vec![table.len() as u32]; + data.extend_from_slice(&table); + let rodata = vec![(block, data)]; + + // Without rodata, HLSL must keep `ld_raw` and omit `xcl_gload_u32`. + let no_ro = translate(&code, &Options::default()).unwrap(); + assert!(no_ro.complete(), "{:?}", no_ro.unsupported_why); + assert!(!no_ro.hlsl.contains("xcl_gload_u32"), "unexpected xcl_gload_u32 without rodata"); + // With rodata, HLSL must emit `xcl_gload_u32` and Direct DXIL must translate (and validate when DXC is present). + let with_ro = translate(&code, &Options { rodata: rodata.clone(), ..Options::default() }).unwrap(); + assert!(with_ro.complete(), "{:?}", with_ro.unsupported_why); + assert!(with_ro.hlsl.contains("xcl_gload_u32("), "expected xcl_gload_u32 in HLSL:\n{}", with_ro.hlsl); + for mw in [1u32, 2] { + let k = kernel::translate_entry_rodata( + &code, + kernel::KernelOptions { wave64: true, split: false, mem_windows: mw, sampler_base: 0 }, + kernel::Entry::Kernel, + &rodata, + ) + .expect("direct DXIL translate sub-dword rodata"); + if super::dxc::location().is_ok() { + validate::validate(&k.dxil).expect("direct DXIL validate sub-dword rodata"); + } + } + + if !gpu_ready() { + return; + } + + let check = |r: &runner::KernelResult, what: &str| { + for l in 0..64usize { + let off = l % 15; // exercises all alignments 0..3, including boundary crossings 3, 7, 11 ~~~~ --- All offsets stay inside the block, so the start/end straddles aren't covered. A lane at `block - 1` would show the HLSL/DXIL mismatch above.
andresd-cerebras commented 2026-11-30 21:49:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andresd-cerebras on 2026-11-30T21:49:31Z.

Review: COMMENTED


Withdrawn.

<!-- greyfinch-sync:ivall/xcl:review:6121174765 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#pullrequestreview-6121174765). Originally posted by [andresd-cerebras](https://github.com/andresd-cerebras) on 2026-11-30T21:49:31Z. **Review:** COMMENTED --- Withdrawn.
Foniass commented 2026-12-01 00:20:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T00:20:00Z.


merge-check
base: d0832e614f
head: 6232c2a006
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored (lib binary from a rerun of cargo test -p xcl --lib --no-fail-fast -- --test-threads=4: on the first full run it aborted with 0xc0000409 after a non-unwinding panic in thread xcl-pso-ahead-1 (windows-core interface.rs:41, misaligned pointer dereference); code the PR does not touch, not seen on the rerun, not checked on base); SKIPPED: 28 (22 "no wave64", 2 "no heap windows", 2 "no d3d12SDKLayers.dll", 1 "no D3D12 debug layer", 1 "cannot disable the driver cache (Developer Mode)"); failing: gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil, the PR's new test (does not exist on base), fails every run: "HLSL 2-window lane 0: ushort across the block's start edge, left: 1024, right: 1185"
review: read the whole diff. (1) The edge lanes added in this push expect, in the 2-window and heap-window runs, the memory bytes next to the rodata block from BEFORE/AFTER, planted at w0 + block - 4 (tests.rs:5047, assertion tests.rs:5015); with several windows a code address is in none of them, so both backends read 0 there. Probed on this GPU: HLSL 2-window, heap windows and Direct DXIL 2-window all return 0x0400 / 0x0011 for the start / end edge, 1-window returns the expected 0x04A1 / 0x0511 in both backends. The backends agree; the test's multi-window expectation is wrong and the test fails on any GPU that runs it (CI has no GPU and skips it). (2) The code is right: xcl_gload_u32 (emit.rs:5981) now looks up each of the two dwords on its own like rodata_loads, which fixes the start-edge HLSL/DXIL mismatch from the earlier review; MUBUF and d16-store callers keep rodata=false (lower_mem.rs:1304, 1321), only FLAT/GLOBAL loads pass true (lower_mem.rs:2021). (3) The PR description check fails: both smoke blocks and the Tested section are for the old head 8645f312; AI use does not name the tool or model; the description still says xcl_gload_u32 uses xcl_gload2. (4) Nits: commit prefix "recomp:" instead of "Recompiler:"; ubyte_d16/sbyte_d16/hi and non-global flat_load* are not exercised by the test. No retail title on this machine, so no smoke run.
performance: reasoned only: two rodata branch chains per sub-dword global/flat load, only in shaders that have rodata (replaces one Load4 + Load). No smoke run here (no retail title); the author's smoke pair is for the old head 8645f312, not this one.
verdict: not yet: the new GPU test fails at 6232c2a0 (wrong multi-window expectation for the bytes outside the block at a code address), and there is no smoke run for the current head (PR description check red)
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114 / 621.14), AMD Ryzen 7 7800X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0 MSVC, DXC 1.9.2602.17 / Claude Code, Claude Opus 5.5

<!-- greyfinch-sync:ivall/xcl:comment:7296211203 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7296211203). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T00:20:00Z. --- merge-check base: d0832e614fa7d6ae027bb4feb27ccb9121f54a8f head: 6232c2a006ce90723f880a813b719621ac372326 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2890 passed, 1 failed, 51 ignored (lib binary from a rerun of `cargo test -p xcl --lib --no-fail-fast -- --test-threads=4`: on the first full run it aborted with 0xc0000409 after a non-unwinding panic in thread `xcl-pso-ahead-1` (windows-core interface.rs:41, misaligned pointer dereference); code the PR does not touch, not seen on the rerun, not checked on base); SKIPPED: 28 (22 "no wave64", 2 "no heap windows", 2 "no d3d12SDKLayers.dll", 1 "no D3D12 debug layer", 1 "cannot disable the driver cache (Developer Mode)"); failing: gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil, the PR's new test (does not exist on base), fails every run: "HLSL 2-window lane 0: ushort across the block's start edge, left: 1024, right: 1185" review: read the whole diff. (1) The edge lanes added in this push expect, in the 2-window and heap-window runs, the memory bytes next to the rodata block from BEFORE/AFTER, planted at w0 + block - 4 (tests.rs:5047, assertion tests.rs:5015); with several windows a code address is in none of them, so both backends read 0 there. Probed on this GPU: HLSL 2-window, heap windows and Direct DXIL 2-window all return 0x0400 / 0x0011 for the start / end edge, 1-window returns the expected 0x04A1 / 0x0511 in both backends. The backends agree; the test's multi-window expectation is wrong and the test fails on any GPU that runs it (CI has no GPU and skips it). (2) The code is right: xcl_gload_u32 (emit.rs:5981) now looks up each of the two dwords on its own like rodata_loads, which fixes the start-edge HLSL/DXIL mismatch from the earlier review; MUBUF and d16-store callers keep rodata=false (lower_mem.rs:1304, 1321), only FLAT/GLOBAL loads pass true (lower_mem.rs:2021). (3) The PR description check fails: both smoke blocks and the Tested section are for the old head 8645f312; AI use does not name the tool or model; the description still says xcl_gload_u32 uses xcl_gload2. (4) Nits: commit prefix "recomp:" instead of "Recompiler:"; ubyte_d16/sbyte_d16/_hi and non-global flat_load_* are not exercised by the test. No retail title on this machine, so no smoke run. performance: reasoned only: two rodata branch chains per sub-dword global/flat load, only in shaders that have rodata (replaces one Load4 + Load). No smoke run here (no retail title); the author's smoke pair is for the old head 8645f312, not this one. verdict: not yet: the new GPU test fails at 6232c2a0 (wrong multi-window expectation for the bytes outside the block at a code address), and there is no smoke run for the current head (PR description check red) hardware / tool and model: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114 / 621.14), AMD Ryzen 7 7800X3D, Windows 11 Pro 10.0.26300, rustc 1.100.0 MSVC, DXC 1.9.2602.17 / Claude Code, Claude Opus 5.5
Foniass commented 2026-12-01 03:38:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:38:38Z.


Review (head 6232c2a0, diff read, not a merge-check: the PR description check fails, so not built or run here yet):

  • Depends on #3434's index fix. Direct DXIL ld_raw_u32_guarded (lower_mem.rs ~516) sends a sub-dword load at at-1..at-3 through main's rodata_loads, which for an aligned address of at-4 computes the second dword's index as 0x40000000+first, outside xcl_rodata (main lower_window.rs ~216-228; the bug #3434 fixes). That hits 16-bit loads one byte before a .rodata block, and the new test asserts exactly that case (even lanes, v11=3), so its result there depends on how the driver treats the bad index. It probably passes on NVIDIA and may read garbage on AMD. Real titles are unlikely to hit it (the bytes before .rodata are code). #3434 should merge first, and the two conflict in rodata_loader (adjacent lines).
  • PR description: the smoke block is on 8645f312, not the head 6232c2a0 (why the check fails). The What is in it and Regression run headings are missing, AI use names no tool or model, and the full-suite result has no counts. It says xcl_gload_u32 uses xcl_gload2, but the code calls xcl_gload twice.

Fine: the sub-dword handling is right (u8/i8/u16/i16 with sign extension, d16 hi/lo, the byte offset within the dword), and a load across the end of a block takes its last byte from the block and the next from memory. buffer_load_* is left alone on purpose, and the HLSL helper is only emitted when .rodata has data. The checks stay limited to programs with s_getpc_b64 (f80cc557). The test fails without the fix, covers both backends with one and two memory windows plus HLSL heap windows, and uses skip_test.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7299917469 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7299917469). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:38:38Z. --- Review (head 6232c2a0, diff read, not a merge-check: the `PR description` check fails, so not built or run here yet): - **Depends on #3434's index fix.** Direct DXIL `ld_raw_u32_guarded` (`lower_mem.rs` ~516) sends a sub-dword load at `at-1..at-3` through main's `rodata_loads`, which for an aligned address of `at-4` computes the second dword's index as `0x40000000+first`, outside `xcl_rodata` (main `lower_window.rs` ~216-228; the bug #3434 fixes). That hits 16-bit loads one byte before a `.rodata` block, and the new test asserts exactly that case (even lanes, `v11=3`), so its result there depends on how the driver treats the bad index. It probably passes on NVIDIA and may read garbage on AMD. Real titles are unlikely to hit it (the bytes before `.rodata` are code). #3434 should merge first, and the two conflict in `rodata_loader` (adjacent lines). - **PR description:** the smoke block is on 8645f312, not the head 6232c2a0 (why the check fails). The **What is in it** and **Regression run** headings are missing, AI use names no tool or model, and the full-suite result has no counts. It says `xcl_gload_u32` uses `xcl_gload2`, but the code calls `xcl_gload` twice. Fine: the sub-dword handling is right (u8/i8/u16/i16 with sign extension, d16 hi/lo, the byte offset within the dword), and a load across the end of a block takes its last byte from the block and the next from memory. `buffer_load_*` is left alone on purpose, and the HLSL helper is only emitted when `.rodata` has data. The checks stay limited to programs with `s_getpc_b64` (f80cc557). The test fails without the fix, covers both backends with one and two memory windows plus HLSL heap windows, and uses `skip_test`. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-01 15:57:30 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T15:57:30Z.


Test report (not a merge-check: PR description red)
base: b2b1f109d2
head: 6232c2a006
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 1 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7299917469, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: its own new test fails on this GPU: gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil panics at tests.rs ~5754, "HLSL 2-window lane 0: ushort across the block's start edge", left 1024, right 1185. Correction to an earlier version of this comment: the PR's code is right and the test's expectation is wrong. With several windows a code address reads 0 outside the block, by design, in both backends. Details, measurements and a test-only fix: https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7320289131. The rest of the suite passes, and the findings in my review stand
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7316798585 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7316798585). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T15:57:30Z. --- Test report (not a merge-check: `PR description` red) base: b2b1f109d27e746a62ec95b04dd1f9924452e682 head: 6232c2a006ce90723f880a813b719621ac372326 merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 1 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7299917469, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main. performance: no smoke run. assessment: its own new test fails on this GPU: `gpu::recomp::tests::subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil` panics at `tests.rs` ~5754, "HLSL 2-window lane 0: ushort across the block's start edge", left 1024, right 1185. Correction to an earlier version of this comment: the PR's code is right and the test's expectation is wrong. With several windows a code address reads 0 outside the block, by design, in both backends. Details, measurements and a test-only fix: https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7320289131. The rest of the suite passes, and the findings in my review stand hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 AI-written and posted by Foniass without a human check of each point.
Foniass commented 2026-12-01 18:02:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T18:02:03Z.


Follow-up to my test report (head 6232c2a0, merged onto main 6bfb5c51): the failing check is in the new test, not in the PR's code or in main.

  • Why it fails: in subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil, lane 0's ushort at block - 1 takes its low byte from the word just before the block. That address is a code address (s_getpc_b64, high dword 0xC0DE). With several memory windows a code address is in none of them, so it reads 0 by design (emit.rs ~2041-2049, lower_window.rs ~54-58). Main's own test relies on the same rule (tests.rs ~5650, "a code address is in none of them"). So the right value with 2 windows is 0x0400 for lane 0 and 0x0011 for lane 1. The test expects window 0's bytes beside the block (BEFORE / AFTER), which neither backend reads.
  • Measured here (RTX 5070 Ti, wave32): HLSL 1-window and Direct DXIL 1-window give 0x04A1 / 0x0511, as worked out by hand. HLSL 2-window, HLSL heap windows and Direct DXIL 2-window all give 0x0400 / 0x0011. Direct DXIL 2-window only looked fine in my report because the HLSL 2-window check panicked before it ran.
  • Suggested change (test only): expect 0 beside the block when there are several windows. The decoys stay in window 0, so the test still fails if a code address ever starts reading window 0:
-    let check = |r: &runner::KernelResult, what: &str| {
+    // `windows`: several memory windows, where a code address is in none of them, so the
+    // bytes beside the block read 0
+    let check = |r: &runner::KernelResult, what: &str, windows: bool| {
@@
-            let edge = if l % 2 == 0 { (BEFORE >> 24) | 0x0400 } else { (table[3] >> 24) | (AFTER & 0xFF) << 8 };
+            let (before, after) = if windows { (0, 0) } else { (BEFORE, AFTER) };
+            let edge = if l % 2 == 0 { (before >> 24) | 0x0400 } else { (table[3] >> 24) | (after & 0xFF) << 8 };
@@
-    check(&runner::run(&dxil_hlsl, &st, &mem).unwrap(), "HLSL 1-window");
+    check(&runner::run(&dxil_hlsl, &st, &mem).unwrap(), "HLSL 1-window", false);
@@
-    check(&runner::run(&k1.dxil, &st, &mem).unwrap(), "Direct DXIL 1-window");
+    check(&runner::run(&k1.dxil, &st, &mem).unwrap(), "Direct DXIL 1-window", false);
@@
-        check(&runner::run_in_arena(&dxil2, &st, &arena).unwrap(), if heap { "HLSL heap windows" } else { "HLSL 2-window" });
+        check(&runner::run_in_arena(&dxil2, &st, &arena).unwrap(), if heap { "HLSL heap windows" } else { "HLSL 2-window" }, true);
@@
-    check(&runner::run_in_arena(&k2.dxil, &st, &arena).unwrap(), "Direct DXIL 2-window");
+    check(&runner::run_in_arena(&k2.dxil, &st, &arena).unwrap(), "Direct DXIL 2-window", true);
  • With the change: the test passes 3 runs out of 3 on the merged tree, and cargo test -p xcl --lib gpu::recomp -- --test-threads=4 gives 530 passed, 0 failed, 21 ignored, with 21 SKIPPED (no wave64). With the PR's emit.rs / lower_mem.rs reset to main, the changed test still fails (first on the xcl_gload_u32 check, then on the GPU at HLSL 1-window lane 0 off 0: ubyte, 0 vs 5), so it still covers the fix. Not run on wave64 / AMD.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7320289131 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7320289131). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T18:02:03Z. --- Follow-up to my test report (head 6232c2a0, merged onto main 6bfb5c51): the failing check is in the new test, not in the PR's code or in main. - **Why it fails:** in `subdword_global_loads_read_rodata_in_hlsl_and_direct_dxil`, lane 0's ushort at `block - 1` takes its low byte from the word just before the block. That address is a code address (`s_getpc_b64`, high dword `0xC0DE`). With several memory windows a code address is in none of them, so it reads 0 by design (`emit.rs` ~2041-2049, `lower_window.rs` ~54-58). Main's own test relies on the same rule (`tests.rs` ~5650, "a code address is in none of them"). So the right value with 2 windows is 0x0400 for lane 0 and 0x0011 for lane 1. The test expects window 0's bytes beside the block (`BEFORE` / `AFTER`), which neither backend reads. - **Measured here (RTX 5070 Ti, wave32):** HLSL 1-window and Direct DXIL 1-window give 0x04A1 / 0x0511, as worked out by hand. HLSL 2-window, HLSL heap windows and Direct DXIL 2-window all give 0x0400 / 0x0011. Direct DXIL 2-window only looked fine in my report because the HLSL 2-window check panicked before it ran. - **Suggested change (test only):** expect 0 beside the block when there are several windows. The decoys stay in window 0, so the test still fails if a code address ever starts reading window 0: ```diff - let check = |r: &runner::KernelResult, what: &str| { + // `windows`: several memory windows, where a code address is in none of them, so the + // bytes beside the block read 0 + let check = |r: &runner::KernelResult, what: &str, windows: bool| { @@ - let edge = if l % 2 == 0 { (BEFORE >> 24) | 0x0400 } else { (table[3] >> 24) | (AFTER & 0xFF) << 8 }; + let (before, after) = if windows { (0, 0) } else { (BEFORE, AFTER) }; + let edge = if l % 2 == 0 { (before >> 24) | 0x0400 } else { (table[3] >> 24) | (after & 0xFF) << 8 }; @@ - check(&runner::run(&dxil_hlsl, &st, &mem).unwrap(), "HLSL 1-window"); + check(&runner::run(&dxil_hlsl, &st, &mem).unwrap(), "HLSL 1-window", false); @@ - check(&runner::run(&k1.dxil, &st, &mem).unwrap(), "Direct DXIL 1-window"); + check(&runner::run(&k1.dxil, &st, &mem).unwrap(), "Direct DXIL 1-window", false); @@ - check(&runner::run_in_arena(&dxil2, &st, &arena).unwrap(), if heap { "HLSL heap windows" } else { "HLSL 2-window" }); + check(&runner::run_in_arena(&dxil2, &st, &arena).unwrap(), if heap { "HLSL heap windows" } else { "HLSL 2-window" }, true); @@ - check(&runner::run_in_arena(&k2.dxil, &st, &arena).unwrap(), "Direct DXIL 2-window"); + check(&runner::run_in_arena(&k2.dxil, &st, &arena).unwrap(), "Direct DXIL 2-window", true); ``` - **With the change:** the test passes 3 runs out of 3 on the merged tree, and `cargo test -p xcl --lib gpu::recomp -- --test-threads=4` gives 530 passed, 0 failed, 21 ignored, with 21 SKIPPED (no wave64). With the PR's `emit.rs` / `lower_mem.rs` reset to main, the changed test still fails (first on the `xcl_gload_u32` check, then on the GPU at `HLSL 1-window lane 0 off 0: ubyte`, 0 vs 5), so it still covers the fix. Not run on wave64 / AMD. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Foniass commented 2026-12-01 19:12:56 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T19:12:56Z.


To get this merged without waiting on another round, I opened #3607: it carries your commit from this PR unchanged (same SHA, you stay the author) plus the one test-only commit from my follow-up above, with a full suite run and a smoke pair on that exact head. If you'd rather keep it here, pushing fb986aec from Foniass/xcl branch ready/3368 onto this branch (a fast-forward) gives the same result, and I'll close #3607.

AI-assisted: Claude Code (Claude Opus 5.5), posted by Foniass.

<!-- greyfinch-sync:ivall/xcl:comment:7322407247 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3368#issuecomment-7322407247). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T19:12:56Z. --- To get this merged without waiting on another round, I opened #3607: it carries your commit from this PR unchanged (same SHA, you stay the author) plus the one test-only commit from my follow-up above, with a full suite run and a smoke pair on that exact head. If you'd rather keep it here, pushing `fb986aec` from `Foniass/xcl` branch `ready/3368` onto this branch (a fast-forward) gives the same result, and I'll close #3607. AI-assisted: Claude Code (Claude Opus 5.5), posted by Foniass.
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!3368
No description provided.