载入中...
搜索中...
未找到
Profiler.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
5#include "common/Capability.h"
6#include "common/GpuTimer.h"
7#include "common/Module.h"
8#include "common/Profile.h"
10#include "common/Result.h"
11
12#include <squirrel.h>
13
14#include <cstdint>
15#include <string>
16#include <vector>
17
18namespace ssq {
19class Object;
20}
21
22namespace eve::profiler {
23
26 std::string module;
27 std::string name;
28 std::string thread;
29 double selfMs = 0.0;
30 double totalMs = 0.0;
31 int count = 0;
32 int depth = 0;
33};
34
37 uint64_t sequence = 0;
38 double cpuFrameMs = 0.0;
39 double gpuFrameMs = 0.0;
40 bool gpuTimingAvailable = false;
41 std::vector<ProfilerZoneSnapshot> zones;
42};
43
68public:
71 Profiler();
73 ~Profiler() override;
74
76 void setEnabled(bool on);
78 bool enabled() const;
80 void reset();
81
83 void beginFrame();
85 void endFrame();
86
91 void begin(const char* name);
93 void end();
94
96 bool hasFrame() const;
98 float frameMs() const;
100 float gpuFrameMs() const;
108 [[nodiscard]] eve::Result<ProfilerFrameSnapshot> captureFrame() const;
110 std::string textReport() const;
116 ssq::Object capture();
117
118 // IRenderTracer: route render passes into the core as "graphics" zones and
119 // drive automatic per-frame aggregation from the render frame boundary.
121 void frameBegin() override;
123 void frameEnd() override;
125 void passBegin(const char* name) override;
127 void passEnd(const char* name) override;
129 void draw(const char* api, const char* detail) override {}
130
131private:
133 void ensureGpuTimer() const;
134
135 int64_t frameBeginNs_ = 0;
136 float frameMs_ = 0.f;
137 uint64_t captureSequence_ = 0;
138 HSQUIRRELVM vm_ = nullptr;
140};
141
149
150} // namespace eve::profiler
struct SQVM * HSQUIRRELVM
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
std::string name
float begin
int detail
Move-only, checked operation results for the common layer.
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Move-only operation result carrying either a value or Status.
Definition Result.h:155
One-shot borrowed capability pointer for composition roots and hot paths.
Definition Capability.h:107
Optional render-pipeline tracer. Graphics / RenderSystem call the rt* helpers; when no tracer is inst...
Definition RenderTrace.h:14
Script-facing wrapper around the engine-wide profiler core (eve::prof, see common/Profile....
Definition Profiler.h:67
void draw(const char *api, const char *detail) override
Draws .
Definition Profiler.h:129
void registerProfilerCapabilities()
Publish the read-only profiler capability (eve::IProfilerQuery).
EVEngine ECS 集成层:底层实现使用 sunxfancy/ECS.hpp https://github.com/sunxfancy/ECS.hpp
Definition ECS.h:14
bool enabled
Owning CPU/GPU profiler snapshot safe to retain across later frames.
Definition Profiler.h:36
std::vector< ProfilerZoneSnapshot > zones
Definition Profiler.h:41
One owning profiler row copied from the last completed frame.
Definition Profiler.h:25
std::string std::string name
Definition Profiler.h:27