Fixes from review for Mac Catalyst on macOS 11.0+.

MVKPixelFormats revert testing for stencil feedback and add Mac Catalyst test.
Revert mvkOSVersionIsAtLeast(mac, ios) to remove test for Mac Catalyst version.
MVKRenderPass revert testing for MTLStorageModeMemoryless for iOS.
This commit is contained in:
Bill Hollings 2020-12-02 16:22:38 -05:00
parent f8d82620c0
commit 7f62362db3
5 changed files with 23 additions and 22 deletions

View File

@ -48,19 +48,16 @@ inline bool mvkOSVersionIsAtLeast(MVKOSVersion minVer) { return mvkOSVersion() >
/**
* Returns whether the operating system version is at least the appropriate min version.
* The constant kMVKOSVersionUnsupported can be used for any value to cause the test
* 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 iOSMinVer, MVKOSVersion macOSMinVer, MVKOSVersion macCatMinVer) {
#if MVK_IOS_OR_TVOS
return mvkOSVersionIsAtLeast(iOSMinVer);
#endif
inline bool mvkOSVersionIsAtLeast(MVKOSVersion macOSMinVer, MVKOSVersion iOSMinVer) {
#if MVK_MACOS
return mvkOSVersionIsAtLeast(macOSMinVer);
#endif
#if MVK_MACCAT
return mvkOSVersionIsAtLeast(macCatMinVer);
#if MVK_IOS_OR_TVOS
return mvkOSVersionIsAtLeast(iOSMinVer);
#endif
}

View File

@ -330,7 +330,7 @@ void MVKPhysicalDevice::getProperties(VkPhysicalDeviceProperties2* properties) {
if (_features.tessellationShader) {
subgroupProps->supportedStages |= VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
}
if (mvkOSVersionIsAtLeast(13.0, 10.15, 14.0)) {
if (mvkOSVersionIsAtLeast(10.15, 13.0)) {
subgroupProps->supportedStages |= VK_SHADER_STAGE_FRAGMENT_BIT;
}
subgroupProps->supportedOperations = VK_SUBGROUP_FEATURE_BASIC_BIT;

View File

@ -2043,25 +2043,25 @@ void MVKPixelFormats::setFormatProperties(MVKVkFormatDesc& vkDesc) {
enableFormatFeatures(DSAtt, Tex, mtlPixFmtCaps, vkProps.optimalTilingFeatures);
enableFormatFeatures(Blend, Tex, mtlPixFmtCaps, vkProps.optimalTilingFeatures);
#if MVK_MACOS_OR_IOS
// We would really want to use the device's Metal features instead of duplicating
// the logic from MVKPhysicalDevice, but those may not have been initialized yet.
id<MTLDevice> mtlDev = _physicalDevice ? _physicalDevice->getMTLDevice() : nil;
#if MVK_MACOS && !MVK_MACCAT
bool supportsStencilFeedback = [mtlDev supportsFeatureSet: MTLFeatureSet_macOS_GPUFamily2_v1];
#endif
if ( chromaSubsamplingComponentBits > 0 ||
// XXX We really want to use the device's Metal features instead of duplicating the
// logic from MVKPhysicalDevice, but those may not have been initialized yet.
#if MVK_MACOS
(isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || !([mtlDev supportsFamily: MTLGPUFamilyMac2] ||
[mtlDev supportsFamily: MTLGPUFamilyMacCatalyst2])))
#if MVK_MACCAT
bool supportsStencilFeedback = [mtlDev supportsFamily: MTLGPUFamilyMacCatalyst2];
#endif
#if MVK_IOS
(isStencilFormat(vkDesc.mtlPixelFormat) && (!_physicalDevice || ![mtlDev supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1]))
bool supportsStencilFeedback = [mtlDev supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily5_v1];
#endif
#if MVK_TVOS
isStencilFormat(vkDesc.mtlPixelFormat)
bool supportsStencilFeedback = (mtlDev && !mtlDev); // Really just false...but silence warning on unused mtlDev otherwise
#endif
) {
// Vulkan forbids blits between chroma-subsampled formats.
// If we can't write the stencil reference from the shader, we can't blit stencil.
// Vulkan forbids blits between chroma-subsampled formats.
// If we can't write the stencil reference from the shader, we can't blit stencil.
if (chromaSubsamplingComponentBits > 0 || (isStencilFormat(vkDesc.mtlPixelFormat) && !supportsStencilFeedback)) {
mvkDisableFlags(vkProps.optimalTilingFeatures, (VK_FORMAT_FEATURE_BLIT_SRC_BIT | VK_FORMAT_FEATURE_BLIT_DST_BIT));
}

View File

@ -327,11 +327,15 @@ void MVKRenderSubpass::populateMTLRenderPassDescriptor(MTLRenderPassDescriptor*
mtlTexDesc.textureType = MTLTextureType2DMultisample;
mtlTexDesc.sampleCount = sampleCount;
}
if (mvkOSVersionIsAtLeast(10.0, 11.0, 14.0)) {
#if MVK_IOS
if ([_renderPass->getMTLDevice() supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v3]) {
mtlTexDesc.storageMode = MTLStorageModeMemoryless;
} else {
mtlTexDesc.storageMode = MTLStorageModePrivate;
}
#else
mtlTexDesc.storageMode = MTLStorageModePrivate;
#endif
mtlTexDesc.usage = MTLTextureUsageRenderTarget;
_mtlDummyTex = [_renderPass->getMTLDevice() newTextureWithDescriptor: mtlTexDesc]; // not retained
[_mtlDummyTex setPurgeableState: MTLPurgeableStateVolatile];

View File

@ -49,7 +49,7 @@ static bool mvkIsSupportedOnPlatform(VkExtensionProperties* pProperties) {
#define MVK_DISABLED_EXTENSION(EXT) \
if (pProperties == &kVkExtProps_##EXT) { return false; }
#define MVK_EXTENSION_MIN_OS(EXT, MAC, IOS) \
if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(IOS, MAC, 14.0); }
if (pProperties == &kVkExtProps_##EXT) { return mvkOSVersionIsAtLeast(MAC, IOS); }
#if MVK_MACOS
MVK_DISABLED_EXTENSION(MVK_IOS_SURFACE)