Fix build for iOS
Change-Id: Ibe81e9312418efb007fc32b32b2accdd6bd3ddce
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212074
Reviewed-by: Loko Kung <lokokung@google.com>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/CMakeLists.txt b/src/dawn/native/CMakeLists.txt
index 4f9a0bb..be4aeff 100644
--- a/src/dawn/native/CMakeLists.txt
+++ b/src/dawn/native/CMakeLists.txt
@@ -864,6 +864,11 @@
target_compile_definitions(dawn_native_objects PRIVATE "DAWN_ENABLE_SWIFTSHADER")
endif()
+if (IOS)
+ target_compile_options(dawn_native_objects PRIVATE -fno-objc-arc)
+ target_compile_options(dawn_native PRIVATE -fno-objc-arc)
+endif()
+
if (DAWN_BUILD_MONOLITHIC_LIBRARY)
###############################################################################
# Do the 'complete_lib' build.
diff --git a/src/dawn/native/Surface_metal.mm b/src/dawn/native/Surface_metal.mm
index ce55acb..2cfd363 100644
--- a/src/dawn/native/Surface_metal.mm
+++ b/src/dawn/native/Surface_metal.mm
@@ -33,10 +33,18 @@
#import <QuartzCore/CAMetalLayer.h>
+#include "dawn/common/Platform.h"
+
namespace dawn::native {
bool InheritsFromCAMetalLayer(void* obj) {
- id<NSObject> object = static_cast<id>(obj);
+ id<NSObject> object =
+#if DAWN_PLATFORM_IS(IOS)
+ (__bridge id)obj;
+#else // DAWN_PLATFORM_IS(IOS)
+ static_cast<id>(obj);
+#endif // DAWN_PLATFORM_IS(IOS)
+
return [object isKindOfClass:[CAMetalLayer class]];
}
diff --git a/src/dawn/native/metal/SharedFenceMTL.mm b/src/dawn/native/metal/SharedFenceMTL.mm
index 76c84be..7ee5a9a 100644
--- a/src/dawn/native/metal/SharedFenceMTL.mm
+++ b/src/dawn/native/metal/SharedFenceMTL.mm
@@ -25,6 +25,8 @@
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include "dawn/common/Platform.h"
+
#include "dawn/native/metal/SharedFenceMTL.h"
#include "dawn/native/ChainUtils.h"
@@ -39,8 +41,13 @@
const SharedFenceMTLSharedEventDescriptor* descriptor) {
DAWN_INVALID_IF(descriptor->sharedEvent == nullptr, "MTLSharedEvent is missing.");
if (@available(macOS 10.14, iOS 12.0, *)) {
- return AcquireRef(new SharedFence(
- device, label, static_cast<id<MTLSharedEvent>>(descriptor->sharedEvent)));
+ return AcquireRef(new SharedFence(device, label,
+#if DAWN_PLATFORM_IS(IOS)
+ (__bridge id<MTLSharedEvent>)(descriptor->sharedEvent)
+#else // DAWN_PLATFORM_IS(IOS)
+ static_cast<id<MTLSharedEvent>>(descriptor->sharedEvent)
+#endif // DAWN_PLATFORM_IS(IOS)
+ ));
} else {
return DAWN_INTERNAL_ERROR("MTLSharedEvent not supported.");
}