tombox-xshader: decode and translate the MUBUF 64-bit integer buffer … #251
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!251
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/251/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@azerioxfr on GitHub · 2026-11-23 07:53 UTC · original
azerioxfr:xshader-mubuf-atomic-x2→main· +194 −30 · 4 files · 1 commits · closed without mergingLibrary / area: tombox-xshader, MUBUF atomics (
hlsl.rsemit_mubuf/ buffer resolution, newhlsl/atomic.rshelper)Exports changed (exports.txt rows): none
Source of the behaviour: opcodes from
tests/isa_table/gfx1013.txt(MUBUF 0x50..0x5d). Semantics from the RDNA2 ISA (64-bit value at the 8-byte address; the vdata pair is the operand; GLC=1 returns the old value), on the SM 6.6 64-bit atomic support already used for image atomics (b17ef2c, OPTIONS9 gate).One topic, +194 / -30: 5 lines in
rdna2/mnem.rs,hlsl.rs+76 / -30,hlsl/atomic.rs+43, tests +56.What was missing
buffer_atomic_{swap,cmpswap,add,sub,smin,umin,smax,umax,and,or,xor,inc,dec}_x2were not decoded ("mubuf: gfx1013 opcodes not named by the decoder").The change
_x2atomics is declaredRWBuffer<uint64_t>/RWStructuredBuffer<uint64_t>, gated throughuses_typed_atomic64like the 64-bit image atomics. A slot that mixes 32-bit and 64-bit atomics is refused with an explicit error.(offset) >> 3). Unaligned constant offsets fall through to the existing "unresolved atomic target" refusal. Like the 32-bit path, this assumes the declared element matches the view's stride.Interlocked*. smin/smax, inc/dec and cmpswap are lowered inatomic_rmw64. GLC=1 writes the old value to vdata / vdata+1._x2branch)Tests
New
mubuf_atomic_x2(typed and raw groups): all 13 ops with carries across the halves, the sign bit in the high dword for smin/smax, inc/dec wrap, cmpswap hit and miss, and GLC 0 and 1.--release, DXC 1.9.2609)mubuf_atomic_x2_typed/_rawadd_x2adds a constantmubuf_atomic_soffset_typed/_raw,buffer_mubuf,image_mimg_atomics_64bit--test isa_table/opcodes/syntheticRun on
x86_64-pc-windows-gnu(no MSVC linker here). Hosts without 64-bit typed/raw UAV atomic support go through the existing OPTIONS9 gate.cargo test -p tombox-xshader --test exec -- mubuf_atomicpassesmissingwith a note@omonkeyz on GitHub · 2026-11-23 13:31 UTC · original
Review, changes needed: (1) on structured slots the constant offset is used as imm/8 with no %8 check, so an unaligned offset hits the wrong address; (2) indexed access assumes an 8-byte stride, not the guest stride; (3) a slot that also has plain loads or stores is declared uint64_t and then fails in DXC; (4) only the test harness knows the RWBuffer<uint64_t> view (R32G32_UINT, stride 8), d3d12_xs has no equivalent; (5) uses_typed_atomic64 is set for structured buffers, which don't need typed 64-bit atomics. Please rebase on #199 when you update.
@omonkeyz on GitHub · 2026-11-25 13:48 UTC · original
Applied on main in
e086d23(cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.@SchmashinPrunes on GitHub · 2026-11-24 14:34 UTC · original · approved these changes
Scope: silicon semantics only. This is not a merge recommendation. The integration issues in omonkeyz's review still need the changes requested there: offset alignment, guest stride, mixed plain/atomic slots, the d3d12_xs view and
uses_typed_atomic64. GitHub doesn't let a reviewer without write access withdraw an approval, so please read this one as a comment.I checked the op semantics on RDNA2 silicon: a gfx1036 iGPU (Ryzen 5 9600X), ROCm/HIP 5.7.1, raw wave32 kernels, so RDNA2, not gfx1013. Each kernel ran twice with identical results, and I compared against the semantics this PR implements (my own port; I didn't run the PR's code).
All 13
buffer_atomic_*_x2ops match on 2,048 cases each, with GLC 1, raw offen addressing and random 64-bit memory, data and compare values:swap,cmpswap(data in vdata[0:1], compare in vdata[2:3]),add,sub,smin,umin,smax,umax,and,ororxor;incgives (m >= d ? 0 : m + 1), anddecgives (m == 0 || m > d ? d : m - 1).That's the same as your model, including the carries across the halves and the signed compares on the high dword.
(Measured with an AI assistant, Claude.)
Pull request closed