1e5c31af7Sopenharmony_ci// Copyright 2015-2021 The Khronos Group, Inc. 2e5c31af7Sopenharmony_ci// 3e5c31af7Sopenharmony_ci// SPDX-License-Identifier: CC-BY-4.0 4e5c31af7Sopenharmony_ci 5e5c31af7Sopenharmony_ci[[queries]] 6e5c31af7Sopenharmony_ci= Queries 7e5c31af7Sopenharmony_ci 8e5c31af7Sopenharmony_ci_Queries_ provide a mechanism to return information about the processing of 9e5c31af7Sopenharmony_cia sequence of Vulkan commands. 10e5c31af7Sopenharmony_ciQuery operations are asynchronous, and as such, their results are not 11e5c31af7Sopenharmony_cireturned immediately. 12e5c31af7Sopenharmony_ciInstead, their results, and their availability status are stored in a 13e5c31af7Sopenharmony_ci<<queries-pools, Query Pool>>. 14e5c31af7Sopenharmony_ciThe state of these queries can: be read back on the host, or copied to a 15e5c31af7Sopenharmony_cibuffer object on the device. 16e5c31af7Sopenharmony_ci 17e5c31af7Sopenharmony_ciThe supported query types are <<queries-occlusion,Occlusion Queries>>, 18e5c31af7Sopenharmony_ci<<queries-pipestats,Pipeline Statistics Queries>>, 19e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 20e5c31af7Sopenharmony_ci<<queries-result-status-only, Result Status Queries>>, 21e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 22e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_queue[] 23e5c31af7Sopenharmony_ci<<queries-video-encode-bitstream-buffer-range, Video Encode Bitstream 24e5c31af7Sopenharmony_ciQueries>>, 25e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_queue[] 26e5c31af7Sopenharmony_ciand <<queries-timestamps, Timestamp Queries>>. 27e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 28e5c31af7Sopenharmony_ci<<queries-performance, Performance Queries>> are supported if the associated 29e5c31af7Sopenharmony_ciextension is available. 30e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 31e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 32e5c31af7Sopenharmony_ci<<queries-transform-feedback, Transform Feedback Queries>> are supported if 33e5c31af7Sopenharmony_cithe associated extension is available. 34e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 35e5c31af7Sopenharmony_ciifdef::VK_INTEL_performance_query[] 36e5c31af7Sopenharmony_ci<<queries-performance-intel>> are supported if the associated extension is 37e5c31af7Sopenharmony_ciavailable. 38e5c31af7Sopenharmony_ciendif::VK_INTEL_performance_query[] 39e5c31af7Sopenharmony_ci 40e5c31af7Sopenharmony_ciifdef::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 41e5c31af7Sopenharmony_ciSeveral additional queries with specific purposes associated with ray 42e5c31af7Sopenharmony_citracing are available if the corresponding extensions are supported, as 43e5c31af7Sopenharmony_cidescribed for elink:VkQueryType. 44e5c31af7Sopenharmony_ciendif::VK_KHR_acceleration_structure,VK_NV_ray_tracing[] 45e5c31af7Sopenharmony_ci 46e5c31af7Sopenharmony_ci 47e5c31af7Sopenharmony_ci[[queries-pools]] 48e5c31af7Sopenharmony_ci== Query Pools 49e5c31af7Sopenharmony_ci 50e5c31af7Sopenharmony_ci[open,refpage='VkQueryPool',desc='Opaque handle to a query pool object',type='handles'] 51e5c31af7Sopenharmony_ci-- 52e5c31af7Sopenharmony_ciQueries are managed using _query pool_ objects. 53e5c31af7Sopenharmony_ciEach query pool is a collection of a specific number of queries of a 54e5c31af7Sopenharmony_ciparticular type. 55e5c31af7Sopenharmony_ci 56e5c31af7Sopenharmony_ciQuery pools are represented by sname:VkQueryPool handles: 57e5c31af7Sopenharmony_ci 58e5c31af7Sopenharmony_ciinclude::{generated}/api/handles/VkQueryPool.txt[] 59e5c31af7Sopenharmony_ci-- 60e5c31af7Sopenharmony_ci 61e5c31af7Sopenharmony_ci[open,refpage='vkCreateQueryPool',desc='Create a new query pool object',type='protos'] 62e5c31af7Sopenharmony_ci-- 63e5c31af7Sopenharmony_ciTo create a query pool, call: 64e5c31af7Sopenharmony_ci 65e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCreateQueryPool.txt[] 66e5c31af7Sopenharmony_ci 67e5c31af7Sopenharmony_ci * pname:device is the logical device that creates the query pool. 68e5c31af7Sopenharmony_ci * pname:pCreateInfo is a pointer to a slink:VkQueryPoolCreateInfo 69e5c31af7Sopenharmony_ci structure containing the number and type of queries to be managed by the 70e5c31af7Sopenharmony_ci pool. 71e5c31af7Sopenharmony_ci * pname:pAllocator controls host memory allocation as described in the 72e5c31af7Sopenharmony_ci <<memory-allocation, Memory Allocation>> chapter. 73e5c31af7Sopenharmony_ci * pname:pQueryPool is a pointer to a slink:VkQueryPool handle in which the 74e5c31af7Sopenharmony_ci resulting query pool object is returned. 75e5c31af7Sopenharmony_ci 76e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCreateQueryPool.txt[] 77e5c31af7Sopenharmony_ci-- 78e5c31af7Sopenharmony_ci 79e5c31af7Sopenharmony_ci[open,refpage='VkQueryPoolCreateInfo',desc='Structure specifying parameters of a newly created query pool',type='structs'] 80e5c31af7Sopenharmony_ci-- 81e5c31af7Sopenharmony_ciThe sname:VkQueryPoolCreateInfo structure is defined as: 82e5c31af7Sopenharmony_ci 83e5c31af7Sopenharmony_ciinclude::{generated}/api/structs/VkQueryPoolCreateInfo.txt[] 84e5c31af7Sopenharmony_ci 85e5c31af7Sopenharmony_ci * pname:sType is the type of this structure. 86e5c31af7Sopenharmony_ci * pname:pNext is `NULL` or a pointer to a structure extending this 87e5c31af7Sopenharmony_ci structure. 88e5c31af7Sopenharmony_ci * pname:flags is reserved for future use. 89e5c31af7Sopenharmony_ci * pname:queryType is a elink:VkQueryType value specifying the type of 90e5c31af7Sopenharmony_ci queries managed by the pool. 91e5c31af7Sopenharmony_ci * pname:queryCount is the number of queries managed by the pool. 92e5c31af7Sopenharmony_ci * pname:pipelineStatistics is a bitmask of 93e5c31af7Sopenharmony_ci elink:VkQueryPipelineStatisticFlagBits specifying which counters will be 94e5c31af7Sopenharmony_ci returned in queries on the new pool, as described below in 95e5c31af7Sopenharmony_ci <<queries-pipestats>>. 96e5c31af7Sopenharmony_ci 97e5c31af7Sopenharmony_cipname:pipelineStatistics is ignored if pname:queryType is not 98e5c31af7Sopenharmony_ciename:VK_QUERY_TYPE_PIPELINE_STATISTICS. 99e5c31af7Sopenharmony_ci 100e5c31af7Sopenharmony_ci.Valid Usage 101e5c31af7Sopenharmony_ci**** 102e5c31af7Sopenharmony_ci * [[VUID-VkQueryPoolCreateInfo-queryType-00791]] 103e5c31af7Sopenharmony_ci If the <<features-pipelineStatisticsQuery,pipeline statistics queries>> 104e5c31af7Sopenharmony_ci feature is not enabled, pname:queryType must: not be 105e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PIPELINE_STATISTICS 106e5c31af7Sopenharmony_ci * [[VUID-VkQueryPoolCreateInfo-queryType-00792]] 107e5c31af7Sopenharmony_ci If pname:queryType is ename:VK_QUERY_TYPE_PIPELINE_STATISTICS, 108e5c31af7Sopenharmony_ci pname:pipelineStatistics must: be a valid combination of 109e5c31af7Sopenharmony_ci elink:VkQueryPipelineStatisticFlagBits values 110e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 111e5c31af7Sopenharmony_ci * [[VUID-VkQueryPoolCreateInfo-queryType-03222]] 112e5c31af7Sopenharmony_ci If pname:queryType is ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, the 113e5c31af7Sopenharmony_ci pname:pNext chain must: include a 114e5c31af7Sopenharmony_ci slink:VkQueryPoolPerformanceCreateInfoKHR structure 115e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 116e5c31af7Sopenharmony_ci * [[VUID-VkQueryPoolCreateInfo-queryCount-02763]] 117e5c31af7Sopenharmony_ci pname:queryCount must: be greater than 0 118e5c31af7Sopenharmony_ci**** 119e5c31af7Sopenharmony_ci 120e5c31af7Sopenharmony_ciinclude::{generated}/validity/structs/VkQueryPoolCreateInfo.txt[] 121e5c31af7Sopenharmony_ci-- 122e5c31af7Sopenharmony_ci 123e5c31af7Sopenharmony_ci[open,refpage='VkQueryPoolCreateFlags',desc='Reserved for future use',type='flags'] 124e5c31af7Sopenharmony_ci-- 125e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkQueryPoolCreateFlags.txt[] 126e5c31af7Sopenharmony_ci 127e5c31af7Sopenharmony_citname:VkQueryPoolCreateFlags is a bitmask type for setting a mask, but is 128e5c31af7Sopenharmony_cicurrently reserved for future use. 129e5c31af7Sopenharmony_ci-- 130e5c31af7Sopenharmony_ci 131e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 132e5c31af7Sopenharmony_ciinclude::{chapters}/VK_KHR_performance_query/querycreateinfo.txt[] 133e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 134e5c31af7Sopenharmony_ci 135e5c31af7Sopenharmony_ci[open,refpage='vkDestroyQueryPool',desc='Destroy a query pool object',type='protos'] 136e5c31af7Sopenharmony_ci-- 137e5c31af7Sopenharmony_ciTo destroy a query pool, call: 138e5c31af7Sopenharmony_ci 139e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkDestroyQueryPool.txt[] 140e5c31af7Sopenharmony_ci 141e5c31af7Sopenharmony_ci * pname:device is the logical device that destroys the query pool. 142e5c31af7Sopenharmony_ci * pname:queryPool is the query pool to destroy. 143e5c31af7Sopenharmony_ci * pname:pAllocator controls host memory allocation as described in the 144e5c31af7Sopenharmony_ci <<memory-allocation, Memory Allocation>> chapter. 145e5c31af7Sopenharmony_ci 146e5c31af7Sopenharmony_ci.Valid Usage 147e5c31af7Sopenharmony_ci**** 148e5c31af7Sopenharmony_ci * [[VUID-vkDestroyQueryPool-queryPool-00793]] 149e5c31af7Sopenharmony_ci All submitted commands that refer to pname:queryPool must: have 150e5c31af7Sopenharmony_ci completed execution 151e5c31af7Sopenharmony_ci * [[VUID-vkDestroyQueryPool-queryPool-00794]] 152e5c31af7Sopenharmony_ci If sname:VkAllocationCallbacks were provided when pname:queryPool was 153e5c31af7Sopenharmony_ci created, a compatible set of callbacks must: be provided here 154e5c31af7Sopenharmony_ci * [[VUID-vkDestroyQueryPool-queryPool-00795]] 155e5c31af7Sopenharmony_ci If no sname:VkAllocationCallbacks were provided when pname:queryPool was 156e5c31af7Sopenharmony_ci created, pname:pAllocator must: be `NULL` 157e5c31af7Sopenharmony_ci**** 158e5c31af7Sopenharmony_ci 159e5c31af7Sopenharmony_ci[NOTE] 160e5c31af7Sopenharmony_ci.Note 161e5c31af7Sopenharmony_ci==== 162e5c31af7Sopenharmony_ciApplications can: verify that pname:queryPool can: be destroyed by checking 163e5c31af7Sopenharmony_cithat fname:vkGetQueryPoolResults() without the 164e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_PARTIAL_BIT flag returns ename:VK_SUCCESS for all 165e5c31af7Sopenharmony_ciqueries that are used in command buffers submitted for execution. 166e5c31af7Sopenharmony_ci==== 167e5c31af7Sopenharmony_ci 168e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkDestroyQueryPool.txt[] 169e5c31af7Sopenharmony_ci-- 170e5c31af7Sopenharmony_ci 171e5c31af7Sopenharmony_ci[open,refpage='VkQueryType',desc='Specify the type of queries managed by a query pool',type='enums'] 172e5c31af7Sopenharmony_ci-- 173e5c31af7Sopenharmony_ciPossible values of slink:VkQueryPoolCreateInfo::pname:queryType, specifying 174e5c31af7Sopenharmony_cithe type of queries managed by the pool, are: 175e5c31af7Sopenharmony_ci 176e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkQueryType.txt[] 177e5c31af7Sopenharmony_ci 178e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_OCCLUSION specifies an <<queries-occlusion, 179e5c31af7Sopenharmony_ci occlusion query>>. 180e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_PIPELINE_STATISTICS specifies a <<queries-pipestats, 181e5c31af7Sopenharmony_ci pipeline statistics query>>. 182e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_TIMESTAMP specifies a <<queries-timestamps, 183e5c31af7Sopenharmony_ci timestamp query>>. 184e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 185e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR specifies a 186e5c31af7Sopenharmony_ci <<queries-performance, performance query>>. 187e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 188e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 189e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT specifies a 190e5c31af7Sopenharmony_ci <<queries-transform-feedback, transform feedback query>>. 191e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 192e5c31af7Sopenharmony_ciifdef::VK_KHR_acceleration_structure[] 193e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR specifies 194e5c31af7Sopenharmony_ci a <<acceleration-structure-copying, acceleration structure size query>> 195e5c31af7Sopenharmony_ci for use with flink:vkCmdWriteAccelerationStructuresPropertiesKHR or 196e5c31af7Sopenharmony_ci flink:vkWriteAccelerationStructuresPropertiesKHR. 197e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR 198e5c31af7Sopenharmony_ci specifies a <<acceleration-structure-copying, serialization acceleration 199e5c31af7Sopenharmony_ci structure size query>> 200e5c31af7Sopenharmony_ciendif::VK_KHR_acceleration_structure[] 201e5c31af7Sopenharmony_ciifdef::VK_NV_ray_tracing[] 202e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV specifies a 203e5c31af7Sopenharmony_ci <<acceleration-structure-copying, acceleration structure size query>> 204e5c31af7Sopenharmony_ci for use with flink:vkCmdWriteAccelerationStructuresPropertiesNV. 205e5c31af7Sopenharmony_ciendif::VK_NV_ray_tracing[] 206e5c31af7Sopenharmony_ciifdef::VK_INTEL_performance_query[] 207e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL specifies a 208e5c31af7Sopenharmony_ci <<queries-performance-intel, Intel performance query>>. 209e5c31af7Sopenharmony_ciendif::VK_INTEL_performance_query[] 210e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 211e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR specifies a 212e5c31af7Sopenharmony_ci <<queries-result-status-only, result status query>>. 213e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 214e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_queue[] 215e5c31af7Sopenharmony_ci * ename:VK_QUERY_TYPE_VIDEO_ENCODE_BITSTREAM_BUFFER_RANGE_KHR specifies a 216e5c31af7Sopenharmony_ci <<queries-video-encode-bitstream-buffer-range, video encode bitstream 217e5c31af7Sopenharmony_ci range query>>. 218e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_queue[] 219e5c31af7Sopenharmony_ci-- 220e5c31af7Sopenharmony_ci 221e5c31af7Sopenharmony_ci 222e5c31af7Sopenharmony_ci[[queries-operation]] 223e5c31af7Sopenharmony_ci== Query Operation 224e5c31af7Sopenharmony_ci 225e5c31af7Sopenharmony_ciThe operation of queries is controlled by the commands 226e5c31af7Sopenharmony_ciflink:vkCmdBeginQuery, flink:vkCmdEndQuery, 227e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 228e5c31af7Sopenharmony_ciflink:vkCmdBeginQueryIndexedEXT, flink:vkCmdEndQueryIndexedEXT, 229e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 230e5c31af7Sopenharmony_ciflink:vkCmdResetQueryPool, flink:vkCmdCopyQueryPoolResults, 231e5c31af7Sopenharmony_ciifdef::VK_KHR_synchronization2[] 232e5c31af7Sopenharmony_ciflink:vkCmdWriteTimestamp2KHR, 233e5c31af7Sopenharmony_ciendif::VK_KHR_synchronization2[] 234e5c31af7Sopenharmony_ciand flink:vkCmdWriteTimestamp. 235e5c31af7Sopenharmony_ci 236e5c31af7Sopenharmony_ciIn order for a sname:VkCommandBuffer to record query management commands, 237e5c31af7Sopenharmony_cithe queue family for which its sname:VkCommandPool was created must: support 238e5c31af7Sopenharmony_cithe appropriate type of operations (graphics, compute) suitable for the 239e5c31af7Sopenharmony_ciquery type of a given query pool. 240e5c31af7Sopenharmony_ci 241e5c31af7Sopenharmony_ciEach query in a query pool has a status that is either _unavailable_ or 242e5c31af7Sopenharmony_ci_available_, and also has state to store the numerical results of a query 243e5c31af7Sopenharmony_cioperation of the type requested when the query pool was created. 244e5c31af7Sopenharmony_ciResetting a query via flink:vkCmdResetQueryPool 245e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_host_query_reset[] 246e5c31af7Sopenharmony_cior flink:vkResetQueryPool 247e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_host_query_reset[] 248e5c31af7Sopenharmony_cisets the status to unavailable and makes the numerical results undefined:. 249e5c31af7Sopenharmony_ciPerforming a query operation with flink:vkCmdBeginQuery and 250e5c31af7Sopenharmony_ciflink:vkCmdEndQuery changes the status to available when the query 251e5c31af7Sopenharmony_ci<<queries-operation-finished,finishes>>, and updates the numerical results. 252e5c31af7Sopenharmony_ciBoth the availability status and numerical results are retrieved by calling 253e5c31af7Sopenharmony_cieither flink:vkGetQueryPoolResults or flink:vkCmdCopyQueryPoolResults. 254e5c31af7Sopenharmony_ci 255e5c31af7Sopenharmony_ci[[queries-order]] 256e5c31af7Sopenharmony_ciQuery commands, for the same query and submitted to the same queue, execute 257e5c31af7Sopenharmony_ciin their entirety in <<synchronization-submission-order, submission order>>, 258e5c31af7Sopenharmony_cirelative to each other. 259e5c31af7Sopenharmony_ciIn effect there is an implicit execution dependency from each such query 260e5c31af7Sopenharmony_cicommand to all query commands previously submitted to the same queue. 261e5c31af7Sopenharmony_ciThere is one significant exception to this; if the pname:flags parameter of 262e5c31af7Sopenharmony_ciflink:vkCmdCopyQueryPoolResults does not include 263e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WAIT_BIT, execution of flink:vkCmdCopyQueryPoolResults 264e5c31af7Sopenharmony_cimay: happen-before the results of flink:vkCmdEndQuery are available. 265e5c31af7Sopenharmony_ci 266e5c31af7Sopenharmony_ciAfter query pool creation, each query must: be reset before it is used. 267e5c31af7Sopenharmony_ciQueries must: also be reset between uses. 268e5c31af7Sopenharmony_ci 269e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_device_group[] 270e5c31af7Sopenharmony_ci 271e5c31af7Sopenharmony_ciIf a logical device includes multiple physical devices, then each command 272e5c31af7Sopenharmony_cithat writes a query must: execute on a single physical device, and any call 273e5c31af7Sopenharmony_cito flink:vkCmdBeginQuery must: execute the corresponding flink:vkCmdEndQuery 274e5c31af7Sopenharmony_cicommand on the same physical device. 275e5c31af7Sopenharmony_ci 276e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_device_group[] 277e5c31af7Sopenharmony_ci 278e5c31af7Sopenharmony_ci[open,refpage='vkCmdResetQueryPool',desc='Reset queries in a query pool',type='protos'] 279e5c31af7Sopenharmony_ci-- 280e5c31af7Sopenharmony_ciTo reset a range of queries in a query pool on a queue, call: 281e5c31af7Sopenharmony_ci 282e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdResetQueryPool.txt[] 283e5c31af7Sopenharmony_ci 284e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which this command will 285e5c31af7Sopenharmony_ci be recorded. 286e5c31af7Sopenharmony_ci * pname:queryPool is the handle of the query pool managing the queries 287e5c31af7Sopenharmony_ci being reset. 288e5c31af7Sopenharmony_ci * pname:firstQuery is the initial query index to reset. 289e5c31af7Sopenharmony_ci * pname:queryCount is the number of queries to reset. 290e5c31af7Sopenharmony_ci 291e5c31af7Sopenharmony_ciWhen executed on a queue, this command sets the status of query indices 292e5c31af7Sopenharmony_ci[eq]#[pname:firstQuery, pname:firstQuery {plus} pname:queryCount - 1]# to 293e5c31af7Sopenharmony_ciunavailable. 294e5c31af7Sopenharmony_ci 295e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 296e5c31af7Sopenharmony_ciIf the pname:queryType used to create pname:queryPool was 297e5c31af7Sopenharmony_ciename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, this command sets the status of 298e5c31af7Sopenharmony_ciquery indices [eq]#[pname:firstQuery, pname:firstQuery {plus} 299e5c31af7Sopenharmony_cipname:queryCount - 1]# to unavailable for each pass of pname:queryPool, as 300e5c31af7Sopenharmony_ciindicated by a call to 301e5c31af7Sopenharmony_ciflink:vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR. 302e5c31af7Sopenharmony_ci 303e5c31af7Sopenharmony_ci[NOTE] 304e5c31af7Sopenharmony_ci.Note 305e5c31af7Sopenharmony_ci==== 306e5c31af7Sopenharmony_ciBecause fname:vkCmdResetQueryPool resets all the passes of the indicated 307e5c31af7Sopenharmony_ciqueries, applications must not record a fname:vkCmdResetQueryPool command 308e5c31af7Sopenharmony_cifor a pname:queryPool created with ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR 309e5c31af7Sopenharmony_ciin a command buffer that needs to be submitted multiple times as indicated 310e5c31af7Sopenharmony_ciby a call to flink:vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR. 311e5c31af7Sopenharmony_ciOtherwise applications will never be able to complete the recorded queries. 312e5c31af7Sopenharmony_ci==== 313e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 314e5c31af7Sopenharmony_ci 315e5c31af7Sopenharmony_ci 316e5c31af7Sopenharmony_ci.Valid Usage 317e5c31af7Sopenharmony_ci**** 318e5c31af7Sopenharmony_ci * [[VUID-vkCmdResetQueryPool-firstQuery-00796]] 319e5c31af7Sopenharmony_ci pname:firstQuery must: be less than the number of queries in 320e5c31af7Sopenharmony_ci pname:queryPool 321e5c31af7Sopenharmony_ci * [[VUID-vkCmdResetQueryPool-firstQuery-00797]] 322e5c31af7Sopenharmony_ci The sum of pname:firstQuery and pname:queryCount must: be less than or 323e5c31af7Sopenharmony_ci equal to the number of queries in pname:queryPool 324e5c31af7Sopenharmony_ci * [[VUID-vkCmdResetQueryPool-None-02841]] 325e5c31af7Sopenharmony_ci All queries used by the command must: not be active 326e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 327e5c31af7Sopenharmony_ci * [[VUID-vkCmdResetQueryPool-firstQuery-02862]] 328e5c31af7Sopenharmony_ci If pname:queryPool was created with 329e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, this command must: not be 330e5c31af7Sopenharmony_ci recorded in a command buffer that, either directly or through secondary 331e5c31af7Sopenharmony_ci command buffers, also contains begin commands for a query from the set 332e5c31af7Sopenharmony_ci of queries [eq]#[pname:firstQuery, pname:firstQuery {plus} 333e5c31af7Sopenharmony_ci pname:queryCount - 1]# 334e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 335e5c31af7Sopenharmony_ci**** 336e5c31af7Sopenharmony_ci 337e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdResetQueryPool.txt[] 338e5c31af7Sopenharmony_ci-- 339e5c31af7Sopenharmony_ci 340e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_host_query_reset[] 341e5c31af7Sopenharmony_ci[open,refpage='vkResetQueryPool',desc='Reset queries in a query pool',type='protos',alias='vkResetQueryPoolEXT'] 342e5c31af7Sopenharmony_ci-- 343e5c31af7Sopenharmony_ciTo reset a range of queries in a query pool on the host, call: 344e5c31af7Sopenharmony_ci 345e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2[] 346e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkResetQueryPool.txt[] 347e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2[] 348e5c31af7Sopenharmony_ci 349e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2+VK_EXT_host_query_reset[or the equivalent command] 350e5c31af7Sopenharmony_ci 351e5c31af7Sopenharmony_ciifdef::VK_EXT_host_query_reset[] 352e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkResetQueryPoolEXT.txt[] 353e5c31af7Sopenharmony_ciendif::VK_EXT_host_query_reset[] 354e5c31af7Sopenharmony_ci 355e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the query pool. 356e5c31af7Sopenharmony_ci * pname:queryPool is the handle of the query pool managing the queries 357e5c31af7Sopenharmony_ci being reset. 358e5c31af7Sopenharmony_ci * pname:firstQuery is the initial query index to reset. 359e5c31af7Sopenharmony_ci * pname:queryCount is the number of queries to reset. 360e5c31af7Sopenharmony_ci 361e5c31af7Sopenharmony_ciThis command sets the status of query indices [eq]#[pname:firstQuery, 362e5c31af7Sopenharmony_cipname:firstQuery {plus} pname:queryCount - 1]# to unavailable. 363e5c31af7Sopenharmony_ci 364e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 365e5c31af7Sopenharmony_ciIf pname:queryPool is ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR this command 366e5c31af7Sopenharmony_cisets the status of query indices [eq]#[pname:firstQuery, pname:firstQuery 367e5c31af7Sopenharmony_ci{plus} pname:queryCount - 1]# to unavailable for each pass. 368e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 369e5c31af7Sopenharmony_ci 370e5c31af7Sopenharmony_ci.Valid Usage 371e5c31af7Sopenharmony_ci**** 372e5c31af7Sopenharmony_ci * [[VUID-vkResetQueryPool-None-02665]] 373e5c31af7Sopenharmony_ci The <<features-hostQueryReset,hostQueryReset>> feature must: be enabled 374e5c31af7Sopenharmony_ci * [[VUID-vkResetQueryPool-firstQuery-02666]] 375e5c31af7Sopenharmony_ci pname:firstQuery must: be less than the number of queries in 376e5c31af7Sopenharmony_ci pname:queryPool 377e5c31af7Sopenharmony_ci * [[VUID-vkResetQueryPool-firstQuery-02667]] 378e5c31af7Sopenharmony_ci The sum of pname:firstQuery and pname:queryCount must: be less than or 379e5c31af7Sopenharmony_ci equal to the number of queries in pname:queryPool 380e5c31af7Sopenharmony_ci * [[VUID-vkResetQueryPool-firstQuery-02741]] 381e5c31af7Sopenharmony_ci Submitted commands that refer to the range specified by pname:firstQuery 382e5c31af7Sopenharmony_ci and pname:queryCount in pname:queryPool must: have completed execution 383e5c31af7Sopenharmony_ci * [[VUID-vkResetQueryPool-firstQuery-02742]] 384e5c31af7Sopenharmony_ci The range of queries specified by pname:firstQuery and pname:queryCount 385e5c31af7Sopenharmony_ci in pname:queryPool must: not be in use by calls to 386e5c31af7Sopenharmony_ci flink:vkGetQueryPoolResults or fname:vkResetQueryPool in other threads 387e5c31af7Sopenharmony_ci**** 388e5c31af7Sopenharmony_ci 389e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkResetQueryPool.txt[] 390e5c31af7Sopenharmony_ci-- 391e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_host_query_reset[] 392e5c31af7Sopenharmony_ci 393e5c31af7Sopenharmony_ciOnce queries are reset and ready for use, query commands can: be issued to a 394e5c31af7Sopenharmony_cicommand buffer. 395e5c31af7Sopenharmony_ciOcclusion queries and pipeline statistics queries count events - drawn 396e5c31af7Sopenharmony_cisamples and pipeline stage invocations, respectively - resulting from 397e5c31af7Sopenharmony_cicommands that are recorded between a flink:vkCmdBeginQuery command and a 398e5c31af7Sopenharmony_ciflink:vkCmdEndQuery command within a specified command buffer, effectively 399e5c31af7Sopenharmony_ciscoping a set of drawing and/or dispatching commands. 400e5c31af7Sopenharmony_ciTimestamp queries write timestamps to a query pool. 401e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 402e5c31af7Sopenharmony_ciPerformance queries record performance counters to a query pool. 403e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 404e5c31af7Sopenharmony_ci 405e5c31af7Sopenharmony_ciA query must: begin and end in the same command buffer, although if it is a 406e5c31af7Sopenharmony_ciprimary command buffer, and the <<features-inheritedQueries,inherited 407e5c31af7Sopenharmony_ciqueries>> feature is enabled, it can: execute secondary command buffers 408e5c31af7Sopenharmony_ciduring the query operation. 409e5c31af7Sopenharmony_ciFor a secondary command buffer to be executed while a query is active, it 410e5c31af7Sopenharmony_cimust: set the pname:occlusionQueryEnable, pname:queryFlags, and/or 411e5c31af7Sopenharmony_cipname:pipelineStatistics members of slink:VkCommandBufferInheritanceInfo to 412e5c31af7Sopenharmony_ciconservative values, as described in the <<commandbuffers-recording, Command 413e5c31af7Sopenharmony_ciBuffer Recording>> section. 414e5c31af7Sopenharmony_ciA query must: either begin and end inside the same subpass of a render pass 415e5c31af7Sopenharmony_ciinstance, or must: both begin and end outside of a render pass instance 416e5c31af7Sopenharmony_ci(i.e. contain entire render pass instances). 417e5c31af7Sopenharmony_ci 418e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 419e5c31af7Sopenharmony_ci 420e5c31af7Sopenharmony_ciIf queries are used while executing a render pass instance that has 421e5c31af7Sopenharmony_cimultiview enabled, the query uses [eq]#N# consecutive query indices in the 422e5c31af7Sopenharmony_ciquery pool (starting at pname:query) where [eq]#N# is the number of bits set 423e5c31af7Sopenharmony_ciin the view mask in the subpass the query is used in. 424e5c31af7Sopenharmony_ciHow the numerical results of the query are distributed among the queries is 425e5c31af7Sopenharmony_ciimplementation-dependent. 426e5c31af7Sopenharmony_ciFor example, some implementations may: write each view's results to a 427e5c31af7Sopenharmony_cidistinct query, while other implementations may: write the total result to 428e5c31af7Sopenharmony_cithe first query and write zero to the other queries. 429e5c31af7Sopenharmony_ciHowever, the sum of the results in all the queries must: accurately reflect 430e5c31af7Sopenharmony_cithe total result of the query summed over all views. 431e5c31af7Sopenharmony_ciApplications can: sum the results from all the queries to compute the total 432e5c31af7Sopenharmony_ciresult. 433e5c31af7Sopenharmony_ci 434e5c31af7Sopenharmony_ciQueries used with multiview rendering must: not span subpasses, i.e. they 435e5c31af7Sopenharmony_cimust: begin and end in the same subpass. 436e5c31af7Sopenharmony_ci 437e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 438e5c31af7Sopenharmony_ci 439e5c31af7Sopenharmony_ci[open,refpage='vkCmdBeginQuery',desc='Begin a query',type='protos'] 440e5c31af7Sopenharmony_ci-- 441e5c31af7Sopenharmony_ci:refpage: vkCmdBeginQuery 442e5c31af7Sopenharmony_ci 443e5c31af7Sopenharmony_ciTo begin a query, call: 444e5c31af7Sopenharmony_ci 445e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdBeginQuery.txt[] 446e5c31af7Sopenharmony_ci 447e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which this command will 448e5c31af7Sopenharmony_ci be recorded. 449e5c31af7Sopenharmony_ci * pname:queryPool is the query pool that will manage the results of the 450e5c31af7Sopenharmony_ci query. 451e5c31af7Sopenharmony_ci * pname:query is the query index within the query pool that will contain 452e5c31af7Sopenharmony_ci the results. 453e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkQueryControlFlagBits specifying 454e5c31af7Sopenharmony_ci constraints on the types of queries that can: be performed. 455e5c31af7Sopenharmony_ci 456e5c31af7Sopenharmony_ciIf the pname:queryType of the pool is ename:VK_QUERY_TYPE_OCCLUSION and 457e5c31af7Sopenharmony_cipname:flags contains ename:VK_QUERY_CONTROL_PRECISE_BIT, an implementation 458e5c31af7Sopenharmony_cimust: return a result that matches the actual number of samples passed. 459e5c31af7Sopenharmony_ciThis is described in more detail in <<queries-occlusion,Occlusion Queries>>. 460e5c31af7Sopenharmony_ci 461e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 462e5c31af7Sopenharmony_ciCalling fname:vkCmdBeginQuery is equivalent to calling 463e5c31af7Sopenharmony_ciflink:vkCmdBeginQueryIndexedEXT with the pname:index parameter set to zero. 464e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 465e5c31af7Sopenharmony_ci 466e5c31af7Sopenharmony_ci[[queries-operation-active]] 467e5c31af7Sopenharmony_ciAfter beginning a query, that query is considered _active_ within the 468e5c31af7Sopenharmony_cicommand buffer it was called in until that same query is ended. 469e5c31af7Sopenharmony_ciQueries active in a primary command buffer when secondary command buffers 470e5c31af7Sopenharmony_ciare executed are considered active for those secondary command buffers. 471e5c31af7Sopenharmony_ci 472e5c31af7Sopenharmony_ci.Valid Usage 473e5c31af7Sopenharmony_ci**** 474e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/query_begin_common.txt[] 475e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQuery-queryPool-01922]] 476e5c31af7Sopenharmony_ci pname:queryPool must: have been created with a pname:queryType that 477e5c31af7Sopenharmony_ci differs from that of any queries that are 478e5c31af7Sopenharmony_ci <<queries-operation-active,active>> within pname:commandBuffer 479e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 480e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQuery-queryType-02327]] 481e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 482e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT the 483e5c31af7Sopenharmony_ci sname:VkCommandPool that pname:commandBuffer was allocated from must: 484e5c31af7Sopenharmony_ci support graphics operations 485e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQuery-queryType-02328]] 486e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 487e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT then 488e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackQueries 489e5c31af7Sopenharmony_ci must: be supported 490e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 491e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/performance_query_begin_common.txt[] 492e5c31af7Sopenharmony_ci**** 493e5c31af7Sopenharmony_ci 494e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdBeginQuery.txt[] 495e5c31af7Sopenharmony_ci-- 496e5c31af7Sopenharmony_ci 497e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 498e5c31af7Sopenharmony_ci[open,refpage='vkCmdBeginQueryIndexedEXT',desc='Begin an indexed query',type='protos'] 499e5c31af7Sopenharmony_ci-- 500e5c31af7Sopenharmony_ci:refpage: vkCmdBeginQueryIndexedEXT 501e5c31af7Sopenharmony_ci 502e5c31af7Sopenharmony_ciTo begin an indexed query, call: 503e5c31af7Sopenharmony_ci 504e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdBeginQueryIndexedEXT.txt[] 505e5c31af7Sopenharmony_ci 506e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which this command will 507e5c31af7Sopenharmony_ci be recorded. 508e5c31af7Sopenharmony_ci * pname:queryPool is the query pool that will manage the results of the 509e5c31af7Sopenharmony_ci query. 510e5c31af7Sopenharmony_ci * pname:query is the query index within the query pool that will contain 511e5c31af7Sopenharmony_ci the results. 512e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkQueryControlFlagBits specifying 513e5c31af7Sopenharmony_ci constraints on the types of queries that can: be performed. 514e5c31af7Sopenharmony_ci * pname:index is the query type specific index. 515e5c31af7Sopenharmony_ci When the query type is ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT 516e5c31af7Sopenharmony_ci the index represents the vertex stream. 517e5c31af7Sopenharmony_ci 518e5c31af7Sopenharmony_ciThe fname:vkCmdBeginQueryIndexedEXT command operates the same as the 519e5c31af7Sopenharmony_ciflink:vkCmdBeginQuery command, except that it also accepts a query type 520e5c31af7Sopenharmony_cispecific pname:index parameter. 521e5c31af7Sopenharmony_ci 522e5c31af7Sopenharmony_ci.Valid Usage 523e5c31af7Sopenharmony_ci**** 524e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/query_begin_common.txt[] 525e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQueryIndexedEXT-queryPool-04753]] 526e5c31af7Sopenharmony_ci If the pname:queryPool was created with the same pname:queryType as that 527e5c31af7Sopenharmony_ci of another <<queries-operation-active,active>> query within 528e5c31af7Sopenharmony_ci pname:commandBuffer, then pname:index must: not match the index used for 529e5c31af7Sopenharmony_ci the active query 530e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQueryIndexedEXT-queryType-02338]] 531e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 532e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT the 533e5c31af7Sopenharmony_ci sname:VkCommandPool that pname:commandBuffer was allocated from must: 534e5c31af7Sopenharmony_ci support graphics operations 535e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQueryIndexedEXT-queryType-02339]] 536e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 537e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT the pname:index 538e5c31af7Sopenharmony_ci parameter must: be less than 539e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackStreams 540e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQueryIndexedEXT-queryType-02340]] 541e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was not 542e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT the pname:index must: 543e5c31af7Sopenharmony_ci be zero 544e5c31af7Sopenharmony_ci * [[VUID-vkCmdBeginQueryIndexedEXT-queryType-02341]] 545e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 546e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT then 547e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:transformFeedbackQueries 548e5c31af7Sopenharmony_ci must: be supported 549e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/performance_query_begin_common.txt[] 550e5c31af7Sopenharmony_ci**** 551e5c31af7Sopenharmony_ci 552e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdBeginQueryIndexedEXT.txt[] 553e5c31af7Sopenharmony_ci-- 554e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 555e5c31af7Sopenharmony_ci 556e5c31af7Sopenharmony_ci[open,refpage='VkQueryControlFlagBits',desc='Bitmask specifying constraints on a query',type='enums'] 557e5c31af7Sopenharmony_ci-- 558e5c31af7Sopenharmony_ciBits which can: be set in flink:vkCmdBeginQuery::pname:flags, specifying 559e5c31af7Sopenharmony_ciconstraints on the types of queries that can: be performed, are: 560e5c31af7Sopenharmony_ci 561e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkQueryControlFlagBits.txt[] 562e5c31af7Sopenharmony_ci 563e5c31af7Sopenharmony_ci * ename:VK_QUERY_CONTROL_PRECISE_BIT specifies the precision of 564e5c31af7Sopenharmony_ci <<queries-occlusion, occlusion queries>>. 565e5c31af7Sopenharmony_ci-- 566e5c31af7Sopenharmony_ci 567e5c31af7Sopenharmony_ci[open,refpage='VkQueryControlFlags',desc='Bitmask of VkQueryControlFlagBits',type='flags'] 568e5c31af7Sopenharmony_ci-- 569e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkQueryControlFlags.txt[] 570e5c31af7Sopenharmony_ci 571e5c31af7Sopenharmony_citname:VkQueryControlFlags is a bitmask type for setting a mask of zero or 572e5c31af7Sopenharmony_cimore elink:VkQueryControlFlagBits. 573e5c31af7Sopenharmony_ci-- 574e5c31af7Sopenharmony_ci 575e5c31af7Sopenharmony_ci[open,refpage='vkCmdEndQuery',desc='Ends a query',type='protos'] 576e5c31af7Sopenharmony_ci-- 577e5c31af7Sopenharmony_ciTo end a query after the set of desired drawing or dispatching commands is 578e5c31af7Sopenharmony_ciexecuted, call: 579e5c31af7Sopenharmony_ci 580e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdEndQuery.txt[] 581e5c31af7Sopenharmony_ci 582e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which this command will 583e5c31af7Sopenharmony_ci be recorded. 584e5c31af7Sopenharmony_ci * pname:queryPool is the query pool that is managing the results of the 585e5c31af7Sopenharmony_ci query. 586e5c31af7Sopenharmony_ci * pname:query is the query index within the query pool where the result is 587e5c31af7Sopenharmony_ci stored. 588e5c31af7Sopenharmony_ci 589e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 590e5c31af7Sopenharmony_ciCalling fname:vkCmdEndQuery is equivalent to calling 591e5c31af7Sopenharmony_ciflink:vkCmdEndQueryIndexedEXT with the pname:index parameter set to zero. 592e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 593e5c31af7Sopenharmony_ci 594e5c31af7Sopenharmony_ci[[queries-operation-finished]] 595e5c31af7Sopenharmony_ciAs queries operate asynchronously, ending a query does not immediately set 596e5c31af7Sopenharmony_cithe query's status to available. 597e5c31af7Sopenharmony_ciA query is considered _finished_ when the final results of the query are 598e5c31af7Sopenharmony_ciready to be retrieved by flink:vkGetQueryPoolResults and 599e5c31af7Sopenharmony_ciflink:vkCmdCopyQueryPoolResults, and this is when the query's status is set 600e5c31af7Sopenharmony_cito available. 601e5c31af7Sopenharmony_ci 602e5c31af7Sopenharmony_ciOnce a query is ended the query must: finish in finite time, unless the 603e5c31af7Sopenharmony_cistate of the query is changed using other commands, e.g. by issuing a reset 604e5c31af7Sopenharmony_ciof the query. 605e5c31af7Sopenharmony_ci 606e5c31af7Sopenharmony_ci.Valid Usage 607e5c31af7Sopenharmony_ci**** 608e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQuery-None-01923]] 609e5c31af7Sopenharmony_ci All queries used by the command must: be 610e5c31af7Sopenharmony_ci <<queries-operation-active,active>> 611e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQuery-query-00810]] 612e5c31af7Sopenharmony_ci pname:query must: be less than the number of queries in pname:queryPool 613e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 614e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQuery-commandBuffer-01886]] 615e5c31af7Sopenharmony_ci pname:commandBuffer must: not be a protected command buffer 616e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 617e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 618e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQuery-query-00812]] 619e5c31af7Sopenharmony_ci If fname:vkCmdEndQuery is called within a render pass instance, the sum 620e5c31af7Sopenharmony_ci of pname:query and the number of bits set in the current subpass's view 621e5c31af7Sopenharmony_ci mask must: be less than or equal to the number of queries in 622e5c31af7Sopenharmony_ci pname:queryPool 623e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 624e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 625e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQuery-queryPool-03227]] 626e5c31af7Sopenharmony_ci If pname:queryPool was created with a pname:queryType of 627e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR and one or more of the 628e5c31af7Sopenharmony_ci counters used to create pname:queryPool was 629e5c31af7Sopenharmony_ci ename:VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR, the 630e5c31af7Sopenharmony_ci flink:vkCmdEndQuery must: be the last recorded command in 631e5c31af7Sopenharmony_ci pname:commandBuffer 632e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQuery-queryPool-03228]] 633e5c31af7Sopenharmony_ci If pname:queryPool was created with a pname:queryType of 634e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR and one or more of the 635e5c31af7Sopenharmony_ci counters used to create pname:queryPool was 636e5c31af7Sopenharmony_ci ename:VK_PERFORMANCE_COUNTER_SCOPE_RENDER_PASS_KHR, the 637e5c31af7Sopenharmony_ci flink:vkCmdEndQuery must: not be recorded within a render pass instance 638e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 639e5c31af7Sopenharmony_ci**** 640e5c31af7Sopenharmony_ci 641e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdEndQuery.txt[] 642e5c31af7Sopenharmony_ci-- 643e5c31af7Sopenharmony_ci 644e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 645e5c31af7Sopenharmony_ci[open,refpage='vkCmdEndQueryIndexedEXT',desc='Ends a query',type='protos'] 646e5c31af7Sopenharmony_ci-- 647e5c31af7Sopenharmony_ciTo end an indexed query after the set of desired drawing or dispatching 648e5c31af7Sopenharmony_cicommands is recorded, call: 649e5c31af7Sopenharmony_ci 650e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdEndQueryIndexedEXT.txt[] 651e5c31af7Sopenharmony_ci 652e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which this command will 653e5c31af7Sopenharmony_ci be recorded. 654e5c31af7Sopenharmony_ci * pname:queryPool is the query pool that is managing the results of the 655e5c31af7Sopenharmony_ci query. 656e5c31af7Sopenharmony_ci * pname:query is the query index within the query pool where the result is 657e5c31af7Sopenharmony_ci stored. 658e5c31af7Sopenharmony_ci * pname:index is the query type specific index. 659e5c31af7Sopenharmony_ci 660e5c31af7Sopenharmony_ciThe fname:vkCmdEndQueryIndexedEXT command operates the same as the 661e5c31af7Sopenharmony_ciflink:vkCmdEndQuery command, except that it also accepts a query type 662e5c31af7Sopenharmony_cispecific pname:index parameter. 663e5c31af7Sopenharmony_ci 664e5c31af7Sopenharmony_ci.Valid Usage 665e5c31af7Sopenharmony_ci**** 666e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-None-02342]] 667e5c31af7Sopenharmony_ci All queries used by the command must: be 668e5c31af7Sopenharmony_ci <<queries-operation-active,active>> 669e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-query-02343]] 670e5c31af7Sopenharmony_ci pname:query must: be less than the number of queries in pname:queryPool 671e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1[] 672e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-commandBuffer-02344]] 673e5c31af7Sopenharmony_ci pname:commandBuffer must: not be a protected command buffer 674e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1[] 675e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 676e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-query-02345]] 677e5c31af7Sopenharmony_ci If fname:vkCmdEndQueryIndexedEXT is called within a render pass 678e5c31af7Sopenharmony_ci instance, the sum of pname:query and the number of bits set in the 679e5c31af7Sopenharmony_ci current subpass's view mask must: be less than or equal to the number of 680e5c31af7Sopenharmony_ci queries in pname:queryPool 681e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 682e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-queryType-02346]] 683e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 684e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT the pname:index 685e5c31af7Sopenharmony_ci parameter must: be less than 686e5c31af7Sopenharmony_ci sname:VkPhysicalDeviceTransformFeedbackPropertiesEXT::pname:maxTransformFeedbackStreams 687e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-queryType-02347]] 688e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was not 689e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT the pname:index must: 690e5c31af7Sopenharmony_ci be zero 691e5c31af7Sopenharmony_ci * [[VUID-vkCmdEndQueryIndexedEXT-queryType-02723]] 692e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 693e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT pname:index must: 694e5c31af7Sopenharmony_ci equal the pname:index used to begin the query 695e5c31af7Sopenharmony_ci 696e5c31af7Sopenharmony_ci**** 697e5c31af7Sopenharmony_ci 698e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdEndQueryIndexedEXT.txt[] 699e5c31af7Sopenharmony_ci-- 700e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 701e5c31af7Sopenharmony_ci 702e5c31af7Sopenharmony_ci[[queries-operation-memorylayout]] 703e5c31af7Sopenharmony_ciAn application can: retrieve results either by requesting they be written 704e5c31af7Sopenharmony_ciinto application-provided memory, or by requesting they be copied into a 705e5c31af7Sopenharmony_cisname:VkBuffer. 706e5c31af7Sopenharmony_ciIn either case, the layout in memory is defined as follows: 707e5c31af7Sopenharmony_ci 708e5c31af7Sopenharmony_ci * The first query's result is written starting at the first byte requested 709e5c31af7Sopenharmony_ci by the command, and each subsequent query's result begins pname:stride 710e5c31af7Sopenharmony_ci bytes later. 711e5c31af7Sopenharmony_ci * Occlusion queries, pipeline statistics queries, 712e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 713e5c31af7Sopenharmony_ci transform feedback queries, 714e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 715e5c31af7Sopenharmony_ci and timestamp queries store results in a tightly packed array of 716e5c31af7Sopenharmony_ci unsigned integers, either 32- or 64-bits as requested by the command, 717e5c31af7Sopenharmony_ci storing the numerical results and, if requested, the availability 718e5c31af7Sopenharmony_ci status. 719e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 720e5c31af7Sopenharmony_ci * Performance queries store results in a tightly packed array whose type 721e5c31af7Sopenharmony_ci is determined by the pname:unit member of the corresponding 722e5c31af7Sopenharmony_ci slink:VkPerformanceCounterKHR. 723e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 724e5c31af7Sopenharmony_ci * If ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is used, the final 725e5c31af7Sopenharmony_ci element of each query's result is an integer indicating whether the 726e5c31af7Sopenharmony_ci query's result is available, with any non-zero value indicating that it 727e5c31af7Sopenharmony_ci is available. 728e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 729e5c31af7Sopenharmony_ci * If ename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR is used, the final element 730e5c31af7Sopenharmony_ci of each query's result is an integer value indicating that status of the 731e5c31af7Sopenharmony_ci query result. 732e5c31af7Sopenharmony_ci Positive values indicate success, negative values indicate failure, and 733e5c31af7Sopenharmony_ci 0 indicates that the result is not yet available. 734e5c31af7Sopenharmony_ci Specific error codes are encoded in the elink:VkQueryResultStatusKHR 735e5c31af7Sopenharmony_ci enumeration. 736e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 737e5c31af7Sopenharmony_ci * Occlusion queries write one integer value - the number of samples 738e5c31af7Sopenharmony_ci passed. 739e5c31af7Sopenharmony_ci Pipeline statistics queries write one integer value for each bit that is 740e5c31af7Sopenharmony_ci enabled in the pname:pipelineStatistics when the pool is created, and 741e5c31af7Sopenharmony_ci the statistics values are written in bit order starting from the least 742e5c31af7Sopenharmony_ci significant bit. 743e5c31af7Sopenharmony_ci Timestamp queries write one integer value. 744e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 745e5c31af7Sopenharmony_ci Performance queries write one slink:VkPerformanceCounterResultKHR value 746e5c31af7Sopenharmony_ci for each slink:VkPerformanceCounterKHR in the query. 747e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 748e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 749e5c31af7Sopenharmony_ci Transform feedback queries write two integers; the first integer is the 750e5c31af7Sopenharmony_ci number of primitives successfully written to the corresponding transform 751e5c31af7Sopenharmony_ci feedback buffer and the second is the number of primitives output to the 752e5c31af7Sopenharmony_ci vertex stream, regardless of whether they were successfully captured or 753e5c31af7Sopenharmony_ci not. 754e5c31af7Sopenharmony_ci In other words, if the transform feedback buffer was sized too small for 755e5c31af7Sopenharmony_ci the number of primitives output by the vertex stream, the first integer 756e5c31af7Sopenharmony_ci represents the number of primitives actually written and the second is 757e5c31af7Sopenharmony_ci the number that would have been written if all the transform feedback 758e5c31af7Sopenharmony_ci buffers associated with that vertex stream were large enough. 759e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 760e5c31af7Sopenharmony_ci * If more than one query is retrieved and pname:stride is not at least as 761e5c31af7Sopenharmony_ci large as the size of the array of values corresponding to a single 762e5c31af7Sopenharmony_ci query, the values written to memory are undefined:. 763e5c31af7Sopenharmony_ci 764e5c31af7Sopenharmony_ci[open,refpage='vkGetQueryPoolResults',desc='Copy results of queries in a query pool to a host memory region',type='protos'] 765e5c31af7Sopenharmony_ci-- 766e5c31af7Sopenharmony_ciTo retrieve status and results for a set of queries, call: 767e5c31af7Sopenharmony_ci 768e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkGetQueryPoolResults.txt[] 769e5c31af7Sopenharmony_ci 770e5c31af7Sopenharmony_ci * pname:device is the logical device that owns the query pool. 771e5c31af7Sopenharmony_ci * pname:queryPool is the query pool managing the queries containing the 772e5c31af7Sopenharmony_ci desired results. 773e5c31af7Sopenharmony_ci * pname:firstQuery is the initial query index. 774e5c31af7Sopenharmony_ci * pname:queryCount is the number of queries to read. 775e5c31af7Sopenharmony_ci * pname:dataSize is the size in bytes of the buffer pointed to by 776e5c31af7Sopenharmony_ci pname:pData. 777e5c31af7Sopenharmony_ci * pname:pData is a pointer to a user-allocated buffer where the results 778e5c31af7Sopenharmony_ci will be written 779e5c31af7Sopenharmony_ci * pname:stride is the stride in bytes between results for individual 780e5c31af7Sopenharmony_ci queries within pname:pData. 781e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkQueryResultFlagBits specifying how 782e5c31af7Sopenharmony_ci and when results are returned. 783e5c31af7Sopenharmony_ci 784e5c31af7Sopenharmony_ciThe range of queries read is defined by [eq]#[pname:firstQuery, 785e5c31af7Sopenharmony_cipname:firstQuery {plus} pname:queryCount - 1]#. 786e5c31af7Sopenharmony_ciFor pipeline statistics queries, each query index in the pool contains one 787e5c31af7Sopenharmony_ciinteger value for each bit that is enabled in 788e5c31af7Sopenharmony_cislink:VkQueryPoolCreateInfo::pname:pipelineStatistics when the pool is 789e5c31af7Sopenharmony_cicreated. 790e5c31af7Sopenharmony_ci 791e5c31af7Sopenharmony_ciIf no bits are set in pname:flags, and all requested queries are in the 792e5c31af7Sopenharmony_ciavailable state, results are written as an array of 32-bit unsigned integer 793e5c31af7Sopenharmony_civalues. 794e5c31af7Sopenharmony_ciThe behavior when not all queries are available, is described 795e5c31af7Sopenharmony_ci<<queries-wait-bit-not-set, below>>. 796e5c31af7Sopenharmony_ci 797e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_64_BIT is not set and the result overflows a 32-bit 798e5c31af7Sopenharmony_civalue, the value may: either wrap or saturate. 799e5c31af7Sopenharmony_ciSimilarly, if ename:VK_QUERY_RESULT_64_BIT is set and the result overflows a 800e5c31af7Sopenharmony_ci64-bit value, the value may: either wrap or saturate. 801e5c31af7Sopenharmony_ci 802e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_WAIT_BIT is set, Vulkan will wait for each query to 803e5c31af7Sopenharmony_cibe in the available state before retrieving the numerical results for that 804e5c31af7Sopenharmony_ciquery. 805e5c31af7Sopenharmony_ciIn this case, fname:vkGetQueryPoolResults is guaranteed to succeed and 806e5c31af7Sopenharmony_cireturn ename:VK_SUCCESS if the queries become available in a finite time 807e5c31af7Sopenharmony_ci(i.e. if they have been issued and not reset). 808e5c31af7Sopenharmony_ciIf queries will never finish (e.g. due to being reset but not issued), then 809e5c31af7Sopenharmony_cifname:vkGetQueryPoolResults may: not return in finite time. 810e5c31af7Sopenharmony_ci 811e5c31af7Sopenharmony_ci[[queries-wait-bit-not-set]] 812e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_WAIT_BIT and ename:VK_QUERY_RESULT_PARTIAL_BIT are 813e5c31af7Sopenharmony_ciboth not set then no result values are written to pname:pData for queries 814e5c31af7Sopenharmony_cithat are in the unavailable state at the time of the call, and 815e5c31af7Sopenharmony_cifname:vkGetQueryPoolResults returns ename:VK_NOT_READY. 816e5c31af7Sopenharmony_ciHowever, availability state is still written to pname:pData for those 817e5c31af7Sopenharmony_ciqueries if ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set. 818e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 819e5c31af7Sopenharmony_ciSimilarly, the status is still written to pname:pData for those queries if 820e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR is set. 821e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 822e5c31af7Sopenharmony_ci 823e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_WAIT_BIT is not set, fname:vkGetQueryPoolResults 824e5c31af7Sopenharmony_cimay: return ename:VK_NOT_READY if there are queries in the unavailable 825e5c31af7Sopenharmony_cistate. 826e5c31af7Sopenharmony_ci 827e5c31af7Sopenharmony_ci[NOTE] 828e5c31af7Sopenharmony_ci.Note 829e5c31af7Sopenharmony_ci==== 830e5c31af7Sopenharmony_ciApplications must: take care to ensure that use of the 831e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WAIT_BIT bit has the desired effect. 832e5c31af7Sopenharmony_ci 833e5c31af7Sopenharmony_ciFor example, if a query has been used previously and a command buffer 834e5c31af7Sopenharmony_cirecords the commands fname:vkCmdResetQueryPool, fname:vkCmdBeginQuery, and 835e5c31af7Sopenharmony_cifname:vkCmdEndQuery for that query, then the query will remain in the 836e5c31af7Sopenharmony_ciavailable state until 837e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_host_query_reset[] 838e5c31af7Sopenharmony_cifname:vkResetQueryPool is called or 839e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_host_query_reset[] 840e5c31af7Sopenharmony_cithe fname:vkCmdResetQueryPool command executes on a queue. 841e5c31af7Sopenharmony_ciApplications can: use fences or events to ensure that a query has already 842e5c31af7Sopenharmony_cibeen reset before checking for its results or availability status. 843e5c31af7Sopenharmony_ciOtherwise, a stale value could be returned from a previous use of the query. 844e5c31af7Sopenharmony_ci 845e5c31af7Sopenharmony_ciThe above also applies when ename:VK_QUERY_RESULT_WAIT_BIT is used in 846e5c31af7Sopenharmony_cicombination with ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT. 847e5c31af7Sopenharmony_ciIn this case, the returned availability status may: reflect the result of a 848e5c31af7Sopenharmony_ciprevious use of the query unless 849e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_2,VK_EXT_host_query_reset[] 850e5c31af7Sopenharmony_cifname:vkResetQueryPool is called or 851e5c31af7Sopenharmony_ciendif::VK_VERSION_1_2,VK_EXT_host_query_reset[] 852e5c31af7Sopenharmony_cithe fname:vkCmdResetQueryPool command has been executed since the last use 853e5c31af7Sopenharmony_ciof the query. 854e5c31af7Sopenharmony_ci 855e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 856e5c31af7Sopenharmony_ciA similar situation can arise with the 857e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR flag. 858e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 859e5c31af7Sopenharmony_ci==== 860e5c31af7Sopenharmony_ci 861e5c31af7Sopenharmony_ci[NOTE] 862e5c31af7Sopenharmony_ci.Note 863e5c31af7Sopenharmony_ci==== 864e5c31af7Sopenharmony_ciApplications can: double-buffer query pool usage, with a pool per frame, and 865e5c31af7Sopenharmony_cireset queries at the end of the frame in which they are read. 866e5c31af7Sopenharmony_ci==== 867e5c31af7Sopenharmony_ci 868e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_PARTIAL_BIT is set, ename:VK_QUERY_RESULT_WAIT_BIT 869e5c31af7Sopenharmony_ciis not set, and the query's status is unavailable, an intermediate result 870e5c31af7Sopenharmony_civalue between zero and the final result value is written to pname:pData for 871e5c31af7Sopenharmony_cithat query. 872e5c31af7Sopenharmony_ci 873e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set, the final integer 874e5c31af7Sopenharmony_civalue written for each query is non-zero if the query's status was available 875e5c31af7Sopenharmony_cior zero if the status was unavailable. 876e5c31af7Sopenharmony_ciWhen ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is used, implementations 877e5c31af7Sopenharmony_cimust: guarantee that if they return a non-zero availability value then the 878e5c31af7Sopenharmony_cinumerical results must: be valid, assuming the results are not reset by a 879e5c31af7Sopenharmony_cisubsequent command. 880e5c31af7Sopenharmony_ci 881e5c31af7Sopenharmony_ci[NOTE] 882e5c31af7Sopenharmony_ci.Note 883e5c31af7Sopenharmony_ci==== 884e5c31af7Sopenharmony_ciSatisfying this guarantee may: require careful ordering by the application, 885e5c31af7Sopenharmony_cie.g. to read the availability status before reading the results. 886e5c31af7Sopenharmony_ci==== 887e5c31af7Sopenharmony_ci 888e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 889e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR is set, the final integer value 890e5c31af7Sopenharmony_ciwritten for each query indicates whether the result is available or not, and 891e5c31af7Sopenharmony_ciwhether an error occurred. 892e5c31af7Sopenharmony_ciA value of zero indicates that the results are not yet available. 893e5c31af7Sopenharmony_ciPositive values indicate that the operations within the query completed 894e5c31af7Sopenharmony_cisuccessfully, and the query results are valid. 895e5c31af7Sopenharmony_ciNegative values indicate that the operations within the query completed 896e5c31af7Sopenharmony_ciunsuccessfully. 897e5c31af7Sopenharmony_ci 898e5c31af7Sopenharmony_ciSpecific result codes are defined by the elink:VkQueryResultStatusKHR 899e5c31af7Sopenharmony_cienumeration. 900e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 901e5c31af7Sopenharmony_ci 902e5c31af7Sopenharmony_ci.Valid Usage 903e5c31af7Sopenharmony_ci**** 904e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-firstQuery-00813]] 905e5c31af7Sopenharmony_ci pname:firstQuery must: be less than the number of queries in 906e5c31af7Sopenharmony_ci pname:queryPool 907e5c31af7Sopenharmony_ciifndef::VK_KHR_performance_query[] 908e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-flags-02827]] 909e5c31af7Sopenharmony_ci If ename:VK_QUERY_RESULT_64_BIT is not set in pname:flags, then 910e5c31af7Sopenharmony_ci pname:pData and pname:stride must: be multiples of `4` 911e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 912e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 913e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-flags-02828]] 914e5c31af7Sopenharmony_ci If ename:VK_QUERY_RESULT_64_BIT is not set in pname:flags and the 915e5c31af7Sopenharmony_ci pname:queryType used to create pname:queryPool was not 916e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, then pname:pData and 917e5c31af7Sopenharmony_ci pname:stride must: be multiples of `4` 918e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 919e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-flags-00815]] 920e5c31af7Sopenharmony_ci If ename:VK_QUERY_RESULT_64_BIT is set in pname:flags then pname:pData 921e5c31af7Sopenharmony_ci and pname:stride must: be multiples of `8` 922e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 923e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-queryType-03229]] 924e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 925e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, then pname:pData and 926e5c31af7Sopenharmony_ci pname:stride must: be multiples of the size of 927e5c31af7Sopenharmony_ci slink:VkPerformanceCounterResultKHR 928e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-queryType-04519]] 929e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 930e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, then pname:stride must: be 931e5c31af7Sopenharmony_ci large enough to contain 932e5c31af7Sopenharmony_ci sname:VkQueryPoolPerformanceCreateInfoKHR::pname:counterIndexCount used 933e5c31af7Sopenharmony_ci to create pname:queryPool times the size of 934e5c31af7Sopenharmony_ci slink:VkPerformanceCounterResultKHR 935e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 936e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-firstQuery-00816]] 937e5c31af7Sopenharmony_ci The sum of pname:firstQuery and pname:queryCount must: be less than or 938e5c31af7Sopenharmony_ci equal to the number of queries in pname:queryPool 939e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-dataSize-00817]] 940e5c31af7Sopenharmony_ci pname:dataSize must: be large enough to contain the result of each 941e5c31af7Sopenharmony_ci query, as described <<queries-operation-memorylayout,here>> 942e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-queryType-00818]] 943e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 944e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TIMESTAMP, pname:flags must: not contain 945e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_PARTIAL_BIT 946e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 947e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-queryType-03230]] 948e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 949e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, pname:flags must: not contain 950e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT, 951e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_PARTIAL_BIT or ename:VK_QUERY_RESULT_64_BIT 952e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-queryType-03231]] 953e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 954e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, the pname:queryPool must: 955e5c31af7Sopenharmony_ci have been recorded once for each pass as retrieved via a call to 956e5c31af7Sopenharmony_ci flink:vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR 957e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 958e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 959e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-queryType-04810]] 960e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 961e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR, pname:flags must: include 962e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR 963e5c31af7Sopenharmony_ci * [[VUID-vkGetQueryPoolResults-flags-04811]] 964e5c31af7Sopenharmony_ci If pname:flags includes ename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR, it 965e5c31af7Sopenharmony_ci must: not include ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT 966e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 967e5c31af7Sopenharmony_ci**** 968e5c31af7Sopenharmony_ci 969e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkGetQueryPoolResults.txt[] 970e5c31af7Sopenharmony_ci-- 971e5c31af7Sopenharmony_ci 972e5c31af7Sopenharmony_ci[open,refpage='VkQueryResultFlagBits',desc='Bitmask specifying how and when query results are returned',type='enums'] 973e5c31af7Sopenharmony_ci-- 974e5c31af7Sopenharmony_ciBits which can: be set in flink:vkGetQueryPoolResults::pname:flags and 975e5c31af7Sopenharmony_ciflink:vkCmdCopyQueryPoolResults::pname:flags, specifying how and when 976e5c31af7Sopenharmony_ciresults are returned, are: 977e5c31af7Sopenharmony_ci 978e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkQueryResultFlagBits.txt[] 979e5c31af7Sopenharmony_ci 980e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_64_BIT specifies the results will be written as an 981e5c31af7Sopenharmony_ci array of 64-bit unsigned integer values. 982e5c31af7Sopenharmony_ci If this bit is not set, the results will be written as an array of 983e5c31af7Sopenharmony_ci 32-bit unsigned integer values. 984e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_WAIT_BIT specifies that Vulkan will wait for each 985e5c31af7Sopenharmony_ci query's status to become available before retrieving its results. 986e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT specifies that the 987e5c31af7Sopenharmony_ci availability status accompanies the results. 988e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_PARTIAL_BIT specifies that returning partial 989e5c31af7Sopenharmony_ci results is acceptable. 990e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 991e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR specifies that the last value 992e5c31af7Sopenharmony_ci returned in the query is a elink:VkQueryResultStatusKHR value. 993e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 994e5c31af7Sopenharmony_ci-- 995e5c31af7Sopenharmony_ci 996e5c31af7Sopenharmony_ci[open,refpage='VkQueryResultFlags',desc='Bitmask of VkQueryResultFlagBits',type='flags'] 997e5c31af7Sopenharmony_ci-- 998e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkQueryResultFlags.txt[] 999e5c31af7Sopenharmony_ci 1000e5c31af7Sopenharmony_citname:VkQueryResultFlags is a bitmask type for setting a mask of zero or 1001e5c31af7Sopenharmony_cimore elink:VkQueryResultFlagBits. 1002e5c31af7Sopenharmony_ci-- 1003e5c31af7Sopenharmony_ci 1004e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 1005e5c31af7Sopenharmony_ci[open,refpage='VkQueryResultStatusKHR',desc='Specific status codes for operations',type='enums'] 1006e5c31af7Sopenharmony_ci-- 1007e5c31af7Sopenharmony_ciSpecific status codes that can: be returned from a query are: 1008e5c31af7Sopenharmony_ci 1009e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkQueryResultStatusKHR.txt[] 1010e5c31af7Sopenharmony_ci 1011e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_STATUS_NOT_READY_KHR specifies that the query 1012e5c31af7Sopenharmony_ci result is not yet available. 1013e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_STATUS_ERROR_KHR specifies that operations did not 1014e5c31af7Sopenharmony_ci complete successfully. 1015e5c31af7Sopenharmony_ci * ename:VK_QUERY_RESULT_STATUS_COMPLETE_KHR specifies that operations 1016e5c31af7Sopenharmony_ci completed successfully and the query result is available. 1017e5c31af7Sopenharmony_ci-- 1018e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 1019e5c31af7Sopenharmony_ci 1020e5c31af7Sopenharmony_ci[open,refpage='vkCmdCopyQueryPoolResults',desc='Copy the results of queries in a query pool to a buffer object',type='protos'] 1021e5c31af7Sopenharmony_ci-- 1022e5c31af7Sopenharmony_ciTo copy query statuses and numerical results directly to buffer memory, 1023e5c31af7Sopenharmony_cicall: 1024e5c31af7Sopenharmony_ci 1025e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdCopyQueryPoolResults.txt[] 1026e5c31af7Sopenharmony_ci 1027e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which this command will 1028e5c31af7Sopenharmony_ci be recorded. 1029e5c31af7Sopenharmony_ci * pname:queryPool is the query pool managing the queries containing the 1030e5c31af7Sopenharmony_ci desired results. 1031e5c31af7Sopenharmony_ci * pname:firstQuery is the initial query index. 1032e5c31af7Sopenharmony_ci * pname:queryCount is the number of queries. 1033e5c31af7Sopenharmony_ci pname:firstQuery and pname:queryCount together define a range of 1034e5c31af7Sopenharmony_ci queries. 1035e5c31af7Sopenharmony_ci * pname:dstBuffer is a slink:VkBuffer object that will receive the results 1036e5c31af7Sopenharmony_ci of the copy command. 1037e5c31af7Sopenharmony_ci * pname:dstOffset is an offset into pname:dstBuffer. 1038e5c31af7Sopenharmony_ci * pname:stride is the stride in bytes between results for individual 1039e5c31af7Sopenharmony_ci queries within pname:dstBuffer. 1040e5c31af7Sopenharmony_ci The required size of the backing memory for pname:dstBuffer is 1041e5c31af7Sopenharmony_ci determined as described above for flink:vkGetQueryPoolResults. 1042e5c31af7Sopenharmony_ci * pname:flags is a bitmask of elink:VkQueryResultFlagBits specifying how 1043e5c31af7Sopenharmony_ci and when results are returned. 1044e5c31af7Sopenharmony_ci 1045e5c31af7Sopenharmony_cifname:vkCmdCopyQueryPoolResults is guaranteed to see the effect of previous 1046e5c31af7Sopenharmony_ciuses of fname:vkCmdResetQueryPool in the same queue, without any additional 1047e5c31af7Sopenharmony_cisynchronization. 1048e5c31af7Sopenharmony_ciThus, the results will always reflect the most recent use of the query. 1049e5c31af7Sopenharmony_ci 1050e5c31af7Sopenharmony_cipname:flags has the same possible values described above for the pname:flags 1051e5c31af7Sopenharmony_ciparameter of flink:vkGetQueryPoolResults, but the different style of 1052e5c31af7Sopenharmony_ciexecution causes some subtle behavioral differences. 1053e5c31af7Sopenharmony_ciBecause fname:vkCmdCopyQueryPoolResults executes in order with respect to 1054e5c31af7Sopenharmony_ciother query commands, there is less ambiguity about which use of a query is 1055e5c31af7Sopenharmony_cibeing requested. 1056e5c31af7Sopenharmony_ci 1057e5c31af7Sopenharmony_ciResults for all requested occlusion queries, pipeline statistics queries, 1058e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 1059e5c31af7Sopenharmony_citransform feedback queries, 1060e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 1061e5c31af7Sopenharmony_ciand timestamp queries are written as 64-bit unsigned integer values if 1062e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_64_BIT is set or 32-bit unsigned integer values 1063e5c31af7Sopenharmony_ciotherwise. 1064e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 1065e5c31af7Sopenharmony_ciPerformance queries store results in a tightly packed array whose type is 1066e5c31af7Sopenharmony_cidetermined by the pname:unit member of the corresponding 1067e5c31af7Sopenharmony_cislink:VkPerformanceCounterKHR. 1068e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 1069e5c31af7Sopenharmony_ci 1070e5c31af7Sopenharmony_ciIf neither of ename:VK_QUERY_RESULT_WAIT_BIT and 1071e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT are set, results are only 1072e5c31af7Sopenharmony_ciwritten out for queries in the available state. 1073e5c31af7Sopenharmony_ci 1074e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_WAIT_BIT is set, the implementation will wait for 1075e5c31af7Sopenharmony_cieach query's status to be in the available state before retrieving the 1076e5c31af7Sopenharmony_cinumerical results for that query. 1077e5c31af7Sopenharmony_ciThis is guaranteed to reflect the most recent use of the query on the same 1078e5c31af7Sopenharmony_ciqueue, assuming that the query is not being simultaneously used by other 1079e5c31af7Sopenharmony_ciqueues. 1080e5c31af7Sopenharmony_ciIf the query does not become available in a finite amount of time (e.g. due 1081e5c31af7Sopenharmony_cito not issuing a query since the last reset), a ename:VK_ERROR_DEVICE_LOST 1082e5c31af7Sopenharmony_cierror may: occur. 1083e5c31af7Sopenharmony_ci 1084e5c31af7Sopenharmony_ciSimilarly, if ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT is set and 1085e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WAIT_BIT is not set, the availability is guaranteed to 1086e5c31af7Sopenharmony_cireflect the most recent use of the query on the same queue, assuming that 1087e5c31af7Sopenharmony_cithe query is not being simultaneously used by other queues. 1088e5c31af7Sopenharmony_ciAs with fname:vkGetQueryPoolResults, implementations must: guarantee that if 1089e5c31af7Sopenharmony_cithey return a non-zero availability value, then the numerical results are 1090e5c31af7Sopenharmony_civalid. 1091e5c31af7Sopenharmony_ci 1092e5c31af7Sopenharmony_ciIf ename:VK_QUERY_RESULT_PARTIAL_BIT is set, ename:VK_QUERY_RESULT_WAIT_BIT 1093e5c31af7Sopenharmony_ciis not set, and the query's status is unavailable, an intermediate result 1094e5c31af7Sopenharmony_civalue between zero and the final result value is written for that query. 1095e5c31af7Sopenharmony_ci 1096e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_PARTIAL_BIT must: not be used if the pool's 1097e5c31af7Sopenharmony_cipname:queryType is ename:VK_QUERY_TYPE_TIMESTAMP. 1098e5c31af7Sopenharmony_ci 1099e5c31af7Sopenharmony_cifname:vkCmdCopyQueryPoolResults is considered to be a transfer operation, 1100e5c31af7Sopenharmony_ciand its writes to buffer memory must: be synchronized using 1101e5c31af7Sopenharmony_ciename:VK_PIPELINE_STAGE_TRANSFER_BIT and ename:VK_ACCESS_TRANSFER_WRITE_BIT 1102e5c31af7Sopenharmony_cibefore using the results. 1103e5c31af7Sopenharmony_ci 1104e5c31af7Sopenharmony_ci.Valid Usage 1105e5c31af7Sopenharmony_ci**** 1106e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-dstOffset-00819]] 1107e5c31af7Sopenharmony_ci pname:dstOffset must: be less than the size of pname:dstBuffer 1108e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-firstQuery-00820]] 1109e5c31af7Sopenharmony_ci pname:firstQuery must: be less than the number of queries in 1110e5c31af7Sopenharmony_ci pname:queryPool 1111e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-firstQuery-00821]] 1112e5c31af7Sopenharmony_ci The sum of pname:firstQuery and pname:queryCount must: be less than or 1113e5c31af7Sopenharmony_ci equal to the number of queries in pname:queryPool 1114e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-flags-00822]] 1115e5c31af7Sopenharmony_ci If ename:VK_QUERY_RESULT_64_BIT is not set in pname:flags then 1116e5c31af7Sopenharmony_ci pname:dstOffset and pname:stride must: be multiples of `4` 1117e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-flags-00823]] 1118e5c31af7Sopenharmony_ci If ename:VK_QUERY_RESULT_64_BIT is set in pname:flags then 1119e5c31af7Sopenharmony_ci pname:dstOffset and pname:stride must: be multiples of `8` 1120e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-dstBuffer-00824]] 1121e5c31af7Sopenharmony_ci pname:dstBuffer must: have enough storage, from pname:dstOffset, to 1122e5c31af7Sopenharmony_ci contain the result of each query, as described 1123e5c31af7Sopenharmony_ci <<queries-operation-memorylayout,here>> 1124e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-dstBuffer-00825]] 1125e5c31af7Sopenharmony_ci pname:dstBuffer must: have been created with 1126e5c31af7Sopenharmony_ci ename:VK_BUFFER_USAGE_TRANSFER_DST_BIT usage flag 1127e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-dstBuffer-00826]] 1128e5c31af7Sopenharmony_ci If pname:dstBuffer is non-sparse then it must: be bound completely and 1129e5c31af7Sopenharmony_ci contiguously to a single sname:VkDeviceMemory object 1130e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-queryType-00827]] 1131e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 1132e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TIMESTAMP, pname:flags must: not contain 1133e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_PARTIAL_BIT 1134e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 1135e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-queryType-03232]] 1136e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 1137e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, 1138e5c31af7Sopenharmony_ci slink:VkPhysicalDevicePerformanceQueryPropertiesKHR::pname:allowCommandBufferQueryCopies 1139e5c31af7Sopenharmony_ci must: be ename:VK_TRUE 1140e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-queryType-03233]] 1141e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 1142e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, pname:flags must: not contain 1143e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_WITH_AVAILABILITY_BIT, 1144e5c31af7Sopenharmony_ci ename:VK_QUERY_RESULT_PARTIAL_BIT or ename:VK_QUERY_RESULT_64_BIT 1145e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-queryType-03234]] 1146e5c31af7Sopenharmony_ci If the pname:queryType used to create pname:queryPool was 1147e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR, the pname:queryPool must: 1148e5c31af7Sopenharmony_ci have been submitted once for each pass as retrieved via a call to 1149e5c31af7Sopenharmony_ci flink:vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR 1150e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 1151e5c31af7Sopenharmony_ciifdef::VK_INTEL_performance_query[] 1152e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-queryType-02734]] 1153e5c31af7Sopenharmony_ci flink:vkCmdCopyQueryPoolResults must: not be called if the 1154e5c31af7Sopenharmony_ci pname:queryType used to create pname:queryPool was 1155e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL 1156e5c31af7Sopenharmony_ciendif::VK_INTEL_performance_query[] 1157e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 1158e5c31af7Sopenharmony_ci * [[VUID-vkCmdCopyQueryPoolResults-queryType-04812]] 1159e5c31af7Sopenharmony_ci flink:vkCmdCopyQueryPoolResults must: not be called if the 1160e5c31af7Sopenharmony_ci pname:queryType used to create pname:queryPool was 1161e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_VIDEO_ENCODE_BITSTREAM_BUFFER_RANGE_KHR or 1162e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR 1163e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 1164e5c31af7Sopenharmony_ci**** 1165e5c31af7Sopenharmony_ci 1166e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdCopyQueryPoolResults.txt[] 1167e5c31af7Sopenharmony_ci-- 1168e5c31af7Sopenharmony_ci 1169e5c31af7Sopenharmony_ci[[queries-operation-undefined]] 1170e5c31af7Sopenharmony_ciRendering operations such as clears, MSAA resolves, attachment load/store 1171e5c31af7Sopenharmony_cioperations, and blits may: count towards the results of queries. 1172e5c31af7Sopenharmony_ciThis behavior is implementation-dependent and may: vary depending on the 1173e5c31af7Sopenharmony_cipath used within an implementation. 1174e5c31af7Sopenharmony_ciFor example, some implementations have several types of clears, some of 1175e5c31af7Sopenharmony_ciwhich may: include vertices and some not. 1176e5c31af7Sopenharmony_ci 1177e5c31af7Sopenharmony_ci 1178e5c31af7Sopenharmony_ci[[queries-occlusion]] 1179e5c31af7Sopenharmony_ci== Occlusion Queries 1180e5c31af7Sopenharmony_ci 1181e5c31af7Sopenharmony_ciOcclusion queries track the number of samples that pass the per-fragment 1182e5c31af7Sopenharmony_citests for a set of drawing commands. 1183e5c31af7Sopenharmony_ciAs such, occlusion queries are only available on queue families supporting 1184e5c31af7Sopenharmony_cigraphics operations. 1185e5c31af7Sopenharmony_ciThe application can: then use these results to inform future rendering 1186e5c31af7Sopenharmony_cidecisions. 1187e5c31af7Sopenharmony_ciAn occlusion query is begun and ended by calling fname:vkCmdBeginQuery and 1188e5c31af7Sopenharmony_cifname:vkCmdEndQuery, respectively. 1189e5c31af7Sopenharmony_ciWhen an occlusion query begins, the count of passing samples always starts 1190e5c31af7Sopenharmony_ciat zero. 1191e5c31af7Sopenharmony_ciFor each drawing command, the count is incremented as described in 1192e5c31af7Sopenharmony_ci<<fragops-samplecount,Sample Counting>>. 1193e5c31af7Sopenharmony_ciIf pname:flags does not contain ename:VK_QUERY_CONTROL_PRECISE_BIT an 1194e5c31af7Sopenharmony_ciimplementation may: generate any non-zero result value for the query if the 1195e5c31af7Sopenharmony_cicount of passing samples is non-zero. 1196e5c31af7Sopenharmony_ci 1197e5c31af7Sopenharmony_ci[NOTE] 1198e5c31af7Sopenharmony_ci.Note 1199e5c31af7Sopenharmony_ci==== 1200e5c31af7Sopenharmony_ciNot setting ename:VK_QUERY_CONTROL_PRECISE_BIT mode may: be more efficient 1201e5c31af7Sopenharmony_cion some implementations, and should: be used where it is sufficient to know 1202e5c31af7Sopenharmony_cia boolean result on whether any samples passed the per-fragment tests. 1203e5c31af7Sopenharmony_ciIn this case, some implementations may: only return zero or one, indifferent 1204e5c31af7Sopenharmony_cito the actual number of samples passing the per-fragment tests. 1205e5c31af7Sopenharmony_ci==== 1206e5c31af7Sopenharmony_ci 1207e5c31af7Sopenharmony_ciWhen an occlusion query finishes, the result for that query is marked as 1208e5c31af7Sopenharmony_ciavailable. 1209e5c31af7Sopenharmony_ciThe application can: then either copy the result to a buffer (via 1210e5c31af7Sopenharmony_cifname:vkCmdCopyQueryPoolResults) or request it be put into host memory (via 1211e5c31af7Sopenharmony_cifname:vkGetQueryPoolResults). 1212e5c31af7Sopenharmony_ci 1213e5c31af7Sopenharmony_ci[NOTE] 1214e5c31af7Sopenharmony_ci.Note 1215e5c31af7Sopenharmony_ci==== 1216e5c31af7Sopenharmony_ciIf occluding geometry is not drawn first, samples can: pass the depth test, 1217e5c31af7Sopenharmony_cibut still not be visible in a final image. 1218e5c31af7Sopenharmony_ci==== 1219e5c31af7Sopenharmony_ci 1220e5c31af7Sopenharmony_ci 1221e5c31af7Sopenharmony_ci[[queries-pipestats]] 1222e5c31af7Sopenharmony_ci== Pipeline Statistics Queries 1223e5c31af7Sopenharmony_ci 1224e5c31af7Sopenharmony_ciPipeline statistics queries allow the application to sample a specified set 1225e5c31af7Sopenharmony_ciof sname:VkPipeline counters. 1226e5c31af7Sopenharmony_ciThese counters are accumulated by Vulkan for a set of either drawing or 1227e5c31af7Sopenharmony_cidispatching commands while a pipeline statistics query is active. 1228e5c31af7Sopenharmony_ciAs such, pipeline statistics queries are available on queue families 1229e5c31af7Sopenharmony_cisupporting either graphics or compute operations. 1230e5c31af7Sopenharmony_ciThe availability of pipeline statistics queries is indicated by the 1231e5c31af7Sopenharmony_cipname:pipelineStatisticsQuery member of the sname:VkPhysicalDeviceFeatures 1232e5c31af7Sopenharmony_ciobject (see fname:vkGetPhysicalDeviceFeatures and fname:vkCreateDevice for 1233e5c31af7Sopenharmony_cidetecting and requesting this query type on a sname:VkDevice). 1234e5c31af7Sopenharmony_ci 1235e5c31af7Sopenharmony_ciA pipeline statistics query is begun and ended by calling 1236e5c31af7Sopenharmony_cifname:vkCmdBeginQuery and fname:vkCmdEndQuery, respectively. 1237e5c31af7Sopenharmony_ciWhen a pipeline statistics query begins, all statistics counters are set to 1238e5c31af7Sopenharmony_cizero. 1239e5c31af7Sopenharmony_ciWhile the query is active, the pipeline type determines which set of 1240e5c31af7Sopenharmony_cistatistics are available, but these must: be configured on the query pool 1241e5c31af7Sopenharmony_ciwhen it is created. 1242e5c31af7Sopenharmony_ciIf a statistic counter is issued on a command buffer that does not support 1243e5c31af7Sopenharmony_cithe corresponding operation, the value of that counter is undefined: after 1244e5c31af7Sopenharmony_cithe query has finished. 1245e5c31af7Sopenharmony_ciAt least one statistic counter relevant to the operations supported on the 1246e5c31af7Sopenharmony_cirecording command buffer must: be enabled. 1247e5c31af7Sopenharmony_ci 1248e5c31af7Sopenharmony_ci[open,refpage='VkQueryPipelineStatisticFlagBits',desc='Bitmask specifying queried pipeline statistics',type='enums'] 1249e5c31af7Sopenharmony_ci-- 1250e5c31af7Sopenharmony_ciBits which can: be set to individually enable pipeline statistics counters 1251e5c31af7Sopenharmony_cifor query pools with slink:VkQueryPoolCreateInfo::pname:pipelineStatistics, 1252e5c31af7Sopenharmony_ciand for secondary command buffers with 1253e5c31af7Sopenharmony_cislink:VkCommandBufferInheritanceInfo::pname:pipelineStatistics, are: 1254e5c31af7Sopenharmony_ci 1255e5c31af7Sopenharmony_ciinclude::{generated}/api/enums/VkQueryPipelineStatisticFlagBits.txt[] 1256e5c31af7Sopenharmony_ci 1257e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT specifies 1258e5c31af7Sopenharmony_ci that queries managed by the pool will count the number of vertices 1259e5c31af7Sopenharmony_ci processed by the <<drawing,input assembly>> stage. 1260e5c31af7Sopenharmony_ci Vertices corresponding to incomplete primitives may: contribute to the 1261e5c31af7Sopenharmony_ci count. 1262e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT 1263e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1264e5c31af7Sopenharmony_ci primitives processed by the <<drawing,input assembly>> stage. 1265e5c31af7Sopenharmony_ci If primitive restart is enabled, restarting the primitive topology has 1266e5c31af7Sopenharmony_ci no effect on the count. 1267e5c31af7Sopenharmony_ci Incomplete primitives may: be counted. 1268e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT 1269e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1270e5c31af7Sopenharmony_ci vertex shader invocations. 1271e5c31af7Sopenharmony_ci This counter's value is incremented each time a vertex shader is 1272e5c31af7Sopenharmony_ci <<shaders-vertex-execution,invoked>>. 1273e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT 1274e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1275e5c31af7Sopenharmony_ci geometry shader invocations. 1276e5c31af7Sopenharmony_ci This counter's value is incremented each time a geometry shader is 1277e5c31af7Sopenharmony_ci <<shaders-geometry-execution,invoked>>. 1278e5c31af7Sopenharmony_ci In the case of <<geometry-invocations,instanced geometry shaders>>, the 1279e5c31af7Sopenharmony_ci geometry shader invocations count is incremented for each separate 1280e5c31af7Sopenharmony_ci instanced invocation. 1281e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT 1282e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1283e5c31af7Sopenharmony_ci primitives generated by geometry shader invocations. 1284e5c31af7Sopenharmony_ci The counter's value is incremented each time the geometry shader emits a 1285e5c31af7Sopenharmony_ci primitive. 1286e5c31af7Sopenharmony_ci Restarting primitive topology using the SPIR-V instructions 1287e5c31af7Sopenharmony_ci code:OpEndPrimitive or code:OpEndStreamPrimitive has no effect on the 1288e5c31af7Sopenharmony_ci geometry shader output primitives count. 1289e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT specifies 1290e5c31af7Sopenharmony_ci that queries managed by the pool will count the number of primitives 1291e5c31af7Sopenharmony_ci processed by the <<vertexpostproc-clipping,Primitive Clipping>> stage of 1292e5c31af7Sopenharmony_ci the pipeline. 1293e5c31af7Sopenharmony_ci The counter's value is incremented each time a primitive reaches the 1294e5c31af7Sopenharmony_ci primitive clipping stage. 1295e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT specifies that 1296e5c31af7Sopenharmony_ci queries managed by the pool will count the number of primitives output 1297e5c31af7Sopenharmony_ci by the <<vertexpostproc-clipping,Primitive Clipping>> stage of the 1298e5c31af7Sopenharmony_ci pipeline. 1299e5c31af7Sopenharmony_ci The counter's value is incremented each time a primitive passes the 1300e5c31af7Sopenharmony_ci primitive clipping stage. 1301e5c31af7Sopenharmony_ci The actual number of primitives output by the primitive clipping stage 1302e5c31af7Sopenharmony_ci for a particular input primitive is implementation-dependent but must: 1303e5c31af7Sopenharmony_ci satisfy the following conditions: 1304e5c31af7Sopenharmony_ci ** If at least one vertex of the input primitive lies inside the clipping 1305e5c31af7Sopenharmony_ci volume, the counter is incremented by one or more. 1306e5c31af7Sopenharmony_ci ** Otherwise, the counter is incremented by zero or more. 1307e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT 1308e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1309e5c31af7Sopenharmony_ci fragment shader invocations. 1310e5c31af7Sopenharmony_ci The counter's value is incremented each time the fragment shader is 1311e5c31af7Sopenharmony_ci <<fragops-shader,invoked>>. 1312e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT 1313e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1314e5c31af7Sopenharmony_ci patches processed by the tessellation control shader. 1315e5c31af7Sopenharmony_ci The counter's value is incremented once for each patch for which a 1316e5c31af7Sopenharmony_ci tessellation control shader is 1317e5c31af7Sopenharmony_ci <<shaders-tessellation-control-execution,invoked>>. 1318e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT 1319e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1320e5c31af7Sopenharmony_ci invocations of the tessellation evaluation shader. 1321e5c31af7Sopenharmony_ci The counter's value is incremented each time the tessellation evaluation 1322e5c31af7Sopenharmony_ci shader is <<shaders-tessellation-evaluation-execution,invoked>>. 1323e5c31af7Sopenharmony_ci * ename:VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT 1324e5c31af7Sopenharmony_ci specifies that queries managed by the pool will count the number of 1325e5c31af7Sopenharmony_ci compute shader invocations. 1326e5c31af7Sopenharmony_ci The counter's value is incremented every time the compute shader is 1327e5c31af7Sopenharmony_ci invoked. 1328e5c31af7Sopenharmony_ci Implementations may: skip the execution of certain compute shader 1329e5c31af7Sopenharmony_ci invocations or execute additional compute shader invocations for 1330e5c31af7Sopenharmony_ci implementation-dependent reasons as long as the results of rendering 1331e5c31af7Sopenharmony_ci otherwise remain unchanged. 1332e5c31af7Sopenharmony_ci 1333e5c31af7Sopenharmony_ciThese values are intended to measure relative statistics on one 1334e5c31af7Sopenharmony_ciimplementation. 1335e5c31af7Sopenharmony_ciVarious device architectures will count these values differently. 1336e5c31af7Sopenharmony_ciAny or all counters may: be affected by the issues described in 1337e5c31af7Sopenharmony_ci<<queries-operation-undefined,Query Operation>>. 1338e5c31af7Sopenharmony_ci 1339e5c31af7Sopenharmony_ci[NOTE] 1340e5c31af7Sopenharmony_ci.Note 1341e5c31af7Sopenharmony_ci==== 1342e5c31af7Sopenharmony_ciFor example, tile-based rendering devices may: need to replay the scene 1343e5c31af7Sopenharmony_cimultiple times, affecting some of the counts. 1344e5c31af7Sopenharmony_ci==== 1345e5c31af7Sopenharmony_ci 1346e5c31af7Sopenharmony_ciIf a pipeline has pname:rasterizerDiscardEnable enabled, implementations 1347e5c31af7Sopenharmony_cimay: discard primitives after the final 1348e5c31af7Sopenharmony_ci<<pipeline-graphics-subsets-pre-rasterization,pre-rasterization shader 1349e5c31af7Sopenharmony_cistage>>. 1350e5c31af7Sopenharmony_ciAs a result, if pname:rasterizerDiscardEnable is enabled, the clipping input 1351e5c31af7Sopenharmony_ciand output primitives counters may: not be incremented. 1352e5c31af7Sopenharmony_ci 1353e5c31af7Sopenharmony_ciWhen a pipeline statistics query finishes, the result for that query is 1354e5c31af7Sopenharmony_cimarked as available. 1355e5c31af7Sopenharmony_ciThe application can: copy the result to a buffer (via 1356e5c31af7Sopenharmony_cifname:vkCmdCopyQueryPoolResults), or request it be put into host memory (via 1357e5c31af7Sopenharmony_cifname:vkGetQueryPoolResults). 1358e5c31af7Sopenharmony_ci-- 1359e5c31af7Sopenharmony_ci 1360e5c31af7Sopenharmony_ci[open,refpage='VkQueryPipelineStatisticFlags',desc='Bitmask of VkQueryPipelineStatisticFlagBits',type='flags'] 1361e5c31af7Sopenharmony_ci-- 1362e5c31af7Sopenharmony_ciinclude::{generated}/api/flags/VkQueryPipelineStatisticFlags.txt[] 1363e5c31af7Sopenharmony_ci 1364e5c31af7Sopenharmony_citname:VkQueryPipelineStatisticFlags is a bitmask type for setting a mask of 1365e5c31af7Sopenharmony_cizero or more elink:VkQueryPipelineStatisticFlagBits. 1366e5c31af7Sopenharmony_ci-- 1367e5c31af7Sopenharmony_ci 1368e5c31af7Sopenharmony_ci 1369e5c31af7Sopenharmony_ci[[queries-timestamps]] 1370e5c31af7Sopenharmony_ci== Timestamp Queries 1371e5c31af7Sopenharmony_ci 1372e5c31af7Sopenharmony_ci_Timestamps_ provide applications with a mechanism for timing the execution 1373e5c31af7Sopenharmony_ciof commands. 1374e5c31af7Sopenharmony_ciA timestamp is an integer value generated by the sname:VkPhysicalDevice. 1375e5c31af7Sopenharmony_ciUnlike other queries, timestamps do not operate over a range, and so do not 1376e5c31af7Sopenharmony_ciuse flink:vkCmdBeginQuery or flink:vkCmdEndQuery. 1377e5c31af7Sopenharmony_ciThe mechanism is built around a set of commands that allow the application 1378e5c31af7Sopenharmony_cito tell the sname:VkPhysicalDevice to write timestamp values to a 1379e5c31af7Sopenharmony_ci<<queries-pools,query pool>> and then either read timestamp values on the 1380e5c31af7Sopenharmony_cihost (using flink:vkGetQueryPoolResults) or copy timestamp values to a 1381e5c31af7Sopenharmony_cisname:VkBuffer (using flink:vkCmdCopyQueryPoolResults). 1382e5c31af7Sopenharmony_ciThe application can: then compute differences between timestamps to 1383e5c31af7Sopenharmony_cidetermine execution time. 1384e5c31af7Sopenharmony_ci 1385e5c31af7Sopenharmony_ciThe number of valid bits in a timestamp value is determined by the 1386e5c31af7Sopenharmony_cisname:VkQueueFamilyProperties::pname:timestampValidBits property of the 1387e5c31af7Sopenharmony_ciqueue on which the timestamp is written. 1388e5c31af7Sopenharmony_ciTimestamps are supported on any queue which reports a non-zero value for 1389e5c31af7Sopenharmony_cipname:timestampValidBits via flink:vkGetPhysicalDeviceQueueFamilyProperties. 1390e5c31af7Sopenharmony_ciIf the <<limits-timestampComputeAndGraphics, 1391e5c31af7Sopenharmony_cipname:timestampComputeAndGraphics>> limit is ename:VK_TRUE, timestamps are 1392e5c31af7Sopenharmony_cisupported by every queue family that supports either graphics or compute 1393e5c31af7Sopenharmony_cioperations (see slink:VkQueueFamilyProperties). 1394e5c31af7Sopenharmony_ci 1395e5c31af7Sopenharmony_ciThe number of nanoseconds it takes for a timestamp value to be incremented 1396e5c31af7Sopenharmony_ciby 1 can: be obtained from 1397e5c31af7Sopenharmony_cisname:VkPhysicalDeviceLimits::pname:timestampPeriod after a call to 1398e5c31af7Sopenharmony_cifname:vkGetPhysicalDeviceProperties. 1399e5c31af7Sopenharmony_ci 1400e5c31af7Sopenharmony_ciifdef::VK_KHR_synchronization2[] 1401e5c31af7Sopenharmony_ci 1402e5c31af7Sopenharmony_ci[open,refpage='vkCmdWriteTimestamp2KHR',desc='Write a device timestamp into a query object',type='protos'] 1403e5c31af7Sopenharmony_ci-- 1404e5c31af7Sopenharmony_ci:refpage: vkCmdWriteTimestamp2KHR 1405e5c31af7Sopenharmony_ci 1406e5c31af7Sopenharmony_ciTo request a timestamp, call: 1407e5c31af7Sopenharmony_ci 1408e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdWriteTimestamp2KHR.txt[] 1409e5c31af7Sopenharmony_ci 1410e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1411e5c31af7Sopenharmony_ci recorded. 1412e5c31af7Sopenharmony_ci * pname:stage specifies a stage of the pipeline. 1413e5c31af7Sopenharmony_ci * pname:queryPool is the query pool that will manage the timestamp. 1414e5c31af7Sopenharmony_ci * pname:query is the query within the query pool that will contain the 1415e5c31af7Sopenharmony_ci timestamp. 1416e5c31af7Sopenharmony_ci 1417e5c31af7Sopenharmony_ciWhen fname:vkCmdWriteTimestamp2KHR is submitted to a queue, it defines an 1418e5c31af7Sopenharmony_ciexecution dependency on commands that were submitted before it, and writes a 1419e5c31af7Sopenharmony_citimestamp to a query pool. 1420e5c31af7Sopenharmony_ci 1421e5c31af7Sopenharmony_ciThe first <<synchronization-dependencies-scopes, synchronization scope>> 1422e5c31af7Sopenharmony_ciincludes all commands that occur earlier in 1423e5c31af7Sopenharmony_ci<<synchronization-submission-order,submission order>>. 1424e5c31af7Sopenharmony_ciThe synchronization scope is limited to operations on the pipeline stage 1425e5c31af7Sopenharmony_cispecified by pname:stage. 1426e5c31af7Sopenharmony_ci 1427e5c31af7Sopenharmony_ciThe second <<synchronization-dependencies-scopes, synchronization scope>> 1428e5c31af7Sopenharmony_ciincludes only the timestamp write operation. 1429e5c31af7Sopenharmony_ci 1430e5c31af7Sopenharmony_ciWhen the timestamp value is written, the availability status of the query is 1431e5c31af7Sopenharmony_ciset to available. 1432e5c31af7Sopenharmony_ci 1433e5c31af7Sopenharmony_ci[NOTE] 1434e5c31af7Sopenharmony_ci.Note 1435e5c31af7Sopenharmony_ci==== 1436e5c31af7Sopenharmony_ciIf an implementation is unable to detect completion and latch the timer at 1437e5c31af7Sopenharmony_ciany specific stage of the pipeline, it may: instead do so at any logically 1438e5c31af7Sopenharmony_cilater stage. 1439e5c31af7Sopenharmony_ci==== 1440e5c31af7Sopenharmony_ci 1441e5c31af7Sopenharmony_ciComparisons between timestamps are not meaningful if the timestamps are 1442e5c31af7Sopenharmony_ciwritten by commands submitted to different queues. 1443e5c31af7Sopenharmony_ci 1444e5c31af7Sopenharmony_ci[NOTE] 1445e5c31af7Sopenharmony_ci.Note 1446e5c31af7Sopenharmony_ci==== 1447e5c31af7Sopenharmony_ciAn example of such a comparison is subtracting an older timestamp from a 1448e5c31af7Sopenharmony_cinewer one to determine the execution time of a sequence of commands. 1449e5c31af7Sopenharmony_ci==== 1450e5c31af7Sopenharmony_ci 1451e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 1452e5c31af7Sopenharmony_ci 1453e5c31af7Sopenharmony_ciIf fname:vkCmdWriteTimestamp2KHR is called while executing a render pass 1454e5c31af7Sopenharmony_ciinstance that has multiview enabled, the timestamp uses [eq]#N# consecutive 1455e5c31af7Sopenharmony_ciquery indices in the query pool (starting at pname:query) where [eq]#N# is 1456e5c31af7Sopenharmony_cithe number of bits set in the view mask of the subpass the command is 1457e5c31af7Sopenharmony_ciexecuted in. 1458e5c31af7Sopenharmony_ciThe resulting query values are determined by an implementation-dependent 1459e5c31af7Sopenharmony_cichoice of one of the following behaviors: 1460e5c31af7Sopenharmony_ci 1461e5c31af7Sopenharmony_ci * The first query is a timestamp value and (if more than one bit is set in 1462e5c31af7Sopenharmony_ci the view mask) zero is written to the remaining queries. 1463e5c31af7Sopenharmony_ci If two timestamps are written in the same subpass, the sum of the 1464e5c31af7Sopenharmony_ci execution time of all views between those commands is the difference 1465e5c31af7Sopenharmony_ci between the first query written by each command. 1466e5c31af7Sopenharmony_ci * All [eq]#N# queries are timestamp values. 1467e5c31af7Sopenharmony_ci If two timestamps are written in the same subpass, the sum of the 1468e5c31af7Sopenharmony_ci execution time of all views between those commands is the sum of the 1469e5c31af7Sopenharmony_ci difference between corresponding queries written by each command. 1470e5c31af7Sopenharmony_ci The difference between corresponding queries may: be the execution time 1471e5c31af7Sopenharmony_ci of a single view. 1472e5c31af7Sopenharmony_ci 1473e5c31af7Sopenharmony_ciIn either case, the application can: sum the differences between all [eq]#N# 1474e5c31af7Sopenharmony_ciqueries to determine the total execution time. 1475e5c31af7Sopenharmony_ci 1476e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 1477e5c31af7Sopenharmony_ci 1478e5c31af7Sopenharmony_ci.Valid Usage 1479e5c31af7Sopenharmony_ci**** 1480e5c31af7Sopenharmony_ci:stageMaskName: stage 1481e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/stage_mask_2_common.txt[] 1482e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-synchronization2-03858]] 1483e5c31af7Sopenharmony_ci The <<features-synchronization2, pname:synchronization2>> feature must: 1484e5c31af7Sopenharmony_ci be enabled 1485e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-stage-03859]] 1486e5c31af7Sopenharmony_ci pname:stage must: only include a single pipeline stage 1487e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-stage-03860]] 1488e5c31af7Sopenharmony_ci pname:stage must: only include stages valid for the queue family that 1489e5c31af7Sopenharmony_ci was used to create the command pool that pname:commandBuffer was 1490e5c31af7Sopenharmony_ci allocated from 1491e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-queryPool-03861]] 1492e5c31af7Sopenharmony_ci pname:queryPool must: have been created with a pname:queryType of 1493e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TIMESTAMP 1494e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-queryPool-03862]] 1495e5c31af7Sopenharmony_ci The query identified by pname:queryPool and pname:query must: be 1496e5c31af7Sopenharmony_ci _unavailable_ 1497e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-timestampValidBits-03863]] 1498e5c31af7Sopenharmony_ci The command pool's queue family must: support a non-zero 1499e5c31af7Sopenharmony_ci pname:timestampValidBits 1500e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-query-04903]] 1501e5c31af7Sopenharmony_ci pname:query must: be less than the number of queries in pname:queryPool 1502e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 1503e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-None-03864]] 1504e5c31af7Sopenharmony_ci All queries used by the command must: be unavailable 1505e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp2KHR-query-03865]] 1506e5c31af7Sopenharmony_ci If fname:vkCmdWriteTimestamp2KHR is called within a render pass 1507e5c31af7Sopenharmony_ci instance, the sum of pname:query and the number of bits set in the 1508e5c31af7Sopenharmony_ci current subpass's view mask must: be less than or equal to the number of 1509e5c31af7Sopenharmony_ci queries in pname:queryPool 1510e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 1511e5c31af7Sopenharmony_ci**** 1512e5c31af7Sopenharmony_ci 1513e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdWriteTimestamp2KHR.txt[] 1514e5c31af7Sopenharmony_ci-- 1515e5c31af7Sopenharmony_ciendif::VK_KHR_synchronization2[] 1516e5c31af7Sopenharmony_ci 1517e5c31af7Sopenharmony_ci[open,refpage='vkCmdWriteTimestamp',desc='Write a device timestamp into a query object',type='protos'] 1518e5c31af7Sopenharmony_ci-- 1519e5c31af7Sopenharmony_ci:refpage: vkCmdWriteTimestamp 1520e5c31af7Sopenharmony_ci 1521e5c31af7Sopenharmony_ciTo request a timestamp, call: 1522e5c31af7Sopenharmony_ci 1523e5c31af7Sopenharmony_ciinclude::{generated}/api/protos/vkCmdWriteTimestamp.txt[] 1524e5c31af7Sopenharmony_ci 1525e5c31af7Sopenharmony_ci * pname:commandBuffer is the command buffer into which the command will be 1526e5c31af7Sopenharmony_ci recorded. 1527e5c31af7Sopenharmony_ci * pname:pipelineStage is a elink:VkPipelineStageFlagBits value, specifying 1528e5c31af7Sopenharmony_ci a stage of the pipeline. 1529e5c31af7Sopenharmony_ci * pname:queryPool is the query pool that will manage the timestamp. 1530e5c31af7Sopenharmony_ci * pname:query is the query within the query pool that will contain the 1531e5c31af7Sopenharmony_ci timestamp. 1532e5c31af7Sopenharmony_ci 1533e5c31af7Sopenharmony_cifname:vkCmdWriteTimestamp latches the value of the timer when all previous 1534e5c31af7Sopenharmony_cicommands have completed executing as far as the specified pipeline stage, 1535e5c31af7Sopenharmony_ciand writes the timestamp value to memory. 1536e5c31af7Sopenharmony_ciWhen the timestamp value is written, the availability status of the query is 1537e5c31af7Sopenharmony_ciset to available. 1538e5c31af7Sopenharmony_ci 1539e5c31af7Sopenharmony_ci[NOTE] 1540e5c31af7Sopenharmony_ci.Note 1541e5c31af7Sopenharmony_ci==== 1542e5c31af7Sopenharmony_ciIf an implementation is unable to detect completion and latch the timer at 1543e5c31af7Sopenharmony_ciany specific stage of the pipeline, it may: instead do so at any logically 1544e5c31af7Sopenharmony_cilater stage. 1545e5c31af7Sopenharmony_ci==== 1546e5c31af7Sopenharmony_ci 1547e5c31af7Sopenharmony_ciComparisons between timestamps are not meaningful if the timestamps are 1548e5c31af7Sopenharmony_ciwritten by commands submitted to different queues. 1549e5c31af7Sopenharmony_ci 1550e5c31af7Sopenharmony_ci[NOTE] 1551e5c31af7Sopenharmony_ci.Note 1552e5c31af7Sopenharmony_ci==== 1553e5c31af7Sopenharmony_ciAn example of such a comparison is subtracting an older timestamp from a 1554e5c31af7Sopenharmony_cinewer one to determine the execution time of a sequence of commands. 1555e5c31af7Sopenharmony_ci==== 1556e5c31af7Sopenharmony_ci 1557e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 1558e5c31af7Sopenharmony_ci 1559e5c31af7Sopenharmony_ciIf fname:vkCmdWriteTimestamp is called while executing a render pass 1560e5c31af7Sopenharmony_ciinstance that has multiview enabled, the timestamp uses [eq]#N# consecutive 1561e5c31af7Sopenharmony_ciquery indices in the query pool (starting at pname:query) where [eq]#N# is 1562e5c31af7Sopenharmony_cithe number of bits set in the view mask of the subpass the command is 1563e5c31af7Sopenharmony_ciexecuted in. 1564e5c31af7Sopenharmony_ciThe resulting query values are determined by an implementation-dependent 1565e5c31af7Sopenharmony_cichoice of one of the following behaviors: 1566e5c31af7Sopenharmony_ci 1567e5c31af7Sopenharmony_ci * The first query is a timestamp value and (if more than one bit is set in 1568e5c31af7Sopenharmony_ci the view mask) zero is written to the remaining queries. 1569e5c31af7Sopenharmony_ci If two timestamps are written in the same subpass, the sum of the 1570e5c31af7Sopenharmony_ci execution time of all views between those commands is the difference 1571e5c31af7Sopenharmony_ci between the first query written by each command. 1572e5c31af7Sopenharmony_ci * All [eq]#N# queries are timestamp values. 1573e5c31af7Sopenharmony_ci If two timestamps are written in the same subpass, the sum of the 1574e5c31af7Sopenharmony_ci execution time of all views between those commands is the sum of the 1575e5c31af7Sopenharmony_ci difference between corresponding queries written by each command. 1576e5c31af7Sopenharmony_ci The difference between corresponding queries may: be the execution time 1577e5c31af7Sopenharmony_ci of a single view. 1578e5c31af7Sopenharmony_ci 1579e5c31af7Sopenharmony_ciIn either case, the application can: sum the differences between all [eq]#N# 1580e5c31af7Sopenharmony_ciqueries to determine the total execution time. 1581e5c31af7Sopenharmony_ci 1582e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 1583e5c31af7Sopenharmony_ci 1584e5c31af7Sopenharmony_ci.Valid Usage 1585e5c31af7Sopenharmony_ci**** 1586e5c31af7Sopenharmony_ciinclude::{chapters}/commonvalidity/pipeline_stage_common.txt[] 1587e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp-queryPool-01416]] 1588e5c31af7Sopenharmony_ci pname:queryPool must: have been created with a pname:queryType of 1589e5c31af7Sopenharmony_ci ename:VK_QUERY_TYPE_TIMESTAMP 1590e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp-queryPool-00828]] 1591e5c31af7Sopenharmony_ci The query identified by pname:queryPool and pname:query must: be 1592e5c31af7Sopenharmony_ci _unavailable_ 1593e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp-timestampValidBits-00829]] 1594e5c31af7Sopenharmony_ci The command pool's queue family must: support a non-zero 1595e5c31af7Sopenharmony_ci pname:timestampValidBits 1596e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp-query-04904]] 1597e5c31af7Sopenharmony_ci pname:query must: be less than the number of queries in pname:queryPool 1598e5c31af7Sopenharmony_ciifdef::VK_VERSION_1_1,VK_KHR_multiview[] 1599e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp-None-00830]] 1600e5c31af7Sopenharmony_ci All queries used by the command must: be unavailable 1601e5c31af7Sopenharmony_ci * [[VUID-vkCmdWriteTimestamp-query-00831]] 1602e5c31af7Sopenharmony_ci If fname:vkCmdWriteTimestamp is called within a render pass instance, 1603e5c31af7Sopenharmony_ci the sum of pname:query and the number of bits set in the current 1604e5c31af7Sopenharmony_ci subpass's view mask must: be less than or equal to the number of queries 1605e5c31af7Sopenharmony_ci in pname:queryPool 1606e5c31af7Sopenharmony_ciendif::VK_VERSION_1_1,VK_KHR_multiview[] 1607e5c31af7Sopenharmony_ci**** 1608e5c31af7Sopenharmony_ci 1609e5c31af7Sopenharmony_ciinclude::{generated}/validity/protos/vkCmdWriteTimestamp.txt[] 1610e5c31af7Sopenharmony_ci-- 1611e5c31af7Sopenharmony_ci 1612e5c31af7Sopenharmony_ciifdef::VK_KHR_performance_query[] 1613e5c31af7Sopenharmony_ciinclude::{chapters}/VK_KHR_performance_query/queriesperformance.txt[] 1614e5c31af7Sopenharmony_ciendif::VK_KHR_performance_query[] 1615e5c31af7Sopenharmony_ci 1616e5c31af7Sopenharmony_ci 1617e5c31af7Sopenharmony_ciifdef::VK_EXT_transform_feedback[] 1618e5c31af7Sopenharmony_ci[[queries-transform-feedback]] 1619e5c31af7Sopenharmony_ci== Transform Feedback Queries 1620e5c31af7Sopenharmony_ci 1621e5c31af7Sopenharmony_ciTransform feedback queries track the number of primitives attempted to be 1622e5c31af7Sopenharmony_ciwritten and actually written, by the vertex stream being captured, to a 1623e5c31af7Sopenharmony_citransform feedback buffer. 1624e5c31af7Sopenharmony_ciThis query is updated during drawing commands while transform feedback is 1625e5c31af7Sopenharmony_ciactive. 1626e5c31af7Sopenharmony_ciThe number of primitives actually written will be less than the number 1627e5c31af7Sopenharmony_ciattempted to be written if the bound transform feedback buffer size was too 1628e5c31af7Sopenharmony_cismall for the number of primitives actually drawn. 1629e5c31af7Sopenharmony_ciPrimitives are not written beyond the bound range of the transform feedback 1630e5c31af7Sopenharmony_cibuffer. 1631e5c31af7Sopenharmony_ciA transform feedback query is begun and ended by calling 1632e5c31af7Sopenharmony_cifname:vkCmdBeginQuery and fname:vkCmdEndQuery, respectively to query for 1633e5c31af7Sopenharmony_civertex stream zero. 1634e5c31af7Sopenharmony_cifname:vkCmdBeginQueryIndexedEXT and fname:vkCmdEndQueryIndexedEXT can: be 1635e5c31af7Sopenharmony_ciused to begin and end transform feedback queries for any supported vertex 1636e5c31af7Sopenharmony_cistream. 1637e5c31af7Sopenharmony_ciWhen a transform feedback query begins, the count of primitives written and 1638e5c31af7Sopenharmony_ciprimitives needed starts from zero. 1639e5c31af7Sopenharmony_ciFor each drawing command, the count is incremented as vertex attribute 1640e5c31af7Sopenharmony_cioutputs are captured to the transform feedback buffers while transform 1641e5c31af7Sopenharmony_cifeedback is active. 1642e5c31af7Sopenharmony_ci 1643e5c31af7Sopenharmony_ciWhen a transform feedback query finishes, the result for that query is 1644e5c31af7Sopenharmony_cimarked as available. 1645e5c31af7Sopenharmony_ciThe application can: then either copy the result to a buffer (via 1646e5c31af7Sopenharmony_cifname:vkCmdCopyQueryPoolResults) or request it be put into host memory (via 1647e5c31af7Sopenharmony_cifname:vkGetQueryPoolResults). 1648e5c31af7Sopenharmony_ci 1649e5c31af7Sopenharmony_ciendif::VK_EXT_transform_feedback[] 1650e5c31af7Sopenharmony_ci 1651e5c31af7Sopenharmony_ciifdef::VK_INTEL_performance_query[] 1652e5c31af7Sopenharmony_ciinclude::{chapters}/VK_INTEL_performance_query/queries.txt[] 1653e5c31af7Sopenharmony_ciendif::VK_INTEL_performance_query[] 1654e5c31af7Sopenharmony_ci 1655e5c31af7Sopenharmony_ci 1656e5c31af7Sopenharmony_ciifdef::VK_KHR_video_queue[] 1657e5c31af7Sopenharmony_ci[[queries-result-status-only]] 1658e5c31af7Sopenharmony_ci== Result Status Queries 1659e5c31af7Sopenharmony_ci 1660e5c31af7Sopenharmony_ciResult status queries are used for a single purpose - to check whether a set 1661e5c31af7Sopenharmony_ciof operations has completed successfully or not, using the 1662e5c31af7Sopenharmony_ciename:VK_QUERY_RESULT_WITH_STATUS_BIT_KHR flag. 1663e5c31af7Sopenharmony_ci 1664e5c31af7Sopenharmony_ciNo other data is written to such a query. 1665e5c31af7Sopenharmony_ciendif::VK_KHR_video_queue[] 1666e5c31af7Sopenharmony_ci 1667e5c31af7Sopenharmony_ci 1668e5c31af7Sopenharmony_ciifdef::VK_KHR_video_encode_queue[] 1669e5c31af7Sopenharmony_ci[[queries-video-encode-bitstream-buffer-range]] 1670e5c31af7Sopenharmony_ci== Video Encode Bitstream Buffer Range 1671e5c31af7Sopenharmony_ci 1672e5c31af7Sopenharmony_ciBitstream buffer range queries describe the range of bytes written in the 1673e5c31af7Sopenharmony_cibitstream buffer by video encode commands. 1674e5c31af7Sopenharmony_ci 1675e5c31af7Sopenharmony_ciWhen an encode command is recorded within a bitstream buffer range query, 1676e5c31af7Sopenharmony_citwo values are written to the query slot. 1677e5c31af7Sopenharmony_ciThe first value is an offset into the bitstream buffer where the encoded 1678e5c31af7Sopenharmony_civideo data was written. 1679e5c31af7Sopenharmony_ciThis offset is an additional offset from the start of the range specified by 1680e5c31af7Sopenharmony_cithe application. 1681e5c31af7Sopenharmony_ciThe second value is a size value describing the number of bytes written to 1682e5c31af7Sopenharmony_cithe bitstream buffer beyond the offset. 1683e5c31af7Sopenharmony_ci 1684e5c31af7Sopenharmony_ciOne slot is consumed for each slice in each command recorded between a begin 1685e5c31af7Sopenharmony_ciand end query pair. 1686e5c31af7Sopenharmony_ciendif::VK_KHR_video_encode_queue[] 1687