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
4 changes: 4 additions & 0 deletions src/gpgmm/common/MemoryAllocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,8 @@ namespace gpgmm {
return mBlock;
}

const char* MemoryAllocation::GetTypename() const {
return "Allocation";
}

} // namespace gpgmm
8 changes: 6 additions & 2 deletions src/gpgmm/common/MemoryAllocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <gpgmm.h>
Expand All @@ -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();
Expand All @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/gpgmm/common/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
6 changes: 3 additions & 3 deletions src/gpgmm/d3d12/ResourceAllocationD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/gpgmm/d3d12/ResourceAllocationD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<ID3D12Resource> mResource;
Expand Down