## 16.1. Query Pools

Queries are managed using query pool objects. Each query pool is a collection of a specific number of queries of a particular type.

Query pools are represented by `VkQueryPool` handles:

    VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool)

To create a query pool, call:

    VkResult vkCreateQueryPool(
        VkDevice                                    device,
        const VkQueryPoolCreateInfo*                pCreateInfo,
        const VkAllocationCallbacks*                pAllocator,
        VkQueryPool*                                pQueryPool);

- `device` is the logical device that creates the query pool.
- `pCreateInfo` is a pointer to an instance of the `VkQueryPoolCreateInfo` structure containing the number and type of queries to be managed by the pool.
- `pAllocator` controls host memory allocation as described in the Memory Allocation chapter.
- `pQueryPool` is a pointer to a `VkQueryPool` handle in which the resulting query pool object is returned.

The `VkQueryPoolCreateInfo` structure is defined as:

    typedef struct VkQueryPoolCreateInfo {
        VkStructureType                  sType;
        const void*                      pNext;
        VkQueryPoolCreateFlags           flags;
        VkQueryType                      queryType;
        uint32_t                         queryCount;
        VkQueryPipelineStatisticFlags    pipelineStatistics;
    } VkQueryPoolCreateInfo;

- `sType` is the type of this structure.
- `pNext` is `NULL` or a pointer to an extension-specific structure.
- `flags` is reserved for future use.

- `queryType` is the type of queries managed by the pool, and must be one of the values

      typedef enum VkQueryType {
          VK_QUERY_TYPE_OCCLUSION = 0,
          VK_QUERY_TYPE_PIPELINE_STATISTICS = 1,
          VK_QUERY_TYPE_TIMESTAMP = 2,
      } VkQueryType;

- `queryCount` is the number of queries managed by the pool.
- `pipelineStatistics` is a bitmask indicating which counters will be returned in queries on the new pool, as described below in Section 16.4, “Pipeline Statistics Queries”. `pipelineStatistics` is ignored if `queryType` is not `VK_QUERY_TYPE_PIPELINE_STATISTICS`.

To destroy a query pool, call:

    void vkDestroyQueryPool(
        VkDevice                                    device,
        VkQueryPool                                 queryPool,
        const VkAllocationCallbacks*                pAllocator);

- `device` is the logical device that destroys the query pool.
- `queryPool` is the query pool to destroy.
- `pAllocator` controls host memory allocation as described in the Memory Allocation chapter.