Skip to content

Runtime + translator: 64-bit atomics on R64 typed UAVs via VK_EXT_shader_image_atomic_int64 (D3D-251) - #2058

Open
opit80 wants to merge 1 commit into
ItsNotRexed:mainfrom
opit80:d3d251-int64-typed-atomics
Open

opit80 wants to merge 1 commit into
ItsNotRexed:mainfrom
opit80:d3d251-int64-typed-atomics

Conversation

@opit80

@opit80 opit80 commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

PR #2058 gövde taslağı (rebase sonrası; GÖNDERİLMEDİ — head kararı beklenir)

Not: Yalnızca "Tested" bölümü ve rebase uyarlama notu güncellendi; ilk bölümler (claim, What and why,
Behaviour change, Scope, Checklist) değişmedi, buraya kopyalanacak. Diff karşılaştırması için
scratch\d3d251\rebase1.md.


Rebased onto current main (aa2988cc) and re-tested. Conflict resolutions kept both sides' intent; one adaptation
was needed for upstream's new FSSM publication gate (cs_fssm_extra in runtime/test/shaders/build.py):
cs_imgatomic64.asm now carries ; fssm-at: 0x150 / ; fssm-data: ... header words — the same pattern as
cs_buf_counter — so its synthetic FSSM is published for the D3D12 test without publishing every compute sidecar.
The new test's initial constant was renamed to initial_rows: upstream's new add_fence(..., std::uint64_t initial)
in runtime/src/queue_holds.h made MSVC warn C4459 at its parameter.

Tested (after the rebase, on aa2988cc + this change)

Tested on: Windows 11 / MSVC / NVIDIA GeForce RTX 5070 Ti / NVIDIA driver (Vulkan SDK 1.4.363.0), Ninja
RelWithDebInfo, -j 4.

  • Translator regression: python -m unittest discover -s tests/semantic — 7,459 tests: the new
    test_image_atomic64 passes; 7 failures + 2 errors remain in test_loop_ballot_barrier, test_cmp_class_f64 and
    test_mutations, and the identical 9 occur on a clean main checkout (aa2988cc) — none is introduced here.
  • regen_fixtures.py --check: clean (exit 0).
  • Build: clean, 0 new warnings (a clean main build shows the same two remaining warnings: one glslang note for
    ps_sg_probe.frag and one C4456 at xgameruntime_test.cpp:492).
  • ctest (155 tests): 154 passed, the rest skipped (game-data tests), 0 failed, 0 VUID — both plain and with
    LEONIDA_VK_VALIDATION=1. On clean main the same suite passes except a flaky run_tiny_game_dir (game-folder
    resolution; it passes in the same build's validation run).
  • New GPU test (d3d12_imgatomic64_test): 64/64 texels exact, both plain and with validation enabled.
  • GPU suite: python -I scripts/run_gpu_tests.py — 215/215 translated and spirv-val clean (the suite has grown on
    main), 165/211 passed, 46 skipped, 0 errors. With LEONIDA_W64_EMULATE=1: 196/211 passed, 15 skipped, 0 errors.
    cs_imgatomic64 passes in both modes ("64/64 texels exact").

Overlap: #3780 (@kotorvr) enables fragmentStoresAndAtomics / vertexPipelineStoresAndAtomics unconditionally; the two touch the same two lines in create_vulkan_device_standalone. Whichever lands second rebases; if #3780 goes first, the two assignments in this PR's image_int64_atomics block become redundant and are dropped.

AI-assisted (Claude Code orchestration; GLM/Hy4 sub-agents).

@2-CD

2-CD commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Windows + GPU check: RTX 5080 + RTX 3070 Ti (NVIDIA 621.01) and AMD Radeon 610M iGPU (Ryzen 9 9950X3D, driver 32.0.13018.6), Windows 11, MSVC RelWithDebInfo/Ninja, CMake 4.4.5, glslang 16.6.0, spirv-tools v2026.4, llvm-mc via scripts/build_llvm_mc.ps1. Tested head 891b772 (base 4eb6155; PR currently conflicts with main).

  • Clean build. Note: d3d12_imgatomic64 only registers when llvm-mc + spirv-as/val are configured (-DLEONIDA_LLVM_MC etc.); built it that way.
  • d3d12_imgatomic64 (new): pass 3/3 on both the RTX 5080 and the iGPU (--repeat until-fail:3; VK_EXT_shader_image_atomic_int64 is available on both, no skips).
  • Full ctest -C RelWithDebInfo -j 6: 108/110 on both GPUs. The two failures, d3d12_compute and d3d12_draw, reproduce in isolation (not contention) on both GPUs at line 515: rt::d3d12_xs::device_proxy_ref_count(device.p) == 1.
  • Isolation against the base: at 4eb6155 (this PR's base) d3d12_draw already fails the same way and d3d12_compute passes; on current main 16282101 both pass. So the draw failure is the stale base (fixed on main since), but the compute failure appears only on the PR head - the PR's changes leak a device-proxy reference on the compute path, or the interaction disappears on rebase. Please re-check d3d12_compute after rebasing onto current main.

Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine.

@LloydNicholson

Copy link
Copy Markdown
Contributor

Tested 891b772 on an RX 9060 XT (RDNA4, GFX1200), RADV Mesa 27.0.0-devel, Nobara Linux (Fedora 44): pass

This is the RADV run the description asks for. RADV reports VK_EXT_shader_image_atomic_int64 with shaderImageInt64Atomics = true. I tested the PR head as it stands, on its base 6a6704d. It conflicts with current main, so this doesn't cover a rebase.

  • d3d12_imgatomic64_test: clang-cl cross-build with the 10.0.26100 SDK, run under Wine 11.22, with the build's generated/imgatomic64 folder and FSSM as arguments.
    • Prints D3D12 typed 64-bit image atomics: 64/64 texels exact and exits 0.
    • Under VK_LAYER_KHRONOS_validation 1.4.341, the run reports no VUIDs beyond the two that come from this host's environment (vkCreateDevice-ppEnabledExtensionNames-01387, VkDeviceCreateInfo-pNext-pNext).
    • A note for others: Wine truncates the arguments past the usual 260-character Windows path limit, so they need a short folder.
  • Without the change: runtime/test/shaders/build.py cs_imgatomic64 with tools/rdna2spirv.py from 6a6704d translates 0 of 1 (image_atomic_swap is refused), so the test can't run there.
  • run_gpu_tests.py: cs_imgatomic64 reports SKIP on Linux ("uses the Windows D3D12 layer"), as expected. The full suite gives 164/174 passed, 10 skipped, 0 failed.
  • Other checks: tests/semantic OK, including the 3 tests in test_image_atomic64.py. d3d12_vulkan_device_test under Wine exits 0.

I didn't exercise the TYPELESS → R64 view path or a vertex/fragment-stage atomic, which the PR leaves out too.

AI-assisted (Claude Code).

@2-CD

2-CD commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Re-check after rebase. Windows + GPU check: NVIDIA GeForce RTX 5080 (driver 621.01) + AMD Radeon 610M iGPU (driver 32.0.13018.6), Windows 11, MSVC (VS BuildTools 18) + Ninja, RelWithDebInfo, Vulkan SDK headers fetched. Tested head 620b1a51 (now rebased onto aa2988cc).

The d3d12_compute regression reported earlier (device-proxy ref leak, device_proxy_ref_count != 1) no longer reproduces on the rebased head.

Build: clean, 214 targets.

Targeted, --repeat until-fail:3:

  • d3d12_compute (the earlier regression sentinel): passes x3 on NVIDIA.
  • d3d12_imgatomic64 (new; dispatches the translated cs_imgatomic64 fixture through the D3D12 typed-UAV path): passes x3 on NVIDIA and on the iGPU.
  • vk_pipeline_check_cli, d3d12_vulkan_device: pass x3.

Python:

  • tests/semantic/test_image_atomic64.py: 3 tests OK (unittest).

Full suite (ctest -C RelWithDebInfo -j 6, excluding the 4 window-showing tests dxgi_swapchain|d3d12_present|vk_presenter_sync|xbox_present):

  • NVIDIA RTX 5080: 150/150 passed, 0 failed.
  • AMD Radeon 610M iGPU (LEONIDA_VK_DEVICE=Radeon): 150/150 passed, 0 failed.

The PR's unstable CI state did not reproduce locally.

Synthetic fixtures only, no game files. AI-assisted (opencode); runs on my machine.

@Vonsek

Vonsek commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested 620b1a5 on Windows 11 (MSVC BuildTools 2022, Ninja, RelWithDebInfo, -j 4; no Vulkan validation layer installed), one GPU at a time, device line confirmed: AMD Radeon RDNA2 iGPU (driver 26.10.1) and NVIDIA RTX 5080 (driver 616.92). Ran ctest -R "^(d3d12_imgatomic64|d3d12_vulkan_device|vk_pipeline_check_cli)$" and run_gpu_tests.py --filter cs_imgatomic64: 3/3 ctest on each GPU; cs_imgatomic64 PASS on each (D3D12 typed 64-bit image atomics: 64/64 texels exact). No game files.

AI-assisted.

@Exopus-0x65f7ad0

Copy link
Copy Markdown

Tested 620b1a51 on Windows 11 (26300), RTX 5060 Ti / 621.14, MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363.0, RelWithDebInfo, clean build with -DLEONIDA_LLVM_MC (translated-shader D3D12 gate tests included), full LEONIDA_VK_VALIDATION=1 ctest -j4: 145/145 passed, 0 VUIDs, 0 build errors. AI-assisted (Claude Code).

@ddm-j

ddm-j commented Nov 23, 2026

Copy link
Copy Markdown

Clash with #4312, found by merging open PRs that touch d3d12_vulkan_device.cpp onto main d0835dd and testing (Windows runtime cross-built with clang-cl + xwin, Wine 11.21 on Fedora 45, RDNA2 iGPU with RADV Mesa 26.2.6 and RTX 4070 Ti with 615.78.08): d3d12_imgatomic64 fails once #4312 is in.

Cause: #4312 (D3D-448) moves a D3D12 compute PSO's root arguments to start at s4. Every D3D12 test that reuses an s0-based fixture is therefore built with LEONIDA_USER_DATA_SHIFT=4 (compute_fixture.shift_user_data moves every SGPR up by 4 and shifted_rsrc2 raises USER_SGPR). That PR adds it to the M4, buffer-UAV and subgroup fixtures in runtime/CMakeLists.txt. cs_imgatomic64 is new here, so #4312 doesn't cover it: it's still built unshifted and reads its user data from s0, where the root arguments no longer are.

Fix, for whichever of the two lands second (here once #4312 is in; or in #4312 if this one merges first):

       add_custom_command(
         OUTPUT ${LEONIDA_ATOMIC64_FILES}
         COMMAND ${CMAKE_COMMAND} -E env "LLVM_MC=${LEONIDA_LLVM_MC}" "LEONIDA_SPIRV_TOOLS=${LEONIDA_SPIRV_TOOLS_NATIVE}"
+                LEONIDA_USER_DATA_SHIFT=4
                 $<TARGET_FILE:Python3::Interpreter> -I ${CMAKE_CURRENT_SOURCE_DIR}/test/shaders/build.py
                 ${LEONIDA_ATOMIC64_DIR} cs_imgatomic64

With it, on main + this PR + #4312: d3d12_imgatomic64 passes on both GPUs. I ran only that test with the fix, not the full suite. The .asm header comment could get the same "D3D12 build: … 4 higher" note #4312 adds to the other fixtures.

AI-assisted (Claude Code).

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.

6 participants