anv: Allocate descriptor buffers from the BO cache
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -663,7 +663,6 @@ VkResult anv_CreateDescriptorPool(
|
|||||||
VkDescriptorPool* pDescriptorPool)
|
VkDescriptorPool* pDescriptorPool)
|
||||||
{
|
{
|
||||||
ANV_FROM_HANDLE(anv_device, device, _device);
|
ANV_FROM_HANDLE(anv_device, device, _device);
|
||||||
const struct anv_physical_device *pdevice = &device->instance->physicalDevice;
|
|
||||||
struct anv_descriptor_pool *pool;
|
struct anv_descriptor_pool *pool;
|
||||||
|
|
||||||
const VkDescriptorPoolInlineUniformBlockCreateInfoEXT *inline_info =
|
const VkDescriptorPoolInlineUniformBlockCreateInfoEXT *inline_info =
|
||||||
@@ -734,36 +733,19 @@ VkResult anv_CreateDescriptorPool(
|
|||||||
pool->free_list = EMPTY;
|
pool->free_list = EMPTY;
|
||||||
|
|
||||||
if (descriptor_bo_size > 0) {
|
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) {
|
if (result != VK_SUCCESS) {
|
||||||
vk_free2(&device->alloc, pAllocator, pool);
|
vk_free2(&device->alloc, pAllocator, pool);
|
||||||
return result;
|
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);
|
util_vma_heap_init(&pool->bo_heap, POOL_HEAP_OFFSET, descriptor_bo_size);
|
||||||
} else {
|
} else {
|
||||||
pool->bo.size = 0;
|
pool->bo = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
anv_state_stream_init(&pool->surface_state_stream,
|
anv_state_stream_init(&pool->surface_state_stream,
|
||||||
@@ -793,12 +775,8 @@ void anv_DestroyDescriptorPool(
|
|||||||
anv_descriptor_set_layout_unref(device, set->layout);
|
anv_descriptor_set_layout_unref(device, set->layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pool->bo.size) {
|
if (pool->bo)
|
||||||
anv_gem_munmap(pool->bo.map, pool->bo.size);
|
anv_device_release_bo(device, pool->bo);
|
||||||
anv_vma_free(device, &pool->bo);
|
|
||||||
anv_gem_close(device, pool->bo.gem_handle);
|
|
||||||
util_vma_heap_finish(&pool->bo_heap);
|
|
||||||
}
|
|
||||||
anv_state_stream_finish(&pool->surface_state_stream);
|
anv_state_stream_finish(&pool->surface_state_stream);
|
||||||
|
|
||||||
vk_free2(&device->alloc, pAllocator, pool);
|
vk_free2(&device->alloc, pAllocator, pool);
|
||||||
@@ -821,9 +799,9 @@ VkResult anv_ResetDescriptorPool(
|
|||||||
pool->next = 0;
|
pool->next = 0;
|
||||||
pool->free_list = EMPTY;
|
pool->free_list = EMPTY;
|
||||||
|
|
||||||
if (pool->bo.size) {
|
if (pool->bo) {
|
||||||
util_vma_heap_finish(&pool->bo_heap);
|
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);
|
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);
|
pool_vma_offset - POOL_HEAP_OFFSET <= INT32_MAX);
|
||||||
set->desc_mem.offset = pool_vma_offset - POOL_HEAP_OFFSET;
|
set->desc_mem.offset = pool_vma_offset - POOL_HEAP_OFFSET;
|
||||||
set->desc_mem.alloc_size = set_buffer_size;
|
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);
|
set->desc_surface_state = anv_descriptor_pool_alloc_state(pool);
|
||||||
anv_fill_buffer_surface_state(device, set->desc_surface_state,
|
anv_fill_buffer_surface_state(device, set->desc_surface_state,
|
||||||
ISL_FORMAT_R32G32B32A32_FLOAT,
|
ISL_FORMAT_R32G32B32A32_FLOAT,
|
||||||
(struct anv_address) {
|
(struct anv_address) {
|
||||||
.bo = &pool->bo,
|
.bo = pool->bo,
|
||||||
.offset = set->desc_mem.offset,
|
.offset = set->desc_mem.offset,
|
||||||
},
|
},
|
||||||
layout->descriptor_buffer_size, 1);
|
layout->descriptor_buffer_size, 1);
|
||||||
|
@@ -1889,7 +1889,7 @@ struct anv_descriptor_pool {
|
|||||||
uint32_t next;
|
uint32_t next;
|
||||||
uint32_t free_list;
|
uint32_t free_list;
|
||||||
|
|
||||||
struct anv_bo bo;
|
struct anv_bo *bo;
|
||||||
struct util_vma_heap bo_heap;
|
struct util_vma_heap bo_heap;
|
||||||
|
|
||||||
struct anv_state_stream surface_state_stream;
|
struct anv_state_stream surface_state_stream;
|
||||||
|
@@ -2103,7 +2103,7 @@ anv_descriptor_set_address(struct anv_cmd_buffer *cmd_buffer,
|
|||||||
if (set->pool) {
|
if (set->pool) {
|
||||||
/* This is a normal descriptor set */
|
/* This is a normal descriptor set */
|
||||||
return (struct anv_address) {
|
return (struct anv_address) {
|
||||||
.bo = &set->pool->bo,
|
.bo = set->pool->bo,
|
||||||
.offset = set->desc_mem.offset,
|
.offset = set->desc_mem.offset,
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user