diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm index 6388772f..848aa94c 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm @@ -73,12 +73,14 @@ VkResult MVKCmdCopyImage::setContent(MVKCommandBuffer* cmdBuff, (pixFmts->getBytesPerBlock(_dstImage->getMTLPixelFormat(dstPlaneIndex)) != pixFmts->getBytesPerBlock(_srcImage->getMTLPixelFormat(srcPlaneIndex)))) { return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Cannot copy between incompatible formats, such as formats of different pixel sizes, or between images with different sample counts."); } - if ((_srcImage->getMTLTextureType() == MTLTextureType3D) != (_dstImage->getMTLTextureType() == MTLTextureType3D)) { - return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Metal does not support copying to or from slices of a 3D texture."); - } _vkImageCopies.push_back(vkIR); } + + // Validate + if ((_srcImage->getMTLTextureType() == MTLTextureType3D) != (_dstImage->getMTLTextureType() == MTLTextureType3D)) { + return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Metal does not support copying to or from slices of a 3D texture."); + } return VK_SUCCESS; } @@ -1096,15 +1098,12 @@ VkResult MVKCmdClearImage::setContent(MVKCommandBuffer* cmdBuff, // Add subresource ranges _subresourceRanges.clear(); // Clear for reuse _subresourceRanges.reserve(rangeCount); + bool isDS = isDepthStencilClear(); for (uint32_t rangeIdx = 0; rangeIdx < rangeCount; rangeIdx++) { auto& vkIR = pRanges[rangeIdx]; uint8_t planeIndex = MVKImage::getPlaneFromVkImageAspectFlags(vkIR.aspectMask); // Validate - bool isDS = isDepthStencilClear(); - if (_image->getImageType() == VK_IMAGE_TYPE_1D) { - return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClear%sImage(): Native 1D images cannot be cleared on this device. Consider enabling MVK_CONFIG_TEXTURE_1D_AS_2D.", (isDS ? "DepthStencil" : "Color")); - } MVKMTLFmtCaps mtlFmtCaps = cmdBuff->getPixelFormats()->getCapabilities(_image->getMTLPixelFormat(planeIndex)); if ((isDS && !mvkAreAllFlagsEnabled(mtlFmtCaps, kMVKMTLFmtCapsDSAtt)) || ( !isDS && !mvkAreAllFlagsEnabled(mtlFmtCaps, kMVKMTLFmtCapsColorAtt))) { @@ -1113,6 +1112,11 @@ VkResult MVKCmdClearImage::setContent(MVKCommandBuffer* cmdBuff, _subresourceRanges.push_back(vkIR); } + + // Validate + if (_image->getImageType() == VK_IMAGE_TYPE_1D) { + return reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClear%sImage(): Native 1D images cannot be cleared on this device. Consider enabling MVK_CONFIG_TEXTURE_1D_AS_2D.", (isDS ? "DepthStencil" : "Color")); + } return VK_SUCCESS; } diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm index f52cadfb..140c31b2 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDescriptor.mm @@ -192,7 +192,7 @@ void MVKDescriptorSetLayoutBinding::push(MVKCommandEncoder* cmdEncoder, uint8_t planeCount = (imageView) ? imageView->getPlaneCount() : 1; for (uint8_t planeIndex = 0; planeIndex < planeCount; planeIndex++) { tb.mtlTexture = imageView->getMTLTexture(planeIndex); - tb.swizzle = (_info.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ? imageView->getPackedSwizzle(0) : 0; + tb.swizzle = (_info.descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ? imageView->getPackedSwizzle() : 0; if (_info.descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) { id mtlTex = tb.mtlTexture; if (mtlTex.parentTexture) { mtlTex = mtlTex.parentTexture; } @@ -282,7 +282,7 @@ void MVKDescriptorSetLayoutBinding::push(MVKCommandEncoder* cmdEncoder, uint8_t planeCount = (imageView) ? imageView->getPlaneCount() : 1; for (uint8_t planeIndex = 0; planeIndex < planeCount; planeIndex++) { tb.mtlTexture = imageView->getMTLTexture(planeIndex); - tb.swizzle = (imageView) ? imageView->getPackedSwizzle(0) : 0; + tb.swizzle = (imageView) ? imageView->getPackedSwizzle() : 0; MVKSampler* sampler; if (_immutableSamplers.empty()) { sampler = (MVKSampler*)imageInfo.sampler; @@ -719,7 +719,7 @@ void MVKImageDescriptor::bind(MVKCommandEncoder* cmdEncoder, } tb.swizzle = ((descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE || descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) && - tb.mtlTexture) ? _mvkImageView->getPackedSwizzle(planeIndex) : 0; + tb.mtlTexture) ? _mvkImageView->getPackedSwizzle() : 0; if (descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE && tb.mtlTexture) { id mtlTex = tb.mtlTexture; if (mtlTex.parentTexture) { mtlTex = mtlTex.parentTexture; } diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm index 38c88709..21c53efb 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm @@ -2907,8 +2907,8 @@ void MVKDevice::enableFeatures(const VkDeviceCreateInfo* pCreateInfo) { pdScalarLayoutFeatures.pNext = &pdTexelBuffAlignFeatures; VkPhysicalDeviceSamplerYcbcrConversionFeatures pdSamplerYcbcrConversionFeatures; - pdScalarLayoutFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES; - pdScalarLayoutFeatures.pNext = &pdScalarLayoutFeatures; + pdSamplerYcbcrConversionFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES; + pdSamplerYcbcrConversionFeatures.pNext = &pdScalarLayoutFeatures; VkPhysicalDeviceHostQueryResetFeaturesEXT pdHostQryResetFeatures; pdHostQryResetFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.h b/MoltenVK/MoltenVK/GPUObjects/MVKImage.h index cd90b25e..dd0ea131 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.h @@ -332,8 +332,8 @@ protected: void initExternalMemory(VkExternalMemoryHandleTypeFlags handleTypes); void releaseIOSurface(); - std::vector> _memoryBindings; - std::vector> _planes; + MVKSmallVector, 3> _memoryBindings; + MVKSmallVector, 3> _planes; VkExtent3D _extent; uint32_t _mipLevels; uint32_t _arrayLayers; @@ -531,7 +531,7 @@ public: inline MTLPixelFormat getMTLPixelFormat(uint8_t planeIndex) { return _planes[planeIndex]->_mtlPixFmt; } /** Returns the packed component swizzle of this image view. */ - inline uint32_t getPackedSwizzle(uint8_t planeIndex) { return _planes[planeIndex]->_packedSwizzle; } + inline uint32_t getPackedSwizzle() { return _planes[0]->_packedSwizzle; } /** Returns the number of planes of this image view. */ inline uint8_t getPlaneCount() { return _planes.size(); } @@ -587,7 +587,7 @@ protected: void propagateDebugName() override; MVKImage* _image; - std::vector> _planes; + MVKSmallVector, 3> _planes; VkImageSubresourceRange _subresourceRange; VkImageUsageFlags _usage; std::mutex _lock; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm index d6ca3491..bd864c1a 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm @@ -359,8 +359,8 @@ void MVKImageMemoryBinding::propagateDebugName() { bool MVKImageMemoryBinding::needsHostReadSync(VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkMemoryBarrier* pMemoryBarrier) { - MVKPipelineBarrier& barrier = *(MVKPipelineBarrier*)pMemoryBarrier; #if MVK_MACOS + MVKPipelineBarrier& barrier = *(MVKPipelineBarrier*)pMemoryBarrier; return ((barrier.newLayout == VK_IMAGE_LAYOUT_GENERAL) && mvkIsAnyFlagEnabled(barrier.dstAccessMask, (VK_ACCESS_HOST_READ_BIT | VK_ACCESS_MEMORY_READ_BIT)) && isMemoryHostAccessible() && !isMemoryHostCoherent());