CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Common/GPU/Vulkan/VulkanProfiler.h
Views: 1401
1
#pragma once
2
3
#include <vector>
4
#include <string>
5
6
#include "VulkanLoader.h"
7
8
// Simple scoped based profiler, initially meant for instant one-time tasks like texture uploads
9
// etc. Supports recursive scopes. Scopes are not yet tracked separately for each command buffer.
10
// For the pass profiler in VulkanQueueRunner, a purpose-built separate profiler that can take only
11
// one measurement between each pass makes more sense.
12
//
13
// Put the whole thing in a FrameData to allow for overlap.
14
15
struct ProfilerScope {
16
char name[52]; // to make a struct size of 64, just because
17
int startQueryId;
18
int endQueryId;
19
int level;
20
};
21
22
class VulkanContext;
23
24
25
class VulkanProfiler {
26
public:
27
void Init(VulkanContext *vulkan);
28
void Shutdown();
29
30
void BeginFrame(VulkanContext *vulkan, VkCommandBuffer firstCommandBuffer);
31
32
void Begin(VkCommandBuffer cmdBuf, VkPipelineStageFlagBits stage, const char *fmt, ...)
33
#ifdef __GNUC__
34
__attribute__((format(printf, 4, 5)))
35
#endif
36
;
37
void End(VkCommandBuffer cmdBuf, VkPipelineStageFlagBits stage);
38
39
void SetEnabledPtr(bool *enabledPtr) {
40
enabledPtr_ = enabledPtr;
41
}
42
private:
43
VulkanContext *vulkan_;
44
45
VkQueryPool queryPool_ = VK_NULL_HANDLE;
46
std::vector<ProfilerScope> scopes_;
47
int numQueries_ = 0;
48
bool firstFrame_ = true;
49
bool *enabledPtr_ = nullptr;
50
int validBits_ = 0;
51
52
std::vector<size_t> scopeStack_;
53
54
const int MAX_QUERY_COUNT = 1024;
55
};
56
57