BRE12
pix3.h
1 /*==========================================================================;
2  *
3  * Copyright (C) Microsoft Corporation. All Rights Reserved.
4  *
5  * File: pix3.h
6  * Content: PIX include file
7  *
8  ****************************************************************************/
9 #pragma once
10 
11 #ifndef _PIX3_H_
12 #define _PIX3_H_
13 
14 #include <sal.h>
15 
16 #ifndef __cplusplus
17 #error "Only C++ files can include pix.h. C is not supported."
18 #endif
19 
20 #if defined(XBOX) || defined(_XBOX_ONE) || defined(_DURANGO)
21 #include "pix3_xbox.h"
22 #else
23 #include "pix3_win.h"
24 #endif
25 
26 //
27 // The PIX event/marker APIs compile to nothing on retail builds and on x86 builds
28 //
29 #if (!defined(USE_PIX)) && ((defined(_DEBUG) || DBG || (defined(PROFILE) && !defined(FASTCAP)) || defined(PROFILE_BUILD)) && !defined(i386) && defined(_AMD64_) && !defined(_PREFAST_))
30 #define USE_PIX
31 #endif
32 
33 #if defined(USE_PIX) && !defined(_AMD64_)
34 #pragma message("Warning: Pix markers are only supported on AMD64")
35 #endif
36 
37 // These flags are used by both PIXBeginCapture and PIXGetCaptureState
38 #define PIX_CAPTURE_TIMING (1 << 0)
39 #define PIX_CAPTURE_GPU (1 << 1)
40 #define PIX_CAPTURE_FUNCTION_SUMMARY (1 << 2)
41 #define PIX_CAPTURE_FUNCTION_DETAILS (1 << 3)
42 #define PIX_CAPTURE_CALLGRAPH (1 << 4)
43 #define PIX_CAPTURE_INSTRUCTION_TRACE (1 << 5)
44 #define PIX_CAPTURE_SYSTEM_MONITOR_COUNTERS (1 << 6)
45 #define PIX_CAPTURE_VIDEO (1 << 7)
46 #define PIX_CAPTURE_AUDIO (1 << 8)
47 
48 typedef union PIXCaptureParameters
49 {
51  {
52  PVOID reserved;
54 
56  {
57  BOOL CaptureCallstacks;
58  PWSTR FileName;
60 
62 
63 
64 
65 #if defined (USE_PIX) && defined(_AMD64_)
66 
67 #include "PIXEventsCommon.h"
68 #include "PIXEventsGenerated.h"
69 
70 // Starts a programmatically controlled capture.
71 // captureFlags uses the PIX_CAPTURE_* family of flags to specify the type of capture to take
72 extern "C" HRESULT WINAPI PIXBeginCapture(DWORD captureFlags, _In_opt_ const PPIXCaptureParameters captureParameters);
73 
74 // Stops a programmatically controlled capture
75 // If discard == TRUE, the captured data is discarded
76 // If discard == FALSE, the captured data is saved
77 extern "C" HRESULT WINAPI PIXEndCapture(BOOL discard);
78 
79 extern "C" DWORD WINAPI PIXGetCaptureState();
80 
81 extern "C" void WINAPI PIXReportCounter(_In_ PCWSTR name, float value);
82 
83 #else
84 
85 // Eliminate these APIs when not using PIX
86 inline HRESULT PIXBeginCapture(DWORD, _In_opt_ const PIXCaptureParameters*) { return S_OK; }
87 inline HRESULT PIXEndCapture(BOOL) { return S_OK; }
88 inline DWORD PIXGetCaptureState() { return 0; }
89 inline void PIXReportCounter(_In_ PCWSTR, float) {}
90 
91 inline void PIXBeginEvent(UINT64, _In_ PCSTR, ...) {}
92 inline void PIXBeginEvent(UINT64, _In_ PCWSTR, ...) {}
93 inline void PIXBeginEvent(void*, UINT64, _In_ PCSTR, ...) {}
94 inline void PIXBeginEvent(void*, UINT64, _In_ PCWSTR, ...) {}
95 inline void PIXEndEvent() {}
96 inline void PIXEndEvent(void*) {}
97 inline void PIXSetMarker(UINT64, _In_ PCSTR, ...) {}
98 inline void PIXSetMarker(UINT64, _In_ PCWSTR, ...) {}
99 inline void PIXSetMarker(void*, UINT64, _In_ PCSTR, ...) {}
100 inline void PIXSetMarker(void*, UINT64, _In_ PCWSTR, ...) {}
101 inline void PIXScopedEvent(UINT64, _In_ PCSTR, ...) {}
102 inline void PIXScopedEvent(UINT64, _In_ PCWSTR, ...) {}
103 inline void PIXScopedEvent(void*, UINT64, _In_ PCSTR, ...) {}
104 inline void PIXScopedEvent(void*, UINT64, _In_ PCWSTR, ...) {}
105 
106 // don't show warnings about expressions with no effect
107 #pragma warning(disable:4548)
108 #pragma warning(disable:4555)
109 
110 #endif // USE_PIX
111 
112 // Use these functions to specify colors to pass as metadata to a PIX event/marker API.
113 // Use PIX_COLOR() to specify a particular color for an event.
114 // Or, use PIX_COLOR_INDEX() to specify a set of unique event categories, and let PIX choose
115 // the colors to represent each category.
116 inline UINT PIX_COLOR(BYTE r, BYTE g, BYTE b) { return 0xff000000 | (r << 16) | (g << 8) | b; }
117 inline UINT PIX_COLOR_INDEX(BYTE i) { return i; }
118 const UINT PIX_COLOR_DEFAULT = PIX_COLOR_INDEX(0);
119 
120 #endif // _PIX3_H_
Definition: pix3.h:48