diff --git a/renderdoc/driver/d3d12/d3d12_resources.cpp b/renderdoc/driver/d3d12/d3d12_resources.cpp index 7df646d93..6263535cb 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.cpp +++ b/renderdoc/driver/d3d12/d3d12_resources.cpp @@ -68,13 +68,6 @@ TrackedResource *GetTracked(ID3D12DeviceChild *ptr) ALL_D3D12_TYPES; - if(WrappedID3D12GraphicsCommandList::IsAlloc(ptr)) - return (TrackedResource *)(WrappedID3D12GraphicsCommandList *)ptr; - if(WrappedID3D12CommandQueue::IsAlloc(ptr)) - return (TrackedResource *)(WrappedID3D12CommandQueue *)ptr; - - RDCERR("Unknown type of ptr 0x%p", ptr); - return NULL; } @@ -109,7 +102,16 @@ ResourceId GetResID(ID3D12DeviceChild *ptr) TrackedResource *res = GetTracked(ptr); if(res == NULL) + { + if(WrappedID3D12GraphicsCommandList::IsAlloc(ptr)) + return ((WrappedID3D12GraphicsCommandList *)ptr)->GetResourceID(); + if(WrappedID3D12CommandQueue::IsAlloc(ptr)) + return ((WrappedID3D12CommandQueue *)ptr)->GetResourceID(); + + RDCERR("Unknown type of ptr 0x%p", ptr); + return ResourceId(); + } return res->GetResourceID(); } @@ -123,7 +125,16 @@ D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr) TrackedResource *res = GetTracked(ptr); if(res == NULL) + { + if(WrappedID3D12GraphicsCommandList::IsAlloc(ptr)) + return ((WrappedID3D12GraphicsCommandList *)ptr)->GetResourceRecord(); + if(WrappedID3D12CommandQueue::IsAlloc(ptr)) + return ((WrappedID3D12CommandQueue *)ptr)->GetResourceRecord(); + + RDCERR("Unknown type of ptr 0x%p", ptr); + return NULL; + } return res->GetResourceRecord(); } diff --git a/renderdoc/driver/d3d12/d3d12_resources.h b/renderdoc/driver/d3d12/d3d12_resources.h index f72ad2d79..4353dbdb4 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.h +++ b/renderdoc/driver/d3d12/d3d12_resources.h @@ -647,11 +647,6 @@ typename UnwrapHelper::Outer *GetWrapped(iface *obj) return wrapped; } -// this function identifies the type by IsAlloc() and returns -// the pointer to the TrackedResource interface for fetching ID -// or record -TrackedResource *GetTracked(ID3D12DeviceChild *ptr); - template ifaceptr Unwrap(ifaceptr obj) { @@ -679,7 +674,7 @@ D3D12ResourceRecord *GetRecord(ifaceptr obj) return GetWrapped(obj)->GetResourceRecord(); } -// specialisations that use the GetTracked() function to fetch the ID +// specialisations that use the IsAlloc() function to identify the real type template <> ResourceId GetResID(ID3D12DeviceChild *ptr); template <>