You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-09 12:50:35 +00:00
Add ability to export VRAM usage as CSV
This commit is contained in:
committed by
Pedro J. Estébanez
parent
85ed2edc06
commit
a037232a67
@@ -149,6 +149,9 @@ void ScriptEditorDebugger::save_node(ObjectID p_id, const String &p_file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditorDebugger::_file_selected(const String &p_file) {
|
void ScriptEditorDebugger::_file_selected(const String &p_file) {
|
||||||
|
|
||||||
|
switch (file_dialog_purpose) {
|
||||||
|
case SAVE_MONITORS_CSV: {
|
||||||
Error err;
|
Error err;
|
||||||
FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
|
FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
|
||||||
|
|
||||||
@@ -183,6 +186,38 @@ void ScriptEditorDebugger::_file_selected(const String &p_file) {
|
|||||||
for (int i = 0; i < profiler_data.size(); i++) {
|
for (int i = 0; i < profiler_data.size(); i++) {
|
||||||
file->store_csv_line(profiler_data[i]);
|
file->store_csv_line(profiler_data[i]);
|
||||||
}
|
}
|
||||||
|
} break;
|
||||||
|
case SAVE_VRAM_CSV: {
|
||||||
|
Error err;
|
||||||
|
FileAccessRef file = FileAccess::open(p_file, FileAccess::WRITE, &err);
|
||||||
|
|
||||||
|
if (err != OK) {
|
||||||
|
ERR_PRINT("Failed to open " + p_file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector<String> headers;
|
||||||
|
headers.resize(vmem_tree->get_columns());
|
||||||
|
for (int i = 0; i < vmem_tree->get_columns(); ++i) {
|
||||||
|
headers.write[i] = vmem_tree->get_column_title(i);
|
||||||
|
}
|
||||||
|
file->store_csv_line(headers);
|
||||||
|
|
||||||
|
if (vmem_tree->get_root()) {
|
||||||
|
TreeItem *ti = vmem_tree->get_root()->get_children();
|
||||||
|
while (ti) {
|
||||||
|
Vector<String> values;
|
||||||
|
values.resize(vmem_tree->get_columns());
|
||||||
|
for (int i = 0; i < vmem_tree->get_columns(); ++i) {
|
||||||
|
values.write[i] = ti->get_text(i);
|
||||||
|
}
|
||||||
|
file->store_csv_line(values);
|
||||||
|
|
||||||
|
ti = ti->get_next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEditorDebugger::request_remote_tree() {
|
void ScriptEditorDebugger::request_remote_tree() {
|
||||||
@@ -233,6 +268,15 @@ void ScriptEditorDebugger::_video_mem_request() {
|
|||||||
_put_msg("core:memory", Array());
|
_put_msg("core:memory", Array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptEditorDebugger::_video_mem_export() {
|
||||||
|
|
||||||
|
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
||||||
|
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
||||||
|
file_dialog->clear_filters();
|
||||||
|
file_dialog_purpose = SAVE_VRAM_CSV;
|
||||||
|
file_dialog->popup_centered_ratio();
|
||||||
|
}
|
||||||
|
|
||||||
Size2 ScriptEditorDebugger::get_minimum_size() const {
|
Size2 ScriptEditorDebugger::get_minimum_size() const {
|
||||||
|
|
||||||
Size2 ms = MarginContainer::get_minimum_size();
|
Size2 ms = MarginContainer::get_minimum_size();
|
||||||
@@ -766,6 +810,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
|||||||
error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected));
|
error_tree->connect("item_selected", callable_mp(this, &ScriptEditorDebugger::_error_selected));
|
||||||
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
|
error_tree->connect("item_activated", callable_mp(this, &ScriptEditorDebugger::_error_activated));
|
||||||
vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons"));
|
vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons"));
|
||||||
|
vmem_export->set_icon(get_theme_icon("Save", "EditorIcons"));
|
||||||
|
|
||||||
reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
|
reason->add_theme_color_override("font_color", get_theme_color("error_color", "Editor"));
|
||||||
|
|
||||||
@@ -840,6 +885,7 @@ void ScriptEditorDebugger::_notification(int p_what) {
|
|||||||
dobreak->set_icon(get_theme_icon("Pause", "EditorIcons"));
|
dobreak->set_icon(get_theme_icon("Pause", "EditorIcons"));
|
||||||
docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons"));
|
docontinue->set_icon(get_theme_icon("DebugContinue", "EditorIcons"));
|
||||||
vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons"));
|
vmem_refresh->set_icon(get_theme_icon("Reload", "EditorIcons"));
|
||||||
|
vmem_export->set_icon(get_theme_icon("Save", "EditorIcons"));
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -981,6 +1027,7 @@ void ScriptEditorDebugger::_export_csv() {
|
|||||||
|
|
||||||
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
file_dialog->set_file_mode(EditorFileDialog::FILE_MODE_SAVE_FILE);
|
||||||
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
file_dialog->set_access(EditorFileDialog::ACCESS_FILESYSTEM);
|
||||||
|
file_dialog_purpose = SAVE_MONITORS_CSV;
|
||||||
file_dialog->popup_centered_ratio();
|
file_dialog->popup_centered_ratio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1701,8 +1748,12 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
|
|||||||
vmem_hb->add_child(vmem_total);
|
vmem_hb->add_child(vmem_total);
|
||||||
vmem_refresh = memnew(ToolButton);
|
vmem_refresh = memnew(ToolButton);
|
||||||
vmem_hb->add_child(vmem_refresh);
|
vmem_hb->add_child(vmem_refresh);
|
||||||
|
vmem_export = memnew(ToolButton);
|
||||||
|
vmem_export->set_tooltip(TTR("Export list to a CSV file"));
|
||||||
|
vmem_hb->add_child(vmem_export);
|
||||||
vmem_vb->add_child(vmem_hb);
|
vmem_vb->add_child(vmem_hb);
|
||||||
vmem_refresh->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_video_mem_request));
|
vmem_refresh->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_video_mem_request));
|
||||||
|
vmem_export->connect("pressed", callable_mp(this, &ScriptEditorDebugger::_video_mem_export));
|
||||||
|
|
||||||
VBoxContainer *vmmc = memnew(VBoxContainer);
|
VBoxContainer *vmmc = memnew(VBoxContainer);
|
||||||
vmem_tree = memnew(Tree);
|
vmem_tree = memnew(Tree);
|
||||||
|
|||||||
@@ -88,6 +88,11 @@ private:
|
|||||||
PopupMenu *item_menu;
|
PopupMenu *item_menu;
|
||||||
|
|
||||||
EditorFileDialog *file_dialog;
|
EditorFileDialog *file_dialog;
|
||||||
|
enum FileDialogPurpose {
|
||||||
|
SAVE_MONITORS_CSV,
|
||||||
|
SAVE_VRAM_CSV,
|
||||||
|
};
|
||||||
|
FileDialogPurpose file_dialog_purpose;
|
||||||
|
|
||||||
int error_count;
|
int error_count;
|
||||||
int warning_count;
|
int warning_count;
|
||||||
@@ -121,6 +126,7 @@ private:
|
|||||||
|
|
||||||
Tree *vmem_tree;
|
Tree *vmem_tree;
|
||||||
Button *vmem_refresh;
|
Button *vmem_refresh;
|
||||||
|
Button *vmem_export;
|
||||||
LineEdit *vmem_total;
|
LineEdit *vmem_total;
|
||||||
|
|
||||||
Tree *stack_dump;
|
Tree *stack_dump;
|
||||||
@@ -160,6 +166,7 @@ private:
|
|||||||
void _remote_object_property_updated(ObjectID p_id, const String &p_property);
|
void _remote_object_property_updated(ObjectID p_id, const String &p_property);
|
||||||
|
|
||||||
void _video_mem_request();
|
void _video_mem_request();
|
||||||
|
void _video_mem_export();
|
||||||
|
|
||||||
int _get_node_path_cache(const NodePath &p_path);
|
int _get_node_path_cache(const NodePath &p_path);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user