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
6 changes: 3 additions & 3 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -1113,11 +1113,11 @@ namespace gpgmm::d3d12 {
const D3D12_CLEAR_VALUE* pClearValue,
IResourceAllocation** ppResourceAllocationOut) = 0;

/** \brief Imports an existing D3D12 resource.
/** \brief Use existing D3D12 resource as a resource allocation.

Allows externally created D3D12 resources to be used as a ResourceAllocation.
Returns a ResourceAllocation which represents an existing resource with a resource heap.

@param allocationDescriptor A reference to ALLOCATION_DESC structure that provides
@param allocationDescriptor A reference to ALLOCATION_DESC structure that provides.
properties for the resource allocation.
@param pCommittedResource A pointer to a committed ID3D12Resource.
@param[out] ppResourceAllocationOut Pointer to a memory block that receives a pointer to the
Expand Down
14 changes: 8 additions & 6 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,11 @@ namespace gpgmm::d3d12 {
return E_INVALIDARG;
}

// If no resource allocation is to be created then only validate by returning early.
if (ppResourceAllocationOut == nullptr) {
return S_FALSE;
}

HEAP_DESC resourceHeapDesc = {};
resourceHeapDesc.SizeInBytes = resourceInfo.SizeInBytes;
resourceHeapDesc.Alignment = resourceInfo.Alignment;
Expand All @@ -1328,13 +1333,10 @@ namespace gpgmm::d3d12 {
allocationDesc.HeapOffset = kInvalidSize;
allocationDesc.SizeInBytes = allocationSize;
allocationDesc.Method = AllocationMethod::kStandalone;
allocationDesc.OffsetFromResource = 0;

if (ppResourceAllocationOut != nullptr) {
*ppResourceAllocationOut = new ResourceAllocation(
allocationDesc, nullptr, this, static_cast<Heap*>(resourceHeap.Detach()), nullptr,
std::move(resource));
}
*ppResourceAllocationOut = new ResourceAllocation(allocationDesc, nullptr, this,
static_cast<Heap*>(resourceHeap.Detach()),
nullptr, std::move(resource));

return S_OK;
}
Expand Down