Merge pull request #1067 from billhollings/setmtltex
vkSetMTLTextureMVK() Fix crash if incoming MTLTexture does not have an IOSurface.
diff --git a/Docs/Whats_New.md b/Docs/Whats_New.md
index 001246a..e3b5c03 100644
--- a/Docs/Whats_New.md
+++ b/Docs/Whats_New.md
@@ -56,6 +56,7 @@
frameworks into a single `MoltenVKShaderConverter` framework.
- Fix Metal validation error when occlusion query and renderpass are in separate
Vulkan command buffers.
+- `vkSetMTLTextureMVK()` Fix crash if incoming `MTLTexture` does not have an associated `IOSurface`.
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
index 7db5dfd..eda24a3 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
@@ -698,7 +698,7 @@
if (_device->_pMetalFeatures->ioSurfaces) {
_ioSurface = mtlTexture.iosurface;
- CFRetain(_ioSurface);
+ if (_ioSurface) { CFRetain(_ioSurface); }
}
return VK_SUCCESS;