summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/classes/RenderSceneBuffersRD.xml36
-rw-r--r--editor/editor_node.cpp8
-rw-r--r--editor/editor_node.h1
-rw-r--r--editor/groups_editor.cpp5
-rw-r--r--main/main.cpp12
-rw-r--r--platform/windows/gl_manager_windows_native.cpp43
-rw-r--r--platform/windows/gl_manager_windows_native.h2
-rw-r--r--scene/main/node.h2
-rw-r--r--servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp6
9 files changed, 96 insertions, 19 deletions
diff --git a/doc/classes/RenderSceneBuffersRD.xml b/doc/classes/RenderSceneBuffersRD.xml
index 359f0b33a8..212a65337e 100644
--- a/doc/classes/RenderSceneBuffersRD.xml
+++ b/doc/classes/RenderSceneBuffersRD.xml
@@ -89,6 +89,12 @@
If [param msaa] is [b]true[/b] and MSAA is enabled, this returns the MSAA variant of the buffer.
</description>
</method>
+ <method name="get_fsr_sharpness" qualifiers="const">
+ <return type="float" />
+ <description>
+ Returns the FSR sharpness value used while rendering the 3D content (if [method get_scaling_3d_mode] is an FSR mode).
+ </description>
+ </method>
<method name="get_internal_size" qualifiers="const">
<return type="Vector2i" />
<description>
@@ -107,6 +113,24 @@
Returns the render target associated with this buffers object.
</description>
</method>
+ <method name="get_scaling_3d_mode" qualifiers="const">
+ <return type="int" enum="RenderingServer.ViewportScaling3DMode" />
+ <description>
+ Returns the scaling mode used for upscaling.
+ </description>
+ </method>
+ <method name="get_screen_space_aa" qualifiers="const">
+ <return type="int" enum="RenderingServer.ViewportScreenSpaceAA" />
+ <description>
+ Returns the screen-space antialiasing method applied.
+ </description>
+ </method>
+ <method name="get_target_size" qualifiers="const">
+ <return type="Vector2i" />
+ <description>
+ Returns the target size of the render buffer (size after upscaling).
+ </description>
+ </method>
<method name="get_texture" qualifiers="const">
<return type="RID" />
<param index="0" name="context" type="StringName" />
@@ -123,6 +147,12 @@
Returns the texture format information with which a cached texture was created.
</description>
</method>
+ <method name="get_texture_samples" qualifiers="const">
+ <return type="int" enum="RenderingDevice.TextureSamples" />
+ <description>
+ Returns the number of MSAA samples used.
+ </description>
+ </method>
<method name="get_texture_slice">
<return type="RID" />
<param index="0" name="context" type="StringName" />
@@ -157,6 +187,12 @@
Returns a specific view of a slice (layer or mipmap) for a cached texture.
</description>
</method>
+ <method name="get_use_debanding" qualifiers="const">
+ <return type="bool" />
+ <description>
+ Returns [code]true[/code] if debanding is enabled.
+ </description>
+ </method>
<method name="get_use_taa" qualifiers="const">
<return type="bool" />
<description>
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 4479eeb66a..941b1d00a2 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -3340,13 +3340,17 @@ void EditorNode::_exit_editor(int p_exit_code) {
dim_editor(true);
// Unload addons before quitting to allow cleanup.
+ unload_editor_addons();
+
+ get_tree()->quit(p_exit_code);
+}
+
+void EditorNode::unload_editor_addons() {
for (const KeyValue<String, EditorPlugin *> &E : addon_name_to_plugin) {
print_verbose(vformat("Unloading addon: %s", E.key));
remove_editor_plugin(E.value, false);
memdelete(E.value);
}
-
- get_tree()->quit(p_exit_code);
}
void EditorNode::_discard_changes(const String &p_str) {
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 7a26156ab8..a2ee61697f 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -908,6 +908,7 @@ public:
void save_before_run();
void try_autosave();
void restart_editor();
+ void unload_editor_addons();
void dim_editor(bool p_dimming);
bool is_editor_dimmed() const;
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 6cfc035fc9..a5f7e8556c 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -275,6 +275,11 @@ void GroupsEditor::_queue_update_groups_and_tree() {
void GroupsEditor::_update_groups_and_tree() {
update_groups_and_tree_queued = false;
+ // The scene_root_node could be unset before we actually run this code because this is queued with call_deferred().
+ // In that case NOTIFICATION_VISIBILITY_CHANGED will call this function again soon.
+ if (!scene_root_node) {
+ return;
+ }
_update_groups();
_update_tree();
}
diff --git a/main/main.cpp b/main/main.cpp
index 86abf94c0a..870f7d31b8 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -4170,7 +4170,13 @@ bool Main::iteration() {
movie_writer->add_frame();
}
+#ifdef TOOLS_ENABLED
+ bool quit_after_timeout = false;
+#endif
if ((quit_after > 0) && (Engine::get_singleton()->_process_frames >= quit_after)) {
+#ifdef TOOLS_ENABLED
+ quit_after_timeout = true;
+#endif
exit = true;
}
@@ -4203,6 +4209,12 @@ bool Main::iteration() {
}
#endif
+#ifdef TOOLS_ENABLED
+ if (exit && quit_after_timeout && EditorNode::get_singleton()) {
+ EditorNode::get_singleton()->unload_editor_addons();
+ }
+#endif
+
return exit;
}
diff --git a/platform/windows/gl_manager_windows_native.cpp b/platform/windows/gl_manager_windows_native.cpp
index c8d7534e26..f74aa4ced7 100644
--- a/platform/windows/gl_manager_windows_native.cpp
+++ b/platform/windows/gl_manager_windows_native.cpp
@@ -76,6 +76,8 @@ static String format_error_message(DWORD id) {
const int OGL_THREAD_CONTROL_ID = 0x20C1221E;
const int OGL_THREAD_CONTROL_DISABLE = 0x00000002;
const int OGL_THREAD_CONTROL_ENABLE = 0x00000001;
+const int VRR_MODE_ID = 0x1194F158;
+const int VRR_MODE_FULLSCREEN_ONLY = 0x1;
typedef int(__cdecl *NvAPI_Initialize_t)();
typedef int(__cdecl *NvAPI_Unload_t)();
@@ -104,10 +106,12 @@ static bool nvapi_err_check(const char *msg, int status) {
return true;
}
-// On windows we have to disable threaded optimization when using NVIDIA graphics cards
-// to avoid stuttering, see https://stackoverflow.com/questions/36959508/nvidia-graphics-driver-causing-noticeable-frame-stuttering/37632948
-// also see https://github.com/Ryujinx/Ryujinx/blob/master/src/Ryujinx.Common/GraphicsDriver/NVThreadedOptimization.cs
-void GLManagerNative_Windows::_nvapi_disable_threaded_optimization() {
+// On windows we have to customize the NVIDIA application profile:
+// * disable threaded optimization when using NVIDIA cards to avoid stuttering, see
+// https://stackoverflow.com/questions/36959508/nvidia-graphics-driver-causing-noticeable-frame-stuttering/37632948
+// https://github.com/Ryujinx/Ryujinx/blob/master/src/Ryujinx.Common/GraphicsDriver/NVThreadedOptimization.cs
+// * disable G-SYNC in windowed mode, as it results in unstable editor refresh rates
+void GLManagerNative_Windows::_nvapi_setup_profile() {
HMODULE nvapi = nullptr;
#ifdef _WIN64
nvapi = LoadLibraryA("nvapi64.dll");
@@ -239,21 +243,29 @@ void GLManagerNative_Windows::_nvapi_disable_threaded_optimization() {
}
}
- NVDRS_SETTING setting;
- setting.version = NVDRS_SETTING_VER;
- setting.settingId = OGL_THREAD_CONTROL_ID;
- setting.settingType = NVDRS_DWORD_TYPE;
- setting.settingLocation = NVDRS_CURRENT_PROFILE_LOCATION;
- setting.isCurrentPredefined = 0;
- setting.isPredefinedValid = 0;
+ NVDRS_SETTING ogl_thread_control_setting = { 0 };
+ ogl_thread_control_setting.version = NVDRS_SETTING_VER;
+ ogl_thread_control_setting.settingId = OGL_THREAD_CONTROL_ID;
+ ogl_thread_control_setting.settingType = NVDRS_DWORD_TYPE;
int thread_control_val = OGL_THREAD_CONTROL_DISABLE;
if (!GLOBAL_GET("rendering/gl_compatibility/nvidia_disable_threaded_optimization")) {
thread_control_val = OGL_THREAD_CONTROL_ENABLE;
}
- setting.u32CurrentValue = thread_control_val;
- setting.u32PredefinedValue = thread_control_val;
+ ogl_thread_control_setting.u32CurrentValue = thread_control_val;
- if (!nvapi_err_check("NVAPI: Error calling NvAPI_DRS_SetSetting", NvAPI_DRS_SetSetting(session_handle, profile_handle, &setting))) {
+ if (!nvapi_err_check("NVAPI: Error calling NvAPI_DRS_SetSetting", NvAPI_DRS_SetSetting(session_handle, profile_handle, &ogl_thread_control_setting))) {
+ NvAPI_DRS_DestroySession(session_handle);
+ NvAPI_Unload();
+ return;
+ }
+
+ NVDRS_SETTING vrr_mode_setting = { 0 };
+ vrr_mode_setting.version = NVDRS_SETTING_VER;
+ vrr_mode_setting.settingId = VRR_MODE_ID;
+ vrr_mode_setting.settingType = NVDRS_DWORD_TYPE;
+ vrr_mode_setting.u32CurrentValue = VRR_MODE_FULLSCREEN_ONLY;
+
+ if (!nvapi_err_check("NVAPI: Error calling NvAPI_DRS_SetSetting", NvAPI_DRS_SetSetting(session_handle, profile_handle, &vrr_mode_setting))) {
NvAPI_DRS_DestroySession(session_handle);
NvAPI_Unload();
return;
@@ -270,6 +282,7 @@ void GLManagerNative_Windows::_nvapi_disable_threaded_optimization() {
} else {
print_verbose("NVAPI: Enabled OpenGL threaded optimization successfully");
}
+ print_verbose("NVAPI: Disabled G-SYNC for windowed mode successfully");
NvAPI_DRS_DestroySession(session_handle);
}
@@ -495,7 +508,7 @@ void GLManagerNative_Windows::swap_buffers() {
}
Error GLManagerNative_Windows::initialize() {
- _nvapi_disable_threaded_optimization();
+ _nvapi_setup_profile();
return OK;
}
diff --git a/platform/windows/gl_manager_windows_native.h b/platform/windows/gl_manager_windows_native.h
index b4e2a3acdf..532092ae74 100644
--- a/platform/windows/gl_manager_windows_native.h
+++ b/platform/windows/gl_manager_windows_native.h
@@ -78,7 +78,7 @@ private:
int glx_minor, glx_major;
private:
- void _nvapi_disable_threaded_optimization();
+ void _nvapi_setup_profile();
int _find_or_create_display(GLWindow &win);
Error _create_context(GLWindow &win, GLDisplay &gl_display);
diff --git a/scene/main/node.h b/scene/main/node.h
index 6b93724478..ee195ddef9 100644
--- a/scene/main/node.h
+++ b/scene/main/node.h
@@ -596,7 +596,7 @@ public:
// No thread processing.
// Only accessible if node is outside the scene tree
// or access will happen from a node-safe thread.
- return !data.inside_tree || is_current_thread_safe_for_nodes();
+ return is_current_thread_safe_for_nodes() || unlikely(!data.inside_tree);
} else {
// Thread processing.
return true;
diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
index b5fdf8bebb..2f44096dc8 100644
--- a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
+++ b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp
@@ -70,8 +70,14 @@ void RenderSceneBuffersRD::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_render_target"), &RenderSceneBuffersRD::get_render_target);
ClassDB::bind_method(D_METHOD("get_view_count"), &RenderSceneBuffersRD::get_view_count);
ClassDB::bind_method(D_METHOD("get_internal_size"), &RenderSceneBuffersRD::get_internal_size);
+ ClassDB::bind_method(D_METHOD("get_target_size"), &RenderSceneBuffersRD::get_target_size);
+ ClassDB::bind_method(D_METHOD("get_scaling_3d_mode"), &RenderSceneBuffersRD::get_scaling_3d_mode);
+ ClassDB::bind_method(D_METHOD("get_fsr_sharpness"), &RenderSceneBuffersRD::get_fsr_sharpness);
ClassDB::bind_method(D_METHOD("get_msaa_3d"), &RenderSceneBuffersRD::get_msaa_3d);
+ ClassDB::bind_method(D_METHOD("get_texture_samples"), &RenderSceneBuffersRD::get_texture_samples);
+ ClassDB::bind_method(D_METHOD("get_screen_space_aa"), &RenderSceneBuffersRD::get_screen_space_aa);
ClassDB::bind_method(D_METHOD("get_use_taa"), &RenderSceneBuffersRD::get_use_taa);
+ ClassDB::bind_method(D_METHOD("get_use_debanding"), &RenderSceneBuffersRD::get_use_debanding);
}
void RenderSceneBuffersRD::update_sizes(NamedTexture &p_named_texture) {