Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK
This commit is contained in:
commit
5dac8dc645
@ -54,7 +54,7 @@ extern "C" {
|
||||
#define MVK_VERSION MVK_MAKE_VERSION(MVK_VERSION_MAJOR, MVK_VERSION_MINOR, MVK_VERSION_PATCH)
|
||||
|
||||
|
||||
#define VK_MVK_MOLTENVK_SPEC_VERSION 8
|
||||
#define VK_MVK_MOLTENVK_SPEC_VERSION 9
|
||||
#define VK_MVK_MOLTENVK_EXTENSION_NAME "VK_MVK_moltenvk"
|
||||
|
||||
/**
|
||||
@ -206,6 +206,7 @@ typedef struct {
|
||||
VkBool32 depthClipMode; /**< If true, depth clipping and depth clamping per the VkGraphicsPipelineCreateInfo::VkPipelineRasterizationStateCreateInfo::depthClampEnable flag is supported. */
|
||||
VkBool32 layeredRendering; /**< If true, layered rendering to multiple cube or texture array layers is supported. */
|
||||
VkBool32 presentModeImmediate; /**< If true, immediate surface present mode (VK_PRESENT_MODE_IMMEDIATE_KHR), allowing a swapchain image to be presented immediately, without waiting for the vertical sync period of the display, is supported. */
|
||||
VkBool32 stencilViews; /**< If true, stencil aspect views are supported through the MTLPixelFormatX24_Stencil8 and MTLPixelFormatX32_Stencil8 formats. */
|
||||
uint32_t maxTextureDimension; /**< The maximum size of each texture dimension (width, height, or depth). */
|
||||
uint32_t maxPerStageBufferCount; /**< The total number of per-stage Metal buffers available for shader uniform content and attributes. */
|
||||
uint32_t maxPerStageTextureCount; /**< The total number of per-stage Metal textures available for shader uniform content. */
|
||||
|
@ -423,6 +423,7 @@ void MVKPhysicalDevice::initMetalFeatures() {
|
||||
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v3] ) {
|
||||
_metalFeatures.mslVersion = SPIRVToMSLConverterOptions::makeMSLVersion(1, 2);
|
||||
_metalFeatures.shaderSpecialization = true;
|
||||
_metalFeatures.stencilViews = true;
|
||||
}
|
||||
if ( [_mtlDevice supportsFeatureSet: MTLFeatureSet_iOS_GPUFamily1_v4] ) {
|
||||
_metalFeatures.mslVersion = SPIRVToMSLConverterOptions::makeMSLVersion(2);
|
||||
@ -454,6 +455,7 @@ void MVKPhysicalDevice::initMetalFeatures() {
|
||||
_metalFeatures.mslVersion = SPIRVToMSLConverterOptions::makeMSLVersion(1, 2);
|
||||
_metalFeatures.dynamicMTLBuffers = true;
|
||||
_metalFeatures.shaderSpecialization = true;
|
||||
_metalFeatures.stencilViews = true;
|
||||
_metalFeatures.maxMTLBufferSize = (1 * GIBI);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
||||
@ -464,12 +477,12 @@ MVKImage::MVKImage(MVKDevice* device, const VkImageCreateInfo* pCreateInfo) : MV
|
||||
|
||||
_isDepthStencilAttachment = (mvkAreFlagsEnabled(pCreateInfo->usage, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ||
|
||||
mvkAreFlagsEnabled(mvkVkFormatProperties(pCreateInfo->format).optimalTilingFeatures, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT));
|
||||
_canSupportMTLTextureView = !_isDepthStencilAttachment;
|
||||
_canSupportMTLTextureView = !_isDepthStencilAttachment || _device->_pMetalFeatures->stencilViews;
|
||||
_hasExpectedTexelSize = (mvkMTLPixelFormatBytesPerBlock(_mtlPixelFormat) == mvkVkFormatBytesPerBlock(pCreateInfo->format));
|
||||
_isLinear = validateLinear(pCreateInfo);
|
||||
_usesTexelBuffer = false;
|
||||
|
||||
// Calc _byteCount after _mtlTexture & _byteAlignment
|
||||
// Calc _byteCount after _mtlTexture & _byteAlignment
|
||||
for (uint32_t mipLvl = 0; mipLvl < _mipLevels; mipLvl++) {
|
||||
_byteCount += getBytesPerLayer(mipLvl) * _extent.depth * _arrayLayers;
|
||||
}
|
||||
@ -718,6 +731,22 @@ MTLPixelFormat MVKImageView::getSwizzledMTLPixelFormat(VkFormat format, VkCompon
|
||||
}
|
||||
break;
|
||||
|
||||
case MTLPixelFormatDepth32Float_Stencil8:
|
||||
if (_subresourceRange.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT &&
|
||||
matchesSwizzle(components, {VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_MAX_ENUM, VK_COMPONENT_SWIZZLE_MAX_ENUM, VK_COMPONENT_SWIZZLE_MAX_ENUM} ) ) {
|
||||
return MTLPixelFormatX32_Stencil8;
|
||||
}
|
||||
break;
|
||||
|
||||
#if MVK_MACOS
|
||||
case MTLPixelFormatDepth24Unorm_Stencil8:
|
||||
if (_subresourceRange.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT &&
|
||||
matchesSwizzle(components, {VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_MAX_ENUM, VK_COMPONENT_SWIZZLE_MAX_ENUM, VK_COMPONENT_SWIZZLE_MAX_ENUM} ) ) {
|
||||
return MTLPixelFormatX24_Stencil8;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user