From f8fa72c3051cf2660a534f5c197f0c719fadc194 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 5 Jul 2016 19:21:46 +0300 Subject: [PATCH] Add safety code for now, to handle unwrapping non-wrapped resources --- renderdoc/driver/d3d12/d3d12_resources.h | 25 +++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_resources.h b/renderdoc/driver/d3d12/d3d12_resources.h index b252dfe0c..9a550220d 100644 --- a/renderdoc/driver/d3d12/d3d12_resources.h +++ b/renderdoc/driver/d3d12/d3d12_resources.h @@ -546,7 +546,7 @@ ALL_D3D12_TYPES; ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr); -#define WRAPPING_DEBUG 0 +#define WRAPPING_DEBUG 1 template typename UnwrapHelper::Outer *GetWrapped(iface *obj) @@ -559,7 +559,7 @@ typename UnwrapHelper::Outer *GetWrapped(iface *obj) #if WRAPPING_DEBUG if(obj != NULL && !wrapped->IsAlloc(wrapped)) { - RDCERR("Trying to unwrap invalid type"); + RDCWARN("Trying to unwrap invalid type"); return NULL; } #endif @@ -578,7 +578,12 @@ iface *Unwrap(iface *obj) if(obj == NULL) return NULL; - return GetWrapped(obj)->GetReal(); + auto wrapped = GetWrapped(obj); + + if(wrapped) + return wrapped->GetReal(); + + return NULL; } template @@ -587,7 +592,12 @@ ResourceId GetResID(iface *obj) if(obj == NULL) return ResourceId(); - return GetWrapped(obj)->GetResourceID(); + auto wrapped = GetWrapped(obj); + + if(wrapped) + return wrapped->GetResourceID(); + + return ResourceId(); } template @@ -596,7 +606,12 @@ D3D12ResourceRecord *GetRecord(iface *obj) if(obj == NULL) return NULL; - return GetWrapped(obj)->GetResourceRecord(); + auto wrapped = GetWrapped(obj); + + if(wrapped) + return wrapped->GetResourceRecord(); + + return NULL; } // specialisations that use the GetTracked() function to fetch the ID