mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Avoid some redundant checks in GetLiveResource
* Historically we always expected a live resource, but with descriptors that can be stale we can have a lot of queries where it's fine to just get NULL back if the resource doesn't exist.
This commit is contained in:
@@ -638,7 +638,7 @@ public:
|
||||
// Live resources to replace serialised IDs
|
||||
void AddLiveResource(ResourceId origid, WrappedResourceType livePtr);
|
||||
bool HasLiveResource(ResourceId origid);
|
||||
WrappedResourceType GetLiveResource(ResourceId origid);
|
||||
WrappedResourceType GetLiveResource(ResourceId origid, bool optional = false);
|
||||
void EraseLiveResource(ResourceId origid);
|
||||
|
||||
// when asked for a given id, return the resource for a replacement id
|
||||
@@ -1816,20 +1816,31 @@ bool ResourceManager<Configuration>::HasLiveResource(ResourceId origid)
|
||||
|
||||
template <typename Configuration>
|
||||
typename Configuration::WrappedResourceType ResourceManager<Configuration>::GetLiveResource(
|
||||
ResourceId origid)
|
||||
ResourceId origid, bool optional)
|
||||
{
|
||||
SCOPED_LOCK_OPTIONAL(m_Lock, m_Capturing);
|
||||
|
||||
if(origid == ResourceId())
|
||||
return (WrappedResourceType)RecordType::NullResource;
|
||||
|
||||
RDCASSERT(HasLiveResource(origid), origid);
|
||||
#if DISABLED(RDOC_RELEASE)
|
||||
if(!optional)
|
||||
{
|
||||
RDCASSERT(HasLiveResource(origid), origid);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(m_Replacements.find(origid) != m_Replacements.end())
|
||||
return GetLiveResource(m_Replacements[origid]);
|
||||
{
|
||||
auto it = m_Replacements.find(origid);
|
||||
if(it != m_Replacements.end())
|
||||
return GetLiveResource(it->second);
|
||||
}
|
||||
|
||||
if(m_LiveResourceMap.find(origid) != m_LiveResourceMap.end())
|
||||
return m_LiveResourceMap[origid];
|
||||
{
|
||||
auto it = m_LiveResourceMap.find(origid);
|
||||
if(it != m_LiveResourceMap.end())
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return (WrappedResourceType)RecordType::NullResource;
|
||||
}
|
||||
|
||||
@@ -629,10 +629,8 @@ D3D12Descriptor *DescriptorFromPortableHandle(D3D12ResourceManager *manager, Por
|
||||
if(handle.heap == ResourceId())
|
||||
return NULL;
|
||||
|
||||
if(!manager->HasLiveResource(handle.heap))
|
||||
return NULL;
|
||||
|
||||
WrappedID3D12DescriptorHeap *heap = manager->GetLiveAs<WrappedID3D12DescriptorHeap>(handle.heap);
|
||||
WrappedID3D12DescriptorHeap *heap =
|
||||
manager->GetLiveAs<WrappedID3D12DescriptorHeap>(handle.heap, true);
|
||||
|
||||
if(heap)
|
||||
return heap->GetDescriptors() + handle.index;
|
||||
|
||||
@@ -693,9 +693,9 @@ public:
|
||||
{
|
||||
}
|
||||
template <class T>
|
||||
T *GetLiveAs(ResourceId id)
|
||||
T *GetLiveAs(ResourceId id, bool optional = false)
|
||||
{
|
||||
return (T *)GetLiveResource(id);
|
||||
return (T *)GetLiveResource(id, optional);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
||||
Reference in New Issue
Block a user