[ios] Build fixes
Disables swiftshader, enables metal, removes some mac-specific
dependencies and updates a stale use of DAWN_PLATFORM_IOS.
Change-Id: Ib742d543e1cf8525ebe61833abb37b7171a2a1ff
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/139940
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ian Vollick <vollick@chromium.org>
diff --git a/scripts/dawn_features.gni b/scripts/dawn_features.gni
index 3e35b53..7a6e9b5 100644
--- a/scripts/dawn_features.gni
+++ b/scripts/dawn_features.gni
@@ -42,7 +42,7 @@
# Enables SwiftShader as the fallback adapter. Requires dawn_swiftshader_dir
# to be set to take effect.
# TODO(dawn:1536): Enable SwiftShader for Android.
- dawn_use_swiftshader = !is_android
+ dawn_use_swiftshader = !is_android && !is_ios
}
declare_args() {
@@ -61,7 +61,7 @@
dawn_enable_d3d12 = is_win
# Enables the compilation of Dawn's Metal backend
- dawn_enable_metal = is_mac
+ dawn_enable_metal = is_mac || is_ios
# Enables the compilation of Dawn's Null backend
# (required for unittests, obviously non-conformant)
@@ -79,8 +79,9 @@
# Enables the compilation of Dawn's Vulkan backend
# Disables vulkan when compiling for UWP, since UWP only supports d3d
- dawn_enable_vulkan = is_linux || is_chromeos || (is_win && !dawn_is_winuwp) ||
- is_fuchsia || is_android || dawn_use_swiftshader
+ dawn_enable_vulkan =
+ (is_linux || is_chromeos || (is_win && !dawn_is_winuwp) || is_fuchsia ||
+ is_android || dawn_use_swiftshader) && !is_ios
# Enables error injection for faking failures to native API calls
dawn_enable_error_injection =
diff --git a/src/dawn/common/BUILD.gn b/src/dawn/common/BUILD.gn
index d94a9d21..4bc62a7 100644
--- a/src/dawn/common/BUILD.gn
+++ b/src/dawn/common/BUILD.gn
@@ -223,7 +223,8 @@
# This GN file is discovered by all Chromium builds, but common doesn't support
# all of Chromium's OSes so we explicitly make the target visible only on
# systems we know Dawn is able to compile on.
-if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) {
+if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android ||
+ is_ios) {
static_library("common") {
sources = [
"Alloc.h",
diff --git a/src/dawn/native/BUILD.gn b/src/dawn/native/BUILD.gn
index 82e342b..f4e5339 100644
--- a/src/dawn/native/BUILD.gn
+++ b/src/dawn/native/BUILD.gn
@@ -572,11 +572,15 @@
if (dawn_enable_metal) {
frameworks = [
- "Cocoa.framework",
"IOKit.framework",
"IOSurface.framework",
- "QuartzCore.framework",
]
+ if (is_mac) {
+ frameworks += [
+ "QuartzCore.framework",
+ "Cocoa.framework",
+ ]
+ }
sources += [
"Surface_metal.mm",
"metal/BackendMTL.h",
diff --git a/src/dawn/native/metal/BackendMTL.mm b/src/dawn/native/metal/BackendMTL.mm
index 12e0d8c..b64381f 100644
--- a/src/dawn/native/metal/BackendMTL.mm
+++ b/src/dawn/native/metal/BackendMTL.mm
@@ -816,7 +816,7 @@
#endif
// iOS only has a single device so MTLCopyAllDevices doesn't exist there.
-#if defined(DAWN_PLATFORM_IOS)
+#if DAWN_PLATFORM_IS(IOS)
Ref<PhysicalDevice> physicalDevice = AcquireRef(
new PhysicalDevice(GetInstance(), AcquireNSPRef(MTLCreateSystemDefaultDevice())));
if (!GetInstance()->ConsumedErrorAndWarnOnce(physicalDevice->Initialize())) {