From 507a34d0fbadfc699f728e725399e820574a31e0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 16 Mar 2026 11:49:41 +0000 Subject: [PATCH] Handle root signatures that alias our own * We deduplicate on capture, but out root signatures are created before the replay so we use a replacement to handle that. --- renderdoc/driver/d3d12/d3d12_device_wrap.cpp | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp index 8d3f7cfa0..f37a67188 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap.cpp @@ -1210,26 +1210,30 @@ bool WrappedID3D12Device::Serialise_CreateRootSignature(SerialiserType &ser, UIN } else { + // we deduplicated during capture but this could alias one of ours in theory if(GetResourceManager()->HasWrapper(ret)) { ret->Release(); ret = (ID3D12RootSignature *)GetResourceManager()->GetWrapper(ret); - ret->AddRef(); + + GetResourceManager()->ReplaceResource(pRootSignature, GetResID(ret)); } else { ret = new WrappedID3D12RootSignature(pRootSignature, ret, this); + + WrappedID3D12RootSignature *wrapped = (WrappedID3D12RootSignature *)ret; + + wrapped->sig = DecodeRootSig(pBlobWithRootSignature, (size_t)blobLengthInBytes); + + if(wrapped->sig.Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE) + wrapped->localRootSigIdx = + GetResourceManager()->GetRTManager()->RegisterLocalRootSig(wrapped->sig); } - WrappedID3D12RootSignature *wrapped = (WrappedID3D12RootSignature *)ret; - - wrapped->sig = DecodeRootSig(pBlobWithRootSignature, (size_t)blobLengthInBytes); - - if(wrapped->sig.Flags & D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE) - wrapped->localRootSigIdx = - GetResourceManager()->GetRTManager()->RegisterLocalRootSig(wrapped->sig); - { + WrappedID3D12RootSignature *wrapped = (WrappedID3D12RootSignature *)ret; + StructuredSerialiser structuriser(ser.GetStructuredFile().chunks.back(), &GetChunkName); structuriser.SetUserData(GetResourceManager());