• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.txt[]
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.txt[]
30
31=== Example Code
32
33[source,c]
34---------------------------------------------------
35
36// A previously created device
37VkDevice device;
38
39// A queue derived from the device
40VkQueue queue;
41
42VkInitializePerformanceApiInfoINTEL performanceApiInfoIntel = {
43  VK_STRUCTURE_TYPE_INITIALIZE_PERFORMANCE_API_INFO_INTEL,
44  NULL,
45  NULL
46};
47
48vkInitializePerformanceApiINTEL(
49  device,
50  &performanceApiInfoIntel);
51
52VkQueryPoolPerformanceQueryCreateInfoINTEL queryPoolIntel = {
53  VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO_INTEL,
54  NULL,
55  VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL,
56};
57
58VkQueryPoolCreateInfo queryPoolCreateInfo = {
59  VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO,
60  &queryPoolIntel,
61  0,
62  VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL,
63  1,
64  0
65};
66
67VkQueryPool queryPool;
68
69VkResult result = vkCreateQueryPool(
70  device,
71  &queryPoolCreateInfo,
72  NULL,
73  &queryPool);
74
75assert(VK_SUCCESS == result);
76
77// A command buffer we want to record counters on
78VkCommandBuffer commandBuffer;
79
80VkCommandBufferBeginInfo commandBufferBeginInfo = {
81  VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
82  NULL,
83  VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
84  NULL
85};
86
87result = vkBeginCommandBuffer(commandBuffer, &commandBufferBeginInfo);
88
89assert(VK_SUCCESS == result);
90
91vkCmdResetQueryPool(
92  commandBuffer,
93  queryPool,
94  0,
95  1);
96
97vkCmdBeginQuery(
98  commandBuffer,
99  queryPool,
100  0,
101  0);
102
103// Perform the commands you want to get performance information on
104// ...
105
106// Perform a barrier to ensure all previous commands were complete before
107// ending the query
108vkCmdPipelineBarrier(commandBuffer,
109  VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
110  VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
111  0,
112  0,
113  NULL,
114  0,
115  NULL,
116  0,
117  NULL);
118
119vkCmdEndQuery(
120  commandBuffer,
121  queryPool,
122  0);
123
124result = vkEndCommandBuffer(commandBuffer);
125
126assert(VK_SUCCESS == result);
127
128VkPerformanceConfigurationAcquireInfoINTEL performanceConfigurationAcquireInfo = {
129  VK_STRUCTURE_TYPE_PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL,
130  NULL,
131  VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL
132};
133
134VkPerformanceConfigurationINTEL performanceConfigurationIntel;
135
136result = vkAcquirePerformanceConfigurationINTEL(
137  device,
138  &performanceConfigurationAcquireInfo,
139  &performanceConfigurationIntel);
140
141vkQueueSetPerformanceConfigurationINTEL(queue, performanceConfigurationIntel);
142
143assert(VK_SUCCESS == result);
144
145// Submit the command buffer and wait for its completion
146// ...
147
148result = vkReleasePerformanceConfigurationINTEL(
149  device,
150  performanceConfigurationIntel);
151
152assert(VK_SUCCESS == result);
153
154// Get the report size from metrics-discovery's QueryReportSize
155
156result = vkGetQueryPoolResults(
157  device,
158  queryPool,
159  0, 1, QueryReportSize,
160  data, QueryReportSize, 0);
161
162assert(VK_SUCCESS == result);
163
164// The data can then be passed back to metrics-discovery from which
165// human readable values can be queried.
166
167---------------------------------------------------
168
169=== Version History
170
171 * Revision 2, 2020-03-06 (Lionel Landwerlin)
172   - Rename VkQueryPoolCreateInfoINTEL in
173     VkQueryPoolPerformanceQueryCreateInfoINTEL
174
175 * Revision 1, 2018-05-16 (Lionel Landwerlin)
176   - Initial revision
177