Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/gpgmm/d3d12/ResidencyHeapD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,20 @@ namespace gpgmm::d3d12 {
}
}

ResidencyHeap::~ResidencyHeap() {
if (mResidencyManager == nullptr) {
return;
}

void ResidencyHeap::DeleteThis() {
if (IsResidencyLocked() && GPGMM_UNSUCCESSFUL(Unlock())) {
DebugLog(MessageId::kUnknown, this)
<< "Heap was locked for residency while being destroyed.";
}

Unknown::DeleteThis();
}

ResidencyHeap::~ResidencyHeap() {
if (mResidencyManager == nullptr) {
return;
}

// When a heap is destroyed, it no longer resides in resident memory, so we must evict
// it from the residency cache. If this heap is not manually removed from the residency
// cache, the ResidencyManager will attempt to use it after it has been deallocated.
Expand Down
3 changes: 3 additions & 0 deletions src/gpgmm/d3d12/ResidencyHeapD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ namespace gpgmm::d3d12 {
const RESIDENCY_HEAP_DESC& descriptor,
bool isResidencyDisabled);

// Unknown interface
void DeleteThis() override;

// ObjectBase interface
DEFINE_OBJECT_BASE_OVERRIDES(IHeap)

Expand Down
7 changes: 5 additions & 2 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,13 @@ namespace gpgmm::d3d12 {
ASSERT(mAdapter != nullptr);
}

ResidencyManager::~ResidencyManager() {
GPGMM_TRACE_EVENT_OBJECT_DESTROY(this);
void ResidencyManager::DeleteThis() {
StopBudgetNotificationUpdates();
Unknown::DeleteThis();
}

ResidencyManager::~ResidencyManager() {
GPGMM_TRACE_EVENT_OBJECT_DESTROY(this);
if (mFlushEventBuffersOnDestruct) {
FlushEventTraceToDisk();
}
Expand Down
3 changes: 3 additions & 0 deletions src/gpgmm/d3d12/ResidencyManagerD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ namespace gpgmm::d3d12 {
IDXGIAdapter3* pAdapter,
std::unique_ptr<Caps> caps);

// Unknown interface
void DeleteThis() override;

HRESULT EvictInternal(uint64_t bytesToEvict,
const DXGI_MEMORY_SEGMENT_GROUP& heapSegment,
uint64_t* bytesEvictedOut = nullptr);
Expand Down
9 changes: 6 additions & 3 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -832,9 +832,7 @@ namespace gpgmm::d3d12 {
/*allowSlabPrefetch*/ false, std::move(pooledOrNonPooledAllocator));
}

ResourceAllocator::~ResourceAllocator() {
GPGMM_TRACE_EVENT_OBJECT_DESTROY(this);

void ResourceAllocator::DeleteThis() {
// Give the debug allocator the first chance to report allocation leaks.
// If allocation leak exists, report then release them immediately to prevent another leak
// check from re-reporting the leaked allocation.
Expand Down Expand Up @@ -870,6 +868,11 @@ namespace gpgmm::d3d12 {
#endif
mResidencyManager = nullptr;

Unknown::DeleteThis();
}

ResourceAllocator::~ResourceAllocator() {
GPGMM_TRACE_EVENT_OBJECT_DESTROY(this);
if (mFlushEventBuffersOnDestruct) {
FlushEventTraceToDisk();
}
Expand Down
2 changes: 2 additions & 0 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ namespace gpgmm::d3d12 {
ResidencyManager* pResidencyManager,
std::unique_ptr<Caps> caps);

void DeleteThis() override;

template <typename CreateResourceFn>
MaybeError TryAllocateResource(MemoryAllocatorBase* allocator,
const MemoryAllocationRequest& request,
Expand Down