Skip to content

Commit

Permalink
Metal: Remove unused and obsolete availability macros
Browse files Browse the repository at this point in the history
* Both usages of ANGLE_APPLE_AVAILABLE_XC are obsolete.
* ANGLE_APPLE_AVAILABLE_CI and ANGLE_APPLE_AVAILABLE_I
  are unused.
* iOS and tvOS SDK version ranges are supported without
  redefinitions.
* Mac Catalyst is defined in the supported SDK versions.

Bug: angleproject:360147119
Change-Id: I8e7730c31f73c03d491373a0a5d316432513d8a2
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5817148
Commit-Queue: Alexey Knyazev <[email protected]>
Reviewed-by: Kimmo Kinnunen <[email protected]>
Reviewed-by: Geoff Lang <[email protected]>
  • Loading branch information
lexaknyazev authored and Angle LUCI CQ committed Aug 27, 2024
1 parent 2609e02 commit b52f281
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 61 deletions.
32 changes: 0 additions & 32 deletions src/common/apple_platform_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,20 @@

// These are macros for substitution of Apple specific directive @available:

// TARGET_OS_MACCATALYST only available in MacSDK 10.15

#if TARGET_OS_MACCATALYST
// ANGLE_APPLE_AVAILABLE_XCI: check if either of the 3 platforms (OSX/Catalyst/iOS) min verions is
// available:
# define ANGLE_APPLE_AVAILABLE_XCI(macVer, macCatalystVer, iOSVer) \
@available(macOS macVer, macCatalyst macCatalystVer, iOS iOSVer, *)
// ANGLE_APPLE_AVAILABLE_XC: check if either of the 2 platforms (OSX/Catalyst) min verions is
// available:
# define ANGLE_APPLE_AVAILABLE_XC(macVer, macCatalystVer) \
@available(macOS macVer, macCatalyst macCatalystVer, *)
// ANGLE_APPLE_AVAILABLE_CI: check if either of the 2 platforms (Catalyst/iOS) min verions is
// available:
# define ANGLE_APPLE_AVAILABLE_CI(macCatalystVer, iOSVer) \
@available(macCatalyst macCatalystVer, iOS iOSVer, *)
#else
# define ANGLE_APPLE_AVAILABLE_XCI(macVer, macCatalystVer, iOSVer) \
ANGLE_APPLE_AVAILABLE_XI(macVer, iOSVer)

# define ANGLE_APPLE_AVAILABLE_XC(macVer, macCatalystVer) @available(macOS macVer, *)
# define ANGLE_APPLE_AVAILABLE_CI(macCatalystVer, iOSVer) @available(iOS iOSVer, tvOS iOSVer, *)
#endif

// ANGLE_APPLE_AVAILABLE_XI: check if either of the 2 platforms (OSX/iOS) min verions is available:
#define ANGLE_APPLE_AVAILABLE_XI(macVer, iOSVer) \
@available(macOS macVer, iOS iOSVer, tvOS iOSVer, *)

// ANGLE_APPLE_AVAILABLE_I: check if a particular iOS version is available
#define ANGLE_APPLE_AVAILABLE_I(iOSVer) @available(iOS iOSVer, tvOS iOSVer, *)

#if TARGET_OS_IPHONE
# if !defined(__IPHONE_11_0)
# define __IPHONE_11_0 110000
# endif
# if !defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
# define __IPHONE_OS_VERSION_MAX_ALLOWED __IPHONE_11_0
# endif
# if !defined(__TV_OS_VERSION_MAX_ALLOWED)
# define __TV_OS_VERSION_MAX_ALLOWED __IPHONE_11_0
# endif
#endif

#if !defined(TARGET_OS_MACCATALYST)
# define TARGET_OS_MACCATALYST 0
#endif

#if defined(__ARM_ARCH)
# define ANGLE_APPLE_IS_ARM (__ARM_ARCH != 0)
#else
Expand Down
5 changes: 1 addition & 4 deletions src/libANGLE/renderer/metal/mtl_utils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -807,10 +807,7 @@ uint32_t GetDeviceVendorId(id<MTLDevice> metalDevice)
{
uint32_t vendorId = 0;
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
if (ANGLE_APPLE_AVAILABLE_XC(10.13, 13.1))
{
vendorId = GetDeviceVendorIdFromIOKit(metalDevice);
}
vendorId = GetDeviceVendorIdFromIOKit(metalDevice);
#endif
if (!vendorId)
{
Expand Down
28 changes: 3 additions & 25 deletions src/tests/test_expectations/GPUTestConfig_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,14 @@

#include "common/apple_platform_utils.h"

// OSX 10.8 deprecates Gestalt but doesn't make the operatingSystemVersion property part of the
// public interface of NSProcessInfo until 10.10. Add a forward declaration.
#if !defined(MAC_OS_X_VERSION_10_10) || MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
@interface NSProcessInfo (YosemiteSDK)
@property(readonly) NSOperatingSystemVersion operatingSystemVersion;
@end
#endif

namespace angle
{

void GetOperatingSystemVersionNumbers(int32_t *majorVersion, int32_t *minorVersion)
{
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
Gestalt(gestaltSystemVersionMajor, reinterpret_cast<SInt32 *>(majorVersion));
Gestalt(gestaltSystemVersionMinor, reinterpret_cast<SInt32 *>(minorVersion));
#else
if (ANGLE_APPLE_AVAILABLE_XC(10.10, 13.1))
{
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
*majorVersion = static_cast<int32_t>(version.majorVersion);
*minorVersion = static_cast<int32_t>(version.minorVersion);
}
else
{
// This can only happen on 10.9
*majorVersion = 10;
*minorVersion = 9;
}
#endif
NSOperatingSystemVersion version = [[NSProcessInfo processInfo] operatingSystemVersion];
*majorVersion = static_cast<int32_t>(version.majorVersion);
*minorVersion = static_cast<int32_t>(version.minorVersion);
}

} // namespace angle

0 comments on commit b52f281

Please sign in to comment.