mirror of
				https://github.com/godotengine/godot.git
				synced 2025-11-03 23:21:15 +00:00 
			
		
		
		
	Visual GPU profiler and related profiling support in Vulkan.
This commit is contained in:
		
							parent
							
								
									dc32083681
								
							
						
					
					
						commit
						123ee5995c
					
				
					 23 changed files with 1418 additions and 17 deletions
				
			
		| 
						 | 
				
			
			@ -35,8 +35,9 @@
 | 
			
		|||
#include "core/ustring.h"
 | 
			
		||||
#include "editor/plugins/canvas_item_editor_plugin.h"
 | 
			
		||||
#include "editor/plugins/spatial_editor_plugin.h"
 | 
			
		||||
#include "editor_log.h"
 | 
			
		||||
#include "editor_network_profiler.h"
 | 
			
		||||
#include "editor/editor_log.h"
 | 
			
		||||
#include "editor/editor_network_profiler.h"
 | 
			
		||||
#include "editor/editor_visual_profiler.h"
 | 
			
		||||
#include "editor_node.h"
 | 
			
		||||
#include "editor_profiler.h"
 | 
			
		||||
#include "editor_scale.h"
 | 
			
		||||
| 
						 | 
				
			
			@ -833,6 +834,32 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
 | 
			
		|||
		}
 | 
			
		||||
		perf_history.push_front(p);
 | 
			
		||||
		perf_draw->update();
 | 
			
		||||
	} else if (p_msg == "visual_profile") {
 | 
			
		||||
		uint64_t frame = p_data[0];
 | 
			
		||||
		PoolVector<String> names = p_data[1];
 | 
			
		||||
		PoolVector<real_t> values = p_data[2];
 | 
			
		||||
 | 
			
		||||
		EditorVisualProfiler::Metric metric;
 | 
			
		||||
		metric.areas.resize(names.size());
 | 
			
		||||
		metric.frame_number = frame;
 | 
			
		||||
		metric.valid = true;
 | 
			
		||||
 | 
			
		||||
		{
 | 
			
		||||
			EditorVisualProfiler::Metric::Area *areas_ptr = metric.areas.ptrw();
 | 
			
		||||
			int metric_count = names.size();
 | 
			
		||||
 | 
			
		||||
			PoolVector<String>::Read rs = names.read();
 | 
			
		||||
			PoolVector<real_t>::Read rr = values.read();
 | 
			
		||||
 | 
			
		||||
			for (int i = 0; i < metric_count; i++) {
 | 
			
		||||
 | 
			
		||||
				areas_ptr[i].name = rs[i];
 | 
			
		||||
				areas_ptr[i].cpu_time = rr[i * 2 + 0];
 | 
			
		||||
				areas_ptr[i].gpu_time = rr[i * 2 + 1];
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		visual_profiler->add_frame_metric(metric);
 | 
			
		||||
 | 
			
		||||
	} else if (p_msg == "error") {
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1565,12 +1592,33 @@ void ScriptEditorDebugger::_profiler_activate(bool p_enable) {
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ScriptEditorDebugger::_visual_profiler_activate(bool p_enable) {
 | 
			
		||||
 | 
			
		||||
	if (!connection.is_valid())
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if (p_enable) {
 | 
			
		||||
		profiler_signature.clear();
 | 
			
		||||
		Array msg;
 | 
			
		||||
		msg.push_back("start_visual_profiling");
 | 
			
		||||
		ppeer->put_var(msg);
 | 
			
		||||
		print_verbose("Starting visual profiling.");
 | 
			
		||||
 | 
			
		||||
	} else {
 | 
			
		||||
		Array msg;
 | 
			
		||||
		msg.push_back("stop_visual_profiling");
 | 
			
		||||
		ppeer->put_var(msg);
 | 
			
		||||
		print_verbose("Ending visual profiling.");
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ScriptEditorDebugger::_network_profiler_activate(bool p_enable) {
 | 
			
		||||
 | 
			
		||||
	if (!connection.is_valid())
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	if (p_enable) {
 | 
			
		||||
		profiler_signature.clear();
 | 
			
		||||
		Array msg;
 | 
			
		||||
		msg.push_back("start_network_profiling");
 | 
			
		||||
		ppeer->put_var(msg);
 | 
			
		||||
| 
						 | 
				
			
			@ -2224,6 +2272,7 @@ void ScriptEditorDebugger::_bind_methods() {
 | 
			
		|||
	ClassDB::bind_method(D_METHOD("_expand_errors_list"), &ScriptEditorDebugger::_expand_errors_list);
 | 
			
		||||
	ClassDB::bind_method(D_METHOD("_collapse_errors_list"), &ScriptEditorDebugger::_collapse_errors_list);
 | 
			
		||||
	ClassDB::bind_method(D_METHOD("_profiler_activate"), &ScriptEditorDebugger::_profiler_activate);
 | 
			
		||||
	ClassDB::bind_method(D_METHOD("_visual_profiler_activate"), &ScriptEditorDebugger::_visual_profiler_activate);
 | 
			
		||||
	ClassDB::bind_method(D_METHOD("_network_profiler_activate"), &ScriptEditorDebugger::_network_profiler_activate);
 | 
			
		||||
	ClassDB::bind_method(D_METHOD("_profiler_seeked"), &ScriptEditorDebugger::_profiler_seeked);
 | 
			
		||||
	ClassDB::bind_method(D_METHOD("_clear_errors_list"), &ScriptEditorDebugger::_clear_errors_list);
 | 
			
		||||
| 
						 | 
				
			
			@ -2455,11 +2504,20 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) {
 | 
			
		|||
		profiler->connect("break_request", this, "_profiler_seeked");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	{ //frame profiler
 | 
			
		||||
		visual_profiler = memnew(EditorVisualProfiler);
 | 
			
		||||
		visual_profiler->set_name(TTR("Visual Profiler"));
 | 
			
		||||
		tabs->add_child(visual_profiler);
 | 
			
		||||
		visual_profiler->connect("enable_profiling", this, "_visual_profiler_activate");
 | 
			
		||||
		visual_profiler->connect("break_request", this, "_profiler_seeked");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	{ //network profiler
 | 
			
		||||
		network_profiler = memnew(EditorNetworkProfiler);
 | 
			
		||||
		network_profiler->set_name(TTR("Network Profiler"));
 | 
			
		||||
		tabs->add_child(network_profiler);
 | 
			
		||||
		network_profiler->connect("enable_profiling", this, "_network_profiler_activate");
 | 
			
		||||
		network_profiler->connect("break_request", this, "_profiler_seeked");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	{ //monitors
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue