Skip to content

Commit 4aed2b7

Browse files
committedNov 29, 2024
Merge pull request #99086 from Calinou/editor-visual-profiler-show-hardware-info
Display CPU and GPU model name in the editor visual profiler
2 parents c2f19e9 + 3e8a24d commit 4aed2b7

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed
 

‎editor/debugger/editor_visual_profiler.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
#include "editor/themes/editor_scale.h"
3838
#include "scene/resources/image_texture.h"
3939

40+
void EditorVisualProfiler::set_hardware_info(const String &p_cpu_name, const String &p_gpu_name) {
41+
cpu_name = p_cpu_name;
42+
gpu_name = p_gpu_name;
43+
queue_redraw();
44+
}
45+
4046
void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
4147
++last_metric;
4248
if (last_metric >= frame_metrics.size()) {
@@ -489,8 +495,8 @@ void EditorVisualProfiler::_graph_tex_draw() {
489495
graph->draw_string(font, Vector2(half_width * 2 - font->get_string_size(limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x - 2, frame_y - 2), limit_str, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75));
490496
}
491497

492-
graph->draw_string(font, Vector2(font->get_string_size("X", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x, font->get_ascent(font_size) + 2), "CPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1));
493-
graph->draw_string(font, Vector2(font->get_string_size("X", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU:", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1));
498+
graph->draw_string(font, Vector2(font->get_string_size("X", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x, font->get_ascent(font_size) + 2), "CPU: " + cpu_name, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75));
499+
graph->draw_string(font, Vector2(font->get_string_size("X", HORIZONTAL_ALIGNMENT_LEFT, -1, font_size).x + graph->get_size().width / 2, font->get_ascent(font_size) + 2), "GPU: " + gpu_name, HORIZONTAL_ALIGNMENT_LEFT, -1, font_size, color * Color(1, 1, 1, 0.75));
494500
}
495501

496502
void EditorVisualProfiler::_graph_tex_mouse_exit() {

‎editor/debugger/editor_visual_profiler.h

+4
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ class EditorVisualProfiler : public VBoxContainer {
9898

9999
float graph_limit = 1000.0f / 60;
100100

101+
String cpu_name;
102+
String gpu_name;
103+
101104
bool seeking = false;
102105

103106
Timer *frame_delay = nullptr;
@@ -136,6 +139,7 @@ class EditorVisualProfiler : public VBoxContainer {
136139
static void _bind_methods();
137140

138141
public:
142+
void set_hardware_info(const String &p_cpu_name, const String &p_gpu_name);
139143
void add_frame_metric(const Metric &p_metric);
140144
void set_enabled(bool p_enable);
141145
void set_profiling(bool p_profiling);

‎editor/debugger/script_editor_debugger.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
513513
frame_data.write[i] = p_data[i];
514514
}
515515
performance_profiler->add_profile_frame(frame_data);
516+
} else if (p_msg == "visual:hardware_info") {
517+
const String cpu_name = p_data[0];
518+
const String gpu_name = p_data[1];
519+
visual_profiler->set_hardware_info(cpu_name, gpu_name);
516520
} else if (p_msg == "visual:profile_frame") {
517521
ServersDebugger::VisualProfilerFrame frame;
518522
frame.deserialize(p_data);

‎servers/debugger/servers_debugger.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,12 @@ class ServersDebugger::VisualProfiler : public EngineProfiler {
370370
public:
371371
void toggle(bool p_enable, const Array &p_opts) {
372372
RS::get_singleton()->set_frame_profiling_enabled(p_enable);
373+
374+
// Send hardware information from the remote device so that it's accurate for remote debugging.
375+
Array hardware_info;
376+
hardware_info.push_back(OS::get_singleton()->get_processor_name());
377+
hardware_info.push_back(RenderingServer::get_singleton()->get_video_adapter_name());
378+
EngineDebugger::get_singleton()->send_message("visual:hardware_info", hardware_info);
373379
}
374380

375381
void add(const Array &p_data) {}

0 commit comments

Comments
 (0)
Please sign in to comment.