vulkan_metal.h: Make compatible with ObjC ARC Fixes #6598 (cherry picked from commit 239423e205496997a387b4f265b1cdaf5acd18cb)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
diff --git a/src/video/khronos/vulkan/vulkan_metal.h b/src/video/khronos/vulkan/vulkan_metal.h
index 11b9640..898d3f2 100644
--- a/src/video/khronos/vulkan/vulkan_metal.h
+++ b/src/video/khronos/vulkan/vulkan_metal.h
@@ -26,6 +26,14 @@ extern "C" {
typedef void CAMetalLayer;
#endif
+#define SDL_UNSAFE_UNRETAINED
+#if defined(__OBJC__) && defined(__has_feature)
+#if __has_feature(objc_arc)
+#undef SDL_UNSAFE_UNRETAINED
+#define SDL_UNSAFE_UNRETAINED __unsafe_unretained
+#endif
+#endif
+
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
@@ -33,7 +41,7 @@ typedef struct VkMetalSurfaceCreateInfoEXT {
VkStructureType sType;
const void* pNext;
VkMetalSurfaceCreateFlagsEXT flags;
- const CAMetalLayer* pLayer;
+ const CAMetalLayer SDL_UNSAFE_UNRETAINED *pLayer;
} VkMetalSurfaceCreateInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
@@ -111,27 +119,27 @@ typedef struct VkExportMetalObjectsInfoEXT {
typedef struct VkExportMetalDeviceInfoEXT {
VkStructureType sType;
const void* pNext;
- MTLDevice_id mtlDevice;
+ MTLDevice_id SDL_UNSAFE_UNRETAINED mtlDevice;
} VkExportMetalDeviceInfoEXT;
typedef struct VkExportMetalCommandQueueInfoEXT {
VkStructureType sType;
const void* pNext;
VkQueue queue;
- MTLCommandQueue_id mtlCommandQueue;
+ MTLCommandQueue_id SDL_UNSAFE_UNRETAINED mtlCommandQueue;
} VkExportMetalCommandQueueInfoEXT;
typedef struct VkExportMetalBufferInfoEXT {
VkStructureType sType;
const void* pNext;
VkDeviceMemory memory;
- MTLBuffer_id mtlBuffer;
+ MTLBuffer_id SDL_UNSAFE_UNRETAINED mtlBuffer;
} VkExportMetalBufferInfoEXT;
typedef struct VkImportMetalBufferInfoEXT {
VkStructureType sType;
const void* pNext;
- MTLBuffer_id mtlBuffer;
+ MTLBuffer_id SDL_UNSAFE_UNRETAINED mtlBuffer;
} VkImportMetalBufferInfoEXT;
typedef struct VkExportMetalTextureInfoEXT {
@@ -141,14 +149,14 @@ typedef struct VkExportMetalTextureInfoEXT {
VkImageView imageView;
VkBufferView bufferView;
VkImageAspectFlagBits plane;
- MTLTexture_id mtlTexture;
+ MTLTexture_id SDL_UNSAFE_UNRETAINED mtlTexture;
} VkExportMetalTextureInfoEXT;
typedef struct VkImportMetalTextureInfoEXT {
VkStructureType sType;
const void* pNext;
VkImageAspectFlagBits plane;
- MTLTexture_id mtlTexture;
+ MTLTexture_id SDL_UNSAFE_UNRETAINED mtlTexture;
} VkImportMetalTextureInfoEXT;
typedef struct VkExportMetalIOSurfaceInfoEXT {
@@ -169,13 +177,13 @@ typedef struct VkExportMetalSharedEventInfoEXT {
const void* pNext;
VkSemaphore semaphore;
VkEvent event;
- MTLSharedEvent_id mtlSharedEvent;
+ MTLSharedEvent_id SDL_UNSAFE_UNRETAINED mtlSharedEvent;
} VkExportMetalSharedEventInfoEXT;
typedef struct VkImportMetalSharedEventInfoEXT {
VkStructureType sType;
const void* pNext;
- MTLSharedEvent_id mtlSharedEvent;
+ MTLSharedEvent_id SDL_UNSAFE_UNRETAINED mtlSharedEvent;
} VkImportMetalSharedEventInfoEXT;
typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo);