summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorStuart Carnie <stuart.carnie@gmail.com>2024-02-20 05:52:00 +1100
committerRémi Verschelde <rverschelde@gmail.com>2024-08-20 12:11:06 +0200
commit2d0165574de6ac21aa2730215dcab60e4ce88d08 (patch)
treef1710c694c12f9360e853111a1ca396f285844bb /main
parent826de7976a6add282c7b14d4be2a7e6d775821d8 (diff)
downloadredot-engine-2d0165574de6ac21aa2730215dcab60e4ce88d08.tar.gz
Add Metal support for macOS (arm64) and iOS
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 9ee88af60e..f82df786bc 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1935,6 +1935,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
{
String driver_hints = "";
String driver_hints_with_d3d12 = "";
+ String driver_hints_with_metal = "";
{
Vector<String> driver_hints_arr;
@@ -1947,18 +1948,25 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
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), default_driver);
- GLOBAL_DEF_RST_NOVAL(PropertyInfo(Variant::STRING, "rendering/rendering_device/driver.macos", 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);
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_vulkan", true);
GLOBAL_DEF_RST("rendering/rendering_device/fallback_to_d3d12", true);
@@ -2233,6 +2241,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
#ifdef D3D12_ENABLED
available_drivers.push_back("d3d12");
#endif
+#ifdef METAL_ENABLED
+ available_drivers.push_back("metal");
+#endif
}
#ifdef GLES3_ENABLED
if (rendering_method == "gl_compatibility") {