mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Add an ObjectDB Profiling Tool
A new tab is added to the debugger that can help profile a game's memory usage. Specifically, this lets you save a snapshot of all the objects in a running game's ObjectDB to disk. It then lets you view the snapshot and diff two snapshots against each other. This is meant to work similarly to Chrome's heap snapshot tool or Unity's memory profiler.
This commit is contained in:
parent
4d1f26e1fd
commit
78f1543e35
40 changed files with 4262 additions and 109 deletions
|
@ -37,40 +37,6 @@
|
|||
#include "scene/gui/text_edit.h"
|
||||
#include "servers/rendering/shader_language.h"
|
||||
|
||||
void EditorNativeShaderSourceVisualizer::_load_theme_settings() {
|
||||
syntax_highlighter->set_number_color(EDITOR_GET("text_editor/theme/highlighting/number_color"));
|
||||
syntax_highlighter->set_symbol_color(EDITOR_GET("text_editor/theme/highlighting/symbol_color"));
|
||||
syntax_highlighter->set_function_color(EDITOR_GET("text_editor/theme/highlighting/function_color"));
|
||||
syntax_highlighter->set_member_variable_color(EDITOR_GET("text_editor/theme/highlighting/member_variable_color"));
|
||||
|
||||
syntax_highlighter->clear_keyword_colors();
|
||||
|
||||
List<String> keywords;
|
||||
ShaderLanguage::get_keyword_list(&keywords);
|
||||
const Color keyword_color = EDITOR_GET("text_editor/theme/highlighting/keyword_color");
|
||||
const Color control_flow_keyword_color = EDITOR_GET("text_editor/theme/highlighting/control_flow_keyword_color");
|
||||
|
||||
for (const String &keyword : keywords) {
|
||||
if (ShaderLanguage::is_control_flow_keyword(keyword)) {
|
||||
syntax_highlighter->add_keyword_color(keyword, control_flow_keyword_color);
|
||||
} else {
|
||||
syntax_highlighter->add_keyword_color(keyword, keyword_color);
|
||||
}
|
||||
}
|
||||
|
||||
// Colorize comments.
|
||||
const Color comment_color = EDITOR_GET("text_editor/theme/highlighting/comment_color");
|
||||
syntax_highlighter->clear_color_regions();
|
||||
syntax_highlighter->add_color_region("/*", "*/", comment_color, false);
|
||||
syntax_highlighter->add_color_region("//", "", comment_color, true);
|
||||
|
||||
// Colorize preprocessor statements.
|
||||
const Color user_type_color = EDITOR_GET("text_editor/theme/highlighting/user_type_color");
|
||||
syntax_highlighter->add_color_region("#", "", user_type_color, true);
|
||||
|
||||
syntax_highlighter->set_uint_suffix_enabled(true);
|
||||
}
|
||||
|
||||
void EditorNativeShaderSourceVisualizer::_inspect_shader(RID p_shader) {
|
||||
if (versions) {
|
||||
memdelete(versions);
|
||||
|
@ -79,7 +45,10 @@ void EditorNativeShaderSourceVisualizer::_inspect_shader(RID p_shader) {
|
|||
|
||||
RS::ShaderNativeSourceCode nsc = RS::get_singleton()->shader_get_native_source_code(p_shader);
|
||||
|
||||
_load_theme_settings();
|
||||
List<String> keywords;
|
||||
ShaderLanguage::get_keyword_list(&keywords);
|
||||
Ref<EditorJsonVisualizerSyntaxHighlighter> syntax_highlighter;
|
||||
syntax_highlighter.instantiate(keywords);
|
||||
|
||||
versions = memnew(TabContainer);
|
||||
versions->set_tab_alignment(TabBar::ALIGNMENT_CENTER);
|
||||
|
@ -93,50 +62,8 @@ void EditorNativeShaderSourceVisualizer::_inspect_shader(RID p_shader) {
|
|||
vtab->set_h_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
versions->add_child(vtab);
|
||||
for (int j = 0; j < nsc.versions[i].stages.size(); j++) {
|
||||
CodeEdit *code_edit = memnew(CodeEdit);
|
||||
code_edit->set_editable(false);
|
||||
code_edit->set_syntax_highlighter(syntax_highlighter);
|
||||
code_edit->add_theme_font_override(SceneStringName(font), get_theme_font("source", EditorStringName(EditorFonts)));
|
||||
code_edit->add_theme_font_size_override(SceneStringName(font_size), get_theme_font_size("source_size", EditorStringName(EditorFonts)));
|
||||
code_edit->add_theme_constant_override("line_spacing", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));
|
||||
|
||||
// Appearance: Caret
|
||||
code_edit->set_caret_type((TextEdit::CaretType)EDITOR_GET("text_editor/appearance/caret/type").operator int());
|
||||
code_edit->set_caret_blink_enabled(EDITOR_GET("text_editor/appearance/caret/caret_blink"));
|
||||
code_edit->set_caret_blink_interval(EDITOR_GET("text_editor/appearance/caret/caret_blink_interval"));
|
||||
code_edit->set_highlight_current_line(EDITOR_GET("text_editor/appearance/caret/highlight_current_line"));
|
||||
code_edit->set_highlight_all_occurrences(EDITOR_GET("text_editor/appearance/caret/highlight_all_occurrences"));
|
||||
|
||||
// Appearance: Gutters
|
||||
code_edit->set_draw_line_numbers(EDITOR_GET("text_editor/appearance/gutters/show_line_numbers"));
|
||||
code_edit->set_line_numbers_zero_padded(EDITOR_GET("text_editor/appearance/gutters/line_numbers_zero_padded"));
|
||||
|
||||
// Appearance: Minimap
|
||||
code_edit->set_draw_minimap(EDITOR_GET("text_editor/appearance/minimap/show_minimap"));
|
||||
code_edit->set_minimap_width((int)EDITOR_GET("text_editor/appearance/minimap/minimap_width") * EDSCALE);
|
||||
|
||||
// Appearance: Lines
|
||||
code_edit->set_line_folding_enabled(EDITOR_GET("text_editor/appearance/lines/code_folding"));
|
||||
code_edit->set_draw_fold_gutter(EDITOR_GET("text_editor/appearance/lines/code_folding"));
|
||||
code_edit->set_line_wrapping_mode((TextEdit::LineWrappingMode)EDITOR_GET("text_editor/appearance/lines/word_wrap").operator int());
|
||||
code_edit->set_autowrap_mode((TextServer::AutowrapMode)EDITOR_GET("text_editor/appearance/lines/autowrap_mode").operator int());
|
||||
|
||||
// Appearance: Whitespace
|
||||
code_edit->set_draw_tabs(EDITOR_GET("text_editor/appearance/whitespace/draw_tabs"));
|
||||
code_edit->set_draw_spaces(EDITOR_GET("text_editor/appearance/whitespace/draw_spaces"));
|
||||
code_edit->add_theme_constant_override("line_spacing", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));
|
||||
|
||||
// Behavior: Navigation
|
||||
code_edit->set_scroll_past_end_of_file_enabled(EDITOR_GET("text_editor/behavior/navigation/scroll_past_end_of_file"));
|
||||
code_edit->set_smooth_scroll_enabled(EDITOR_GET("text_editor/behavior/navigation/smooth_scrolling"));
|
||||
code_edit->set_v_scroll_speed(EDITOR_GET("text_editor/behavior/navigation/v_scroll_speed"));
|
||||
code_edit->set_drag_and_drop_selection_enabled(EDITOR_GET("text_editor/behavior/navigation/drag_and_drop_selection"));
|
||||
|
||||
// Behavior: Indent
|
||||
code_edit->set_indent_size(EDITOR_GET("text_editor/behavior/indent/size"));
|
||||
code_edit->set_auto_indent_enabled(EDITOR_GET("text_editor/behavior/indent/auto_indent"));
|
||||
code_edit->set_indent_wrapped_lines(EDITOR_GET("text_editor/behavior/indent/indent_wrapped_lines"));
|
||||
|
||||
EditorJsonVisualizer *code_edit = memnew(EditorJsonVisualizer);
|
||||
code_edit->load_theme(syntax_highlighter);
|
||||
code_edit->set_name(nsc.versions[i].stages[j].name);
|
||||
code_edit->set_text(nsc.versions[i].stages[j].code);
|
||||
code_edit->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||
|
@ -153,8 +80,6 @@ void EditorNativeShaderSourceVisualizer::_bind_methods() {
|
|||
}
|
||||
|
||||
EditorNativeShaderSourceVisualizer::EditorNativeShaderSourceVisualizer() {
|
||||
syntax_highlighter.instantiate();
|
||||
|
||||
add_to_group("_native_shader_source_visualizer");
|
||||
set_title(TTR("Native Shader Source Inspector"));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue