anv: Allocate query pool BOs from the cache
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
@@ -3835,7 +3835,7 @@ struct anv_query_pool {
|
|||||||
uint32_t stride;
|
uint32_t stride;
|
||||||
/** Number of slots in this query pool */
|
/** Number of slots in this query pool */
|
||||||
uint32_t slots;
|
uint32_t slots;
|
||||||
struct anv_bo bo;
|
struct anv_bo * bo;
|
||||||
};
|
};
|
||||||
|
|
||||||
int anv_get_instance_entrypoint_index(const char *name);
|
int anv_get_instance_entrypoint_index(const char *name);
|
||||||
|
@@ -116,31 +116,23 @@ VkResult genX(CreateQueryPool)(
|
|||||||
pool->stride = uint64s_per_slot * sizeof(uint64_t);
|
pool->stride = uint64s_per_slot * sizeof(uint64_t);
|
||||||
pool->slots = pCreateInfo->queryCount;
|
pool->slots = pCreateInfo->queryCount;
|
||||||
|
|
||||||
uint64_t size = pool->slots * pool->stride;
|
uint32_t bo_flags = 0;
|
||||||
result = anv_bo_init_new(&pool->bo, device, size);
|
|
||||||
if (result != VK_SUCCESS)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
if (pdevice->supports_48bit_addresses)
|
if (pdevice->supports_48bit_addresses)
|
||||||
pool->bo.flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
|
bo_flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
|
||||||
|
|
||||||
if (pdevice->use_softpin)
|
if (pdevice->use_softpin)
|
||||||
pool->bo.flags |= EXEC_OBJECT_PINNED;
|
bo_flags |= EXEC_OBJECT_PINNED;
|
||||||
|
|
||||||
if (pdevice->has_exec_async)
|
if (pdevice->has_exec_async)
|
||||||
pool->bo.flags |= EXEC_OBJECT_ASYNC;
|
bo_flags |= EXEC_OBJECT_ASYNC;
|
||||||
|
|
||||||
anv_vma_alloc(device, &pool->bo);
|
uint64_t size = pool->slots * pool->stride;
|
||||||
|
result = anv_device_alloc_bo(device, size,
|
||||||
/* For query pools, we set the caching mode to I915_CACHING_CACHED. On LLC
|
ANV_BO_ALLOC_MAPPED |
|
||||||
* platforms, this does nothing. On non-LLC platforms, this means snooping
|
ANV_BO_ALLOC_SNOOPED,
|
||||||
* which comes at a slight cost. However, the buffers aren't big, won't be
|
&pool->bo);
|
||||||
* written frequently, and trying to handle the flushing manually without
|
if (result != VK_SUCCESS)
|
||||||
* doing too much flushing is extremely painful.
|
goto fail;
|
||||||
*/
|
|
||||||
anv_gem_set_caching(device, pool->bo.gem_handle, I915_CACHING_CACHED);
|
|
||||||
|
|
||||||
pool->bo.map = anv_gem_mmap(device, pool->bo.gem_handle, 0, size, 0);
|
|
||||||
|
|
||||||
*pQueryPool = anv_query_pool_to_handle(pool);
|
*pQueryPool = anv_query_pool_to_handle(pool);
|
||||||
|
|
||||||
@@ -163,9 +155,7 @@ void genX(DestroyQueryPool)(
|
|||||||
if (!pool)
|
if (!pool)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
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);
|
|
||||||
vk_free2(&device->alloc, pAllocator, pool);
|
vk_free2(&device->alloc, pAllocator, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,7 +163,7 @@ static struct anv_address
|
|||||||
anv_query_address(struct anv_query_pool *pool, uint32_t query)
|
anv_query_address(struct anv_query_pool *pool, uint32_t query)
|
||||||
{
|
{
|
||||||
return (struct anv_address) {
|
return (struct anv_address) {
|
||||||
.bo = &pool->bo,
|
.bo = pool->bo,
|
||||||
.offset = query * pool->stride,
|
.offset = query * pool->stride,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -245,7 +235,7 @@ cpu_write_query_result(void *dst_slot, VkQueryResultFlags flags,
|
|||||||
static void *
|
static void *
|
||||||
query_slot(struct anv_query_pool *pool, uint32_t query)
|
query_slot(struct anv_query_pool *pool, uint32_t query)
|
||||||
{
|
{
|
||||||
return pool->bo.map + query * pool->stride;
|
return pool->bo->map + query * pool->stride;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@@ -266,7 +256,7 @@ wait_for_available(struct anv_device *device,
|
|||||||
if (query_is_available(pool, query))
|
if (query_is_available(pool, query))
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
|
|
||||||
int ret = anv_gem_busy(device, pool->bo.gem_handle);
|
int ret = anv_gem_busy(device, pool->bo->gem_handle);
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
/* The BO is still busy, keep waiting. */
|
/* The BO is still busy, keep waiting. */
|
||||||
continue;
|
continue;
|
||||||
|
Reference in New Issue
Block a user