@@ -103,10 +103,12 @@ static inline MTLSize mvkClampMTLSize(MTLSize size, MTLOrigin origin, MTLSize ma
103
103
}
104
104
105
105
static inline MTLPixelFormat getDepthStencilAspectFormat (const MTLPixelFormat format, const VkImageAspectFlags aspectMask) {
106
- if (format == MTLPixelFormatDepth32Float_Stencil8 ) {
107
- if (aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT) return MTLPixelFormatDepth32Float ;
108
- if (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) return MTLPixelFormatStencil8 ;
109
- }
106
+ if (format == MTLPixelFormatDepth32Float_Stencil8 &&
107
+ (aspectMask & VK_IMAGE_ASPECT_DEPTH_BIT))
108
+ return MTLPixelFormatDepth32Float ;
109
+ if ((format == MTLPixelFormatDepth32Float_Stencil8 || format == MTLPixelFormatDepth24Unorm_Stencil8 ) &&
110
+ (aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT))
111
+ return MTLPixelFormatStencil8 ;
110
112
return format;
111
113
}
112
114
@@ -115,6 +117,7 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
115
117
uint8_t srcPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags (region->srcSubresource .aspectMask );
116
118
uint8_t dstPlaneIndex = MVKImage::getPlaneFromVkImageAspectFlags (region->dstSubresource .aspectMask );
117
119
120
+ // If the format is combined depth-stencil, use the format based on the aspect for the following checks.
118
121
auto srcFormat = getDepthStencilAspectFormat (_srcImage->getMTLPixelFormat (srcPlaneIndex), region->srcSubresource .aspectMask );
119
122
auto dstFormat = getDepthStencilAspectFormat (_dstImage->getMTLPixelFormat (dstPlaneIndex), region->dstSubresource .aspectMask );
120
123
@@ -144,20 +147,20 @@ static inline MTLPixelFormat getDepthStencilAspectFormat(const MTLPixelFormat fo
144
147
145
148
MTLPixelFormat srcMTLPixFmt = _srcImage->getMTLPixelFormat (srcPlaneIndex);
146
149
bool isSrcCompressed = _srcImage->getIsCompressed ();
147
- bool isSrcCombinedDepthStencil = srcMTLPixFmt == MTLPixelFormatDepth32Float_Stencil8 ;
150
+ bool isSrcCombinedDepthStencilAspect = getDepthStencilAspectFormat ( srcMTLPixFmt, vkIC. srcSubresource . aspectMask ) != srcMTLPixFmt ;
148
151
bool canReinterpretSrc = _srcImage->hasPixelFormatView (srcPlaneIndex);
149
152
150
153
MTLPixelFormat dstMTLPixFmt = _dstImage->getMTLPixelFormat (dstPlaneIndex);
151
154
bool isDstCompressed = _dstImage->getIsCompressed ();
152
- bool isDstCombinedDepthStencil = dstMTLPixFmt == MTLPixelFormatDepth32Float_Stencil8 ;
155
+ bool isDstCombinedDepthStencilAspect = getDepthStencilAspectFormat ( dstMTLPixFmt, vkIC. dstSubresource . aspectMask ) != dstMTLPixFmt ;
153
156
bool canReinterpretDst = _dstImage->hasPixelFormatView (dstPlaneIndex);
154
157
155
158
bool isEitherCompressed = isSrcCompressed || isDstCompressed;
156
- bool isOneCombinedDepthStencil = isSrcCombinedDepthStencil != isDstCombinedDepthStencil ;
159
+ bool isOneCombinedDepthStencilAspect = isSrcCombinedDepthStencilAspect != isDstCombinedDepthStencilAspect ;
157
160
bool canReinterpret = canReinterpretSrc || canReinterpretDst;
158
161
159
162
// If source and destination can't be reinterpreted to matching formats use a temporary intermediary buffer
160
- bool useTempBuffer = (srcMTLPixFmt != dstMTLPixFmt) && (isEitherCompressed || isOneCombinedDepthStencil || !canReinterpret);
163
+ bool useTempBuffer = (srcMTLPixFmt != dstMTLPixFmt) && (isEitherCompressed || isOneCombinedDepthStencilAspect || !canReinterpret);
161
164
162
165
if (useTempBuffer) {
163
166
// Add copy from source image to temp buffer.
0 commit comments