1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-27 15:57:02 +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:
Rémi Verschelde
2025-02-23 00:42:44 +01:00
parent 11f56d8265
commit b77423370a
4 changed files with 93 additions and 72 deletions

View File

@@ -6764,24 +6764,30 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
_register_raw_input_devices(INVALID_WINDOW_ID);
#if defined(RD_ENABLED)
bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
bool fallback_to_d3d12 = GLOBAL_GET("rendering/rendering_device/fallback_to_d3d12");
#if defined(VULKAN_ENABLED)
if (rendering_driver == "vulkan") {
rendering_context = memnew(RenderingContextDriverVulkanWindows);
tested_drivers.set_flag(DRIVER_ID_RD_VULKAN);
}
#else
fallback_to_d3d12 = true; // Always enable fallback if engine was built w/o other driver support.
#endif
#if defined(D3D12_ENABLED)
if (rendering_driver == "d3d12") {
rendering_context = memnew(RenderingContextDriverD3D12);
tested_drivers.set_flag(DRIVER_ID_RD_D3D12);
}
#else
fallback_to_vulkan = true; // Always enable fallback if engine was built w/o other driver support.
#endif
if (rendering_context) {
if (rendering_context->initialize() != OK) {
bool failed = true;
#if defined(VULKAN_ENABLED)
bool fallback_to_vulkan = GLOBAL_GET("rendering/rendering_device/fallback_to_vulkan");
if (failed && fallback_to_vulkan && rendering_driver != "vulkan") {
memdelete(rendering_context);
rendering_context = memnew(RenderingContextDriverVulkanWindows);
@@ -6795,7 +6801,6 @@ DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, Win
}
#endif
#if defined(D3D12_ENABLED)
bool fallback_to_d3d12 = GLOBAL_GET("rendering/rendering_device/fallback_to_d3d12");
if (failed && fallback_to_d3d12 && rendering_driver != "d3d12") {
memdelete(rendering_context);
rendering_context = memnew(RenderingContextDriverD3D12);