Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
stenzek
GitHub Repository: stenzek/duckstation
Path: blob/master/dep/winpixeventruntime/include/WinPixEventRuntime/pix3.h
4261 views
1
// Copyright (c) Microsoft Corporation. All rights reserved.
2
3
/*==========================================================================;
4
*
5
* Copyright (C) Microsoft Corporation. All Rights Reserved.
6
*
7
* File: pix3.h
8
* Content: PIX include file
9
*
10
****************************************************************************/
11
#pragma once
12
13
#ifndef _PIX3_H_
14
#define _PIX3_H_
15
16
#include <sal.h>
17
18
#ifndef __cplusplus
19
#error "Only C++ files can include pix3.h. C is not supported."
20
#endif
21
22
#if !defined(USE_PIX_SUPPORTED_ARCHITECTURE)
23
#if defined(_M_X64) || defined(USE_PIX_ON_ALL_ARCHITECTURES) || defined(_M_ARM64)
24
#define USE_PIX_SUPPORTED_ARCHITECTURE
25
#endif
26
#endif
27
28
#if !defined(USE_PIX)
29
#if defined(USE_PIX_SUPPORTED_ARCHITECTURE) && (defined(_DEBUG) || DBG || defined(PROFILE) || defined(PROFILE_BUILD)) && !defined(_PREFAST_)
30
#define USE_PIX
31
#endif
32
#endif
33
34
#if defined(USE_PIX) && !defined(USE_PIX_SUPPORTED_ARCHITECTURE)
35
#pragma message("Warning: Pix markers are only supported on AMD64 and ARM64")
36
#endif
37
38
39
// These flags are used by both PIXBeginCapture and PIXGetCaptureState
40
#define PIX_CAPTURE_TIMING (1 << 0)
41
#define PIX_CAPTURE_GPU (1 << 1)
42
#define PIX_CAPTURE_FUNCTION_SUMMARY (1 << 2)
43
#define PIX_CAPTURE_FUNCTION_DETAILS (1 << 3)
44
#define PIX_CAPTURE_CALLGRAPH (1 << 4)
45
#define PIX_CAPTURE_INSTRUCTION_TRACE (1 << 5)
46
#define PIX_CAPTURE_SYSTEM_MONITOR_COUNTERS (1 << 6)
47
#define PIX_CAPTURE_VIDEO (1 << 7)
48
#define PIX_CAPTURE_AUDIO (1 << 8)
49
#define PIX_CAPTURE_RESERVED (1 << 15)
50
51
union PIXCaptureParameters
52
{
53
enum PIXCaptureStorage
54
{
55
Memory = 0,
56
};
57
58
struct GpuCaptureParameters
59
{
60
PCWSTR FileName;
61
} GpuCaptureParameters;
62
63
struct TimingCaptureParameters
64
{
65
PCWSTR FileName;
66
UINT32 MaximumToolingMemorySizeMb;
67
PIXCaptureStorage CaptureStorage;
68
69
BOOL CaptureGpuTiming;
70
71
BOOL CaptureCallstacks;
72
BOOL CaptureCpuSamples;
73
UINT32 CpuSamplesPerSecond;
74
75
BOOL CaptureFileIO;
76
77
BOOL CaptureVirtualAllocEvents;
78
BOOL CaptureHeapAllocEvents;
79
BOOL CaptureXMemEvents; // Xbox only
80
BOOL CapturePixMemEvents; // Xbox only
81
} TimingCaptureParameters;
82
};
83
84
typedef PIXCaptureParameters* PPIXCaptureParameters;
85
86
#if defined(XBOX) || defined(_XBOX_ONE) || defined(_DURANGO) || defined(_GAMING_XBOX) || defined(_GAMING_XBOX_SCARLETT)
87
#include "pix3_xbox.h"
88
#else
89
#include "pix3_win.h"
90
#endif
91
92
#if defined(USE_PIX_SUPPORTED_ARCHITECTURE) && (defined(USE_PIX) || defined(USE_PIX_RETAIL))
93
94
#define PIX_EVENTS_ARE_TURNED_ON
95
96
#include "PIXEventsCommon.h"
97
#include "PIXEvents.h"
98
99
#ifdef USE_PIX
100
// Starts a programmatically controlled capture.
101
// captureFlags uses the PIX_CAPTURE_* family of flags to specify the type of capture to take
102
extern "C" HRESULT WINAPI PIXBeginCapture2(DWORD captureFlags, _In_opt_ const PPIXCaptureParameters captureParameters);
103
inline HRESULT PIXBeginCapture(DWORD captureFlags, _In_opt_ const PPIXCaptureParameters captureParameters) { return PIXBeginCapture2(captureFlags, captureParameters); }
104
105
// Stops a programmatically controlled capture
106
// If discard == TRUE, the captured data is discarded
107
// If discard == FALSE, the captured data is saved
108
// discard parameter is not supported on Windows
109
extern "C" HRESULT WINAPI PIXEndCapture(BOOL discard);
110
111
extern "C" DWORD WINAPI PIXGetCaptureState();
112
113
extern "C" void WINAPI PIXReportCounter(_In_ PCWSTR name, float value);
114
115
#endif // USE_PIX
116
117
#endif // (USE_PIX_SUPPORTED_ARCHITECTURE) && (USE_PIX || USE_PIX_RETAIL)
118
119
#if !defined(USE_PIX_SUPPORTED_ARCHITECTURE) || !defined(USE_PIX)
120
121
// Eliminate these APIs when not using PIX
122
inline HRESULT PIXBeginCapture2(DWORD, _In_opt_ const PIXCaptureParameters*) { return S_OK; }
123
inline HRESULT PIXBeginCapture(DWORD, _In_opt_ const PIXCaptureParameters*) { return S_OK; }
124
inline HRESULT PIXEndCapture(BOOL) { return S_OK; }
125
inline HRESULT PIXGpuCaptureNextFrames(PCWSTR, UINT32) { return S_OK; }
126
inline HRESULT PIXSetTargetWindow(HWND) { return S_OK; }
127
inline HRESULT PIXForceD3D11On12() { return S_OK; }
128
inline HRESULT WINAPI PIXSetHUDOptions(PIXHUDOptions) { return S_OK; }
129
inline bool WINAPI PIXIsAttachedForGpuCapture() { return false; }
130
inline HINSTANCE WINAPI PIXOpenCaptureInUI(PCWSTR) { return 0; }
131
inline HMODULE PIXLoadLatestWinPixGpuCapturerLibrary() { return nullptr; }
132
inline HMODULE PIXLoadLatestWinPixTimingCapturerLibrary() { return nullptr; }
133
inline DWORD PIXGetCaptureState() { return 0; }
134
inline void PIXReportCounter(_In_ PCWSTR, float) {}
135
inline void PIXNotifyWakeFromFenceSignal(_In_ HANDLE) {}
136
137
#if !defined(USE_PIX_RETAIL)
138
139
inline void PIXBeginEvent(UINT64, _In_ PCSTR, ...) {}
140
inline void PIXBeginEvent(UINT64, _In_ PCWSTR, ...) {}
141
inline void PIXBeginEvent(void*, UINT64, _In_ PCSTR, ...) {}
142
inline void PIXBeginEvent(void*, UINT64, _In_ PCWSTR, ...) {}
143
inline void PIXEndEvent() {}
144
inline void PIXEndEvent(void*) {}
145
inline void PIXSetMarker(UINT64, _In_ PCSTR, ...) {}
146
inline void PIXSetMarker(UINT64, _In_ PCWSTR, ...) {}
147
inline void PIXSetMarker(void*, UINT64, _In_ PCSTR, ...) {}
148
inline void PIXSetMarker(void*, UINT64, _In_ PCWSTR, ...) {}
149
inline void PIXBeginRetailEvent(void*, UINT64, _In_ PCSTR, ...) {}
150
inline void PIXBeginRetailEvent(void*, UINT64, _In_ PCWSTR, ...) {}
151
inline void PIXEndRetailEvent(void*) {}
152
inline void PIXSetRetailMarker(void*, UINT64, _In_ PCSTR, ...) {}
153
inline void PIXSetRetailMarker(void*, UINT64, _In_ PCWSTR, ...) {}
154
inline void PIXScopedEvent(UINT64, _In_ PCSTR, ...) {}
155
inline void PIXScopedEvent(UINT64, _In_ PCWSTR, ...) {}
156
inline void PIXScopedEvent(void*, UINT64, _In_ PCSTR, ...) {}
157
inline void PIXScopedEvent(void*, UINT64, _In_ PCWSTR, ...) {}
158
159
#endif // !USE_PIX_RETAIL
160
161
// don't show warnings about expressions with no effect
162
#pragma warning(disable:4548)
163
#pragma warning(disable:4555)
164
165
#endif // !USE_PIX_SUPPORTED_ARCHITECTURE || !USE_PIX
166
167
// Use these functions to specify colors to pass as metadata to a PIX event/marker API.
168
// Use PIX_COLOR() to specify a particular color for an event.
169
// Or, use PIX_COLOR_INDEX() to specify a set of unique event categories, and let PIX choose
170
// the colors to represent each category.
171
inline UINT PIX_COLOR(BYTE r, BYTE g, BYTE b) { return 0xff000000 | (r << 16) | (g << 8) | b; }
172
inline UINT PIX_COLOR_INDEX(BYTE i) { return i; }
173
const UINT PIX_COLOR_DEFAULT = PIX_COLOR_INDEX(0);
174
175
#endif // _PIX3_H_
176
177