Skip to content

Commit

Permalink
Merge pull request godotengine#99086 from Calinou/editor-visual-profi…
Browse files Browse the repository at this point in the history
…ler-show-hardware-info

Display CPU and GPU model name in the editor visual profiler
  • Loading branch information
akien-mga committed Nov 29, 2024
2 parents c2f19e9 + 3e8a24d commit 4aed2b7
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
10 changes: 8 additions & 2 deletions editor/debugger/editor_visual_profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
#include "editor/themes/editor_scale.h"
#include "scene/resources/image_texture.h"

void EditorVisualProfiler::set_hardware_info(const String &p_cpu_name, const String &p_gpu_name) {
cpu_name = p_cpu_name;
gpu_name = p_gpu_name;
queue_redraw();
}

void EditorVisualProfiler::add_frame_metric(const Metric &p_metric) {
++last_metric;
if (last_metric >= frame_metrics.size()) {
Expand Down Expand Up @@ -489,8 +495,8 @@ void EditorVisualProfiler::_graph_tex_draw() {
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));
}

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));
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));
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));
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));
}

void EditorVisualProfiler::_graph_tex_mouse_exit() {
Expand Down
4 changes: 4 additions & 0 deletions editor/debugger/editor_visual_profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ class EditorVisualProfiler : public VBoxContainer {

float graph_limit = 1000.0f / 60;

String cpu_name;
String gpu_name;

bool seeking = false;

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

public:
void set_hardware_info(const String &p_cpu_name, const String &p_gpu_name);
void add_frame_metric(const Metric &p_metric);
void set_enabled(bool p_enable);
void set_profiling(bool p_profiling);
Expand Down
4 changes: 4 additions & 0 deletions editor/debugger/script_editor_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, uint64_t p_thread
frame_data.write[i] = p_data[i];
}
performance_profiler->add_profile_frame(frame_data);
} else if (p_msg == "visual:hardware_info") {
const String cpu_name = p_data[0];
const String gpu_name = p_data[1];
visual_profiler->set_hardware_info(cpu_name, gpu_name);
} else if (p_msg == "visual:profile_frame") {
ServersDebugger::VisualProfilerFrame frame;
frame.deserialize(p_data);
Expand Down
6 changes: 6 additions & 0 deletions servers/debugger/servers_debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,12 @@ class ServersDebugger::VisualProfiler : public EngineProfiler {
public:
void toggle(bool p_enable, const Array &p_opts) {
RS::get_singleton()->set_frame_profiling_enabled(p_enable);

// Send hardware information from the remote device so that it's accurate for remote debugging.
Array hardware_info;
hardware_info.push_back(OS::get_singleton()->get_processor_name());
hardware_info.push_back(RenderingServer::get_singleton()->get_video_adapter_name());
EngineDebugger::get_singleton()->send_message("visual:hardware_info", hardware_info);
}

void add(const Array &p_data) {}
Expand Down

0 comments on commit 4aed2b7

Please sign in to comment.