From 2bb34a4489769e21a4886f1a9f33aa49c0dfcf34 Mon Sep 17 00:00:00 2001 From: Marcel Offermans Date: Sat, 4 May 2024 10:23:10 +0200 Subject: [PATCH] Added a project setting to configure the maximum amount of timestamps, with a description and a reference to the setting when the limit is hit and an ERR_FAIL_COND is hit. --- core/config/project_settings.cpp | 1 + doc/classes/ProjectSettings.xml | 3 +++ servers/rendering/rendering_device.cpp | 4 ++-- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index ee20aea35d3..ccdbab05929 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1514,6 +1514,7 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF_BASIC(PropertyInfo(Variant::STRING, "display/window/stretch/scale_mode", PROPERTY_HINT_ENUM, "fractional,integer"), "fractional"); GLOBAL_DEF(PropertyInfo(Variant::INT, "debug/settings/profiler/max_functions", PROPERTY_HINT_RANGE, "128,65535,1"), 16384); + GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "debug/settings/profiler/max_timestamp_query_elements", PROPERTY_HINT_RANGE, "256,65535,1"), 256); GLOBAL_DEF(PropertyInfo(Variant::BOOL, "compression/formats/zstd/long_distance_matching"), Compression::zstd_long_distance_matching); GLOBAL_DEF(PropertyInfo(Variant::INT, "compression/formats/zstd/compression_level", PROPERTY_HINT_RANGE, "1,22,1"), Compression::zstd_level); diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index e8d7dfb9137..b04a3fb0275 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -620,6 +620,9 @@ Maximum number of functions per frame allowed when profiling. + + Maximum number of timestamp query elements allowed per frame for visual profiling. + Print frames per second to standard output every second. diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 1ee5362f2ce..93a9f194054 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -4964,7 +4964,7 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ frame = 0; frames.resize(frame_count); - max_timestamp_query_elements = 256; + max_timestamp_query_elements = GLOBAL_GET("debug/settings/profiler/max_timestamp_query_elements"); device = context->device_get(device_index); err = driver->initialize(device_index, frame_count); @@ -5212,7 +5212,7 @@ void RenderingDevice::_free_rids(T &p_owner, const char *p_type) { void RenderingDevice::capture_timestamp(const String &p_name) { ERR_FAIL_COND_MSG(draw_list != nullptr && draw_list->state.draw_count > 0, "Capturing timestamps during draw list creation is not allowed. Offending timestamp was: " + p_name); ERR_FAIL_COND_MSG(compute_list != nullptr && compute_list->state.dispatch_count > 0, "Capturing timestamps during compute list creation is not allowed. Offending timestamp was: " + p_name); - ERR_FAIL_COND(frames[frame].timestamp_count >= max_timestamp_query_elements); + ERR_FAIL_COND_MSG(frames[frame].timestamp_count >= max_timestamp_query_elements, vformat("Tried capturing more timestamps than the configured maximum (%d). You can increase this limit in the project settings under 'Debug/Settings' called 'Max Timestamp Query Elements'.", max_timestamp_query_elements)); draw_graph.add_capture_timestamp(frames[frame].timestamp_pool, frames[frame].timestamp_count);