1// Copyright (c) 2018-2020 Intel Corporation 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5include::{generated}/meta/{refprefix}VK_INTEL_performance_query.adoc[] 6 7=== Other Extension Metadata 8 9*Last Modified Date*:: 10 2018-05-16 11*IP Status*:: 12 No known IP claims. 13*Contributors*:: 14 - Lionel Landwerlin, Intel 15 - Piotr Maciejewski, Intel 16 17=== Description 18 19This extension allows an application to capture performance data to be 20interpreted by a external application or library. 21 22Such a library is available at : https://github.com/intel/metrics-discovery 23 24Performance analysis tools such as 25link:++https://software.intel.com/content/www/us/en/develop/tools/graphics-performance-analyzers.html++[Graphics 26Performance Analyzers] make use of this extension and the metrics-discovery 27library to present the data in a human readable way. 28 29include::{generated}/interfaces/VK_INTEL_performance_query.adoc[] 30 31=== Example Code 32 33[source,c] 34---- 35// A previously created device 36VkDevice device; 37 38// A queue derived from the device 39VkQueue queue; 40 41VkInitializePerformanceApiInfoINTEL performanceApiInfoIntel = { 42 VK_STRUCTURE_TYPE_INITIALIZE_PERFORMANCE_API_INFO_INTEL, 43 NULL, 44 NULL 45}; 46 47vkInitializePerformanceApiINTEL( 48 device, 49 &performanceApiInfoIntel); 50 51VkQueryPoolPerformanceQueryCreateInfoINTEL queryPoolIntel = { 52 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO_INTEL, 53 NULL, 54 VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL, 55}; 56 57VkQueryPoolCreateInfo queryPoolCreateInfo = { 58 VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO, 59 &queryPoolIntel, 60 0, 61 VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL, 62 1, 63 0 64}; 65 66VkQueryPool queryPool; 67 68VkResult result = vkCreateQueryPool( 69 device, 70 &queryPoolCreateInfo, 71 NULL, 72 &queryPool); 73 74assert(VK_SUCCESS == result); 75 76// A command buffer we want to record counters on 77VkCommandBuffer commandBuffer; 78 79VkCommandBufferBeginInfo commandBufferBeginInfo = { 80 VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, 81 NULL, 82 VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT, 83 NULL 84}; 85 86result = vkBeginCommandBuffer(commandBuffer, &commandBufferBeginInfo); 87 88assert(VK_SUCCESS == result); 89 90vkCmdResetQueryPool( 91 commandBuffer, 92 queryPool, 93 0, 94 1); 95 96vkCmdBeginQuery( 97 commandBuffer, 98 queryPool, 99 0, 100 0); 101 102// Perform the commands you want to get performance information on 103// ... 104 105// Perform a barrier to ensure all previous commands were complete before 106// ending the query 107vkCmdPipelineBarrier(commandBuffer, 108 VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 109 VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 110 0, 111 0, 112 NULL, 113 0, 114 NULL, 115 0, 116 NULL); 117 118vkCmdEndQuery( 119 commandBuffer, 120 queryPool, 121 0); 122 123result = vkEndCommandBuffer(commandBuffer); 124 125assert(VK_SUCCESS == result); 126 127VkPerformanceConfigurationAcquireInfoINTEL performanceConfigurationAcquireInfo = { 128 VK_STRUCTURE_TYPE_PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL, 129 NULL, 130 VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL 131}; 132 133VkPerformanceConfigurationINTEL performanceConfigurationIntel; 134 135result = vkAcquirePerformanceConfigurationINTEL( 136 device, 137 &performanceConfigurationAcquireInfo, 138 &performanceConfigurationIntel); 139 140vkQueueSetPerformanceConfigurationINTEL(queue, performanceConfigurationIntel); 141 142assert(VK_SUCCESS == result); 143 144// Submit the command buffer and wait for its completion 145// ... 146 147result = vkReleasePerformanceConfigurationINTEL( 148 device, 149 performanceConfigurationIntel); 150 151assert(VK_SUCCESS == result); 152 153// Get the report size from metrics-discovery's QueryReportSize 154 155result = vkGetQueryPoolResults( 156 device, 157 queryPool, 158 0, 1, QueryReportSize, 159 data, QueryReportSize, 0); 160 161assert(VK_SUCCESS == result); 162 163// The data can then be passed back to metrics-discovery from which 164// human readable values can be queried. 165---- 166 167=== Version History 168 169 * Revision 2, 2020-03-06 (Lionel Landwerlin) 170 ** Rename VkQueryPoolCreateInfoINTEL in 171 VkQueryPoolPerformanceQueryCreateInfoINTEL 172 173 * Revision 1, 2018-05-16 (Lionel Landwerlin) 174 ** Initial revision 175