From ca0ccecf67f25f498143801074b55e6f4dac4c69 Mon Sep 17 00:00:00 2001 From: Adam Sawicki Date: Mon, 4 Dec 2017 13:33:01 +0100 Subject: [PATCH] vmaCreateBuffer: Added some asserts. --- src/vk_mem_alloc.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/vk_mem_alloc.h b/src/vk_mem_alloc.h index 8b3fd76..7795762 100644 --- a/src/vk_mem_alloc.h +++ b/src/vk_mem_alloc.h @@ -8359,6 +8359,24 @@ VkResult vmaCreateBuffer( allocator->GetBufferMemoryRequirements(*pBuffer, vkMemReq, requiresDedicatedAllocation, prefersDedicatedAllocation); + // Make sure alignment requirements for specific buffer usages reported + // in Physical Device Properties are included in alignment reported by memory requirements. + if((pBufferCreateInfo->usage & VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT) != 0) + { + VMA_ASSERT(vkMemReq.alignment % + allocator->m_PhysicalDeviceProperties.limits.minTexelBufferOffsetAlignment == 0); + } + if((pBufferCreateInfo->usage & VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT) != 0) + { + VMA_ASSERT(vkMemReq.alignment % + allocator->m_PhysicalDeviceProperties.limits.minUniformBufferOffsetAlignment == 0); + } + if((pBufferCreateInfo->usage & VK_BUFFER_USAGE_STORAGE_BUFFER_BIT) != 0) + { + VMA_ASSERT(vkMemReq.alignment % + allocator->m_PhysicalDeviceProperties.limits.minStorageBufferOffsetAlignment == 0); + } + // 3. Allocate memory using allocator. res = allocator->AllocateMemory( vkMemReq,