Skip to content

Commit

Permalink
Redefine derivations of MVK_APPLE_SILICON, MVK_MACOS_APPLE_SILICON, a…
Browse files Browse the repository at this point in the history
…nd MVK_XCODE_12.

Derive MVK_APPLE_SILICON from target CPU.
Derive MVK_MACOS_APPLE_SILICON from target CPU and macOS platform.
Derive MVK_XCODE_12 from macOS and iOS SDK versions.
Test for simulator on non-Apple GPU using MVK_OS_SIMULATOR && !MVK_APPLE_SILICON.
  • Loading branch information
billhollings committed Feb 20, 2021
1 parent 0d19759 commit 4675481
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
14 changes: 7 additions & 7 deletions Common/MVKCommonEnvironment.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ extern "C" {
# define MVK_OS_SIMULATOR TARGET_OS_SIMULATOR
#endif

/** Building for macOS with support for Apple Silicon. */
#ifndef MVK_MACOS_APPLE_SILICON
# define MVK_MACOS_APPLE_SILICON (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101600)
/** Building for Apple Silicon on iOS, tvOS, or macOS platform. */
#ifndef MVK_APPLE_SILICON
# define MVK_APPLE_SILICON TARGET_CPU_ARM64
#endif

/** Building for Apple Silicon. */
#ifndef MVK_APPLE_SILICON
# define MVK_APPLE_SILICON (MVK_IOS || MVK_TVOS || MVK_MACOS_APPLE_SILICON)
/** Building for macOS with support for Apple Silicon. */
#ifndef MVK_MACOS_APPLE_SILICON
# define MVK_MACOS_APPLE_SILICON (MVK_MACOS && MVK_APPLE_SILICON)
#endif

/** Building with Xcode 12. */
#ifndef MVK_XCODE_12
# define MVK_XCODE_12 (MVK_MACOS_APPLE_SILICON || \
# define MVK_XCODE_12 ((__MAC_OS_X_VERSION_MAX_ALLOWED >= 101600) || \
(__IPHONE_OS_VERSION_MAX_ALLOWED >= 140000)) // Also covers tvOS
#endif

Expand Down
10 changes: 3 additions & 7 deletions MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1546,13 +1546,9 @@
#endif
}

// iOS and tvOS adjustments necessary when running in the simulator on non-Apple GPUs.
// Apple1 used as baseline for detecting Apple Silicon on macOS because Apple7 not supported for tvOS.
// Must run after setting native iOS and tvOS values above.
#if MVK_OS_SIMULATOR
if ( !supportsMTLGPUFamily(Apple1) ) {
_metalFeatures.mtlBufferAlignment = 256;
}
// iOS and tvOS adjustments necessary when running in the simulator on non-Apple GPUs.
#if MVK_OS_SIMULATOR && !MVK_APPLE_SILICON
_metalFeatures.mtlBufferAlignment = 256;
#endif
}

Expand Down

0 comments on commit 4675481

Please sign in to comment.