| 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 |
#pragma once |
| 32 |
|
| 33 |
#include "servers/rendering/rendering_server.h" |
| 34 |
|
| 35 |
class ServersDebugger { |
| 36 |
public: |
| 37 |
|
| 38 |
struct ResourceInfo { |
| 39 |
String path; |
| 40 |
String format; |
| 41 |
String type; |
| 42 |
RID id; |
| 43 |
int vram = 0; |
| 44 |
bool operator<(const ResourceInfo &p_img) const { return vram == p_img.vram ? id < p_img.id : vram > p_img.vram; } |
| 45 |
}; |
| 46 |
|
| 47 |
struct ResourceUsage { |
| 48 |
List<ResourceInfo> infos; |
| 49 |
|
| 50 |
Array serialize(); |
| 51 |
bool deserialize(const Array &p_arr); |
| 52 |
}; |
| 53 |
|
| 54 |
|
| 55 |
struct ScriptFunctionSignature { |
| 56 |
StringName name; |
| 57 |
int id = -1; |
| 58 |
|
| 59 |
Array serialize(); |
| 60 |
bool deserialize(const Array &p_arr); |
| 61 |
}; |
| 62 |
|
| 63 |
struct ScriptFunctionInfo { |
| 64 |
StringName name; |
| 65 |
int sig_id = -1; |
| 66 |
int call_count = 0; |
| 67 |
double self_time = 0; |
| 68 |
double total_time = 0; |
| 69 |
double internal_time = 0; |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
struct ServerFunctionInfo { |
| 74 |
StringName name; |
| 75 |
double time = 0; |
| 76 |
}; |
| 77 |
|
| 78 |
struct ServerInfo { |
| 79 |
StringName name; |
| 80 |
List<ServerFunctionInfo> functions; |
| 81 |
}; |
| 82 |
|
| 83 |
struct ServersProfilerFrame { |
| 84 |
int frame_number = 0; |
| 85 |
double frame_time = 0; |
| 86 |
double process_time = 0; |
| 87 |
double physics_time = 0; |
| 88 |
double physics_frame_time = 0; |
| 89 |
double script_time = 0; |
| 90 |
List<ServerInfo> servers; |
| 91 |
Vector<ScriptFunctionInfo> script_functions; |
| 92 |
|
| 93 |
Array serialize(); |
| 94 |
bool deserialize(const Array &p_arr); |
| 95 |
}; |
| 96 |
|
| 97 |
|
| 98 |
struct VisualProfilerFrame { |
| 99 |
uint64_t frame_number = 0; |
| 100 |
Vector<RS::FrameProfileArea> areas; |
| 101 |
|
| 102 |
Array serialize(); |
| 103 |
bool deserialize(const Array &p_arr); |
| 104 |
}; |
| 105 |
|
| 106 |
private: |
| 107 |
class ScriptsProfiler; |
| 108 |
class ServersProfiler; |
| 109 |
class VisualProfiler; |
| 110 |
|
| 111 |
double last_draw_time = 0.0; |
| 112 |
Ref<ServersProfiler> servers_profiler; |
| 113 |
Ref<VisualProfiler> visual_profiler; |
| 114 |
|
| 115 |
static ServersDebugger *singleton; |
| 116 |
|
| 117 |
static Error _capture(void *p_user, const String &p_cmd, const Array &p_data, bool &r_captured); |
| 118 |
|
| 119 |
void _send_resource_usage(); |
| 120 |
String _get_resource_type_from_path(const String &p_path); |
| 121 |
|
| 122 |
ServersDebugger(); |
| 123 |
|
| 124 |
public: |
| 125 |
static void initialize(); |
| 126 |
static void deinitialize(); |
| 127 |
|
| 128 |
~ServersDebugger(); |
| 129 |
}; |