Fix visionOS build
This adds a few macros to test which platform is currently being built. Addresses some compile warnings such as missing return values.
This commit is contained in:
parent
37361ccd55
commit
9082ca839f
@ -69,8 +69,11 @@ extern "C" {
|
||||
#ifndef TARGET_OS_XR
|
||||
# define TARGET_OS_XR 0 // Older SDK's don't define TARGET_OS_XR
|
||||
#endif
|
||||
#ifndef TARGET_OS_VISION
|
||||
# define TARGET_OS_VISION 0 // Older SDK's don't define TARGET_OS_VISION
|
||||
#endif
|
||||
#ifndef MVK_VISIONOS
|
||||
# define MVK_VISIONOS TARGET_OS_XR
|
||||
# define MVK_VISIONOS (TARGET_OS_XR || TARGET_OS_VISION)
|
||||
#endif
|
||||
|
||||
/** Building for iOS or tvOS. */
|
||||
@ -83,9 +86,9 @@ extern "C" {
|
||||
# define MVK_MACOS_OR_IOS (MVK_MACOS || MVK_IOS)
|
||||
#endif
|
||||
|
||||
/** Building for macOS, iOS or visionOS. */
|
||||
#ifndef MVK_MACOS_OR_IOS_OR_VISIONOS
|
||||
# define MVK_MACOS_OR_IOS_OR_VISIONOS (MVK_MACOS || MVK_IOS | MVK_VISIONOS)
|
||||
/** Building for iOS or visionOS. */
|
||||
#ifndef MVK_IOS_OR_VISIONOS
|
||||
# define MVK_IOS_OR_VISIONOS (MVK_IOS || MVK_VISIONOS)
|
||||
#endif
|
||||
|
||||
/** Building for a Simulator. */
|
||||
|
@ -121,8 +121,7 @@ bool MVKBuffer::needsHostReadSync(MVKPipelineBarrier& barrier) {
|
||||
return (mvkIsAnyFlagEnabled(barrier.dstStageMask, (VK_PIPELINE_STAGE_HOST_BIT)) &&
|
||||
mvkIsAnyFlagEnabled(barrier.dstAccessMask, (VK_ACCESS_HOST_READ_BIT)) &&
|
||||
isMemoryHostAccessible() && (!isMemoryHostCoherent() || _isHostCoherentTexelBuffer));
|
||||
#endif
|
||||
#if MVK_IOS_OR_TVOS
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
@ -2936,7 +2936,7 @@ void MVKPhysicalDevice::initGPUInfoProperties() {
|
||||
|
||||
#endif //MVK_MACOS
|
||||
|
||||
#if MVK_IOS_OR_TVOS
|
||||
#if !MVK_MACOS
|
||||
// For Apple Silicon, the Device ID is determined by the highest
|
||||
// GPU capability, which is a combination of OS version and GPU type.
|
||||
void MVKPhysicalDevice::initGPUInfoProperties() {
|
||||
@ -2945,7 +2945,7 @@ void MVKPhysicalDevice::initGPUInfoProperties() {
|
||||
_properties.deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU;
|
||||
strlcpy(_properties.deviceName, _mtlDevice.name.UTF8String, VK_MAX_PHYSICAL_DEVICE_NAME_SIZE);
|
||||
}
|
||||
#endif //MVK_IOS_OR_TVOS
|
||||
#endif //!MVK_MACOS
|
||||
|
||||
// Since this is a uint8_t array, use Big-Endian byte ordering,
|
||||
// so a hex dump of the array is human readable in its parts.
|
||||
@ -3013,7 +3013,7 @@ uint32_t MVKPhysicalDevice::getHighestGPUCapability() {
|
||||
}
|
||||
|
||||
// Fall back to legacy feature sets on older OS's
|
||||
#if MVK_IOS
|
||||
#if MVK_IOS_OR_VISIONOS
|
||||
uint32_t maxFS = (uint32_t)MTLFeatureSet_iOS_GPUFamily5_v1;
|
||||
uint32_t minFS = (uint32_t)MTLFeatureSet_iOS_GPUFamily1_v1;
|
||||
#endif
|
||||
@ -3177,12 +3177,11 @@ void MVKPhysicalDevice::initMemoryProperties() {
|
||||
}
|
||||
|
||||
bool MVKPhysicalDevice::getHasUnifiedMemory() {
|
||||
#if MVK_IOS_OR_TVOS
|
||||
return true;
|
||||
#endif
|
||||
#if MVK_MACOS
|
||||
return ([_mtlDevice respondsToSelector: @selector(hasUnifiedMemory)]
|
||||
? _mtlDevice.hasUnifiedMemory : _mtlDevice.isLowPower);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -472,8 +472,7 @@ bool MVKImageMemoryBinding::needsHostReadSync(MVKPipelineBarrier& barrier) {
|
||||
return ((barrier.newLayout == VK_IMAGE_LAYOUT_GENERAL) &&
|
||||
mvkIsAnyFlagEnabled(barrier.dstAccessMask, (VK_ACCESS_HOST_READ_BIT | VK_ACCESS_MEMORY_READ_BIT)) &&
|
||||
isMemoryHostAccessible() && (!_device->_pMetalFeatures->sharedLinearTextures || !isMemoryHostCoherent()));
|
||||
#endif
|
||||
#if MVK_IOS_OR_TVOS
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
@ -131,6 +131,13 @@ using namespace std;
|
||||
# define MTLPixelFormatX24_Stencil8 MTLPixelFormatInvalid
|
||||
#endif
|
||||
|
||||
#if MVK_VISIONOS
|
||||
# define MTLPixelFormatDepth24Unorm_Stencil8 MTLPixelFormatInvalid
|
||||
# define MTLPixelFormatDepth16Unorm_Stencil8 MTLPixelFormatInvalid
|
||||
# define MTLPixelFormatX24_Stencil8 MTLPixelFormatInvalid
|
||||
#endif
|
||||
|
||||
|
||||
#if MVK_TVOS
|
||||
# define MTLPixelFormatASTC_4x4_HDR MTLPixelFormatInvalid
|
||||
# define MTLPixelFormatASTC_5x4_HDR MTLPixelFormatInvalid
|
||||
@ -1321,8 +1328,8 @@ void MVKPixelFormats::initMTLPixelFormatCapabilities() {
|
||||
addMTLPixelFormatDesc ( Depth32Float, None, DRM, DRFMR );
|
||||
addMTLPixelFormatDesc ( Stencil8, None, DRM, DRMR );
|
||||
addMTLPixelFormatDesc ( Depth24Unorm_Stencil8, Depth24_Stencil8, None, None );
|
||||
addMTLPixelFormatDesc ( Depth32Float_Stencil8, Depth32_Stencil8, DRM, DRFMR );
|
||||
addMTLPixelFormatDesc ( X24_Stencil8, Depth24_Stencil8, None, DRMR );
|
||||
addMTLPixelFormatDesc ( Depth32Float_Stencil8, Depth32_Stencil8, DRM, DRFMR );
|
||||
addMTLPixelFormatDesc ( X32_Stencil8, Depth32_Stencil8, DRM, DRMR );
|
||||
|
||||
_mtlPixelFormatDescriptions.shrink_to_fit();
|
||||
@ -2004,6 +2011,9 @@ void MVKPixelFormats::buildVkFormatMaps(id<MTLDevice> mtlDevice) {
|
||||
#endif
|
||||
#if MVK_IOS || MVK_TVOS
|
||||
bool supportsNativeTextureSwizzle = mtlDevice && mvkOSVersionIsAtLeast(13.0);
|
||||
#endif
|
||||
#if MVK_VISIONOS
|
||||
bool supportsNativeTextureSwizzle = mtlDevice;
|
||||
#endif
|
||||
if (!supportsNativeTextureSwizzle && !getMVKConfig().fullImageViewSwizzle) {
|
||||
vkDesc.mtlPixelFormat = vkDesc.mtlPixelFormatSubstitute = MTLPixelFormatInvalid;
|
||||
@ -2123,6 +2133,9 @@ void MVKPixelFormats::setFormatProperties(id<MTLDevice> mtlDevice, MVKVkFormatDe
|
||||
#if MVK_TVOS
|
||||
bool supportsStencilFeedback = false;
|
||||
#endif
|
||||
#if MVK_VISIONOS
|
||||
bool supportsStencilFeedback = [mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1];
|
||||
#endif
|
||||
|
||||
// Vulkan forbids blits between chroma-subsampled formats.
|
||||
// If we can't write the stencil reference from the shader, we can't blit stencil.
|
||||
|
@ -190,8 +190,8 @@ void MVKSwapchain::markFrameInterval() {
|
||||
VkResult MVKSwapchain::getRefreshCycleDuration(VkRefreshCycleDurationGOOGLE *pRefreshCycleDuration) {
|
||||
if (_device->getConfigurationResult() != VK_SUCCESS) { return _device->getConfigurationResult(); }
|
||||
|
||||
auto* screen = getCAMetalLayer().screenMVK; // Will be nil if headless
|
||||
#if MVK_MACOS && !MVK_MACCAT
|
||||
auto* screen = getCAMetalLayer().screenMVK; // Will be nil if headless
|
||||
double framesPerSecond = 60;
|
||||
if (screen) {
|
||||
CGDirectDisplayID displayId = [[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue];
|
||||
@ -207,6 +207,7 @@ VkResult MVKSwapchain::getRefreshCycleDuration(VkRefreshCycleDurationGOOGLE *pRe
|
||||
framesPerSecond = 60.0;
|
||||
}
|
||||
#elif MVK_IOS_OR_TVOS || MVK_MACCAT
|
||||
auto* screen = getCAMetalLayer().screenMVK; // Will be nil if headless
|
||||
NSInteger framesPerSecond = 60;
|
||||
if ([screen respondsToSelector: @selector(maximumFramesPerSecond)]) {
|
||||
framesPerSecond = screen.maximumFramesPerSecond;
|
||||
|
@ -30,7 +30,7 @@
|
||||
#if MVK_TVOS
|
||||
return 0;
|
||||
#endif
|
||||
#if MVK_IOS
|
||||
#if MVK_IOS_OR_VISIONOS
|
||||
if ( [self respondsToSelector: @selector(renderTargetArrayLength)] ) {
|
||||
return self.renderTargetArrayLength;
|
||||
}
|
||||
@ -44,7 +44,7 @@
|
||||
#if MVK_MACOS
|
||||
self.renderTargetArrayLength = length;
|
||||
#endif
|
||||
#if MVK_IOS
|
||||
#if MVK_IOS_OR_VISIONOS
|
||||
if ( [self respondsToSelector: @selector(setRenderTargetArrayLength:)] ) {
|
||||
self.renderTargetArrayLength = length;
|
||||
}
|
||||
@ -56,18 +56,17 @@
|
||||
|
||||
#if MVK_TVOS
|
||||
return 0;
|
||||
#endif
|
||||
#if MVK_MACOS_OR_IOS
|
||||
if ([self respondsToSelector: @selector(renderTargetWidth)])
|
||||
return self.renderTargetWidth;
|
||||
return 0;
|
||||
#else
|
||||
if ([self respondsToSelector: @selector(renderTargetWidth)])
|
||||
return self.renderTargetWidth;
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
-(void) setRenderTargetWidthMVK: (NSUInteger) width {
|
||||
|
||||
#if MVK_MACOS_OR_IOS
|
||||
#if !MVK_TVOS
|
||||
if ([self respondsToSelector: @selector(setRenderTargetWidth:)])
|
||||
self.renderTargetWidth = width;
|
||||
#endif
|
||||
@ -78,8 +77,7 @@
|
||||
|
||||
#if MVK_TVOS
|
||||
return 0;
|
||||
#endif
|
||||
#if MVK_MACOS_OR_IOS
|
||||
#else
|
||||
if ([self respondsToSelector: @selector(renderTargetHeight)])
|
||||
return self.renderTargetHeight;
|
||||
return 0;
|
||||
@ -89,7 +87,7 @@
|
||||
|
||||
-(void) setRenderTargetHeightMVK: (NSUInteger) height {
|
||||
|
||||
#if MVK_MACOS_OR_IOS
|
||||
#if !MVK_TVOS
|
||||
if ([self respondsToSelector: @selector(setRenderTargetHeight:)])
|
||||
self.renderTargetHeight = height;
|
||||
#endif
|
||||
|
@ -75,6 +75,10 @@
|
||||
# define MVK_SUPPORT_IOSURFACE_BOOL (__TV_OS_VERSION_MIN_REQUIRED >= __TVOS_11_0)
|
||||
#endif
|
||||
|
||||
#if MVK_VISIONOS
|
||||
# define MVK_SUPPORT_IOSURFACE_BOOL 1
|
||||
#endif
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark MoltenVK Configuration
|
||||
@ -126,6 +130,9 @@ void mvkSetConfig(MVKConfiguration& dstMVKConfig, const MVKConfiguration& srcMVK
|
||||
#if MVK_IOS_OR_TVOS
|
||||
# define MVK_CONFIG_MTLEVENT_MIN_OS 12.0
|
||||
#endif
|
||||
#if MVK_VISIONOS
|
||||
# define MVK_CONFIG_MTLEVENT_MIN_OS 1.0
|
||||
#endif
|
||||
#ifndef MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS
|
||||
# define MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS mvkOSVersionIsAtLeast(MVK_CONFIG_MTLEVENT_MIN_OS)
|
||||
#endif
|
||||
|
@ -553,11 +553,10 @@ static void mvkRemoveAllOccurances(C& container, T val) {
|
||||
/** Selects and returns one of the values, based on the platform OS. */
|
||||
template<typename T>
|
||||
static constexpr const T& mvkSelectPlatformValue(const T& macOSVal, const T& iOSVal) {
|
||||
#if MVK_IOS_OR_TVOS
|
||||
return iOSVal;
|
||||
#endif
|
||||
#if MVK_MACOS
|
||||
return macOSVal;
|
||||
#else
|
||||
return iOSVal;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -206,6 +206,7 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
279BD8642B7FAE0A0021CE70 /* create_dylib_xros.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = create_dylib_xros.sh; sourceTree = "<group>"; };
|
||||
A92DB3E41CE0F37D00FBC835 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
|
||||
A92DB3E51CE0F37D00FBC835 /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
|
||||
A92DB3E61CE0F37D00FBC835 /* Whats_New.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; name = Whats_New.md; path = Docs/Whats_New.md; sourceTree = "<group>"; };
|
||||
@ -278,6 +279,7 @@
|
||||
A9C70F45221B04C800FBA31A /* create_dylib_ios.sh */,
|
||||
A9C70F41221B04C800FBA31A /* create_dylib_macos.sh */,
|
||||
A9FC5F64249D3778003CB086 /* create_dylib_tvos.sh */,
|
||||
279BD8642B7FAE0A0021CE70 /* create_dylib_xros.sh */,
|
||||
A975D55C213F25D700D4834F /* create_dylib.sh */,
|
||||
A9B1007A24F837AF00EADC6E /* create_xcframework_func.sh */,
|
||||
A980A25F24C628F3007A8F6F /* gen_moltenvk_rev_hdr.sh */,
|
||||
|
Loading…
x
Reference in New Issue
Block a user