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
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/JSONSerializerD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 9 additions & 9 deletions src/gpgmm/d3d12/ResourceAllocationD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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<size_t>(mOffsetFromResource));
newReadRange = GetResourceRange(pReadRange, static_cast<size_t>(mOffsetFromResource));
newReadRangePtr = &newReadRange;
}

void* mappedData = nullptr;
ReturnIfFailed(mResource->Map(subresource, newReadRangePtr, &mappedData));

if (dataOut != nullptr) {
*dataOut = static_cast<uint8_t*>(mappedData) + mOffsetFromResource;
if (ppDataOut != nullptr) {
*ppDataOut = static_cast<uint8_t*>(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);
Expand All @@ -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 =
Expand Down
17 changes: 9 additions & 8 deletions src/gpgmm/d3d12/ResourceAllocationD3D12.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand All @@ -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;

Expand Down Expand Up @@ -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.

Expand All @@ -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.

Expand Down
10 changes: 5 additions & 5 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down