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
10 changes: 10 additions & 0 deletions include/gpgmm_d3d12.h
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,16 @@ namespace gpgmm::d3d12 {
Mostly used when external resources are residency managed elsewhere.
*/
ALLOCATION_FLAG_DISABLE_RESIDENCY = 0x80,

/** \brief Report alignment mismatches upon successful resource creation.

Flag is used to report when requested size does not match the allocation size due to
resource or allocation alignment requirements.

Must compile with GPGMM_ENABLE_MEMORY_ALIGN_CHECKS to use as the request size
is normally not tracked.
*/
ALLOCATION_FLAG_WARN_ON_ALIGNMENT_MISMATCH = 0x100,
};

DEFINE_ENUM_FLAG_OPERATORS(ALLOCATION_FLAGS)
Expand Down
4 changes: 2 additions & 2 deletions src/gpgmm/common/MemoryAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ namespace gpgmm {

void MemoryAllocator::CheckAndReportAllocationMisalignment(const MemoryAllocation& allocation) {
if (allocation.GetSize() > allocation.GetRequestSize()) {
DebugEvent(this, MessageId::kAlignmentMismatch)
<< "Resource allocation is larger then the requested size (" +
WarningLog(MessageId::kAlignmentMismatch)
<< "Allocation is larger then the requested size (" +
std::to_string(allocation.GetSize()) + " vs " +
std::to_string(allocation.GetRequestSize()) + " bytes).";
}
Expand Down
8 changes: 4 additions & 4 deletions src/gpgmm/d3d12/ResourceAllocatorD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,10 +949,10 @@ namespace gpgmm::d3d12 {
ReturnIfFailed(QueryStatsInternal(nullptr));
}

#if defined(GPGMM_ENABLE_MEMORY_ALIGN_CHECKS)
// Allocation is subject to alignment requirements per allocator or allocation method.
CheckAndReportAllocationMisalignment(*static_cast<ResourceAllocation*>(allocation.Get()));
#endif
if (allocationDescriptor.Flags & ALLOCATION_FLAG_WARN_ON_ALIGNMENT_MISMATCH) {
CheckAndReportAllocationMisalignment(
*static_cast<ResourceAllocation*>(allocation.Get()));
}

if (ppResourceAllocationOut != nullptr) {
*ppResourceAllocationOut = allocation.Detach();
Expand Down