From 27c0a4b7c80273952515fd61d60627b7551c8244 Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 15:29:36 -0500 Subject: [PATCH] RR runtime: retain checks for ID3D12GraphicsCommandList2 before it records anything retain_locked created the transient copy and recorded the copy and its barriers into the game's list, and only then asked the list for ID3D12GraphicsCommandList2, which the completion marker needs. If the query failed, the marker and the serial increment were skipped, retain still returned WG_OK, and a later release could free the copy while its recorded copy was still pending on the list. The query now comes first; a list without List2 gets WG_E_INVALID_PARAMETER before anything is created or recorded, as evaluate already refuses such a list. Fixes #65 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/rr_f/runtime/src/rr_runtime.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/clean/rr_f/runtime/src/rr_runtime.cpp b/clean/rr_f/runtime/src/rr_runtime.cpp index c642a468..0362f6f4 100644 --- a/clean/rr_f/runtime/src/rr_runtime.cpp +++ b/clean/rr_f/runtime/src/rr_runtime.cpp @@ -3483,6 +3483,14 @@ uint32_t retain_locked(void* cmd, void* resource, uint32_t format, uint32_t stat if (!rt.dev || !cmd || !resource) return WG_E_INVALID_PARAMETER; ID3D12GraphicsCommandList* l = nullptr; if (FAILED(((IUnknown*)cmd)->QueryInterface(IID_PPV_ARGS(&l)))) return WG_E_INVALID_PARAMETER; + // Issue #65: the completion marker below needs ID3D12GraphicsCommandList2 (evaluate refuses a list without it). Ask + // first: nothing is created or recorded for a list that cannot take the marker, as without the marker the copy's + // release would not wait for the list. + ID3D12GraphicsCommandList2* l2 = nullptr; + if (FAILED(l->QueryInterface(IID_PPV_ARGS(&l2)))) { + release(l); + return WG_E_INVALID_PARAMETER; + } ID3D12Resource* src = (ID3D12Resource*)resource; D3D12_RESOURCE_DESC d = src->GetDesc(); // bug hunt C: a texture with mips is copied as its mip 0 (texture_shape.h: a copy uses subresource 0; the runtime reads @@ -3497,6 +3505,7 @@ uint32_t retain_locked(void* cmd, void* resource, uint32_t format, uint32_t stat ID3D12Resource* c = nullptr; if (FAILED(rt.dev->CreateCommittedResource(&hp, D3D12_HEAP_FLAG_NONE, &d, D3D12_RESOURCE_STATE_COPY_DEST, nullptr, IID_PPV_ARGS(&c)))) { + release(l2); release(l); return WG_E_D3D_API; } @@ -3521,15 +3530,14 @@ uint32_t retain_locked(void* cmd, void* resource, uint32_t format, uint32_t stat // bug hunt B: the copy runs when the game's list does, and a copy alone never advanced rt.serial: a release before the // next frame (the input re-tagged or untagged) freed it at once, before its CopyResource ran. The copy gets a serial of // its own, written into the same list after it (the frames' marker), so release_transient's defer waits for that list. - ID3D12GraphicsCommandList2* l2 = nullptr; - if (rt.marker && SUCCEEDED(l->QueryInterface(IID_PPV_ARGS(&l2)))) { + if (rt.marker) { const uint64_t serial = rt.serial + 1; D3D12_WRITEBUFFERIMMEDIATE_PARAMETER p{rt.marker->GetGPUVirtualAddress(), (UINT)(serial & 0xffffffffu)}; D3D12_WRITEBUFFERIMMEDIATE_MODE mode = D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_OUT; l2->WriteBufferImmediate(1, &p, &mode); rt.serial = serial; - release(l2); } + release(l2); release(l); rt.transient.push_back(c); *out = c;