Skip to content

tests/semantic: buffer_load_short_d16_hi keeps both halves in inactive lanes - #7866

Open
aslan2142 wants to merge 1 commit into
ItsNotRexed:mainfrom
aslan2142:semantic-d16-hi-inactive-lane
Open

aslan2142 wants to merge 1 commit into
ItsNotRexed:mainfrom
aslan2142:semantic-d16-hi-inactive-lane

Conversation

@aslan2142

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue: #7694 (comment) (released by Vadson159).

A CPU semantic test for buffer_load_short_d16_hi when some lanes are off in EXEC. Test only: the translator is not changed.

What it checks

  • tests/semantic/fixtures/cs_buffer_load_d16_hi_exec.asm is a hand-written wave32 program. Each lane puts its own value in v5: (lane * 0x10001) ^ 0xC0DE1234.
  • EXEC is then set to 0x5AC3A50F (16 lanes on, 16 off), and each lane loads the 16-bit word at 0x100 + 2 * lane into the high half of v5.
  • With EXEC back to all lanes, every lane stores v5. tests/semantic/test_buffer_load_d16_hi_exec.py translates the program, runs all 32 lanes in spirv_mini_interp and checks each lane:
    • an active lane has the loaded word in the high half and keeps its own low half
    • an inactive lane keeps both halves
  • Every lane's loaded word is different from the high half it starts with, so a lane that loads when it shouldn't is caught.
  • Until now, test_buffer_sub_dword.py checked an inactive lane only for a store (buffer_store_byte).

How it catches a regression

I ran the test against three broken copies of tools/ (set with LEONIDA_TOOLS_DIR), each changing Gen.buffer_sub in tools/rdna2spirv.py:

  • the d16 result written with store_reg instead of dst, so every lane gets it: 16 failures, all inactive lanes (their high half becomes 0x0000). test_buffer_sub_dword.py and test_buffer_sub16_fixture.py both still pass with this change.
  • the load ignoring EXEC as well (cond = in_b): 16 failures, all inactive lanes (they get the loaded word).
  • the kept half dropped (OpBitFieldInsert into 0 instead of the old value): 16 failures, all active lanes.

On unchanged main, all three tests pass.

Tests

  • python -I tests/semantic/test_buffer_load_d16_hi_exec.py -v: 3 tests OK
  • python -I tests/semantic/regen_fixtures.py --check: exit 0. The fixture is a hand-written tests/semantic/fixtures/*.asm, like fragment_swizzle_exec.asm, not a GPU source under runtime/test/shaders/. It has no regen_fixtures marker and no generated .s.
  • python -I tests/test_semantic_translator_use.py: OK
  • The other d16 and sub-dword semantic tests pass: test_buffer_sub_dword, test_buffer_sub16_fixture, test_buffer_tbuffer_format_d16, test_buffer_format_d16_hi_absent, test_buffer_load_sub, test_lds_read_u8_d16, test_lds_subword_d16, test_global_sub_dword, test_global_mem_ext_fixture, test_fixtures.
  • python -I scripts/run_semantic_tests.py tests/semantic: 448 files, 5959 tests. Only the two files that already fail on main fail: test_image_atomics_guard and test_image_store_d16 (fixed by test: cover supported d16 cube image stores #7194 / test: exercise narrowed EXEC for image atomic guards #7212).
  • CPU only, no GPU: Linux 7.3.5 (Arch, zen kernel), Python 3.14.10.

Checklist

  • No game data: checked. The fixture is hand-written and no shader, log or output from the game is included.
  • Translator rule: none changed (test only), so docs/design.md is unchanged.

AI-assisted (Claude Code, Claude Opus 5.5).

…e lanes

A hand-written wave32 fixture gives every lane its own value in v5, cuts EXEC to 0x5AC3A50F and loads a 16-bit
word per lane into the high half of v5. The 16 active lanes must get the loaded word in the high half and keep
their low half; the 16 inactive lanes must keep both halves. test_buffer_sub_dword.py checked an inactive lane only
for a store.

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

NiHuShu commented Nov 23, 2026

Copy link
Copy Markdown

Verified d5253c4eb74c2e31446b32ca0ef0c3f826cec8c4 on CachyOS x86-64, CPython 3.14.10, with python -I tests/semantic/test_buffer_load_d16_hi_exec.py -v. Stock passed 3/3. In a disposable worktree I made only the d16 destination write unconditional in the translator, keeping the load guard in place.

With the checked-in EXEC mask, the translated-shader test failed on exactly lanes 4, 5, 6, 7, 9, 11, 12, 14, 18, 19, 20, 21, 24, 26, 29, 31. These were 16 lane subtest failures in one test method. All active lanes matched.

As a separate control I changed the fixture and its expected EXEC mask to 0xA5A55A49. The failures moved to exactly that mask’s 17 inactive lanes. Restoring the translator gave 3/3 passes with the alternate mask, then 3/3 again with the original fixture restored. Zero skips throughout. Synthetic fixture and CPU interpreter only; GPU not used. AI-assisted.

@morodirule

Copy link
Copy Markdown

Tested d5253c4 on Arch Linux, Python 3.14.10, CPU only: pass — first Linux check. New test_buffer_load_d16_hi_exec 3/3 + related buffer_sub_dword 6/6, buffer_load_sub 9/9, buffer_load_format 34/34 OK. Test file is new in the PR (nothing to swap); related suites show no regression. No game files, no GPU. AI-assisted.

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.

3 participants