mirror of
https://github.com/godotengine/godot.git
synced 2025-04-01 00:41:35 +08:00
Merge pull request #98615 from Summersay415/three-opengls-please
Fix fallbacks to OpenGL
This commit is contained in:
commit
05a4620e88
@ -625,12 +625,6 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
||||
|
||||
native_menu = memnew(NativeMenu);
|
||||
|
||||
#if defined(GLES3_ENABLED)
|
||||
if (rendering_driver == "opengl3") {
|
||||
RasterizerGLES3::make_current(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(RD_ENABLED)
|
||||
rendering_context = nullptr;
|
||||
rendering_device = nullptr;
|
||||
@ -645,19 +639,24 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
||||
if (rendering_context->initialize() != OK) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
#if defined(GLES3_ENABLED)
|
||||
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_method("gl_compatibility");
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rendering_context) {
|
||||
union {
|
||||
#ifdef VULKAN_ENABLED
|
||||
RenderingContextDriverVulkanAndroid::WindowPlatformData vulkan;
|
||||
@ -697,6 +696,12 @@ DisplayServerAndroid::DisplayServerAndroid(const String &p_rendering_driver, Dis
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GLES3_ENABLED)
|
||||
if (rendering_driver == "opengl3") {
|
||||
RasterizerGLES3::make_current(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
Input::get_singleton()->set_event_dispatch_function(_dispatch_input_events);
|
||||
|
||||
r_error = OK;
|
||||
|
@ -479,12 +479,17 @@ class Godot(private val context: Context) {
|
||||
// ...add to FrameLayout
|
||||
containerLayout?.addView(editText)
|
||||
renderView = if (usesVulkan()) {
|
||||
if (!meetsVulkanRequirements(activity.packageManager)) {
|
||||
if (meetsVulkanRequirements(activity.packageManager)) {
|
||||
GodotVulkanRenderView(host, this, godotInputHandler)
|
||||
} else if (canFallbackToOpenGL()) {
|
||||
// Fallback to OpenGl.
|
||||
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
|
||||
} else {
|
||||
throw IllegalStateException(activity.getString(R.string.error_missing_vulkan_requirements_message))
|
||||
}
|
||||
GodotVulkanRenderView(host, this, godotInputHandler)
|
||||
|
||||
} else {
|
||||
// Fallback to openGl
|
||||
// Fallback to OpenGl.
|
||||
GodotGLRenderView(host, this, godotInputHandler, xrMode, useDebugOpengl)
|
||||
}
|
||||
|
||||
@ -818,6 +823,13 @@ class Godot(private val context: Context) {
|
||||
return ("forward_plus" == renderer || "mobile" == renderer) && "vulkan" == renderingDevice
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if can fallback to OpenGL.
|
||||
*/
|
||||
private fun canFallbackToOpenGL(): Boolean {
|
||||
return java.lang.Boolean.parseBoolean(GodotLib.getGlobal("rendering/rendering_device/fallback_to_opengl3"))
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the device meets the base requirements for Vulkan support, false otherwise.
|
||||
*/
|
||||
|
@ -111,19 +111,24 @@ DisplayServerIOS::DisplayServerIOS(const String &p_rendering_driver, WindowMode
|
||||
if (rendering_context->initialize() != OK) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
#if defined(GLES3_ENABLED)
|
||||
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 MoltenVK or Metal, switching to OpenGL 3.");
|
||||
rendering_driver = "opengl3";
|
||||
OS::get_singleton()->set_current_rendering_method("gl_compatibility");
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ERR_PRINT(vformat("Failed to initialize %s context", rendering_driver));
|
||||
r_error = ERR_UNAVAILABLE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rendering_context) {
|
||||
if (rendering_context->window_create(MAIN_WINDOW_ID, &wpd) != OK) {
|
||||
ERR_PRINT(vformat("Failed to create %s window.", rendering_driver));
|
||||
memdelete(rendering_context);
|
||||
|
@ -1356,13 +1356,16 @@ DisplayServerWayland::DisplayServerWayland(const String &p_rendering_driver, Win
|
||||
if (rendering_context->initialize() != OK) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
#if defined(GLES3_ENABLED)
|
||||
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_method("gl_compatibility");
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
} else
|
||||
#endif // GLES3_ENABLED
|
||||
{
|
||||
r_error = ERR_CANT_CREATE;
|
||||
|
||||
if (p_rendering_driver == "vulkan") {
|
||||
|
@ -6168,13 +6168,16 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode
|
||||
if (rendering_context->initialize() != OK) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
#if defined(GLES3_ENABLED)
|
||||
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_method("gl_compatibility");
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
} else
|
||||
#endif // GLES3_ENABLED
|
||||
{
|
||||
r_error = ERR_CANT_CREATE;
|
||||
|
||||
if (p_rendering_driver == "vulkan") {
|
||||
|
@ -3623,6 +3623,39 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM
|
||||
//TODO - do Vulkan and OpenGL support checks, driver selection and fallback
|
||||
rendering_driver = p_rendering_driver;
|
||||
|
||||
#if defined(RD_ENABLED)
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (rendering_driver == "vulkan") {
|
||||
rendering_context = memnew(RenderingContextDriverVulkanMacOS);
|
||||
}
|
||||
#endif
|
||||
#if defined(METAL_ENABLED)
|
||||
if (rendering_driver == "metal") {
|
||||
rendering_context = memnew(RenderingContextDriverMetal);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rendering_context) {
|
||||
if (rendering_context->initialize() != OK) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
#if defined(GLES3_ENABLED)
|
||||
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 MoltenVK or Metal, switching to OpenGL 3.");
|
||||
rendering_driver = "opengl3";
|
||||
OS::get_singleton()->set_current_rendering_method("gl_compatibility");
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
r_error = ERR_CANT_CREATE;
|
||||
ERR_FAIL_MSG("Could not initialize " + rendering_driver);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(GLES3_ENABLED)
|
||||
if (rendering_driver == "opengl3_angle") {
|
||||
gl_manager_angle = memnew(GLManagerANGLE_MacOS);
|
||||
@ -3655,35 +3688,6 @@ DisplayServerMacOS::DisplayServerMacOS(const String &p_rendering_driver, WindowM
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(RD_ENABLED)
|
||||
#if defined(VULKAN_ENABLED)
|
||||
if (rendering_driver == "vulkan") {
|
||||
rendering_context = memnew(RenderingContextDriverVulkanMacOS);
|
||||
}
|
||||
#endif
|
||||
#if defined(METAL_ENABLED)
|
||||
if (rendering_driver == "metal") {
|
||||
rendering_context = memnew(RenderingContextDriverMetal);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rendering_context) {
|
||||
if (rendering_context->initialize() != OK) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
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 MoltenVK or Metal, switching to OpenGL 3.");
|
||||
rendering_driver = "opengl3";
|
||||
OS::get_singleton()->set_current_rendering_method("gl_compatibility");
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
} else {
|
||||
r_error = ERR_CANT_CREATE;
|
||||
ERR_FAIL_MSG("Could not initialize " + rendering_driver);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Point2i window_position;
|
||||
if (p_position != nullptr) {
|
||||
|
@ -6238,6 +6238,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(GLES3_ENABLED)
|
||||
bool fallback_to_opengl3 = GLOBAL_GET("rendering/rendering_device/fallback_to_opengl3");
|
||||
if (failed && fallback_to_opengl3 && rendering_driver != "opengl3") {
|
||||
memdelete(rendering_context);
|
||||
@ -6249,6 +6250,7 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
|
||||
OS::get_singleton()->set_current_rendering_driver_name(rendering_driver);
|
||||
failed = false;
|
||||
}
|
||||
#endif
|
||||
if (failed) {
|
||||
memdelete(rendering_context);
|
||||
rendering_context = nullptr;
|
||||
|
Loading…
x
Reference in New Issue
Block a user