1 /* Mac Driver Vulkan implementation
3 * Copyright 2017 Roderick Colenbrander
4 * Copyright 2018 Andrew Eikum for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 /* NOTE: If making changes here, consider whether they should be reflected in
22 * the other drivers. */
25 #include "wine/port.h"
34 #include "wine/debug.h"
35 #include "wine/heap.h"
37 #define VK_NO_PROTOTYPES
40 #include "wine/vulkan.h"
41 #include "wine/vulkan_driver.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(vulkan
);
45 #ifdef SONAME_LIBMOLTENVK
47 WINE_DECLARE_DEBUG_CHANNEL(fps
);
49 typedef VkFlags VkMacOSSurfaceCreateFlagsMVK
;
50 #define VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK 1000123000
52 typedef VkFlags VkMetalSurfaceCreateFlagsEXT
;
53 #define VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT 1000217000
55 struct wine_vk_surface
57 macdrv_metal_device device
;
58 macdrv_metal_view view
;
59 VkSurfaceKHR surface
; /* native surface */
62 typedef struct VkMacOSSurfaceCreateInfoMVK
64 VkStructureType sType
;
66 VkMacOSSurfaceCreateFlagsMVK flags
;
67 const void *pView
; /* NSView */
68 } VkMacOSSurfaceCreateInfoMVK
;
70 typedef struct VkMetalSurfaceCreateInfoEXT
72 VkStructureType sType
;
74 VkMetalSurfaceCreateFlagsEXT flags
;
75 const void *pLayer
; /* CAMetalLayer */
76 } VkMetalSurfaceCreateInfoEXT
;
78 static VkResult (*pvkCreateInstance
)(const VkInstanceCreateInfo
*, const VkAllocationCallbacks
*, VkInstance
*);
79 static VkResult (*pvkCreateSwapchainKHR
)(VkDevice
, const VkSwapchainCreateInfoKHR
*, const VkAllocationCallbacks
*, VkSwapchainKHR
*);
80 static VkResult (*pvkCreateMacOSSurfaceMVK
)(VkInstance
, const VkMacOSSurfaceCreateInfoMVK
*, const VkAllocationCallbacks
*, VkSurfaceKHR
*);
81 static VkResult (*pvkCreateMetalSurfaceEXT
)(VkInstance
, const VkMetalSurfaceCreateInfoEXT
*, const VkAllocationCallbacks
*, VkSurfaceKHR
*);
82 static void (*pvkDestroyInstance
)(VkInstance
, const VkAllocationCallbacks
*);
83 static void (*pvkDestroySurfaceKHR
)(VkInstance
, VkSurfaceKHR
, const VkAllocationCallbacks
*);
84 static void (*pvkDestroySwapchainKHR
)(VkDevice
, VkSwapchainKHR
, const VkAllocationCallbacks
*);
85 static VkResult (*pvkEnumerateInstanceExtensionProperties
)(const char *, uint32_t *, VkExtensionProperties
*);
86 static void * (*pvkGetDeviceProcAddr
)(VkDevice
, const char *);
87 static void * (*pvkGetInstanceProcAddr
)(VkInstance
, const char *);
88 static VkResult (*pvkGetPhysicalDeviceSurfaceCapabilities2KHR
)(VkPhysicalDevice
, const VkPhysicalDeviceSurfaceInfo2KHR
*, VkSurfaceCapabilities2KHR
*);
89 static VkResult (*pvkGetPhysicalDeviceSurfaceCapabilitiesKHR
)(VkPhysicalDevice
, VkSurfaceKHR
, VkSurfaceCapabilitiesKHR
*);
90 static VkResult (*pvkGetPhysicalDeviceSurfaceFormats2KHR
)(VkPhysicalDevice
, const VkPhysicalDeviceSurfaceInfo2KHR
*, uint32_t *, VkSurfaceFormat2KHR
*);
91 static VkResult (*pvkGetPhysicalDeviceSurfaceFormatsKHR
)(VkPhysicalDevice
, VkSurfaceKHR
, uint32_t *, VkSurfaceFormatKHR
*);
92 static VkResult (*pvkGetPhysicalDeviceSurfacePresentModesKHR
)(VkPhysicalDevice
, VkSurfaceKHR
, uint32_t *, VkPresentModeKHR
*);
93 static VkResult (*pvkGetPhysicalDeviceSurfaceSupportKHR
)(VkPhysicalDevice
, uint32_t, VkSurfaceKHR
, VkBool32
*);
94 static VkResult (*pvkGetSwapchainImagesKHR
)(VkDevice
, VkSwapchainKHR
, uint32_t *, VkImage
*);
95 static VkResult (*pvkQueuePresentKHR
)(VkQueue
, const VkPresentInfoKHR
*);
97 static void *macdrv_get_vk_device_proc_addr(const char *name
);
98 static void *macdrv_get_vk_instance_proc_addr(VkInstance instance
, const char *name
);
100 static inline struct wine_vk_surface
*surface_from_handle(VkSurfaceKHR handle
)
102 return (struct wine_vk_surface
*)(uintptr_t)handle
;
105 static void *vulkan_handle
;
107 static BOOL WINAPI
wine_vk_init(INIT_ONCE
*once
, void *param
, void **context
)
109 if (!(vulkan_handle
= dlopen(SONAME_LIBMOLTENVK
, RTLD_NOW
)))
111 ERR("Failed to load %s\n", SONAME_LIBMOLTENVK
);
115 #define LOAD_FUNCPTR(f) if ((p##f = dlsym(vulkan_handle, #f)) == NULL) goto fail;
116 LOAD_FUNCPTR(vkCreateInstance
)
117 LOAD_FUNCPTR(vkCreateSwapchainKHR
)
118 LOAD_FUNCPTR(vkCreateMacOSSurfaceMVK
)
119 LOAD_FUNCPTR(vkCreateMetalSurfaceEXT
)
120 LOAD_FUNCPTR(vkDestroyInstance
)
121 LOAD_FUNCPTR(vkDestroySurfaceKHR
)
122 LOAD_FUNCPTR(vkDestroySwapchainKHR
)
123 LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties
)
124 LOAD_FUNCPTR(vkGetDeviceProcAddr
)
125 LOAD_FUNCPTR(vkGetInstanceProcAddr
)
126 LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceCapabilities2KHR
)
127 LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceCapabilitiesKHR
)
128 LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceFormats2KHR
)
129 LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceFormatsKHR
)
130 LOAD_FUNCPTR(vkGetPhysicalDeviceSurfacePresentModesKHR
)
131 LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceSupportKHR
)
132 LOAD_FUNCPTR(vkGetSwapchainImagesKHR
)
133 LOAD_FUNCPTR(vkQueuePresentKHR
)
139 dlclose(vulkan_handle
);
140 vulkan_handle
= NULL
;
144 /* Helper function for converting between win32 and MoltenVK compatible VkInstanceCreateInfo.
145 * Caller is responsible for allocation and cleanup of 'dst'.
147 static VkResult
wine_vk_instance_convert_create_info(const VkInstanceCreateInfo
*src
,
148 VkInstanceCreateInfo
*dst
)
151 const char **enabled_extensions
= NULL
;
153 dst
->sType
= src
->sType
;
154 dst
->flags
= src
->flags
;
155 dst
->pApplicationInfo
= src
->pApplicationInfo
;
156 dst
->pNext
= src
->pNext
;
157 dst
->enabledLayerCount
= 0;
158 dst
->ppEnabledLayerNames
= NULL
;
159 dst
->enabledExtensionCount
= 0;
160 dst
->ppEnabledExtensionNames
= NULL
;
162 if (src
->enabledExtensionCount
> 0)
164 enabled_extensions
= heap_calloc(src
->enabledExtensionCount
, sizeof(*src
->ppEnabledExtensionNames
));
165 if (!enabled_extensions
)
167 ERR("Failed to allocate memory for enabled extensions\n");
168 return VK_ERROR_OUT_OF_HOST_MEMORY
;
171 for (i
= 0; i
< src
->enabledExtensionCount
; i
++)
173 /* Substitute extension with MoltenVK ones else copy. Long-term, when we
174 * support more extensions, we should store these in a list.
176 if (!strcmp(src
->ppEnabledExtensionNames
[i
], "VK_KHR_win32_surface"))
178 enabled_extensions
[i
] = pvkCreateMetalSurfaceEXT
? "VK_EXT_metal_surface" : "VK_MVK_macos_surface";
182 enabled_extensions
[i
] = src
->ppEnabledExtensionNames
[i
];
185 dst
->ppEnabledExtensionNames
= enabled_extensions
;
186 dst
->enabledExtensionCount
= src
->enabledExtensionCount
;
192 static void wine_vk_surface_destroy(VkInstance instance
, struct wine_vk_surface
*surface
)
194 /* vkDestroySurfaceKHR must handle VK_NULL_HANDLE (0) for surface. */
198 pvkDestroySurfaceKHR(instance
, surface
->surface
, NULL
/* allocator */);
201 macdrv_view_release_metal_view(surface
->view
);
204 macdrv_release_metal_device(surface
->device
);
209 static VkResult
macdrv_vkCreateInstance(const VkInstanceCreateInfo
*create_info
,
210 const VkAllocationCallbacks
*allocator
, VkInstance
*instance
)
212 VkInstanceCreateInfo create_info_host
;
214 TRACE("create_info %p, allocator %p, instance %p\n", create_info
, allocator
, instance
);
217 FIXME("Support for allocation callbacks not implemented yet\n");
219 /* Perform a second pass on converting VkInstanceCreateInfo. Winevulkan
220 * performed a first pass in which it handles everything except for WSI
221 * functionality such as VK_KHR_win32_surface. Handle this now.
223 res
= wine_vk_instance_convert_create_info(create_info
, &create_info_host
);
224 if (res
!= VK_SUCCESS
)
226 ERR("Failed to convert instance create info, res=%d\n", res
);
230 res
= pvkCreateInstance(&create_info_host
, NULL
/* allocator */, instance
);
232 heap_free((void *)create_info_host
.ppEnabledExtensionNames
);
236 static VkResult
macdrv_vkCreateSwapchainKHR(VkDevice device
,
237 const VkSwapchainCreateInfoKHR
*create_info
,
238 const VkAllocationCallbacks
*allocator
, VkSwapchainKHR
*swapchain
)
240 VkSwapchainCreateInfoKHR create_info_host
;
241 TRACE("%p %p %p %p\n", device
, create_info
, allocator
, swapchain
);
244 FIXME("Support for allocation callbacks not implemented yet\n");
246 create_info_host
= *create_info
;
247 create_info_host
.surface
= surface_from_handle(create_info
->surface
)->surface
;
249 return pvkCreateSwapchainKHR(device
, &create_info_host
, NULL
/* allocator */,
253 static VkResult
macdrv_vkCreateWin32SurfaceKHR(VkInstance instance
,
254 const VkWin32SurfaceCreateInfoKHR
*create_info
,
255 const VkAllocationCallbacks
*allocator
, VkSurfaceKHR
*surface
)
258 struct wine_vk_surface
*mac_surface
;
259 struct macdrv_win_data
*data
;
261 TRACE("%p %p %p %p\n", instance
, create_info
, allocator
, surface
);
264 FIXME("Support for allocation callbacks not implemented yet\n");
266 if (!(data
= get_win_data(create_info
->hwnd
)))
268 FIXME("DC for window %p of other process: not implemented\n", create_info
->hwnd
);
269 return VK_ERROR_INCOMPATIBLE_DRIVER
;
272 mac_surface
= heap_alloc_zero(sizeof(*mac_surface
));
275 release_win_data(data
);
276 return VK_ERROR_OUT_OF_HOST_MEMORY
;
279 mac_surface
->device
= macdrv_create_metal_device();
280 if (!mac_surface
->device
)
282 ERR("Failed to allocate Metal device for hwnd=%p\n", create_info
->hwnd
);
283 res
= VK_ERROR_OUT_OF_HOST_MEMORY
;
287 mac_surface
->view
= macdrv_view_create_metal_view(data
->client_cocoa_view
, mac_surface
->device
);
288 if (!mac_surface
->view
)
290 ERR("Failed to allocate Metal view for hwnd=%p\n", create_info
->hwnd
);
292 /* VK_KHR_win32_surface only allows out of host and device memory as errors. */
293 res
= VK_ERROR_OUT_OF_HOST_MEMORY
;
297 if (pvkCreateMetalSurfaceEXT
)
299 VkMetalSurfaceCreateInfoEXT create_info_host
;
300 create_info_host
.sType
= VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT
;
301 create_info_host
.pNext
= NULL
;
302 create_info_host
.flags
= 0; /* reserved */
303 create_info_host
.pLayer
= macdrv_view_get_metal_layer(mac_surface
->view
);
305 res
= pvkCreateMetalSurfaceEXT(instance
, &create_info_host
, NULL
/* allocator */, &mac_surface
->surface
);
309 VkMacOSSurfaceCreateInfoMVK create_info_host
;
310 create_info_host
.sType
= VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK
;
311 create_info_host
.pNext
= NULL
;
312 create_info_host
.flags
= 0; /* reserved */
313 create_info_host
.pView
= macdrv_view_get_metal_layer(mac_surface
->view
);
315 res
= pvkCreateMacOSSurfaceMVK(instance
, &create_info_host
, NULL
/* allocator */, &mac_surface
->surface
);
317 if (res
!= VK_SUCCESS
)
319 ERR("Failed to create MoltenVK surface, res=%d\n", res
);
323 *surface
= (uintptr_t)mac_surface
;
325 release_win_data(data
);
327 TRACE("Created surface=0x%s\n", wine_dbgstr_longlong(*surface
));
331 wine_vk_surface_destroy(instance
, mac_surface
);
332 release_win_data(data
);
336 static void macdrv_vkDestroyInstance(VkInstance instance
, const VkAllocationCallbacks
*allocator
)
338 TRACE("%p %p\n", instance
, allocator
);
341 FIXME("Support for allocation callbacks not implemented yet\n");
343 pvkDestroyInstance(instance
, NULL
/* allocator */);
346 static void macdrv_vkDestroySurfaceKHR(VkInstance instance
, VkSurfaceKHR surface
,
347 const VkAllocationCallbacks
*allocator
)
349 struct wine_vk_surface
*mac_surface
= surface_from_handle(surface
);
351 TRACE("%p 0x%s %p\n", instance
, wine_dbgstr_longlong(surface
), allocator
);
354 FIXME("Support for allocation callbacks not implemented yet\n");
356 wine_vk_surface_destroy(instance
, mac_surface
);
359 static void macdrv_vkDestroySwapchainKHR(VkDevice device
, VkSwapchainKHR swapchain
,
360 const VkAllocationCallbacks
*allocator
)
362 TRACE("%p, 0x%s %p\n", device
, wine_dbgstr_longlong(swapchain
), allocator
);
365 FIXME("Support for allocation callbacks not implemented yet\n");
367 pvkDestroySwapchainKHR(device
, swapchain
, NULL
/* allocator */);
370 static VkResult
macdrv_vkEnumerateInstanceExtensionProperties(const char *layer_name
,
371 uint32_t *count
, VkExtensionProperties
* properties
)
374 BOOL seen_surface
= FALSE
;
377 TRACE("layer_name %s, count %p, properties %p\n", debugstr_a(layer_name
), count
, properties
);
379 /* This shouldn't get called with layer_name set, the ICD loader prevents it. */
382 ERR("Layer enumeration not supported from ICD.\n");
383 return VK_ERROR_LAYER_NOT_PRESENT
;
386 /* We will return at most the same number of instance extensions reported by the host back to
387 * winevulkan. Along the way we may replace MoltenVK extensions with their win32 equivalents,
388 * or remove redundant extensions outright.
389 * Winevulkan will perform more detailed filtering as it knows whether it has thunks
390 * for a particular extension.
392 res
= pvkEnumerateInstanceExtensionProperties(layer_name
, count
, properties
);
393 if (!properties
|| res
< 0)
396 for (i
= 0; i
< *count
; i
++)
398 /* For now the only MoltenVK extensions we need to fixup. Long-term we may need an array. */
399 if (!strcmp(properties
[i
].extensionName
, "VK_MVK_macos_surface") ||
400 !strcmp(properties
[i
].extensionName
, "VK_EXT_metal_surface"))
404 /* If we've already seen a surface extension, just hide this one. */
405 memmove(properties
+ i
, properties
+ i
+ 1, (*count
- i
- 1) * sizeof(*properties
));
410 TRACE("Substituting %s for VK_KHR_win32_surface\n", properties
[i
].extensionName
);
412 snprintf(properties
[i
].extensionName
, sizeof(properties
[i
].extensionName
),
413 VK_KHR_WIN32_SURFACE_EXTENSION_NAME
);
414 properties
[i
].specVersion
= VK_KHR_WIN32_SURFACE_SPEC_VERSION
;
419 TRACE("Returning %u extensions.\n", *count
);
423 static void *macdrv_vkGetDeviceProcAddr(VkDevice device
, const char *name
)
427 TRACE("%p, %s\n", device
, debugstr_a(name
));
429 if ((proc_addr
= macdrv_get_vk_device_proc_addr(name
)))
432 return pvkGetDeviceProcAddr(device
, name
);
435 static void *macdrv_vkGetInstanceProcAddr(VkInstance instance
, const char *name
)
439 TRACE("%p, %s\n", instance
, debugstr_a(name
));
441 if ((proc_addr
= macdrv_get_vk_instance_proc_addr(instance
, name
)))
444 return pvkGetInstanceProcAddr(instance
, name
);
447 static VkResult
macdrv_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice phys_dev
,
448 const VkPhysicalDeviceSurfaceInfo2KHR
*surface_info
, VkSurfaceCapabilities2KHR
*capabilities
)
450 VkPhysicalDeviceSurfaceInfo2KHR surface_info_host
;
452 TRACE("%p, %p, %p\n", phys_dev
, surface_info
, capabilities
);
454 surface_info_host
= *surface_info
;
455 surface_info_host
.surface
= surface_from_handle(surface_info
->surface
)->surface
;
457 return pvkGetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev
, &surface_info_host
, capabilities
);
460 static VkResult
macdrv_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice phys_dev
,
461 VkSurfaceKHR surface
, VkSurfaceCapabilitiesKHR
*capabilities
)
463 struct wine_vk_surface
*mac_surface
= surface_from_handle(surface
);
465 TRACE("%p, 0x%s, %p\n", phys_dev
, wine_dbgstr_longlong(surface
), capabilities
);
467 return pvkGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev
, mac_surface
->surface
,
471 static VkResult
macdrv_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice phys_dev
,
472 const VkPhysicalDeviceSurfaceInfo2KHR
*surface_info
, uint32_t *count
, VkSurfaceFormat2KHR
*formats
)
474 VkPhysicalDeviceSurfaceInfo2KHR surface_info_host
;
476 TRACE("%p, %p, %p, %p\n", phys_dev
, surface_info
, count
, formats
);
478 surface_info_host
= *surface_info
;
479 surface_info_host
.surface
= surface_from_handle(surface_info
->surface
)->surface
;
481 return pvkGetPhysicalDeviceSurfaceFormats2KHR(phys_dev
, &surface_info_host
, count
, formats
);
484 static VkResult
macdrv_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice phys_dev
,
485 VkSurfaceKHR surface
, uint32_t *count
, VkSurfaceFormatKHR
*formats
)
487 struct wine_vk_surface
*mac_surface
= surface_from_handle(surface
);
489 TRACE("%p, 0x%s, %p, %p\n", phys_dev
, wine_dbgstr_longlong(surface
), count
, formats
);
491 return pvkGetPhysicalDeviceSurfaceFormatsKHR(phys_dev
, mac_surface
->surface
,
495 static VkResult
macdrv_vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice phys_dev
,
496 VkSurfaceKHR surface
, uint32_t *count
, VkPresentModeKHR
*modes
)
498 struct wine_vk_surface
*mac_surface
= surface_from_handle(surface
);
500 TRACE("%p, 0x%s, %p, %p\n", phys_dev
, wine_dbgstr_longlong(surface
), count
, modes
);
502 return pvkGetPhysicalDeviceSurfacePresentModesKHR(phys_dev
, mac_surface
->surface
, count
,
506 static VkResult
macdrv_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice phys_dev
,
507 uint32_t index
, VkSurfaceKHR surface
, VkBool32
*supported
)
509 struct wine_vk_surface
*mac_surface
= surface_from_handle(surface
);
511 TRACE("%p, %u, 0x%s, %p\n", phys_dev
, index
, wine_dbgstr_longlong(surface
), supported
);
513 return pvkGetPhysicalDeviceSurfaceSupportKHR(phys_dev
, index
, mac_surface
->surface
,
517 static VkBool32
macdrv_vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice phys_dev
,
520 TRACE("%p %u\n", phys_dev
, index
);
525 static VkResult
macdrv_vkGetSwapchainImagesKHR(VkDevice device
,
526 VkSwapchainKHR swapchain
, uint32_t *count
, VkImage
*images
)
528 TRACE("%p, 0x%s %p %p\n", device
, wine_dbgstr_longlong(swapchain
), count
, images
);
529 return pvkGetSwapchainImagesKHR(device
, swapchain
, count
, images
);
532 static VkResult
macdrv_vkQueuePresentKHR(VkQueue queue
, const VkPresentInfoKHR
*present_info
)
534 TRACE("%p, %p\n", queue
, present_info
);
535 VkResult res
= pvkQueuePresentKHR(queue
, present_info
);
539 static unsigned long frames
, frames_total
;
540 static long prev_time
, start_time
;
543 time
= GetTickCount();
546 if (time
- prev_time
> 1500)
548 TRACE_(fps
)("%p @ approx %.2ffps, total %.2ffps\n",
549 queue
, 1000.0 * frames
/ (time
- prev_time
),
550 1000.0 * frames_total
/ (time
- start_time
));
561 static const struct vulkan_funcs vulkan_funcs
=
563 macdrv_vkCreateInstance
,
564 macdrv_vkCreateSwapchainKHR
,
565 macdrv_vkCreateWin32SurfaceKHR
,
566 macdrv_vkDestroyInstance
,
567 macdrv_vkDestroySurfaceKHR
,
568 macdrv_vkDestroySwapchainKHR
,
569 macdrv_vkEnumerateInstanceExtensionProperties
,
571 macdrv_vkGetDeviceProcAddr
,
572 macdrv_vkGetInstanceProcAddr
,
574 macdrv_vkGetPhysicalDeviceSurfaceCapabilities2KHR
,
575 macdrv_vkGetPhysicalDeviceSurfaceCapabilitiesKHR
,
576 macdrv_vkGetPhysicalDeviceSurfaceFormats2KHR
,
577 macdrv_vkGetPhysicalDeviceSurfaceFormatsKHR
,
578 macdrv_vkGetPhysicalDeviceSurfacePresentModesKHR
,
579 macdrv_vkGetPhysicalDeviceSurfaceSupportKHR
,
580 macdrv_vkGetPhysicalDeviceWin32PresentationSupportKHR
,
581 macdrv_vkGetSwapchainImagesKHR
,
582 macdrv_vkQueuePresentKHR
,
585 static void *macdrv_get_vk_device_proc_addr(const char *name
)
587 return get_vulkan_driver_device_proc_addr(&vulkan_funcs
, name
);
590 static void *macdrv_get_vk_instance_proc_addr(VkInstance instance
, const char *name
)
592 return get_vulkan_driver_instance_proc_addr(&vulkan_funcs
, instance
, name
);
595 static const struct vulkan_funcs
*get_vulkan_driver(UINT version
)
597 static INIT_ONCE init_once
= INIT_ONCE_STATIC_INIT
;
599 if (version
!= WINE_VULKAN_DRIVER_VERSION
)
601 ERR("version mismatch, vulkan wants %u but driver has %u\n", version
, WINE_VULKAN_DRIVER_VERSION
);
605 InitOnceExecuteOnce(&init_once
, wine_vk_init
, NULL
, NULL
);
607 return &vulkan_funcs
;
612 #else /* No vulkan */
614 static const struct vulkan_funcs
*get_vulkan_driver(UINT version
)
616 ERR("Wine was built without Vulkan support.\n");
620 #endif /* SONAME_LIBMOLTENVK */
622 const struct vulkan_funcs
* CDECL
macdrv_wine_get_vulkan_driver(PHYSDEV dev
, UINT version
)
624 const struct vulkan_funcs
*ret
;
626 if (!(ret
= get_vulkan_driver( version
)))
628 dev
= GET_NEXT_PHYSDEV( dev
, wine_get_vulkan_driver
);
629 ret
= dev
->funcs
->wine_get_vulkan_driver( dev
, version
);