From 67f659c06411467c3dd44c62388805f7edbc9a2a Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Tue, 5 Jun 2018 17:24:05 -0400 Subject: [PATCH] Fix copying 4-byte 32-bit depth/stencil formats between buffers and textures. --- MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm index d80afbe4..6b0fe1cd 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm @@ -658,9 +658,12 @@ void MVKCmdBufferImageCopy::encode(MVKCommandEncoder* cmdEncoder) { bool wantStencil = mvkAreFlagsEnabled(imgFlags, VK_IMAGE_ASPECT_STENCIL_BIT); // The stencil component is always 1 byte per pixel. + // Don't reduce depths of 32-bit depth/stencil formats. if (wantDepth && !wantStencil) { - bytesPerRow -= buffImgWd; - bytesPerImg -= buffImgWd * buffImgHt; + if (mvkMTLPixelFormatBytesPerTexel(mtlPixFmt) != 4) { + bytesPerRow -= buffImgWd; + bytesPerImg -= buffImgWd * buffImgHt; + } blitOptions |= MTLBlitOptionDepthFromDepthStencil; } else if (wantStencil && !wantDepth) { bytesPerRow = buffImgWd;