Skip to content

Commit

Permalink
Fix build for iOS
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
fs-eire authored and Dawn LUCI CQ committed Oct 24, 2024
1 parent be9d992 commit e6f35ad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/dawn/native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,11 @@ if (DAWN_ENABLE_SWIFTSHADER)
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.
Expand Down
10 changes: 9 additions & 1 deletion src/dawn/native/Surface_metal.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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]];
}

Expand Down
11 changes: 9 additions & 2 deletions src/dawn/native/metal/SharedFenceMTL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.");
}
Expand Down

0 comments on commit e6f35ad

Please sign in to comment.