Repository navigation
Description
The range check the recompiler emits for buffer accesses does not follow the descriptor's OOB_SELECT mode. For a descriptor with a stride it only tests index < num_records, so a store whose byte offset is at or past the stride is performed on the PC where the console drops it. Since a memory window is one UAV here, such a store lands on whatever title data follows the element.
Found by reading the code against the public GFX10 rule. I have not seen a title do this: I looked for it in one retail title's shaders and found no store that depends on it (details at the end). I am reporting it because the check is weaker than the hardware's in the direction that writes memory.
The hardware rule
Mesa documents it in src/amd/common/ac_descriptors.c, in ac_set_buf_desc_word3, for GFX10 (the generation of the console's GPU). Paraphrased:
OOB_SELECT |
out of range when |
|---|---|
| 0 | index >= NUM_RECORDS or offset >= STRIDE |
| 1 | index >= NUM_RECORDS |
| 2 | NUM_RECORDS == 0 |
| 3 | offset >= NUM_RECORDS (or the swizzled address, with swizzle on) |
GFX11 adds the access size to modes 0 and 3; the GFX10 text has no size term.
What XCL does (main 8b957bec)
gpu/desc.rs:700,buffer_words: the descriptors XCL builds itself carry mode 3 for raw buffers (stride 0) and mode 0 for everything else.gpu/recomp/emit.rs:2148, thein_rangeclosure inmubuf:stride == 0 ? off + bytes <= num_records : index < num_records. The same rule is used for byte and short forms, format stores and the atomics (buffer_atomic), and in the direct DXIL backend (gpu/dxil/lower_mem.rs:1263).- No shader path reads bits 29:28 of word 3.
SOFFSETis added to the address and is not part of the check.
Where the two differ
| case | console | XCL |
|---|---|---|
mode 0, index in range, offset >= stride |
dropped | stored, in the next element or past the end for the last one |
| title-written descriptor, mode 3 with a stride | checked by byte offset | checked by index, so up to (stride - 1) * num_records bytes too far |
| title-written descriptor, mode 2 | only num_records == 0 fails |
checked by index or offset, so valid accesses can be dropped |
| title-written descriptor, mode 1 with stride 0 | checked by index | checked by offset |
raw access where SOFFSET pushes the address past num_records |
not settled (see below) | stored |
The first row is the one that XCL can hit with its own descriptors: it writes "mode 0" into word 3 and then does not apply the offset half of mode 0.
Not settled
- Whether
SOFFSETcounts towardoffseton GFX10. The Mesa comment does not say. - Whether a multi-dword store that starts below the stride and ends past it is split or dropped as a whole on GFX10.
- What
offsetmeans in mode 3 when the descriptor has a stride and no swizzle.
A possible fix
Read (word3 >> 28) & 3 in the emitted check and apply the table above, in one helper shared by both backends, leaving SOFFSET as it is until the hardware behaviour is known. I have not written it: constant-buffer loads by byte offset go through stride-16 descriptors (cbv_words) and would be dropped under a strict mode 0, so the descriptors XCL builds may need mode 1 where the title addresses by byte offset. That needs someone who knows which modes the console's own views use.
What I checked in a title
In the retail title of #505 I decoded all 26,503 shader records of the pack and looked for stores at 12-byte spacing inside a 0x40-byte element, for an unrelated memory-corruption hunt. None of the title's shaders, in any stage, has that shape, so this report is not the explanation of that corruption. I did not check every store of the title against the offset-versus-stride rule.
Related: #1893 (wraparound in the raw-buffer check), #1241, #1737, #2325.
AI use: Claude Code with Claude Fable 5.2 and Anthropic subagents (Claude Opus 5.5, Claude Sonnet 5.5) helped developing with the supervision of @tiagonleal.
Activity
ending3729 commentedon Nov 27, 2026
I have a minimal fix + GPU regression test for
#2954ready on a clean branch based onorigin/main(f9a0cb80f9decb41d6f6315f6cf4e06270ba2bda):5 files changed, 309 insertions(+), 50 deletions(-))https://github.com/ending3729/xcl.git(recompiler-oob-select)What changed
crates/xcl/src/gpu/recomp/emit.rs): Added sharedOOB_SELECT(SRSRCword3[29:28]) range checks (emit_buffer_oob/buffer_in_range) acrossmubuf,buffer_atomic, andmubuf_d16, honoring all four GFX10/RDNA2 modes:0:index < num_records && off + bytes <= stride(per-dword for multi-dword ops, wrap-safe)1:index < num_records2:num_records != 03(unswizzled):off + soffset + bytes <= num_records(wrap-safe;index * strideshifts EA only)crates/xcl/src/gpu/dxil/lower_mem.rs): Implemented the matching wrap-safe 32-bitOOB_SELECThelpers (buffer_oob/buffer_in_range) inmubuf(including D16, small, and format ops) andbuffer_atomic.crates/xcl/src/gpu/desc.rs): Switchedcbv_wordsfromOOB_SELECT = 0toOOB_SELECT = 1(1 << 28) so byte-offset CBV loads past 16 bytes remain valid while row-indexed loads stay bounded bynum_records.crates/xcl/src/gpu/recomp/tests.rs,crates/xcl/src/gpu/dxil/core_tests.rs,crates/xcl/src/gpu/desc.rs): Addedgpu_mubuf_oob_select_modescovering modes0..=3,DWORD/DWORDX4, atomics,BYTE/SHORT_D16_HI,MUBUF/MTBUFformat stores,cbv_words, Mode 3SOFFSET, and 32-bit offset wraparound across both HLSL and Direct DXIL with 1 and 2 memory windows; updated legacy raw-buffer (stride = 0) test descriptors fromword3[29:28] = 0to3 << 28.s_buffer_load_*(SMEM),ld_rawaddress clamping (#1241), and swizzled V#s (#2325).Local verification
26100, Ryzen 57500F, AMD Radeon RX 6600 XT (8 GB, RDNA2, driver32.0.21045.29003, nativewave64+ mesh shaders),rustc 1.100.0, DXC1.9.2602.17.cbv_is_float4_rowsandgpu_mubuf_oob_select_modesboth failed before the fix and pass after.cargo test --workspace --no-fail-fast -- --test-threads=4(38 targets):XCL_REQUIRE_GPU=wave64,mesh:1462 passed; 3 failed; 47 ignored(6#1426skips;0wave64/mesh skips;xcl --lib=1334 passed; 2 failed; 27 ignored, exact+1overf9a0cb80).XCL_REQUIRE_GPUunset):1464 passed; 1 failed; 47 ignored(8skips;xcl --lib=1335 passed; 1 failed; 27 ignored).origin/mainf9a0cb80:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1, plus (underXCL_REQUIRE_GPUonly)shaders::tests::pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode disabled,0x887A002D) andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).cargo build --release --workspacepasses;0new Clippy warnings in touched lines.Request for paired retail
scripts/smoke.ps1runI do not have a retail Xbox Series title unpacked locally to produce the paired
xcl-smoke v1blocks required byscripts/pr_check.py. If an independent runner with a retail title can runscripts/smoke.ps1on clean basef9a0cb80f9decb41d6f6315f6cf4e06270ba2bdaand clean headb6909154e5682254d16209bdb3279a1e8b875ba1and post the two rawxcl-smoke v1blocks here, I will open the PR immediately (crediting the runner under Tested / Regression run).To make testing easy without modifying your local branches (from an
xclcheckout with a clean working tree):AI use
gpu_mubuf_oob_select_modes, ran the local test suite on RX 6600 XT, and drafted this comment; human reviewed the plan, test results, and diff.thehollowedone commentedon Nov 28, 2026
I checked the candidate commit against AMD's RDNA2 ISA, Table 35 and note 1. One formatted-load case needs a correction before the paired smoke run.
For a valid
32_FLOATbuffer descriptor withOOB_SELECT=0,STRIDE=16,NUM_RECORDS=1,index=0,offset=16, andDST_SEL_X=SEL_1,BUFFER_LOAD_FORMAT_Xis out of range, but its selected X result is 1.0f (0x3f800000). The RDNA2 guide explicitly exemptsSEL_1components from the usual zero result for an out-of-range read. On this commit, the new predicate is false and both HLSL emission and Direct DXIL lowering select a final zero after applyingDST_SEL. The previous index-only check happened to retain 1.0f for this mode-0 case because it missed the offset bound. The new test uses ordinary component selectors, so it does not distinguish this behavior.The range failure should zero the fetched/decoded components before
DST_SEL;SEL_1must still select its constant. Keep format validity separate, and apply the same ordering to the D16 format-load paths before packing. A focused regression with the descriptor above should expect0x3f800000in both translated backends; pair it withDST_SEL_X=SEL_0expecting zero. A native RDNA2 comparison would also check the guide against hardware.This is a source and specification check. I have not run the candidate or a GPU test. AI use: Codex (GPT-6.2 Sol) checked the candidate and drafted this finding; Codex (GPT-6.2 Astra) independently traced the selector paths.
ending3729 commentedon Nov 28, 2026
@thehollowedone confirmed your RDNA2 ISA Table 35 Note 1 finding against both
FormatLoadtranslators and updated the candidate branch rebased ontomain(e429936c10a5b8aa09470ff99dfc8c8d3d8c56fd):recompiler-oob-select,5 files changed, 387 insertions(+), 62 deletions(-))Fix in
FormatLoadcrates/xcl/src/gpu/recomp/emit.rs): Separated format validity (bool {t}_ok = ({t}_info & 7u) != 0u;) from theOOB_SELECTrange check (bool {t}_in = ...), zeroing the decoded component vector{t}_cwhen!{t}_inbeforedst_sel(and before D16 conversion/packing).crates/xcl/src/gpu/dxil/lower_mem.rs): Applied the same ordering across all threeBufKind::FormatLoadpaths (single_comp,num_comp < 4,num_comp == 4, includingD16and_HI_Xlow-half preservation) by zeroing the decoded component value(s) withrngprior toDST_SELwhile keepingdesc.hason the outside soBUF_FMT_INVALID(fmt = 0) still yields0. Zeroing after component decode (rather than raw bytes) also preventsSEL_Won a 1-component format such as32_FLOATfrom leaking1.0fwhen out of range.Verification (RX 6600 XT — translated HLSL & Direct DXIL)
(Note: local GPU tests validate XCL's translated HLSL and Direct DXIL execution on RX 6600 XT, not raw native RDNA2 ISA execution.)
gpu_mubuf_oob_format_dst_sel):hlsl: x sel1 (v10)(left: 0, right: 1065353216/0x3F800000) withOOB_SELECT=0, STRIDE=16, NUM_RECORDS=1, index=0, OFFSET=16, DST_SEL_X=SEL_1.aae26728):cbv_is_float4_rows,gpu_mubuf_oob_select_modes,gpu_mubuf_oob_format_dst_sel(coveringX/XY/XYZW,D16_X/D16_HI_X/D16_XY/D16_XYZW,TBUFFER_LOAD_FORMAT_X,32_UINTSEL_1->1,SEL_0->0,SEL_Won32_FLOATOOB ->0, andBUF_FMT_INVALID->0on both HLSL and Direct DXIL),gpu_typed_buffer_loads_and_stores,buffer_format_d16_packs_and_unpacks_halves, andsubmit_marking_calls_out_unlocked_and_revalidates_the_queue_markerall pass (6 passed; 0 failed).cargo test --workspace --no-fail-fast -- --test-threads=4(40 targets, Windows 11 Build26100, Ryzen 57500F, RX 6600 XT driver32.0.21045.29003,rustc 1.100.0, DXC1.9.2602.17):XCL_REQUIRE_GPUunset):2129 passed; 9 failed; 48 ignored(8SKIPPEDlines: 6#1426f16/f32 skips +pso_measurement_compiles_an_exact_synthetic_record[Developer Mode off] +heap_window_out_of_memory_falls_back_to_the_switch_form[no heap windows]). Every one of those failures reproduces on unmodifiedorigin/maine429936c(fuzz_validate_and_gpu_1,dispatch_chain_wave32_live_loops,dispatch_chain_oversized_loop_matches_whole,dispatch_chain_wave64_live_loops_and_exchange,gpu_heap_flat_reads_match_guarded_and_root_output,gpu_compute_mode_dispatch_abi,test_title_runs_and_game_folder_is_untouched,two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs).XCL_REQUIRE_GPU=wave64,mesh:2125 passed; 13 failed; 48 ignored(6#1426skips;0wave64/mesh skips; adds the 2 non-wave/mesh capability skips above plus 2 parallelalloc_pooltests that both pass when run in isolation and in the default run above).cargo build --workspaceandcargo build --release --workspaceboth exit0;cargo clippy -p xcl --all-targets --locked --no-depsshows0new warnings in any added or modified lines.Updated paired
scripts/smoke.ps1snippet (maine429936c-> fixaae26728)AI use
FormatLoadfix, addedgpu_mubuf_oob_format_dst_sel, rebased ontoe429936c, ran the local RX 6600 XT test suite and Clippy, and drafted this reply; human reviewed the test output and diff.Recompiler: honor OOB_SELECT in buffer range checks (xcl-dev#2954)