You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix cross-platform configuration of rendering driver settings
Simpler alternative to #103026 which avoids breaking compatibility. Instead of introducing a new `auto` default value, we ensure that all supported drivers are registered regardless of the editor's host platform, and that the defaults are the intended ones. This solves the following issues: - macOS exports are meant to default to Metal in 4.4, but they would default to Vulkan if exported from Linux, Windows, or Android editors. - Windows exports couldn't be made with Direct3D 12 from Linux, macOS, or Android editors, as the option couldn't be selected outside Windows. Unlike #103026, it doesn't solve the issue of not always saving the rendering drivers to `project.godot`, but now the defaults are at least consistent between editor platforms. Co-authored-by: Pāvels Nadtočajevs <7645683+bruvzg@users.noreply.github.com>
This commit is contained in:
@@ -2030,41 +2030,20 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
|
||||
Logger::set_flush_stdout_on_print(GLOBAL_GET("application/run/flush_stdout_on_print"));
|
||||
|
||||
// Rendering drivers configuration.
|
||||
|
||||
// Always include all supported drivers as hint, as this is used by the editor host platform
|
||||
// for project settings. For example, a Linux user should be able to configure that they want
|
||||
// to export for D3D12 on Windows and Metal on macOS even if their host platform can't use those.
|
||||
|
||||
{
|
||||
String driver_hints = "";
|
||||
String driver_hints_with_d3d12 = "";
|
||||
String driver_hints_with_metal = "";
|
||||
|
||||
{
|
||||
Vector<String> driver_hints_arr;
|
||||
#ifdef VULKAN_ENABLED
|
||||
driver_hints_arr.push_back("vulkan");
|
||||
#endif
|
||||
driver_hints = String(",").join(driver_hints_arr);
|
||||
|
||||
#ifdef D3D12_ENABLED
|
||||
driver_hints_arr.push_back("d3d12");
|
||||
#endif
|
||||
driver_hints_with_d3d12 = String(",").join(driver_hints_arr);
|
||||
|
||||
#ifdef METAL_ENABLED
|
||||
// Make metal the preferred and default driver.
|
||||
driver_hints_arr.insert(0, "metal");
|
||||
#endif
|
||||
driver_hints_with_metal = String(",").join(driver_hints_arr);
|
||||
}
|
||||
|
||||
String default_driver = driver_hints.get_slice(",", 0);
|
||||
String default_driver_with_d3d12 = driver_hints_with_d3d12.get_slice(",", 0);
|
||||
String default_driver_with_metal = driver_hints_with_metal.get_slice(",", 0);
|
||||
|
||||
// For now everything defaults to vulkan when available. This can change in future updates.
|
||||
GLOBAL_DEF_RST_NOVAL("rendering/rendering_device/driver", default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, driver_hints_with_d3d12), default_driver_with_d3d12);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.linuxbsd", PROPERTY_HINT_ENUM, driver_hints), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.android", PROPERTY_HINT_ENUM, driver_hints), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.ios", PROPERTY_HINT_ENUM, driver_hints_with_metal), default_driver_with_metal);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", PROPERTY_HINT_ENUM, driver_hints_with_metal), default_driver_with_metal);
|
||||
// RenderingDevice driver overrides per platform.
|
||||
GLOBAL_DEF_RST("rendering/rendering_device/driver", "vulkan");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.windows", PROPERTY_HINT_ENUM, "vulkan,d3d12"), "vulkan");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.linuxbsd", PROPERTY_HINT_ENUM, "vulkan"), "vulkan");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.android", PROPERTY_HINT_ENUM, "vulkan"), "vulkan");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.ios", PROPERTY_HINT_ENUM, "metal,vulkan"), "metal");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", PROPERTY_HINT_ENUM, "metal,vulkan"), "metal");
|
||||
|
||||
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_vulkan", true);
|
||||
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_d3d12", true);
|
||||
@@ -2072,24 +2051,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
|
||||
{
|
||||
String driver_hints = "";
|
||||
String driver_hints_angle = "";
|
||||
String driver_hints_egl = "";
|
||||
#ifdef GLES3_ENABLED
|
||||
driver_hints = "opengl3";
|
||||
driver_hints_angle = "opengl3,opengl3_angle"; // macOS, Windows.
|
||||
driver_hints_egl = "opengl3,opengl3_es"; // Linux.
|
||||
#endif
|
||||
|
||||
String default_driver = driver_hints.get_slice(",", 0);
|
||||
|
||||
GLOBAL_DEF_RST_NOVAL("rendering/gl_compatibility/driver", default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.windows", PROPERTY_HINT_ENUM, driver_hints_angle), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.linuxbsd", PROPERTY_HINT_ENUM, driver_hints_egl), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.web", PROPERTY_HINT_ENUM, driver_hints), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.android", PROPERTY_HINT_ENUM, driver_hints), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.ios", PROPERTY_HINT_ENUM, driver_hints), default_driver);
|
||||
GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.macos", PROPERTY_HINT_ENUM, driver_hints_angle), default_driver);
|
||||
// GL Compatibility driver overrides per platform.
|
||||
GLOBAL_DEF_RST("rendering/gl_compatibility/driver", "opengl3");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.windows", PROPERTY_HINT_ENUM, "opengl3,opengl3_angle"), "opengl3");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.linuxbsd", PROPERTY_HINT_ENUM, "opengl3,opengl3_es"), "opengl3");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.web", PROPERTY_HINT_ENUM, "opengl3"), "opengl3");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.android", PROPERTY_HINT_ENUM, "opengl3"), "opengl3");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.ios", PROPERTY_HINT_ENUM, "opengl3"), "opengl3");
|
||||
GLOBAL_DEF_RST(PropertyInfo(Variant::STRING, "rendering/gl_compatibility/driver.macos", PROPERTY_HINT_ENUM, "opengl3,opengl3_angle"), "opengl3");
|
||||
|
||||
GLOBAL_DEF_RST("rendering/gl_compatibility/nvidia_disable_threaded_optimization", true);
|
||||
GLOBAL_DEF_RST("rendering/gl_compatibility/fallback_to_angle", true);
|
||||
|
||||
Reference in New Issue
Block a user