Log format substitution error when MTLPixelFormatDepth24Unorm_Stencil8 is not supported.
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index e30ba45..db86868 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -37,6 +37,7 @@
- Allow `MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS` build setting to be overridden.
- Fix memory leaks of system classes during `VkInstance` and `VkQueue` creation.
- Fix memory leaks when compiling shaders and pipelines without default OS autorelease pool.
+- Log format substitution error when `MTLPixelFormatDepth24Unorm_Stencil8` is not supported.
- Reduce memory usage by adjusting default memory allocs for many `MVKVectorInline` uses and
replacing use of `MVKVectorDefault` with `std::vector` in descriptor set bindings.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
index 8c71c0e..b116ae6 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKDevice.mm
@@ -211,8 +211,6 @@
switch (mvkMTLPixelFormatFromVkFormat(format)) {
case MTLPixelFormatDepth24Unorm_Stencil8:
return getMTLDevice().isDepth24Stencil8PixelFormatSupported;
- break;
-
default:
break;
}
@@ -2512,7 +2510,7 @@
#if MVK_MACOS
if (mtlPixFmt == MTLPixelFormatDepth24Unorm_Stencil8 &&
!getMTLDevice().isDepth24Stencil8PixelFormatSupported) {
- return MTLPixelFormatDepth32Float_Stencil8;
+ return mvkMTLPixelFormatFromVkFormatInObj(vkFormat, mvkObj, MTLPixelFormatDepth24Unorm_Stencil8);
}
#endif
return mtlPixFmt;
diff --git a/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.hpp b/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.hpp
index 62eeae7..617db53 100644
--- a/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.hpp
+++ b/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.hpp
@@ -47,7 +47,9 @@
* of an MVKBaseObject subclass, which is true for all but static calling functions.
*/
-MTLPixelFormat mvkMTLPixelFormatFromVkFormatInObj(VkFormat vkFormat, MVKBaseObject* mvkObj);
+MTLPixelFormat mvkMTLPixelFormatFromVkFormatInObj(VkFormat vkFormat,
+ MVKBaseObject* mvkObj,
+ MTLPixelFormat mtlPixelFormatKnownUnsupported = MTLPixelFormatInvalid);
#define mvkMTLPixelFormatFromVkFormat(vkFormat) mvkMTLPixelFormatFromVkFormatInObj(vkFormat, this)
MTLVertexFormat mvkMTLVertexFormatFromVkFormatInObj(VkFormat vkFormat, MVKBaseObject* mvkObj);
diff --git a/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm b/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
index 950ffb5..a24700f 100644
--- a/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
+++ b/MoltenVK/MoltenVK/Vulkan/mvk_datatypes.mm
@@ -569,11 +569,13 @@
return mvkMTLPixelFormatFromVkFormatInObj(vkFormat, nullptr);
}
-MTLPixelFormat mvkMTLPixelFormatFromVkFormatInObj(VkFormat vkFormat, MVKBaseObject* mvkObj) {
+MTLPixelFormat mvkMTLPixelFormatFromVkFormatInObj(VkFormat vkFormat,
+ MVKBaseObject* mvkObj,
+ MTLPixelFormat mtlPixelFormatKnownUnsupported) {
MTLPixelFormat mtlPixFmt = MTLPixelFormatInvalid;
const MVKFormatDesc& fmtDesc = formatDescForVkFormat(vkFormat);
- if (fmtDesc.isSupported()) {
+ if (fmtDesc.isSupported() && (fmtDesc.mtl != mtlPixelFormatKnownUnsupported)) {
mtlPixFmt = fmtDesc.mtl;
} else if (vkFormat != VK_FORMAT_UNDEFINED) {
// If the MTLPixelFormat is not supported but VkFormat is valid, attempt to substitute a different format.