forked from GPUOpen-Tools/gpu_performance_api
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGLGPAPass.h
148 lines (117 loc) · 5.65 KB
/
GLGPAPass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
//==============================================================================
// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
/// \author AMD Developer Tools Team
/// \file
/// \brief GL GPA Pass Object Header
//==============================================================================
#ifndef _GL_GPA_PASS_H_
#define _GL_GPA_PASS_H_
// GPA Common
#include "GPAPass.h"
#include "IGPACommandList.h"
#include "GLInclude.h"
using GLPerfMonitorId = GLuint; ///< type alias for GL perf monitor id
/// GLCounter Struct
/// structure used to store data that is needed to retrieve and store the
/// results for a counter.
struct GLCounter
{
/// Initializes a new instance of the GLCounter class
GLCounter()
{
m_counterID = 0;
m_counterType = 0;
m_counterGroup = 0;
m_counterIndex = 0;
m_isCounterResultReady = false;
}
GLuint m_counterID; ///< ID that is calculated in the CounterDefinition files
GLenum m_counterType; ///< data type that GL specifies the result will be
GLuint m_counterGroup; ///< group that this counter is in
GLuint m_counterIndex; ///< index to this counter within its group
bool m_isCounterResultReady; ///< indicates whether the result has been stored in the pCounterResult buffer
};
/// Class for OpenGL gpa pass
class GLGPAPass : public GPAPass
{
public:
/// Constructor
/// \param[in] pGpaSession GPA session object pointer
/// \param[in] passIndex pass index
/// \param[in] counterSource counter source
/// \param[in] pCounterScheduler counter scheduler
/// \param[in] pCounterAccessor counter accessor
GLGPAPass(IGPASession* pGpaSession,
PassIndex passIndex,
GPACounterSource counterSource,
IGPACounterScheduler* pCounterScheduler,
const IGPACounterAccessor* pCounterAccessor);
/// Destructor
~GLGPAPass();
/// \copydoc GPAPass::CreateAPISpecificSample
GPASample* CreateAPISpecificSample(IGPACommandList* pCmdList,
GpaSampleType sampleType,
ClientSampleId sampleId) override final;
/// \copydoc GPAPass::ContinueSample
bool ContinueSample(ClientSampleId srcSampleId, IGPACommandList* pPrimaryGpaCmdList) override final;
/// \copydoc GPAPass::CreateAPISpecificCommandList
IGPACommandList* CreateAPISpecificCommandList(void* pCmd,
CommandListId commandListId,
GPA_Command_List_Type cmdType) override final;
/// \copydoc GPAPass::EndSample
bool EndSample(IGPACommandList* pCmdList) override final;
/// Returns the GL performance monitor, it may return if cached monitor is available otherwise returns by creating one.
/// \param[out] glPerfMonitorId cached/new performance moniotr Id
/// \return true upon successful operation otherwise false
bool GetPerfMonitor(GLPerfMonitorId& glPerfMonitorId);
/// Marks the data for the passed performance moniotr to be collected and it can be used as for cache
/// \param[in] glPerfMonitorId performance monitor Id
void MarkDataCollected(const GLPerfMonitorId glPerfMonitorId);
/// Returns the GL counter in the pass
/// \param[in] counterGroup group of the counter
/// \param[in] counterIndex index of the counter
/// \param[out] indexOfCounterWithinPass index of the counter within pass
/// \return pointer to the GL counter if found otherwise nullptr
const GLCounter* GetGLCounter(const GLuint& counterGroup,
const GLuint& counterIndex,
unsigned int& indexOfCounterWithinPass) const;
private:
/// Intializes the counter info for the passed performance Id
/// \param[in] glPerfMonitorId performance monitor Id
/// \return true upon successful operation otherwise false
bool InitializeCounters(const GLPerfMonitorId& glPerfMonitorId);
/// Class for handling perf monitor
class GLPerfMonitor
{
public:
/// Constructor
GLPerfMonitor();
/// Initializes the perf monitor id
/// \return true upon successful operation otherwise false
bool Initialize();
/// Returns the perf monitor Id
/// \return GL perf monitor Id
GLPerfMonitorId GetPerfMonitorId() const;
/// Checks whether or not the data has been collected from the monitor
/// \return true upon successful operation otherwise false
bool IsDataCollected() const;
/// Adds/increments the reference of the monitor
/// \return value of the monitor reference after adding
unsigned int AddRef();
/// Release/decrements the reference of the monitor
/// \return value of the reference after releasing
unsigned int Release();
/// Deletes the performance monitor in the driver if it's not being used
/// \param[in] forceClear flag indicating whether the monitor needs to be deleted even if it's data is not populated
/// \return true upon successful operation otherwise false
bool Clear(bool forceClear = false);
/// Destructor
~GLPerfMonitor() = default;
private:
GLPerfMonitorId m_glPerfMonitorId; ///< Perf Monitor Id
unsigned int m_refCount; ///< reference count
};
std::map<GLPerfMonitorId, GLPerfMonitor> m_glPerfMonitorInfoList; ///< Map of perf monitor Id and GLPerfMonitor
mutable std::vector<GLCounter> m_glCounterList; ///< List of counters in the pass
};
#endif // _GL_GPA_PASS_H_