VmaAllocator_T::AllocateMemoryOfType: Fixed major bug when VMA_ALLOCATION_CREATE_PERSISTENT_MAP_BIT is used with VMA_MEMORY_USAGE_GPU_ONLY.

This commit is contained in:
Adam Sawicki 2017-10-18 15:35:00 +02:00
parent 0fcf86292b
commit ee92a03f59
2 changed files with 10 additions and 10 deletions

Binary file not shown.

View File

@ -6496,12 +6496,19 @@ VkResult VmaAllocator_T::AllocateMemoryOfType(
VMA_ASSERT(pAllocation != VMA_NULL); VMA_ASSERT(pAllocation != VMA_NULL);
VMA_DEBUG_LOG(" AllocateMemory: MemoryTypeIndex=%u, Size=%llu", memTypeIndex, vkMemReq.size); VMA_DEBUG_LOG(" AllocateMemory: MemoryTypeIndex=%u, Size=%llu", memTypeIndex, vkMemReq.size);
uint32_t blockVectorType = VmaAllocationCreateFlagsToBlockVectorType(createInfo.flags); VmaAllocationCreateInfo finalCreateInfo = createInfo;
// If memory type is not HOST_VISIBLE, disable PERSISTENT_MAP.
if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_PERSISTENT_MAP_BIT) != 0 &&
(m_MemProps.memoryTypes[memTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0)
{
finalCreateInfo.flags &= ~VMA_ALLOCATION_CREATE_PERSISTENT_MAP_BIT;
}
uint32_t blockVectorType = VmaAllocationCreateFlagsToBlockVectorType(finalCreateInfo.flags);
VmaBlockVector* const blockVector = m_pBlockVectors[memTypeIndex][blockVectorType]; VmaBlockVector* const blockVector = m_pBlockVectors[memTypeIndex][blockVectorType];
VMA_ASSERT(blockVector); VMA_ASSERT(blockVector);
VmaAllocationCreateInfo finalCreateInfo = createInfo;
const VkDeviceSize preferredBlockSize = blockVector->GetPreferredBlockSize(); const VkDeviceSize preferredBlockSize = blockVector->GetPreferredBlockSize();
bool preferDedicatedMemory = bool preferDedicatedMemory =
VMA_DEBUG_ALWAYS_DEDICATED_MEMORY || VMA_DEBUG_ALWAYS_DEDICATED_MEMORY ||
@ -6516,13 +6523,6 @@ VkResult VmaAllocator_T::AllocateMemoryOfType(
finalCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT; finalCreateInfo.flags |= VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT;
} }
// If memory type is not HOST_VISIBLE, disable PERSISTENT_MAP.
if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_PERSISTENT_MAP_BIT) != 0 &&
(m_MemProps.memoryTypes[memTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) == 0)
{
finalCreateInfo.flags &= ~VMA_ALLOCATION_CREATE_PERSISTENT_MAP_BIT;
}
if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT) != 0) if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT) != 0)
{ {
if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0) if((finalCreateInfo.flags & VMA_ALLOCATION_CREATE_NEVER_ALLOCATE_BIT) != 0)