From c273786758d0035c0614f81419a422238a2a8a04 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 21 Aug 2024 09:56:58 +0300 Subject: [PATCH] Update rendering driver name on fallbacks. Fix rendering driver/method in the editor system info. --- core/os/os.h | 6 ++--- editor/editor_node.cpp | 25 +++++++++++++++---- main/main.cpp | 9 +++---- .../wayland/display_server_wayland.cpp | 1 + platform/linuxbsd/x11/display_server_x11.cpp | 1 + platform/macos/display_server_macos.mm | 1 + platform/windows/display_server_windows.cpp | 3 +++ 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/core/os/os.h b/core/os/os.h index be8820eba9d..e6ce5277207 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -111,9 +111,6 @@ protected: virtual void initialize() = 0; virtual void initialize_joypads() = 0; - void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; } - void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; } - void set_display_driver_id(int p_display_driver_id) { _display_driver_id = p_display_driver_id; } virtual void set_main_loop(MainLoop *p_main_loop) = 0; @@ -131,6 +128,9 @@ public: static OS *get_singleton(); + void set_current_rendering_driver_name(const String &p_driver_name) { _current_rendering_driver_name = p_driver_name; } + void set_current_rendering_method(const String &p_name) { _current_rendering_method = p_name; } + String get_current_rendering_driver_name() const { return _current_rendering_driver_name; } String get_current_rendering_method() const { return _current_rendering_method; } diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d3fa2ed716f..59c8b63d6de 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -167,6 +167,10 @@ #include "modules/modules_enabled.gen.h" // For gdscript, mono. +#if defined(GLES3_ENABLED) +#include "drivers/gles3/rasterizer_gles3.h" +#endif + EditorNode *EditorNode::singleton = nullptr; static const String EDITOR_NODE_CONFIG_SECTION = "EditorNode"; @@ -5016,8 +5020,8 @@ String EditorNode::_get_system_info() const { #ifdef LINUXBSD_ENABLED const String display_server = OS::get_singleton()->get_environment("XDG_SESSION_TYPE").capitalize().replace(" ", ""); // `replace` is necessary, because `capitalize` introduces a whitespace between "x" and "11". #endif // LINUXBSD_ENABLED - String driver_name = GLOBAL_GET("rendering/rendering_device/driver"); - String rendering_method = GLOBAL_GET("rendering/renderer/rendering_method"); + String driver_name = OS::get_singleton()->get_current_rendering_driver_name().to_lower(); + String rendering_method = OS::get_singleton()->get_current_rendering_method().to_lower(); const String rendering_device_name = RenderingServer::get_singleton()->get_video_adapter_name(); @@ -5053,12 +5057,23 @@ String EditorNode::_get_system_info() const { rendering_method = "Mobile"; } else if (rendering_method == "gl_compatibility") { rendering_method = "Compatibility"; - driver_name = GLOBAL_GET("rendering/gl_compatibility/driver"); } if (driver_name == "vulkan") { driver_name = "Vulkan"; - } else if (driver_name.begins_with("opengl3")) { - driver_name = "GLES3"; + } else if (driver_name == "d3d12") { + driver_name = "Direct3D 12"; +#if defined(GLES3_ENABLED) + } else if (driver_name == "opengl3_angle") { + driver_name = "OpenGL ES 3/ANGLE"; + } else if (driver_name == "opengl3_es") { + driver_name = "OpenGL ES 3"; + } else if (driver_name == "opengl3") { + if (RasterizerGLES3::is_gles_over_gl()) { + driver_name = "OpenGL 3"; + } else { + driver_name = "OpenGL ES 3"; + } +#endif } else if (driver_name == "metal") { driver_name = "Metal"; } diff --git a/main/main.cpp b/main/main.cpp index 101fc642b66..f2f71c27a42 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -2327,15 +2327,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } } - // note this is the desired rendering driver, it doesn't mean we will get it. - // TODO - make sure this is updated in the case of fallbacks, so that the user interface - // shows the correct driver string. - OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); - OS::get_singleton()->set_current_rendering_method(rendering_method); - // always convert to lower case for consistency in the code rendering_driver = rendering_driver.to_lower(); + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); + OS::get_singleton()->set_current_rendering_method(rendering_method); + if (use_custom_res) { if (!force_res) { window_size.width = GLOBAL_GET("display/window/size/viewport_width"); diff --git a/platform/linuxbsd/wayland/display_server_wayland.cpp b/platform/linuxbsd/wayland/display_server_wayland.cpp index 93096fcdcc6..d1d83fe4cec 100644 --- a/platform/linuxbsd/wayland/display_server_wayland.cpp +++ b/platform/linuxbsd/wayland/display_server_wayland.cpp @@ -1429,6 +1429,7 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win if (fallback) { WARN_PRINT("Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES."); rendering_driver = "opengl3_es"; + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else { r_error = ERR_UNAVAILABLE; ERR_FAIL_MSG("Could not initialize OpenGL."); diff --git a/platform/linuxbsd/x11/display_server_x11.cpp b/platform/linuxbsd/x11/display_server_x11.cpp index 8a2f83be2d9..e602963c542 100644 --- a/platform/linuxbsd/x11/display_server_x11.cpp +++ b/platform/linuxbsd/x11/display_server_x11.cpp @@ -6231,6 +6231,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode if (fallback) { WARN_PRINT("Your video card drivers seem not to support the required OpenGL version, switching to OpenGLES."); rendering_driver = "opengl3_es"; + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else { r_error = ERR_UNAVAILABLE; ERR_FAIL_MSG("Could not initialize OpenGL."); diff --git a/platform/macos/display_server_macos.mm b/platform/macos/display_server_macos.mm index 989a9dcf6c5..52dc51bc960 100644 --- a/platform/macos/display_server_macos.mm +++ b/platform/macos/display_server_macos.mm @@ -3615,6 +3615,7 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM WARN_PRINT("Your video card drivers seem not to support GLES3 / ANGLE or ANGLE dynamic libraries (libEGL.dylib and libGLESv2.dylib) are missing, switching to native OpenGL."); #endif rendering_driver = "opengl3"; + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); } else { r_error = ERR_UNAVAILABLE; ERR_FAIL_MSG("Could not initialize ANGLE OpenGL."); diff --git a/platform/windows/display_server_windows.cpp b/platform/windows/display_server_windows.cpp index 8bcd556c220..602ca5f52eb 100644 --- a/platform/windows/display_server_windows.cpp +++ b/platform/windows/display_server_windows.cpp @@ -6150,6 +6150,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win if (rendering_context->initialize() == OK) { WARN_PRINT("Your video card drivers seem not to support Direct3D 12, switching to Vulkan."); rendering_driver = "vulkan"; + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); failed = false; } } @@ -6163,6 +6164,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win if (rendering_context->initialize() == OK) { WARN_PRINT("Your video card drivers seem not to support Vulkan, switching to Direct3D 12."); rendering_driver = "d3d12"; + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); failed = false; } } @@ -6241,6 +6243,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win } } rendering_driver = "opengl3_angle"; + OS::get_singleton()->set_current_rendering_driver_name(rendering_driver); } }