Skip to content

Run Windows games on Apple Silicon — free, open source, with an open compatibility database that tells you what actually works.

tsshim: HB_TSSHIM_ATOMIC64=1 answers yes to D3D12 OPTIONS11, 64-bit atomics on descriptor heap resources. D3DMetal 3 answers no on an M1 Pro, and Capcom's RE Engine then refuses the adapter: the Onimusha: Way of the Sword demo (highball-db#450) and Kunitsu-Gami. A player who patched D3DMetal's flag to yes ran the Onimusha demo through its benchmark at 32 fps, so the game does not need the feature to draw. Opt-in, for a game's fix to set; without the variable D3DMetal's answer stands. Measured with dx12probe through a clone of engine r26 carrying this shim: OPTIONS11 0 without the variable, 1 with it, shim active and D3DMetal underneath. Source only: the component and an engine revision that carries it are not built or published here.

Gauthier Piarrettee5c70ccc131e
diff --git a/spike/tsshim/d3d12.c b/spike/tsshim/d3d12.c
index 90a0dd5..e24c7f2 100644
--- a/spike/tsshim/d3d12.c
+++ b/spike/tsshim/d3d12.c
@@ -311,6 +311,14 @@ static void STDMETHODCALLTYPE hook_CreateDepthStencilView(ID3D12Device *dev, ID3
// against a newer SDK takes as "no usable shader model": Forza Horizon 6's 461.691 build asks with
// 0x6a and stopped at "Your graphics card is not supported (FH206)" (M4, macOS 27.0, D3DMetal 4.0b2).
// The Windows runtime the game ships knows its own enum, so on Windows the question never fails.
+//
+// OPTIONS11, 64-bit atomics on descriptor heap resources: D3DMetal 3 answers no on an M1 Pro, and
+// Capcom's RE Engine then refuses the adapter ("unsupported graphics card", the Onimusha: Way of
+// the Sword demo, highball-db#450, and Kunitsu-Gami). A player who patched D3DMetal to answer yes
+// ran the Onimusha demo through its benchmark at 32 fps, so the game does not need the feature to
+// draw. HB_TSSHIM_ATOMIC64=1, set only by such a game's fix, makes the shim answer yes; nothing
+// else changes, and without the variable the answer is D3DMetal's.
+static int claim_atomic64;
static HRESULT (STDMETHODCALLTYPE *real_CheckFeatureSupport)(ID3D12Device *, D3D12_FEATURE, void *, UINT);
static HRESULT STDMETHODCALLTYPE hook_CheckFeatureSupport(ID3D12Device *dev, D3D12_FEATURE feature, void *data, UINT size)
{
@@ -324,6 +332,11 @@ static HRESULT STDMETHODCALLTYPE hook_CheckFeatureSupport(ID3D12Device *dev, D3D
}
if (FAILED(hr)) sm->HighestShaderModel = asked;
LOG("shader model query for 0x%x answered as 0x%x (hr 0x%08lx)", asked, (unsigned)sm->HighestShaderModel, (unsigned long)hr);
+ } else if (feature == D3D12_FEATURE_D3D12_OPTIONS11 && claim_atomic64 && SUCCEEDED(hr) && data
+ && size >= sizeof(D3D12_FEATURE_DATA_D3D12_OPTIONS11)) {
+ D3D12_FEATURE_DATA_D3D12_OPTIONS11 *o = data;
+ if (!o->AtomicInt64OnDescriptorHeapResourceSupported) LOG("OPTIONS11: answering yes to 64-bit atomics on descriptor heap resources (HB_TSSHIM_ATOMIC64)");
+ o->AtomicInt64OnDescriptorHeapResourceSupported = TRUE;
} else if (dbg) LOG("CheckFeatureSupport feature=%d size=%u hr=0x%08lx", (int)feature, size, (unsigned long)hr);
return hr;
}
@@ -477,6 +490,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
dbg = GetEnvironmentVariableA("HB_TSSHIM_DEBUG", NULL, 0) > 0;
{ char v[8]; idle = GetEnvironmentVariableA("HB_D3D12_TSSHIM", v, sizeof v) == 1 && v[0] == '0'; } // kill switch
{ char v[8]; pass_depth_resolve = GetEnvironmentVariableA("HB_TSSHIM_DEPTHRESOLVE", v, sizeof v) == 1 && v[0] == '1'; }
+ { char v[8]; claim_atomic64 = GetEnvironmentVariableA("HB_TSSHIM_ATOMIC64", v, sizeof v) == 1 && v[0] == '1'; }
if (!load_real()) return FALSE;
RESOLVE(D3D12CoreCreateLayeredDevice); RESOLVE(D3D12CoreGetLayeredDeviceSize); RESOLVE(D3D12CoreRegisterLayers);
RESOLVE(D3D12CreateRootSignatureDeserializer); RESOLVE(D3D12CreateVersionedRootSignatureDeserializer);