tests: run raw buffer atomics addressed by soffset alone (TEST-ATOMIC-SOFFSET-BOUNDS) #1275

Closed
github-bot wants to merge 1 commit from gh-pr/1275/head into gh-pr/1275/base
Owner

@⁠Moriz82 on GitHub · 2026-11-24 21:11 UTC · original
split/test-atomic-soffset-bounds → main · +29 −12 · 1 files · 1 commits · closed without merging

Claimed in the coordination issue as: TEST-ATOMIC-SOFFSET-BOUNDS (claim).

Part of the split of #984 into small pull requests.

Depends on: none
Overlaps: #984 is the parent integration. #1097 (open, SHADER-BUFFER-BOUNDS) is the runtime half of the integrated commit this test comes from; it has no translator test and this pull request has nothing of the runtime. #850 (open) edits another test of the same file, test_spirv_emits_alignment_guard; its current diff applies cleanly on this branch. #1068 (open) tests soffset for loads and stores, not for atomics. None of the current diffs of #850, #1039 and #1068 adds a buffer atomic with a non-zero soffset.

What and why

Test only; the translator is not changed.

No test runs a buffer atomic with a non-zero scalar offset. The tests and the GPU fixtures hold 57 buffer_atomic_* instructions as text, and all 57 pass 0 as soffset. The address and bounds code is shared with loads and stores, which do test soffset, but each of the three atomic lowerings (32-bit integer, float min/max, 64-bit _x2) hands its operands to that code at its own call site. Dropping the operand at any of the three went unnoticed by the whole translator suite (see the mutation below).

test_raw_atomic_soffset_only addresses a raw V# through soffset alone, with no vaddr and no instruction offset, once per lowering (buffer_atomic_add, buffer_atomic_fmax, buffer_atomic_swap_x2). For each it checks both sides of the raw bound of docs/buffer_bounds.md, offset + soffset + size > NUM_RECORDS: with NUM_RECORDS = soffset + size the element is updated and glc returns the old value, and one byte short it is left alone and glc returns 0. The words in front of the element must keep their sentinel, so an atomic that lands at the V# base instead fails as well.

The expected values follow the rule the repository already documents for raw accesses. Nothing new was measured on hardware for this.

Tested

CachyOS (kernel 7.3.5), Python 3.14, SPIRV-Tools v2026.4.

  • python3 -I tests/semantic/test_buffer_atomic_fminmax_and_align.py: 11 tests pass (10 before, plus the new one with its 6 subtests). It passes on the base commit's translator too, as a pure test addition must.
  • Mutation, to show what the test adds: with soffset dropped at the three atomic call sites of Gen.buffer_address (a replaced by a[:3]), python3 -I scripts/run_semantic_tests.py tests/semantic -j 2 ran 470 files and 6,169 tests and exactly one file failed, this one, in the 6 subtests of the new test. Its other 10 tests and the other 469 files passed, so without this test the mutation passes the whole translator suite. The mutation was applied to the working tree for that run only and is not in the branch.
  • python3 -I scripts/run_semantic_tests.py tests/semantic -j 2 on the branch as committed: 470 files, 6,169 tests, 0 files failed (the base: 470 files, 6,168 tests, 0 failed).
  • The standard-library and pytest files under tests/ the way ci.yml runs them, and python3 -I -m compileall -q make_game.py tools tests: 520 files, 519 pass. tests/test_imhex_patterns.py fails (6 of its 9 tests) and fails the same way on the base commit, so it is not from this change. compileall passes.
  • python3 -I scripts/check_no_game_data.py: passes.
  • spirv-as and spirv-val --target-env vulkan1.2 (SPIRV-Tools v2026.4) on the three in-range modules of the test, written out by hand: all three validate.

Not run: any GPU test (there is no GPU fixture for an atomic with a soffset, and this adds none), the tools/hw_oracle probe, native Windows, macOS, the runtime build and a game boot.

GPUs tested: n/a (CPU interpreter only).

AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.

Checklist

  • Based on upstream main 6293c1c4f, one commit, one file.
  • One topic: one test.
  • No game data, keys or decryption, including in logs or reports quoted here.
  • No new translator rule: the test pins the documented raw bound for an operand form that had no test.

🤖 Generated with Claude Code

**@⁠Moriz82** on GitHub · 2026-11-24 21:11 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1275) `split/test-atomic-soffset-bounds` → `main` · +29 −12 · 1 files · 1 commits · closed without merging Claimed in the coordination issue as: TEST-ATOMIC-SOFFSET-BOUNDS ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). Part of the split of #984 into small pull requests. Depends on: none Overlaps: #984 is the parent integration. #1097 (open, SHADER-BUFFER-BOUNDS) is the runtime half of the integrated commit this test comes from; it has no translator test and this pull request has nothing of the runtime. #850 (open) edits another test of the same file, `test_spirv_emits_alignment_guard`; its current diff applies cleanly on this branch. #1068 (open) tests `soffset` for loads and stores, not for atomics. None of the current diffs of #850, #1039 and #1068 adds a buffer atomic with a non-zero `soffset`. ### What and why Test only; the translator is not changed. No test runs a buffer atomic with a non-zero scalar offset. The tests and the GPU fixtures hold 57 `buffer_atomic_*` instructions as text, and all 57 pass `0` as `soffset`. The address and bounds code is shared with loads and stores, which do test `soffset`, but each of the three atomic lowerings (32-bit integer, float min/max, 64-bit `_x2`) hands its operands to that code at its own call site. Dropping the operand at any of the three went unnoticed by the whole translator suite (see the mutation below). `test_raw_atomic_soffset_only` addresses a raw V# through `soffset` alone, with no `vaddr` and no instruction offset, once per lowering (`buffer_atomic_add`, `buffer_atomic_fmax`, `buffer_atomic_swap_x2`). For each it checks both sides of the raw bound of `docs/buffer_bounds.md`, `offset + soffset + size > NUM_RECORDS`: with `NUM_RECORDS = soffset + size` the element is updated and `glc` returns the old value, and one byte short it is left alone and `glc` returns 0. The words in front of the element must keep their sentinel, so an atomic that lands at the V# base instead fails as well. The expected values follow the rule the repository already documents for raw accesses. Nothing new was measured on hardware for this. ### Tested CachyOS (kernel 7.3.5), Python 3.14, SPIRV-Tools v2026.4. - `python3 -I tests/semantic/test_buffer_atomic_fminmax_and_align.py`: 11 tests pass (10 before, plus the new one with its 6 subtests). It passes on the base commit's translator too, as a pure test addition must. - Mutation, to show what the test adds: with `soffset` dropped at the three atomic call sites of `Gen.buffer_address` (`a` replaced by `a[:3]`), `python3 -I scripts/run_semantic_tests.py tests/semantic -j 2` ran 470 files and 6,169 tests and exactly one file failed, this one, in the 6 subtests of the new test. Its other 10 tests and the other 469 files passed, so without this test the mutation passes the whole translator suite. The mutation was applied to the working tree for that run only and is not in the branch. - `python3 -I scripts/run_semantic_tests.py tests/semantic -j 2` on the branch as committed: 470 files, 6,169 tests, 0 files failed (the base: 470 files, 6,168 tests, 0 failed). - The standard-library and pytest files under `tests/` the way `ci.yml` runs them, and `python3 -I -m compileall -q make_game.py tools tests`: 520 files, 519 pass. `tests/test_imhex_patterns.py` fails (6 of its 9 tests) and fails the same way on the base commit, so it is not from this change. `compileall` passes. - `python3 -I scripts/check_no_game_data.py`: passes. - `spirv-as` and `spirv-val --target-env vulkan1.2` (SPIRV-Tools v2026.4) on the three in-range modules of the test, written out by hand: all three validate. Not run: any GPU test (there is no GPU fixture for an atomic with a `soffset`, and this adds none), the `tools/hw_oracle` probe, native Windows, macOS, the runtime build and a game boot. GPUs tested: n/a (CPU interpreter only). AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named. ### Checklist - [x] Based on upstream main `6293c1c4f`, one commit, one file. - [x] One topic: one test. - [x] No game data, keys or decryption, including in logs or reports quoted here. - [x] No new translator rule: the test pins the documented raw bound for an operand form that had no test. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
No test ran a buffer atomic with a non-zero scalar offset: all 57
buffer_atomic_* instructions in the tests and the GPU fixtures pass 0
there. The three atomic lowerings (32-bit integer, float min/max, 64-bit
_x2) each hand their operands to the shared address code on their own,
so dropping the operand in any of them went unnoticed.

Add one test that addresses the element through soffset only and checks
the documented raw bound on both sides of the limit for each lowering.
Test only; the translator is unchanged.

The test passes on main. With soffset dropped at the three atomic call
sites, the translator suite (470 files, 6,169 tests) fails in this test
only, in all 6 of its subtests. On the branch the suite has 0 failing
files, and of the other Python test files only
tests/test_imhex_patterns.py fails, as on main.

AI-assisted (Claude Code).

Co-authored-by: Plaaasma <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:45:24 +00:00
github-bot closed this pull request 2026-11-26 09:45:24 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 14:46 UTC · original

Reviewed c53551d6b: test-only PR extending the soffset-only raw atomic test to the integer, float-min/max and 64-bit _x2 lowerings, on both sides of the documented raw bound. Ran the touched file on both the PR and main (11 tests OK on each; it also passes on main, matching its message), and probe-verified the added coverage: dropping soffset at the three atomic call sites fails exactly the 6 new subtests, and the old main test missed the float and _x2 drops that this one catches. Note: the intro line "No test ran a buffer atomic with a non-zero scalar offset" overstates — the replaced test already did that for buffer_atomic_add; the actual gap was float/_x2 coverage. Full suite not rerun here (2-core box, no GPU). AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 14:46 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1275#issuecomment-7165793193) Reviewed c53551d6b: test-only PR extending the soffset-only raw atomic test to the integer, float-min/max and 64-bit _x2 lowerings, on both sides of the documented raw bound. Ran the touched file on both the PR and main (11 tests OK on each; it also passes on main, matching its message), and probe-verified the added coverage: dropping soffset at the three atomic call sites fails exactly the 6 new subtests, and the old main test missed the float and _x2 drops that this one catches. Note: the intro line "No test ran a buffer atomic with a non-zero scalar offset" overstates — the replaced test already did that for `buffer_atomic_add`; the actual gap was float/_x2 coverage. Full suite not rerun here (2-core box, no GPU). AI-assisted review. **Recommendation:** Merge

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.