Merge pull request #91780 from Riteo/falling-with-style
Improve UX when falling back between Display Servers
This commit is contained in:
commit
8eff04192b
|
@ -2903,6 +2903,8 @@ Error Main::setup2(bool p_show_boot_logo) {
|
|||
Error err;
|
||||
display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, err);
|
||||
if (err != OK || display_server == nullptr) {
|
||||
String last_name = DisplayServer::get_create_function_name(display_driver_idx);
|
||||
|
||||
// We can't use this display server, try other ones as fallback.
|
||||
// Skip headless (always last registered) because that's not what users
|
||||
// would expect if they didn't request it explicitly.
|
||||
|
@ -2910,6 +2912,9 @@ Error Main::setup2(bool p_show_boot_logo) {
|
|||
if (i == display_driver_idx) {
|
||||
continue; // Don't try the same twice.
|
||||
}
|
||||
String name = DisplayServer::get_create_function_name(i);
|
||||
WARN_PRINT(vformat("Display driver %s failed, falling back to %s.", last_name, name));
|
||||
|
||||
display_server = DisplayServer::create(i, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, context, err);
|
||||
if (err == OK && display_server != nullptr) {
|
||||
break;
|
||||
|
|
|
@ -1349,23 +1349,39 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
|
|||
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
bool driver_found = false;
|
||||
String executable_name = OS::get_singleton()->get_executable_path().get_file();
|
||||
|
||||
#ifdef RD_ENABLED
|
||||
#ifdef VULKAN_ENABLED
|
||||
if (rendering_driver == "vulkan") {
|
||||
rendering_context = memnew(RenderingContextDriverVulkanWayland);
|
||||
}
|
||||
#endif
|
||||
#endif // VULKAN_ENABLED
|
||||
|
||||
if (rendering_context) {
|
||||
if (rendering_context->initialize() != OK) {
|
||||
ERR_PRINT(vformat("Could not initialize %s", rendering_driver));
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
r_error = ERR_CANT_CREATE;
|
||||
return;
|
||||
|
||||
if (p_rendering_driver == "vulkan") {
|
||||
OS::get_singleton()->alert(
|
||||
vformat("Your video card drivers seem not to support the required Vulkan version.\n\n"
|
||||
"If possible, consider updating your video card drivers or using the OpenGL 3 driver.\n\n"
|
||||
"You can enable the OpenGL 3 driver by starting the engine from the\n"
|
||||
"command line with the command:\n\n \"%s\" --rendering-driver opengl3\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
executable_name),
|
||||
"Unable to initialize Vulkan video driver");
|
||||
}
|
||||
|
||||
ERR_FAIL_MSG(vformat("Could not initialize %s", rendering_driver));
|
||||
}
|
||||
#endif
|
||||
|
||||
driver_found = true;
|
||||
}
|
||||
#endif // RD_ENABLED
|
||||
|
||||
#ifdef GLES3_ENABLED
|
||||
if (rendering_driver == "opengl3" || rendering_driver == "opengl3_es") {
|
||||
|
@ -1432,26 +1448,53 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
|
|||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
|
||||
OS::get_singleton()->alert(
|
||||
vformat("Your video card drivers seem not to support the required OpenGL 3.3 version.\n\n"
|
||||
"If possible, consider updating your video card drivers or using the Vulkan driver.\n\n"
|
||||
"You can enable the Vulkan driver by starting the engine from the\n"
|
||||
"command line with the command:\n\n \"%s\" --rendering-driver vulkan\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
executable_name),
|
||||
"Unable to initialize OpenGL video driver");
|
||||
|
||||
ERR_FAIL_MSG("Could not initialize OpenGL.");
|
||||
}
|
||||
} else {
|
||||
RasterizerGLES3::make_current(true);
|
||||
driver_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (rendering_driver == "opengl3_es") {
|
||||
egl_manager = memnew(EGLManagerWaylandGLES);
|
||||
|
||||
if (egl_manager->initialize(wayland_thread.get_wl_display()) != OK) {
|
||||
if (egl_manager->initialize(wayland_thread.get_wl_display()) != OK || egl_manager->open_display(wayland_thread.get_wl_display()) != OK) {
|
||||
memdelete(egl_manager);
|
||||
egl_manager = nullptr;
|
||||
r_error = ERR_CANT_CREATE;
|
||||
ERR_FAIL_MSG("Could not initialize GLES3.");
|
||||
|
||||
OS::get_singleton()->alert(
|
||||
vformat("Your video card drivers seem not to support the required OpenGL ES 3.0 version.\n\n"
|
||||
"If possible, consider updating your video card drivers or using the Vulkan driver.\n\n"
|
||||
"You can enable the Vulkan driver by starting the engine from the\n"
|
||||
"command line with the command:\n\n \"%s\" --rendering-driver vulkan\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
executable_name),
|
||||
"Unable to initialize OpenGL ES video driver");
|
||||
|
||||
ERR_FAIL_MSG("Could not initialize OpenGL ES.");
|
||||
}
|
||||
|
||||
RasterizerGLES3::make_current(false);
|
||||
driver_found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!driver_found) {
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
ERR_FAIL_MSG("Video driver not found.");
|
||||
}
|
||||
#endif // GLES3_ENABLED
|
||||
|
||||
cursor_set_shape(CURSOR_BUSY);
|
||||
|
@ -1482,12 +1525,12 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
|
|||
|
||||
RendererCompositorRD::make_current();
|
||||
}
|
||||
#endif
|
||||
#endif // RD_ENABLED
|
||||
|
||||
#ifdef DBUS_ENABLED
|
||||
portal_desktop = memnew(FreeDesktopPortalDesktop);
|
||||
screensaver = memnew(FreeDesktopScreenSaver);
|
||||
#endif
|
||||
#endif // DBUS_ENABLED
|
||||
|
||||
screen_set_keep_on(GLOBAL_GET("display/window/energy_saving/keep_screen_on"));
|
||||
|
||||
|
|
|
@ -5428,25 +5428,6 @@ Vector<String> DisplayServerX11::get_rendering_drivers_func() {
|
|||
|
||||
DisplayServer *DisplayServerX11::create_func(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, Error &r_error) {
|
||||
DisplayServer *ds = memnew(DisplayServerX11(p_rendering_driver, p_mode, p_vsync_mode, p_flags, p_position, p_resolution, p_screen, p_context, r_error));
|
||||
if (r_error != OK) {
|
||||
if (p_rendering_driver == "vulkan") {
|
||||
String executable_name = OS::get_singleton()->get_executable_path().get_file();
|
||||
OS::get_singleton()->alert(
|
||||
vformat("Your video card drivers seem not to support the required Vulkan version.\n\n"
|
||||
"If possible, consider updating your video card drivers or using the OpenGL 3 driver.\n\n"
|
||||
"You can enable the OpenGL 3 driver by starting the engine from the\n"
|
||||
"command line with the command:\n\n \"%s\" --rendering-driver opengl3\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
executable_name),
|
||||
"Unable to initialize Vulkan video driver");
|
||||
} else {
|
||||
OS::get_singleton()->alert(
|
||||
"Your video card drivers seem not to support the required OpenGL 3.3 version.\n\n"
|
||||
"If possible, consider updating your video card drivers.\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
"Unable to initialize OpenGL video driver");
|
||||
}
|
||||
}
|
||||
return ds;
|
||||
}
|
||||
|
||||
|
@ -6160,25 +6141,40 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||
rendering_driver = p_rendering_driver;
|
||||
|
||||
bool driver_found = false;
|
||||
String executable_name = OS::get_singleton()->get_executable_path().get_file();
|
||||
|
||||
// Initialize context and rendering device.
|
||||
|
||||
#if defined(RD_ENABLED)
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (rendering_driver == "vulkan") {
|
||||
rendering_context = memnew(RenderingContextDriverVulkanX11);
|
||||
}
|
||||
#endif
|
||||
#endif // VULKAN_ENABLED
|
||||
|
||||
if (rendering_context) {
|
||||
if (rendering_context->initialize() != OK) {
|
||||
ERR_PRINT(vformat("Could not initialize %s", rendering_driver));
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
r_error = ERR_CANT_CREATE;
|
||||
return;
|
||||
|
||||
if (p_rendering_driver == "vulkan") {
|
||||
OS::get_singleton()->alert(
|
||||
vformat("Your video card drivers seem not to support the required Vulkan version.\n\n"
|
||||
"If possible, consider updating your video card drivers or using the OpenGL 3 driver.\n\n"
|
||||
"You can enable the OpenGL 3 driver by starting the engine from the\n"
|
||||
"command line with the command:\n\n \"%s\" --rendering-driver opengl3\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
executable_name),
|
||||
"Unable to initialize Vulkan video driver");
|
||||
}
|
||||
|
||||
ERR_FAIL_MSG(vformat("Could not initialize %s", rendering_driver));
|
||||
}
|
||||
driver_found = true;
|
||||
}
|
||||
#endif
|
||||
// Initialize context and rendering device.
|
||||
#endif // RD_ENABLED
|
||||
|
||||
#if defined(GLES3_ENABLED)
|
||||
if (rendering_driver == "opengl3" || rendering_driver == "opengl3_es") {
|
||||
if (getenv("DRI_PRIME") == nullptr) {
|
||||
|
@ -6234,6 +6230,16 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
|
||||
OS::get_singleton()->alert(
|
||||
vformat("Your video card drivers seem not to support the required OpenGL 3.3 version.\n\n"
|
||||
"If possible, consider updating your video card drivers or using the Vulkan driver.\n\n"
|
||||
"You can enable the Vulkan driver by starting the engine from the\n"
|
||||
"command line with the command:\n\n \"%s\" --rendering-driver vulkan\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
executable_name),
|
||||
"Unable to initialize OpenGL video driver");
|
||||
|
||||
ERR_FAIL_MSG("Could not initialize OpenGL.");
|
||||
}
|
||||
} else {
|
||||
|
@ -6244,20 +6250,28 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||
|
||||
if (rendering_driver == "opengl3_es") {
|
||||
gl_manager_egl = memnew(GLManagerEGL_X11);
|
||||
if (gl_manager_egl->initialize() != OK) {
|
||||
if (gl_manager_egl->initialize() != OK || gl_manager_egl->open_display(x11_display) != OK) {
|
||||
memdelete(gl_manager_egl);
|
||||
gl_manager_egl = nullptr;
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
|
||||
OS::get_singleton()->alert(
|
||||
"Your video card drivers seem not to support the required OpenGL ES 3.0 version.\n\n"
|
||||
"If possible, consider updating your video card drivers.\n\n"
|
||||
"If you recently updated your video card drivers, try rebooting.",
|
||||
"Unable to initialize OpenGL ES video driver");
|
||||
|
||||
ERR_FAIL_MSG("Could not initialize OpenGL ES.");
|
||||
}
|
||||
driver_found = true;
|
||||
RasterizerGLES3::make_current(false);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // GLES3_ENABLED
|
||||
|
||||
if (!driver_found) {
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
ERR_FAIL_MSG("Video driver not found");
|
||||
ERR_FAIL_MSG("Video driver not found.");
|
||||
}
|
||||
|
||||
Point2i window_position;
|
||||
|
@ -6298,7 +6312,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||
|
||||
RendererCompositorRD::make_current();
|
||||
}
|
||||
#endif
|
||||
#endif // RD_ENABLED
|
||||
|
||||
{
|
||||
//set all event master mask
|
||||
|
@ -6451,7 +6465,8 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
|||
screen_set_keep_on(GLOBAL_GET("display/window/energy_saving/keep_screen_on"));
|
||||
|
||||
portal_desktop = memnew(FreeDesktopPortalDesktop);
|
||||
#endif
|
||||
#endif // DBUS_ENABLED
|
||||
|
||||
XSetErrorHandler(&default_window_error_handler);
|
||||
|
||||
r_error = OK;
|
||||
|
|
Loading…
Reference in New Issue