Skip to content

Commit e6f35ad

Browse files
fs-eireDawn LUCI CQ
authored andcommitted
Fix build for iOS
Change-Id: Ibe81e9312418efb007fc32b32b2accdd6bd3ddce Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/212074 Reviewed-by: Loko Kung <[email protected]> Commit-Queue: Corentin Wallez <[email protected]> Reviewed-by: Corentin Wallez <[email protected]>
1 parent be9d992 commit e6f35ad

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/dawn/native/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,11 @@ if (DAWN_ENABLE_SWIFTSHADER)
864864
target_compile_definitions(dawn_native_objects PRIVATE "DAWN_ENABLE_SWIFTSHADER")
865865
endif()
866866

867+
if (IOS)
868+
target_compile_options(dawn_native_objects PRIVATE -fno-objc-arc)
869+
target_compile_options(dawn_native PRIVATE -fno-objc-arc)
870+
endif()
871+
867872
if (DAWN_BUILD_MONOLITHIC_LIBRARY)
868873
###############################################################################
869874
# Do the 'complete_lib' build.

src/dawn/native/Surface_metal.mm

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,18 @@
3333

3434
#import <QuartzCore/CAMetalLayer.h>
3535

36+
#include "dawn/common/Platform.h"
37+
3638
namespace dawn::native {
3739

3840
bool InheritsFromCAMetalLayer(void* obj) {
39-
id<NSObject> object = static_cast<id>(obj);
41+
id<NSObject> object =
42+
#if DAWN_PLATFORM_IS(IOS)
43+
(__bridge id)obj;
44+
#else // DAWN_PLATFORM_IS(IOS)
45+
static_cast<id>(obj);
46+
#endif // DAWN_PLATFORM_IS(IOS)
47+
4048
return [object isKindOfClass:[CAMetalLayer class]];
4149
}
4250

src/dawn/native/metal/SharedFenceMTL.mm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2626
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2727

28+
#include "dawn/common/Platform.h"
29+
2830
#include "dawn/native/metal/SharedFenceMTL.h"
2931

3032
#include "dawn/native/ChainUtils.h"
@@ -39,8 +41,13 @@
3941
const SharedFenceMTLSharedEventDescriptor* descriptor) {
4042
DAWN_INVALID_IF(descriptor->sharedEvent == nullptr, "MTLSharedEvent is missing.");
4143
if (@available(macOS 10.14, iOS 12.0, *)) {
42-
return AcquireRef(new SharedFence(
43-
device, label, static_cast<id<MTLSharedEvent>>(descriptor->sharedEvent)));
44+
return AcquireRef(new SharedFence(device, label,
45+
#if DAWN_PLATFORM_IS(IOS)
46+
(__bridge id<MTLSharedEvent>)(descriptor->sharedEvent)
47+
#else // DAWN_PLATFORM_IS(IOS)
48+
static_cast<id<MTLSharedEvent>>(descriptor->sharedEvent)
49+
#endif // DAWN_PLATFORM_IS(IOS)
50+
));
4451
} else {
4552
return DAWN_INTERNAL_ERROR("MTLSharedEvent not supported.");
4653
}

0 commit comments

Comments
 (0)