radv: keep track of the query pool size
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 28 Feb 2018 19:22:29 +0000 (20:22 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 1 Mar 2018 08:53:39 +0000 (09:53 +0100)
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_private.h
src/amd/vulkan/radv_query.c

index b76d2eb5cbba0c1dc69c07c5a0d7cece73bd93f7..752b6a759220b610efdad6a05fc414c44e83abdd 100644 (file)
@@ -1606,6 +1606,7 @@ struct radv_query_pool {
        struct radeon_winsys_bo *bo;
        uint32_t stride;
        uint32_t availability_offset;
+       uint64_t size;
        char *ptr;
        VkQueryType type;
        uint32_t pipeline_stats_mask;
index b1393a2ec7784f57bc1c1595563afad8d331e348..ff2782bae8970cf34776b807f7a0f78f6b5c209d 100644 (file)
@@ -748,7 +748,6 @@ VkResult radv_CreateQueryPool(
        VkQueryPool*                                pQueryPool)
 {
        RADV_FROM_HANDLE(radv_device, device, _device);
-       uint64_t size;
        struct radv_query_pool *pool = vk_alloc2(&device->alloc, pAllocator,
                                               sizeof(*pool), 8,
                                               VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
@@ -774,12 +773,12 @@ VkResult radv_CreateQueryPool(
        pool->type = pCreateInfo->queryType;
        pool->pipeline_stats_mask = pCreateInfo->pipelineStatistics;
        pool->availability_offset = pool->stride * pCreateInfo->queryCount;
-       size = pool->availability_offset;
+       pool->size = pool->availability_offset;
        if (pCreateInfo->queryType == VK_QUERY_TYPE_TIMESTAMP ||
            pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS)
-               size += 4 * pCreateInfo->queryCount;
+               pool->size += 4 * pCreateInfo->queryCount;
 
-       pool->bo = device->ws->buffer_create(device->ws, size,
+       pool->bo = device->ws->buffer_create(device->ws, pool->size,
                                             64, RADEON_DOMAIN_GTT, RADEON_FLAG_NO_INTERPROCESS_SHARING);
 
        if (!pool->bo) {
@@ -794,7 +793,7 @@ VkResult radv_CreateQueryPool(
                vk_free2(&device->alloc, pAllocator, pool);
                return vk_error(VK_ERROR_OUT_OF_DEVICE_MEMORY);
        }
-       memset(pool->ptr, 0, size);
+       memset(pool->ptr, 0, pool->size);
 
        *pQueryPool = radv_query_pool_to_handle(pool);
        return VK_SUCCESS;