diff options
author | Jason Ekstrand <[email protected]> | 2019-10-25 17:15:31 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-10-31 13:46:09 +0000 |
commit | 0a6d2593b8b63d2429e79eed900848c5c9a522c9 (patch) | |
tree | 36983396138d38e0e75269efa433c19526f86893 /src/intel | |
parent | e0ee23660fa2b38315ebc72aac5455cd064000fa (diff) |
anv: Allocate descriptor buffers from the BO cache
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/vulkan/anv_descriptor_set.c | 46 | ||||
-rw-r--r-- | src/intel/vulkan/anv_private.h | 2 | ||||
-rw-r--r-- | src/intel/vulkan/genX_cmd_buffer.c | 2 |
3 files changed, 14 insertions, 36 deletions
diff --git a/src/intel/vulkan/anv_descriptor_set.c b/src/intel/vulkan/anv_descriptor_set.c index 3951a665e18..2f7b32b1b82 100644 --- a/src/intel/vulkan/anv_descriptor_set.c +++ b/src/intel/vulkan/anv_descriptor_set.c @@ -663,7 +663,6 @@ VkResult anv_CreateDescriptorPool( VkDescriptorPool* pDescriptorPool) { ANV_FROM_HANDLE(anv_device, device, _device); - const struct anv_physical_device *pdevice = &device->instance->physicalDevice; struct anv_descriptor_pool *pool; const VkDescriptorPoolInlineUniformBlockCreateInfoEXT *inline_info = @@ -734,36 +733,19 @@ VkResult anv_CreateDescriptorPool( pool->free_list = EMPTY; if (descriptor_bo_size > 0) { - VkResult result = anv_bo_init_new(&pool->bo, device, descriptor_bo_size); + VkResult result = anv_device_alloc_bo(device, + descriptor_bo_size, + ANV_BO_ALLOC_MAPPED | + ANV_BO_ALLOC_SNOOPED, + &pool->bo); if (result != VK_SUCCESS) { vk_free2(&device->alloc, pAllocator, pool); return result; } - anv_gem_set_caching(device, pool->bo.gem_handle, I915_CACHING_CACHED); - - pool->bo.map = anv_gem_mmap(device, pool->bo.gem_handle, 0, - descriptor_bo_size, 0); - if (pool->bo.map == NULL) { - anv_gem_close(device, pool->bo.gem_handle); - vk_free2(&device->alloc, pAllocator, pool); - return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY); - } - - if (pdevice->supports_48bit_addresses) - pool->bo.flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS; - - if (pdevice->use_softpin) { - pool->bo.flags |= EXEC_OBJECT_PINNED; - anv_vma_alloc(device, &pool->bo); - } - - if (pdevice->has_exec_async) - pool->bo.flags |= EXEC_OBJECT_ASYNC; - util_vma_heap_init(&pool->bo_heap, POOL_HEAP_OFFSET, descriptor_bo_size); } else { - pool->bo.size = 0; + pool->bo = NULL; } anv_state_stream_init(&pool->surface_state_stream, @@ -793,12 +775,8 @@ void anv_DestroyDescriptorPool( anv_descriptor_set_layout_unref(device, set->layout); } - if (pool->bo.size) { - anv_gem_munmap(pool->bo.map, pool->bo.size); - anv_vma_free(device, &pool->bo); - anv_gem_close(device, pool->bo.gem_handle); - util_vma_heap_finish(&pool->bo_heap); - } + if (pool->bo) + anv_device_release_bo(device, pool->bo); anv_state_stream_finish(&pool->surface_state_stream); vk_free2(&device->alloc, pAllocator, pool); @@ -821,9 +799,9 @@ VkResult anv_ResetDescriptorPool( pool->next = 0; pool->free_list = EMPTY; - if (pool->bo.size) { + if (pool->bo) { util_vma_heap_finish(&pool->bo_heap); - util_vma_heap_init(&pool->bo_heap, POOL_HEAP_OFFSET, pool->bo.size); + util_vma_heap_init(&pool->bo_heap, POOL_HEAP_OFFSET, pool->bo->size); } anv_state_stream_finish(&pool->surface_state_stream); @@ -954,13 +932,13 @@ anv_descriptor_set_create(struct anv_device *device, pool_vma_offset - POOL_HEAP_OFFSET <= INT32_MAX); set->desc_mem.offset = pool_vma_offset - POOL_HEAP_OFFSET; set->desc_mem.alloc_size = set_buffer_size; - set->desc_mem.map = pool->bo.map + set->desc_mem.offset; + set->desc_mem.map = pool->bo->map + set->desc_mem.offset; set->desc_surface_state = anv_descriptor_pool_alloc_state(pool); anv_fill_buffer_surface_state(device, set->desc_surface_state, ISL_FORMAT_R32G32B32A32_FLOAT, (struct anv_address) { - .bo = &pool->bo, + .bo = pool->bo, .offset = set->desc_mem.offset, }, layout->descriptor_buffer_size, 1); diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 0ef2ec73b01..07ef198cb4d 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1889,7 +1889,7 @@ struct anv_descriptor_pool { uint32_t next; uint32_t free_list; - struct anv_bo bo; + struct anv_bo *bo; struct util_vma_heap bo_heap; struct anv_state_stream surface_state_stream; diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c index f7a49147394..5301486f192 100644 --- a/src/intel/vulkan/genX_cmd_buffer.c +++ b/src/intel/vulkan/genX_cmd_buffer.c @@ -2103,7 +2103,7 @@ anv_descriptor_set_address(struct anv_cmd_buffer *cmd_buffer, if (set->pool) { /* This is a normal descriptor set */ return (struct anv_address) { - .bo = &set->pool->bo, + .bo = set->pool->bo, .offset = set->desc_mem.offset, }; } else { |