Hash :
f507fe05
Author :
Date :
2023-04-06T12:27:00
Rename PLATFORM_IOS to PLATFORM_IOS_FAMILY The current define ANGLE_PLATFORM_IOS actually means "iOS or tvOS or WatchOS or MacCatalyst". The current define ANGLE_PLATFORM_WATCHOS means nothing. The current define ANGLE_PLATFORM_APPLETV means nothing. Replace PLATFORM_IOS and its uses with PLATFORM_IOS_FAMILY, so that then PLATFORM_IOS can be reintroduced and others can be fixed. Replace PLATFORM_IOS_SIMULATOR and its uses with PLATFORM_IOS_FAMILY_SIMULATOR for consistency. Use consistent `#if X` notation instead of `#if defined(X)`. Bug: angleproject:8121 Change-Id: Ibe668c2ae9bb801d15e036fcf1dfd53f22c30787 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4404161 Reviewed-by: Dan Glastonbury <djg@apple.com> Reviewed-by: Kenneth Russell <kbr@chromium.org> Commit-Queue: Kimmo Kinnunen <kkinnunen@apple.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
//
// Copyright 2022 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "common/apple_platform_utils.h"
#include <Metal/Metal.h>
namespace angle
{
bool IsMetalRendererAvailable()
{
static bool queriedSystemDevice = false;
static bool gpuFamilySufficient = false;
// We only support macos 10.13+ and 11 for now. Since they are requirements for Metal 2.0.
#if TARGET_OS_SIMULATOR
if (ANGLE_APPLE_AVAILABLE_XCI(10.13, 13.0, 13))
#else
if (ANGLE_APPLE_AVAILABLE_XCI(10.13, 13.0, 11))
#endif
{
if (!queriedSystemDevice)
{
ANGLE_APPLE_OBJC_SCOPE
{
queriedSystemDevice = true;
auto device = [MTLCreateSystemDefaultDevice() ANGLE_APPLE_AUTORELEASE];
if (!device)
{
return false;
}
// -[MTLDevice supportsFamily] introduced in macOS 10.15, Catalyst 13.1, iOS 13.
#if defined(ANGLE_PLATFORM_MACOS) || defined(ANGLE_PLATFORM_MACCATALYST)
// Old Macs, such as MacBookPro11,4, cannot use ANGLE's Metal backend.
// This check can be removed once they are no longer supported.
if (ANGLE_APPLE_AVAILABLE_XCI(10.15, 13.1, 13))
{
if ([device supportsFamily:MTLGPUFamilyMac2])
gpuFamilySufficient = true;
}
else
{
// Hardcode constant to sidestep compiler errors. Call will
// return false on older macOS versions.
const NSUInteger macFamily2v1 = 10005;
ANGLE_APPLE_ALLOW_DEPRECATED_BEGIN
if ([device supportsFeatureSet:static_cast<MTLFeatureSet>(macFamily2v1)])
gpuFamilySufficient = true;
ANGLE_APPLE_ALLOW_DEPRECATED_END
}
#elif ANGLE_PLATFORM_IOS_FAMILY && !ANGLE_PLATFORM_IOS_FAMILY_SIMULATOR
// Hardcode constant to sidestep compiler errors. Call will
// return false on older macOS versions.
const NSUInteger iosFamily3v1 = 4;
if ([device supportsFeatureSet:static_cast<MTLFeatureSet>(iosFamily3v1)])
gpuFamilySufficient = true;
#elif ANGLE_PLATFORM_IOS_FAMILY && ANGLE_PLATFORM_IOS_FAMILY_SIMULATOR
// FIXME: Currently we do not have good simulator query, as it does not support
// the whole feature set needed for iOS.
gpuFamilySufficient = true;
#endif
}
}
return gpuFamilySufficient;
}
return false;
}
} // namespace angle