From 2d0165574de6ac21aa2730215dcab60e4ce88d08 Mon Sep 17 00:00:00 2001 From: Stuart Carnie Date: Tue, 20 Feb 2024 05:52:00 +1100 Subject: Add Metal support for macOS (arm64) and iOS --- main/main.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'main') 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 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); @@ -2232,6 +2240,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph #endif #ifdef D3D12_ENABLED available_drivers.push_back("d3d12"); +#endif +#ifdef METAL_ENABLED + available_drivers.push_back("metal"); #endif } #ifdef GLES3_ENABLED -- cgit v1.2.3