diff --git a/src/gpgmm/common/BuddyBlockAllocator.cpp b/src/gpgmm/common/BuddyBlockAllocator.cpp index 429fe095..14d7dd4d 100644 --- a/src/gpgmm/common/BuddyBlockAllocator.cpp +++ b/src/gpgmm/common/BuddyBlockAllocator.cpp @@ -262,8 +262,4 @@ namespace gpgmm { SafeDelete(block); } - const char* BuddyBlockAllocator::GetTypename() const { - return "BuddyBlockAllocator"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/BuddyBlockAllocator.h b/src/gpgmm/common/BuddyBlockAllocator.h index 82f98346..c5a991af 100644 --- a/src/gpgmm/common/BuddyBlockAllocator.h +++ b/src/gpgmm/common/BuddyBlockAllocator.h @@ -50,7 +50,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(BuddyBlockAllocator) uint32_t ComputeLevelFromBlockSize(uint64_t blockSize) const; uint64_t GetNextFreeAlignedBlock(size_t allocationBlockLevel, uint64_t alignment) const; diff --git a/src/gpgmm/common/BuddyMemoryAllocator.cpp b/src/gpgmm/common/BuddyMemoryAllocator.cpp index 307025fb..cafaae3f 100644 --- a/src/gpgmm/common/BuddyMemoryAllocator.cpp +++ b/src/gpgmm/common/BuddyMemoryAllocator.cpp @@ -146,8 +146,4 @@ namespace gpgmm { return result; } - const char* BuddyMemoryAllocator::GetTypename() const { - return "BuddyMemoryAllocator"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/BuddyMemoryAllocator.h b/src/gpgmm/common/BuddyMemoryAllocator.h index 62f28ca6..5d21530a 100644 --- a/src/gpgmm/common/BuddyMemoryAllocator.h +++ b/src/gpgmm/common/BuddyMemoryAllocator.h @@ -53,7 +53,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(BuddyMemoryAllocator) uint64_t GetMemoryIndex(uint64_t offset) const; diff --git a/src/gpgmm/common/ConditionalMemoryAllocator.cpp b/src/gpgmm/common/ConditionalMemoryAllocator.cpp index 697c5f13..dab849eb 100644 --- a/src/gpgmm/common/ConditionalMemoryAllocator.cpp +++ b/src/gpgmm/common/ConditionalMemoryAllocator.cpp @@ -52,10 +52,6 @@ namespace gpgmm { return result; } - const char* ConditionalMemoryAllocator::GetTypename() const { - return "ConditionalMemoryAllocator"; - } - MemoryAllocator* ConditionalMemoryAllocator::GetFirstAllocatorForTesting() const { return mFirstAllocator.get(); } diff --git a/src/gpgmm/common/ConditionalMemoryAllocator.h b/src/gpgmm/common/ConditionalMemoryAllocator.h index 18bbdbdb..7e566644 100644 --- a/src/gpgmm/common/ConditionalMemoryAllocator.h +++ b/src/gpgmm/common/ConditionalMemoryAllocator.h @@ -41,7 +41,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(ConditionalMemoryAllocator) std::unique_ptr mFirstAllocator; std::unique_ptr mSecondAllocator; diff --git a/src/gpgmm/common/DedicatedMemoryAllocator.cpp b/src/gpgmm/common/DedicatedMemoryAllocator.cpp index 8d157e05..863fb079 100644 --- a/src/gpgmm/common/DedicatedMemoryAllocator.cpp +++ b/src/gpgmm/common/DedicatedMemoryAllocator.cpp @@ -80,8 +80,4 @@ namespace gpgmm { uint64_t DedicatedMemoryAllocator::GetMemoryAlignment() const { return mMemoryAlignment; } - - const char* DedicatedMemoryAllocator::GetTypename() const { - return "DedicatedMemoryAllocator"; - } } // namespace gpgmm diff --git a/src/gpgmm/common/DedicatedMemoryAllocator.h b/src/gpgmm/common/DedicatedMemoryAllocator.h index 30b10045..c1617cce 100644 --- a/src/gpgmm/common/DedicatedMemoryAllocator.h +++ b/src/gpgmm/common/DedicatedMemoryAllocator.h @@ -38,7 +38,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(DedicatedMemoryAllocator) const uint64_t mMemoryAlignment; }; diff --git a/src/gpgmm/common/Memory.cpp b/src/gpgmm/common/Memory.cpp index 01ffedf5..574538e7 100644 --- a/src/gpgmm/common/Memory.cpp +++ b/src/gpgmm/common/Memory.cpp @@ -53,8 +53,4 @@ namespace gpgmm { return mSubAllocationRefs.Unref(); } - const char* MemoryBase::GetTypename() const { - return "Memory"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/Memory.h b/src/gpgmm/common/Memory.h index d9517d36..d54c2232 100644 --- a/src/gpgmm/common/Memory.h +++ b/src/gpgmm/common/Memory.h @@ -38,7 +38,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(MemoryBase) RefCounted mSubAllocationRefs; diff --git a/src/gpgmm/common/MemoryAllocation.cpp b/src/gpgmm/common/MemoryAllocation.cpp index 4a7c95a3..e8b8dde2 100644 --- a/src/gpgmm/common/MemoryAllocation.cpp +++ b/src/gpgmm/common/MemoryAllocation.cpp @@ -134,8 +134,4 @@ namespace gpgmm { return mBlock; } - const char* MemoryAllocation::GetTypename() const { - return "Allocation"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/MemoryAllocation.h b/src/gpgmm/common/MemoryAllocation.h index 25b13e2b..dd66f733 100644 --- a/src/gpgmm/common/MemoryAllocation.h +++ b/src/gpgmm/common/MemoryAllocation.h @@ -99,7 +99,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(MemoryAllocation) MemoryBase* mMemory; uint64_t mOffset; // Offset always local to the memory. diff --git a/src/gpgmm/common/MemoryAllocator.cpp b/src/gpgmm/common/MemoryAllocator.cpp index c38ff08e..86f94ccb 100644 --- a/src/gpgmm/common/MemoryAllocator.cpp +++ b/src/gpgmm/common/MemoryAllocator.cpp @@ -156,10 +156,6 @@ namespace gpgmm { return mStats; } - const char* MemoryAllocator::GetTypename() const { - return "MemoryAllocator"; - } - bool MemoryAllocator::ValidateRequest(const MemoryAllocationRequest& request) const { ASSERT(request.SizeInBytes > 0 && request.Alignment > 0); diff --git a/src/gpgmm/common/MemoryAllocator.h b/src/gpgmm/common/MemoryAllocator.h index 96d0d05a..562f6599 100644 --- a/src/gpgmm/common/MemoryAllocator.h +++ b/src/gpgmm/common/MemoryAllocator.h @@ -264,7 +264,7 @@ namespace gpgmm { The type is used for profiling and debugging purposes only. */ - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(MemoryAllocator) /** \brief Checks if the request is valid. diff --git a/src/gpgmm/common/Object.h b/src/gpgmm/common/Object.h index fdfb2b39..74886aec 100644 --- a/src/gpgmm/common/Object.h +++ b/src/gpgmm/common/Object.h @@ -28,6 +28,11 @@ namespace gpgmm { virtual const char* GetTypename() const = 0; }; +// Helper to provide ObjectBase-based object types the type name based on class name. +#define DEFINE_OBJECT_BASE_OVERRIDES(type) \ + inline const char* GetTypename() const override { \ + return #type; \ + } } // namespace gpgmm #endif // GPGMM_COMMON_OBJECT_H_ diff --git a/src/gpgmm/common/PooledMemoryAllocator.cpp b/src/gpgmm/common/PooledMemoryAllocator.cpp index dedfeaaa..2c7b64d6 100644 --- a/src/gpgmm/common/PooledMemoryAllocator.cpp +++ b/src/gpgmm/common/PooledMemoryAllocator.cpp @@ -97,8 +97,4 @@ namespace gpgmm { return mMemoryAlignment; } - const char* PooledMemoryAllocator::GetTypename() const { - return "PooledMemoryAllocator"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/PooledMemoryAllocator.h b/src/gpgmm/common/PooledMemoryAllocator.h index ec46cc72..b4dd468e 100644 --- a/src/gpgmm/common/PooledMemoryAllocator.h +++ b/src/gpgmm/common/PooledMemoryAllocator.h @@ -39,7 +39,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(PooledMemoryAllocator) std::unique_ptr mPool; uint64_t mMemoryAlignment; diff --git a/src/gpgmm/common/SegmentedMemoryAllocator.cpp b/src/gpgmm/common/SegmentedMemoryAllocator.cpp index 4a6160e8..e23e710f 100644 --- a/src/gpgmm/common/SegmentedMemoryAllocator.cpp +++ b/src/gpgmm/common/SegmentedMemoryAllocator.cpp @@ -207,8 +207,4 @@ namespace gpgmm { return std::distance(mFreeSegments.begin(), mFreeSegments.end()); } - const char* SegmentedMemoryAllocator::GetTypename() const { - return "SegmentedMemoryAllocator"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/SegmentedMemoryAllocator.h b/src/gpgmm/common/SegmentedMemoryAllocator.h index 6bce3897..851bd0f4 100644 --- a/src/gpgmm/common/SegmentedMemoryAllocator.h +++ b/src/gpgmm/common/SegmentedMemoryAllocator.h @@ -49,7 +49,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(SegmentedMemoryAllocator) MemorySegment* GetOrCreateFreeSegment(uint64_t memorySize); diff --git a/src/gpgmm/common/SlabBlockAllocator.cpp b/src/gpgmm/common/SlabBlockAllocator.cpp index 66f5f207..ae6454cb 100644 --- a/src/gpgmm/common/SlabBlockAllocator.cpp +++ b/src/gpgmm/common/SlabBlockAllocator.cpp @@ -109,8 +109,4 @@ namespace gpgmm { return mBlockCount; } - const char* SlabBlockAllocator::GetTypename() const { - return "SlabBlockAllocator"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/SlabBlockAllocator.h b/src/gpgmm/common/SlabBlockAllocator.h index 70723adc..6dcfae3c 100644 --- a/src/gpgmm/common/SlabBlockAllocator.h +++ b/src/gpgmm/common/SlabBlockAllocator.h @@ -54,7 +54,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(SlabBlockAllocator) struct BlockList { SlabBlock* pHead = nullptr; // First free block in slab. diff --git a/src/gpgmm/common/SlabMemoryAllocator.cpp b/src/gpgmm/common/SlabMemoryAllocator.cpp index 6bfb87b6..5748ddc0 100644 --- a/src/gpgmm/common/SlabMemoryAllocator.cpp +++ b/src/gpgmm/common/SlabMemoryAllocator.cpp @@ -465,10 +465,6 @@ namespace gpgmm { return result; } - const char* SlabMemoryAllocator::GetTypename() const { - return "SlabMemoryAllocator"; - } - bool SlabMemoryAllocator::IsPrefetchCoverageBelowThreshold() const { if (mStats.PrefetchedMemoryMissesEliminated >= mStats.PrefetchedMemoryMisses) { return true; @@ -595,8 +591,4 @@ namespace gpgmm { return GetNextInChain()->GetMemorySize(); } - const char* SlabCacheAllocator::GetTypename() const { - return "SlabCacheAllocator"; - } - } // namespace gpgmm diff --git a/src/gpgmm/common/SlabMemoryAllocator.h b/src/gpgmm/common/SlabMemoryAllocator.h index e40f6e34..0e0f1575 100644 --- a/src/gpgmm/common/SlabMemoryAllocator.h +++ b/src/gpgmm/common/SlabMemoryAllocator.h @@ -63,7 +63,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(SlabMemoryAllocator) uint64_t ComputeSlabSize(uint64_t requestSize, uint64_t baseSlabSize, @@ -132,7 +132,7 @@ namespace gpgmm { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(SlabCacheAllocator) class SlabAllocatorCacheEntry : public NonCopyable { public: diff --git a/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.cpp index d1121952..d146fa22 100644 --- a/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.cpp @@ -89,8 +89,4 @@ namespace gpgmm::d3d12 { entry->GetValue().GetAllocator()->DeallocateMemory(std::move(allocation)); } - const char* DebugResourceAllocator::GetTypename() const { - return "DebugResourceAllocator"; - } - } // namespace gpgmm::d3d12 diff --git a/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.h b/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.h index f6a3177c..54754151 100644 --- a/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/DebugResourceAllocatorD3D12.h @@ -35,7 +35,7 @@ namespace gpgmm::d3d12 { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(DebugResourceAllocator) void DeallocateMemory(std::unique_ptr allocation) override; diff --git a/src/gpgmm/d3d12/HeapD3D12.cpp b/src/gpgmm/d3d12/HeapD3D12.cpp index b1b0070f..0e1216eb 100644 --- a/src/gpgmm/d3d12/HeapD3D12.cpp +++ b/src/gpgmm/d3d12/HeapD3D12.cpp @@ -204,10 +204,6 @@ namespace gpgmm::d3d12 { GPGMM_TRACE_EVENT_OBJECT_DESTROY(this); } - const char* Heap::GetTypename() const { - return "IHeap"; - } - uint64_t Heap::GetLastUsedFenceValue() const { return mLastUsedFenceValue; } diff --git a/src/gpgmm/d3d12/HeapD3D12.h b/src/gpgmm/d3d12/HeapD3D12.h index a79fe3b2..b0093a4e 100644 --- a/src/gpgmm/d3d12/HeapD3D12.h +++ b/src/gpgmm/d3d12/HeapD3D12.h @@ -59,7 +59,7 @@ namespace gpgmm::d3d12 { bool isResidencyDisabled); // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(IHeap) HRESULT SetDebugNameImpl(LPCWSTR name) override; DXGI_MEMORY_SEGMENT_GROUP GetHeapSegment() const; diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp index 9d6524e3..2051bc77 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.cpp @@ -309,10 +309,6 @@ namespace gpgmm::d3d12 { } } - const char* ResidencyManager::GetTypename() const { - return "IResidencyManager"; - } - // Increments number of locks on a heap to ensure the heap remains resident. HRESULT ResidencyManager::LockHeap(IHeap* pHeap) { GPGMM_RETURN_IF_NULLPTR(pHeap); diff --git a/src/gpgmm/d3d12/ResidencyManagerD3D12.h b/src/gpgmm/d3d12/ResidencyManagerD3D12.h index 61cf84c3..b5061f11 100644 --- a/src/gpgmm/d3d12/ResidencyManagerD3D12.h +++ b/src/gpgmm/d3d12/ResidencyManagerD3D12.h @@ -99,7 +99,7 @@ namespace gpgmm::d3d12 { bool IsUMA() const; // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(IResidencyManager) using LRUCache = LinkedList; diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp index b95c268d..2d742349 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp @@ -151,10 +151,6 @@ namespace gpgmm::d3d12 { return {GetSize(), GetAlignment(), static_cast(GetMethod())}; } - const char* ResourceAllocation::GetTypename() const { - return "IResourceAllocation"; - } - IHeap* ResourceAllocation::GetMemory() const { return static_cast(MemoryAllocation::GetMemory()); } diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.h b/src/gpgmm/d3d12/ResourceAllocationD3D12.h index e4c5b202..2180d24d 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.h @@ -76,7 +76,7 @@ namespace gpgmm::d3d12 { void DeleteThis() override; // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(IResourceAllocation) ResidencyManager* const mResidencyManager; ComPtr mResource; diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index 8133e0ab..b7776d49 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -834,10 +834,6 @@ namespace gpgmm::d3d12 { } } - const char* ResourceAllocator::GetTypename() const { - return "IResourceAllocator"; - } - HRESULT ResourceAllocator::ReleaseResourceHeaps(uint64_t bytesToRelease, uint64_t* pBytesReleased) { std::lock_guard lock(mMutex); diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h index 87d447f9..c44bd648 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.h @@ -79,7 +79,7 @@ namespace gpgmm::d3d12 { friend ResourceAllocation; // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(IResourceAllocator) HRESULT CreateResourceInternal(const ALLOCATION_DESC& allocationDescriptor, const D3D12_RESOURCE_DESC& resourceDescriptor, diff --git a/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.cpp index 1375773a..dc9b2dce 100644 --- a/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.cpp @@ -98,10 +98,6 @@ namespace gpgmm::d3d12 { SafeRelease(allocation); } - const char* ResourceHeapAllocator::GetTypename() const { - return "ResourceHeapAllocator"; - } - CreateResourceHeapCallbackContext::CreateResourceHeapCallbackContext(ID3D12Device* device, D3D12_HEAP_DESC* heapDesc) : mDevice(device), mHeapDesc(heapDesc) { diff --git a/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.h b/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.h index ce3fce2c..cd4c884b 100644 --- a/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.h +++ b/src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.h @@ -52,7 +52,7 @@ namespace gpgmm::d3d12 { private: // ObjectBase interface - const char* GetTypename() const override; + DEFINE_OBJECT_BASE_OVERRIDES(ResourceHeapAllocator) ResidencyManager* const mResidencyManager; ID3D12Device* const mDevice;