Fix Apple SDK availablity check

Change-Id: I02332c8cbddaa30fb74603849fe00c52d9b43b88
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14661
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Danusch Merrikh-Yazdi 2019-12-18 00:08:16 +00:00 committed by Commit Bot service account
parent 2fdc7ab692
commit 7433023fff
1 changed files with 9 additions and 4 deletions

View File

@ -229,9 +229,10 @@ namespace dawn_native { namespace metal {
std::vector<std::unique_ptr<AdapterBase>> Backend::DiscoverDefaultAdapters() { std::vector<std::unique_ptr<AdapterBase>> Backend::DiscoverDefaultAdapters() {
std::vector<std::unique_ptr<AdapterBase>> adapters; std::vector<std::unique_ptr<AdapterBase>> adapters;
BOOL supportedVersion = NO;
if (@available(macOS 10.11, *)) {
#if defined(DAWN_PLATFORM_MACOS) #if defined(DAWN_PLATFORM_MACOS)
if (@available(macOS 10.11, *)) {
supportedVersion = YES;
NSArray<id<MTLDevice>>* devices = MTLCopyAllDevices(); NSArray<id<MTLDevice>>* devices = MTLCopyAllDevices();
for (id<MTLDevice> device in devices) { for (id<MTLDevice> device in devices) {
@ -239,14 +240,18 @@ namespace dawn_native { namespace metal {
} }
[devices release]; [devices release];
}
#endif #endif
} else if (@available(iOS 8.0, *)) {
#if defined(DAWN_PLATFORM_IOS) #if defined(DAWN_PLATFORM_IOS)
if (@available(iOS 8.0, *)) {
supportedVersion = YES;
// iOS only has a single device so MTLCopyAllDevices doesn't exist there. // iOS only has a single device so MTLCopyAllDevices doesn't exist there.
adapters.push_back( adapters.push_back(
std::make_unique<Adapter>(GetInstance(), MTLCreateSystemDefaultDevice())); std::make_unique<Adapter>(GetInstance(), MTLCreateSystemDefaultDevice()));
}
#endif #endif
} else { if (!supportedVersion) {
UNREACHABLE(); UNREACHABLE();
} }
return adapters; return adapters;