vkCmdBlitImage() return error if scaling or inverting to linear image on macOS.

This commit is contained in:
Bill Hollings 2020-07-27 16:00:42 -04:00
parent f7a1c87c71
commit 23ea3c9bf7
2 changed files with 20 additions and 15 deletions

View File

@ -213,8 +213,6 @@ VkResult MVKCmdBlitImage<N>::setContent(MVKCommandBuffer* cmdBuff,
const VkImageBlit* pRegions, const VkImageBlit* pRegions,
VkFilter filter) { VkFilter filter) {
MVKPixelFormats* pixFmts = cmdBuff->getPixelFormats();
_srcImage = (MVKImage*)srcImage; _srcImage = (MVKImage*)srcImage;
_srcLayout = srcImageLayout; _srcLayout = srcImageLayout;
_dstImage = (MVKImage*)dstImage; _dstImage = (MVKImage*)dstImage;
@ -222,22 +220,26 @@ VkResult MVKCmdBlitImage<N>::setContent(MVKCommandBuffer* cmdBuff,
_filter = filter; _filter = filter;
bool isDepthStencil = _dstImage->getIsDepthStencil();
bool isDestUnwritableLinear = MVK_MACOS && _dstImage->getIsLinear();
_vkImageBlits.clear(); // Clear for reuse _vkImageBlits.clear(); // Clear for reuse
for (uint32_t regionIdx = 0; regionIdx < regionCount; regionIdx++) { for (uint32_t rIdx = 0; rIdx < regionCount; rIdx++) {
auto& vkIR = pRegions[regionIdx]; auto& vkIB = pRegions[rIdx];
uint8_t srcPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags(vkIR.srcSubresource.aspectMask);
// Validate - depth stencil formats cannot be scaled or inverted // Validate - depth stencil formats and macOS linear images cannot be a scaling or inversion destination
MTLPixelFormat srcMTLPixFmt = _srcImage->getMTLPixelFormat(srcPlaneIndex); if (isDepthStencil || isDestUnwritableLinear) {
if (pixFmts->isDepthFormat(srcMTLPixFmt) || pixFmts->isStencilFormat(srcMTLPixFmt)) { if ( !(canCopyFormats(vkIB) && canCopy(vkIB)) ) {
for (auto& vkIB : _vkImageBlits) { if (isDepthStencil) {
if ( !(canCopyFormats(vkIB) && canCopy(vkIB)) ) { return cmdBuff->reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdBlitImage(): Scaling or inverting depth/stencil images is not supported.");
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; return VK_SUCCESS;

View File

@ -182,6 +182,9 @@ public:
/** Returns whether this image is compressed. */ /** Returns whether this image is compressed. */
bool getIsCompressed(); 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. * Returns the 3D extent of this image at the base mipmap level.
* For 2D or cube images, the Z component will be 1. * For 2D or cube images, the Z component will be 1.