Only set MTLTextureUsagePixelFormatView on depth/stencil views...
...and only if the device supports stencil views.
This commit is contained in:
parent
1f33a311ae
commit
6947fdf57e
@ -168,6 +168,9 @@ public:
|
||||
/** Returns the Metal texture type of this image. */
|
||||
inline MTLTextureType getMTLTextureType() { return _mtlTextureType; }
|
||||
|
||||
/** Returns the Metal texture usage of this image. */
|
||||
MTLTextureUsage getMTLTextureUsage();
|
||||
|
||||
/**
|
||||
* Returns whether the Metal texel size is the same as the Vulkan texel size.
|
||||
*
|
||||
|
@ -327,6 +327,19 @@ VkResult MVKImage::useIOSurface(IOSurfaceRef ioSurface) {
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
MTLTextureUsage MVKImage::getMTLTextureUsage() {
|
||||
MTLTextureUsage usage = mvkMTLTextureUsageFromVkImageUsageFlags(_usage);
|
||||
// If this is a depth/stencil texture, and the device supports it, tell
|
||||
// Metal we may create texture views of this, too.
|
||||
if ((_mtlPixelFormat == MTLPixelFormatDepth32Float_Stencil8
|
||||
#if MVK_MACOS
|
||||
|| _mtlPixelFormat == MTLPixelFormatDepth24Unorm_Stencil8
|
||||
#endif
|
||||
) && _device->_pMetalFeatures->stencilViews)
|
||||
mvkEnableFlag(usage, MTLTextureUsagePixelFormatView);
|
||||
return usage;
|
||||
}
|
||||
|
||||
// Returns an autoreleased Metal texture descriptor constructed from the properties of this image.
|
||||
MTLTextureDescriptor* MVKImage::getMTLTextureDescriptor() {
|
||||
MTLTextureDescriptor* mtlTexDesc = [[MTLTextureDescriptor alloc] init];
|
||||
@ -338,7 +351,7 @@ MTLTextureDescriptor* MVKImage::getMTLTextureDescriptor() {
|
||||
mtlTexDesc.mipmapLevelCount = _mipLevels;
|
||||
mtlTexDesc.sampleCount = mvkSampleCountFromVkSampleCountFlagBits(_samples);
|
||||
mtlTexDesc.arrayLength = _arrayLayers;
|
||||
mtlTexDesc.usageMVK = mvkMTLTextureUsageFromVkImageUsageFlags(_usage);
|
||||
mtlTexDesc.usageMVK = getMTLTextureUsage();
|
||||
mtlTexDesc.storageModeMVK = getMTLStorageMode();
|
||||
mtlTexDesc.cpuCacheMode = getMTLCPUCacheMode();
|
||||
|
||||
|
@ -759,7 +759,7 @@ MVK_PUBLIC_SYMBOL MTLTextureUsage mvkMTLTextureUsageFromVkImageUsageFlags(VkImag
|
||||
}
|
||||
if ( mvkAreFlagsEnabled(vkImageUsageFlags, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ) {
|
||||
mvkEnableFlag(mtlUsage, MTLTextureUsageRenderTarget);
|
||||
mvkEnableFlag(mtlUsage, MTLTextureUsagePixelFormatView);
|
||||
mvkDisableFlag(mtlUsage, MTLTextureUsagePixelFormatView); // Clears bit. Do this last.
|
||||
}
|
||||
|
||||
return mtlUsage;
|
||||
|
Loading…
x
Reference in New Issue
Block a user