2018-02-26 19:42:16 +01:00
|
|
|
/* X11DRV Vulkan implementation
|
|
|
|
*
|
|
|
|
* Copyright 2017 Roderick Colenbrander
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2018-07-13 16:28:12 +02:00
|
|
|
/* NOTE: If making changes here, consider whether they should be reflected in
|
|
|
|
* the other drivers. */
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
#include <stdarg.h>
|
2018-03-15 07:39:37 +01:00
|
|
|
#include <stdio.h>
|
2018-03-01 16:37:03 +01:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
#include "wine/debug.h"
|
2018-03-12 15:37:55 +01:00
|
|
|
#include "wine/heap.h"
|
2018-03-13 07:32:03 +01:00
|
|
|
#include "x11drv.h"
|
2018-03-12 15:37:53 +01:00
|
|
|
|
2018-04-03 11:13:10 +02:00
|
|
|
#define VK_NO_PROTOTYPES
|
2018-06-01 13:10:22 +02:00
|
|
|
#define WINE_VK_HOST
|
2018-03-12 15:37:53 +01:00
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
#include "wine/vulkan.h"
|
|
|
|
#include "wine/vulkan_driver.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
|
|
|
|
|
2018-03-22 07:20:53 +01:00
|
|
|
#ifdef SONAME_LIBVULKAN
|
2018-10-11 17:35:32 +02:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(fps);
|
2018-03-22 07:20:53 +01:00
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
static CRITICAL_SECTION context_section;
|
|
|
|
static CRITICAL_SECTION_DEBUG critsect_debug =
|
|
|
|
{
|
|
|
|
0, 0, &context_section,
|
|
|
|
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": context_section") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION context_section = { &critsect_debug, -1, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
static XContext vulkan_hwnd_context;
|
|
|
|
|
2018-03-13 07:32:03 +01:00
|
|
|
#define VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR 1000004000
|
|
|
|
|
|
|
|
struct wine_vk_surface
|
|
|
|
{
|
2018-06-13 22:08:20 +02:00
|
|
|
LONG ref;
|
2018-03-13 07:32:03 +01:00
|
|
|
Window window;
|
|
|
|
VkSurfaceKHR surface; /* native surface */
|
2021-05-03 12:26:27 +02:00
|
|
|
HWND hwnd;
|
2018-03-13 07:32:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct VkXlibSurfaceCreateInfoKHR
|
|
|
|
{
|
|
|
|
VkStructureType sType;
|
|
|
|
const void *pNext;
|
|
|
|
VkXlibSurfaceCreateFlagsKHR flags;
|
|
|
|
Display *dpy;
|
|
|
|
Window window;
|
|
|
|
} VkXlibSurfaceCreateInfoKHR;
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *);
|
2018-03-14 13:11:51 +01:00
|
|
|
static VkResult (*pvkCreateSwapchainKHR)(VkDevice, const VkSwapchainCreateInfoKHR *, const VkAllocationCallbacks *, VkSwapchainKHR *);
|
2018-03-13 07:32:03 +01:00
|
|
|
static VkResult (*pvkCreateXlibSurfaceKHR)(VkInstance, const VkXlibSurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *);
|
2018-03-01 16:37:03 +01:00
|
|
|
static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *);
|
2018-03-13 07:32:03 +01:00
|
|
|
static void (*pvkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *);
|
2018-03-14 13:11:51 +01:00
|
|
|
static void (*pvkDestroySwapchainKHR)(VkDevice, VkSwapchainKHR, const VkAllocationCallbacks *);
|
2018-03-15 07:39:37 +01:00
|
|
|
static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *);
|
2018-07-13 10:55:35 +02:00
|
|
|
static VkResult (*pvkGetDeviceGroupSurfacePresentModesKHR)(VkDevice, VkSurfaceKHR, VkDeviceGroupPresentModeFlagsKHR *);
|
2018-03-09 17:48:48 +01:00
|
|
|
static void * (*pvkGetDeviceProcAddr)(VkDevice, const char *);
|
2018-03-02 07:13:35 +01:00
|
|
|
static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *);
|
2018-07-13 10:55:35 +02:00
|
|
|
static VkResult (*pvkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkRect2D *);
|
2020-04-07 01:58:40 +02:00
|
|
|
static VkResult (*pvkGetPhysicalDeviceSurfaceCapabilities2KHR)(VkPhysicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *, VkSurfaceCapabilities2KHR *);
|
2018-03-13 07:32:06 +01:00
|
|
|
static VkResult (*pvkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice, VkSurfaceKHR, VkSurfaceCapabilitiesKHR *);
|
2020-04-07 01:58:40 +02:00
|
|
|
static VkResult (*pvkGetPhysicalDeviceSurfaceFormats2KHR)(VkPhysicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR *, uint32_t *, VkSurfaceFormat2KHR *);
|
2018-03-13 07:32:06 +01:00
|
|
|
static VkResult (*pvkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkSurfaceFormatKHR *);
|
|
|
|
static VkResult (*pvkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice, VkSurfaceKHR, uint32_t *, VkPresentModeKHR *);
|
|
|
|
static VkResult (*pvkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice, uint32_t, VkSurfaceKHR, VkBool32 *);
|
2018-03-13 07:32:04 +01:00
|
|
|
static VkBool32 (*pvkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice, uint32_t, Display *, VisualID);
|
2018-03-14 13:11:51 +01:00
|
|
|
static VkResult (*pvkGetSwapchainImagesKHR)(VkDevice, VkSwapchainKHR, uint32_t *, VkImage *);
|
|
|
|
static VkResult (*pvkQueuePresentKHR)(VkQueue, const VkPresentInfoKHR *);
|
2018-03-01 16:37:03 +01:00
|
|
|
|
2018-03-24 14:28:04 +01:00
|
|
|
static void *X11DRV_get_vk_device_proc_addr(const char *name);
|
2018-03-24 14:28:03 +01:00
|
|
|
static void *X11DRV_get_vk_instance_proc_addr(VkInstance instance, const char *name);
|
|
|
|
|
2018-03-29 14:53:49 +02:00
|
|
|
static inline struct wine_vk_surface *surface_from_handle(VkSurfaceKHR handle)
|
2018-03-12 15:37:53 +01:00
|
|
|
{
|
2021-01-26 13:32:24 +01:00
|
|
|
return (struct wine_vk_surface *)(uintptr_t)handle;
|
2018-03-13 07:32:05 +01:00
|
|
|
}
|
|
|
|
|
2018-05-31 15:17:34 +02:00
|
|
|
static void *vulkan_handle;
|
2018-03-01 16:37:03 +01:00
|
|
|
|
2018-05-31 15:17:34 +02:00
|
|
|
static BOOL WINAPI wine_vk_init(INIT_ONCE *once, void *param, void **context)
|
|
|
|
{
|
2020-04-06 22:43:15 +02:00
|
|
|
if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW)))
|
2018-03-29 14:53:48 +02:00
|
|
|
{
|
2018-07-13 10:55:35 +02:00
|
|
|
ERR("Failed to load %s.\n", SONAME_LIBVULKAN);
|
2018-05-31 15:17:34 +02:00
|
|
|
return TRUE;
|
2018-03-29 14:53:48 +02:00
|
|
|
}
|
2018-03-01 16:37:03 +01:00
|
|
|
|
2020-04-06 22:43:15 +02:00
|
|
|
#define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail
|
|
|
|
#define LOAD_OPTIONAL_FUNCPTR(f) p##f = dlsym(vulkan_handle, #f)
|
|
|
|
LOAD_FUNCPTR(vkCreateInstance);
|
|
|
|
LOAD_FUNCPTR(vkCreateSwapchainKHR);
|
|
|
|
LOAD_FUNCPTR(vkCreateXlibSurfaceKHR);
|
|
|
|
LOAD_FUNCPTR(vkDestroyInstance);
|
|
|
|
LOAD_FUNCPTR(vkDestroySurfaceKHR);
|
|
|
|
LOAD_FUNCPTR(vkDestroySwapchainKHR);
|
|
|
|
LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties);
|
|
|
|
LOAD_FUNCPTR(vkGetDeviceProcAddr);
|
|
|
|
LOAD_FUNCPTR(vkGetInstanceProcAddr);
|
|
|
|
LOAD_OPTIONAL_FUNCPTR(vkGetPhysicalDeviceSurfaceCapabilities2KHR);
|
|
|
|
LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceCapabilitiesKHR);
|
|
|
|
LOAD_OPTIONAL_FUNCPTR(vkGetPhysicalDeviceSurfaceFormats2KHR);
|
|
|
|
LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceFormatsKHR);
|
|
|
|
LOAD_FUNCPTR(vkGetPhysicalDeviceSurfacePresentModesKHR);
|
|
|
|
LOAD_FUNCPTR(vkGetPhysicalDeviceSurfaceSupportKHR);
|
|
|
|
LOAD_FUNCPTR(vkGetPhysicalDeviceXlibPresentationSupportKHR);
|
|
|
|
LOAD_FUNCPTR(vkGetSwapchainImagesKHR);
|
|
|
|
LOAD_FUNCPTR(vkQueuePresentKHR);
|
|
|
|
LOAD_OPTIONAL_FUNCPTR(vkGetDeviceGroupSurfacePresentModesKHR);
|
|
|
|
LOAD_OPTIONAL_FUNCPTR(vkGetPhysicalDevicePresentRectanglesKHR);
|
2018-03-01 16:37:03 +01:00
|
|
|
#undef LOAD_FUNCPTR
|
2018-07-13 10:55:35 +02:00
|
|
|
#undef LOAD_OPTIONAL_FUNCPTR
|
2018-03-01 16:37:03 +01:00
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
vulkan_hwnd_context = XUniqueContext();
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
return TRUE;
|
2018-05-31 15:17:34 +02:00
|
|
|
|
|
|
|
fail:
|
2020-04-06 22:43:15 +02:00
|
|
|
dlclose(vulkan_handle);
|
2018-05-31 15:17:34 +02:00
|
|
|
vulkan_handle = NULL;
|
|
|
|
return TRUE;
|
2018-03-01 16:37:03 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:55 +01:00
|
|
|
/* Helper function for converting between win32 and X11 compatible VkInstanceCreateInfo.
|
|
|
|
* Caller is responsible for allocation and cleanup of 'dst'.
|
|
|
|
*/
|
|
|
|
static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src,
|
|
|
|
VkInstanceCreateInfo *dst)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
const char **enabled_extensions = NULL;
|
|
|
|
|
|
|
|
dst->sType = src->sType;
|
|
|
|
dst->flags = src->flags;
|
|
|
|
dst->pApplicationInfo = src->pApplicationInfo;
|
|
|
|
dst->pNext = src->pNext;
|
|
|
|
dst->enabledLayerCount = 0;
|
|
|
|
dst->ppEnabledLayerNames = NULL;
|
|
|
|
dst->enabledExtensionCount = 0;
|
|
|
|
dst->ppEnabledExtensionNames = NULL;
|
|
|
|
|
|
|
|
if (src->enabledExtensionCount > 0)
|
|
|
|
{
|
|
|
|
enabled_extensions = heap_calloc(src->enabledExtensionCount, sizeof(*src->ppEnabledExtensionNames));
|
|
|
|
if (!enabled_extensions)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate memory for enabled extensions\n");
|
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < src->enabledExtensionCount; i++)
|
|
|
|
{
|
|
|
|
/* Substitute extension with X11 ones else copy. Long-term, when we
|
|
|
|
* support more extensions, we should store these in a list.
|
|
|
|
*/
|
|
|
|
if (!strcmp(src->ppEnabledExtensionNames[i], "VK_KHR_win32_surface"))
|
|
|
|
{
|
|
|
|
enabled_extensions[i] = "VK_KHR_xlib_surface";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
enabled_extensions[i] = src->ppEnabledExtensionNames[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dst->ppEnabledExtensionNames = enabled_extensions;
|
|
|
|
dst->enabledExtensionCount = src->enabledExtensionCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
static struct wine_vk_surface *wine_vk_surface_grab(struct wine_vk_surface *surface)
|
2018-03-13 07:32:03 +01:00
|
|
|
{
|
2018-06-13 22:08:20 +02:00
|
|
|
InterlockedIncrement(&surface->ref);
|
|
|
|
return surface;
|
|
|
|
}
|
2018-03-13 07:32:03 +01:00
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
static void wine_vk_surface_release(struct wine_vk_surface *surface)
|
|
|
|
{
|
|
|
|
if (InterlockedDecrement(&surface->ref))
|
|
|
|
return;
|
2018-03-13 07:32:03 +01:00
|
|
|
|
|
|
|
if (surface->window)
|
|
|
|
XDestroyWindow(gdi_display, surface->window);
|
|
|
|
|
|
|
|
heap_free(surface);
|
|
|
|
}
|
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
void wine_vk_surface_destroy(HWND hwnd)
|
|
|
|
{
|
|
|
|
struct wine_vk_surface *surface;
|
|
|
|
EnterCriticalSection(&context_section);
|
|
|
|
if (!XFindContext(gdi_display, (XID)hwnd, vulkan_hwnd_context, (char **)&surface))
|
|
|
|
{
|
|
|
|
wine_vk_surface_release(surface);
|
|
|
|
}
|
|
|
|
XDeleteContext(gdi_display, (XID)hwnd, vulkan_hwnd_context);
|
|
|
|
LeaveCriticalSection(&context_section);
|
|
|
|
}
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
static VkResult X11DRV_vkCreateInstance(const VkInstanceCreateInfo *create_info,
|
|
|
|
const VkAllocationCallbacks *allocator, VkInstance *instance)
|
|
|
|
{
|
2018-03-12 15:37:55 +01:00
|
|
|
VkInstanceCreateInfo create_info_host;
|
|
|
|
VkResult res;
|
2018-03-01 16:37:03 +01:00
|
|
|
TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2018-03-12 15:37:55 +01:00
|
|
|
/* Perform a second pass on converting VkInstanceCreateInfo. Winevulkan
|
|
|
|
* performed a first pass in which it handles everything except for WSI
|
|
|
|
* functionality such as VK_KHR_win32_surface. Handle this now.
|
|
|
|
*/
|
|
|
|
res = wine_vk_instance_convert_create_info(create_info, &create_info_host);
|
|
|
|
if (res != VK_SUCCESS)
|
2018-03-01 16:37:03 +01:00
|
|
|
{
|
2018-03-12 15:37:55 +01:00
|
|
|
ERR("Failed to convert instance create info, res=%d\n", res);
|
|
|
|
return res;
|
2018-03-01 16:37:03 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:55 +01:00
|
|
|
res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance);
|
|
|
|
|
|
|
|
heap_free((void *)create_info_host.ppEnabledExtensionNames);
|
|
|
|
return res;
|
2018-02-26 19:42:16 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:53 +01:00
|
|
|
static VkResult X11DRV_vkCreateSwapchainKHR(VkDevice device,
|
|
|
|
const VkSwapchainCreateInfoKHR *create_info,
|
|
|
|
const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain)
|
|
|
|
{
|
2021-05-03 12:26:27 +02:00
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(create_info->surface);
|
2018-03-14 13:11:51 +01:00
|
|
|
VkSwapchainCreateInfoKHR create_info_host;
|
|
|
|
TRACE("%p %p %p %p\n", device, create_info, allocator, swapchain);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2021-05-03 12:26:27 +02:00
|
|
|
if (!x11_surface->hwnd)
|
|
|
|
return VK_ERROR_SURFACE_LOST_KHR;
|
|
|
|
|
2018-03-14 13:11:51 +01:00
|
|
|
create_info_host = *create_info;
|
2021-05-03 12:26:27 +02:00
|
|
|
create_info_host.surface = x11_surface->surface;
|
2018-03-14 13:11:51 +01:00
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
return pvkCreateSwapchainKHR(device, &create_info_host, NULL /* allocator */, swapchain);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance,
|
|
|
|
const VkWin32SurfaceCreateInfoKHR *create_info,
|
|
|
|
const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)
|
|
|
|
{
|
2018-03-13 07:32:03 +01:00
|
|
|
VkResult res;
|
|
|
|
VkXlibSurfaceCreateInfoKHR create_info_host;
|
2018-06-13 22:08:20 +02:00
|
|
|
struct wine_vk_surface *x11_surface, *prev;
|
2018-03-13 07:32:03 +01:00
|
|
|
|
|
|
|
TRACE("%p %p %p %p\n", instance, create_info, allocator, surface);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
|
|
|
/* TODO: support child window rendering. */
|
2021-05-03 12:26:27 +02:00
|
|
|
if (create_info->hwnd && GetAncestor(create_info->hwnd, GA_PARENT) != GetDesktopWindow())
|
2018-03-13 07:32:03 +01:00
|
|
|
{
|
|
|
|
FIXME("Application requires child window rendering, which is not implemented yet!\n");
|
|
|
|
return VK_ERROR_INCOMPATIBLE_DRIVER;
|
|
|
|
}
|
|
|
|
|
|
|
|
x11_surface = heap_alloc_zero(sizeof(*x11_surface));
|
|
|
|
if (!x11_surface)
|
|
|
|
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
x11_surface->ref = 1;
|
2021-05-03 12:26:27 +02:00
|
|
|
x11_surface->hwnd = create_info->hwnd;
|
|
|
|
x11_surface->window = x11_surface->hwnd ? create_client_window(create_info->hwnd, &default_visual)
|
|
|
|
: create_dummy_client_window();
|
2018-06-13 22:08:20 +02:00
|
|
|
|
2018-03-13 07:32:03 +01:00
|
|
|
if (!x11_surface->window)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate client window for hwnd=%p\n", create_info->hwnd);
|
|
|
|
|
|
|
|
/* VK_KHR_win32_surface only allows out of host and device memory as errors. */
|
|
|
|
res = VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
create_info_host.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR;
|
|
|
|
create_info_host.pNext = NULL;
|
|
|
|
create_info_host.flags = 0; /* reserved */
|
|
|
|
create_info_host.dpy = gdi_display;
|
|
|
|
create_info_host.window = x11_surface->window;
|
|
|
|
|
|
|
|
res = pvkCreateXlibSurfaceKHR(instance, &create_info_host, NULL /* allocator */, &x11_surface->surface);
|
|
|
|
if (res != VK_SUCCESS)
|
|
|
|
{
|
|
|
|
ERR("Failed to create Xlib surface, res=%d\n", res);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2021-05-03 12:26:27 +02:00
|
|
|
if (x11_surface->hwnd)
|
2018-06-13 22:08:20 +02:00
|
|
|
{
|
2021-05-03 12:26:27 +02:00
|
|
|
EnterCriticalSection(&context_section);
|
|
|
|
if (!XFindContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char **)&prev))
|
|
|
|
{
|
|
|
|
wine_vk_surface_release(prev);
|
|
|
|
}
|
|
|
|
XSaveContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char *)wine_vk_surface_grab(x11_surface));
|
|
|
|
LeaveCriticalSection(&context_section);
|
2018-06-13 22:08:20 +02:00
|
|
|
}
|
|
|
|
|
2021-01-26 13:32:24 +01:00
|
|
|
*surface = (uintptr_t)x11_surface;
|
2018-03-13 07:32:03 +01:00
|
|
|
|
|
|
|
TRACE("Created surface=0x%s\n", wine_dbgstr_longlong(*surface));
|
|
|
|
return VK_SUCCESS;
|
|
|
|
|
|
|
|
err:
|
2018-06-13 22:08:20 +02:00
|
|
|
wine_vk_surface_release(x11_surface);
|
2018-03-13 07:32:03 +01:00
|
|
|
return res;
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
static void X11DRV_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *allocator)
|
|
|
|
{
|
2018-03-01 16:37:03 +01:00
|
|
|
TRACE("%p %p\n", instance, allocator);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
|
|
|
pvkDestroyInstance(instance, NULL /* allocator */);
|
2018-02-26 19:42:16 +01:00
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:53 +01:00
|
|
|
static void X11DRV_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface,
|
|
|
|
const VkAllocationCallbacks *allocator)
|
|
|
|
{
|
2018-03-13 07:32:05 +01:00
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p 0x%s %p\n", instance, wine_dbgstr_longlong(surface), allocator);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
2018-06-13 22:08:20 +02:00
|
|
|
/* vkDestroySurfaceKHR must handle VK_NULL_HANDLE (0) for surface. */
|
|
|
|
if (x11_surface)
|
|
|
|
{
|
|
|
|
pvkDestroySurfaceKHR(instance, x11_surface->surface, NULL /* allocator */);
|
|
|
|
|
|
|
|
wine_vk_surface_release(x11_surface);
|
|
|
|
}
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void X11DRV_vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain,
|
|
|
|
const VkAllocationCallbacks *allocator)
|
|
|
|
{
|
2018-03-14 13:11:51 +01:00
|
|
|
TRACE("%p, 0x%s %p\n", device, wine_dbgstr_longlong(swapchain), allocator);
|
|
|
|
|
|
|
|
if (allocator)
|
|
|
|
FIXME("Support for allocation callbacks not implemented yet\n");
|
|
|
|
|
|
|
|
pvkDestroySwapchainKHR(device, swapchain, NULL /* allocator */);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
static VkResult X11DRV_vkEnumerateInstanceExtensionProperties(const char *layer_name,
|
|
|
|
uint32_t *count, VkExtensionProperties* properties)
|
|
|
|
{
|
2018-03-23 14:46:18 +01:00
|
|
|
unsigned int i;
|
2018-03-29 14:53:49 +02:00
|
|
|
VkResult res;
|
2018-03-12 15:37:53 +01:00
|
|
|
|
2018-04-01 22:20:50 +02:00
|
|
|
TRACE("layer_name %s, count %p, properties %p\n", debugstr_a(layer_name), count, properties);
|
2018-02-26 19:42:17 +01:00
|
|
|
|
|
|
|
/* This shouldn't get called with layer_name set, the ICD loader prevents it. */
|
|
|
|
if (layer_name)
|
|
|
|
{
|
|
|
|
ERR("Layer enumeration not supported from ICD.\n");
|
|
|
|
return VK_ERROR_LAYER_NOT_PRESENT;
|
|
|
|
}
|
|
|
|
|
2018-03-29 14:53:49 +02:00
|
|
|
/* We will return the same number of instance extensions reported by the host back to
|
|
|
|
* winevulkan. Along the way we may replace xlib extensions with their win32 equivalents.
|
|
|
|
* Winevulkan will perform more detailed filtering as it knows whether it has thunks
|
|
|
|
* for a particular extension.
|
|
|
|
*/
|
|
|
|
res = pvkEnumerateInstanceExtensionProperties(layer_name, count, properties);
|
|
|
|
if (!properties || res < 0)
|
|
|
|
return res;
|
2018-02-26 19:42:17 +01:00
|
|
|
|
2018-03-23 14:46:18 +01:00
|
|
|
for (i = 0; i < *count; i++)
|
2018-03-12 15:37:53 +01:00
|
|
|
{
|
2018-03-29 14:53:49 +02:00
|
|
|
/* For now the only x11 extension we need to fixup. Long-term we may need an array. */
|
|
|
|
if (!strcmp(properties[i].extensionName, "VK_KHR_xlib_surface"))
|
|
|
|
{
|
|
|
|
TRACE("Substituting VK_KHR_xlib_surface for VK_KHR_win32_surface\n");
|
|
|
|
|
2018-04-03 11:13:09 +02:00
|
|
|
snprintf(properties[i].extensionName, sizeof(properties[i].extensionName),
|
|
|
|
VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
|
|
|
|
properties[i].specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION;
|
2018-03-29 14:53:49 +02:00
|
|
|
}
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
2018-03-23 14:46:18 +01:00
|
|
|
TRACE("Returning %u extensions.\n", *count);
|
2018-03-29 14:53:49 +02:00
|
|
|
return res;
|
2018-02-26 19:42:16 +01:00
|
|
|
}
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
static VkResult X11DRV_vkGetDeviceGroupSurfacePresentModesKHR(VkDevice device,
|
|
|
|
VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR *flags)
|
|
|
|
{
|
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", device, wine_dbgstr_longlong(surface), flags);
|
|
|
|
|
|
|
|
return pvkGetDeviceGroupSurfacePresentModesKHR(device, x11_surface->surface, flags);
|
|
|
|
}
|
|
|
|
|
2021-08-20 13:24:47 +02:00
|
|
|
static const char *wine_vk_native_fn_name(const char *name)
|
|
|
|
{
|
|
|
|
if (!strcmp(name, "vkCreateWin32SurfaceKHR"))
|
|
|
|
return "vkCreateXlibSurfaceKHR";
|
|
|
|
if (!strcmp(name, "vkGetPhysicalDeviceWin32PresentationSupportKHR"))
|
|
|
|
return "vkGetPhysicalDeviceXlibPresentationSupportKHR";
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2018-03-24 14:28:04 +01:00
|
|
|
static void *X11DRV_vkGetDeviceProcAddr(VkDevice device, const char *name)
|
2018-03-09 17:48:48 +01:00
|
|
|
{
|
2018-03-24 14:28:04 +01:00
|
|
|
void *proc_addr;
|
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
TRACE("%p, %s\n", device, debugstr_a(name));
|
2018-03-24 14:28:04 +01:00
|
|
|
|
2021-08-20 13:24:47 +02:00
|
|
|
if (!pvkGetDeviceProcAddr(device, wine_vk_native_fn_name(name)))
|
|
|
|
return NULL;
|
|
|
|
|
2018-03-24 14:28:04 +01:00
|
|
|
if ((proc_addr = X11DRV_get_vk_device_proc_addr(name)))
|
|
|
|
return proc_addr;
|
|
|
|
|
2018-03-09 17:48:48 +01:00
|
|
|
return pvkGetDeviceProcAddr(device, name);
|
|
|
|
}
|
|
|
|
|
2018-03-24 14:28:03 +01:00
|
|
|
static void *X11DRV_vkGetInstanceProcAddr(VkInstance instance, const char *name)
|
2018-02-26 19:42:16 +01:00
|
|
|
{
|
2018-03-24 14:28:03 +01:00
|
|
|
void *proc_addr;
|
|
|
|
|
2018-03-02 07:13:35 +01:00
|
|
|
TRACE("%p, %s\n", instance, debugstr_a(name));
|
2018-03-24 14:28:03 +01:00
|
|
|
|
2021-08-20 13:24:47 +02:00
|
|
|
if (!pvkGetInstanceProcAddr(instance, wine_vk_native_fn_name(name)))
|
|
|
|
return NULL;
|
|
|
|
|
2018-03-24 14:28:03 +01:00
|
|
|
if ((proc_addr = X11DRV_get_vk_instance_proc_addr(instance, name)))
|
|
|
|
return proc_addr;
|
|
|
|
|
2018-03-02 07:13:35 +01:00
|
|
|
return pvkGetInstanceProcAddr(instance, name);
|
2018-02-26 19:42:16 +01:00
|
|
|
}
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
static VkResult X11DRV_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice phys_dev,
|
|
|
|
VkSurfaceKHR surface, uint32_t *count, VkRect2D *rects)
|
|
|
|
{
|
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p, %p\n", phys_dev, wine_dbgstr_longlong(surface), count, rects);
|
|
|
|
|
2021-05-03 12:26:27 +02:00
|
|
|
if (!x11_surface->hwnd)
|
|
|
|
{
|
|
|
|
if (rects)
|
|
|
|
return VK_ERROR_SURFACE_LOST_KHR;
|
|
|
|
|
|
|
|
*count = 1;
|
|
|
|
return VK_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
return pvkGetPhysicalDevicePresentRectanglesKHR(phys_dev, x11_surface->surface, count, rects);
|
|
|
|
}
|
|
|
|
|
2020-04-07 01:58:40 +02:00
|
|
|
static VkResult X11DRV_vkGetPhysicalDeviceSurfaceCapabilities2KHR(VkPhysicalDevice phys_dev,
|
|
|
|
const VkPhysicalDeviceSurfaceInfo2KHR *surface_info, VkSurfaceCapabilities2KHR *capabilities)
|
|
|
|
{
|
|
|
|
VkPhysicalDeviceSurfaceInfo2KHR surface_info_host;
|
|
|
|
TRACE("%p, %p, %p\n", phys_dev, surface_info, capabilities);
|
|
|
|
|
|
|
|
surface_info_host = *surface_info;
|
|
|
|
surface_info_host.surface = surface_from_handle(surface_info->surface)->surface;
|
|
|
|
|
|
|
|
if (pvkGetPhysicalDeviceSurfaceCapabilities2KHR)
|
|
|
|
return pvkGetPhysicalDeviceSurfaceCapabilities2KHR(phys_dev, &surface_info_host, capabilities);
|
|
|
|
|
|
|
|
/* Until the loader version exporting this function is common, emulate it using the older non-2 version. */
|
|
|
|
if (surface_info->pNext || capabilities->pNext)
|
|
|
|
FIXME("Emulating vkGetPhysicalDeviceSurfaceCapabilities2KHR with vkGetPhysicalDeviceSurfaceCapabilitiesKHR, pNext is ignored.\n");
|
|
|
|
|
|
|
|
return pvkGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev, surface_info_host.surface, &capabilities->surfaceCapabilities);
|
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:53 +01:00
|
|
|
static VkResult X11DRV_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice phys_dev,
|
|
|
|
VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *capabilities)
|
|
|
|
{
|
2018-03-13 07:32:06 +01:00
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p\n", phys_dev, wine_dbgstr_longlong(surface), capabilities);
|
|
|
|
|
2021-05-03 12:26:27 +02:00
|
|
|
if (!x11_surface->hwnd)
|
|
|
|
return VK_ERROR_SURFACE_LOST_KHR;
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
return pvkGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev, x11_surface->surface, capabilities);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
2020-04-07 01:58:40 +02:00
|
|
|
static VkResult X11DRV_vkGetPhysicalDeviceSurfaceFormats2KHR(VkPhysicalDevice phys_dev,
|
|
|
|
const VkPhysicalDeviceSurfaceInfo2KHR *surface_info, uint32_t *count, VkSurfaceFormat2KHR *formats)
|
|
|
|
{
|
|
|
|
VkPhysicalDeviceSurfaceInfo2KHR surface_info_host = *surface_info;
|
|
|
|
VkSurfaceFormatKHR *formats_host;
|
|
|
|
uint32_t i;
|
|
|
|
VkResult result;
|
|
|
|
TRACE("%p, %p, %p, %p\n", phys_dev, surface_info, count, formats);
|
|
|
|
|
|
|
|
surface_info_host = *surface_info;
|
|
|
|
surface_info_host.surface = surface_from_handle(surface_info->surface)->surface;
|
|
|
|
|
|
|
|
if (pvkGetPhysicalDeviceSurfaceFormats2KHR)
|
|
|
|
return pvkGetPhysicalDeviceSurfaceFormats2KHR(phys_dev, &surface_info_host, count, formats);
|
|
|
|
|
|
|
|
/* Until the loader version exporting this function is common, emulate it using the older non-2 version. */
|
|
|
|
if (surface_info->pNext)
|
|
|
|
FIXME("Emulating vkGetPhysicalDeviceSurfaceFormats2KHR with vkGetPhysicalDeviceSurfaceFormatsKHR, pNext is ignored.\n");
|
|
|
|
|
|
|
|
if (!formats)
|
|
|
|
return pvkGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, surface_info_host.surface, count, NULL);
|
|
|
|
|
|
|
|
formats_host = heap_calloc(*count, sizeof(*formats_host));
|
|
|
|
if (!formats_host) return VK_ERROR_OUT_OF_HOST_MEMORY;
|
|
|
|
result = pvkGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, surface_info_host.surface, count, formats_host);
|
|
|
|
if (result == VK_SUCCESS || result == VK_INCOMPLETE)
|
|
|
|
{
|
|
|
|
for (i = 0; i < *count; i++)
|
|
|
|
formats[i].surfaceFormat = formats_host[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
heap_free(formats_host);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-03-12 15:37:53 +01:00
|
|
|
static VkResult X11DRV_vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice phys_dev,
|
|
|
|
VkSurfaceKHR surface, uint32_t *count, VkSurfaceFormatKHR *formats)
|
|
|
|
{
|
2018-03-13 07:32:06 +01:00
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p, %p\n", phys_dev, wine_dbgstr_longlong(surface), count, formats);
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
return pvkGetPhysicalDeviceSurfaceFormatsKHR(phys_dev, x11_surface->surface, count, formats);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static VkResult X11DRV_vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice phys_dev,
|
|
|
|
VkSurfaceKHR surface, uint32_t *count, VkPresentModeKHR *modes)
|
|
|
|
{
|
2018-03-13 07:32:06 +01:00
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, 0x%s, %p, %p\n", phys_dev, wine_dbgstr_longlong(surface), count, modes);
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
return pvkGetPhysicalDeviceSurfacePresentModesKHR(phys_dev, x11_surface->surface, count, modes);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static VkResult X11DRV_vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice phys_dev,
|
|
|
|
uint32_t index, VkSurfaceKHR surface, VkBool32 *supported)
|
|
|
|
{
|
2018-03-13 07:32:06 +01:00
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("%p, %u, 0x%s, %p\n", phys_dev, index, wine_dbgstr_longlong(surface), supported);
|
|
|
|
|
2018-07-13 10:55:35 +02:00
|
|
|
return pvkGetPhysicalDeviceSurfaceSupportKHR(phys_dev, index, x11_surface->surface, supported);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static VkBool32 X11DRV_vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice phys_dev,
|
|
|
|
uint32_t index)
|
|
|
|
{
|
2018-03-13 07:32:04 +01:00
|
|
|
TRACE("%p %u\n", phys_dev, index);
|
|
|
|
|
|
|
|
return pvkGetPhysicalDeviceXlibPresentationSupportKHR(phys_dev, index, gdi_display,
|
|
|
|
default_visual.visual->visualid);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static VkResult X11DRV_vkGetSwapchainImagesKHR(VkDevice device,
|
|
|
|
VkSwapchainKHR swapchain, uint32_t *count, VkImage *images)
|
|
|
|
{
|
2018-03-14 13:11:51 +01:00
|
|
|
TRACE("%p, 0x%s %p %p\n", device, wine_dbgstr_longlong(swapchain), count, images);
|
|
|
|
return pvkGetSwapchainImagesKHR(device, swapchain, count, images);
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static VkResult X11DRV_vkQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *present_info)
|
|
|
|
{
|
2018-08-15 10:43:23 +02:00
|
|
|
VkResult res;
|
|
|
|
|
2018-03-14 13:11:51 +01:00
|
|
|
TRACE("%p, %p\n", queue, present_info);
|
2018-08-15 10:43:23 +02:00
|
|
|
|
|
|
|
res = pvkQueuePresentKHR(queue, present_info);
|
|
|
|
|
|
|
|
if (TRACE_ON(fps))
|
|
|
|
{
|
|
|
|
static unsigned long frames, frames_total;
|
|
|
|
static long prev_time, start_time;
|
|
|
|
DWORD time;
|
|
|
|
|
|
|
|
time = GetTickCount();
|
|
|
|
frames++;
|
|
|
|
frames_total++;
|
|
|
|
if (time - prev_time > 1500)
|
|
|
|
{
|
|
|
|
TRACE_(fps)("%p @ approx %.2ffps, total %.2ffps\n",
|
|
|
|
queue, 1000.0 * frames / (time - prev_time),
|
|
|
|
1000.0 * frames_total / (time - start_time));
|
|
|
|
prev_time = time;
|
|
|
|
frames = 0;
|
|
|
|
if (!start_time)
|
|
|
|
start_time = time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2018-03-12 15:37:53 +01:00
|
|
|
}
|
|
|
|
|
2021-01-26 13:32:24 +01:00
|
|
|
static VkSurfaceKHR X11DRV_wine_get_native_surface(VkSurfaceKHR surface)
|
|
|
|
{
|
|
|
|
struct wine_vk_surface *x11_surface = surface_from_handle(surface);
|
|
|
|
|
|
|
|
TRACE("0x%s\n", wine_dbgstr_longlong(surface));
|
|
|
|
|
|
|
|
return x11_surface->surface;
|
|
|
|
}
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
static const struct vulkan_funcs vulkan_funcs =
|
2018-02-26 19:42:16 +01:00
|
|
|
{
|
|
|
|
X11DRV_vkCreateInstance,
|
2018-03-12 15:37:53 +01:00
|
|
|
X11DRV_vkCreateSwapchainKHR,
|
|
|
|
X11DRV_vkCreateWin32SurfaceKHR,
|
2018-02-26 19:42:16 +01:00
|
|
|
X11DRV_vkDestroyInstance,
|
2018-03-12 15:37:53 +01:00
|
|
|
X11DRV_vkDestroySurfaceKHR,
|
|
|
|
X11DRV_vkDestroySwapchainKHR,
|
2018-02-26 19:42:16 +01:00
|
|
|
X11DRV_vkEnumerateInstanceExtensionProperties,
|
2018-07-13 10:55:35 +02:00
|
|
|
X11DRV_vkGetDeviceGroupSurfacePresentModesKHR,
|
2018-03-09 17:48:48 +01:00
|
|
|
X11DRV_vkGetDeviceProcAddr,
|
2018-03-12 15:37:53 +01:00
|
|
|
X11DRV_vkGetInstanceProcAddr,
|
2018-07-13 10:55:35 +02:00
|
|
|
X11DRV_vkGetPhysicalDevicePresentRectanglesKHR,
|
2020-04-07 01:58:40 +02:00
|
|
|
X11DRV_vkGetPhysicalDeviceSurfaceCapabilities2KHR,
|
2018-03-12 15:37:53 +01:00
|
|
|
X11DRV_vkGetPhysicalDeviceSurfaceCapabilitiesKHR,
|
2020-04-07 01:58:40 +02:00
|
|
|
X11DRV_vkGetPhysicalDeviceSurfaceFormats2KHR,
|
2018-03-12 15:37:53 +01:00
|
|
|
X11DRV_vkGetPhysicalDeviceSurfaceFormatsKHR,
|
|
|
|
X11DRV_vkGetPhysicalDeviceSurfacePresentModesKHR,
|
|
|
|
X11DRV_vkGetPhysicalDeviceSurfaceSupportKHR,
|
|
|
|
X11DRV_vkGetPhysicalDeviceWin32PresentationSupportKHR,
|
|
|
|
X11DRV_vkGetSwapchainImagesKHR,
|
2018-03-24 14:28:03 +01:00
|
|
|
X11DRV_vkQueuePresentKHR,
|
2021-01-26 13:32:24 +01:00
|
|
|
|
|
|
|
X11DRV_wine_get_native_surface,
|
2018-02-26 19:42:16 +01:00
|
|
|
};
|
|
|
|
|
2018-03-29 14:53:50 +02:00
|
|
|
static void *X11DRV_get_vk_device_proc_addr(const char *name)
|
|
|
|
{
|
|
|
|
return get_vulkan_driver_device_proc_addr(&vulkan_funcs, name);
|
|
|
|
}
|
|
|
|
|
2018-03-24 14:28:03 +01:00
|
|
|
static void *X11DRV_get_vk_instance_proc_addr(VkInstance instance, const char *name)
|
|
|
|
{
|
|
|
|
return get_vulkan_driver_instance_proc_addr(&vulkan_funcs, instance, name);
|
|
|
|
}
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
const struct vulkan_funcs *get_vulkan_driver(UINT version)
|
|
|
|
{
|
2018-05-31 15:17:34 +02:00
|
|
|
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
|
|
|
|
2018-02-26 19:42:16 +01:00
|
|
|
if (version != WINE_VULKAN_DRIVER_VERSION)
|
|
|
|
{
|
|
|
|
ERR("version mismatch, vulkan wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-05-31 15:17:34 +02:00
|
|
|
InitOnceExecuteOnce(&init_once, wine_vk_init, NULL, NULL);
|
|
|
|
if (vulkan_handle)
|
2018-03-01 16:37:03 +01:00
|
|
|
return &vulkan_funcs;
|
|
|
|
|
|
|
|
return NULL;
|
2018-02-26 19:42:16 +01:00
|
|
|
}
|
2018-03-01 16:37:03 +01:00
|
|
|
|
|
|
|
#else /* No vulkan */
|
|
|
|
|
|
|
|
const struct vulkan_funcs *get_vulkan_driver(UINT version)
|
|
|
|
{
|
2018-03-21 10:03:43 +01:00
|
|
|
ERR("Wine was built without Vulkan support.\n");
|
2018-03-01 16:37:03 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2018-06-15 01:01:27 +02:00
|
|
|
void wine_vk_surface_destroy(HWND hwnd)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-01 16:37:03 +01:00
|
|
|
#endif /* SONAME_LIBVULKAN */
|