diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm index cd781c61..6299de78 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm @@ -213,8 +213,6 @@ VkResult MVKCmdBlitImage::setContent(MVKCommandBuffer* cmdBuff, const VkImageBlit* pRegions, VkFilter filter) { - MVKPixelFormats* pixFmts = cmdBuff->getPixelFormats(); - _srcImage = (MVKImage*)srcImage; _srcLayout = srcImageLayout; _dstImage = (MVKImage*)dstImage; @@ -222,22 +220,26 @@ VkResult MVKCmdBlitImage::setContent(MVKCommandBuffer* cmdBuff, _filter = filter; + bool isDepthStencil = _dstImage->getIsDepthStencil(); + bool isDestUnwritableLinear = MVK_MACOS && _dstImage->getIsLinear(); + _vkImageBlits.clear(); // Clear for reuse - for (uint32_t regionIdx = 0; regionIdx < regionCount; regionIdx++) { - auto& vkIR = pRegions[regionIdx]; - uint8_t srcPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags(vkIR.srcSubresource.aspectMask); + for (uint32_t rIdx = 0; rIdx < regionCount; rIdx++) { + auto& vkIB = pRegions[rIdx]; - // Validate - depth stencil formats cannot be scaled or inverted - MTLPixelFormat srcMTLPixFmt = _srcImage->getMTLPixelFormat(srcPlaneIndex); - if (pixFmts->isDepthFormat(srcMTLPixFmt) || pixFmts->isStencilFormat(srcMTLPixFmt)) { - for (auto& vkIB : _vkImageBlits) { - if ( !(canCopyFormats(vkIB) && canCopy(vkIB)) ) { - return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdBlitImage(): Scaling or inverting depth/stencil images is not supported."); - } - } - } + // Validate - depth stencil formats and macOS linear images cannot be a scaling or inversion destination + if (isDepthStencil || isDestUnwritableLinear) { + if ( !(canCopyFormats(vkIB) && canCopy(vkIB)) ) { + if (isDepthStencil) { + return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdBlitImage(): Scaling or inverting depth/stencil images is not supported."); + } + if (isDestUnwritableLinear) { + return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdBlitImage(): Scaling or inverting to a linear destination image is not supported."); + } + } + } - _vkImageBlits.push_back(vkIR); + _vkImageBlits.push_back(vkIB); } return VK_SUCCESS; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.h b/MoltenVK/MoltenVK/GPUObjects/MVKImage.h index c66efc41..90d1c765 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.h @@ -182,6 +182,9 @@ public: /** Returns whether this image is compressed. */ bool getIsCompressed(); + /** Returns whether this image has a linear memory layout. */ + bool getIsLinear() { return _isLinear; } + /** * Returns the 3D extent of this image at the base mipmap level. * For 2D or cube images, the Z component will be 1.