Add MVKLogWarning, apiVersion warning
* Added MVKLogWarning logger, and updated header comments. * Added greater _appInfo.apiVersion than MoltenVK version warning.
This commit is contained in:
parent
a22dfba076
commit
c8813898cf
@ -35,9 +35,9 @@ extern "C" {
|
|||||||
* This library adds flexible, non-intrusive logging and assertion capabilities
|
* This library adds flexible, non-intrusive logging and assertion capabilities
|
||||||
* that can be efficiently enabled or disabled via compiler switches.
|
* that can be efficiently enabled or disabled via compiler switches.
|
||||||
*
|
*
|
||||||
* There are four levels of logging: Trace, Info, Error and Debug, and each can be enabled
|
* There are five levels of logging: Trace, Info, Warning, Error and Debug, and each can be enabled
|
||||||
* independently via the MVK_LOG_LEVEL_TRACE, MVK_LOG_LEVEL_INFO, MVK_LOG_LEVEL_ERROR and
|
* independently via the MVK_LOG_LEVEL_TRACE, MVK_LOG_LEVEL_INFO, MVK_LOG_LEVEL_WARNING,
|
||||||
* MVK_LOG_LEVEL_DEBUG switches, respectively.
|
* MVK_LOG_LEVEL_ERROR and MVK_LOG_LEVEL_DEBUG switches, respectively.
|
||||||
*
|
*
|
||||||
* ALL logging can be enabled or disabled via the MVK_LOGGING_ENABLED switch.
|
* ALL logging can be enabled or disabled via the MVK_LOGGING_ENABLED switch.
|
||||||
*
|
*
|
||||||
@ -59,12 +59,17 @@ extern "C" {
|
|||||||
* MVKLogErrorIf(cond, fmt, ...) - same as MVKLogError if boolean "cond" condition expression evaluates to YES,
|
* MVKLogErrorIf(cond, fmt, ...) - same as MVKLogError if boolean "cond" condition expression evaluates to YES,
|
||||||
* otherwise logs nothing.
|
* otherwise logs nothing.
|
||||||
*
|
*
|
||||||
|
* MVKLogWarning(fmt, ...) - recommended for not immediately harmful errors
|
||||||
|
* - will print if MVK_LOG_LEVEL_WARNING is set on.
|
||||||
|
* MVKLogWarningIf(cond, fmt, ...) - same as MVKLogWarning if boolean "cond" condition expression evaluates to YES,
|
||||||
|
* otherwise logs nothing.
|
||||||
|
*
|
||||||
* MVKLogInfo(fmt, ...) - recommended for general, infrequent, information messages
|
* MVKLogInfo(fmt, ...) - recommended for general, infrequent, information messages
|
||||||
* - will print if MVK_LOG_LEVEL_INFO is set on.
|
* - will print if MVK_LOG_LEVEL_INFO is set on.
|
||||||
* MVKLogInfoIf(cond, fmt, ...) - same as MVKLogInfo if boolean "cond" condition expression evaluates to YES,
|
* MVKLogInfoIf(cond, fmt, ...) - same as MVKLogInfo if boolean "cond" condition expression evaluates to YES,
|
||||||
* otherwise logs nothing.
|
* otherwise logs nothing.
|
||||||
*
|
*
|
||||||
* MVKLogDebug(fmt, ...) - recommended for temporary use during debugging
|
* MVKLogDebug(fmt, ...) - recommended for temporary use during debugging
|
||||||
* - will print if MVK_LOG_LEVEL_DEBUG is set on.
|
* - will print if MVK_LOG_LEVEL_DEBUG is set on.
|
||||||
* MVKLogDebugIf(cond, fmt, ...) - same as MVKLogDebug if boolean "cond" condition expression evaluates to YES,
|
* MVKLogDebugIf(cond, fmt, ...) - same as MVKLogDebug if boolean "cond" condition expression evaluates to YES,
|
||||||
* otherwise logs nothing.
|
* otherwise logs nothing.
|
||||||
@ -118,6 +123,9 @@ extern "C" {
|
|||||||
#ifndef MVK_LOG_LEVEL_ERROR
|
#ifndef MVK_LOG_LEVEL_ERROR
|
||||||
# define MVK_LOG_LEVEL_ERROR MVK_LOGGING_ENABLED
|
# define MVK_LOG_LEVEL_ERROR MVK_LOGGING_ENABLED
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef MVK_LOG_LEVEL_WARNING
|
||||||
|
# define MVK_LOG_LEVEL_WARNING MVK_LOGGING_ENABLED
|
||||||
|
#endif
|
||||||
#ifndef MVK_LOG_LEVEL_INFO
|
#ifndef MVK_LOG_LEVEL_INFO
|
||||||
# define MVK_LOG_LEVEL_INFO MVK_LOGGING_ENABLED
|
# define MVK_LOG_LEVEL_INFO MVK_LOGGING_ENABLED
|
||||||
#endif
|
#endif
|
||||||
@ -140,6 +148,15 @@ extern "C" {
|
|||||||
# define MVKLogErrorIf(cond, fmt, ...)
|
# define MVKLogErrorIf(cond, fmt, ...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Warning logging - for not immediately harmful errors
|
||||||
|
#if MVK_LOG_LEVEL_WARNING
|
||||||
|
# define MVKLogWarning(fmt, ...) MVKLogWarningImpl(fmt, ##__VA_ARGS__)
|
||||||
|
# define MVKLogWarningIf(cond, fmt, ...) if(cond) { MVKLogWarningImpl(fmt, ##__VA_ARGS__); }
|
||||||
|
#else
|
||||||
|
# define MVKLogWarning(...)
|
||||||
|
# define MVKLogWarningIf(cond, fmt, ...)
|
||||||
|
#endif
|
||||||
|
|
||||||
// Info logging - for general, non-performance affecting information messages
|
// Info logging - for general, non-performance affecting information messages
|
||||||
#if MVK_LOG_LEVEL_INFO
|
#if MVK_LOG_LEVEL_INFO
|
||||||
# define MVKLogInfo(fmt, ...) MVKLogInfoImpl(fmt, ##__VA_ARGS__)
|
# define MVKLogInfo(fmt, ...) MVKLogInfoImpl(fmt, ##__VA_ARGS__)
|
||||||
@ -168,6 +185,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MVKLogErrorImpl(fmt, ...) reportMessage(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
|
#define MVKLogErrorImpl(fmt, ...) reportMessage(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
|
||||||
|
#define MVKLogWarningImpl(fmt, ...) reportMessage(ASL_LEVEL_WARNING, fmt, ##__VA_ARGS__)
|
||||||
#define MVKLogInfoImpl(fmt, ...) reportMessage(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
|
#define MVKLogInfoImpl(fmt, ...) reportMessage(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
|
||||||
#define MVKLogTraceImpl(fmt, ...) reportMessage(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
#define MVKLogTraceImpl(fmt, ...) reportMessage(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||||
#define MVKLogDebugImpl(fmt, ...) reportMessage(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
#define MVKLogDebugImpl(fmt, ...) reportMessage(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
|
||||||
|
@ -335,16 +335,12 @@ MVKInstance::MVKInstance(const VkInstanceCreateInfo* pCreateInfo) : _enabledExte
|
|||||||
|
|
||||||
mvkSetOrClear(&_appInfo, pCreateInfo->pApplicationInfo);
|
mvkSetOrClear(&_appInfo, pCreateInfo->pApplicationInfo);
|
||||||
|
|
||||||
if (_appInfo.apiVersion == 0) {
|
if (_appInfo.apiVersion > MVK_VULKAN_API_VERSION) {
|
||||||
_appInfo.apiVersion = VK_API_VERSION_1_0; // Default
|
MVKLogWarning("Unrecognized CreateInstance->pCreateInfo->pApplicationInfo->apiVersion number (0x%08x). Assuming MoltenVK %d.%d version.",
|
||||||
|
_appInfo.apiVersion, MVK_VERSION_MAJOR, MVK_VERSION_MINOR);
|
||||||
}
|
}
|
||||||
else if (VK_API_VERSION_MAJOR(_appInfo.apiVersion) > MVK_VERSION_MAJOR ||
|
|
||||||
VK_API_VERSION_MINOR(_appInfo.apiVersion) > MVK_VERSION_MINOR) {
|
if (_appInfo.apiVersion == 0) { _appInfo.apiVersion = VK_API_VERSION_1_0; } // Default
|
||||||
reportMessage(ASL_LEVEL_WARNING,
|
|
||||||
"Unsupported MoltenVK API version. Assuming VK_API_VERSION_1_1.");
|
|
||||||
_appInfo.apiVersion = MVK_VULKAN_API_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
initProcAddrs(); // Init function pointers
|
initProcAddrs(); // Init function pointers
|
||||||
|
|
||||||
@ -365,7 +361,7 @@ MVKInstance::MVKInstance(const VkInstanceCreateInfo* pCreateInfo) : _enabledExte
|
|||||||
_physicalDevices.push_back(new MVKPhysicalDevice(this, mtlDev));
|
_physicalDevices.push_back(new MVKPhysicalDevice(this, mtlDev));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_physicalDevices.empty()) {
|
if (_physicalDevices.empty()) {
|
||||||
setConfigurationResult(reportError(VK_ERROR_INCOMPATIBLE_DRIVER, "Vulkan is not supported on this device. MoltenVK requires Metal, which is not available on this device."));
|
setConfigurationResult(reportError(VK_ERROR_INCOMPATIBLE_DRIVER, "Vulkan is not supported on this device. MoltenVK requires Metal, which is not available on this device."));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user