1 //////////////////////////////////////////////////////////////////////////////
2 //
3 //     Copyright © 2019-2020, Intel Corporation
4 //
5 //     Permission is hereby granted, free of charge, to any person obtaining a
6 //     copy of this software and associated documentation files (the "Software"),
7 //     to deal in the Software without restriction, including without limitation
8 //     the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 //     and/or sell copies of the Software, and to permit persons to whom the
10 //     Software is furnished to do so, subject to the following conditions:
11 //
12 //     The above copyright notice and this permission notice shall be included
13 //     in all copies or substantial portions of the Software.
14 //
15 //     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 //     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 //     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 //     THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 //     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 //     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 //     IN THE SOFTWARE.
22 //
23 //     File Name:  metrics_discovery_api.h
24 //
25 //     Abstract:   Interface for metrics discovery DLL
26 //
27 //     Notes:
28 //
29 //////////////////////////////////////////////////////////////////////////////
30 #pragma once
31 
32 #include <stdint.h>
33 
34 #ifdef _MSC_VER
35     #define MD_STDCALL __stdcall
36 #else
37     #define MD_STDCALL
38 #endif // _MSC_VER
39 
40 //////////////////////////////////////////////////////////////////////////////////
41 // Helper macro to check required API version.
42 // Combines major and minor into one, comparable 64bit value.
43 //////////////////////////////////////////////////////////////////////////////////
44 #define MD_API_VERSION_COMBINE_MAJOR_MINOR( version ) \
45     ( ( uint64_t )( version ).MajorNumber << 32 | ( uint64_t )( version ).MinorNumber )
46 
47 //////////////////////////////////////////////////////////////////////////////////
48 // Macro to check required API version.
49 // Uses TApiVersion_1_0 struct.
50 //////////////////////////////////////////////////////////////////////////////////
51 #define MD_API_VERSION_AT_LEAST( requiredVersion, currentVersion ) \
52     ( MD_API_VERSION_COMBINE_MAJOR_MINOR( ( currentVersion ) ) > MD_API_VERSION_COMBINE_MAJOR_MINOR( ( requiredVersion ) ) || MD_API_VERSION_COMBINE_MAJOR_MINOR( ( currentVersion ) ) == MD_API_VERSION_COMBINE_MAJOR_MINOR( ( requiredVersion ) ) && ( currentVersion ).BuildNumber >= ( requiredVersion ).BuildNumber )
53 
54 //////////////////////////////////////////////////////////////////////////////////
55 // API build number:
56 //////////////////////////////////////////////////////////////////////////////////
57 #define MD_API_BUILD_NUMBER_CURRENT 139
58 
59 namespace MetricsDiscovery
60 {
61     //////////////////////////////////////////////////////////////////////////////////
62     // API major version number:
63     //////////////////////////////////////////////////////////////////////////////////
64     typedef enum EMD_API_MAJOR_VERSION
65     {
66         MD_API_MAJOR_NUMBER_1       = 1,
67         MD_API_MAJOR_NUMBER_CURRENT = MD_API_MAJOR_NUMBER_1,
68         MD_API_MAJOR_NUMBER_CEIL    = 0xFFFFFFFF
69     } MD_API_MAJOR_VERSION;
70 
71     //////////////////////////////////////////////////////////////////////////////////
72     // API minor version number:
73     //////////////////////////////////////////////////////////////////////////////////
74     typedef enum EMD_API_MINOR_VERSION
75     {
76         MD_API_MINOR_NUMBER_0       = 0,
77         MD_API_MINOR_NUMBER_1       = 1,  // CalculationAPI
78         MD_API_MINOR_NUMBER_2       = 2,  // OverridesAPI
79         MD_API_MINOR_NUMBER_3       = 3,  // BatchBuffer Sampling (aka DMA Sampling)
80         MD_API_MINOR_NUMBER_4       = 4,  // GT dependent MetricSets
81         MD_API_MINOR_NUMBER_5       = 5,  // MaxValue calculation for CalculationAPI
82         MD_API_MINOR_NUMBER_6       = 6,  // Multi adapter support
83         MD_API_MINOR_NUMBER_7       = 7,  // Compile time equations calculation approach
84         MD_API_MINOR_NUMBER_8       = 8,  // TAdapterParams update
85         MD_API_MINOR_NUMBER_9       = 9,  // Sub device support.
86         MD_API_MINOR_NUMBER_10      = 10, // GetGpuCpuTimestamps API function extended by a correlation indicator param
87         MD_API_MINOR_NUMBER_CURRENT = MD_API_MINOR_NUMBER_10,
88         MD_API_MINOR_NUMBER_CEIL    = 0xFFFFFFFF
89     } MD_API_MINOR_VERSION;
90 
91     //////////////////////////////////////////////////////////////////////////////////
92     // Completion codes:
93     //////////////////////////////////////////////////////////////////////////////////
94     typedef enum ECompletionCode
95     {
96         CC_OK                      = 0,
97         CC_READ_PENDING            = 1,
98         CC_ALREADY_INITIALIZED     = 2,
99         CC_STILL_INITIALIZED       = 3,
100         CC_CONCURRENT_GROUP_LOCKED = 4,
101         CC_WAIT_TIMEOUT            = 5,
102         CC_TRY_AGAIN               = 6,
103         CC_INTERRUPTED             = 7,
104         CC_ERROR_INVALID_PARAMETER = 40,
105         CC_ERROR_NO_MEMORY         = 41,
106         CC_ERROR_GENERAL           = 42,
107         CC_ERROR_FILE_NOT_FOUND    = 43,
108         CC_ERROR_NOT_SUPPORTED     = 44,
109         CC_LAST_1_0                = 45
110     } TCompletionCode;
111 
112     /* Forward declarations */
113 
114     //////////////////////////////////////////////////////////////////////////////////
115     // Abstract interface for the GPU metrics root object.
116     //////////////////////////////////////////////////////////////////////////////////
117     class IMetricsDevice_1_0;
118     class IMetricsDevice_1_1;
119     class IMetricsDevice_1_2;
120     class IMetricsDevice_1_5;
121 
122     //////////////////////////////////////////////////////////////////////////////////
123     // Abstract interface for Metrics Device overrides.
124     //////////////////////////////////////////////////////////////////////////////////
125     class IOverride_1_2;
126 
127     //////////////////////////////////////////////////////////////////////////////////
128     // Abstract interface for the metrics groups that can be collected concurrently
129     // to another group.
130     //////////////////////////////////////////////////////////////////////////////////
131     class IConcurrentGroup_1_0;
132     class IConcurrentGroup_1_1;
133     class IConcurrentGroup_1_5;
134 
135     //////////////////////////////////////////////////////////////////////////////////
136     // Abstract interface for the metric sets mapping to different HW configuration
137     // that should be used exclusively to each other metric set in the concurrent
138     // group.
139     //////////////////////////////////////////////////////////////////////////////////
140     class IMetricSet_1_0;
141     class IMetricSet_1_1;
142     class IMetricSet_1_4;
143     class IMetricSet_1_5;
144 
145     //////////////////////////////////////////////////////////////////////////////////
146     // Abstract interface for the metric that is sampled.
147     //////////////////////////////////////////////////////////////////////////////////
148     class IMetric_1_0;
149 
150     //////////////////////////////////////////////////////////////////////////////////
151     // Abstract interface for the measurement information (report reason, etc.).
152     //////////////////////////////////////////////////////////////////////////////////
153     class IInformation_1_0;
154 
155     //////////////////////////////////////////////////////////////////////////////////
156     // Abstract interface for the metric read and normalization equation.
157     //////////////////////////////////////////////////////////////////////////////////
158     class IEquation_1_0;
159 
160     //////////////////////////////////////////////////////////////////////////////////
161     // Value types:
162     //////////////////////////////////////////////////////////////////////////////////
163     typedef enum EValueType
164     {
165         VALUE_TYPE_UINT32,
166         VALUE_TYPE_UINT64,
167         VALUE_TYPE_FLOAT,
168         VALUE_TYPE_BOOL,
169         VALUE_TYPE_CSTRING,
170         // ...
171         VALUE_TYPE_LAST,
172     } TValueType;
173 
174     //////////////////////////////////////////////////////////////////////////////////
175     // Byte Array:
176     //////////////////////////////////////////////////////////////////////////////////
177     typedef struct SByteArray_1_0
178     {
179         uint32_t Size;
180         uint8_t* Data;
181     } TByteArray_1_0;
182 
183     //////////////////////////////////////////////////////////////////////////////////
184     // Typed value:
185     //////////////////////////////////////////////////////////////////////////////////
186     typedef struct STypedValue_1_0
187     {
188         TValueType ValueType;
189         union
190         {
191             uint32_t ValueUInt32;
192             uint64_t ValueUInt64;
193             struct
194             {
195                 uint32_t Low;
196                 uint32_t High;
197             } ValueUInt64Fields;
198             float ValueFloat;
199             bool  ValueBool;
200             char* ValueCString;
201         };
202     } TTypedValue_1_0;
203 
204     //////////////////////////////////////////////////////////////////////////////////
205     // Global symbol:
206     //     Global symbols will be available to describe SKU specific information.
207     //     Example global symbols:
208     //     "EuCoresTotalCount", "EuThreadsCount", "EuSlicesTotalCount", "EuSubslicesTotalCount",
209     //     "SamplersTotalCount", "PciDeviceId", "NumberOfShadingUnits", "GpuTimestampFrequency",
210     //     "MaxTimestamp", "GpuMinFrequencyMHz", "GpuMaxFrequencyMHz"
211     //////////////////////////////////////////////////////////////////////////////////
212     typedef struct SGlobalSymbol_1_0
213     {
214         const char*     SymbolName;
215         TTypedValue_1_0 SymbolTypedValue;
216     } TGlobalSymbol_1_0;
217 
218     //////////////////////////////////////////////////////////////////////////////////
219     // API version:
220     //////////////////////////////////////////////////////////////////////////////////
221     typedef struct SApiVersion_1_0
222     {
223         uint32_t MajorNumber;
224         uint32_t MinorNumber;
225         uint32_t BuildNumber;
226     } TApiVersion_1_0;
227 
228     //////////////////////////////////////////////////////////////////////////////////
229     // Global parameters of Metrics Device:
230     //////////////////////////////////////////////////////////////////////////////////
231     typedef struct SMetricsDeviceParams_1_0
232     {
233         // API version
234         TApiVersion_1_0 Version;
235         uint32_t        ConcurrentGroupsCount;
236         uint32_t        GlobalSymbolsCount;
237         uint32_t        DeltaFunctionsCount;
238         uint32_t        EquationElementTypesCount;
239         uint32_t        EquationOperationsCount;
240         const char*     DeviceName;
241     } TMetricsDeviceParams_1_0;
242 
243     //////////////////////////////////////////////////////////////////////////////////
244     // Global parameters of Metrics Device 1.2:
245     //////////////////////////////////////////////////////////////////////////////////
246     typedef struct SMetricsDeviceParams_1_2 : public SMetricsDeviceParams_1_0
247     {
248         uint32_t OverrideCount;
249     } TMetricsDeviceParams_1_2;
250 
251     //////////////////////////////////////////////////////////////////////////////////
252     // Metric API types:
253     //////////////////////////////////////////////////////////////////////////////////
254     typedef enum EMetricApiType
255     {
256         API_TYPE_IOSTREAM = 0x00000001, // API independent method
257         API_TYPE_DX9      = 0x00000002,
258         API_TYPE_DX10     = 0x00000004,
259         API_TYPE_DX11     = 0x00000008,
260         API_TYPE_OGL      = 0x00000010,
261         API_TYPE_OGL4_X   = 0x00000020,
262         API_TYPE_OCL      = 0x00000040,
263         API_TYPE_MEDIA    = 0x00000080, // Only option would be using DmaBuffer sampling
264         API_TYPE_DX12     = 0x00000100,
265         API_TYPE_BBSTREAM = 0x00000200,
266         API_TYPE_VULKAN   = 0x00000400,
267         API_TYPE_RESERVED = 0x00000800,
268         API_TYPE_ALL      = 0xffffffff
269     } TMetricApiType;
270 
271     //////////////////////////////////////////////////////////////////////////////////
272     // Measurement types:
273     //////////////////////////////////////////////////////////////////////////////////
274     typedef enum EMeasurementType
275     {
276         MEASUREMENT_TYPE_SNAPSHOT_IO    = 0x00000001,
277         MEASUREMENT_TYPE_SNAPSHOT_QUERY = 0x00000002,
278         MEASUREMENT_TYPE_DELTA_QUERY    = 0x00000004,
279         MEASUREMENT_TYPE_ALL            = 0x0000ffff,
280     } TMeasurementType;
281 
282     //////////////////////////////////////////////////////////////////////////////////
283     // Usage flags:
284     //////////////////////////////////////////////////////////////////////////////////
285     typedef enum EMetricUsageFlag
286     {
287         USAGE_FLAG_OVERVIEW  = 0x00000001, // GPU system overview metric, useful for high level workload characterization
288         USAGE_FLAG_INDICATE  = 0x00000002, // Metric indicating a performance problem, useful when comparing with threshold
289         USAGE_FLAG_CORRELATE = 0x00000004, // Metric correlating with performance problem, useful for proving to false only
290         USAGE_FLAG_SYSTEM    = 0x00000020, // Metric useful at system level
291         USAGE_FLAG_FRAME     = 0x00000040, // Metric useful at frame level
292         USAGE_FLAG_BATCH     = 0x00000080, // Metric useful at batch level
293         USAGE_FLAG_DRAW      = 0x00000100, // Metric useful at draw level
294         USAGE_FLAG_TIER_1    = 0x00000400,
295         USAGE_FLAG_TIER_2    = 0x00000800,
296         USAGE_FLAG_TIER_3    = 0x00001000,
297         USAGE_FLAG_TIER_4    = 0x00002000,
298         USAGE_FLAG_GLASS_JAW = 0x00004000,
299         USAGE_FLAG_ALL       = 0x0000ffff,
300     } TMetricUsageFlag;
301 
302     //////////////////////////////////////////////////////////////////////////////////
303     // Sampling types:
304     //////////////////////////////////////////////////////////////////////////////////
305     typedef enum ESamplingType
306     {
307         SAMPLING_TYPE_OA_TIMER   = 0x00000001,
308         SAMPLING_TYPE_OA_EVENT   = 0x00000002,
309         SAMPLING_TYPE_GPU_QUERY  = 0x00000004,
310         SAMPLING_TYPE_DMA_BUFFER = 0x00000008, // Possible future extension for media
311         SAMPLING_TYPE_ALL        = 0x0000ffff,
312     } TSamplingType;
313 
314     //////////////////////////////////////////////////////////////////////////////////
315     // Metric categories:
316     //////////////////////////////////////////////////////////////////////////////////
317     typedef enum EMetricCategory
318     {
319         GPU_RENDER  = 0x0001,
320         GPU_COMPUTE = 0x0002,
321         GPU_MEDIA   = 0x0004,
322         GPU_GENERIC = 0x0008, // Does not belong to any specific category like memory traffic
323     } TMetricCategory;
324 
325     //////////////////////////////////////////////////////////////////////////////////
326     // IoStream read flags:
327     //////////////////////////////////////////////////////////////////////////////////
328     typedef enum EIoReadFlag
329     {
330         IO_READ_FLAG_DROP_OLD_REPORTS    = 0x00000001,
331         IO_READ_FLAG_GET_CONTEXT_ID_TAGS = 0x00000002,
332     } TIoReadFlag;
333 
334     //////////////////////////////////////////////////////////////////////////////////
335     // Override modes:
336     //////////////////////////////////////////////////////////////////////////////////
337     typedef enum EOverrideMode
338     {
339         OVERRIDE_MODE_GLOBAL = 0x0001,
340         OVERRIDE_MODE_LOCAL  = 0x0002,
341     } TOverrideMode;
342 
343     //////////////////////////////////////////////////////////////////////////////////
344     // Adapter capability flags:
345     //////////////////////////////////////////////////////////////////////////////////
346     typedef enum EAdapterCapability
347     {
348         ADAPTER_CAPABILITY_UNDEFINED        = 0,
349         ADAPTER_CAPABILITY_RENDER_SUPPORTED = 1 << 0,
350     } TAdapterCapability;
351 
352     //////////////////////////////////////////////////////////////////////////////////
353     // Adapter types:
354     //////////////////////////////////////////////////////////////////////////////////
355     typedef enum EAdapterType
356     {
357         ADAPTER_TYPE_UNDEFINED = 0,
358         ADAPTER_TYPE_INTEGRATED,
359         ADAPTER_TYPE_DISCRETE,
360     } TAdapterType;
361 
362     //////////////////////////////////////////////////////////////////////////////////
363     // Adapter ID types:
364     //////////////////////////////////////////////////////////////////////////////////
365     typedef enum EAdapterIdType
366     {
367         ADAPTER_ID_TYPE_UNDEFINED = 0,
368         ADAPTER_ID_TYPE_LUID,
369         ADAPTER_ID_TYPE_MAJOR_MINOR,
370     } TAdapterIdType;
371 
372     //////////////////////////////////////////////////////////////////////////////////
373     // LUID (locally unique identifier) adapter ID:
374     //////////////////////////////////////////////////////////////////////////////////
375     typedef struct SAdapterIdLuid_1_6
376     {
377         uint32_t LowPart;
378         int32_t  HighPart;
379     } TAdapterIdLuid_1_6;
380 
381     //////////////////////////////////////////////////////////////////////////////////
382     // Major / minor pair adapter ID:
383     //////////////////////////////////////////////////////////////////////////////////
384     typedef struct SAdapterIdMajorMinor_1_6
385     {
386         int32_t Major;
387         int32_t Minor;
388     } TAdapterIdMajorMinor_1_6;
389 
390     //////////////////////////////////////////////////////////////////////////////////
391     // Adapter ID:
392     //////////////////////////////////////////////////////////////////////////////////
393     typedef struct SAdapterId_1_6
394     {
395         TAdapterIdType Type;
396         union
397         {
398             TAdapterIdLuid_1_6       Luid;
399             TAdapterIdMajorMinor_1_6 MajorMinor;
400         };
401     } TAdapterId_1_6;
402 
403     //////////////////////////////////////////////////////////////////////////////////
404     // Global parameters of GPU adapter:
405     //////////////////////////////////////////////////////////////////////////////////
406     typedef struct SAdapterParams_1_6
407     {
408         const char*    ShortName;
409         TAdapterId_1_6 SystemId; // Operating system specific adapter id
410         uint32_t       VendorId;
411         uint32_t       SubVendorId;
412         uint32_t       DeviceId;
413         uint32_t       Platform;
414         uint32_t       BusNumber;
415         uint32_t       DeviceNumber;
416         uint32_t       FunctionNumber;
417         TAdapterType   Type;           // Adapter type, e.g. integrated, discrete
418         uint32_t       CapabilityMask; // Consists of TAdapterCapability flags, e.g. RENDER_SUPPORTED
419     } TAdapterParams_1_6;
420 
421     //////////////////////////////////////////////////////////////////////////////////
422     // Global parameters of GPU adapter:
423     //////////////////////////////////////////////////////////////////////////////////
424     typedef struct SAdapterParams_1_8 : public SAdapterParams_1_6
425     {
426         uint32_t DomainNumber;
427     } TAdapterParams_1_8;
428 
429     //////////////////////////////////////////////////////////////////////////////////
430     // Global parameters of GPU adapter:
431     //////////////////////////////////////////////////////////////////////////////////
432     typedef struct SAdapterParams_1_9 : public SAdapterParams_1_8
433     {
434         uint32_t SubDevicesCount;
435     } TAdapterParams_1_9;
436 
437     //////////////////////////////////////////////////////////////////////////////////
438     // Global parameters of GPU sub device:
439     //////////////////////////////////////////////////////////////////////////////////
440     typedef struct SSubDeviceParams_1_9
441     {
442         uint32_t EnginesCount;
443     } TSubDeviceParams_1_9;
444 
445     //////////////////////////////////////////////////////////////////////////////////
446     // Engine ID types:
447     //////////////////////////////////////////////////////////////////////////////////
448     typedef enum EEngineIdType
449     {
450         ENGINE_ID_TYPE_CLASS_INSTANCE = 0
451     } TEngineIdType;
452 
453     //////////////////////////////////////////////////////////////////////////////////
454     // Class / instance engine ID:
455     //////////////////////////////////////////////////////////////////////////////////
456     typedef struct SEngineIdClassInstance_1_9
457     {
458         uint32_t Class;
459         uint32_t Instance;
460     } TEngineIdClassInstance_1_9;
461 
462     //////////////////////////////////////////////////////////////////////////////////
463     // Engine identification:
464     //////////////////////////////////////////////////////////////////////////////////
465     typedef struct SEngineId_1_9
466     {
467         TEngineIdType Type;
468 
469         union
470         {
471             TEngineIdClassInstance_1_9 ClassInstance;
472         };
473     } TEngineId_1_9;
474 
475     //////////////////////////////////////////////////////////////////////////////////
476     // Global parameters of GPU engine:
477     //////////////////////////////////////////////////////////////////////////////////
478     typedef struct SEngineParams_1_9
479     {
480         TEngineId_1_9 EngineId;
481     } TEngineParams_1_9;
482 
483     //////////////////////////////////////////////////////////////////////////////////
484     // Global parameters of Adapter Group:
485     //////////////////////////////////////////////////////////////////////////////////
486     typedef struct SAdapterGroupParams_1_6
487     {
488         // API version
489         TApiVersion_1_0 Version;
490         uint32_t        AdapterCount;
491     } TAdapterGroupParams_1_6;
492 
493     //////////////////////////////////////////////////////////////////////////////////
494     // Global parameters of Concurrent Group:
495     //////////////////////////////////////////////////////////////////////////////////
496     typedef struct SConcurrentGroupParams_1_0
497     {
498         const char* SymbolName;  // For example "PerfMon" or "OA" or "PipeStats"
499         const char* Description; // For example "PerfMon and ODLAT Uncore ring counters"
500         uint32_t    MeasurementTypeMask;
501         uint32_t    MetricSetsCount;
502         uint32_t    IoMeasurementInformationCount;
503         uint32_t    IoGpuContextInformationCount;
504 
505     } TConcurrentGroupParams_1_0;
506 
507     //////////////////////////////////////////////////////////////////////////////////
508     // Global parameters of an Override:
509     //////////////////////////////////////////////////////////////////////////////////
510     typedef struct SOverrideParams_1_2
511     {
512         const char* SymbolName;  // For example "FrequencyOverride"
513         const char* Description; // For example "Overrides device GPU frequency with a static value."
514         uint32_t    ApiMask;
515         uint32_t    PlatformMask;
516         uint32_t    OverrideModeMask;
517 
518     } TOverrideParams_1_2;
519 
520     //////////////////////////////////////////////////////////////////////////////////
521     // Base params of SetOverride method:
522     //////////////////////////////////////////////////////////////////////////////////
523     typedef struct SSetOverrideParams_1_2
524     {
525         bool Enable;
526     } TSetOverrideParams_1_2;
527 
528     //////////////////////////////////////////////////////////////////////////////////
529     // Frequency override specific SetOverride params:
530     //////////////////////////////////////////////////////////////////////////////////
531     typedef struct SSetFrequencyOverrideParams_1_2 : SSetOverrideParams_1_2
532     {
533         uint32_t FrequencyMhz;
534         uint32_t Pid;
535     } TSetFrequencyOverrideParams_1_2;
536 
537     //////////////////////////////////////////////////////////////////////////////////
538     // Query override specific SetOverride params:
539     //////////////////////////////////////////////////////////////////////////////////
540     typedef struct SSetQueryOverrideParams_1_2 : SSetOverrideParams_1_2
541     {
542         uint32_t Period; // Nanoseconds
543     } TSetQueryOverrideParams_1_2;
544 
545     //////////////////////////////////////////////////////////////////////////////////
546     // Driver override params:
547     //////////////////////////////////////////////////////////////////////////////////
548     typedef struct SSetDriverOverrideParams_1_2 : SSetOverrideParams_1_2
549     {
550         uint32_t Value;
551     } TSetDriverOverrideParams_1_2;
552 
553     //////////////////////////////////////////////////////////////////////////////////
554     // API specific id:
555     //////////////////////////////////////////////////////////////////////////////////
556     typedef struct SApiSpecificId_1_0
557     {
558         uint32_t    D3D9QueryId;           // D3D9 Query ID
559         uint32_t    D3D9Fourcc;            // D3D9 FourCC
560         uint32_t    D3D1XQueryId;          // D3D1X Query ID
561         uint32_t    D3D1XDevDependentId;   // D3D1X device dependent counter ID
562         const char* D3D1XDevDependentName; // Device dependent counter name
563         uint32_t    OGLQueryIntelId;       // Intel OGL query extension ID
564         const char* OGLQueryIntelName;     // Intel OGL query extension name
565         uint32_t    OGLQueryARBTargetId;   // ARB OGL Query Target ID
566         uint32_t    OCL;                   // OCL configuration ID
567         uint32_t    HwConfigId;            // Config ID for IO stream
568         uint32_t    placeholder[1];
569     } TApiSpecificId_1_0;
570 
571     //////////////////////////////////////////////////////////////////////////////////
572     // Global parameters of Metric set:
573     //////////////////////////////////////////////////////////////////////////////////
574     typedef struct SMetricSetParams_1_0
575     {
576         const char*        SymbolName; // For example "Dx11Tessellation"
577         const char*        ShortName;  // For example "DX11 Tessellation Metrics Set"
578         uint32_t           ApiMask;
579         uint32_t           CategoryMask;
580         uint32_t           RawReportSize;   // As in HW
581         uint32_t           QueryReportSize; // As in Query API
582         uint32_t           MetricsCount;
583         uint32_t           InformationCount;
584         uint32_t           ComplementarySetsCount;
585         TApiSpecificId_1_0 ApiSpecificId;
586         uint32_t           PlatformMask;
587     } TMetricSetParams_1_0;
588 
589     //////////////////////////////////////////////////////////////////////////////////
590     // GT differenced MetricSet params:
591     //////////////////////////////////////////////////////////////////////////////////
592     typedef struct SMetricSetParams_1_4 : SMetricSetParams_1_0
593     {
594         uint32_t GtMask;
595     } TMetricSetParams_1_4;
596 
597     //////////////////////////////////////////////////////////////////////////////////
598     // Metric result types:
599     //////////////////////////////////////////////////////////////////////////////////
600     typedef enum EMetricResultType
601     {
602         RESULT_UINT32,
603         RESULT_UINT64,
604         RESULT_BOOL,
605         RESULT_FLOAT,
606         RESULT_LAST
607     } TMetricResultType;
608 
609     //////////////////////////////////////////////////////////////////////////////////
610     // Metric types:
611     //////////////////////////////////////////////////////////////////////////////////
612     typedef enum EMetricType
613     {
614         METRIC_TYPE_DURATION,
615         METRIC_TYPE_EVENT,
616         METRIC_TYPE_EVENT_WITH_RANGE,
617         METRIC_TYPE_THROUGHPUT,
618         METRIC_TYPE_TIMESTAMP,
619         METRIC_TYPE_FLAG,
620         METRIC_TYPE_RATIO,
621         METRIC_TYPE_RAW,
622         METRIC_TYPE_LAST
623     } TMetricType;
624 
625     //////////////////////////////////////////////////////////////////////////////////
626     // Information types:
627     //////////////////////////////////////////////////////////////////////////////////
628     typedef enum EInformationType
629     {
630         INFORMATION_TYPE_REPORT_REASON,
631         INFORMATION_TYPE_VALUE,
632         INFORMATION_TYPE_FLAG,
633         INFORMATION_TYPE_TIMESTAMP,
634         INFORMATION_TYPE_CONTEXT_ID_TAG,
635         INFORMATION_TYPE_SAMPLE_PHASE,
636         INFORMATION_TYPE_GPU_NODE,
637         INFORMATION_TYPE_LAST
638     } TInformationType;
639 
640     //////////////////////////////////////////////////////////////////////////////////
641     // Report reasons:
642     //////////////////////////////////////////////////////////////////////////////////
643     typedef enum EReportReason
644     {
645         REPORT_REASON_UNDEFINED                 = 0x0000,
646         REPORT_REASON_INTERNAL_TIMER            = 0x0001,
647         REPORT_REASON_INTERNAL_TRIGGER1         = 0x0002,
648         REPORT_REASON_INTERNAL_TRIGGER2         = 0x0004,
649         REPORT_REASON_INTERNAL_CONTEXT_SWITCH   = 0x0008,
650         REPORT_REASON_INTERNAL_GO               = 0x0010,
651         REPORT_REASON_INTERNAL_FREQUENCY_CHANGE = 0x0020,
652         REPORT_REASON_QUERY_DEFAULT             = 0x0100,
653         REPORT_REASON_QUERY_INTERNAL_RESOLVE    = 0x0200,
654         REPORT_REASON_QUERY_INTERNAL_CLEAR      = 0x0400,
655     } TReportReason;
656 
657     //////////////////////////////////////////////////////////////////////////////////
658     // Sample phase:
659     //////////////////////////////////////////////////////////////////////////////////
660     typedef enum ESamplePhase
661     {
662         SAMPLE_PHASE_END,
663         SAMPLE_PHASE_BEGIN,
664         SAMPLE_PHASE_LAST
665     } TSamplePhase;
666 
667     //////////////////////////////////////////////////////////////////////////////////
668     // Gpu Node:
669     //////////////////////////////////////////////////////////////////////////////////
670     typedef enum EInformationGpuNode
671     {
672         INFORMATION_GPUNODE_3D       = 0, // Available by default on all platform
673         INFORMATION_GPUNODE_VIDEO    = 1, // Available on CTG+
674         INFORMATION_GPUNODE_BLT      = 2, // Available on GT
675         INFORMATION_GPUNODE_VE       = 3, // Available on HSW+ (VideoEnhancement)
676         INFORMATION_GPUNODE_VCS2     = 4, // Available on BDW+ GT3+
677         INFORMATION_GPUNODE_REAL_MAX = 5, // All nodes beyond this are virtual nodes - they don't have an actual GPU engine
678         INFORMATION_GPUNODE_LAST
679     } TInformationGpuNode;
680 
681     //////////////////////////////////////////////////////////////////////////////////
682     // Hardware unit types:
683     //////////////////////////////////////////////////////////////////////////////////
684     typedef enum EHwUnitType
685     {
686         HW_UNIT_GPU,
687         HW_UNIT_SLICE,
688         HW_UNIT_SUBSLICE,
689         HW_UNIT_SUBSLICE_BANK,
690         HW_UNIT_EU_UNIT,
691         HW_UNIT_UNCORE,
692         HW_UNIT_DUALSUBSLICE,
693         HW_UNIT_LAST
694     } THwUnitType;
695 
696     //////////////////////////////////////////////////////////////////////////////////
697     // Delta function types:
698     //////////////////////////////////////////////////////////////////////////////////
699     typedef enum EDeltaFunctionType
700     {
701         DELTA_FUNCTION_NULL = 0,
702         DELTA_N_BITS,
703         DELTA_BOOL_OR,      // Logic OR - good for exceptions
704         DELTA_BOOL_XOR,     // Logic XOR - good to check if bits were changed
705         DELTA_GET_PREVIOUS, // Preserve previous value
706         DELTA_GET_LAST,     // Preserve last value
707         DELTA_NS_TIME,      // Delta for nanosecond timestamps (GPU timestamp wraps at 32 bits but was value multiplied by 80)
708         DELTA_FUNCTION_LAST_1_0
709     } TDeltaFunctionType;
710 
711     //////////////////////////////////////////////////////////////////////////////////
712     // Delta function:
713     //////////////////////////////////////////////////////////////////////////////////
714     typedef struct SDeltaFunction_1_0
715     {
716         TDeltaFunctionType FunctionType;
717         union
718         {
719             uint32_t BitsCount; // Used for DELTA_N_BITS to specify bits count
720         };
721     } TDeltaFunction_1_0;
722 
723     //////////////////////////////////////////////////////////////////////////////////
724     // Equation element types:
725     //////////////////////////////////////////////////////////////////////////////////
726     typedef enum EEquationElementType
727     {
728         EQUATION_ELEM_OPERATION,                 // See TEquationOperation enumeration
729         EQUATION_ELEM_RD_BITFIELD,               //
730         EQUATION_ELEM_RD_UINT8,                  //
731         EQUATION_ELEM_RD_UINT16,                 //
732         EQUATION_ELEM_RD_UINT32,                 //
733         EQUATION_ELEM_RD_UINT64,                 //
734         EQUATION_ELEM_RD_FLOAT,                  //
735         EQUATION_ELEM_RD_40BIT_CNTR,             // Assemble 40 bit counter that is in two locations, result in unsigned integer 64b
736         EQUATION_ELEM_IMM_UINT64,                //
737         EQUATION_ELEM_IMM_FLOAT,                 //
738         EQUATION_ELEM_SELF_COUNTER_VALUE,        // Defined by $Self token, the UINT64 result of DeltaFunction for IO or QueryReadEquation
739         EQUATION_ELEM_GLOBAL_SYMBOL,             // Defined by $"SymbolName", available in MetricsDevice SymbolTable
740         EQUATION_ELEM_LOCAL_COUNTER_SYMBOL,      // Defined by $"SymbolName", refers to counter delta value in the local set
741         EQUATION_ELEM_OTHER_SET_COUNTER_SYMBOL,  // Defined by concatenated string of $"setSymbolName/SymbolName", refers to counter
742                                                  // Delta value in the other set
743         EQUATION_ELEM_LOCAL_METRIC_SYMBOL,       // Defined by $$"SymbolName", refers to metric normalized value in the local set
744         EQUATION_ELEM_OTHER_SET_METRIC_SYMBOL,   // Defined by concatenated string of $$"setSymbolName/SymbolName", refers to metric
745                                                  // Normalized value in the other set
746         EQUATION_ELEM_INFORMATION_SYMBOL,        // Defined by i$"SymbolName", refers to information value type only
747         EQUATION_ELEM_STD_NORM_GPU_DURATION,     // Action is $Self $GpuCoreClocks FDIV 100 FMUL
748         EQUATION_ELEM_STD_NORM_EU_AGGR_DURATION, // Action is $Self $GpuCoreClocks $EuCoresTotalCount UMUL FDIV 100 FMUL
749 
750         EQUATION_ELEM_LAST_1_0
751 
752     } TEquationElementType;
753 
754     //////////////////////////////////////////////////////////////////////////////////
755     // Equation operations:
756     //////////////////////////////////////////////////////////////////////////////////
757     typedef enum EEquationOperation
758     {
759         EQUATION_OPER_RSHIFT, // 64b unsigned integer right shift
760         EQUATION_OPER_LSHIFT, // 64b unsigned integer left shift
761         EQUATION_OPER_AND,    // Bitwise AND of two unsigned integers, 64b each
762         EQUATION_OPER_OR,     // Bitwise OR of two unsigned integers, 64b each
763         EQUATION_OPER_XOR,    // Bitwise XOR of two unsigned integers, 64b each
764         EQUATION_OPER_XNOR,   // Bitwise XNOR of two unsigned integers, 64b each
765         EQUATION_OPER_AND_L,  // Logical AND (C-like "&&") of two unsigned integers, 64b each, result is true(1) if both values are true(greater than 0)
766         EQUATION_OPER_EQUALS, // Equality (C-like "==") of two unsigned integers, 64b each, result is true(1) or false(0)
767         EQUATION_OPER_UADD,   // Unsigned integer add, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
768         EQUATION_OPER_USUB,   // Unsigned integer subtract, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
769         EQUATION_OPER_UMUL,   // Unsigned integer mul, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
770         EQUATION_OPER_UDIV,   // Unsigned integer div, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
771         EQUATION_OPER_FADD,   // Floating point add, arguments are casted to be 32b floating points, result is a 32b float
772         EQUATION_OPER_FSUB,   // Floating point subtract, arguments are casted to be 32b floating points, result is a 32b float
773         EQUATION_OPER_FMUL,   // Floating point multiply, arguments are casted to be 32b floating points, result is a 32b float
774         EQUATION_OPER_FDIV,   // Floating point divide, arguments are casted to be 32b floating points, result is a 32b float
775         EQUATION_OPER_UGT,    // 64b unsigned integers comparison of is greater than, result is bool true(1) or false(0)
776         EQUATION_OPER_ULT,    // 64b unsigned integers comparison of is less than, result is bool true(1) or false(0)
777         EQUATION_OPER_UGTE,   // 64b unsigned integers comparison of is greater than or equal, result is bool true(1) or false(0)
778         EQUATION_OPER_ULTE,   // 64b unsigned integers comparison of is less than or equal, result is bool true(1) or false(0)
779         EQUATION_OPER_FGT,    // 32b floating point numbers comparison of is greater than, result is bool true(1) or false(0)
780         EQUATION_OPER_FLT,    // 32b floating point numbers comparison of is less than, result is bool true(1) or false(0)
781         EQUATION_OPER_FGTE,   // 32b floating point numbers comparison of is greater than or equal, result is bool true(1) or false(0)
782         EQUATION_OPER_FLTE,   // 32b floating point numbers comparison of is less than or equal, result is bool true(1) or false(0)
783         EQUATION_OPER_UMIN,   // Unsigned integer MIN function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
784         EQUATION_OPER_UMAX,   // Unsigned integer MAX function, arguments are casted to be 64b unsigned integers, result is unsigned integer 64b
785         EQUATION_OPER_FMIN,   // Floating point MIN function, arguments are casted to be 32b floating points, result is a 32b float
786         EQUATION_OPER_FMAX,   // Floating point MAX function, arguments are casted to be 32b floating points, result is a 32b float
787         EQUATION_OPER_LAST_1_0
788     } TEquationOperation;
789 
790     //////////////////////////////////////////////////////////////////////////////////
791     // Read params:
792     //////////////////////////////////////////////////////////////////////////////////
793     typedef struct SReadParams_1_0
794     {
795         uint32_t ByteOffset;
796         uint32_t BitOffset;
797         uint32_t BitsCount;
798         uint32_t ByteOffsetExt;
799     } TReadParams_1_0;
800 
801     //////////////////////////////////////////////////////////////////////////////////
802     // Equation element:
803     //////////////////////////////////////////////////////////////////////////////////
804     typedef struct SEquationElement_1_0
805     {
806         TEquationElementType Type;
807         union
808         {
809             uint64_t           ImmediateUInt64;
810             float              ImmediateFloat;
811             TEquationOperation Operation;
812             TReadParams_1_0    ReadParams;
813         };
814         char* SymbolName;
815     } TEquationElement_1_0;
816 
817     ///////////////////////////////////////////////////////////////////////////////
818     //
819     // Class:
820     //   IEquation_1_0
821     //
822     // Description:
823     //   Abstract interface for the equation object.
824     //
825     ///////////////////////////////////////////////////////////////////////////////
826     class IEquation_1_0
827     {
828     public:
829         virtual ~IEquation_1_0();
830         virtual uint32_t              GetEquationElementsCount( void );
831         virtual TEquationElement_1_0* GetEquationElement( uint32_t index );
832     };
833 
834     //////////////////////////////////////////////////////////////////////////////////
835     // Global parameters of Metric:
836     //////////////////////////////////////////////////////////////////////////////////
837     typedef struct SMetricParams_1_0
838     {
839         uint32_t           IdInSet;           // Position in the set
840         uint32_t           GroupId;           // Specific metric group id
841         const char*        SymbolName;        // Symbol name, used in equations
842         const char*        ShortName;         // Consistent metric name, not changed platform to platform
843         const char*        GroupName;         // VertexShader for example
844         const char*        LongName;          // Hint about the metric shown to users
845         const char*        DxToOglAlias;      // To replace DX pixels with OGL fragments
846         uint32_t           UsageFlagsMask;    //
847         uint32_t           ApiMask;           //
848         TMetricResultType  ResultType;        //
849         const char*        MetricResultUnits; //
850         TMetricType        MetricType;        //
851         uint64_t           LowWatermark;      // Low watermark for hotspot indication (USAGE_FLAG_INDICATE only)
852         uint64_t           HighWatermark;     // High watermark for hotspot indication (USAGE_FLAG_INDICATE only)
853         THwUnitType        HwUnitType;        //
854         IEquation_1_0*     IoReadEquation;    // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations)
855         IEquation_1_0*     QueryReadEquation; // Read equation specification for query (accessing calculated delta values)
856         TDeltaFunction_1_0 DeltaFunction;     //
857         IEquation_1_0*     NormEquation;      // Normalization equation to get normalized value to bytes transfered or to a percentage of utilization
858         IEquation_1_0*     MaxValueEquation;  // To calculate metrics max value as a function of other metrics and device parameters (e.g. 100 for percentage)
859     } TMetricParams_1_0;
860 
861     //////////////////////////////////////////////////////////////////////////////////
862     // Global parameters of Information:
863     //////////////////////////////////////////////////////////////////////////////////
864     typedef struct SInformationParams_1_0
865     {
866         uint32_t           IdInSet;           // Position in the set
867         const char*        SymbolName;        // Symbol name, used in equations
868         const char*        ShortName;         // Consistent name, not changed platform to platform
869         const char*        GroupName;         // Some more global context of the information
870         const char*        LongName;          // Hint about the information shown to users
871         uint32_t           ApiMask;           //
872         TInformationType   InfoType;          //
873         const char*        InfoUnits;         //
874         IEquation_1_0*     IoReadEquation;    // Read equation specification for IO stream (accessing raw values potentially spread in report in several locations)
875         IEquation_1_0*     QueryReadEquation; // Read equation specification for query (accessing calculated delta values)
876         TDeltaFunction_1_0 OverflowFunction;  //
877     } TInformationParams_1_0;
878 
879     ///////////////////////////////////////////////////////////////////////////////
880     //
881     // Class:
882     //   IInformation_1_0
883     //
884     // Descriptions:
885     //   Abstract interface for the measurement information parameter.
886     //
887     ///////////////////////////////////////////////////////////////////////////////
888     class IInformation_1_0
889     {
890     public:
891         virtual ~IInformation_1_0();
892         virtual TInformationParams_1_0* GetParams();
893     };
894 
895     ///////////////////////////////////////////////////////////////////////////////
896     //
897     // Class:
898     //   IMetric_1_0
899     //
900     // Description:
901     //   Abstract interface for the metric that is sampled.
902     //
903     ///////////////////////////////////////////////////////////////////////////////
904     class IMetric_1_0
905     {
906     public:
907         virtual ~IMetric_1_0();
908         virtual TMetricParams_1_0* GetParams();
909     };
910 
911     ///////////////////////////////////////////////////////////////////////////////
912     //
913     // Class:
914     //   IMetricSet_1_0
915     //
916     // Description:
917     //   Abstract interface for the metric sets mapping to different HW
918     //   configuration that should be used exclusively to each other
919     //   metric set in the concurrent group.
920     //
921     // New:
922     // - GetParams:
923     // - GetMetric:                         To get particular metric
924     // - GetInformation:                    To get particular information about measurement
925     // - GetComplementaryMetricSet:         Below proposal to address multi-passes at the set level
926     // - Activate:                          To enable this configuration before query instance is created
927     // - Deactivate:                        To disable this configuration after query instance is created
928     // - AddCustomMetric:                   To add an additional custom metric to this set
929     //
930     ///////////////////////////////////////////////////////////////////////////////
931     class IMetricSet_1_0
932     {
933     public:
934         virtual ~IMetricSet_1_0();
935 
936         virtual TMetricSetParams_1_0* GetParams( void );
937         virtual IMetric_1_0*          GetMetric( uint32_t index );
938         virtual IInformation_1_0*     GetInformation( uint32_t index );
939         virtual IMetricSet_1_0*       GetComplementaryMetricSet( uint32_t index );
940         virtual TCompletionCode       Activate( void );
941         virtual TCompletionCode       Deactivate( void );
942         virtual IMetric_1_0*          AddCustomMetric(
943                      const char*       symbolName,
944                      const char*       shortName,
945                      const char*       groupName,
946                      const char*       longName,
947                      const char*       dxToOglAlias,
948                      uint32_t          usageFlagsMask,
949                      uint32_t          apiMask,
950                      TMetricResultType resultType,
951                      const char*       resultUnits,
952                      TMetricType       metricType,
953                      int64_t           loWatermark,
954                      int64_t           hiWatermark,
955                      THwUnitType       hwType,
956                      const char*       ioReadEquation,
957                      const char*       deltaFunction,
958                      const char*       queryReadEquation,
959                      const char*       normalizationEquation,
960                      const char*       maxValueEquation,
961                      const char*       signalName );
962     };
963 
964     ///////////////////////////////////////////////////////////////////////////////
965     //
966     // Class:
967     //   IMetricSet_1_1
968     //
969     // Description:
970     //   Updated 1.0 version to use with 1.1 interface version.
971     //   Introduces an ability to calculate metrics from raw data.
972     //
973     // New:
974     // - SetApiFiltering:                       To filter available metrics/information for the given API. Use TMetricApiType to build the mask.
975     // - CalculateMetrics:                      To calculate normalized metrics/information from the raw data.
976     // - CalculateIoMeasurementInformation:     To calculate additional information for stream measurements.
977     //
978     ///////////////////////////////////////////////////////////////////////////////
979     class IMetricSet_1_1 : public IMetricSet_1_0
980     {
981     public:
982         virtual ~IMetricSet_1_1();
983         virtual TCompletionCode SetApiFiltering( uint32_t apiMask );
984         virtual TCompletionCode CalculateMetrics( const uint8_t* rawData, uint32_t rawDataSize, TTypedValue_1_0* out, uint32_t outSize, uint32_t* outReportCount, bool enableContextFiltering );
985         virtual TCompletionCode CalculateIoMeasurementInformation( TTypedValue_1_0* out, uint32_t outSize );
986     };
987 
988     ///////////////////////////////////////////////////////////////////////////////
989     //
990     // Class:
991     //   IMetricSet_1_4
992     //
993     // Description:
994     //   Updated 1.1 version to use with 1.4 interface version.
995     //   Extends set params with gtType information.
996     //
997     // Updates:
998     // - GetParams
999     //
1000     ///////////////////////////////////////////////////////////////////////////////
1001     class IMetricSet_1_4 : public IMetricSet_1_1
1002     {
1003     public:
1004         virtual ~IMetricSet_1_4();
1005         virtual TMetricSetParams_1_4* GetParams( void );
1006     };
1007 
1008     ///////////////////////////////////////////////////////////////////////////////
1009     //
1010     // Class:
1011     //   IMetricSet_1_5
1012     //
1013     // Description:
1014     //   Updated 1.4 version to use with 1.5 interface version.
1015     //   Adds an ability to calculate MaxValueEquations (maximal value) for each metric.
1016     //   Param 'enableContextFiltering' becomes deprecated.
1017     //
1018     // Updates:
1019     // - GetComplementaryMetricSet:         Update to 1.5 interface
1020     // - CalculateMetrics:                  CalculateMetrics extended with max values calculation.
1021     //                                      ptional param 'outMaxValues' should have a memory
1022     //                                      for at least 'MetricCount * RawReportCount' values, can be NULL.
1023     //
1024     ///////////////////////////////////////////////////////////////////////////////
1025     class IMetricSet_1_5 : public IMetricSet_1_4
1026     {
1027     public:
1028         using IMetricSet_1_1::CalculateMetrics; // To avoid hiding by 1.5 interface function
1029         virtual IMetricSet_1_5* GetComplementaryMetricSet( uint32_t index );
1030         virtual TCompletionCode CalculateMetrics(
1031             const uint8_t*   rawData,
1032             uint32_t         rawDataSize,
1033             TTypedValue_1_0* out,
1034             uint32_t         outSize,
1035             uint32_t*        outReportCount,
1036             TTypedValue_1_0* outMaxValues,
1037             uint32_t         outMaxValuesSize );
1038     };
1039 
1040     ///////////////////////////////////////////////////////////////////////////////
1041     //
1042     // Class:
1043     //   IConcurrentGroup_1_0
1044     //
1045     // Description:
1046     //   Abstract interface for the metrics groups that can be collected
1047     //   concurrently to another group.
1048     //
1049     ///////////////////////////////////////////////////////////////////////////////
1050     class IConcurrentGroup_1_0
1051     {
1052     public:
1053         virtual ~IConcurrentGroup_1_0();
1054         virtual TConcurrentGroupParams_1_0* GetParams( void );
1055         virtual IMetricSet_1_0*             GetMetricSet( uint32_t index );
1056         virtual TCompletionCode             OpenIoStream( IMetricSet_1_0* metricSet, uint32_t processId, uint32_t* nsTimerPeriod, uint32_t* oaBufferSize );
1057         virtual TCompletionCode             ReadIoStream( uint32_t* reportsCount, char* reportData, uint32_t readFlags );
1058         virtual TCompletionCode             CloseIoStream( void );
1059         virtual TCompletionCode             WaitForReports( uint32_t milliseconds );
1060         virtual IInformation_1_0*           GetIoMeasurementInformation( uint32_t index );
1061         virtual IInformation_1_0*           GetIoGpuContextInformation( uint32_t index );
1062     };
1063 
1064     ///////////////////////////////////////////////////////////////////////////////
1065     //
1066     // Class:
1067     //   IConcurrentGroup_1_1
1068     //
1069     // Description:
1070     //   Updated 1.0 version to use with 1.1 interface version.
1071     //
1072     // Updates:
1073     // - GetMetricSet:                  Update to 1.1 interface
1074     //
1075     ///////////////////////////////////////////////////////////////////////////////
1076     class IConcurrentGroup_1_1 : public IConcurrentGroup_1_0
1077     {
1078     public:
1079         virtual IMetricSet_1_1* GetMetricSet( uint32_t index );
1080     };
1081 
1082     ///////////////////////////////////////////////////////////////////////////////
1083     //
1084     // Class:
1085     //   IConcurrentGroup_1_3
1086     //
1087     // Description:
1088     //   Updated 1.1 version to use with 1.3 interface version.Introduces setting Stream Sampling Type.
1089     //
1090     // New:
1091     // - SetIoStreamSamplingType:       To set sampling type during IoStream measurements
1092     //
1093     ///////////////////////////////////////////////////////////////////////////////
1094     class IConcurrentGroup_1_3 : public IConcurrentGroup_1_1
1095     {
1096     public:
1097         virtual TCompletionCode SetIoStreamSamplingType( TSamplingType type );
1098     };
1099 
1100     ///////////////////////////////////////////////////////////////////////////////
1101     //
1102     // Class:
1103     //   IConcurrentGroup_1_5
1104     //
1105     // Description:
1106     //   Updated 1.3 version to use with 1.5 interface version.
1107     //
1108     // Updates:
1109     // - GetMetricSet:                  Update to 1.5 interface
1110     //
1111     ///////////////////////////////////////////////////////////////////////////////
1112     class IConcurrentGroup_1_5 : public IConcurrentGroup_1_3
1113     {
1114     public:
1115         virtual IMetricSet_1_5* GetMetricSet( uint32_t index );
1116     };
1117 
1118     ///////////////////////////////////////////////////////////////////////////////
1119     //
1120     // Class:
1121     //   IOverride_1_2
1122     //
1123     // Description:
1124     //   Abstract interface for Metrics Device overrides.
1125     //
1126     // New:
1127     // - GetParams:                     To get this Override params
1128     // - SetOverride:                   To enable/disable this Override
1129     //
1130     ///////////////////////////////////////////////////////////////////////////////
1131     class IOverride_1_2
1132     {
1133     public:
1134         virtual ~IOverride_1_2();
1135         virtual TOverrideParams_1_2* GetParams( void );
1136         virtual TCompletionCode      SetOverride( TSetOverrideParams_1_2* params, uint32_t paramsSize );
1137     };
1138 
1139     ///////////////////////////////////////////////////////////////////////////////
1140     //
1141     // Class:
1142     //   IMetricsDevice_1_0
1143     //
1144     // Description:
1145     //   Abstract interface for the GPU metrics root object.
1146     //
1147     // New:
1148     // - GetParams:                     To get MetricsDevice params
1149     // - GetConcurrentGroup:            Child objects are of IConcurrentGroup
1150     // - GetGlobalSymbol:               To get GlobalSymbol at the given index
1151     // - GetGlobalSymbolValueByName:    To get GlobalSymbol with the given name
1152     // - GetLastError:                  To get last error from TCompletionCode enum
1153     // - GetGpuCpuTimestamps:           To get both GPU and CPU timestamp at the same time
1154     //
1155     ///////////////////////////////////////////////////////////////////////////////
1156     class IMetricsDevice_1_0
1157     {
1158     public:
1159         virtual ~IMetricsDevice_1_0();
1160         virtual TMetricsDeviceParams_1_0* GetParams( void );
1161         virtual IConcurrentGroup_1_0*     GetConcurrentGroup( uint32_t index );
1162         virtual TGlobalSymbol_1_0*        GetGlobalSymbol( uint32_t index );
1163         virtual TTypedValue_1_0*          GetGlobalSymbolValueByName( const char* name );
1164         virtual TCompletionCode           GetLastError( void );
1165         virtual TCompletionCode           GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, uint32_t* cpuId );
1166     };
1167 
1168     ///////////////////////////////////////////////////////////////////////////////
1169     //
1170     // Class:
1171     //   IMetricsDevice_1_1
1172     //
1173     // Description:
1174     //   Updated 1.0 version to use with 1.1 interface version.
1175     //
1176     // Updates:
1177     // - GetConcurrentGroup:            Update to 1.1 interface
1178     //
1179     ///////////////////////////////////////////////////////////////////////////////
1180     class IMetricsDevice_1_1 : public IMetricsDevice_1_0
1181     {
1182     public:
1183         virtual IConcurrentGroup_1_1* GetConcurrentGroup( uint32_t index );
1184     };
1185 
1186     ///////////////////////////////////////////////////////////////////////////////
1187     //
1188     // Class:
1189     //   IMetricsDevice_1_2
1190     //
1191     // Description:
1192     //   Updated 1.1 version to use with 1.2 interface version.
1193     //   Introduces an interface for getting overrides.
1194     //
1195     // Updates:
1196     // - GetParams:                     Update to 1.2 interface
1197     //
1198     // New:
1199     // - GetOverride:                   To get override at the given index
1200     // - GetOverrideByName:             To get override with the given name
1201     //
1202     ///////////////////////////////////////////////////////////////////////////////
1203     class IMetricsDevice_1_2 : public IMetricsDevice_1_1
1204     {
1205     public:
1206         virtual TMetricsDeviceParams_1_2* GetParams( void );
1207         virtual IOverride_1_2*            GetOverride( uint32_t index );
1208         virtual IOverride_1_2*            GetOverrideByName( const char* symbolName );
1209     };
1210 
1211     ///////////////////////////////////////////////////////////////////////////////
1212     //
1213     // Class:
1214     //   IMetricsDevice_1_5
1215     //
1216     // Description:
1217     //   Updated 1.2 version to use with 1.5 interface version.
1218     //
1219     // New:
1220     // - GetConcurrentGroup:            Update to 1.5 interface
1221     //
1222     ///////////////////////////////////////////////////////////////////////////////
1223     class IMetricsDevice_1_5 : public IMetricsDevice_1_2
1224     {
1225     public:
1226         virtual IConcurrentGroup_1_5* GetConcurrentGroup( uint32_t index );
1227     };
1228 
1229     ///////////////////////////////////////////////////////////////////////////////
1230     //
1231     // Class:
1232     //   IMetricsDevice_1_10
1233     //
1234     // Description:
1235     //   Updated 1.5 version to use with 1.10 interface version.
1236     //
1237     // Updates:
1238     // - GetGpuCpuTimestamps:            Update to 1.10 interface
1239     //
1240     ///////////////////////////////////////////////////////////////////////////////
1241     class IMetricsDevice_1_10 : public IMetricsDevice_1_5
1242     {
1243     public:
1244         using IMetricsDevice_1_0::GetGpuCpuTimestamps; // To avoid hiding by 1.10 interface function
1245         virtual TCompletionCode GetGpuCpuTimestamps( uint64_t* gpuTimestampNs, uint64_t* cpuTimestampNs, uint32_t* cpuId, uint64_t* correlationIndicatorNs );
1246     };
1247 
1248     ///////////////////////////////////////////////////////////////////////////////
1249     //
1250     // Class:
1251     //   IAdapter_1_6
1252     //
1253     // Description:
1254     //   Abstract interface for GPU adapter.
1255     //
1256     // New:
1257     // - GetParams:                     To get this adapter params
1258     // - Reset:                         To reset this adapter state
1259     // - OpenMetricsDevice
1260     // - OpenMetricsDeviceFromFile
1261     // - CloseMetricsDevice
1262     // - SaveMetricsDeviceToFile
1263     //
1264     ///////////////////////////////////////////////////////////////////////////////
1265     class IAdapter_1_6
1266     {
1267     public:
1268         virtual ~IAdapter_1_6();
1269         virtual const TAdapterParams_1_6* GetParams( void ) const;
1270         virtual TCompletionCode           Reset();
1271         virtual TCompletionCode           OpenMetricsDevice( IMetricsDevice_1_5** metricsDevice );
1272         virtual TCompletionCode           OpenMetricsDeviceFromFile( const char* fileName, void* openParams, IMetricsDevice_1_5** metricsDevice );
1273         virtual TCompletionCode           CloseMetricsDevice( IMetricsDevice_1_5* metricsDevice );
1274         virtual TCompletionCode           SaveMetricsDeviceToFile( const char* fileName, void* saveParams, IMetricsDevice_1_5* metricsDevice );
1275     };
1276 
1277     ///////////////////////////////////////////////////////////////////////////////
1278     //
1279     // Class:
1280     //   IAdapter_1_8
1281     //
1282     // Description:
1283     //   Abstract interface for GPU adapter.
1284     //
1285     // New:
1286     // - GetParams:                     To get this adapter params
1287     //
1288     ///////////////////////////////////////////////////////////////////////////////
1289     class IAdapter_1_8 : public IAdapter_1_6
1290     {
1291     public:
1292         virtual const TAdapterParams_1_8* GetParams( void ) const;
1293     };
1294 
1295     ///////////////////////////////////////////////////////////////////////////////
1296     //
1297     // Class:
1298     //   IAdapter_1_9
1299     //
1300     // Description:
1301     //   Abstract interface for GPU adapter.
1302     //
1303     // New:
1304     // - GetParams:                     To get this adapter parameters
1305     // - GetSubDeviceParams             To get sub device parameters
1306     // - GetEngineParams                To get engine parameters
1307     // - OpenMetricsSubDevice           To open metrics device on given sub device
1308     // - OpenMetricsSubDeviceFromFile   To open metrics device from file on given sub device
1309     //
1310     ///////////////////////////////////////////////////////////////////////////////
1311     class IAdapter_1_9 : public IAdapter_1_8
1312     {
1313     public:
1314         virtual const TAdapterParams_1_9*   GetParams( void ) const;
1315         virtual const TSubDeviceParams_1_9* GetSubDeviceParams( const uint32_t subDeviceIndex );
1316         virtual const TEngineParams_1_9*    GetEngineParams( const uint32_t subDeviceIndex, const uint32_t engineIndex );
1317         virtual TCompletionCode             OpenMetricsSubDevice( const uint32_t subDeviceIndex, IMetricsDevice_1_5** metricsDevice );
1318         virtual TCompletionCode             OpenMetricsSubDeviceFromFile( const uint32_t subDeviceIndex, const char* fileName, void* openParams, IMetricsDevice_1_5** metricsDevice );
1319     };
1320 
1321     ///////////////////////////////////////////////////////////////////////////////
1322     //
1323     // Class:
1324     //   IAdapter_1_10
1325     //
1326     // Description:
1327     //   Abstract interface for GPU adapter.
1328     //
1329     // Updates:
1330     // - OpenMetricsDevice:              Update to 1.10 interface
1331     // - OpenMetricsDeviceFromFile:      Update to 1.10 interface
1332     // - OpenMetricsSubDevice:           Update to 1.10 interface
1333     // - OpenMetricsSubDeviceFromFile:   Update to 1.10 interface
1334     //
1335     ///////////////////////////////////////////////////////////////////////////////
1336     class IAdapter_1_10 : public IAdapter_1_9
1337     {
1338     public:
1339         using IAdapter_1_6::OpenMetricsDevice;
1340         using IAdapter_1_6::OpenMetricsDeviceFromFile;
1341         using IAdapter_1_9::OpenMetricsSubDevice;
1342         using IAdapter_1_9::OpenMetricsSubDeviceFromFile;
1343 
1344         virtual TCompletionCode OpenMetricsDevice( IMetricsDevice_1_10** metricsDevice );
1345         virtual TCompletionCode OpenMetricsDeviceFromFile( const char* fileName, void* openParams, IMetricsDevice_1_10** metricsDevice );
1346         virtual TCompletionCode OpenMetricsSubDevice( const uint32_t subDeviceIndex, IMetricsDevice_1_10** metricsDevice );
1347         virtual TCompletionCode OpenMetricsSubDeviceFromFile( const uint32_t subDeviceIndex, const char* fileName, void* openParams, IMetricsDevice_1_10** metricsDevice );
1348     };
1349 
1350     ///////////////////////////////////////////////////////////////////////////////
1351     //
1352     // Class:
1353     //   IAdapterGroup_1_6
1354     //
1355     // Description:
1356     //   Abstract interface for the GPU adapters root object.
1357     //
1358     // New:
1359     // - GetParams:                     To get this adapter group params
1360     // - GetAdapter:                    To enumerate available GPU adapters
1361     // - Close:                         To close this adapter group
1362     //
1363     ///////////////////////////////////////////////////////////////////////////////
1364     class IAdapterGroup_1_6
1365     {
1366     public:
1367         virtual ~IAdapterGroup_1_6();
1368         virtual const TAdapterGroupParams_1_6* GetParams( void ) const;
1369         virtual IAdapter_1_6*                  GetAdapter( uint32_t index );
1370         virtual TCompletionCode                Close();
1371     };
1372 
1373     ///////////////////////////////////////////////////////////////////////////////
1374     //
1375     // Class:
1376     //   IAdapterGroup_1_8
1377     //
1378     // Description:
1379     //   Abstract interface for the GPU adapters root object.
1380     //
1381     // New:
1382     // - GetAdapter:                    To enumerate available GPU adapters
1383     //
1384     ///////////////////////////////////////////////////////////////////////////////
1385     class IAdapterGroup_1_8 : public IAdapterGroup_1_6
1386     {
1387     public:
1388         virtual IAdapter_1_8* GetAdapter( uint32_t index );
1389     };
1390 
1391     ///////////////////////////////////////////////////////////////////////////////
1392     //
1393     // Class:
1394     //   IAdapterGroup_1_9
1395     //
1396     // Description:
1397     //   Abstract interface for the GPU adapters root object.
1398     //
1399     // New:
1400     // - GetAdapter:                    To enumerate available GPU adapters
1401     //
1402     ///////////////////////////////////////////////////////////////////////////////
1403     class IAdapterGroup_1_9 : public IAdapterGroup_1_8
1404     {
1405     public:
1406         virtual IAdapter_1_9* GetAdapter( uint32_t index );
1407     };
1408 
1409     ///////////////////////////////////////////////////////////////////////////////
1410     //
1411     // Class:
1412     //   IAdapterGroup_1_10
1413     //
1414     // Description:
1415     //   Abstract interface for the GPU adapters root object.
1416     //
1417     // Updates:
1418     // - GetAdapter:                    Update to 1.10 interface
1419     //
1420     ///////////////////////////////////////////////////////////////////////////////
1421     class IAdapterGroup_1_10 : public IAdapterGroup_1_9
1422     {
1423     public:
1424         virtual IAdapter_1_10* GetAdapter( uint32_t index );
1425     };
1426 
1427     //////////////////////////////////////////////////////////////////////////////////
1428     // Latest interfaces and typedef structs versions:
1429     //////////////////////////////////////////////////////////////////////////////////
1430     using IAdapterGroupLatest               = IAdapterGroup_1_10;
1431     using IAdapterLatest                    = IAdapter_1_10;
1432     using IConcurrentGroupLatest            = IConcurrentGroup_1_5;
1433     using IEquationLatest                   = IEquation_1_0;
1434     using IInformationLatest                = IInformation_1_0;
1435     using IMetricLatest                     = IMetric_1_0;
1436     using IMetricSetLatest                  = IMetricSet_1_5;
1437     using IMetricsDeviceLatest              = IMetricsDevice_1_10;
1438     using IOverrideLatest                   = IOverride_1_2;
1439     using TAdapterGroupParamsLatest         = TAdapterGroupParams_1_6;
1440     using TAdapterIdLatest                  = TAdapterId_1_6;
1441     using TAdapterIdLuidLatest              = TAdapterIdLuid_1_6;
1442     using TAdapterIdMajorMinorLatest        = TAdapterIdMajorMinor_1_6;
1443     using TAdapterParamsLatest              = TAdapterParams_1_9;
1444     using TApiSpecificIdLatest              = TApiSpecificId_1_0;
1445     using TApiVersionLatest                 = TApiVersion_1_0;
1446     using TByteArrayLatest                  = TByteArray_1_0;
1447     using TConcurrentGroupParamsLatest      = TConcurrentGroupParams_1_0;
1448     using TDeltaFunctionLatest              = TDeltaFunction_1_0;
1449     using TEngineIdClassInstanceLatest      = TEngineIdClassInstance_1_9;
1450     using TEngineIdLatest                   = TEngineId_1_9;
1451     using TEngineParamsLatest               = TEngineParams_1_9;
1452     using TEquationElementLatest            = TEquationElement_1_0;
1453     using TGlobalSymbolLatest               = TGlobalSymbol_1_0;
1454     using TInformationParamsLatest          = TInformationParams_1_0;
1455     using TMetricParamsLatest               = TMetricParams_1_0;
1456     using TMetricSetParamsLatest            = TMetricSetParams_1_4;
1457     using TMetricsDeviceParamsLatest        = TMetricsDeviceParams_1_2;
1458     using TOverrideParamsLatest             = TOverrideParams_1_2;
1459     using TReadParamsLatest                 = TReadParams_1_0;
1460     using TSetDriverOverrideParamsLatest    = TSetDriverOverrideParams_1_2;
1461     using TSetFrequencyOverrideParamsLatest = TSetFrequencyOverrideParams_1_2;
1462     using TSetOverrideParamsLatest          = TSetOverrideParams_1_2;
1463     using TSetQueryOverrideParamsLatest     = TSetQueryOverrideParams_1_2;
1464     using TSubDeviceParamsLatest            = TSubDeviceParams_1_9;
1465     using TTypedValueLatest                 = TTypedValue_1_0;
1466 
1467 #ifdef __cplusplus
1468     extern "C"
1469     {
1470 #endif
1471 
1472         // [Current] Factory functions
1473         typedef TCompletionCode( MD_STDCALL* OpenAdapterGroup_fn )( IAdapterGroupLatest** adapterGroup );
1474 
1475         // [Legacy] Factory functions
1476         typedef TCompletionCode( MD_STDCALL* OpenMetricsDevice_fn )( IMetricsDeviceLatest** metricsDevice );
1477         typedef TCompletionCode( MD_STDCALL* OpenMetricsDeviceFromFile_fn )( const char* fileName, void* openParams, IMetricsDeviceLatest** metricsDevice );
1478         typedef TCompletionCode( MD_STDCALL* CloseMetricsDevice_fn )( IMetricsDeviceLatest* metricsDevice );
1479         typedef TCompletionCode( MD_STDCALL* SaveMetricsDeviceToFile_fn )( const char* fileName, void* saveParams, IMetricsDeviceLatest* metricsDevice );
1480 
1481 #ifdef __cplusplus
1482     }
1483 #endif
1484 
1485 }; // namespace MetricsDiscovery
1486