feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -30,11 +30,13 @@
|
|||
|
||||
#include "editor_profiler.h"
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "core/io/image.h"
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_string_names.h"
|
||||
#include "editor/gui/editor_run_bar.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "editor/themes/editor_theme_manager.h"
|
||||
#include "scene/gui/check_box.h"
|
||||
#include "scene/gui/flow_container.h"
|
||||
#include "scene/resources/image_texture.h"
|
||||
|
||||
void EditorProfiler::_make_metric_ptrs(Metric &m) {
|
||||
|
|
@ -150,6 +152,11 @@ Color EditorProfiler::_get_color_from_signature(const StringName &p_signature) c
|
|||
return c.lerp(get_theme_color(SNAME("base_color"), EditorStringName(Editor)), 0.07);
|
||||
}
|
||||
|
||||
int EditorProfiler::_get_zoom_left_border() const {
|
||||
const int max_profiles_shown = frame_metrics.size() / Math::exp(graph_zoom);
|
||||
return CLAMP(zoom_center - max_profiles_shown / 2, 0, frame_metrics.size() - max_profiles_shown);
|
||||
}
|
||||
|
||||
void EditorProfiler::_item_edited() {
|
||||
if (updating_frame) {
|
||||
return;
|
||||
|
|
@ -177,8 +184,8 @@ void EditorProfiler::_item_edited() {
|
|||
}
|
||||
|
||||
void EditorProfiler::_update_plot() {
|
||||
const int w = graph->get_size().width;
|
||||
const int h = graph->get_size().height;
|
||||
const int w = MAX(1, graph->get_size().width); // Clamp to 1 to prevent from crashing when profiler is autostarted.
|
||||
const int h = MAX(1, graph->get_size().height);
|
||||
bool reset_texture = false;
|
||||
const int desired_len = w * h * 4;
|
||||
|
||||
|
|
@ -235,12 +242,17 @@ void EditorProfiler::_update_plot() {
|
|||
|
||||
HashMap<StringName, int> prev_plots;
|
||||
|
||||
for (int i = 0; i < total_metrics * w / frame_metrics.size() - 1; i++) {
|
||||
const int max_profiles_shown = frame_metrics.size() / Math::exp(graph_zoom);
|
||||
const int left_border = _get_zoom_left_border();
|
||||
const int profiles_drawn = CLAMP(total_metrics - left_border, 0, max_profiles_shown);
|
||||
const int pixel_cols = (profiles_drawn * w) / max_profiles_shown - 1;
|
||||
|
||||
for (int i = 0; i < pixel_cols; i++) {
|
||||
for (int j = 0; j < h * 4; j++) {
|
||||
column[j] = 0;
|
||||
}
|
||||
|
||||
int current = i * frame_metrics.size() / w;
|
||||
int current = (i * max_profiles_shown / w) + left_border;
|
||||
|
||||
for (const StringName &E : plot_sigs) {
|
||||
const Metric &m = _get_frame_metric(current);
|
||||
|
|
@ -388,10 +400,10 @@ void EditorProfiler::_update_frame() {
|
|||
|
||||
void EditorProfiler::_update_button_text() {
|
||||
if (activate->is_pressed()) {
|
||||
activate->set_icon(get_editor_theme_icon(SNAME("Stop")));
|
||||
activate->set_button_icon(get_editor_theme_icon(SNAME("Stop")));
|
||||
activate->set_text(TTR("Stop"));
|
||||
} else {
|
||||
activate->set_icon(get_editor_theme_icon(SNAME("Play")));
|
||||
activate->set_button_icon(get_editor_theme_icon(SNAME("Play")));
|
||||
activate->set_text(TTR("Start"));
|
||||
}
|
||||
}
|
||||
|
|
@ -416,14 +428,19 @@ void EditorProfiler::_internal_profiles_pressed() {
|
|||
_combo_changed(0);
|
||||
}
|
||||
|
||||
void EditorProfiler::_autostart_toggled(bool p_toggled_on) {
|
||||
EditorSettings::get_singleton()->set_project_metadata("debug_options", "autostart_profiler", p_toggled_on);
|
||||
EditorRunBar::get_singleton()->update_profiler_autostart_indicator();
|
||||
}
|
||||
|
||||
void EditorProfiler::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE:
|
||||
case NOTIFICATION_LAYOUT_DIRECTION_CHANGED:
|
||||
case NOTIFICATION_THEME_CHANGED:
|
||||
case NOTIFICATION_TRANSLATION_CHANGED: {
|
||||
activate->set_icon(get_editor_theme_icon(SNAME("Play")));
|
||||
clear_button->set_icon(get_editor_theme_icon(SNAME("Clear")));
|
||||
activate->set_button_icon(get_editor_theme_icon(SNAME("Play")));
|
||||
clear_button->set_button_icon(get_editor_theme_icon(SNAME("Clear")));
|
||||
|
||||
theme_cache.seek_line_color = get_theme_color(SceneStringName(font_color), EditorStringName(Editor));
|
||||
theme_cache.seek_line_color.a = 0.8;
|
||||
|
|
@ -443,10 +460,12 @@ void EditorProfiler::_graph_tex_draw() {
|
|||
}
|
||||
if (seeking) {
|
||||
int frame = cursor_metric_edit->get_value() - _get_frame_metric(0).frame_number;
|
||||
int cur_x = (2 * frame + 1) * graph->get_size().x / (2 * frame_metrics.size()) + 1;
|
||||
frame = frame - _get_zoom_left_border() + 1;
|
||||
int cur_x = (frame * graph->get_size().width * Math::exp(graph_zoom)) / frame_metrics.size();
|
||||
cur_x = CLAMP(cur_x, 0, graph->get_size().width);
|
||||
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), theme_cache.seek_line_color);
|
||||
}
|
||||
if (hover_metric > -1 && hover_metric < total_metrics) {
|
||||
if (hover_metric > -1) {
|
||||
int cur_x = (2 * hover_metric + 1) * graph->get_size().x / (2 * frame_metrics.size()) + 1;
|
||||
graph->draw_line(Vector2(cur_x, 0), Vector2(cur_x, graph->get_size().y), theme_cache.seek_line_hover_color);
|
||||
}
|
||||
|
|
@ -474,22 +493,17 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
|
|||
Ref<InputEventMouse> me = p_ev;
|
||||
Ref<InputEventMouseButton> mb = p_ev;
|
||||
Ref<InputEventMouseMotion> mm = p_ev;
|
||||
MouseButton button_idx = mb.is_valid() ? mb->get_button_index() : MouseButton();
|
||||
|
||||
if (
|
||||
(mb.is_valid() && mb->get_button_index() == MouseButton::LEFT && mb->is_pressed()) ||
|
||||
(mb.is_valid() && button_idx == MouseButton::LEFT && mb->is_pressed()) ||
|
||||
(mm.is_valid())) {
|
||||
int x = me->get_position().x - 1;
|
||||
hover_metric = x * frame_metrics.size() / graph->get_size().width;
|
||||
|
||||
x = x * frame_metrics.size() / graph->get_size().width;
|
||||
|
||||
hover_metric = x;
|
||||
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
|
||||
if (x >= frame_metrics.size()) {
|
||||
x = frame_metrics.size() - 1;
|
||||
}
|
||||
x = x / Math::exp(graph_zoom) + _get_zoom_left_border();
|
||||
x = CLAMP(x, 0, frame_metrics.size() - 1);
|
||||
|
||||
if (mb.is_valid() || (mm->get_button_mask().has_flag(MouseButtonMask::LEFT))) {
|
||||
updating_frame = true;
|
||||
|
|
@ -512,9 +526,34 @@ void EditorProfiler::_graph_tex_input(const Ref<InputEvent> &p_ev) {
|
|||
frame_delay->start();
|
||||
}
|
||||
}
|
||||
|
||||
graph->queue_redraw();
|
||||
}
|
||||
|
||||
if (graph_zoom > 0 && mm.is_valid() && (mm->get_button_mask().has_flag(MouseButtonMask::MIDDLE) || mm->get_button_mask().has_flag(MouseButtonMask::RIGHT))) {
|
||||
// Panning.
|
||||
const int max_profiles_shown = frame_metrics.size() / Math::exp(graph_zoom);
|
||||
pan_accumulator += (float)mm->get_relative().x * max_profiles_shown / graph->get_size().width;
|
||||
|
||||
if (Math::abs(pan_accumulator) > 1) {
|
||||
zoom_center = CLAMP(zoom_center - (int)pan_accumulator, max_profiles_shown / 2, frame_metrics.size() - max_profiles_shown / 2);
|
||||
pan_accumulator -= (int)pan_accumulator;
|
||||
_update_plot();
|
||||
}
|
||||
}
|
||||
|
||||
if (button_idx == MouseButton::WHEEL_DOWN) {
|
||||
// Zooming.
|
||||
graph_zoom = MAX(-0.05 + graph_zoom, 0);
|
||||
_update_plot();
|
||||
} else if (button_idx == MouseButton::WHEEL_UP) {
|
||||
if (graph_zoom == 0) {
|
||||
zoom_center = me->get_position().x;
|
||||
zoom_center = zoom_center * frame_metrics.size() / graph->get_size().width;
|
||||
}
|
||||
graph_zoom = MIN(0.05 + graph_zoom, 2);
|
||||
_update_plot();
|
||||
}
|
||||
|
||||
graph->queue_redraw();
|
||||
}
|
||||
|
||||
void EditorProfiler::disable_seeking() {
|
||||
|
|
@ -539,9 +578,10 @@ void EditorProfiler::set_enabled(bool p_enable, bool p_clear) {
|
|||
}
|
||||
}
|
||||
|
||||
void EditorProfiler::set_pressed(bool p_pressed) {
|
||||
void EditorProfiler::set_profiling(bool p_pressed) {
|
||||
activate->set_pressed(p_pressed);
|
||||
_update_button_text();
|
||||
emit_signal(SNAME("enable_profiling"), activate->is_pressed());
|
||||
}
|
||||
|
||||
bool EditorProfiler::is_profiling() {
|
||||
|
|
@ -619,21 +659,39 @@ Vector<Vector<String>> EditorProfiler::get_data_as_csv() const {
|
|||
|
||||
EditorProfiler::EditorProfiler() {
|
||||
HBoxContainer *hb = memnew(HBoxContainer);
|
||||
hb->add_theme_constant_override(SNAME("separation"), 8 * EDSCALE);
|
||||
add_child(hb);
|
||||
|
||||
FlowContainer *container = memnew(FlowContainer);
|
||||
container->set_h_size_flags(SIZE_EXPAND_FILL);
|
||||
container->add_theme_constant_override(SNAME("h_separation"), 8 * EDSCALE);
|
||||
container->add_theme_constant_override(SNAME("v_separation"), 2 * EDSCALE);
|
||||
hb->add_child(container);
|
||||
|
||||
activate = memnew(Button);
|
||||
activate->set_toggle_mode(true);
|
||||
activate->set_disabled(true);
|
||||
activate->set_text(TTR("Start"));
|
||||
activate->connect(SceneStringName(pressed), callable_mp(this, &EditorProfiler::_activate_pressed));
|
||||
hb->add_child(activate);
|
||||
container->add_child(activate);
|
||||
|
||||
clear_button = memnew(Button);
|
||||
clear_button->set_text(TTR("Clear"));
|
||||
clear_button->connect(SceneStringName(pressed), callable_mp(this, &EditorProfiler::_clear_pressed));
|
||||
clear_button->set_disabled(true);
|
||||
hb->add_child(clear_button);
|
||||
container->add_child(clear_button);
|
||||
|
||||
hb->add_child(memnew(Label(TTR("Measure:"))));
|
||||
CheckBox *autostart_checkbox = memnew(CheckBox);
|
||||
autostart_checkbox->set_text(TTR("Autostart"));
|
||||
autostart_checkbox->set_pressed(EditorSettings::get_singleton()->get_project_metadata("debug_options", "autostart_profiler", false));
|
||||
autostart_checkbox->connect(SceneStringName(toggled), callable_mp(this, &EditorProfiler::_autostart_toggled));
|
||||
container->add_child(autostart_checkbox);
|
||||
|
||||
HBoxContainer *hb_measure = memnew(HBoxContainer);
|
||||
hb_measure->add_theme_constant_override(SNAME("separation"), 2 * EDSCALE);
|
||||
container->add_child(hb_measure);
|
||||
|
||||
hb_measure->add_child(memnew(Label(TTR("Measure:"))));
|
||||
|
||||
display_mode = memnew(OptionButton);
|
||||
display_mode->add_item(TTR("Frame Time (ms)"));
|
||||
|
|
@ -642,9 +700,13 @@ EditorProfiler::EditorProfiler() {
|
|||
display_mode->add_item(TTR("Physics Frame %"));
|
||||
display_mode->connect(SceneStringName(item_selected), callable_mp(this, &EditorProfiler::_combo_changed));
|
||||
|
||||
hb->add_child(display_mode);
|
||||
hb_measure->add_child(display_mode);
|
||||
|
||||
hb->add_child(memnew(Label(TTR("Time:"))));
|
||||
HBoxContainer *hb_time = memnew(HBoxContainer);
|
||||
hb_time->add_theme_constant_override(SNAME("separation"), 2 * EDSCALE);
|
||||
container->add_child(hb_time);
|
||||
|
||||
hb_time->add_child(memnew(Label(TTR("Time:"))));
|
||||
|
||||
display_time = memnew(OptionButton);
|
||||
// TRANSLATORS: This is an option in the profiler to display the time spent in a function, including the time spent in other functions called by that function.
|
||||
|
|
@ -653,28 +715,28 @@ EditorProfiler::EditorProfiler() {
|
|||
display_time->add_item(TTR("Self"));
|
||||
display_time->set_tooltip_text(TTR("Inclusive: Includes time from other functions called by this function.\nUse this to spot bottlenecks.\n\nSelf: Only count the time spent in the function itself, not in other functions called by that function.\nUse this to find individual functions to optimize."));
|
||||
display_time->connect(SceneStringName(item_selected), callable_mp(this, &EditorProfiler::_combo_changed));
|
||||
|
||||
hb->add_child(display_time);
|
||||
hb_time->add_child(display_time);
|
||||
|
||||
display_internal_profiles = memnew(CheckButton(TTR("Display internal functions")));
|
||||
display_internal_profiles->set_visible(EDITOR_GET("debugger/profile_native_calls"));
|
||||
display_internal_profiles->set_pressed(false);
|
||||
display_internal_profiles->connect(SceneStringName(pressed), callable_mp(this, &EditorProfiler::_internal_profiles_pressed));
|
||||
hb->add_child(display_internal_profiles);
|
||||
container->add_child(display_internal_profiles);
|
||||
|
||||
hb->add_spacer();
|
||||
HBoxContainer *hb_frame = memnew(HBoxContainer);
|
||||
hb_frame->add_theme_constant_override(SNAME("separation"), 2 * EDSCALE);
|
||||
hb_frame->set_v_size_flags(SIZE_SHRINK_BEGIN);
|
||||
hb->add_child(hb_frame);
|
||||
|
||||
hb->add_child(memnew(Label(TTR("Frame #:"))));
|
||||
hb_frame->add_child(memnew(Label(TTR("Frame #:"))));
|
||||
|
||||
cursor_metric_edit = memnew(SpinBox);
|
||||
cursor_metric_edit->set_h_size_flags(SIZE_FILL);
|
||||
cursor_metric_edit->set_value(0);
|
||||
cursor_metric_edit->set_editable(false);
|
||||
hb->add_child(cursor_metric_edit);
|
||||
hb_frame->add_child(cursor_metric_edit);
|
||||
cursor_metric_edit->connect(SceneStringName(value_changed), callable_mp(this, &EditorProfiler::_cursor_metric_changed));
|
||||
|
||||
hb->add_theme_constant_override("separation", 8 * EDSCALE);
|
||||
|
||||
h_split = memnew(HSplitContainer);
|
||||
add_child(h_split);
|
||||
h_split->set_v_size_flags(SIZE_EXPAND_FILL);
|
||||
|
|
@ -699,9 +761,11 @@ EditorProfiler::EditorProfiler() {
|
|||
variables->set_column_expand(2, false);
|
||||
variables->set_column_clip_content(2, true);
|
||||
variables->set_column_custom_minimum_width(2, 50 * EDSCALE);
|
||||
variables->set_theme_type_variation("TreeSecondary");
|
||||
variables->connect("item_edited", callable_mp(this, &EditorProfiler::_item_edited));
|
||||
|
||||
graph = memnew(TextureRect);
|
||||
graph->set_custom_minimum_size(Size2(250 * EDSCALE, 0));
|
||||
graph->set_expand_mode(TextureRect::EXPAND_IGNORE_SIZE);
|
||||
graph->set_mouse_filter(MOUSE_FILTER_STOP);
|
||||
graph->connect(SceneStringName(draw), callable_mp(this, &EditorProfiler::_graph_tex_draw));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue