Skip to content

Commit fc787a4

Browse files
committed
vulkan_metal.h: Make compatible with ObjC ARC (thanks @jmroot!)
(re)Fixes #6598 We need to remember to apply this again once we update from upstream headers. (cherry picked from commit e67e0c5)
1 parent 05bb182 commit fc787a4

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/video/khronos/vulkan/vulkan_metal.h

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@ extern "C" {
2727
typedef void CAMetalLayer;
2828
#endif
2929

30+
#define SDL_UNSAFE_UNRETAINED
31+
#if defined(__OBJC__) && defined(__has_feature)
32+
#if __has_feature(objc_arc)
33+
#undef SDL_UNSAFE_UNRETAINED
34+
#define SDL_UNSAFE_UNRETAINED __unsafe_unretained
35+
#endif
36+
#endif
37+
3038
#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1
3139
#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface"
3240
typedef VkFlags VkMetalSurfaceCreateFlagsEXT;
3341
typedef struct VkMetalSurfaceCreateInfoEXT {
3442
VkStructureType sType;
3543
const void* pNext;
3644
VkMetalSurfaceCreateFlagsEXT flags;
37-
const CAMetalLayer* pLayer;
45+
const CAMetalLayer SDL_UNSAFE_UNRETAINED *pLayer;
3846
} VkMetalSurfaceCreateInfoEXT;
3947

4048
typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface);
@@ -113,27 +121,27 @@ typedef struct VkExportMetalObjectsInfoEXT {
113121
typedef struct VkExportMetalDeviceInfoEXT {
114122
VkStructureType sType;
115123
const void* pNext;
116-
MTLDevice_id mtlDevice;
124+
MTLDevice_id SDL_UNSAFE_UNRETAINED mtlDevice;
117125
} VkExportMetalDeviceInfoEXT;
118126

119127
typedef struct VkExportMetalCommandQueueInfoEXT {
120128
VkStructureType sType;
121129
const void* pNext;
122130
VkQueue queue;
123-
MTLCommandQueue_id mtlCommandQueue;
131+
MTLCommandQueue_id SDL_UNSAFE_UNRETAINED mtlCommandQueue;
124132
} VkExportMetalCommandQueueInfoEXT;
125133

126134
typedef struct VkExportMetalBufferInfoEXT {
127135
VkStructureType sType;
128136
const void* pNext;
129137
VkDeviceMemory memory;
130-
MTLBuffer_id mtlBuffer;
138+
MTLBuffer_id SDL_UNSAFE_UNRETAINED mtlBuffer;
131139
} VkExportMetalBufferInfoEXT;
132140

133141
typedef struct VkImportMetalBufferInfoEXT {
134142
VkStructureType sType;
135143
const void* pNext;
136-
MTLBuffer_id mtlBuffer;
144+
MTLBuffer_id SDL_UNSAFE_UNRETAINED mtlBuffer;
137145
} VkImportMetalBufferInfoEXT;
138146

139147
typedef struct VkExportMetalTextureInfoEXT {
@@ -143,14 +151,14 @@ typedef struct VkExportMetalTextureInfoEXT {
143151
VkImageView imageView;
144152
VkBufferView bufferView;
145153
VkImageAspectFlagBits plane;
146-
MTLTexture_id mtlTexture;
154+
MTLTexture_id SDL_UNSAFE_UNRETAINED mtlTexture;
147155
} VkExportMetalTextureInfoEXT;
148156

149157
typedef struct VkImportMetalTextureInfoEXT {
150158
VkStructureType sType;
151159
const void* pNext;
152160
VkImageAspectFlagBits plane;
153-
MTLTexture_id mtlTexture;
161+
MTLTexture_id SDL_UNSAFE_UNRETAINED mtlTexture;
154162
} VkImportMetalTextureInfoEXT;
155163

156164
typedef struct VkExportMetalIOSurfaceInfoEXT {
@@ -171,13 +179,13 @@ typedef struct VkExportMetalSharedEventInfoEXT {
171179
const void* pNext;
172180
VkSemaphore semaphore;
173181
VkEvent event;
174-
MTLSharedEvent_id mtlSharedEvent;
182+
MTLSharedEvent_id SDL_UNSAFE_UNRETAINED mtlSharedEvent;
175183
} VkExportMetalSharedEventInfoEXT;
176184

177185
typedef struct VkImportMetalSharedEventInfoEXT {
178186
VkStructureType sType;
179187
const void* pNext;
180-
MTLSharedEvent_id mtlSharedEvent;
188+
MTLSharedEvent_id SDL_UNSAFE_UNRETAINED mtlSharedEvent;
181189
} VkImportMetalSharedEventInfoEXT;
182190

183191
typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo);

0 commit comments

Comments
 (0)