Skip to content

Commit eb32814

Browse files
committed
Handle D24S8 copy for maintenance8 rules as well.
1 parent 9baacf7 commit eb32814

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

MoltenVK/MoltenVK/Commands/MVKCmdTransfer.mm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
107107
if (aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) return MTLPixelFormatDepth32Float;
108108
if (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) return MTLPixelFormatStencil8;
109109
}
110+
#if MVK_MACOS
111+
if (format == MTLPixelFormatDepth24Unorm_Stencil8 && (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT))
112+
return MTLPixelFormatStencil8;
113+
#endif
110114
return format;
111115
}
112116

@@ -115,6 +119,7 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
115119
uint8_t srcPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags(region->srcSubresource.aspectMask);
116120
uint8_t dstPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags(region->dstSubresource.aspectMask);
117121

122+
// If the format is combined depth-stencil, use the format based on the aspect for the following checks.
118123
auto srcFormat = getDepthStencilAspectFormat(_srcImage->getMTLPixelFormat(srcPlaneIndex), region->srcSubresource.aspectMask);
119124
auto dstFormat = getDepthStencilAspectFormat(_dstImage->getMTLPixelFormat(dstPlaneIndex), region->dstSubresource.aspectMask);
120125

@@ -144,20 +149,20 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
144149

145150
MTLPixelFormat srcMTLPixFmt = _srcImage->getMTLPixelFormat(srcPlaneIndex);
146151
bool isSrcCompressed = _srcImage->getIsCompressed();
147-
bool isSrcCombinedDepthStencil = srcMTLPixFmt == MTLPixelFormatDepth32Float_Stencil8;
152+
bool isSrcCombinedDepthStencilAspect = getDepthStencilAspectFormat(srcMTLPixFmt, vkIC.srcSubresource.aspectMask) != srcMTLPixFmt;
148153
bool canReinterpretSrc = _srcImage->hasPixelFormatView(srcPlaneIndex);
149154

150155
MTLPixelFormat dstMTLPixFmt = _dstImage->getMTLPixelFormat(dstPlaneIndex);
151156
bool isDstCompressed = _dstImage->getIsCompressed();
152-
bool isDstCombinedDepthStencil = dstMTLPixFmt == MTLPixelFormatDepth32Float_Stencil8;
157+
bool isDstCombinedDepthStencilAspect = getDepthStencilAspectFormat(dstMTLPixFmt, vkIC.dstSubresource.aspectMask) != dstMTLPixFmt;
153158
bool canReinterpretDst = _dstImage->hasPixelFormatView(dstPlaneIndex);
154159

155160
bool isEitherCompressed = isSrcCompressed || isDstCompressed;
156-
bool isOneCombinedDepthStencil = isSrcCombinedDepthStencil != isDstCombinedDepthStencil;
161+
bool isOneCombinedDepthStencilAspect = isSrcCombinedDepthStencilAspect != isDstCombinedDepthStencilAspect;
157162
bool canReinterpret = canReinterpretSrc || canReinterpretDst;
158163

159164
// If source and destination can't be reinterpreted to matching formats use a temporary intermediary buffer
160-
bool useTempBuffer = (srcMTLPixFmt != dstMTLPixFmt) && (isEitherCompressed || isOneCombinedDepthStencil || !canReinterpret);
165+
bool useTempBuffer = (srcMTLPixFmt != dstMTLPixFmt) && (isEitherCompressed || isOneCombinedDepthStencilAspect || !canReinterpret);
161166

162167
if (useTempBuffer) {
163168
// Add copy from source image to temp buffer.

0 commit comments

Comments
 (0)