[PR #251] rdna2spirv: add --int64-atomics option for 64-bit OpAtomicExchange on *_atomic_swap_x2 (SHADER-868) #304

Open
opened 2026-11-26 20:17:26 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/251
Author: @kotekompotek
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: work/shader-868-atomic-swap-x2


📝 Commits (1)

  • 2d0a082 rdna2spirv: add --int64-atomics option for 64-bit OpAtomicExchange on *_atomic_swap_x2 (SHADER-868)

📊 Changes

12 files changed (+639 additions, -32 deletions)

View changed files

📝 docs/design.md (+2 -2)
📝 make_game.py (+5 -1)
📝 runtime/shims/d3d12_com.h (+3 -0)
📝 runtime/shims/d3d12_vulkan_device.cpp (+2 -0)
📝 runtime/test/d3d12_vulkan_device_test.cpp (+1 -0)
📝 runtime/test/shaders/build.py (+21 -1)
📝 runtime/test/shaders/check.py (+3 -1)
➕ runtime/test/shaders/cs_atomic_swap_x2_int64.asm (+172 -0)
📝 scripts/run_gpu_tests.py (+35 -2)
➕ tests/semantic/fixtures/disasm/cs_atomic_swap_x2_int64.s (+163 -0)
➕ tests/semantic/test_atomic_swap_x2_int64.py (+173 -0)
📝 tools/rdna2spirv.py (+59 -25)

📄 Description

Claimed in the coordination issue as: SHADER-868 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149)

What and why

  • Addressed @ubiquitarianism's review feedback on this opt-in feature PR (ds_wrxchg_rtn_b64 is untouched).
  • Added --int64-atomics flag forwarding in make_game.py (FALLBACK_FLAGS and CLI parser) alongside tools/rdna2spirv.py and runtime/test/shaders/build.py (LEONIDA_INT64_ATOMICS=1).
  • Updated the Global atomics and buffer_atomic_{and,or,xor,swap}_x2 rows in docs/design.md to document opt-in --int64-atomics vs the default 32-bit dword-pair approximation.
  • Added GPU shader fixture runtime/test/shaders/cs_atomic_swap_x2_int64.asm, registered it in runtime/test/shaders/check.py, scripts/run_gpu_tests.py, and tests/semantic/regen_fixtures.py (tests/semantic/fixtures/disasm/cs_atomic_swap_x2_int64.s).
  • Updated in commit 14eaf6052: enabled shaderBufferInt64Atomics on VkPhysicalDeviceVulkan12Features in runtime/shims/d3d12_vulkan_device.cpp (recorded in runtime/shims/d3d12_com.h, asserted in runtime/test/d3d12_vulkan_device_test.cpp), replaced the single-thread cs_atomic_swap_x2_int64.asm fixture with a 64-thread tearing check, and added dedicated --int64-atomics runner pass in scripts/run_gpu_tests.py.

Tested

On commit 14eaf6052:

  • python -I tests/semantic/regen_fixtures.py --check (OK)
  • python -I tests/semantic/test_atomic_swap_x2_int64.py (6/6 OK via spirv_mini_interp.run_workgroup, 64 threads + 14 = OpAtomicExchange %ulong)
  • tests/semantic/test_fixtures.py & tests/semantic/test_regen_fixtures.py (OK)
  • All 12 tests/test_docs_*.py (OK)
  • compileall (OK)
  • MSVC /W4 compile-check of runtime/shims/d3d12_vulkan_device.cpp & runtime/test/d3d12_vulkan_device_test.cpp (OK)
  • Note: live RDNA2/Vulkan hardware execution of the 64-thread tearing fixture not available locally.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • 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.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/251 **Author:** [@kotekompotek](https://github.com/kotekompotek) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `work/shader-868-atomic-swap-x2` --- ### 📝 Commits (1) - [`2d0a082`](https://github.com/ubiquitarianism/leonida/commit/2d0a0822fe1166609e31fdffc7aafa2d5ce5342f) rdna2spirv: add --int64-atomics option for 64-bit OpAtomicExchange on *_atomic_swap_x2 (SHADER-868) ### 📊 Changes **12 files changed** (+639 additions, -32 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+2 -2) 📝 `make_game.py` (+5 -1) 📝 `runtime/shims/d3d12_com.h` (+3 -0) 📝 `runtime/shims/d3d12_vulkan_device.cpp` (+2 -0) 📝 `runtime/test/d3d12_vulkan_device_test.cpp` (+1 -0) 📝 `runtime/test/shaders/build.py` (+21 -1) 📝 `runtime/test/shaders/check.py` (+3 -1) ➕ `runtime/test/shaders/cs_atomic_swap_x2_int64.asm` (+172 -0) 📝 `scripts/run_gpu_tests.py` (+35 -2) ➕ `tests/semantic/fixtures/disasm/cs_atomic_swap_x2_int64.s` (+163 -0) ➕ `tests/semantic/test_atomic_swap_x2_int64.py` (+173 -0) 📝 `tools/rdna2spirv.py` (+59 -25) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-868 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149) ### What and why - Addressed @ubiquitarianism's review feedback on this opt-in feature PR (`ds_wrxchg_rtn_b64` is untouched). - Added `--int64-atomics` flag forwarding in `make_game.py` (`FALLBACK_FLAGS` and CLI parser) alongside `tools/rdna2spirv.py` and `runtime/test/shaders/build.py` (`LEONIDA_INT64_ATOMICS=1`). - Updated the `Global atomics` and `buffer_atomic_{and,or,xor,swap}_x2` rows in `docs/design.md` to document opt-in `--int64-atomics` vs the default 32-bit dword-pair approximation. - Added GPU shader fixture `runtime/test/shaders/cs_atomic_swap_x2_int64.asm`, registered it in `runtime/test/shaders/check.py`, `scripts/run_gpu_tests.py`, and `tests/semantic/regen_fixtures.py` (`tests/semantic/fixtures/disasm/cs_atomic_swap_x2_int64.s`). - Updated in commit `14eaf6052`: enabled `shaderBufferInt64Atomics` on `VkPhysicalDeviceVulkan12Features` in `runtime/shims/d3d12_vulkan_device.cpp` (recorded in `runtime/shims/d3d12_com.h`, asserted in `runtime/test/d3d12_vulkan_device_test.cpp`), replaced the single-thread `cs_atomic_swap_x2_int64.asm` fixture with a 64-thread tearing check, and added dedicated `--int64-atomics` runner pass in `scripts/run_gpu_tests.py`. ### Tested On commit `14eaf6052`: - `python -I tests/semantic/regen_fixtures.py --check` (`OK`) - `python -I tests/semantic/test_atomic_swap_x2_int64.py` (`6/6 OK` via `spirv_mini_interp.run_workgroup`, 64 threads + 14 `= OpAtomicExchange %ulong`) - `tests/semantic/test_fixtures.py` & `tests/semantic/test_regen_fixtures.py` (`OK`) - All 12 `tests/test_docs_*.py` (`OK`) - `compileall` (`OK`) - MSVC `/W4` compile-check of `runtime/shims/d3d12_vulkan_device.cpp` & `runtime/test/d3d12_vulkan_device_test.cpp` (`OK`) - Note: live RDNA2/Vulkan hardware execution of the 64-thread tearing fixture not available locally. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#304
No description provided.