From d149a595139d9932f4bf975beaf6795ea1225da4 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Fri, 7 Mar 2025 12:43:51 +0000 Subject: [PATCH] Add GLOBAL_GET cached macros. GLOBAL_GET is an expensive operation which should not be used each frame / tick. This PR adds macros which do a cheaper revision check, and only call the expensive GLOBAL_GET when project settings have changed. Co-authored-by: Lukas Tenbrink --- core/config/project_settings.cpp | 2 ++ core/config/project_settings.h | 29 ++++++++++++++++++- core/error/error_macros.cpp | 2 +- drivers/gles2/rasterizer_gles2.cpp | 2 +- drivers/gles2/rasterizer_scene_gles2.cpp | 4 +-- drivers/gles2/rasterizer_storage_gles2.cpp | 2 +- drivers/gles2/shader_compiler_gles2.cpp | 4 +-- drivers/gles2/shader_gles2.cpp | 2 +- drivers/gles3/rasterizer_gles3.cpp | 2 +- drivers/gles3/rasterizer_scene_gles3.cpp | 16 +++++----- drivers/gles3/rasterizer_storage_gles3.cpp | 2 +- drivers/gles3/shader_compiler_gles3.cpp | 4 +-- editor/import/resource_importer_texture.cpp | 4 +-- .../animation_player_editor_plugin.cpp | 2 +- editor/plugins/canvas_item_editor_plugin.cpp | 2 +- editor/plugins/editor_preview_plugins.cpp | 2 +- editor/plugins/theme_editor_preview.cpp | 2 +- .../editor_script_text_editor.cpp | 2 +- main/main.cpp | 2 +- modules/gdscript/gdscript_editor.cpp | 2 +- modules/gdscript/gdscript_parser.cpp | 6 ++-- .../android/export/gradle_export_util.cpp | 2 +- scene/3d/mesh_instance.cpp | 4 +-- scene/main/scene_tree.cpp | 2 +- scene/main/viewport.cpp | 6 ++-- scene/resources/material/spatial_material.cpp | 2 +- servers/audio/audio_stream.cpp | 2 +- .../portals/portal_occlusion_culler.cpp | 2 +- servers/rendering_server.cpp | 8 ++--- 29 files changed, 76 insertions(+), 47 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 9db9935de..3e7646f8d 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -194,6 +194,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { for (int i = 0; i < custom_feature_array.size(); i++) { custom_features.insert(custom_feature_array[i]); } + _version++; return true; } @@ -207,6 +208,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { } } + _version++; return true; } bool ProjectSettings::_get(const StringName &p_name, Variant &r_ret) const { diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 0e0f913b6..3f0b5b524 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -67,6 +67,10 @@ class ProjectSettings : public Object { int _dirty_this_frame = 2; + // Starting version from 1 ensures that all callers can reset their tested version to 0, + // and will always detect the initial project settings as a "change". + uint32_t _version = 1; + public: typedef RBMap CustomMap; static const String PROJECT_DATA_DIR_NAME_SUFFIX; @@ -198,6 +202,10 @@ public: // There is therefore the potential for a change to be missed. Persisting the counter // for two frames avoids this, at the cost of a frame delay. bool has_changes() const { return _dirty_this_frame == 1; } + + // Testing a version allows fast cached GET_GLOBAL macros. + uint32_t get_version() const { return _version; } + void update(); ProjectSettings(); @@ -215,4 +223,23 @@ Variant _GLOBAL_DEF_ALIAS(const String &p_var, const String &p_old_name, const V #define GLOBAL_DEF_ALIAS_RST(m_var, m_old_name, m_value) _GLOBAL_DEF(m_var, m_old_name, m_value, true) #define GLOBAL_GET(m_var) ProjectSettings::get_singleton()->get(m_var) -#endif +///////////////////////////////////////////////////////////////////////////////////////// +// Cached versions of GLOBAL_GET. +// Cached but uses a typed variable for storage, this can be more efficient. +#define GLOBAL_GET_CACHED(m_type, m_setting_name) ([](const char *p_name) -> m_type {\ +static_assert(std::is_trivially_destructible::value, "GLOBAL_GET_CACHED must use a trivial type that allows static lifetime.");\ +static m_type local_var;\ +static uint32_t local_version = 0;\ +static Mutex local_mutex;\ +uint32_t new_version = ProjectSettings::get_singleton()->get_version();\ +if (local_version != new_version) {\ + MutexLock lock(local_mutex);\ + local_version = new_version;\ + local_var = ProjectSettings::get_singleton()->get(p_name);\ + return local_var;\ +}\ +MutexLock lock(local_mutex);\ +return local_var; })(m_setting_name) + +#endif // PROJECT_SETTINGS_H + diff --git a/core/error/error_macros.cpp b/core/error/error_macros.cpp index a32e11ea5..aaa799fa6 100644 --- a/core/error/error_macros.cpp +++ b/core/error/error_macros.cpp @@ -147,7 +147,7 @@ void _physics_interpolation_warning(const char *p_function, const char *p_file, warn_count = warn_max; warn_timeout = time_now + warn_timeout_seconds; - if (GLOBAL_GET("debug/settings/physics_interpolation/enable_warnings")) { + if (GLOBAL_GET_CACHED(bool, "debug/settings/physics_interpolation/enable_warnings")) { // UINT64_MAX means unused. if (p_id == UINT64_MAX) { _err_print_error(p_function, p_file, p_line, "[Physics interpolation] " + String(p_warn_string) + " (possibly benign).", ERR_HANDLER_WARNING); diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 997532067..96f74752f 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -276,7 +276,7 @@ void RasterizerGLES2::begin_frame(double frame_step) { frame_step = 0.001; } - double time_roll_over = GLOBAL_GET("rendering/limits/time/time_rollover_secs"); + double time_roll_over = GLOBAL_GET_CACHED(double, "rendering/limits/time/time_rollover_secs"); time_total = Math::fmod(time_total, time_roll_over); storage->frame.time[0] = time_total; diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 509c2f390..0d8c50fbe 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -4059,9 +4059,9 @@ void RasterizerSceneGLES2::initialize() { } void RasterizerSceneGLES2::iteration() { - shadow_filter_mode = ShadowFilterMode(int(GLOBAL_GET("rendering/quality/shadows/filter_mode"))); + shadow_filter_mode = ShadowFilterMode(int(GLOBAL_GET_CACHED(int32_t, "rendering/quality/shadows/filter_mode"))); - const int directional_shadow_size_new = next_power_of_2(int(GLOBAL_GET("rendering/quality/directional_shadow/size"))); + const int directional_shadow_size_new = next_power_of_2(GLOBAL_GET_CACHED(int32_t, "rendering/quality/directional_shadow/size")); if (directional_shadow_size != directional_shadow_size_new) { directional_shadow_size = directional_shadow_size_new; directional_shadow_create(); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 663fd9e54..9a3bcac47 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -2296,7 +2296,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } //bool has_morph = p_blend_shapes.size(); - bool use_split_stream = GLOBAL_GET("rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); + bool use_split_stream = GLOBAL_GET_CACHED(bool, "rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); Surface::Attrib attribs[RS::ARRAY_MAX]; diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index 6b30ca682..4268e0831 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -1226,7 +1226,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { //actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n"; //actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; - bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley"); + bool force_lambert = GLOBAL_GET_CACHED(bool, "rendering/quality/shading/force_lambert_over_burley"); if (!force_lambert) { actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; @@ -1236,7 +1236,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; - bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx"); + bool force_blinn = GLOBAL_GET_CACHED(bool, "rendering/quality/shading/force_blinn_over_ggx"); if (!force_blinn) { actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n"; diff --git a/drivers/gles2/shader_gles2.cpp b/drivers/gles2/shader_gles2.cpp index eabbeafea..e40375c42 100644 --- a/drivers/gles2/shader_gles2.cpp +++ b/drivers/gles2/shader_gles2.cpp @@ -178,7 +178,7 @@ ShaderGLES2::Version *ShaderGLES2::get_current_version() { strings.push_back("#define USE_HIGHP_PRECISION\n"); #endif - if (GLOBAL_GET("rendering/gles2/compatibility/enable_high_float.Android")) { + if (GLOBAL_GET_CACHED(bool, "rendering/gles2/compatibility/enable_high_float.Android")) { // enable USE_HIGHP_PRECISION but safeguarded by an availability check as highp support is optional in GLES2 // see Section 4.5.4 of the GLSL_ES_Specification_1.00 strings.push_back("#ifdef GL_FRAGMENT_PRECISION_HIGH\n #define USE_HIGHP_PRECISION\n#endif\n"); diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 22239493b..7c147c3d1 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -200,7 +200,7 @@ void RasterizerGLES3::begin_frame(double frame_step) { frame_step = 0.001; } - double time_roll_over = GLOBAL_GET("rendering/limits/time/time_rollover_secs"); + double time_roll_over = GLOBAL_GET_CACHED(double, "rendering/limits/time/time_rollover_secs"); time_total = Math::fmod(time_total, time_roll_over); storage->frame.time[0] = time_total; diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index d76aebaea..c7b1f326e 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -5315,22 +5315,22 @@ void RasterizerSceneGLES3::initialize() { } void RasterizerSceneGLES3::iteration() { - shadow_filter_mode = ShadowFilterMode(int(GLOBAL_GET("rendering/quality/shadows/filter_mode"))); + shadow_filter_mode = ShadowFilterMode(GLOBAL_GET_CACHED(int32_t, "rendering/quality/shadows/filter_mode")); - const int directional_shadow_size_new = next_power_of_2(int(GLOBAL_GET("rendering/quality/directional_shadow/size"))); + const int directional_shadow_size_new = next_power_of_2(GLOBAL_GET_CACHED(int32_t, "rendering/quality/directional_shadow/size")); if (directional_shadow_size != directional_shadow_size_new) { directional_shadow_size = directional_shadow_size_new; directional_shadow_create(); } - subsurface_scatter_follow_surface = GLOBAL_GET("rendering/quality/subsurface_scattering/follow_surface"); - subsurface_scatter_weight_samples = GLOBAL_GET("rendering/quality/subsurface_scattering/weight_samples"); - subsurface_scatter_quality = SubSurfaceScatterQuality(int(GLOBAL_GET("rendering/quality/subsurface_scattering/quality"))); - subsurface_scatter_size = GLOBAL_GET("rendering/quality/subsurface_scattering/scale"); + subsurface_scatter_follow_surface = GLOBAL_GET_CACHED(bool, "rendering/quality/subsurface_scattering/follow_surface"); + subsurface_scatter_weight_samples = GLOBAL_GET_CACHED(bool, "rendering/quality/subsurface_scattering/weight_samples"); + subsurface_scatter_quality = SubSurfaceScatterQuality(int(GLOBAL_GET_CACHED(int32_t, "rendering/quality/subsurface_scattering/quality"))); + subsurface_scatter_size = GLOBAL_GET_CACHED(float, "rendering/quality/subsurface_scattering/scale"); - storage->config.use_lightmap_filter_bicubic = GLOBAL_GET("rendering/quality/lightmapping/use_bicubic_sampling"); + storage->config.use_lightmap_filter_bicubic = GLOBAL_GET_CACHED(bool, "rendering/quality/lightmapping/use_bicubic_sampling"); state.scene_shader.set_conditional(SceneShaderGLES3::USE_LIGHTMAP_FILTER_BICUBIC, storage->config.use_lightmap_filter_bicubic); - state.scene_shader.set_conditional(SceneShaderGLES3::VCT_QUALITY_HIGH, GLOBAL_GET("rendering/quality/voxel_cone_tracing/high_quality")); + state.scene_shader.set_conditional(SceneShaderGLES3::VCT_QUALITY_HIGH, GLOBAL_GET_CACHED(bool, "rendering/quality/voxel_cone_tracing/high_quality")); } void RasterizerSceneGLES3::finalize() { diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 3d623b021..9011b54d6 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -3390,7 +3390,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, RS: } //bool has_morph = p_blend_shapes.size(); - bool use_split_stream = GLOBAL_GET("rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); + bool use_split_stream = GLOBAL_GET_CACHED(bool, "rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); Surface::Attrib attribs[RS::ARRAY_MAX]; diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 66d5bce64..a31686262 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -1268,7 +1268,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[RS::SHADER_SPATIAL].render_mode_defines["cull_front"] = "#define DO_SIDE_CHECK\n"; actions[RS::SHADER_SPATIAL].render_mode_defines["cull_disabled"] = "#define DO_SIDE_CHECK\n"; - bool force_lambert = GLOBAL_GET("rendering/quality/shading/force_lambert_over_burley"); + bool force_lambert = GLOBAL_GET_CACHED(bool, "rendering/quality/shading/force_lambert_over_burley"); if (!force_lambert) { actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_burley"] = "#define DIFFUSE_BURLEY\n"; @@ -1278,7 +1278,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_lambert_wrap"] = "#define DIFFUSE_LAMBERT_WRAP\n"; actions[RS::SHADER_SPATIAL].render_mode_defines["diffuse_toon"] = "#define DIFFUSE_TOON\n"; - bool force_blinn = GLOBAL_GET("rendering/quality/shading/force_blinn_over_ggx"); + bool force_blinn = GLOBAL_GET_CACHED(bool, "rendering/quality/shading/force_blinn_over_ggx"); if (!force_blinn) { actions[RS::SHADER_SPATIAL].render_mode_defines["specular_schlick_ggx"] = "#define SPECULAR_SCHLICK_GGX\n"; diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index b3e9c678e..5af645861 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -419,12 +419,12 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String tex_flags |= Texture::FLAG_REPEAT; const bool min_gles3 = GLOBAL_GET("rendering/quality/driver/driver_name") == "GLES3" && - !GLOBAL_GET("rendering/quality/driver/fallback_to_gles2"); + !GLOBAL_GET_CACHED(bool, "rendering/quality/driver/fallback_to_gles2"); if (!min_gles3 && !image->is_size_po2()) { // The project can be run using GLES2. GLES2 does not guarantee that // repeating textures with a non-power-of-two size will be displayed // without artifacts (due to upscaling to the nearest power of 2). - if (GLOBAL_GET("rendering/quality/driver/fallback_to_gles2")) { + if (GLOBAL_GET_CACHED(bool, "rendering/quality/driver/fallback_to_gles2")) { WARN_PRINT(vformat("%s: Imported a repeating texture with a size of %dx%d, but the project is configured to allow falling back to GLES2.\nNon-power-of-2 repeating textures may not display correctly on some platforms such as HTML5. This is because GLES2 does not mandate support for non-power-of-2 repeating textures.", p_source_file, image->get_width(), image->get_height())); } else { diff --git a/editor/plugins/animation_player_editor_plugin.cpp b/editor/plugins/animation_player_editor_plugin.cpp index 23bfe6833..1386d7538 100644 --- a/editor/plugins/animation_player_editor_plugin.cpp +++ b/editor/plugins/animation_player_editor_plugin.cpp @@ -1475,7 +1475,7 @@ void AnimationPlayerEditor::_prepare_onion_layers_2() { // Render every past/future step with the capture shader. RS::get_singleton()->canvas_item_set_material(onion.capture.canvas_item, onion.capture.material->get_rid()); - onion.capture.material->set_shader_param("bkg_color", GLOBAL_GET("rendering/environment/default_clear_color")); + onion.capture.material->set_shader_param("bkg_color", GLOBAL_GET_CACHED(Color, "rendering/environment/default_clear_color")); onion.capture.material->set_shader_param("differences_only", onion.differences_only); onion.capture.material->set_shader_param("present", onion.differences_only ? RS::get_singleton()->viewport_get_texture(present_rid) : RID()); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 6c5dbcc1f..f95e82fe6 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -3677,7 +3677,7 @@ void CanvasItemEditor::set_current_tool(Tool p_tool) { void CanvasItemEditor::_notification(int p_what) { if (p_what == NOTIFICATION_PHYSICS_PROCESS) { - EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET("gui/common/snap_controls_to_pixels")); + EditorNode::get_singleton()->get_scene_root()->set_snap_controls_to_pixels(GLOBAL_GET_CACHED(bool, "gui/common/snap_controls_to_pixels")); bool has_container_parents = false; int nb_control = 0; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 729a603bb..bc5f82d1f 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -894,7 +894,7 @@ Ref EditorFontPreviewPlugin::generate_from_path(const String &p_path, c Ref font = sampled_font; - const Color c = GLOBAL_GET("rendering/environment/default_clear_color"); + const Color c = GLOBAL_GET_CACHED(Color, "rendering/environment/default_clear_color"); const float fg = c.get_luminance() < 0.5 ? 1.0 : 0.0; font->draw(canvas_item, pos, sampled_text, Color(fg, fg, fg)); diff --git a/editor/plugins/theme_editor_preview.cpp b/editor/plugins/theme_editor_preview.cpp index 9e469bebd..a0eb1d7bb 100644 --- a/editor/plugins/theme_editor_preview.cpp +++ b/editor/plugins/theme_editor_preview.cpp @@ -96,7 +96,7 @@ void ThemeEditorPreview::_propagate_redraw(Control *p_at) { void ThemeEditorPreview::_refresh_interval() { // In case the project settings have changed. - preview_bg->set_frame_color(GLOBAL_GET("rendering/environment/default_clear_color")); + preview_bg->set_frame_color(GLOBAL_GET_CACHED(Color, "rendering/environment/default_clear_color")); _propagate_redraw(preview_bg); _propagate_redraw(preview_content); diff --git a/editor_modules/editor_code_editor/editor_script_text_editor.cpp b/editor_modules/editor_code_editor/editor_script_text_editor.cpp index e44386bc2..ef2e45956 100644 --- a/editor_modules/editor_code_editor/editor_script_text_editor.cpp +++ b/editor_modules/editor_code_editor/editor_script_text_editor.cpp @@ -446,7 +446,7 @@ void EditorScriptTextEditor::_validate_script() { warnings_panel->clear(); // Add missing connections. - if (GLOBAL_GET("debug/gdscript/warnings/enable").booleanize()) { + if (GLOBAL_GET_CACHED(bool, "debug/gdscript/warnings/enable")) { Node *base = get_tree()->get_edited_scene_root(); if (base && missing_connections.size() > 0) { warnings_panel->push_table(1); diff --git a/main/main.cpp b/main/main.cpp index 822bd3145..56c72fac0 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2544,7 +2544,7 @@ bool Main::iteration() { if (print_fps) { print_line(vformat("Editor FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2))); } - } else if (print_fps || GLOBAL_GET("debug/settings/stdout/print_fps")) { + } else if (print_fps || GLOBAL_GET_CACHED(bool, "debug/settings/stdout/print_fps")) { print_line(vformat("Project FPS: %d (%s mspf)", frames, rtos(1000.0 / frames).pad_decimals(2))); } } else { diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index 8d5a9e799..f78a60bcb 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -2091,7 +2091,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionContext &p_context if (!_static) { List methods; - bool is_autocompleting_getters = GLOBAL_GET("debug/gdscript/completion/autocomplete_setters_and_getters").booleanize(); + bool is_autocompleting_getters = GLOBAL_GET_CACHED(bool, "debug/gdscript/completion/autocomplete_setters_and_getters"); ClassDB::get_method_list(type, &methods, false, !is_autocompleting_getters); for (List::Element *E = methods.front(); E; E = E->next()) { if (E->get().name.begins_with("_")) { diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index b0d5798c1..765c2dc22 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -8703,10 +8703,10 @@ void GDScriptParser::_add_warning(int p_code, int p_line, const String &p_symbol } void GDScriptParser::_add_warning(int p_code, int p_line, const Vector &p_symbols) { - if (GLOBAL_GET("debug/gdscript/warnings/exclude_addons").booleanize() && base_path.begins_with("res://addons/")) { + if (GLOBAL_GET_CACHED(bool, "debug/gdscript/warnings/exclude_addons") && base_path.begins_with("res://addons/")) { return; } - if (tokenizer->is_ignoring_warnings() || !GLOBAL_GET("debug/gdscript/warnings/enable").booleanize()) { + if (tokenizer->is_ignoring_warnings() || !GLOBAL_GET_CACHED(bool, "debug/gdscript/warnings/enable")) { return; } String warn_name = GDScriptWarning::get_name_from_code((GDScriptWarning::Code)p_code).to_lower(); @@ -8820,7 +8820,7 @@ Error GDScriptParser::_parse(const String &p_base_path) { // Resolve warning ignores Vector> warning_skips = tokenizer->get_warning_skips(); - bool warning_is_error = GLOBAL_GET("debug/gdscript/warnings/treat_warnings_as_errors").booleanize(); + bool warning_is_error = GLOBAL_GET_CACHED(bool, "debug/gdscript/warnings/treat_warnings_as_errors"); for (List::Element *E = warnings.front(); E;) { GDScriptWarning &w = E->get(); int skip_index = -1; diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp index a7db010f3..f1845853a 100644 --- a/platform/android/export/gradle_export_util.cpp +++ b/platform/android/export/gradle_export_util.cpp @@ -223,7 +223,7 @@ String _get_activity_tag(const Ref &p_preset) { "android:resizeableActivity=\"%s\">\n", bool_to_string(p_preset->get("package/exclude_from_recents")), orientation, - bool_to_string(bool(GLOBAL_GET("display/window/size/resizable")))); + bool_to_string(GLOBAL_GET_CACHED(bool, "display/window/size/resizable"))); manifest_activity_text += " \n"; manifest_activity_text += " \n"; return manifest_activity_text; diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 2b870133d..26a4f95e4 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -202,12 +202,12 @@ void MeshInstance::_resolve_skeleton_path() { bool MeshInstance::_is_global_software_skinning_enabled() { // Check if forced in project settings. - if (GLOBAL_GET("rendering/quality/skinning/force_software_skinning")) { + if (GLOBAL_GET_CACHED(bool, "rendering/quality/skinning/force_software_skinning")) { return true; } // Check if enabled in project settings. - if (!GLOBAL_GET("rendering/quality/skinning/software_skinning_fallback")) { + if (!GLOBAL_GET_CACHED(bool, "rendering/quality/skinning/software_skinning_fallback")) { return false; } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index d959b5fff..f443ca0fe 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -652,7 +652,7 @@ bool SceneTree::iteration(float p_time) { call_group_flags(GROUP_CALL_REALTIME, "_pg_process", "trigger_physics_process"); _notify_group_pause("physics_process_internal", Node::NOTIFICATION_INTERNAL_PHYSICS_PROCESS); - if (GLOBAL_GET("physics/common/enable_pause_aware_picking")) { + if (GLOBAL_GET_CACHED(bool, "physics/common/enable_pause_aware_picking")) { call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_process_picking", true); } _notify_group_pause("physics_process", Node::NOTIFICATION_PHYSICS_PROCESS); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index b8e4cfb44..8fcb8822d 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -174,14 +174,14 @@ class TooltipPanel : public PanelContainer { GDCLASS(TooltipPanel, PanelContainer); public: - TooltipPanel() {}; + TooltipPanel() {} }; class TooltipLabel : public Label { GDCLASS(TooltipLabel, Label); public: - TooltipLabel() {}; + TooltipLabel() {} }; ///////////////////////////////////// @@ -387,7 +387,7 @@ void Viewport::_notification(int p_what) { } } - if (!GLOBAL_GET("physics/common/enable_pause_aware_picking")) { + if (!GLOBAL_GET_CACHED(bool, "physics/common/enable_pause_aware_picking")) { _process_picking(false); } } break; diff --git a/scene/resources/material/spatial_material.cpp b/scene/resources/material/spatial_material.cpp index cf2523370..a91def7f0 100644 --- a/scene/resources/material/spatial_material.cpp +++ b/scene/resources/material/spatial_material.cpp @@ -2194,7 +2194,7 @@ SpatialMaterial::SpatialMaterial(bool p_orm) : flags[i] = false; } - force_vertex_shading = GLOBAL_GET("rendering/quality/shading/force_vertex_shading"); + force_vertex_shading = GLOBAL_GET_CACHED(bool, "rendering/quality/shading/force_vertex_shading"); diffuse_mode = DIFFUSE_BURLEY; specular_mode = SPECULAR_SCHLICK_GGX; diff --git a/servers/audio/audio_stream.cpp b/servers/audio/audio_stream.cpp index 4c07312e9..d08427ee6 100644 --- a/servers/audio/audio_stream.cpp +++ b/servers/audio/audio_stream.cpp @@ -185,7 +185,7 @@ void AudioStreamPlaybackMicrophone::start(float p_from_pos) { return; } - if (!GLOBAL_GET("audio/enable_audio_input")) { + if (!GLOBAL_GET_CACHED(bool, "audio/enable_audio_input")) { WARN_PRINT("Need to enable Project settings > Audio > Enable Audio Input option to use capturing."); return; } diff --git a/servers/rendering/portals/portal_occlusion_culler.cpp b/servers/rendering/portals/portal_occlusion_culler.cpp index 0db6f0928..e26ce8370 100644 --- a/servers/rendering/portals/portal_occlusion_culler.cpp +++ b/servers/rendering/portals/portal_occlusion_culler.cpp @@ -249,7 +249,7 @@ void PortalOcclusionCuller::prepare_generic(PortalRenderer &p_portal_renderer, c // Bodge to keep settings up to date, until the project settings PR is merged #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && ((Engine::get_singleton()->get_frames_drawn() % 16) == 0)) { - _max_polys = GLOBAL_GET("rendering/misc/occlusion_culling/max_active_polygons"); + _max_polys = GLOBAL_GET_CACHED(int32_t, "rendering/misc/occlusion_culling/max_active_polygons"); } #endif _num_spheres = 0; diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index eee3ee95a..9f6cdca54 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -870,7 +870,7 @@ uint32_t RenderingServer::mesh_surface_get_format_stride(uint32_t p_format, int } void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, int p_vertex_len, int p_index_len, uint32_t *r_offsets, uint32_t *r_strides) const { - bool use_split_stream = GLOBAL_GET("rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); + bool use_split_stream = GLOBAL_GET_CACHED(bool, "rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); int attributes_base_offset = 0; int attributes_stride = 0; @@ -1248,7 +1248,7 @@ bool RenderingServer::_mesh_find_format(RS::PrimitiveType p_primitive, const Arr } uint32_t RenderingServer::mesh_find_format_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, uint32_t p_compress_format) { - bool use_split_stream = GLOBAL_GET("rendering/misc/mesh_storage/split_stream") && !(p_compress_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); + bool use_split_stream = GLOBAL_GET_CACHED(bool, "rendering/misc/mesh_storage/split_stream") && !(p_compress_format & rS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); uint32_t offsets[RS::ARRAY_MAX]; @@ -1268,7 +1268,7 @@ uint32_t RenderingServer::mesh_find_format_from_arrays(PrimitiveType p_primitive } void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes, uint32_t p_compress_format) { - bool use_split_stream = GLOBAL_GET("rendering/misc/mesh_storage/split_stream") && !(p_compress_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); + bool use_split_stream = GLOBAL_GET_CACHED(bool, "rendering/misc/mesh_storage/split_stream") && !(p_compress_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); uint32_t offsets[RS::ARRAY_MAX]; @@ -1338,7 +1338,7 @@ void RenderingServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_p } Array RenderingServer::_get_array_from_surface(uint32_t p_format, PoolVector p_vertex_data, int p_vertex_len, PoolVector p_index_data, int p_index_len) const { - bool use_split_stream = GLOBAL_GET("rendering/misc/mesh_storage/split_stream") && !(p_format & RS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); + bool use_split_stream = GLOBAL_GET_CACHED(bool, "rendering/misc/mesh_storage/split_stream") && !(p_format & rS::ARRAY_FLAG_USE_DYNAMIC_UPDATE); uint32_t offsets[ARRAY_MAX]; uint32_t strides[RS::ARRAY_MAX];