Skip to content

Translator: scalar loads truncate and bound like RDNA2 hardware; raw buffer_load tail (SHADER-41) - #443

Merged
ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
shelbykb2:fix/smem-hw-bounds
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ProjectLeonida:mainfrom
shelbykb2:fix/smem-hw-bounds

Conversation

@shelbykb2

@shelbykb2 shelbykb2 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

What and why

SHADER-41 from #374 (claimed in #156): scalar loads and the raw vector-load tail, brought in line with what RDNA2 hardware does. #171 left these as "known remaining differences" in docs/design.md; this PR measures them properly and implements them.

What the translator did, and what hardware does

Case Hardware (RX 6800) Translator before
s_load* / s_buffer_load* with an unaligned base, register offset or immediate each of the three is truncated to a multiple of 4, then they are added added unaligned
s_buffer_load* past NUM_RECORDS that dword is 0 no bound: read whatever follows the buffer
s_load_dword sD, s[p:p+1], sOFF offset:-4 reads pointer + sOFF - 4 zero-extended the immediate: pointer + sOFF + 4 GiB - 4
raw buffer_load_dwordx4 whose tail crosses NUM_RECORDS the dwords that don't fit are 0 checked only the first byte, so the tail returned data

Rules, as measured

# s_buffer_load_dword / x2 / x4 / x8
limit = stride ? NUM_RECORDS * stride : NUM_RECORDS          # bytes
off   = (sOFF & ~3) + (IMM & ~3)                             # IMM unsigned
dword i = (off + 4*i + 4 > limit) ? 0 : mem32[(base & ~3) + off + 4*i]

# s_load_dword*: mem32[(ptr & ~3) + (sOFF & ~3) + (sext21(IMM) & ~3) + 4*i], no bound

# raw buffer_load_dword / x2 / x4 (stride 0, no idxen): O = inst_offset + soffset + offen, byte exact
dword i = (O + 4*i + 4 <= NUM_RECORDS) ? data : 0

Hardware measurement. AMD Radeon RX 6800 (gfx1030, not the console's gfx1013), the instructions run as raw compute kernels (the hw-oracle tool from the AnyPS5 project), wave32 and wave64: 155 runs, every result either 0 or the stored data, wave32 = wave64 in every dword. Rows that separate the rule from its neighbours:

Probe Result Rules out
s_buffer_load IMM 0x10, NUM_RECORDS 18 0 a check of the first byte only
IMM 0x13, NUM_RECORDS 21 the dword at +0x10 a bound on the untruncated offset
sOFF 0xe + IMM 2, NUM_RECORDS 16 the dword at +0xc truncating the sum instead of each term
x4 at 0xc, NUM_RECORDS 21 data, data, 0, 0 a whole-load check
stride 4, NUM_RECORDS 5: IMM 0x10 / 0x14 data / 0 ignoring the stride
stride 1, NUM_RECORDS 17: IMM 0x10 0 an index test
base & 3 = 3, IMM 0x13, NUM_RECORDS 20 data a bound that sees base & 3
s_load sOFF 8 + IMM -4 the dword at +4 zero-extension
s_load sOFF 0xb + IMM -1 the dword at +4 truncating the sum
buffer_load_dword at 0xf, NUM_RECORDS 18 0 a first-byte check
buffer_load_dwordx4 at 3, NUM_RECORDS 18 three data dwords, then 0 whole-load and per-dword start checks

For s_buffer_load*, OOB_SELECT (V# word3[29:28]) 0, 1, 2 and 3 gave the same pattern (7 probes per value).

How it is emitted. Each s_buffer_load dword gets its own structured if and an OpPhi with 0, so an out-of-range dword issues no load (reading past the buffer through a device address would be undefined on the host). s_load stays straight-line. buffer_load without idxen checks each dword (the raw rule when the stride is 0, the existing first-byte check otherwise); structured buffers and idxen loads keep their existing first-byte check, so their behaviour is unchanged though the emitted code is rearranged. Stores, atomics and buffer_load_format_* are untouched.

This makes s_buffer_load bigger. Function-body lines for one instruction: s_buffer_load_dword 23 → 38, x4 35 → 71, x8 53 → 127, x16 83 → 203; raw buffer_load_dwordx4 74 → 104. I have no game files, so I could not measure what that does to the corpus build size or time, or count how many shaders read past NUM_RECORDS. If the size matters more than the bound for shaders that never go out of range, that is a call for the maintainers; the per-dword branch is what avoids the out-of-range read.

The runtime now depends on NUM_RECORDS. A V# whose dword2 is 0 or too small now reads as zeros through s_buffer_load, as it does on hardware. One existing test (test_heap_base_is_added_once) built a V# with NUM_RECORDS 0 and is given a real size.

Not measured, and said so in docs/design.md:

  • s_load with a negative total offset (a negative immediate without a register offset included). The translator uses the 64-bit signed sum, which is an inference. I did not run it on hardware because it reads below the kernel's buffer.
  • x16, and buffer_load_dwordx3: they get the measured rule of their neighbours.
  • An s_buffer_load immediate with bit 20 set (llvm-mc rejects it).
  • OOB_SELECT for vector loads. The raw rule above was measured with OOB_SELECT 3. Two probes with OOB_SELECT 1 and 2 returned data past NUM_RECORDS, and OOB_SELECT 0 with stride 0 returned 0 at every offset. The translator ignores OOB_SELECT, as before; cs_bounds.asm builds its V# with word3 = 0 and expects data at offset 0. That is recorded as an observation and left alone: two probes are not enough to build a rule on.
  • gfx1013 itself.

Tests added

  • tests/semantic/test_scalar_mem_smem.py (SmemHardwareRuleTests) and tests/semantic/test_value_semantics.py (RawBufferTailBounds, MeasuredBoundsShaders): the measured rows, asserting both the values and the exact addresses loaded, plus guards that the unchanged paths are unchanged.
  • Four GPU tests, cs_smem_bounds, cs_smem_stride_align, cs_smem_sload_neg, cs_buf_tail, in check.py and scripts/run_gpu_tests.py. Each builds its own V# and its header derives the expected words from the rules above. cs_smem_sload_neg must not be run with a translator from before this PR: there its first load goes 4 GiB past the heap.

Overlap: #421 (negative global_* offsets) touches the same lists in check.py, run_gpu_tests.py and tests/test_shader_checks.py. I will rebase whichever is left after the first one lands.

Tested

AMD Radeon RX 6800, Windows 11, driver 26.11.2, branch at 32647a7 on main d937b7f:

Check Result
scripts/run_gpu_tests.py 62/62 passed
runtime/test/shaders/check.py 56 of 56 pass, 0 skipped
python -I -m unittest discover -s tests/semantic 460 OK
python -m pytest tests 1796 passed, 7 skipped, 1 xfailed
cs_smem_bounds, cs_smem_stride_align, cs_buf_tail on the GPU with main's translator all three FAIL (data where the rule gives 0, and untruncated addresses)
cs_smem_sload_neg with main's translator not run, for the reason above

Not tested: any GPU other than the RX 6800. The vector GPU rows use dword-aligned offsets only; the unaligned ones (offset 3, 0xf) are covered by the semantic tests, not on a Vulkan driver.

AI-assisted (Claude Code): written by an AI agent from the measured model, then reviewed and re-run by a second one on the hardware above.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (The "Scalar/buffer memory" and "Buffer bounds checking" rows.)

🤖 Generated with Claude Code

@shelbykb2
shelbykb2 force-pushed the fix/smem-hw-bounds branch 2 times, most recently from 5294f45 to 765b853 Compare November 22, 2026 00:32
@esteban-dcp

Copy link
Copy Markdown

Tested 765b853 on two GPUs, Linux 7.3.5 (CachyOS): pass.

  • NVIDIA RTX 4050 Laptop (Ada), driver 620.73.04, subgroup 32: 78 shaders: 78 translated, 78 pass spirv-val; 49/75 passed, 26 wave64 skipped; with LEONIDA_W64_EMULATE=1: 75/75 passed
  • AMD Radeon 740M (RDNA3, RADV, Mesa 26.3.1), subgroup 32..64: 75/75 passed
  • New cs_buf_tail (0 5eed000c 5eed0008 5eed000c 0 0 5eed0010 0) and cs_smem_bounds (0 5eed0010 5eed000c 0 5eed000c 5eed0010 0 0): PASS on all three runs
  • CPU: unittest discover -s tests/semantic 728 OK; tests/test_shader_checks.py OK

Ran python -I scripts/run_gpu_tests.py --build runtime/build/linux on the PR head as-is, with the test programs built from this branch, VK_LOADER_DRIVERS_SELECT pinning each GPU (device line checked in each run) and VK_LOADER_LAYERS_DISABLE=~implicit~. 0 failures.

@shelbykb2

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (91b36cf, which now includes #421); the branch is now 765b853. Conflict resolution only, in tests/semantic/README.md and tests/test_shader_checks.py. It also removes the stray conflict markers that are on main in tests/semantic/README.md (left from the #421 merge), keeping both bullets.

Re-run on AMD Radeon RX 6800, Windows 11, driver 26.11.2: run_gpu_tests.py 75/75 passed, check.py 68 of 68 pass, unittest discover -s tests/semantic OK, pytest tests 2564 passed, 9 skipped, 1 xfailed.

AI-assisted (Claude Code).

@kacper-serewis

Copy link
Copy Markdown
Contributor

Tested 765b853 on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200: pass.

Tools: llvm-mc 21.1.8 (WSL), Vulkan SDK 1.4.363.0, MSVC 19.50, Python 3.13.

@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Member

@shelbykb2 This is related to your buffer_address() change. I posted a finding in #374: the translator ignores the V# OOB_SELECT field. I measured all four modes on AMD hardware (RDNA3.5), and the results match Mesa's table bit for bit. Mesa gives separate rules for RDNA2.

I'd like to add the per-mode bounds check, but it touches the same function as this PR. Would you rather I build it on top of this branch after it lands, or should I send you a patch to include here? Either is fine with me; I don't want to conflict with your raw-tail work.

AI-assisted (Claude Code).

@shelbykb2

Copy link
Copy Markdown
Contributor Author

@AlxcBTW thanks for asking first. I'd rather you build the per-mode check on top of this once it lands than fold a patch in here: this PR is already large, and its raw-tail rule is only claimed for OOB_SELECT 3, so a per-mode check is a clean follow-up to it and not a correction. buffer_address() returns word3 already, so the mode is in reach there. If this PR sits unmerged for long and you'd prefer not to wait, basing your branch on fix/smem-hw-bounds with Depends on: #443 works for me too.

One thing that may save you a step: your measurement is RDNA3.5 and Mesa has separate RDNA2 rules. I have an RX 6800 (gfx1030) and the raw-kernel setup from this PR. So far I only have two RDNA2 probes for the vector path (OOB_SELECT 1 and 2 returned data past NUM_RECORDS at offset 0x28 with NUM_RECORDS 18; OOB_SELECT 0 with stride 0 returned 0 at every offset). If you post the rows you ran, I can run the same matrix on RDNA2 and put the words next to yours.

I'm rebasing this branch onto current main now; I'll post the new SHA when it's pushed.

AI-assisted (Claude Code).

@shelbykb2

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (067d3e8); the branch is now a0f6c71. Thanks @esteban-dcp and @kacper-serewis for the NVIDIA and RADV runs.

What changed in the rebase. Conflict resolution, plus one test change: 2e8101b made spirv_mini_interp.py raise on a PhysicalStorageBuffer access that is not 4-byte aligned, and three of this PR's RawBufferTailBounds tests load at the unaligned offsets that were measured on hardware. Those rows now set the base's low bits so that base + offset is aligned, keeping the measured offset / NUM_RECORDS pairs as they were (the bound only sees the offset); the one row measured with base & 3 = 3 at offset 3 uses offset 5 as a stand-in that still separates a bound that counts base & 3 from one that does not. The cost: the semantic tests now check the bound at unaligned offsets, not the data read there. The translator is unchanged from the previous head.

Tested on AMD Radeon RX 6800, Windows 11, driver 26.11.2, at this head: run_gpu_tests.py 105/105 passed; check.py 96 of 96 pass; unittest discover -s tests/semantic OK; pytest tests 3420 passed, 21 skipped, 1 xfailed.

Corpus numbers, which this PR's description said I could not give (my own copy of the 1.0.2.1 package, counts only, instructions / shaders):

s_buffer_load_dword* 1,398,820 / 24,803 (x1 628,343, x2 191,093, x4 447,761, x8 76,463, x16 55,160)
s_load_dword* 1,269,732 / 25,865
offset forms immediate only or register only. No instruction has a register offset plus an immediate, so the form #171 fixed is not in the corpus
immediates all multiples of 4, none negative, none ≥ 0x100000. So the truncation and the signed s_load immediate change nothing for a constant offset; they can only matter through a register offset (s_buffer_load 514,506, s_load 214,041), whose values I cannot see statically
raw buffer_load_dword* 561,480 / 17,867; 344,611 with idxen (unchanged path), 199,239 offen only, 13,955 with neither

What the per-dword bound costs on the whole corpus. All 26,503 shaders translate; 26,501 pass spirv-val, and the 2 that fail are the same 2 compute shaders that fail on main with "id bound is larger than the max id bound" (reported on #634), so this PR pushes no further shader over that limit. Total SPIR-V size grows by 5.0% against main at 4a36bb1 (a slightly older base, so a little of that is other merges): per shader the median is +5.1%, the 90th percentile +9.0%, the 99th +22.8%, the largest +33.1%. The sharded translate took about the same time (753 s against 792 s for main, 28 jobs). I have not measured pipeline compile time or run time.

So the trade-off I left to the maintainers is now a number: about 5% more SPIR-V, for a bound that hardware applies on 1.4 million scalar buffer loads. Whether any shader actually reads past NUM_RECORDS cannot be told from the code.

AI-assisted (Claude Code).

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested a0f6c716411e2e39ebc1b0d7ad2b868a1c26b3f1 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent Linux RTX 5090 check of a0f6c716411e2e39ebc1b0d7ad2b868a1c26b3f1, NVIDIA driver 595.99.02. I rebuilt the runtime at this head and ran the four synthetic load fixtures individually through the stock GPU runner in its default mode. All four translated, passed SPIR-V validation, and matched their eight-word GPU readbacks (4/4 passed, zero skips).

Fixture Readback words, hex
cs_buf_tail 0 5eed000c 5eed0008 5eed000c 0 0 5eed0010 0
cs_smem_bounds 0 5eed0010 5eed000c 0 5eed000c 5eed0010 0 0
cs_smem_sload_neg 5eed0004 5eed0000 5eed0004 5eed0004 5eed0008 5eed000c eeeeeeee eeeeeeee
cs_smem_stride_align 5eed0010 0 0 5eed0000 5eed0000 5eed0000 5eed0000 5eed0004

This measures translated Vulkan execution on Blackwell. The run covered these four fixtures only and did not measure pipeline compilation or runtime cost. Synthetic inputs only. AI-assisted.

AI-assisted verification.

…_load imm, raw MUBUF per-dword tail

What was wrong (tools/rdna2spirv.py):
- s_load* / s_buffer_load* added base + soffset + imm unaligned; hardware truncates each of the three to a
  multiple of 4 before adding them.
- s_buffer_load* had no bound at all and read past NUM_RECORDS.
- s_load* zero-extended a negative immediate from 32 bits (soffset 8 + imm -4 read ptr + 4 GiB + 4).
- raw buffer_load_dword* checked only the start (offset < num_records), so a dword at NR-1..NR-3 and the tail
  of a multi-dword load returned data where hardware returns 0.

Hardware evidence: AMD Radeon RX 6800 (gfx1030, driver 32.0.21045.29003), raw compute kernels, wave32 and
wave64, 155 runs, every result 0 or the stored data, wave32 = wave64 in every dword. Decisive rows:
s_buffer_load imm 0x10 with NR 18 -> 0; imm 0x13 with NR 21 -> data@0x10; soffset 0xe + imm 2 with NR 16 ->
data@0xc; x4 at 0xc with NR 21 -> data, data, 0, 0; stride 4 with NR 5: 0x10 data, 0x14 0; stride 1 with NR 17:
0x10 -> 0; base & 3 = 1 with imm 3 -> data@0. s_load soffset 8 + imm -4 -> @4, soffset 0xb + imm -1 -> @4.
buffer_load_dword at 0xf with NR 18 -> 0; x4 at 3 with NR 18 -> d0..d2 data, d3 0.

Now: off = (soff & ~3) + (imm & ~3), dword i at (base & ~3) + off + 4i. s_buffer_load dword i is 0 and not
loaded (its own selection construct + OpPhi) when off + 4i + 4 > limit, limit = NR * stride or NR (stride 0).
s_load: imm sign-extended from 21 bits, 64-bit sum, no bound. Raw (stride 0, no idxen) buffer_load: dword i
loaded iff O + 4i + 4 <= NR. Structured, idxen, stores, atomics and format loads keep their old first-byte
check (not measured).

Inferred, not measured: s_load with soffset + imm < 0 (64-bit signed sum), s_buffer_load x16 and buffer_load
x3 (same rule), an s_buffer_load immediate with bit 20 set or negative. OOB_SELECT (V# word3[29:28]) changes
vector-load results on hardware (2 probes) and is recorded in docs/design.md, not modelled.

Tests: tests/semantic SmemHardwareRuleTests (evaluator follows branches/phis), RawBufferTailBounds and
MeasuredBoundsShaders assert values and the exact addresses read; 19 fail with main's translator. New GPU
tests cs_smem_bounds, cs_smem_stride_align, cs_smem_sload_neg, cs_buf_tail (expected words derived by hand
from the model) in check.py and scripts/run_gpu_tests.py. test_heap_base_is_added_once now gives its V# a
NUM_RECORDS (it had 0, which the measured bound turns into a load of nothing).

Tested on AMD Radeon RX 6800 / Windows / driver 26.11.2 (Vulkan), on main d937b7f: run_gpu_tests 62/62 passed;
check.py 56 of 56; unittest tests/semantic 460 OK; pytest 1796 passed, 7 skipped, 1 xfailed. The three new tests
that are safe to run with main's translator fail with it on the GPU; cs_smem_sload_neg was not run with it (it
would read 4 GiB past the heap). Indexed (idxen) buffer loads keep their single selection construct.

AI-assisted.

Rebased onto main 8df277f: since 2e8101b the semantic mini interpreter raises on a PhysicalStorageBuffer access that
is not 4-byte aligned, so RawBufferTailBounds rows that load at an unaligned O now set base_low so that base + O is
aligned (the bound sees only O, so the measured O / NR pairs are kept); the base & 3 = 3 row uses offset 5 as a
stand-in for the measured offset 3. Byte-exact data at an unaligned address is no longer asserted there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested a0f6c71 on NVIDIA GeForce RTX 5070 (subgroup 32), driver 621.24, Windows 11 Pro (26300), Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 (built with scripts/build_llvm_mc.ps1), scripts/run_gpu_tests.py:

  • native: 78/105 passed, 27 skipped (main 8df277f here: 64/91 passed, 27 skipped, all wave64 tests needing a 64-wide subgroup)
  • LEONIDA_W64_EMULATE=1: 105/105 passed (main here: 91/91)
  • python -m unittest discover -s tests/semantic: Ran 1040 tests in 318.850s OK

@esteban-dcp

Copy link
Copy Markdown

Tested a0f6c71 on two GPUs, Linux 7.3.5 (CachyOS): pass. Re-test of the rebased head (my earlier run was on 765b853).

  • NVIDIA RTX 4050 Laptop (Ada), driver 620.73.04, subgroup 32: 106 shaders: 106 translated, 106 pass spirv-val; 78/105 passed, 27 wave64 skipped; with LEONIDA_W64_EMULATE=1: 105/105 passed
  • AMD Radeon 740M (RDNA3, RADV, Mesa 26.3.1), subgroup 32..64: 105/105 passed
  • New cs_buf_tail and cs_smem_bounds: PASS on all three runs (cs_buf_tail cs_buf_tail 0x0 0x5eed000c 0x5eed0008 0x5eed000c 0x0 0x0 0x5eed0010 0x0; cs_smem_bounds cs_smem_bounds 0x0 0x5eed0010 0x5eed000c 0x0 0x5eed000c 0x5eed0010 0x0 0x0)
  • CPU: unittest discover -s tests/semantic 1040 OK; tests/test_shader_checks.py OK

python -I scripts/run_gpu_tests.py --build runtime/build/linux on the PR head, test programs built from this branch, VK_LOADER_DRIVERS_SELECT pinning each GPU (device line checked), VK_LOADER_LAYERS_DISABLE=~implicit~. 0 failures.

@shelbykb2

Copy link
Copy Markdown
Contributor Author

Rebased onto main 43d4703, now 87d7bf7 (only docs/design.md conflicted; behaviour unchanged). Re-run on AMD Radeon RX 6800, driver 26.11.2, Windows 11: run_gpu_tests.py 109/109, check.py 101 of 101, unittest discover -s tests/semantic OK (1082 tests), pytest tests 3600 passed, 26 skipped. The four SMEM/MUBUF entries in regen_fixtures.py now sit at the front of SHADERS so later appends stop conflicting. AI-assisted (Claude Code).

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 87d7bf7c4387d0b259b1f6d098b9a952433a30f1 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Retested the rebased head 87d7bf7c4387d0b259b1f6d098b9a952433a30f1 on Linux RTX 5090 (595.99.02). With the runtime rebuilt from this revision, I ran cs_buf_tail, cs_smem_bounds, cs_smem_sload_neg, and cs_smem_stride_align individually through the stock GPU runner with LEONIDA_W64_EMULATE=0 and again with =1, using separate work directories.

All eight runs translated, passed SPIR-V validation, and returned the expected eight words. Each fixture's readback was identical in both modes and matched its earlier default-mode result at a0f6c71. This was a focused correctness check of the four synthetic fixtures. Compile time and runtime performance were outside the measurement. AI-assisted.

AI-assisted verification.

@ItsNotRexed
ItsNotRexed merged commit 360229b into ProjectLeonida:main Nov 22, 2026
9 of 10 checks passed
@AlxcBTW

AlxcBTW commented Nov 22, 2026

Copy link
Copy Markdown
Member

Thanks @shelbykb2: SHADER-110 (#1104) builds on your raw tail rule now that this has landed. It extends the rule to every OOB_SELECT mode and to stores.

ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
buffer_address() picked the bounds check from the stride alone and never read
word3. It now reads OOB_SELECT (bits 29:28) and applies the rule measured
natively on RDNA2 (gfx1036, docs/buffer_bounds.md; Mesa's GFX11 column): a
dword is out of range in mode 0 at idx >= NR or off + 4 > stride, mode 1 at
idx >= NR, mode 2 at NR == 0, mode 3 (RAW) at offs + 4 > NR, where off is
inst_offset + vaddr and offs adds soffset. A literal word3 folds the mode, a
run-time one selects with OpSelect.

Builds on the raw tail rule of #443 (per-dword loads): x2..x4 loads AND stores
are per dword in modes 0 and 3 (a store that straddled the edge used to write
past it), modes 1 and 2 take the whole access, a typed element
(buffer_load/store_format) is all or nothing at its format's size, an atomic
checks its dword's end. Measured on a Radeon 880M (gfx1150), a valid proxy for
RDNA2: 504 buffer_load_dword cases over idxen/offen/inst_offset/soffset at the
stride and record edges agree with the rules, plus the x2/x4, typed and atomic
edges.

Swizzle (V# word1 bit 31 SWIZZLE_ENABLE, word3 bit 23 ADD_TID_ENABLE; Mesa
gfx10-rsrc.json lines 326 and 337): a literal V# with either is Unsupported in
every mode; a run-time one is translated unswizzled (documented known gap).

A V# with word3 = 0 is mode 0 / stride 0 and so always out of range, as on
hardware: the harness output V# (vk_compute_test, interpreter push constants),
cs_bounds, cs_fmt_1010102, cs_store, mem_diff and the format tests now say
OOB_SELECT 3 (or 1 with a stride) explicitly.

Tests: tests/semantic/test_buffer_oob_select.py (33 hand-tabulated cases plus
multi-dword stores, typed elements and the swizzle gate, literal and run-time
V#), GPU tests cs_oob_select.asm and cs_oob_tail.asm (the second tells the end
check from Mesa's GFX10 start check). docs/design.md, Buffer bounds checking,
has the per-mode rule; docs/buffer_bounds.md notes the translator reads it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants