vkGetQueryPoolResults - Copy results of queries in a query pool to a
host memory region
Description
Any results written for a query are written according to
a layout dependent on the query type.
If no bits are set in flags, and all requested queries are in the
available state, results are written as an array of 32-bit unsigned
integer values. Behavior when not all queries are available is described
below.
If
QUERY_RESULT_WITH_AVAILABILITY_BIT
is set, results for all queries in queryPool identified by
firstQuery and queryCount are copied to pData, along with an extra
availability or status value written directly after the results of each
query and interpreted as an unsigned integer. A value of zero indicates
that the results are not yet available, otherwise the query is complete
and results are available. The size of the availability or status values
is 64 bits if
QUERY_RESULT_64_BIT is set in
flags. Otherwise, it is 32 bits.
If
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR
is set, results for all queries in queryPool identified by
firstQuery and queryCount are copied to pData, along with an extra
status value written directly after the results of each query and
interpreted as a signed integer. A value of zero indicates that the
results are not yet available. Positive values indicate that the
operations within the query completed successfully, and the query
results are valid. Negative values indicate that the operations within
the query completed unsuccessfully.
VkQueryResultStatusKHR
defines specific meaning for values returned here, though
implementations are free to return other values.
If the status value written is negative, indicating that the operations
within the query completed unsuccessfully, then all other results
written by this command are undefined unless otherwise specified for any
of the results of the used query type.
If
QUERY_RESULT_WITH_AVAILABILITY_BIT
or
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR
is set, the layout of data in the buffer is a (result,availability) or
(result,status) pair for each query returned, and stride is the
stride between each pair.
Results for any available query written by this command are final and
represent the final result of the query. If
QUERY_RESULT_PARTIAL_BIT is
set, then for any query that is unavailable, an intermediate result
between zero and the final result value is written for that query.
Otherwise, any result written by this command is undefined.
If QUERY_RESULT_64_BIT is set,
results and, if returned, availability or status values for all queries
are written as an array of 64-bit values. If the queryPool was created
with QUERY_TYPE_PERFORMANCE_QUERY_KHR,
results for each query are written as an array of the type indicated by
PerformanceCounterKHR::storage
for the counter being queried. Otherwise, results and availability or
status values are written as an array of 32-bit values. If an unsigned
integer query’s value overflows the result type, the value may either
wrap or saturate. If the
maintenance7
feature is enabled, for an unsigned integer query, the 32-bit result
value must be equal to the 32 least significant bits of the equivalent
64-bit result value. If a signed integer query’s value overflows the
result type, the value is undefined. If a floating-point query’s value
is not representable as the result type, the value is undefined.
If QUERY_RESULT_WAIT_BIT is
set, this command defines an execution dependency with any earlier
commands that writes one of the identified queries. The first
synchronization scope
includes all instances of
cmdEndQuery,
cmdEndQueryIndexedEXT,
cmdWriteAccelerationStructuresPropertiesKHR,
cmdWriteAccelerationStructuresPropertiesNV,
cmdWriteMicromapsPropertiesEXT,
cmdWriteTimestamp2,
and cmdWriteTimestamp that
reference any query in queryPool indicated by firstQuery and
queryCount. The second
synchronization scope
includes the host operations of this command.
If QUERY_RESULT_WAIT_BIT is
not set, getQueryPoolResults may return
NOT_READY if there are queries in the
unavailable state.
Applications must take care to ensure that use of the
QUERY_RESULT_WAIT_BIT bit has
the desired effect.
For example, if a query has been used previously and a command buffer
records the commands
cmdResetQueryPool,
cmdBeginQuery, and
cmdEndQuery for that query, then
the query will remain in the available state until
resetQueryPool is
called or the cmdResetQueryPool
command executes on a queue. Applications can use fences or events to
ensure that a query has already been reset before checking for its
results or availability status. Otherwise, a stale value could be
returned from a previous use of the query.
The above also applies when
QUERY_RESULT_WAIT_BIT is used
in combination with
QUERY_RESULT_WITH_AVAILABILITY_BIT.
In this case, the returned availability status may reflect the result
of a previous use of the query unless
resetQueryPool is
called or the cmdResetQueryPool
command has been executed since the last use of the query.
A similar situation can arise with the
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR
flag.
Applications can double-buffer query pool usage, with a pool per
frame, and reset queries at the end of the frame in which they are read.
Valid Usage
The sum of
firstQuery and queryCount must be less than or equal to the
number of queries in queryPool
If queryCount is
greater than 1, stride must not be zero
If the queryType used
to create queryPool was
QUERY_TYPE_TIMESTAMP, flags must
not contain
QUERY_RESULT_PARTIAL_BIT
If the queryType used
to create queryPool was
QUERY_TYPE_TIME_ELAPSED_QCOM,
flags must not contain
QUERY_RESULT_PARTIAL_BIT
or
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR
If the queryType used
to create queryPool was
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
flags must not contain
QUERY_RESULT_WITH_AVAILABILITY_BIT,
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR,
QUERY_RESULT_PARTIAL_BIT,
or QUERY_RESULT_64_BIT
If the queryType used
to create queryPool was
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
the queryPool must have been recorded once for each pass as
retrieved via a call to
getPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR
If the queryType used
to create queryPool was not
VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR
or
VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR,
then flags must not include
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR
If the queryType used
to create queryPool was
VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR,
then flags must include
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR
If flags includes
VK_QUERY_RESULT_WITH_STATUS_BIT_KHR,
then it must not include
QUERY_RESULT_WITH_AVAILABILITY_BIT
All queries used by the
command must not be uninitialized
If
QUERY_RESULT_64_BIT is not
set in flags and the queryType used to create queryPool was
not
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
then pData must be aligned to a multiple of 4
If queryCount is
greater than 1,
QUERY_RESULT_64_BIT is not
set in flags and the queryType used to create queryPool was
not
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
then stride must be a multiple of 4
If
QUERY_RESULT_64_BIT is set
in flags then pData must be aligned to a multiple of 8
If queryCount is
greater than 1 and
QUERY_RESULT_64_BIT is set
in flags, then stride must be a multiple of 8
If queryCount is greater
than 1 and
QUERY_RESULT_WITH_AVAILABILITY_BIT
is set, stride must be large enough to contain the unsigned
integer representing availability or status in addition to the query
result
If the queryType used
to create queryPool was
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
then pData must be aligned to a multiple of the size of
PerformanceCounterResultKHR
If queryCount is
greater than 1 and the queryType used to create queryPool was
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
then stride must be a multiple of the size of
PerformanceCounterResultKHR
If queryCount is
greater than 1 and the queryType used to create queryPool was
QUERY_TYPE_PERFORMANCE_QUERY_KHR,
then stride must be large enough to contain the
QueryPoolPerformanceCreateInfoKHR::counterIndexCount
used to create queryPool times the size of
PerformanceCounterResultKHR
dataSize must be
large enough to contain the result of each query, as described
here
Valid Usage (Implicit)
queryPool must
be a valid QueryPool handle
pData must be a
valid pointer to an array of dataSize bytes
flags must be a
valid combination of
QueryResultFlagBits values
dataSize must
be greater than 0
queryPool must
have been created, allocated, or retrieved from device
Return Codes
- Success
- Failure
See Also
VK_VERSION_1_0,
Device,
DeviceSize,
QueryPool,
QueryResultFlags