Repository navigation
Interop: declare the spin pass's buffer without globallycoherent - #12
Merged
Merged
Conversation
The done_mode=spin pass (PASS_SPIN in clean/runtime/interop/convert.cpp) reads and writes spinBuf only through InterlockedAdd. UAV atomics are coherent across thread groups and the device whether or not the UAV is declared globallycoherent; the tag only matters for non-atomic loads (Direct3D 11.3 functional spec, 7.14.4 "Global vs Group/Local Coherency on Non-Atomic UAV Reads"). Dropping it leaves the shader's behaviour unchanged and lets HLSL compilers that reject the modifier, as reported for Wine's d3dcompiler_47 in #7, build the interop shaders. Wine and Proton were not tested. With the Windows SDK's fxc (cs_5_0, /O3, the runtime's defines and entry points) all nine interop passes compile before and after (seven are built at context create, motionpt and outtex on first use). Only the spin pass's bytecode changes, and its only difference is the UAV declaration (dcl_uav_typed_buffer_glc -> dcl_uav_typed_buffer). Reported-by: j0nsh1n Refs: #7 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
phantoslayer21
marked this pull request as ready for review
November 13, 2026 15:31
phantoslayer21
force-pushed
the
fix/interop-spin-no-globallycoherent
branch
from
November 13, 2026 15:31
4be4a40 to
2e71577
Compare
j0nsh1n
added a commit
to j0nsh1n/wronggpu
that referenced
this pull request
Nov 13, 2026
clean/linux/run_wine_tests.py runs three tests in a Wine prefix set up the way Proton sets up a game's (clean/linux/wine_env.py: vkd3d-proton d3d12 / d3d12core, DXVK dxgi, Wine's vkd3d libraries for its builtin d3dcompiler_47), with an optional self-built vkd3d-proton (--vkd3d): - interop: the existing run-tests.sh (31 tests); - rr-leak: the RR test host's tagloop job (pull request phantoslayer21#11) against a given wronggpu_runtime.dll with a synthetic RR model, with the 256 MiB limit of the Windows end-to-end test; - ags-layout: wg_ags.hlsli's WMMA and conversion helpers on fixed register values against a CPU reference of the gfx12 semantics (new: ags_layout.hlsl, ags_layout_host.cpp). run-tests.sh: -fms-extensions for clang-based MinGW (the __try in descriptor_publish.h), and WG_WINE to pick Proton's wine over a system wine64. Verified on an RX 9070 XT, RADV, GE-Proton 11-11, with a vkd3d-proton built with dxil-spirv PR #362: interop 31/31, rr-leak +37 MiB (limit 256), ags-layout 7/7. Each test fails on the bug it targets: interop 29/31 with "Unknown modifier globallycoherent" before pull request phantoslayer21#12, rr-leak +2636 MiB with a runtime from before pull request phantoslayer21#11, ags-layout at CreateComputePipelineState on stock vkd3d-proton; its comparison rejects lane-swapped and half-swapped results. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
This was referenced Nov 13, 2026
j0nsh1n
added a commit
to j0nsh1n/wronggpu
that referenced
this pull request
Nov 14, 2026
From the review of phantoslayer21#52: - README: the globallycoherent count now agrees (29 of 31, before phantoslayer21#12). The leak figures are named as one run on an RX 9070 XT, RADV, GE-Proton 11-11 and vkd3d-proton 5b1089c8 + dxil-spirv #362: +2636 MiB with a runtime built before phantoslayer21#11, +37.2 MiB with the fix. The launcher red check describes what was run (a wg-core check broken on purpose). The player advice about DLLs next to the game exe is gone, and the opening says the tests don't make Linux a supported platform. The vkd3d-proton commit named is the one tested (5b1089c8). It also says that --work/prefix is reused if it already is a Wine prefix. - ags_layout.hlsl: the FloatConversion opcode 0x1c names its source in this repository (f2h_hw in clean/rr_f/kernels/rr_fast.hlsli). - wine_env.py: mscoree / mshtml off and winemenubuilder disabled, so a new prefix shows no Mono / Gecko dialog and writes no menu entries. - run_wine_tests.py: rr-leak fails when video memory does not change at all (a stack reporting a constant CurrentUsage), and --work with a space is refused (the RR host's job file is split on spaces). Verified on main c793823 + this branch, GE-Proton 11-11 with a fresh --work: interop 31/31, rr-leak +37.2 MiB, ags-layout 7/7, launcher 73/230/186/18 checks. No new entries under ~/.local/share/applications. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Jonathan Shin <85975340+j0nsh1n@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported by @j0nsh1n in #7.
What changed and why
The
done_mode=spinpass (PASS_SPINinclean/runtime/interop/convert.cpp) declared its buffer asgloballycoherent RWBuffer<uint> spinBuf. The report in #7 says Wine'sd3dcompiler_47rejects that modifier underProton (
E5030: Unknown modifier "globallycoherent"). The spin pass is one of the seven passes compiled when a contextis created, so the create failed. This change drops the modifier and adds a comment saying why that's correct.
Why the modifier isn't needed:
spinBufonly throughInterlockedAdd. The poll isInterlockedAdd(spinBuf[0], 0, o)and thetimeout count is
InterlockedAdd(spinBuf[1], 1, o). There is no plain load or store, and no other pass declares thisbuffer. The done flag it polls is written by the HIP stream (
hipStreamWriteValue32) or by the rescue queue(
WriteBufferImmediate), not by a shader.(https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm), restricts the "globally coherent"
tag to non-atomic loads: "Atomic read-modify-write operations do not have this constraint [...] atomic operations are
implemented by all hardware in a globally coherent way, regardless of whether the UAV has been tagged as "globally
coherent" or not." The spec speaks of shader atomics and loads in other thread groups. A write from another queue or
from the HIP stream is outside that rule with or without the tag, so removing the tag takes no documented guarantee
away.
How it was tested
Tested: FXC, and Windows (the system's
d3dcompiler_47, through the runtime and through a small harness).Not tested: Wine / Proton, and
done_mode=spinend to end. The mode needs the HIP executor, which was not run, sothe normal writer of the done flag (
hipStreamWriteValue32) was never exercised against a running spin.done_modedefaults to
fence.#7 asked to check that
cs_5_0still compiles and thatdone_mode=spinbehaves as before.cs_5_0compiles with FXCand with Windows' compiler (not checked with Wine's). For
done_mode=spin, the spin shader's bytecode differs only inits UAV declaration (below); the mode itself was not run.
FXC (Windows SDK 10.0.26100
fxc.exe): each of the nine interop passes was compiled ascs_5_0with theruntime's flags, entry points and defines (
/O3,/E <entry>,/D PASS_X=1):motionptand
outtexare built on first use.(
dcl_uav_typed_buffer_glcbecomesdcl_uav_typed_buffer). The atomic instructions are unchanged. The bytecode ofthe other eight passes is byte-identical before and after.
Interop test (
clean/runtime/interop/tests/test_interop_d3d12.cpp) on an RX 9070 XT under Windows. The runtimeDLL was built with
clean/runner/build.py --runtime-only --no-embed --no-model-k, before and after the change:nohipcase was left out because it loads the HIP runtime.done_mode=spinfalls back to the fence there (the runtime logs"done_mode=spin not available ..."). The suite does compile the spin shader at every context create.
Spin pass on the device: a small harness (not part of this PR) ran
Converter::record_spindirectly, with thesame results before and after the change. It exited with a failure in both builds, because one case failed:
timeout. This is a stand-in writer; the product does not write the done flag with a shader.
WriteBufferImmediatefrom another queue about 50 ms later (the rescue path's writer) was notseen by the running spin: 0 of 5 runs, one timeout each, the flag stayed at 0. This is the same before and after
the change, so it does not depend on the modifier and is not caused by it. It is not addressed here.
Neither writer of the done flag was shown to be seen by a running spin: the rescue writer fails as above, and the HIP
stream writer was not run.
Refs #7.