Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/OpenGL/GLProfiler.h
10523 views
1
#pragma once
2
3
#include <vector>
4
#include <string>
5
#include <cstdint>
6
7
#include "Common/GPU/OpenGL/GLCommon.h"
8
#include "Common/GPU/OpenGL/gl3stub.h"
9
10
// Simple scoped based profiler for OpenGL, similar to VulkanProfiler.
11
// Uses GL_EXT_disjoint_timer_query (GLES) or GL_ARB_timer_query (desktop GL).
12
// Put the whole thing in a FrameData to allow for overlap.
13
14
struct GLProfilerScope {
15
char name[52]; // to make a struct size of 64, just because
16
int startQueryId;
17
int endQueryId;
18
int level;
19
};
20
21
class GLProfiler {
22
public:
23
void Init();
24
void Shutdown();
25
26
void BeginFrame();
27
28
void Begin(const char *fmt, ...)
29
#ifdef __GNUC__
30
__attribute__((format(printf, 2, 3)))
31
#endif
32
;
33
void End();
34
35
void SetEnabledPtr(bool *enabledPtr) {
36
enabledPtr_ = enabledPtr;
37
}
38
39
bool IsSupported() const { return supported_; }
40
41
private:
42
bool supported_ = false;
43
bool firstFrame_ = true;
44
bool *enabledPtr_ = nullptr;
45
46
std::vector<GLuint> queries_;
47
std::vector<GLProfilerScope> scopes_;
48
int numQueries_ = 0;
49
50
std::vector<size_t> scopeStack_;
51
52
static const int MAX_QUERY_COUNT = 1024;
53
};
54
55