You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-20 14:45:44 +00:00
Add some important profiling hooks.
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/io/dir_access.h"
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/profiling/profiling.h"
|
||||
#include "modules/modules_enabled.gen.h"
|
||||
#include "servers/rendering/rendering_shader_container.h"
|
||||
|
||||
@@ -6256,12 +6257,16 @@ String RenderingDevice::get_device_pipeline_cache_uuid() const {
|
||||
void RenderingDevice::swap_buffers(bool p_present) {
|
||||
ERR_RENDER_THREAD_GUARD();
|
||||
|
||||
GodotProfileZoneGroupedFirst(_profile_zone, "_end_frame");
|
||||
_end_frame();
|
||||
|
||||
GodotProfileZoneGrouped(_profile_zone, "_execute_frame");
|
||||
_execute_frame(p_present);
|
||||
|
||||
// Advance to the next frame and begin recording again.
|
||||
frame = (frame + 1) % frames.size();
|
||||
|
||||
GodotProfileZoneGrouped(_profile_zone, "_begin_frame");
|
||||
_begin_frame(true);
|
||||
}
|
||||
|
||||
@@ -6389,27 +6394,34 @@ uint64_t RenderingDevice::get_memory_usage(MemoryType p_type) const {
|
||||
}
|
||||
|
||||
void RenderingDevice::_begin_frame(bool p_presented) {
|
||||
GodotProfileZoneGroupedFirst(_profile_zone, "_stall_for_frame");
|
||||
// Before writing to this frame, wait for it to be finished.
|
||||
_stall_for_frame(frame);
|
||||
|
||||
if (command_pool_reset_enabled) {
|
||||
GodotProfileZoneGrouped(_profile_zone, "driver->command_pool_reset");
|
||||
bool reset = driver->command_pool_reset(frames[frame].command_pool);
|
||||
ERR_FAIL_COND(!reset);
|
||||
}
|
||||
|
||||
if (p_presented) {
|
||||
GodotProfileZoneGrouped(_profile_zone, "update_perf_report");
|
||||
update_perf_report();
|
||||
driver->linear_uniform_set_pools_reset(frame);
|
||||
}
|
||||
|
||||
// Begin recording on the frame's command buffers.
|
||||
GodotProfileZoneGrouped(_profile_zone, "driver->begin_segment");
|
||||
driver->begin_segment(frame, frames_drawn++);
|
||||
GodotProfileZoneGrouped(_profile_zone, "driver->command_buffer_begin");
|
||||
driver->command_buffer_begin(frames[frame].command_buffer);
|
||||
|
||||
// Reset the graph.
|
||||
GodotProfileZoneGrouped(_profile_zone, "draw_graph.begin");
|
||||
draw_graph.begin();
|
||||
|
||||
// Erase pending resources.
|
||||
GodotProfileZoneGrouped(_profile_zone, "_free_pending_resources");
|
||||
_free_pending_resources(frame);
|
||||
|
||||
// Advance staging buffers if used.
|
||||
@@ -6446,11 +6458,16 @@ void RenderingDevice::_end_frame() {
|
||||
|
||||
// The command buffer must be copied into a stack variable as the driver workarounds can change the command buffer in use.
|
||||
RDD::CommandBufferID command_buffer = frames[frame].command_buffer;
|
||||
GodotProfileZoneGroupedFirst(_profile_zone, "_submit_transfer_workers");
|
||||
_submit_transfer_workers(command_buffer);
|
||||
GodotProfileZoneGrouped(_profile_zone, "_submit_transfer_barriers");
|
||||
_submit_transfer_barriers(command_buffer);
|
||||
|
||||
GodotProfileZoneGrouped(_profile_zone, "draw_graph.end");
|
||||
draw_graph.end(RENDER_GRAPH_REORDER, RENDER_GRAPH_FULL_BARRIERS, command_buffer, frames[frame].command_buffer_pool);
|
||||
GodotProfileZoneGrouped(_profile_zone, "driver->command_buffer_end");
|
||||
driver->command_buffer_end(command_buffer);
|
||||
GodotProfileZoneGrouped(_profile_zone, "driver->end_segment");
|
||||
driver->end_segment();
|
||||
}
|
||||
|
||||
@@ -6542,11 +6559,13 @@ void RenderingDevice::_stall_for_frame(uint32_t p_frame) {
|
||||
thread_local PackedByteArray packed_byte_array;
|
||||
|
||||
if (frames[p_frame].fence_signaled) {
|
||||
GodotProfileZoneGroupedFirst(_profile_zone, "driver->fence_wait");
|
||||
driver->fence_wait(frames[p_frame].fence);
|
||||
frames[p_frame].fence_signaled = false;
|
||||
|
||||
// Flush any pending requests for asynchronous buffer downloads.
|
||||
if (!frames[p_frame].download_buffer_get_data_requests.is_empty()) {
|
||||
GodotProfileZoneGrouped(_profile_zone, "flush asynchronous buffer downloads");
|
||||
for (uint32_t i = 0; i < frames[p_frame].download_buffer_get_data_requests.size(); i++) {
|
||||
const BufferGetDataRequest &request = frames[p_frame].download_buffer_get_data_requests[i];
|
||||
packed_byte_array.resize(request.size);
|
||||
@@ -6571,6 +6590,7 @@ void RenderingDevice::_stall_for_frame(uint32_t p_frame) {
|
||||
|
||||
// Flush any pending requests for asynchronous texture downloads.
|
||||
if (!frames[p_frame].download_texture_get_data_requests.is_empty()) {
|
||||
GodotProfileZoneGrouped(_profile_zone, "flush asynchronous texture downloads");
|
||||
uint32_t pitch_step = driver->api_trait_get(RDD::API_TRAIT_TEXTURE_DATA_ROW_PITCH_STEP);
|
||||
for (uint32_t i = 0; i < frames[p_frame].download_texture_get_data_requests.size(); i++) {
|
||||
const TextureGetDataRequest &request = frames[p_frame].download_texture_get_data_requests[i];
|
||||
@@ -6618,6 +6638,7 @@ void RenderingDevice::_stall_for_frame(uint32_t p_frame) {
|
||||
request.callback.call(packed_byte_array);
|
||||
}
|
||||
|
||||
GodotProfileZoneGrouped(_profile_zone, "clear buffers");
|
||||
frames[p_frame].download_texture_staging_buffers.clear();
|
||||
frames[p_frame].download_buffer_texture_copy_regions.clear();
|
||||
frames[p_frame].download_texture_mipmap_offsets.clear();
|
||||
|
||||
Reference in New Issue
Block a user