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,
VkFilter filter) {
MVKPixelFormats* pixFmts = cmdBuff->getPixelFormats();
_srcImage = (MVKImage*)srcImage;
_srcLayout = srcImageLayout;
_dstImage = (MVKImage*)dstImage;
@ -222,22 +220,26 @@ VkResult MVKCmdBlitImage<N>::setContent(MVKCommandBuffer* cmdBuff,
_filter = filter;
_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);
bool isDepthStencil = _dstImage->getIsDepthStencil();
bool isDestUnwritableLinear = MVK_MACOS && _dstImage->getIsLinear();
// 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) {
_vkImageBlits.clear(); // Clear for reuse
for (uint32_t rIdx = 0; rIdx < regionCount; rIdx++) {
auto& vkIB = pRegions[rIdx];
// 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;

View File

@ -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.