Skip to content

Commit

Permalink
Android and X11
Browse files Browse the repository at this point in the history
  • Loading branch information
SheepYhangCN committed Sep 18, 2024
1 parent ac7ccd4 commit 8bd0f9c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
2 changes: 1 addition & 1 deletion doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2801,7 +2801,7 @@
</member>
<member name="rendering/rendering_device/fallback_to_opengl3" type="bool" setter="" getter="" default="true">
If [code]true[/code], the forward renderer will fall back to OpenGL 3 if both Direct3D 12 and Vulkan are not supported.
[b]Note:[/b] This setting is implemented only on Windows.
[b]Note:[/b] This setting is implemented only on Windows, Android and Linux/X11.
</member>
<member name="rendering/rendering_device/pipeline_cache/enable" type="bool" setter="" getter="" default="true">
Enable the pipeline cache that is saved to disk if the graphics API supports it.
Expand Down
15 changes: 12 additions & 3 deletions platform/android/display_server_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,11 +607,20 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis

if (rendering_context) {
if (rendering_context->initialize() != OK) {
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_UNAVAILABLE;
return;
bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
if (fallback_to_opengl3 && rendering_driver != "opengl3") {
WARN_PRINT("Your device seem not to support Vulkan, switching to OpenGL 3.");
rendering_driver = "opengl3";
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
}
else
{
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
r_error = ERR_UNAVAILABLE;
return;
}
}

union {
Expand Down
33 changes: 21 additions & 12 deletions platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6160,20 +6160,29 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
if (rendering_context->initialize() != OK) {
memdelete(rendering_context);
rendering_context = nullptr;
r_error = ERR_CANT_CREATE;

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");
bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
if (fallback_to_opengl3 && rendering_driver != "opengl3") {
WARN_PRINT("Your video card drivers seem not to support the required Vulkan version, switching to OpenGL 3.");
rendering_driver = "opengl3";
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
}
else
{
r_error = ERR_CANT_CREATE;

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));
ERR_FAIL_MSG(vformat("Could not initialize %s", rendering_driver));
}
}
driver_found = true;
}
Expand Down

0 comments on commit 8bd0f9c

Please sign in to comment.