vkCmdEndQuery(3)

# vkCmdEndQuery(3) Manual Page

## Name

vkCmdEndQuery - Ends a query

## C Specification

To end a query after the set of desired commands is recorded, call:

    // Provided by VK_VERSION_1_0
    void vkCmdEndQuery(
        VkCommandBuffer                             commandBuffer,
        VkQueryPool                                 queryPool,
        uint32_t                                    query);

## Parameters

- `commandBuffer` is the command buffer into which this command will be recorded.

- `queryPool` is the query pool that is managing the results of the query.

- `query` is the query index within the query pool where the result is stored.

## Description

The command completes the query in `queryPool` identified by `query`, and marks it as available.

This command defines an execution dependency between other query commands that reference the same query.

The first synchronization scope includes all commands which reference the queries in `queryPool` indicated by `query` that occur earlier in submission order.

The second synchronization scope includes only the operation of this command.

If the `queryType` of the pool is VK_QUERY_TYPE_TIME_ELAPSED_QCOM, this command also defines an execution dependency on commands that were submitted before it, and ending the timer.

The first synchronization scope includes all commands that occur earlier in submission order.

The second synchronization scope includes only the ending of the timer.

Calling `vkCmdEndQuery` is equivalent to calling vkCmdEndQueryIndexedEXT with the `index` parameter set to zero.

Valid Usage

- VUID-vkCmdEndQuery-None-01923
  All queries used by the command must be active

- VUID-vkCmdEndQuery-query-00810
  `query` must be less than the number of queries in `queryPool`

- VUID-vkCmdEndQuery-commandBuffer-01886
  `commandBuffer` must not be a protected command buffer

- VUID-vkCmdEndQuery-query-00812
  If `vkCmdEndQuery` is called within a render pass instance, the sum of `query` and the number of bits set in the current subpass’s view mask must be less than or equal to the number of queries in `queryPool`

- VUID-vkCmdEndQuery-queryPool-03227
  If `queryPool` was created with a `queryType` of VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR and one or more of the counters used to create `queryPool` was VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR, the vkCmdEndQuery must be the last recorded command in `commandBuffer`

- VUID-vkCmdEndQuery-queryPool-03228
  If `queryPool` was created with a `queryType` of VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR and one or more of the counters used to create `queryPool` was VK_PERFORMANCE_COUNTER_SCOPE_RENDER_PASS_KHR, the vkCmdEndQuery must not be recorded within a render pass instance

- VUID-vkCmdEndQuery-None-07007
  If called within a subpass of a render pass instance, the corresponding `vkCmdBeginQuery`* command must have been called previously within the same subpass

- VUID-vkCmdEndQuery-None-10682
  This command must not be recorded when per-tile execution model is enabled

Valid Usage (Implicit)

- VUID-vkCmdEndQuery-commandBuffer-parameter
  `commandBuffer` must be a valid VkCommandBuffer handle

- VUID-vkCmdEndQuery-queryPool-parameter
  `queryPool` must be a valid VkQueryPool handle

- VUID-vkCmdEndQuery-commandBuffer-recording
  `commandBuffer` must be in the recording state

- VUID-vkCmdEndQuery-commandBuffer-cmdpool
  The `VkCommandPool` that `commandBuffer` was allocated from must support VK_QUEUE_COMPUTE_BIT, VK_QUEUE_GRAPHICS_BIT, VK_QUEUE_VIDEO_DECODE_BIT_KHR, or VK_QUEUE_VIDEO_ENCODE_BIT_KHR operations

- VUID-vkCmdEndQuery-suspended
  This command must not be called between suspended render pass instances

- VUID-vkCmdEndQuery-commonparent
  Both of `commandBuffer`, and `queryPool` must have been created, allocated, or retrieved from the same VkDevice

Host Synchronization

- Host access to `commandBuffer` must be externally synchronized

- Host access to the `VkCommandPool` that `commandBuffer` was allocated from must be externally synchronized

Command Properties

Command Buffer Levels | Render Pass Scope | Video Coding Scope | Supported Queue Types | Command Type
--- | --- | --- | --- | ---
Primary Secondary | Both | Both | VK_QUEUE_COMPUTE_BIT VK_QUEUE_GRAPHICS_BIT VK_QUEUE_VIDEO_DECODE_BIT_KHR VK_QUEUE_VIDEO_ENCODE_BIT_KHR | Action State

Conditional Rendering

vkCmdEndQuery is not affected by conditional rendering

## See Also

VK_VERSION_1_0, VkCommandBuffer, VkQueryPool, vkCmdBeginQuery, vkCmdBeginQueryIndexedEXT, vkCmdEndQueryIndexedEXT

## Document Notes

For more information, see the Vulkan Specification.

This page is extracted from the Vulkan Specification. Fixes and changes should be made to the Specification, not directly.

## Copyright

Copyright 2014-2026 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0