Metal: Fail BackendConnection creation when Metal isn't supported
Chromium still supports macOS 10.10 that doesn't have Metal support and calling any Metal function there results in a crash. Prevent using the backend when Metal isn't present by not creating a BackendConnection. BUG=chromium:852089 Change-Id: I53ffe6972f7b926b6bcbe740275fcee88b9df67a Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6480 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
f4c3f4562e
commit
c005c9acf0
|
@ -104,6 +104,12 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsMetalSupported() {
|
||||||
|
// Metal was first introduced in macOS 10.11
|
||||||
|
NSOperatingSystemVersion macOS10_11 = {10, 11, 0};
|
||||||
|
return [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:macOS10_11];
|
||||||
|
}
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
// The Metal backend's Adapter.
|
// The Metal backend's Adapter.
|
||||||
|
@ -155,6 +161,9 @@ namespace dawn_native { namespace metal {
|
||||||
}
|
}
|
||||||
|
|
||||||
BackendConnection* Connect(InstanceBase* instance) {
|
BackendConnection* Connect(InstanceBase* instance) {
|
||||||
|
if (!IsMetalSupported()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
return new Backend(instance);
|
return new Backend(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue