@@ -107,6 +107,10 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
107
107
if (aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) return MTLPixelFormatDepth32Float ;
108
108
if (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) return MTLPixelFormatStencil8 ;
109
109
}
110
+ #if MVK_MACOS
111
+ if (format == MTLPixelFormatDepth24Unorm_Stencil8 && (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT))
112
+ return MTLPixelFormatStencil8 ;
113
+ #endif
110
114
return format;
111
115
}
112
116
@@ -115,6 +119,7 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
115
119
uint8_t srcPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags (region->srcSubresource .aspectMask );
116
120
uint8_t dstPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags (region->dstSubresource .aspectMask );
117
121
122
+ // If the format is combined depth-stencil, use the format based on the aspect for the following checks.
118
123
auto srcFormat = getDepthStencilAspectFormat (_srcImage->getMTLPixelFormat (srcPlaneIndex), region->srcSubresource .aspectMask );
119
124
auto dstFormat = getDepthStencilAspectFormat (_dstImage->getMTLPixelFormat (dstPlaneIndex), region->dstSubresource .aspectMask );
120
125
@@ -144,20 +149,20 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
144
149
145
150
MTLPixelFormat srcMTLPixFmt = _srcImage->getMTLPixelFormat (srcPlaneIndex);
146
151
bool isSrcCompressed = _srcImage->getIsCompressed ();
147
- bool isSrcCombinedDepthStencil = srcMTLPixFmt == MTLPixelFormatDepth32Float_Stencil8 ;
152
+ bool isSrcCombinedDepthStencilAspect = getDepthStencilAspectFormat ( srcMTLPixFmt, vkIC. srcSubresource . aspectMask ) != srcMTLPixFmt ;
148
153
bool canReinterpretSrc = _srcImage->hasPixelFormatView (srcPlaneIndex);
149
154
150
155
MTLPixelFormat dstMTLPixFmt = _dstImage->getMTLPixelFormat (dstPlaneIndex);
151
156
bool isDstCompressed = _dstImage->getIsCompressed ();
152
- bool isDstCombinedDepthStencil = dstMTLPixFmt == MTLPixelFormatDepth32Float_Stencil8 ;
157
+ bool isDstCombinedDepthStencilAspect = getDepthStencilAspectFormat ( dstMTLPixFmt, vkIC. dstSubresource . aspectMask ) != dstMTLPixFmt ;
153
158
bool canReinterpretDst = _dstImage->hasPixelFormatView (dstPlaneIndex);
154
159
155
160
bool isEitherCompressed = isSrcCompressed || isDstCompressed;
156
- bool isOneCombinedDepthStencil = isSrcCombinedDepthStencil != isDstCombinedDepthStencil ;
161
+ bool isOneCombinedDepthStencilAspect = isSrcCombinedDepthStencilAspect != isDstCombinedDepthStencilAspect ;
157
162
bool canReinterpret = canReinterpretSrc || canReinterpretDst;
158
163
159
164
// 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);
161
166
162
167
if (useTempBuffer) {
163
168
// Add copy from source image to temp buffer.
0 commit comments