diff options
author | Jason Ekstrand <[email protected]> | 2018-05-30 15:34:25 -0700 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2018-06-01 14:27:10 -0700 |
commit | b0d50247a7049350ef30adcefc609039ce86beee (patch) | |
tree | 327a448861a4dfe10aca0ee31d2984544666481e /src/intel/vulkan/anv_device.c | |
parent | 27cc68d9e90c8d2031383fa6dc28fe910a351eb6 (diff) |
anv/allocator: Set the BO flags in bo_cache_alloc/import
It's safer to set them there because we have the opportunity to properly
handle combining flags if a BO is imported more than once.
Reviewed-by: Scott D Phillips <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_device.c')
-rw-r--r-- | src/intel/vulkan/anv_device.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index 067f4369b76..69de75c7374 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -2033,6 +2033,24 @@ VkResult anv_AllocateMemory( mem->map = NULL; mem->map_size = 0; + uint64_t bo_flags = 0; + + assert(mem->type->heapIndex < pdevice->memory.heap_count); + if (pdevice->memory.heaps[mem->type->heapIndex].supports_48bit_addresses) + bo_flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS; + + const struct wsi_memory_allocate_info *wsi_info = + vk_find_struct_const(pAllocateInfo->pNext, WSI_MEMORY_ALLOCATE_INFO_MESA); + if (wsi_info && wsi_info->implicit_sync) { + /* We need to set the WRITE flag on window system buffers so that GEM + * will know we're writing to them and synchronize uses on other rings + * (eg if the display server uses the blitter ring). + */ + bo_flags |= EXEC_OBJECT_WRITE; + } else if (pdevice->has_exec_async) { + bo_flags |= EXEC_OBJECT_ASYNC; + } + const VkImportMemoryFdInfoKHR *fd_info = vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHR); @@ -2047,7 +2065,7 @@ VkResult anv_AllocateMemory( VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT); result = anv_bo_cache_import(device, &device->bo_cache, - fd_info->fd, &mem->bo); + fd_info->fd, bo_flags, &mem->bo); if (result != VK_SUCCESS) goto fail; @@ -2085,7 +2103,7 @@ VkResult anv_AllocateMemory( close(fd_info->fd); } else { result = anv_bo_cache_alloc(device, &device->bo_cache, - pAllocateInfo->allocationSize, + pAllocateInfo->allocationSize, bo_flags, &mem->bo); if (result != VK_SUCCESS) goto fail; @@ -2114,22 +2132,6 @@ VkResult anv_AllocateMemory( } } - assert(mem->type->heapIndex < pdevice->memory.heap_count); - if (pdevice->memory.heaps[mem->type->heapIndex].supports_48bit_addresses) - mem->bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS; - - const struct wsi_memory_allocate_info *wsi_info = - vk_find_struct_const(pAllocateInfo->pNext, WSI_MEMORY_ALLOCATE_INFO_MESA); - if (wsi_info && wsi_info->implicit_sync) { - /* We need to set the WRITE flag on window system buffers so that GEM - * will know we're writing to them and synchronize uses on other rings - * (eg if the display server uses the blitter ring). - */ - mem->bo->flags |= EXEC_OBJECT_WRITE; - } else if (pdevice->has_exec_async) { - mem->bo->flags |= EXEC_OBJECT_ASYNC; - } - *pMem = anv_device_memory_to_handle(mem); return VK_SUCCESS; |