Skip to content

Commit 42bfb6b

Browse files
Align buffers to 256 B at least
Because this is the alignment required for constant buffers.
1 parent 1063339 commit 42bfb6b

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/D3D12MemAlloc.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7710,7 +7710,15 @@ D3D12_RESOURCE_ALLOCATION_INFO AllocatorPimpl::GetResourceAllocationInfo(D3D12_R
77107710
}
77117711
#endif // #if D3D12MA_USE_SMALL_RESOURCE_PLACEMENT_ALIGNMENT
77127712

7713-
return GetResourceAllocationInfoNative(inOutResourceDesc);
7713+
D3D12_RESOURCE_ALLOCATION_INFO resAllocInfo = GetResourceAllocationInfoNative(inOutResourceDesc);
7714+
7715+
// Align up to 256 B because this is the alignment required for constant buffers.
7716+
if (inOutResourceDesc.Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
7717+
{
7718+
resAllocInfo.Alignment = D3D12MA_MAX(resAllocInfo.Alignment, (UINT64)D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
7719+
}
7720+
7721+
return resAllocInfo;
77147722
}
77157723

77167724
bool AllocatorPimpl::NewAllocationWithinBudget(D3D12_HEAP_TYPE heapType, UINT64 size)

0 commit comments

Comments
 (0)