From 44c9aaa9571e6f9f580e562c01a00aefd1710a3e Mon Sep 17 00:00:00 2001 From: Chip Davis Date: Wed, 3 Oct 2018 00:28:01 -0500 Subject: [PATCH 1/2] vkCmdCopyImage: Allow copies between compatible formats. The docs for the `MTLBlitCommandEncoder`'s `copyFromTexture:...` method state that the source and destination textures must have the same format. This was true when it was written in the iOS 8 timeframe for Metal 1.0. But, I suspect it was changed in Metal 1.1 when support was added for texture views of differing formats. Like with texture views, the two formats now need only be compatible. This is the same behavior that Vulkan prescribes. --- MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm | 6 ------ 1 file changed, 6 deletions(-) diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm index e0d9f65e..c58baa3e 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm @@ -59,12 +59,6 @@ void MVKCmdCopyImage::setContent(VkImage srcImage, // Validate clearConfigurationResult(); - if (_srcImage->getMTLPixelFormat() != _dstImage->getMTLPixelFormat()) { - setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): The source and destination images must have the same format.")); - } - if ((_srcImage->getMTLTextureType() == MTLTextureType3D) || (_dstImage->getMTLTextureType() == MTLTextureType3D)) { - setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Metal does not support copying to or from slices of a 3D texture.")); - } } // Adds a Metal copy region structure for each layer in the specified copy region. From b8202e7b659a8d22204d3f8e8b096193244b2393 Mon Sep 17 00:00:00 2001 From: Chip Davis Date: Wed, 3 Oct 2018 11:24:49 -0500 Subject: [PATCH 2/2] Forbid copying between 3D texture and a 2D array texture. Metal doesn't support that yet. --- MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm index c58baa3e..723cfd01 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm @@ -59,6 +59,9 @@ void MVKCmdCopyImage::setContent(VkImage srcImage, // Validate clearConfigurationResult(); + if ((_srcImage->getMTLTextureType() == MTLTextureType3D) != (_dstImage->getMTLTextureType() == MTLTextureType3D)) { + setConfigurationResult(mvkNotifyErrorWithText(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdCopyImage(): Metal does not support copying to or from slices of a 3D texture.")); + } } // Adds a Metal copy region structure for each layer in the specified copy region.