Add MVK_APPLE_SILICON macro definition.
Use MVK_APPLE_SILICON instead of MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON or MVK_MACOS_APPLE_SILICON || MVK_IOS_OR_TVOS.
This commit is contained in:
parent
4a65c293c6
commit
e1b3585413
@ -82,6 +82,11 @@ extern "C" {
|
||||
# define MVK_MACOS_APPLE_SILICON (__MAC_OS_X_VERSION_MAX_ALLOWED >= 101600)
|
||||
#endif
|
||||
|
||||
/** Building for Apple Silicon. */
|
||||
#ifndef MVK_APPLE_SILICON
|
||||
# define MVK_APPLE_SILICON (MVK_IOS || MVK_TVOS || MVK_MACOS_APPLE_SILICON)
|
||||
#endif
|
||||
|
||||
/** Building with Xcode 12. */
|
||||
#ifndef MVK_XCODE_12
|
||||
# define MVK_XCODE_12 (MVK_MACOS_APPLE_SILICON || \
|
||||
|
@ -948,7 +948,7 @@ void MVKCmdBufferImageCopy<N>::encode(MVKCommandEncoder* cmdEncoder) {
|
||||
}
|
||||
}
|
||||
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
if (pixFmts->isPVRTCFormat(mtlPixFmt)) {
|
||||
blitOptions |= MTLBlitOptionRowLinearPVRTC;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ VkResult MVKBuffer::getMemoryRequirements(VkMemoryRequirements* pMemoryRequireme
|
||||
pMemoryRequirements->alignment = _byteAlignment;
|
||||
}
|
||||
pMemoryRequirements->memoryTypeBits = _device->getPhysicalDevice()->getAllMemoryTypes();
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
// Memoryless storage is not allowed for buffers
|
||||
mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getLazilyAllocatedMemoryTypes());
|
||||
#endif
|
||||
|
@ -657,7 +657,7 @@ VkResult MVKPhysicalDevice::getImageFormatProperties(VkFormat format,
|
||||
return VK_ERROR_FORMAT_NOT_SUPPORTED;
|
||||
}
|
||||
#endif
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
// ETC2 and EAC formats aren't supported for 3D textures.
|
||||
switch (format) {
|
||||
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
|
||||
@ -2998,7 +2998,7 @@ uint32_t MVKDevice::getVulkanMemoryTypeIndex(MTLStorageMode mtlStorageMode) {
|
||||
vkMemFlags = MVK_VK_MEMORY_TYPE_METAL_MANAGED;
|
||||
break;
|
||||
#endif
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
case MTLStorageModeMemoryless:
|
||||
vkMemFlags = MVK_VK_MEMORY_TYPE_METAL_MEMORYLESS;
|
||||
break;
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
|
||||
/** Returns whether the memory is accessible from the host. */
|
||||
inline bool isMemoryHostAccessible() {
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
if (_mtlStorageMode == MTLStorageModeMemoryless)
|
||||
return false;
|
||||
#endif
|
||||
|
@ -647,7 +647,7 @@ VkResult MVKImage::getMemoryRequirements(VkMemoryRequirements* pMemoryRequiremen
|
||||
mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getHostCoherentMemoryTypes());
|
||||
}
|
||||
#endif
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
// Only transient attachments may use memoryless storage
|
||||
if (!mvkAreAllFlagsEnabled(_usage, VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) ) {
|
||||
mvkDisableFlags(pMemoryRequirements->memoryTypeBits, _device->getPhysicalDevice()->getLazilyAllocatedMemoryTypes());
|
||||
@ -1668,7 +1668,7 @@ VkResult MVKImageView::validateSwizzledMTLPixelFormat(const VkImageViewCreateInf
|
||||
|
||||
switch (mtlPixFmt) {
|
||||
case MTLPixelFormatR8Unorm:
|
||||
#if MVK_MACOS_APPLE_SILICON || MVK_IOS_OR_TVOS
|
||||
#if MVK_APPLE_SILICON
|
||||
case MTLPixelFormatR8Unorm_sRGB:
|
||||
#endif
|
||||
case MTLPixelFormatR8Snorm:
|
||||
@ -1688,7 +1688,7 @@ VkResult MVKImageView::validateSwizzledMTLPixelFormat(const VkImageViewCreateInf
|
||||
break;
|
||||
|
||||
case MTLPixelFormatRG8Unorm:
|
||||
#if MVK_MACOS_APPLE_SILICON || MVK_IOS_OR_TVOS
|
||||
#if MVK_APPLE_SILICON
|
||||
case MTLPixelFormatRG8Unorm_sRGB:
|
||||
#endif
|
||||
case MTLPixelFormatRG8Snorm:
|
||||
|
@ -193,7 +193,7 @@ bool MVKPixelFormats::isStencilFormat(MTLPixelFormat mtlFormat) {
|
||||
|
||||
bool MVKPixelFormats::isPVRTCFormat(MTLPixelFormat mtlFormat) {
|
||||
switch (mtlFormat) {
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
case MTLPixelFormatPVRTC_RGBA_2BPP:
|
||||
case MTLPixelFormatPVRTC_RGBA_2BPP_sRGB:
|
||||
case MTLPixelFormatPVRTC_RGBA_4BPP:
|
||||
|
@ -211,7 +211,7 @@ void MVKRenderSubpass::populateMTLRenderPassDescriptor(MTLRenderPassDescriptor*
|
||||
MVKRenderPassAttachment* clrMVKRPAtt = &_renderPass->_attachments[clrRPAttIdx];
|
||||
framebuffer->getAttachment(clrRPAttIdx)->populateMTLRenderPassAttachmentDescriptor(mtlColorAttDesc);
|
||||
bool isMemorylessAttachment = false;
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
isMemorylessAttachment = framebuffer->getAttachment(clrRPAttIdx)->getMTLTexture(0).storageMode == MTLStorageModeMemoryless;
|
||||
#endif
|
||||
if (clrMVKRPAtt->populateMTLRenderPassAttachmentDescriptor(mtlColorAttDesc, this,
|
||||
@ -256,7 +256,7 @@ void MVKRenderSubpass::populateMTLRenderPassDescriptor(MTLRenderPassDescriptor*
|
||||
}
|
||||
dsImage->populateMTLRenderPassAttachmentDescriptor(mtlDepthAttDesc);
|
||||
bool isMemorylessAttachment = false;
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
isMemorylessAttachment = dsImage->getMTLTexture(0).storageMode == MTLStorageModeMemoryless;
|
||||
#endif
|
||||
if (dsMVKRPAtt->populateMTLRenderPassAttachmentDescriptor(mtlDepthAttDesc, this,
|
||||
@ -284,7 +284,7 @@ void MVKRenderSubpass::populateMTLRenderPassDescriptor(MTLRenderPassDescriptor*
|
||||
}
|
||||
dsImage->populateMTLRenderPassAttachmentDescriptor(mtlStencilAttDesc);
|
||||
bool isMemorylessAttachment = false;
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
isMemorylessAttachment = dsImage->getMTLTexture(0).storageMode == MTLStorageModeMemoryless;
|
||||
#endif
|
||||
if (dsMVKRPAtt->populateMTLRenderPassAttachmentDescriptor(mtlStencilAttDesc, this,
|
||||
@ -376,7 +376,7 @@ void MVKRenderSubpass::encodeStoreActions(MVKCommandEncoder* cmdEncoder,
|
||||
if (clrRPAttIdx != VK_ATTACHMENT_UNUSED) {
|
||||
bool hasResolveAttachment = _resolveAttachments.empty() ? false : _resolveAttachments[caIdx].attachment != VK_ATTACHMENT_UNUSED;
|
||||
bool isMemorylessAttachment = false;
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
isMemorylessAttachment = cmdEncoder->_framebuffer->getAttachment(clrRPAttIdx)->getMTLTexture(0).storageMode == MTLStorageModeMemoryless;
|
||||
#endif
|
||||
_renderPass->_attachments[clrRPAttIdx].encodeStoreAction(cmdEncoder, this, isRenderingEntireAttachment, isMemorylessAttachment, hasResolveAttachment, caIdx, false, storeOverride);
|
||||
@ -388,7 +388,7 @@ void MVKRenderSubpass::encodeStoreActions(MVKCommandEncoder* cmdEncoder,
|
||||
bool hasDepthResolveAttachment = hasResolveAttachment && _depthResolveMode != VK_RESOLVE_MODE_NONE;
|
||||
bool hasStencilResolveAttachment = hasResolveAttachment && _stencilResolveMode != VK_RESOLVE_MODE_NONE;
|
||||
bool isMemorylessAttachment = false;
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
isMemorylessAttachment = cmdEncoder->_framebuffer->getAttachment(dsRPAttIdx)->getMTLTexture(0).storageMode == MTLStorageModeMemoryless;
|
||||
#endif
|
||||
_renderPass->_attachments[dsRPAttIdx].encodeStoreAction(cmdEncoder, this, isRenderingEntireAttachment, isMemorylessAttachment, hasDepthResolveAttachment, 0, false, storeOverride);
|
||||
@ -783,7 +783,7 @@ MVKRenderPassAttachment::MVKRenderPassAttachment(MVKRenderPass* renderPass,
|
||||
#pragma mark MVKRenderPass
|
||||
|
||||
VkExtent2D MVKRenderPass::getRenderAreaGranularity() {
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
if (_device->_pMetalFeatures->tileBasedDeferredRendering) {
|
||||
// This is the tile area.
|
||||
// FIXME: We really ought to use MTLRenderCommandEncoder.tile{Width,Height}, but that requires
|
||||
|
@ -736,7 +736,7 @@ MVK_PUBLIC_SYMBOL MTLStorageMode mvkMTLStorageModeFromVkMemoryPropertyFlags(VkMe
|
||||
|
||||
// If not visible to the host: Private
|
||||
if ( !mvkAreAllFlagsEnabled(vkFlags, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) ) {
|
||||
#if MVK_IOS_OR_TVOS || MVK_MACOS_APPLE_SILICON
|
||||
#if MVK_APPLE_SILICON
|
||||
// iOS: If lazily allocated, Memoryless
|
||||
if (mvkAreAllFlagsEnabled(vkFlags, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT)) {
|
||||
return MTLStorageModeMemoryless;
|
||||
|
Loading…
x
Reference in New Issue
Block a user