mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-12 10:05:01 +02:00
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
#include <string>
|
|
#include <cstdint>
|
|
|
|
#include "Common/CommonFuncs.h"
|
|
#include "Common/GPU/OpenGL/GLCommon.h"
|
|
#include "Common/GPU/OpenGL/gl3stub.h"
|
|
|
|
// Simple scoped based profiler for OpenGL, similar to VulkanProfiler.
|
|
// Uses GL_EXT_disjoint_timer_query (GLES) or GL_ARB_timer_query (desktop GL).
|
|
// Put the whole thing in a FrameData to allow for overlap.
|
|
|
|
struct GLProfilerScope {
|
|
char name[52]; // to make a struct size of 64, just because
|
|
int startQueryId;
|
|
int endQueryId;
|
|
int level;
|
|
};
|
|
|
|
class GLProfiler {
|
|
public:
|
|
void Init();
|
|
void Shutdown();
|
|
|
|
void BeginFrame();
|
|
|
|
ATTR_FORMAT_PRINTF(2, 3)
|
|
void Begin(MSVC_FORMAT_PRINTF const char *fmt, ...);
|
|
void End();
|
|
|
|
void SetEnabledPtr(bool *enabledPtr) {
|
|
enabledPtr_ = enabledPtr;
|
|
}
|
|
|
|
bool IsSupported() const { return supported_; }
|
|
|
|
private:
|
|
bool supported_ = false;
|
|
bool firstFrame_ = true;
|
|
bool *enabledPtr_ = nullptr;
|
|
|
|
std::vector<GLuint> queries_;
|
|
std::vector<GLProfilerScope> scopes_;
|
|
int numQueries_ = 0;
|
|
|
|
std::vector<size_t> scopeStack_;
|
|
|
|
static const int MAX_QUERY_COUNT = 1024;
|
|
};
|