From 2e71577cc13a8529f91ce4b52017655563cb60f0 Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 08:24:50 -0500 Subject: [PATCH] interop: declare the spin pass's buffer without globallycoherent 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> --- clean/runtime/interop/convert.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clean/runtime/interop/convert.cpp b/clean/runtime/interop/convert.cpp index 122717b5..f055df8c 100644 --- a/clean/runtime/interop/convert.cpp +++ b/clean/runtime/interop/convert.cpp @@ -56,8 +56,10 @@ void flag(uint3 id : SV_DispatchThreadID) { flagBuf[0] = rx; } #if defined(PASS_SPIN) // done_mode=spin: one thread polls the done flag (written by the HIP stream after the network) until it reaches rx, // for at most ry polls; a timeout is counted in the second word. The poll is an atomic: a plain globallycoherent load -// in the loop is hoisted by the shader compiler. -globallycoherent RWBuffer spinBuf : register(u0); +// in the loop is hoisted by the shader compiler. spinBuf is touched only by atomics, which are coherent across thread +// groups and the device without globallycoherent (D3D11.3 functional spec 7.14.4: that tag concerns non-atomic loads +// only), so the buffer is declared without it; some HLSL compilers (e.g. Wine's d3dcompiler_47) reject the modifier. +RWBuffer spinBuf : register(u0); [numthreads(1, 1, 1)] void spin(uint3 id : SV_DispatchThreadID) { uint o = 0;