diff --git a/src/gpgmm/common/MemoryAllocation.cpp b/src/gpgmm/common/MemoryAllocation.cpp index e8b8dde20..4a7c95a30 100644 --- a/src/gpgmm/common/MemoryAllocation.cpp +++ b/src/gpgmm/common/MemoryAllocation.cpp @@ -134,4 +134,8 @@ 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 9cb9534ef..6c66084f5 100644 --- a/src/gpgmm/common/MemoryAllocation.h +++ b/src/gpgmm/common/MemoryAllocation.h @@ -16,6 +16,7 @@ #ifndef GPGMM_COMMON_MEMORYALLOCATION_H_ #define GPGMM_COMMON_MEMORYALLOCATION_H_ +#include "gpgmm/common/Object.h" #include "gpgmm/utils/Limits.h" #include @@ -27,7 +28,7 @@ namespace gpgmm { class MemoryAllocator; // Represents a location and range in memory. - class MemoryAllocation { + class MemoryAllocation : public ObjectBase { public: // Contructs an invalid memory allocation. MemoryAllocation(); @@ -43,7 +44,7 @@ namespace gpgmm { // Constructs a "standalone" memory allocation. MemoryAllocation(MemoryAllocator* allocator, MemoryBase* memory, uint64_t requestSize); - virtual ~MemoryAllocation() = default; + virtual ~MemoryAllocation() override = default; MemoryAllocation(const MemoryAllocation&) = default; MemoryAllocation& operator=(const MemoryAllocation&) = default; @@ -65,6 +66,9 @@ namespace gpgmm { MemoryAllocator* mAllocator; private: + // ObjectBase interface + const char* GetTypename() const override; + MemoryBase* mMemory; uint64_t mOffset; // Offset always local to the memory. AllocationMethod mMethod; diff --git a/src/gpgmm/common/Object.h b/src/gpgmm/common/Object.h index e2798fbc0..fdfb2b394 100644 --- a/src/gpgmm/common/Object.h +++ b/src/gpgmm/common/Object.h @@ -21,6 +21,10 @@ namespace gpgmm { public: ObjectBase() = default; virtual ~ObjectBase() = default; + + ObjectBase(const ObjectBase&) = default; + ObjectBase& operator=(const ObjectBase&) = default; + virtual const char* GetTypename() const = 0; }; diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp index 5ee5e6f04..8e81ce185 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp @@ -15,8 +15,8 @@ #include "gpgmm/d3d12/ResourceAllocationD3D12.h" +#include "gpgmm/common/EventMessage.h" #include "gpgmm/common/MemoryAllocator.h" -#include "gpgmm/common/TraceEvent.h" #include "gpgmm/d3d12/BackendD3D12.h" #include "gpgmm/d3d12/ErrorD3D12.h" #include "gpgmm/d3d12/HeapD3D12.h" @@ -78,7 +78,7 @@ namespace gpgmm::d3d12 { // Allocation coordinates relative to the resource cannot be used when specifying // subresource-relative coordinates. if (subresource > 0 && GetMethod() == AllocationMethod::kSubAllocatedWithin) { - gpgmm::ErrorLog(MessageId::kBadOperation) + gpgmm::ErrorEvent(this, MessageId::kBadOperation) << "Map() on resource sub-allocation within cannot use " "non-zero subresource-relative coordinates."; return E_INVALIDARG; @@ -114,7 +114,7 @@ namespace gpgmm::d3d12 { // Allocation coordinates relative to the resource cannot be used when specifying // subresource-relative coordinates. if (subresource > 0 && GetMethod() == AllocationMethod::kSubAllocatedWithin) { - gpgmm::ErrorLog(MessageId::kBadOperation) + gpgmm::ErrorEvent(this, MessageId::kBadOperation) << "Unmap() on resource sub-allocation within cannot use " "non-zero subresource-relative coordinates."; return; diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.h b/src/gpgmm/d3d12/ResourceAllocationD3D12.h index 4c6d439f3..8dfac2a65 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.h @@ -75,7 +75,8 @@ namespace gpgmm::d3d12 { void DeleteThis() override; - const char* GetTypename() const; + // ObjectBase interface + const char* GetTypename() const override; ResidencyManager* const mResidencyManager; ComPtr mResource;