Skip to content

Commit

Permalink
Rename ALLOCATION_TYPE => RESOURCE_ALLOCATION_TYPE. (#898)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbernhar authored Aug 16, 2023
1 parent 0fe82e2 commit fd3b67a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 49 deletions.
14 changes: 7 additions & 7 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,33 +518,33 @@ namespace gpgmm::d3d12 {
UINT64 CurrentHeapCount;
};

/** \enum ALLOCATION_TYPE
/** \enum RESOURCE_ALLOCATION_TYPE
Represents how memory was allocated.
*/
enum ALLOCATION_TYPE {
enum RESOURCE_ALLOCATION_TYPE {
/** \brief Not yet allocated or invalid.
This is an invalid state that assigned temporary before the actual method is known.
*/
ALLOCATION_TYPE_UNKNOWN = 0,
RESOURCE_ALLOCATION_TYPE_UNKNOWN = 0,

/** \brief Not sub-divided.
One and only one allocation exists for the memory.
*/
ALLOCATION_TYPE_STANDALONE = 1,
RESOURCE_ALLOCATION_TYPE_STANDALONE = 1,

/** \brief Sub-divided using one or more allocations.
Underlying memory will be broken up into one or more memory allocations.
*/
ALLOCATION_TYPE_SUBALLOCATED = 2,
RESOURCE_ALLOCATION_TYPE_SUBALLOCATED = 2,

/** \brief Sub-divided within a single memory allocation.
A single memory allocation will be broken into one or more sub-allocations.
*/
ALLOCATION_TYPE_SUBALLOCATED_WITHIN = 3,
RESOURCE_ALLOCATION_TYPE_SUBALLOCATED_WITHIN = 3,
};

/** \brief ResidencyManager tracks and maintains one or more Heap within a residency cache.
Expand Down Expand Up @@ -676,7 +676,7 @@ namespace gpgmm::d3d12 {

/** \brief Describes the method used to allocate memory for the resource.
*/
ALLOCATION_TYPE Type;
RESOURCE_ALLOCATION_TYPE Type;
};

/** \brief ResourceAllocation is an allocation that contains a ID3D12Resource.
Expand Down
9 changes: 5 additions & 4 deletions src/gpgmm/d3d12/ResourceAllocationD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace gpgmm::d3d12 {
void** ppDataOut) {
// Allocation coordinates relative to the resource cannot be used when specifying
// subresource-relative coordinates.
if (subresource > 0 && GetInfo().Type == ALLOCATION_TYPE_SUBALLOCATED_WITHIN) {
if (subresource > 0 && GetInfo().Type == RESOURCE_ALLOCATION_TYPE_SUBALLOCATED_WITHIN) {
ErrorLog(ErrorCode::kBadOperation, this)
<< "Mapping a sub-allocation within a resource cannot use "
"non-zero subresource-relative coordinates.";
Expand Down Expand Up @@ -115,7 +115,7 @@ namespace gpgmm::d3d12 {
void ResourceAllocation::Unmap(uint32_t subresource, const D3D12_RANGE* pWrittenRange) {
// Allocation coordinates relative to the resource cannot be used when specifying
// subresource-relative coordinates.
if (subresource > 0 && GetInfo().Type == ALLOCATION_TYPE_SUBALLOCATED_WITHIN) {
if (subresource > 0 && GetInfo().Type == RESOURCE_ALLOCATION_TYPE_SUBALLOCATED_WITHIN) {
ErrorLog(ErrorCode::kBadOperation, this)
<< "Unmapping a sub-allocation within a resource cannot use "
"non-zero subresource-relative coordinates.";
Expand Down Expand Up @@ -148,7 +148,7 @@ namespace gpgmm::d3d12 {
}

RESOURCE_ALLOCATION_INFO ResourceAllocation::GetInfo() const {
return {GetSize(), GetAlignment(), static_cast<ALLOCATION_TYPE>(GetMethod())};
return {GetSize(), GetAlignment(), static_cast<RESOURCE_ALLOCATION_TYPE>(GetMethod())};
}

IResidencyHeap* ResourceAllocation::GetMemory() const {
Expand All @@ -161,7 +161,8 @@ namespace gpgmm::d3d12 {

HRESULT ResourceAllocation::SetDebugNameImpl(LPCWSTR name) {
// D3D name is set per resource.
if (GetDebugName() != nullptr && GetInfo().Type == ALLOCATION_TYPE_SUBALLOCATED_WITHIN) {
if (GetDebugName() != nullptr &&
GetInfo().Type == RESOURCE_ALLOCATION_TYPE_SUBALLOCATED_WITHIN) {
return S_FALSE;
}

Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/ResourceAllocationD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace gpgmm::d3d12 {
uint64_t SizeInBytes;
uint64_t HeapOffset;
uint64_t OffsetFromResource;
ALLOCATION_TYPE Type;
RESOURCE_ALLOCATION_TYPE Type;
LPCWSTR DebugName;
};

Expand Down
12 changes: 7 additions & 5 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ namespace gpgmm::d3d12 {
RESOURCE_ALLOCATION_DESC allocationDesc = {};
allocationDesc.SizeInBytes = resourceDescriptor.Width;
allocationDesc.HeapOffset = kInvalidOffset;
allocationDesc.Type = ALLOCATION_TYPE_SUBALLOCATED_WITHIN;
allocationDesc.Type = RESOURCE_ALLOCATION_TYPE_SUBALLOCATED_WITHIN;
allocationDesc.OffsetFromResource = subAllocation.GetOffset();
allocationDesc.DebugName = allocationDescriptor.DebugName;

Expand Down Expand Up @@ -1270,7 +1270,8 @@ namespace gpgmm::d3d12 {
RESOURCE_ALLOCATION_DESC allocationDesc = {};
allocationDesc.SizeInBytes = subAllocRequest.SizeInBytes;
allocationDesc.HeapOffset = subAllocation.GetOffset();
allocationDesc.Type = static_cast<ALLOCATION_TYPE>(subAllocation.GetMethod());
allocationDesc.Type =
static_cast<RESOURCE_ALLOCATION_TYPE>(subAllocation.GetMethod());
allocationDesc.OffsetFromResource = 0;
allocationDesc.DebugName = allocationDescriptor.DebugName;

Expand Down Expand Up @@ -1313,7 +1314,8 @@ namespace gpgmm::d3d12 {
RESOURCE_ALLOCATION_DESC allocationDesc = {};
allocationDesc.SizeInBytes = dedicatedRequest.SizeInBytes;
allocationDesc.HeapOffset = allocation.GetOffset();
allocationDesc.Type = static_cast<ALLOCATION_TYPE>(allocation.GetMethod());
allocationDesc.Type =
static_cast<RESOURCE_ALLOCATION_TYPE>(allocation.GetMethod());
allocationDesc.OffsetFromResource = 0;
allocationDesc.DebugName = allocationDescriptor.DebugName;

Expand Down Expand Up @@ -1378,7 +1380,7 @@ namespace gpgmm::d3d12 {
RESOURCE_ALLOCATION_DESC allocationDesc = {};
allocationDesc.HeapOffset = kInvalidOffset;
allocationDesc.SizeInBytes = request.SizeInBytes;
allocationDesc.Type = ALLOCATION_TYPE_STANDALONE;
allocationDesc.Type = RESOURCE_ALLOCATION_TYPE_STANDALONE;
allocationDesc.DebugName = allocationDescriptor.DebugName;

if (ppResourceAllocationOut != nullptr) {
Expand Down Expand Up @@ -1469,7 +1471,7 @@ namespace gpgmm::d3d12 {
RESOURCE_ALLOCATION_DESC allocationDesc = {};
allocationDesc.HeapOffset = kInvalidSize;
allocationDesc.SizeInBytes = allocationSize;
allocationDesc.Type = ALLOCATION_TYPE_STANDALONE;
allocationDesc.Type = RESOURCE_ALLOCATION_TYPE_STANDALONE;

*ppResourceAllocationOut = new ResourceAllocation(
allocationDesc, nullptr, this, static_cast<ResidencyHeap*>(resourceHeap.Detach()),
Expand Down
Loading

0 comments on commit fd3b67a

Please sign in to comment.