VmaBlockMetadata_Buddy: Added (simple way of) respecting bufferImageGranularity.

Minor fixes in documentation.
This commit is contained in:
Adam Sawicki 2018-09-21 15:10:04 +02:00
parent 9933c5cadf
commit 1e8cf94558

View file

@ -1965,7 +1965,7 @@ typedef enum VmaPoolCreateFlagBits {
(wasted memory). In that case, if you can make sure you always allocate only (wasted memory). In that case, if you can make sure you always allocate only
buffers and linear images or only optimal images out of this pool, use this flag buffers and linear images or only optimal images out of this pool, use this flag
to make allocator disregard Buffer-Image Granularity and so make allocations to make allocator disregard Buffer-Image Granularity and so make allocations
more optimal. faster and more optimal.
*/ */
VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT = 0x00000002, VMA_POOL_CREATE_IGNORE_BUFFER_IMAGE_GRANULARITY_BIT = 0x00000002,
@ -9392,6 +9392,16 @@ bool VmaBlockMetadata_Buddy::CreateAllocationRequest(
{ {
VMA_ASSERT(!upperAddress && "VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT can be used only with linear algorithm."); VMA_ASSERT(!upperAddress && "VMA_ALLOCATION_CREATE_UPPER_ADDRESS_BIT can be used only with linear algorithm.");
// Simple way to respect bufferImageGranularity. May be optimized some day.
// Whenever it might be an OPTIMAL image...
if(allocType == VMA_SUBALLOCATION_TYPE_UNKNOWN ||
allocType == VMA_SUBALLOCATION_TYPE_IMAGE_UNKNOWN ||
allocType == VMA_SUBALLOCATION_TYPE_IMAGE_OPTIMAL)
{
allocAlignment = VMA_MAX(allocAlignment, bufferImageGranularity);
allocSize = VMA_MAX(allocSize, bufferImageGranularity);
}
if(allocSize > m_UsableSize) if(allocSize > m_UsableSize)
{ {
return false; return false;