From 2ce9005f15dce2b96aeab7e54a785a3f633a0053 Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Tue, 30 Aug 2022 14:24:42 -0700 Subject: [PATCH] Rename RESOURCE_ALLOCATION_DESC::RequestSizeInBytes to RESOURCE_ALLOCATION_DESC::SizeInBytes. --- src/gpgmm/d3d12/JSONSerializerD3D12.cpp | 2 +- src/gpgmm/d3d12/ResourceAllocationD3D12.cpp | 18 +++++++++--------- src/gpgmm/d3d12/ResourceAllocationD3D12.h | 17 +++++++++-------- src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp | 10 +++++----- 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp index 774970e2b..f112cc8c6 100644 --- a/src/gpgmm/d3d12/JSONSerializerD3D12.cpp +++ b/src/gpgmm/d3d12/JSONSerializerD3D12.cpp @@ -182,7 +182,7 @@ namespace gpgmm::d3d12 { // static JSONDict JSONSerializer::Serialize(const RESOURCE_ALLOCATION_DESC& desc) { JSONDict dict; - dict.AddItem("RequestSizeInBytes", desc.RequestSizeInBytes); + dict.AddItem("SizeInBytes", desc.SizeInBytes); dict.AddItem("HeapOffset", desc.HeapOffset); dict.AddItem("OffsetFromResource", desc.OffsetFromResource); dict.AddItem("Method", desc.Method); diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp index 45722782d..c3be0966e 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.cpp @@ -52,7 +52,7 @@ namespace gpgmm::d3d12 { desc.HeapOffset, desc.Method, block, - desc.RequestSizeInBytes), + desc.SizeInBytes), mResidencyManager(residencyManager), mResource(std::move(resource)), mOffsetFromResource(desc.OffsetFromResource) { @@ -73,8 +73,8 @@ namespace gpgmm::d3d12 { } HRESULT ResourceAllocation::Map(uint32_t subresource, - const D3D12_RANGE* readRange, - void** dataOut) { + const D3D12_RANGE* pReadRange, + void** ppDataOut) { // Allocation coordinates relative to the resource cannot be used when specifying // subresource-relative coordinates. if (subresource > 0 && GetMethod() == AllocationMethod::kSubAllocatedWithin) { @@ -89,24 +89,24 @@ namespace gpgmm::d3d12 { // adjusted if the entire resource is being mapped where allocation coordinates are relative // to entire resource. D3D12_RANGE newReadRange{}; - const D3D12_RANGE* newReadRangePtr = readRange; + const D3D12_RANGE* newReadRangePtr = pReadRange; if (newReadRangePtr != nullptr && mOffsetFromResource > 0) { ASSERT(subresource == 0); - newReadRange = GetResourceRange(readRange, static_cast(mOffsetFromResource)); + newReadRange = GetResourceRange(pReadRange, static_cast(mOffsetFromResource)); newReadRangePtr = &newReadRange; } void* mappedData = nullptr; ReturnIfFailed(mResource->Map(subresource, newReadRangePtr, &mappedData)); - if (dataOut != nullptr) { - *dataOut = static_cast(mappedData) + mOffsetFromResource; + if (ppDataOut != nullptr) { + *ppDataOut = static_cast(mappedData) + mOffsetFromResource; } return S_OK; } - void ResourceAllocation::Unmap(uint32_t subresource, const D3D12_RANGE* writtenRange) { + void ResourceAllocation::Unmap(uint32_t subresource, const D3D12_RANGE* pWrittenRange) { // Allocation coordinates relative to the resource cannot be used when specifying // subresource-relative coordinates. ASSERT(subresource == 0 || GetMethod() != AllocationMethod::kSubAllocatedWithin); @@ -116,7 +116,7 @@ namespace gpgmm::d3d12 { } D3D12_RANGE newWrittenRange{}; - const D3D12_RANGE* newWrittenRangePtr = writtenRange; + const D3D12_RANGE* newWrittenRangePtr = pWrittenRange; if (newWrittenRangePtr != nullptr && mOffsetFromResource > 0) { ASSERT(subresource == 0); newWrittenRange = diff --git a/src/gpgmm/d3d12/ResourceAllocationD3D12.h b/src/gpgmm/d3d12/ResourceAllocationD3D12.h index ce47f1903..195e28bfd 100644 --- a/src/gpgmm/d3d12/ResourceAllocationD3D12.h +++ b/src/gpgmm/d3d12/ResourceAllocationD3D12.h @@ -37,9 +37,10 @@ namespace gpgmm::d3d12 { struct RESOURCE_ALLOCATION_DESC { /** \brief Requested size, in bytes, of the resource allocation. - Must be non-zero. + The requested size is the non-zero allocation size before being subjected to allocator + alignment. */ - uint64_t RequestSizeInBytes; + uint64_t SizeInBytes; /** \brief Offset, in bytes, of the resource in the heap. */ @@ -48,7 +49,7 @@ namespace gpgmm::d3d12 { /** \brief Offset, in bytes, of the allocation, from the start of the resource. - Always zero when the resource is placed in a heap or created with it's own heap. + Always zero when the resource is placed in a heap or created with it's own heap. */ uint64_t OffsetFromResource; @@ -104,14 +105,14 @@ namespace gpgmm::d3d12 { pointer value will start from the allocation instead of the resource. @param subresource Specifies the index number of the subresource. - @param readRange A pointer to a D3D12_RANGE structure that describes the range of memory to + @param pReadRange A pointer to a D3D12_RANGE structure that describes the range of memory to access. - @param[out] dataOut A pointer to a memory block that receives a pointer to the resource + @param[out] ppDataOut A pointer to a memory block that receives a pointer to the resource data. */ HRESULT Map(uint32_t subresource = 0, - const D3D12_RANGE* readRange = nullptr, - void** dataOut = nullptr); + const D3D12_RANGE* pReadRange = nullptr, + void** ppDataOut = nullptr); /** \brief Unmaps the resource allocation. @@ -121,7 +122,7 @@ namespace gpgmm::d3d12 { @param writtenRange A pointer to a D3D12_RANGE structure that describes the range of memory to unmap. */ - void Unmap(uint32_t subresource = 0, const D3D12_RANGE* writtenRange = nullptr); + void Unmap(uint32_t subresource = 0, const D3D12_RANGE* pWrittenRange = nullptr); /** \brief Returns the resource owned by this allocation. diff --git a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp index dd72e5f14..8eb405857 100644 --- a/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp +++ b/src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp @@ -882,7 +882,7 @@ namespace gpgmm::d3d12 { ReturnIfFailed(resourceHeap->QueryInterface(IID_PPV_ARGS(&committedResource))); RESOURCE_ALLOCATION_DESC allocationDesc = {}; - allocationDesc.RequestSizeInBytes = resourceDescriptor.Width; + allocationDesc.SizeInBytes = resourceDescriptor.Width; allocationDesc.HeapOffset = kInvalidOffset; allocationDesc.Method = AllocationMethod::kSubAllocatedWithin; allocationDesc.OffsetFromResource = subAllocation.GetOffset(); @@ -921,7 +921,7 @@ namespace gpgmm::d3d12 { initialResourceState, &placedResource)); RESOURCE_ALLOCATION_DESC allocationDesc = {}; - allocationDesc.RequestSizeInBytes = request.SizeInBytes; + allocationDesc.SizeInBytes = request.SizeInBytes; allocationDesc.HeapOffset = subAllocation.GetOffset(); allocationDesc.Method = subAllocation.GetMethod(); allocationDesc.OffsetFromResource = 0; @@ -960,7 +960,7 @@ namespace gpgmm::d3d12 { initialResourceState, &placedResource)); RESOURCE_ALLOCATION_DESC allocationDesc = {}; - allocationDesc.RequestSizeInBytes = request.SizeInBytes; + allocationDesc.SizeInBytes = request.SizeInBytes; allocationDesc.HeapOffset = allocation.GetOffset(); allocationDesc.Method = allocation.GetMethod(); allocationDesc.OffsetFromResource = 0; @@ -1008,7 +1008,7 @@ namespace gpgmm::d3d12 { RESOURCE_ALLOCATION_DESC allocationDesc = {}; allocationDesc.HeapOffset = kInvalidOffset; - allocationDesc.RequestSizeInBytes = request.SizeInBytes; + allocationDesc.SizeInBytes = request.SizeInBytes; allocationDesc.Method = AllocationMethod::kStandalone; allocationDesc.OffsetFromResource = 0; allocationDesc.DebugName = allocationDescriptor.DebugName; @@ -1064,7 +1064,7 @@ namespace gpgmm::d3d12 { RESOURCE_ALLOCATION_DESC allocationDesc = {}; allocationDesc.HeapOffset = kInvalidSize; - allocationDesc.RequestSizeInBytes = resourceInfo.SizeInBytes; + allocationDesc.SizeInBytes = resourceInfo.SizeInBytes; allocationDesc.Method = AllocationMethod::kStandalone; allocationDesc.OffsetFromResource = 0;