Remove use of @available() directive as it can cause issues in some build environments.
Generally replace use of @available() with respondsToSelector:. Add mvkMakeOSVersion() and mvkOSVersionIsAtLeast(macos,ios) to help testing OS versions. Set maxDrawIndexedIndexValue to kMVKUndefinedLargeUInt32 instead of uint32_t max.
This commit is contained in:
parent
7cf3b26b37
commit
dd98fbd26f
@ -18,12 +18,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "MVKCommonEnvironment.h"
|
||||||
#include <dispatch/dispatch.h>
|
#include <dispatch/dispatch.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
|
|
||||||
typedef float MVKOSVersion;
|
typedef float MVKOSVersion;
|
||||||
|
|
||||||
|
/*** Constant indicating unsupported functionality in an OS. */
|
||||||
|
static const MVKOSVersion kMVKOSVersionUnsupported = std::numeric_limits<MVKOSVersion>::max();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the operating system version as an MVKOSVersion, which is a float in which the
|
* Returns the operating system version as an MVKOSVersion, which is a float in which the
|
||||||
* whole number portion indicates the major version, and the fractional portion indicates
|
* whole number portion indicates the major version, and the fractional portion indicates
|
||||||
@ -33,9 +38,29 @@ typedef float MVKOSVersion;
|
|||||||
*/
|
*/
|
||||||
MVKOSVersion mvkOSVersion();
|
MVKOSVersion mvkOSVersion();
|
||||||
|
|
||||||
|
/** Returns a MVKOSVersion built from the version components. */
|
||||||
|
inline MVKOSVersion mvkMakeOSVersion(uint32_t major, uint32_t minor, uint32_t patch) {
|
||||||
|
return (float)major + ((float)minor / 100.0f) + ((float)patch / 10000.0f);
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns whether the operating system version is at least minVer. */
|
/** Returns whether the operating system version is at least minVer. */
|
||||||
inline bool mvkOSVersionIsAtLeast(MVKOSVersion minVer) { return mvkOSVersion() >= minVer; }
|
inline bool mvkOSVersionIsAtLeast(MVKOSVersion minVer) { return mvkOSVersion() >= minVer; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the operating system version is at least the appropriate min version.
|
||||||
|
* The constant kMVKOSVersionUnsupported can be used for either value to cause the test
|
||||||
|
* to always fail on that OS, which is useful for indidicating functionalty guarded by
|
||||||
|
* this test is not supported on that OS.
|
||||||
|
*/
|
||||||
|
inline bool mvkOSVersionIsAtLeast(MVKOSVersion macOSMinVer, MVKOSVersion iOSMinVer) {
|
||||||
|
#if MVK_MACOS
|
||||||
|
return mvkOSVersionIsAtLeast(macOSMinVer);
|
||||||
|
#endif
|
||||||
|
#if MVK_IOS
|
||||||
|
return mvkOSVersionIsAtLeast(iOSMinVer);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a monotonic timestamp value for use in Vulkan and performance timestamping.
|
* Returns a monotonic timestamp value for use in Vulkan and performance timestamping.
|
||||||
*
|
*
|
||||||
|
@ -29,17 +29,13 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
static const MVKOSVersion kMVKOSVersionUnknown = 0.0f;
|
|
||||||
static MVKOSVersion _mvkOSVersion = kMVKOSVersionUnknown;
|
|
||||||
MVKOSVersion mvkOSVersion() {
|
MVKOSVersion mvkOSVersion() {
|
||||||
if (_mvkOSVersion == kMVKOSVersionUnknown) {
|
static MVKOSVersion _mvkOSVersion = 0;
|
||||||
NSOperatingSystemVersion osVer = [[NSProcessInfo processInfo] operatingSystemVersion];
|
if ( !_mvkOSVersion ) {
|
||||||
float maj = osVer.majorVersion;
|
NSOperatingSystemVersion osVer = [[NSProcessInfo processInfo] operatingSystemVersion];
|
||||||
float min = osVer.minorVersion;
|
_mvkOSVersion = mvkMakeOSVersion((uint32_t)osVer.majorVersion, (uint32_t)osVer.minorVersion, (uint32_t)osVer.patchVersion);
|
||||||
float pat = osVer.patchVersion;
|
}
|
||||||
_mvkOSVersion = maj + (min / 100.0f) + + (pat / 10000.0f);
|
return _mvkOSVersion;
|
||||||
}
|
|
||||||
return _mvkOSVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t _mvkTimestampBase;
|
static uint64_t _mvkTimestampBase;
|
||||||
|
@ -1476,7 +1476,7 @@ void MVKPhysicalDevice::initProperties() {
|
|||||||
_properties.limits.maxComputeWorkGroupCount[1] = kMVKUndefinedLargeUInt32;
|
_properties.limits.maxComputeWorkGroupCount[1] = kMVKUndefinedLargeUInt32;
|
||||||
_properties.limits.maxComputeWorkGroupCount[2] = kMVKUndefinedLargeUInt32;
|
_properties.limits.maxComputeWorkGroupCount[2] = kMVKUndefinedLargeUInt32;
|
||||||
|
|
||||||
_properties.limits.maxDrawIndexedIndexValue = numeric_limits<uint32_t>::max();
|
_properties.limits.maxDrawIndexedIndexValue = kMVKUndefinedLargeUInt32;
|
||||||
_properties.limits.maxDrawIndirectCount = kMVKUndefinedLargeUInt32;
|
_properties.limits.maxDrawIndirectCount = kMVKUndefinedLargeUInt32;
|
||||||
|
|
||||||
_properties.limits.maxClipDistances = kMVKUndefinedLargeUInt32;
|
_properties.limits.maxClipDistances = kMVKUndefinedLargeUInt32;
|
||||||
|
@ -991,7 +991,7 @@ void MVKPresentableSwapchainImage::presentCAMetalDrawable(id<MTLCommandBuffer> m
|
|||||||
}];
|
}];
|
||||||
|
|
||||||
if (hasPresentTime) {
|
if (hasPresentTime) {
|
||||||
if (@available(iOS 10.3, macOS 10.15.4, *)) {
|
if ([_mtlDrawable respondsToSelector: @selector(addPresentedHandler:)]) {
|
||||||
[_mtlDrawable addPresentedHandler: ^(id<MTLDrawable> drawable) {
|
[_mtlDrawable addPresentedHandler: ^(id<MTLDrawable> drawable) {
|
||||||
// Record the presentation time
|
// Record the presentation time
|
||||||
CFTimeInterval presentedTimeSeconds = drawable.presentedTime;
|
CFTimeInterval presentedTimeSeconds = drawable.presentedTime;
|
||||||
|
@ -383,19 +383,19 @@ void MVKSwapchain::initSurfaceImages(const VkSwapchainCreateInfoKHR* pCreateInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
VkResult MVKSwapchain::getRefreshCycleDuration(VkRefreshCycleDurationGOOGLE *pRefreshCycleDuration) {
|
VkResult MVKSwapchain::getRefreshCycleDuration(VkRefreshCycleDurationGOOGLE *pRefreshCycleDuration) {
|
||||||
#if MVK_IOS
|
|
||||||
NSInteger framesPerSecond = 60;
|
NSInteger framesPerSecond = 60;
|
||||||
if (@available(iOS 10.3, *)) {
|
|
||||||
framesPerSecond = [UIScreen mainScreen].maximumFramesPerSecond;
|
#if MVK_IOS
|
||||||
} else {
|
UIScreen* screen = [UIScreen mainScreen];
|
||||||
// TODO: fallback
|
if ([screen respondsToSelector: @selector(maximumFramesPerSecond)]) {
|
||||||
|
framesPerSecond = screen.maximumFramesPerSecond;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if MVK_MACOS
|
#if MVK_MACOS
|
||||||
// TODO: hook this up for macOS, probably need to use CGDisplayModeGetRefeshRate
|
// TODO: hook this up for macOS, probably need to use CGDisplayModeGetRefeshRate
|
||||||
NSInteger framesPerSecond = 60;
|
|
||||||
#endif
|
#endif
|
||||||
pRefreshCycleDuration->refreshDuration = 1e9 / ( uint64_t ) framesPerSecond;
|
|
||||||
|
pRefreshCycleDuration->refreshDuration = (uint64_t)1e9 / framesPerSecond;
|
||||||
return VK_SUCCESS;
|
return VK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -836,9 +836,10 @@
|
|||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = NO;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = NO;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = NO;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
@ -855,8 +856,8 @@
|
|||||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
|
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
|
||||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_PARAMETER = YES;
|
|
||||||
GCC_WARN_UNUSED_VARIABLE = NO;
|
GCC_WARN_UNUSED_VARIABLE = NO;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
@ -890,9 +891,10 @@
|
|||||||
CLANG_WARN_INT_CONVERSION = YES;
|
CLANG_WARN_INT_CONVERSION = YES;
|
||||||
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
|
||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES;
|
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = NO;
|
||||||
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
CLANG_WARN_SUSPICIOUS_MOVE = YES;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = NO;
|
CLANG_WARN_UNGUARDED_AVAILABILITY = NO;
|
||||||
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
COPY_PHASE_STRIP = YES;
|
COPY_PHASE_STRIP = YES;
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
@ -909,8 +911,8 @@
|
|||||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
|
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
|
||||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
||||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||||
GCC_WARN_UNUSED_PARAMETER = YES;
|
|
||||||
GCC_WARN_UNUSED_VARIABLE = NO;
|
GCC_WARN_UNUSED_VARIABLE = NO;
|
||||||
HEADER_SEARCH_PATHS = (
|
HEADER_SEARCH_PATHS = (
|
||||||
"$(inherited)",
|
"$(inherited)",
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "OSSupport.h"
|
#include "OSSupport.h"
|
||||||
#include "FileSupport.h"
|
#include "FileSupport.h"
|
||||||
#include "MoltenVKShaderConverterTool.h"
|
#include "MoltenVKShaderConverterTool.h"
|
||||||
|
#include "MVKOSExtensions.h"
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <Metal/Metal.h>
|
#import <Metal/Metal.h>
|
||||||
@ -71,13 +72,9 @@ bool mvk::compile(const string& mslSourceCode,
|
|||||||
|
|
||||||
MTLLanguageVersion mslVerEnum = (MTLLanguageVersion)0;
|
MTLLanguageVersion mslVerEnum = (MTLLanguageVersion)0;
|
||||||
if (mslVer(2, 1, 0)) {
|
if (mslVer(2, 1, 0)) {
|
||||||
if (@available(macOS 10.14, *)) {
|
mslVerEnum = MTLLanguageVersion2_1;
|
||||||
mslVerEnum = MTLLanguageVersion2_1;
|
|
||||||
}
|
|
||||||
} else if (mslVer(2, 0, 0)) {
|
} else if (mslVer(2, 0, 0)) {
|
||||||
if (@available(macOS 10.13, *)) {
|
mslVerEnum = MTLLanguageVersion2_0;
|
||||||
mslVerEnum = MTLLanguageVersion2_0;
|
|
||||||
}
|
|
||||||
} else if (mslVer(1, 2, 0)) {
|
} else if (mslVer(1, 2, 0)) {
|
||||||
mslVerEnum = MTLLanguageVersion1_2;
|
mslVerEnum = MTLLanguageVersion1_2;
|
||||||
} else if (mslVer(1, 1, 0)) {
|
} else if (mslVer(1, 1, 0)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user