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: 7 additions & 0 deletions src/gpgmm/common/DedicatedMemoryAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ namespace gpgmm {

MemoryAllocationRequest memoryRequest = request;
memoryRequest.Alignment = mMemoryAlignment;
memoryRequest.SizeInBytes = AlignTo(request.SizeInBytes, request.Alignment);

std::unique_ptr<MemoryAllocation> allocation;
GPGMM_TRY_ASSIGN(GetNextInChain()->TryAllocateMemory(memoryRequest), allocation);

if (memoryRequest.SizeInBytes > request.SizeInBytes) {
DebugLog(MessageId::kAlignmentMismatch)
<< "Memory allocation was larger then the requested size: "
<< memoryRequest.SizeInBytes << " vs " << request.SizeInBytes << " bytes.";
}

mStats.UsedBlockCount++;
mStats.UsedBlockUsage += allocation->GetSize();

Expand Down
17 changes: 8 additions & 9 deletions src/gpgmm/d3d12/BufferAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,8 @@ namespace gpgmm::d3d12 {
return {};
}

const uint64_t heapSize = AlignTo(request.SizeInBytes, request.Alignment);
if (heapSize > request.SizeInBytes) {
DebugEvent(this, MessageId::kAlignmentMismatch)
<< "Resource heap size is larger then the requested size (" +
std::to_string(heapSize) + " vs " + std::to_string(request.SizeInBytes) +
" bytes).";
}

D3D12_RESOURCE_ALLOCATION_INFO info = {};
info.SizeInBytes = heapSize;
info.SizeInBytes = AlignTo(request.SizeInBytes, request.Alignment);
info.Alignment = request.Alignment;

D3D12_RESOURCE_DESC resourceDescriptor;
Expand All @@ -77,10 +69,17 @@ namespace gpgmm::d3d12 {
mHeapProperties, mHeapFlags, info, &resourceDescriptor,
/*pOptimizedClearValue*/ nullptr, mInitialResourceState, /*resourceOut*/ nullptr,
&resourceHeap);

if (FAILED(hr)) {
return {static_cast<ErrorCodeType>(hr)};
}

if (info.SizeInBytes > request.SizeInBytes) {
DebugLog(MessageId::kAlignmentMismatch)
<< "Memory allocation size was larger then the requested size: " << info.SizeInBytes
<< " vs " << request.SizeInBytes << " bytes.";
}

mStats.UsedMemoryUsage += resourceHeap->GetSize();
mStats.UsedMemoryCount++;

Expand Down
6 changes: 6 additions & 0 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,12 @@ namespace gpgmm::d3d12 {
&newResourceDesc, clearValue, initialResourceState,
&committedResource, &resourceHeap));

if (resourceInfo.SizeInBytes > request.SizeInBytes) {
DebugLog(MessageId::kAlignmentMismatch)
<< "Resource heap size is larger then the requested size: "
<< resourceInfo.SizeInBytes << " vs " << request.SizeInBytes << " bytes.";
}

// Using committed resources will create a tightly allocated resource allocations.
// This means the block and heap size should be equal (modulo driver padding).
const uint64_t& allocationSize = resourceHeap->GetSize();
Expand Down
2 changes: 1 addition & 1 deletion src/gpgmm/d3d12/ResourceHeapAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace gpgmm::d3d12 {
}

if (resourceHeapDesc.SizeInBytes > request.SizeInBytes) {
DebugEvent(this, MessageId::kAlignmentMismatch)
DebugLog(MessageId::kAlignmentMismatch)
<< "Resource heap was larger then the requested size: "
<< resourceHeapDesc.SizeInBytes << " vs " << request.SizeInBytes << " bytes.";
}
Expand Down