vn_object_base_init(&mem->base, VK_OBJECT_TYPE_DEVICE_MEMORY, &dev->base);
mem->size = size;
+ mem->flags = mem_flags;
mem_handle = vn_device_memory_to_handle(mem);
result = vn_call_vkAllocateMemory(
}
result = vn_renderer_bo_create_from_device_memory(
- dev->renderer, mem->size, mem->base.id, mem_flags, 0, &mem->base_bo);
+ dev->renderer, mem->size, mem->base.id, mem->flags, 0, &mem->base_bo);
if (result != VK_SUCCESS) {
assert(!mem->base_bo);
goto fail;
static bool
vn_device_memory_should_suballocate(const VkMemoryAllocateInfo *alloc_info,
- const VkMemoryType *mem_type)
+ const VkMemoryPropertyFlags flags)
{
/* We should not support suballocations because apps can do better. But
* each BO takes up a KVM memslot currently and some CTS tests exhausts
*/
/* consider host-visible memory only */
- if (!(mem_type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
+ if (!(flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
return false;
/* reject larger allocations */
struct vn_device_memory *mem,
const VkMemoryAllocateInfo *alloc_info,
bool need_bo,
- VkMemoryPropertyFlags flags,
VkExternalMemoryHandleTypeFlags external_handles)
{
VkDevice dev_handle = vn_device_to_handle(dev);
return result;
result = vn_renderer_bo_create_from_device_memory(
- dev->renderer, mem->size, mem->base.id, flags, external_handles,
+ dev->renderer, mem->size, mem->base.id, mem->flags, external_handles,
&mem->base_bo);
if (result != VK_SUCCESS) {
vn_async_vkFreeMemory(dev->instance, dev_handle, mem_handle, NULL);
const VkPhysicalDeviceMemoryProperties *mem_props =
&dev->physical_device->memory_properties.memoryProperties;
- const VkMemoryType *mem_type =
- &mem_props->memoryTypes[pAllocateInfo->memoryTypeIndex];
+ const VkMemoryPropertyFlags mem_flags =
+ mem_props->memoryTypes[pAllocateInfo->memoryTypeIndex].propertyFlags;
const VkExportMemoryAllocateInfo *export_info = NULL;
const VkImportAndroidHardwareBufferInfoANDROID *import_ahb_info = NULL;
vn_object_base_init(&mem->base, VK_OBJECT_TYPE_DEVICE_MEMORY, &dev->base);
mem->size = pAllocateInfo->allocationSize;
+ mem->flags = mem_flags;
VkDeviceMemory mem_handle = vn_device_memory_to_handle(mem);
VkResult result;
import_fd_info->fd);
} else if (export_info) {
result = vn_device_memory_alloc(dev, mem, pAllocateInfo, true,
- mem_type->propertyFlags,
export_info->handleTypes);
- } else if (vn_device_memory_should_suballocate(pAllocateInfo, mem_type)) {
+ } else if (vn_device_memory_should_suballocate(pAllocateInfo, mem_flags)) {
result = vn_device_memory_pool_suballocate(
dev, mem, pAllocateInfo->memoryTypeIndex);
} else {
- const bool need_bo =
- mem_type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
- result = vn_device_memory_alloc(dev, mem, pAllocateInfo, need_bo,
- mem_type->propertyFlags, 0);
+ const bool need_bo = mem_flags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
+ result = vn_device_memory_alloc(dev, mem, pAllocateInfo, need_bo, 0);
}
if (result != VK_SUCCESS) {
vn_object_base_fini(&mem->base);