// Get the memory requirements for the buffer
VkMemoryRequirements memoryReq;
vkGetBufferMemoryRequirements(_VkSystem.device, buffer, &memoryReq);
// Get Physical Device Properties
VkPhysicalDeviceMemoryProperties devMemProp = {};
vkGetPhysicalDeviceMemoryProperties(_VkSystem.physicalDevice, &devMemProp);
// Check which index of the memory properties supports HOST_VISIBLE?
int level = log2(memoryReq.memoryTypeBits);
for (int i = 0; i < level; i++)
{
if (devMemProp.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
{
level = i;
break;
}
}
// Setup Memory Allocation Information
VkMemoryAllocateInfo allocInfo = {};
allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
allocInfo.allocationSize = memoryReq.size;
allocInfo.memoryTypeIndex = level;