Skip to content

compute: lower more typed 2D image atomics in direct compute - #3271

Merged
R0Y00 merged 2 commits into
R0Y00:mainfrom
Leyukaka:image-atomic-binops
Nov 28, 2026
Merged

R0Y00 merged 2 commits into
R0Y00:mainfrom
Leyukaka:image-atomic-binops

Conversation

@Leyukaka

Copy link
Copy Markdown
Collaborator

Part of #2935 and #3224, as claimed there. Target branch main. Extends #3162.

Change (src/gfx1013_direct_compute.inl). The direct compute typed 2D image atomic path of #3162 handles image_atomic_cmpswap, _add and _umax. It now also lowers these to DXIL AtomicBinOp, on the same RWTexture2D<uint> binding:

MIMG op DXIL AtomicBinOp
image_atomic_swap (0x0f) Exchange (8)
image_atomic_umin (0x15) UMin (6)
image_atomic_and (0x18) And (1)
image_atomic_or (0x19) Or (2)
image_atomic_xor (0x1a) Xor (3)

Tests. The setup was Windows 11 with an NVIDIA GeForce RTX 5080 and DXC from the Windows SDK 10.0.26100, Release, on main e8dd89ed plus this commit.

  • New native_image_atomic_binops_{controls,warp,hardware} reuses the shader: lower typed 2D image atomics in direct Compute DXIL #3162 fixture (native_image_atomic_check.py):
    • the controls check that each new op compiles to atomicBinOp with its code, that the operand refusals (dim, dmask, coordinate, flags and two address-flag encodings) still apply, and that the refused ops keep their message;
    • the readback checks every texture word against a CPU reference. It covers distinct and contended texels, GLC on and off, and a sparse EXEC.
  • Inbox WARP reports the capability skip. On the RTX both tests pass, as do the existing native_image_atomic_* tests.
  • With main's compile_dxil, the controls stop at "direct image opcode or descriptor modifiers".
  • Mutation checks by hand:
    • mapping or to the Xor code fails the controls;
    • mapping umin to UMax or to Exchange fails the hardware readback.
  • On a full build, ctest -R "native_|startup_compute|compile_dxil|image" passes 532 of 533. native_scalar_lds_hardware fails as on main.

Measured with compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests, base and change both on main e8dd89ed.

AI-assisted.

The direct compute typed 2D image atomic path of R0Y00#3162 (cmpswap, add,
umax) now also lowers image_atomic_swap, _umin, _and, _or and _xor to
DXIL AtomicBinOp Exchange, UMin, And, Or and Xor on the same
RWTexture2D<uint> binding, with the same operand checks, EXEC guard and
GLC return of the old value. image_atomic_smin and _smax stay refused,
because signed min/max is not verified on this R32_UINT binding; sub,
inc, dec and the float atomics stay refused too.

New test native_image_atomic_binops (controls, WARP, hardware) reuses
the R0Y00#3162 fixture: each new op compiles to atomicBinOp with its code,
the operand refusals still apply, and the refused ops keep "direct
image opcode or descriptor modifiers". The readback covers distinct and
contended texels, GLC on and off, and a sparse EXEC.

AI-assisted.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of 47df6e154b014a165f3c21cbc21f2e8446c83313. The new opcode mapping uses the existing typed 2D UAV operand checks, EXEC guard and GLC return path. The DXIL/refusal controls passed. All 20 new hardware cases matched 336 words each, including contended and distinct texels with GLC on and off. The adjacent add/umax/compare-and-swap fixture also passed and its intentional missing-GLC controls produced readback mismatches.

Release commands:

cmake --build --preset release --target compile_dxil offscreen_check
ctest --preset release --no-tests=error --output-on-failure -V -R '^native_image_atomic_(binops_)?(controls|warp|hardware)$'

Four passed, two capability skips, zero failures. Windows 11 26200.9974, SDK/DXC 10.0.26100.0, RTX 4060 Laptop GPU driver 32.0.16.1656, WARP 10.0.26100.9818. The D3D12 debug layer was enabled and WARP exposed four lanes, below the wave32 requirement.

Before merge, please update docs/experiments/native-image-atomics.md. Its opening still lists the original three direct Compute operations. Add the five now verified on the fixed R32_UINT 2D UAV, and link the new fixture in the reproduction section. Keep signed min/max outside the verified scope.

native-image-atomics now lists swap, umin, and, or and xor with their
AtomicBinOp codes, keeps signed min/max outside the verified scope, and
links the binary-operation fixture.

AI-assisted.
@Leyukaka

Copy link
Copy Markdown
Collaborator Author

Thanks for testing it. Pushed 703d6cae, docs only. docs/experiments/native-image-atomics.md now:

  • lists swap, umin, and, or and xor next to add, umax and cmpswap on the fixed 2D R32_UINT UAV, with their AtomicBinOp codes (Exchange 8, UMin 6, And 1, Or 2, Xor 3);
  • keeps signed smin/smax outside the verified scope, together with sub, inc, dec and the float atomics;
  • links tests/native_image_atomic_binops_check.py in the reproduction section, with what it checks. The existing ctest -R '^native_image_atomic_' command already selects it.
  • says the binary-operation fixture passed on an RTX 5080 (driver 32.0.16.2101), and keeps the earlier RTX 4070 sentence for the two original fixtures.

AI-assisted.

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed 703d6cae. The documentation lists the five new operations and links the fixture, while keeping signed min/max explicitly refused. The only change from the previously tested head is that Markdown file. The docs-link check passed (640 links), and the focused Release suite again reported four passes and two inbox WARP wave32 capability skips. RTX 4060 Laptop readback and the DXIL/refusal controls passed. The requested change is resolved.

@R0Y00
R0Y00 merged commit b4c8ee5 into R0Y00:main Nov 28, 2026
5 checks passed
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.

2 participants