vulkan_metal.h: Make compatible with ObjC ARC

Fixes #6598

(cherry picked from commit 239423e205)
This commit is contained in:
Joshua Root 2022-11-24 11:06:37 +11:00 committed by Sam Lantinga
parent da1bddd27c
commit bf70a37606

View file

@ -26,6 +26,14 @@ extern "C" {
typedef void CAMetalLayer; typedef void CAMetalLayer;
#endif #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_SPEC_VERSION 1
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface" #define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
typedef VkFlags VkMetalSurfaceCreateFlagsEXT; typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
@ -33,7 +41,7 @@ typedef struct VkMetalSurfaceCreateInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
VkMetalSurfaceCreateFlagsEXT flags; VkMetalSurfaceCreateFlagsEXT flags;
const CAMetalLayer* pLayer; const CAMetalLayer SDL_UNSAFE_UNRETAINED *pLayer;
} VkMetalSurfaceCreateInfoEXT; } VkMetalSurfaceCreateInfoEXT;
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); 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 { typedef struct VkExportMetalDeviceInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
MTLDevice_id mtlDevice; MTLDevice_id SDL_UNSAFE_UNRETAINED mtlDevice;
} VkExportMetalDeviceInfoEXT; } VkExportMetalDeviceInfoEXT;
typedef struct VkExportMetalCommandQueueInfoEXT { typedef struct VkExportMetalCommandQueueInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
VkQueue queue; VkQueue queue;
MTLCommandQueue_id mtlCommandQueue; MTLCommandQueue_id SDL_UNSAFE_UNRETAINED mtlCommandQueue;
} VkExportMetalCommandQueueInfoEXT; } VkExportMetalCommandQueueInfoEXT;
typedef struct VkExportMetalBufferInfoEXT { typedef struct VkExportMetalBufferInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
VkDeviceMemory memory; VkDeviceMemory memory;
MTLBuffer_id mtlBuffer; MTLBuffer_id SDL_UNSAFE_UNRETAINED mtlBuffer;
} VkExportMetalBufferInfoEXT; } VkExportMetalBufferInfoEXT;
typedef struct VkImportMetalBufferInfoEXT { typedef struct VkImportMetalBufferInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
MTLBuffer_id mtlBuffer; MTLBuffer_id SDL_UNSAFE_UNRETAINED mtlBuffer;
} VkImportMetalBufferInfoEXT; } VkImportMetalBufferInfoEXT;
typedef struct VkExportMetalTextureInfoEXT { typedef struct VkExportMetalTextureInfoEXT {
@ -141,14 +149,14 @@ typedef struct VkExportMetalTextureInfoEXT {
VkImageView imageView; VkImageView imageView;
VkBufferView bufferView; VkBufferView bufferView;
VkImageAspectFlagBits plane; VkImageAspectFlagBits plane;
MTLTexture_id mtlTexture; MTLTexture_id SDL_UNSAFE_UNRETAINED mtlTexture;
} VkExportMetalTextureInfoEXT; } VkExportMetalTextureInfoEXT;
typedef struct VkImportMetalTextureInfoEXT { typedef struct VkImportMetalTextureInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
VkImageAspectFlagBits plane; VkImageAspectFlagBits plane;
MTLTexture_id mtlTexture; MTLTexture_id SDL_UNSAFE_UNRETAINED mtlTexture;
} VkImportMetalTextureInfoEXT; } VkImportMetalTextureInfoEXT;
typedef struct VkExportMetalIOSurfaceInfoEXT { typedef struct VkExportMetalIOSurfaceInfoEXT {
@ -169,13 +177,13 @@ typedef struct VkExportMetalSharedEventInfoEXT {
const void* pNext; const void* pNext;
VkSemaphore semaphore; VkSemaphore semaphore;
VkEvent event; VkEvent event;
MTLSharedEvent_id mtlSharedEvent; MTLSharedEvent_id SDL_UNSAFE_UNRETAINED mtlSharedEvent;
} VkExportMetalSharedEventInfoEXT; } VkExportMetalSharedEventInfoEXT;
typedef struct VkImportMetalSharedEventInfoEXT { typedef struct VkImportMetalSharedEventInfoEXT {
VkStructureType sType; VkStructureType sType;
const void* pNext; const void* pNext;
MTLSharedEvent_id mtlSharedEvent; MTLSharedEvent_id SDL_UNSAFE_UNRETAINED mtlSharedEvent;
} VkImportMetalSharedEventInfoEXT; } VkImportMetalSharedEventInfoEXT;
typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo); typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo);