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

Closed
Moriz82 wants to merge 1 commit from upstream-pr/1275 into main
Moriz82 commented 2026-11-24 21:11:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Moriz82 on 2026-11-24T21:11:36Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5480409014 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1275). Originally posted by [Moriz82](https://github.com/Moriz82) on 2026-11-24T21:11:36Z. --- Claimed in the coordination issue as: TEST-ATOMIC-SOFFSET-BOUNDS ([claim](https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144600523)). 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)
PierreEbele commented 2026-11-25 14:46:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T14:46:28Z.


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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7165793193 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1275#issuecomment-7165793193). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T14:46:28Z. --- 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

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
ProjectLeonida/mandy!1275
No description provided.