Commit 6eab8468 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winevulkan: Wrap host swapchain handles.

parent 83148123
......@@ -225,6 +225,7 @@ MANUAL_UNIX_THUNKS = {
"vkCreateDevice",
"vkCreateImage",
"vkCreateInstance",
"vkCreateSwapchainKHR",
"vkCreateWin32SurfaceKHR",
"vkDestroyCommandPool",
"vkDestroyDebugReportCallbackEXT",
......@@ -233,6 +234,7 @@ MANUAL_UNIX_THUNKS = {
"vkDestroyDevice",
"vkDestroyInstance",
"vkDestroySurfaceKHR",
"vkDestroySwapchainKHR",
"vkEnumerateDeviceExtensionProperties",
"vkEnumerateDeviceLayerProperties",
"vkEnumerateInstanceExtensionProperties",
......@@ -1185,6 +1187,8 @@ class VkHandle(object):
return "wine_queue_from_handle({0})->host_queue".format(name)
if self.name == "VkSurfaceKHR":
return "wine_surface_from_handle({0})->host_surface".format(name)
if self.name == "VkSwapchainKHR":
return "wine_swapchain_from_handle({0})->host_swapchain".format(name)
if self.is_dispatchable():
LOGGER.error("Unhandled host handle for: {0}".format(self.name))
return None
......
......@@ -1542,6 +1542,47 @@ void wine_vkDestroySurfaceKHR(VkInstance handle, VkSurfaceKHR surface,
free(object);
}
VkResult wine_vkCreateSwapchainKHR(VkDevice device_handle, const VkSwapchainCreateInfoKHR *create_info,
const VkAllocationCallbacks *allocator, VkSwapchainKHR *swapchain_handle)
{
struct wine_swapchain *object, *old_swapchain = wine_swapchain_from_handle(create_info->oldSwapchain);
struct wine_surface *surface = wine_surface_from_handle(create_info->surface);
struct wine_device *device = wine_device_from_handle(device_handle);
VkSwapchainCreateInfoKHR create_info_host = *create_info;
VkResult res;
if (surface) create_info_host.surface = surface->driver_surface;
if (old_swapchain) create_info_host.oldSwapchain = old_swapchain->host_swapchain;
if (!(object = calloc(1, sizeof(*object)))) return VK_ERROR_OUT_OF_HOST_MEMORY;
res = device->funcs.p_vkCreateSwapchainKHR(device->host_device, &create_info_host, NULL, &object->host_swapchain);
if (res != VK_SUCCESS)
{
free(object);
return res;
}
WINE_VK_ADD_NON_DISPATCHABLE_MAPPING(device->phys_dev->instance, object, object->host_swapchain, object);
*swapchain_handle = wine_swapchain_to_handle(object);
return res;
}
void wine_vkDestroySwapchainKHR(VkDevice device_handle, VkSwapchainKHR swapchain_handle,
const VkAllocationCallbacks *allocator)
{
struct wine_device *device = wine_device_from_handle(device_handle);
struct wine_swapchain *swapchain = wine_swapchain_from_handle(swapchain_handle);
if (allocator) FIXME("Support for allocation callbacks not implemented yet\n");
if (!swapchain) return;
device->funcs.p_vkDestroySwapchainKHR(device->host_device, swapchain->host_swapchain, NULL);
WINE_VK_REMOVE_HANDLE_MAPPING(device->phys_dev->instance, swapchain);
free(swapchain);
}
VkResult wine_vkAllocateMemory(VkDevice handle, const VkMemoryAllocateInfo *alloc_info,
const VkAllocationCallbacks *allocator, VkDeviceMemory *ret)
{
......
......@@ -238,6 +238,23 @@ static inline VkSurfaceKHR wine_surface_to_handle(struct wine_surface *surface)
return (VkSurfaceKHR)(uintptr_t)surface;
}
struct wine_swapchain
{
VkSwapchainKHR host_swapchain;
struct wine_vk_mapping mapping;
};
static inline struct wine_swapchain *wine_swapchain_from_handle(VkSwapchainKHR handle)
{
return (struct wine_swapchain *)(uintptr_t)handle;
}
static inline VkSwapchainKHR wine_swapchain_to_handle(struct wine_swapchain *surface)
{
return (VkSwapchainKHR)(uintptr_t)surface;
}
BOOL wine_vk_device_extension_supported(const char *name);
BOOL wine_vk_instance_extension_supported(const char *name);
......
......@@ -25,6 +25,7 @@ VkResult wine_vkCreateDeferredOperationKHR(VkDevice device, const VkAllocationCa
VkResult wine_vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, void *client_ptr);
VkResult wine_vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage);
VkResult wine_vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, void *client_ptr);
VkResult wine_vkCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSwapchainKHR *pSwapchain);
VkResult wine_vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface);
void wine_vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator);
void wine_vkDestroyDebugReportCallbackEXT(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks *pAllocator);
......@@ -33,6 +34,7 @@ void wine_vkDestroyDeferredOperationKHR(VkDevice device, VkDeferredOperationKHR
void wine_vkDestroyDevice(VkDevice device, const VkAllocationCallbacks *pAllocator);
void wine_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator);
void wine_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator);
void wine_vkDestroySwapchainKHR(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks *pAllocator);
VkResult wine_vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
VkResult wine_vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties);
VkResult wine_vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment