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
7 changes: 5 additions & 2 deletions src/gpgmm/d3d12/HeapD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ namespace gpgmm::d3d12 {

// Ensure enough budget exists before creating the heap to avoid an out-of-memory error.
if (!isResidencyDisabled && (descriptor.Flags & HEAP_FLAG_ALWAYS_IN_BUDGET)) {
ReturnIfFailed(residencyManager->EnsureInBudget(descriptor.SizeInBytes,
descriptor.MemorySegmentGroup));
if (FAILED(residencyManager->EnsureInBudget(descriptor.SizeInBytes,
descriptor.MemorySegmentGroup))) {
gpgmm::ErrorLog() << "Unable to create heap because not enough budget exists.";
return E_OUTOFMEMORY;
}
}

ComPtr<ID3D12Pageable> pageable;
Expand Down
13 changes: 11 additions & 2 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ namespace gpgmm::d3d12 {
const D3D12_RESOURCE_ALLOCATION_INFO resourceInfo =
GetResourceAllocationInfo(mDevice.Get(), newResourceDesc);
if (resourceInfo.SizeInBytes > mCaps->GetMaxResourceSize()) {
gpgmm::ErrorLog() << "Unable to create resource allocation because the size exceeded "
"capabilities of the device.";
return E_OUTOFMEMORY;
}

Expand Down Expand Up @@ -962,6 +964,9 @@ namespace gpgmm::d3d12 {
const RESOURCE_HEAP_TYPE resourceHeapType = GetResourceHeapType(
newResourceDesc.Dimension, heapType, newResourceDesc.Flags, mResourceHeapTier);
if (resourceHeapType == RESOURCE_HEAP_TYPE_INVALID) {
gpgmm::ErrorLog()
<< "Unable to create resource allocation because the resource type was invalid due "
"to the combination of resource flags, descriptor, and resource heap tier.";
return E_INVALIDARG;
}

Expand Down Expand Up @@ -1193,12 +1198,15 @@ namespace gpgmm::d3d12 {
// allocations where sub-allocation or pooling is otherwise ineffective.
// The time and space complexity of committed resource is driver-defined.
if (request.NeverAllocate) {
ErrorLog() << "Unable to allocate memory for resource because no memory was allowed to "
"be created.";
return E_OUTOFMEMORY;
}

// Committed resources cannot specify resource heap size.
if (GPGMM_UNLIKELY(requiresPadding)) {
ErrorLog() << "A padding was specified but no resource allocator could be used.";
ErrorLog() << "Unable to allocate memory for resource because a padding was specified "
"but no resource allocator could be used.";
return E_FAIL;
}

Expand All @@ -1207,7 +1215,8 @@ namespace gpgmm::d3d12 {
return E_FAIL;
}
InfoEvent(this, EventMessageId::kAllocatorFailed)
<< "Unable to allocate by using a heap, falling back to a committed resource.";
<< "Unable to allocate memory for a resource by using a heap, falling back to a "
"committed resource.";
}

ComPtr<ID3D12Resource> committedResource;
Expand Down