Merge pull request #1297 from billhollings/config-adv-multiple-extns

Extend MVKConfiguration::advertiseExtensions to optionally specify a few extensions.
This commit is contained in:
Bill Hollings 2021-03-09 10:07:03 -05:00 committed by GitHub
commit 315cb418cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 48 additions and 15 deletions

View File

@ -22,7 +22,7 @@ Released TBD
- Add `MVKConfiguration::apiVersionToAdvertise` and `MVK_CONFIG_API_VERSION_TO_ADVERTISE` - Add `MVKConfiguration::apiVersionToAdvertise` and `MVK_CONFIG_API_VERSION_TO_ADVERTISE`
env var to configure **MoltenVK** to advertise a particular _Vulkan_ version. env var to configure **MoltenVK** to advertise a particular _Vulkan_ version.
- Add `MVKConfiguration::advertiseExtensions` and `MVK_CONFIG_ADVERTISE_EXTENSIONS` - Add `MVKConfiguration::advertiseExtensions` and `MVK_CONFIG_ADVERTISE_EXTENSIONS`
env var to configure **MoltenVK** to not advertise support for any _Vulkan_ extensions. env var to configure **MoltenVK** to force advertising support for no, or minimal, _Vulkan_ extensions.
- Remove the `Hologram` and `API-Samples` demo apps, and remove - Remove the `Hologram` and `API-Samples` demo apps, and remove
`LunarG/VulkanSamples` as a dependency library. `LunarG/VulkanSamples` as a dependency library.
- Add `NDEBUG` macro to all Release builds to remove `assert()` calls. - Add `NDEBUG` macro to all Release builds to remove `assert()` calls.

View File

@ -58,6 +58,16 @@ typedef unsigned long MTLLanguageVersion;
#define VK_MVK_MOLTENVK_SPEC_VERSION 31 #define VK_MVK_MOLTENVK_SPEC_VERSION 31
#define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk" #define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
/** Identifies extensions to advertise as part of MoltenVK configuration. */
typedef enum MVKConfigAdvertiseExtensionBits {
MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL = 0x00000001, /**< All supported extensions. */
MVK_CONFIG_ADVERTISE_EXTENSIONS_MOLTENVK = 0x00000002, /**< This VK_MVK_moltenvk extension. */
MVK_CONFIG_ADVERTISE_EXTENSIONS_WSI = 0x00000004, /**< WSI extensions supported on the platform. */
MVK_CONFIG_ADVERTISE_EXTENSIONS_PORTABILITY = 0x00000008, /**< Vulkan Portability Subset extensions. */
MVK_CONFIG_ADVERTISE_EXTENSIONS_MAX_ENUM = 0x7FFFFFFF
} MVKConfigAdvertiseExtensionBits;
typedef VkFlags MVKConfigAdvertiseExtensions;
/** /**
* MoltenVK configuration settings. * MoltenVK configuration settings.
* *
@ -732,10 +742,12 @@ typedef struct {
uint32_t apiVersionToAdvertise; uint32_t apiVersionToAdvertise;
/** /**
* Controls whether MoltenVK should advertise the Vulkan extensions it supports in * Controls which extensions MoltenVK should advertise it supports in
* vkEnumerateInstanceExtensionProperties() and vkEnumerateDeviceExtensionProperties(). * vkEnumerateInstanceExtensionProperties() and vkEnumerateDeviceExtensionProperties().
* If this setting is enabled, all supported extensions will be advertised. * The value of this parameter is a bitwise OR of values from the MVKConfigAdvertiseExtensionBits
* If this setting is disabled, only VK_KHR_portability_subset will be advertised. * enumeration. Any prerequisite extensions are also advertised.
* If the flag MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL is included, all supported extensions
* will be advertised. A value of zero means no extensions will be advertised.
* *
* The value of this parameter must be changed before creating a VkInstance, * The value of this parameter must be changed before creating a VkInstance,
* for the change to take effect. * for the change to take effect.
@ -743,10 +755,10 @@ typedef struct {
* The initial value or this parameter is set by the * The initial value or this parameter is set by the
* MVK_CONFIG_ADVERTISE_EXTENSIONS * MVK_CONFIG_ADVERTISE_EXTENSIONS
* runtime environment variable or MoltenVK compile-time build setting. * runtime environment variable or MoltenVK compile-time build setting.
* If neither is set, this setting is enabled by default, and all supported * If neither is set, the value of this setting defaults to
* extensions will be advertised. * MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL, and all supported extensions will be advertised.
*/ */
VkBool32 advertiseExtensions; MVKConfigAdvertiseExtensions advertiseExtensions;
} MVKConfiguration; } MVKConfiguration;

View File

@ -42,10 +42,15 @@ typedef struct {
bool isDevice; bool isDevice;
bool isCore() { return !ext1Name && !ext2Name; } bool isCore() { return !ext1Name && !ext2Name; }
// If we're artificially running without all supported extensions, allow the
// associated functions to be available anyway, in case the app is surprised
// (ie- expects the functions from past experience and has no alternate handling).
bool isEnabled(uint32_t enabledVersion, const MVKExtensionList& extList) { bool isEnabled(uint32_t enabledVersion, const MVKExtensionList& extList) {
return ((isCore() && MVK_VULKAN_API_VERSION_CONFORM(enabledVersion) >= apiVersion) || return ((isCore() && MVK_VULKAN_API_VERSION_CONFORM(enabledVersion) >= apiVersion) ||
(extList.isEnabled(ext1Name) || extList.isEnabled(ext2Name) || (extList.isEnabled(ext1Name) || extList.isEnabled(ext2Name) ||
!mvkGetMVKConfiguration()->advertiseExtensions)); !mvkIsAnyFlagEnabled(mvkGetMVKConfiguration()->advertiseExtensions,
MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL)));
} }
} MVKEntryPoint; } MVKEntryPoint;

View File

@ -49,11 +49,27 @@ static bool mvkIsSupportedOnPlatform(VkExtensionProperties* pProperties) {
#define MVK_EXTENSION_MIN_OS(EXT, MAC, IOS) \ #define MVK_EXTENSION_MIN_OS(EXT, MAC, IOS) \
if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(MAC, IOS); } if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(MAC, IOS); }
// Extensions that must always be advertised if supported on platform // If the config indicates that not all supported extensions should be advertised,
MVK_EXTENSION_MIN_OS(KHR_PORTABILITY_SUBSET, 10.11, 8.0) // only advertise those supported extensions that have been specifically configured.
auto advExtns = mvkGetMVKConfiguration()->advertiseExtensions;
if ( !mvkIsAnyFlagEnabled(advExtns, MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL) ) {
if (mvkIsAnyFlagEnabled(advExtns, MVK_CONFIG_ADVERTISE_EXTENSIONS_MOLTENVK)) {
MVK_EXTENSION_MIN_OS(MVK_MOLTENVK, 10.11, 8.0)
}
if (mvkIsAnyFlagEnabled(advExtns, MVK_CONFIG_ADVERTISE_EXTENSIONS_WSI)) {
MVK_EXTENSION_MIN_OS(EXT_METAL_SURFACE, 10.11, 8.0)
MVK_EXTENSION_MIN_OS(MVK_IOS_SURFACE, MVK_NA, 8.0)
MVK_EXTENSION_MIN_OS(MVK_MACOS_SURFACE, 10.11, MVK_NA)
MVK_EXTENSION_MIN_OS(KHR_SURFACE, 10.11, 8.0)
MVK_EXTENSION_MIN_OS(KHR_SWAPCHAIN, 10.11, 8.0)
}
if (mvkIsAnyFlagEnabled(advExtns, MVK_CONFIG_ADVERTISE_EXTENSIONS_PORTABILITY)) {
MVK_EXTENSION_MIN_OS(KHR_PORTABILITY_SUBSET, 10.11, 8.0)
MVK_EXTENSION_MIN_OS(KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2, 10.11, 8.0)
}
// For all other extensions, only advertise if configured to do so return false;
if ( !mvkGetMVKConfiguration()->advertiseExtensions ) { return false; } }
MVK_EXTENSION_MIN_OS(MVK_IOS_SURFACE, MVK_NA, 8.0) MVK_EXTENSION_MIN_OS(MVK_IOS_SURFACE, MVK_NA, 8.0)
MVK_EXTENSION_MIN_OS(MVK_MACOS_SURFACE, 10.11, MVK_NA) MVK_EXTENSION_MIN_OS(MVK_MACOS_SURFACE, 10.11, MVK_NA)

View File

@ -59,7 +59,7 @@ static void mvkInitConfigFromEnvVars() {
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.useCommandPooling, MVK_CONFIG_USE_COMMAND_POOLING); MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.useCommandPooling, MVK_CONFIG_USE_COMMAND_POOLING);
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.useMTLHeap, MVK_CONFIG_USE_MTLHEAP); MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.useMTLHeap, MVK_CONFIG_USE_MTLHEAP);
MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.apiVersionToAdvertise, MVK_CONFIG_API_VERSION_TO_ADVERTISE); MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.apiVersionToAdvertise, MVK_CONFIG_API_VERSION_TO_ADVERTISE);
MVK_SET_FROM_ENV_OR_BUILD_BOOL (evCfg.advertiseExtensions, MVK_CONFIG_ADVERTISE_EXTENSIONS); MVK_SET_FROM_ENV_OR_BUILD_INT32 (evCfg.advertiseExtensions, MVK_CONFIG_ADVERTISE_EXTENSIONS);
mvkSetMVKConfiguration(&evCfg); mvkSetMVKConfiguration(&evCfg);
} }

View File

@ -283,7 +283,7 @@ void mvkSetMVKConfiguration(MVKConfiguration* pMVKConfig);
# define MVK_CONFIG_API_VERSION_TO_ADVERTISE MVK_VULKAN_API_VERSION # define MVK_CONFIG_API_VERSION_TO_ADVERTISE MVK_VULKAN_API_VERSION
#endif #endif
/** Advertise supported extensions. Enabled by default. */ /** Advertise supported extensions. Defaults to all. */
#ifndef MVK_CONFIG_ADVERTISE_EXTENSIONS #ifndef MVK_CONFIG_ADVERTISE_EXTENSIONS
# define MVK_CONFIG_ADVERTISE_EXTENSIONS 1 # define MVK_CONFIG_ADVERTISE_EXTENSIONS MVK_CONFIG_ADVERTISE_EXTENSIONS_ALL
#endif #endif