Check for stencil only image view in identity swizzle case
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
index bc27fe7..790ae2c 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
@@ -1231,6 +1231,16 @@
// If we have an identity swizzle, we're all good.
if (SWIZZLE_MATCHES(R, G, B, A)) {
+ // Change to stencil-only format if only stencil aspect is requested
+ if (pCreateInfo->subresourceRange.aspectMask == VK_IMAGE_ASPECT_STENCIL_BIT) {
+ if (mtlPixFmt == MTLPixelFormatDepth32Float_Stencil8)
+ mtlPixFmt = MTLPixelFormatX32_Stencil8;
+#if MVK_MACOS
+ else if (mtlPixFmt == MTLPixelFormatDepth24Unorm_Stencil8)
+ mtlPixFmt = MTLPixelFormatX24_Stencil8;
+#endif
+ }
+
return VK_SUCCESS;
}