Merge pull request #717 from billhollings/master
Fixes to vkCmdBlitImage() & vkCmdClearImage().
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index 3239b8d..73d38a5 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -26,7 +26,8 @@
- Ensure Vulkan loader magic number is set every time before returning any dispatchable Vulkan handle.
- Fix crash when `VkDeviceCreateInfo` specifies queue families out of numerical order.
- Fix crash in `vkDestroyPipelineLayout()`.
-- `vkCmdClearImage()` set error if attempt made to clear 1D image.
+- `vkCmdBlitImage()` support format component swizzling.
+- `vkCmdClearImage()` set error if attempt made to clear 1D image, and fix validation of depth attachment formats.
- Remove error logging on `VK_TIMEOUT` of `VkSemaphore` and `VkFence`.
- Consolidate the various linkable objects into a `MVKLinkableMixin` template base class.
- Use `MVKVector` whenever possible in MoltenVK, especially within render loop.
diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.h b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.h
index a7b9486..49812c8 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.h
+++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.h
@@ -52,7 +52,8 @@
protected:
void setContent(VkImage srcImage, VkImageLayout srcImageLayout,
- VkImage dstImage, VkImageLayout dstImageLayout, MVKCommandUse commandUse);
+ VkImage dstImage, VkImageLayout dstImageLayout,
+ bool formatsMustMatch, MVKCommandUse commandUse);
void addImageCopyRegion(const VkImageCopy& region);
void addTempBufferImageCopyRegion(const VkImageCopy& region);
diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
index 103befb..df846e8 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
+++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm
@@ -41,7 +41,7 @@
const VkImageCopy* pRegions,
MVKCommandUse commandUse) {
- setContent(srcImage, srcImageLayout, dstImage, dstImageLayout, commandUse);
+ setContent(srcImage, srcImageLayout, dstImage, dstImageLayout, false, commandUse);
for (uint32_t i = 0; i < regionCount; i++) {
addImageCopyRegion(pRegions[i]);
@@ -56,11 +56,12 @@
}
}
-// Sets basic content for use by this class and subclasses
+// Sets common content for use by this class and subclasses
void MVKCmdCopyImage::setContent(VkImage srcImage,
VkImageLayout srcImageLayout,
VkImage dstImage,
VkImageLayout dstImageLayout,
+ bool formatsMustMatch,
MVKCommandUse commandUse) {
_srcImage = (MVKImage*)srcImage;
_srcLayout = srcImageLayout;
@@ -76,7 +77,9 @@
_isDstCompressed = _dstImage->getIsCompressed();
uint32_t dstBytesPerBlock = mvkMTLPixelFormatBytesPerBlock(_dstMTLPixFmt);
- _canCopyFormats = (srcBytesPerBlock == dstBytesPerBlock) && (_srcSampleCount == _dstSampleCount);
+ _canCopyFormats = formatsMustMatch
+ ? (_dstMTLPixFmt == _srcMTLPixFmt)
+ : ((dstBytesPerBlock == srcBytesPerBlock) && (_dstSampleCount == _srcSampleCount));
_useTempBuffer = (_srcMTLPixFmt != _dstMTLPixFmt) && (_isSrcCompressed || _isDstCompressed); // Different formats and at least one is compressed
_commandUse = commandUse;
@@ -214,7 +217,7 @@
VkFilter filter,
MVKCommandUse commandUse) {
- MVKCmdCopyImage::setContent(srcImage, srcImageLayout, dstImage, dstImageLayout, commandUse);
+ MVKCmdCopyImage::setContent(srcImage, srcImageLayout, dstImage, dstImageLayout, true, commandUse);
_mtlFilter = mvkMTLSamplerMinMagFilterFromVkFilter(filter);
@@ -1058,7 +1061,8 @@
if (_image->getImageType() == VK_IMAGE_TYPE_1D) {
setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClearImage(): 1D images cannot be cleared on this device."));
}
- if ( !_image->getSupportsAllFormatFeatures(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT) ) {
+ if ((_isDepthStencilClear && !_image->getSupportsAllFormatFeatures(VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)) ||
+ (!_isDepthStencilClear && !_image->getSupportsAllFormatFeatures(VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))) {
setConfigurationResult(reportError(VK_ERROR_FEATURE_NOT_PRESENT, "vkCmdClearImage(): Format %s cannot be cleared on this device.", mvkVkFormatName(_image->getVkFormat())));
}
}