Skip to content
Snippets Groups Projects
Commit 9288310a authored by Leandro Ribeiro's avatar Leandro Ribeiro Committed by Alexandros Frantzis
Browse files

winewayland.drv: Implement cross-process vkCreateSwapchainKHR.


Introduce the remote swapchain object, currently with a stub
implementation, that we are going to use for cross-process Vulkan
rendering.

Signed-off-by: default avatarLeandro Ribeiro <leandro.ribeiro@collabora.com>
Signed-off-by: default avatarAlexandros Frantzis <alexandros.frantzis@collabora.com>
parent 2a53d78a
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ C_SRCS = \
registry.c \
unicode.c \
vulkan.c \
vulkan_remote.c \
wayland.c \
wayland_buffer_queue.c \
wayland_cursor.c \
......
......@@ -35,6 +35,7 @@
#include "wine/vulkan.h"
#include "wine/vulkan_driver.h"
#include "vulkan_remote.h"
#include <dlfcn.h>
#include <stdlib.h>
......@@ -135,6 +136,8 @@ struct wine_vk_swapchain
VkSwapchainKHR native_vk_swapchain;
VkExtent2D extent;
BOOL valid;
/* Only used for cross-process Vulkan rendering apps. */
struct wayland_remote_vk_swapchain *remote_vk_swapchain;
};
static inline void wine_vk_list_add(struct wl_list *list, struct wl_list *link)
......@@ -192,6 +195,9 @@ static void wine_vk_swapchain_destroy(struct wine_vk_swapchain *wine_vk_swapchai
if (wine_vk_swapchain->wayland_surface)
wayland_surface_unref_glvk(wine_vk_swapchain->wayland_surface);
if (wine_vk_swapchain->remote_vk_swapchain)
wayland_remote_vk_swapchain_destroy(wine_vk_swapchain->remote_vk_swapchain);
free(wine_vk_swapchain);
}
......@@ -537,6 +543,7 @@ static VkResult wayland_vkCreateSwapchainKHR(VkDevice device,
VkSwapchainKHR *swapchain)
{
VkResult res;
struct wine_vk_device *wine_vk_device;
struct wine_vk_surface *wine_vk_surface;
struct wine_vk_swapchain *wine_vk_swapchain;
VkSwapchainCreateInfoKHR info = *create_info;
......@@ -552,6 +559,10 @@ static VkResult wayland_vkCreateSwapchainKHR(VkDevice device,
if (info.imageExtent.height == 0)
info.imageExtent.height = 1;
wine_vk_device = wine_vk_device_from_handle(device);
if (!wine_vk_device)
return VK_ERROR_DEVICE_LOST;
wine_vk_surface = wine_vk_surface_from_handle(info.surface);
if (!wine_vk_surface || !__atomic_load_n(&wine_vk_surface->valid, __ATOMIC_SEQ_CST))
RETURN_VK_ERROR_SURFACE_LOST_KHR;
......@@ -569,9 +580,33 @@ static VkResult wayland_vkCreateSwapchainKHR(VkDevice device,
wine_vk_swapchain->hwnd = wine_vk_surface->hwnd;
if (wine_vk_surface->wayland_surface)
{
wayland_surface_create_or_ref_glvk(wine_vk_surface->wayland_surface);
if (!wayland_surface_create_or_ref_glvk(wine_vk_surface->wayland_surface))
{
ERR("Failed to create or ref vulkan surface owned by " \
"wine_vk_surface=%p\n", wine_vk_surface);
res = VK_ERROR_OUT_OF_HOST_MEMORY;
goto err;
}
wine_vk_swapchain->wayland_surface = wine_vk_surface->wayland_surface;
}
else
{
if (!wine_vk_device->supports_remote_vulkan)
{
ERR("Failed to create remote Vulkan swapchain, required extensions " \
"not supported by VkDevice %p\n", wine_vk_device->dev);
res = VK_ERROR_OUT_OF_HOST_MEMORY;
goto err;
}
wine_vk_swapchain->remote_vk_swapchain =
wayland_remote_vk_swapchain_create(wine_vk_swapchain->hwnd);
if (!wine_vk_swapchain->remote_vk_swapchain)
{
res = VK_ERROR_OUT_OF_HOST_MEMORY;
goto err;
}
}
wine_vk_swapchain->native_vk_swapchain = *swapchain;
wine_vk_swapchain->extent = info.imageExtent;
wine_vk_swapchain->valid = TRUE;
......
/* WAYLANDDRV Vulkan remote implementation
*
* Copyright 2022 Leandro Ribeiro
*
* 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
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include "waylanddrv.h"
#include "wine/debug.h"
#include <stdlib.h>
WINE_DEFAULT_DEBUG_CHANNEL(vulkan);
struct wayland_remote_vk_swapchain
{
};
void wayland_remote_vk_swapchain_destroy(struct wayland_remote_vk_swapchain *swapchain)
{
free(swapchain);
}
struct wayland_remote_vk_swapchain *wayland_remote_vk_swapchain_create(HWND hwnd)
{
struct wayland_remote_vk_swapchain *swapchain;
swapchain = calloc(1, sizeof(*swapchain));
if (!swapchain)
{
ERR("Failed to allocate memory\n");
goto err;
}
return swapchain;
err:
ERR("Failed to create remote swapchain\n");
if (swapchain)
wayland_remote_vk_swapchain_destroy(swapchain);
return NULL;
}
/* WAYLANDDRV Vulkan remote implementation
*
* Copyright 2022 Leandro Ribeiro
*
* 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
*/
#ifndef __WINE_WAYLANDDRV_VULKAN_REMOTE_H
#define __WINE_WAYLANDDRV_VULKAN_REMOTE_H
#include "config.h"
#include "waylanddrv.h"
#define VK_NO_PROTOTYPES
#define WINE_VK_HOST
#include "wine/vulkan.h"
struct wayland_remote_vk_swapchain;
struct wayland_remote_vk_swapchain *wayland_remote_vk_swapchain_create(HWND hwnd) DECLSPEC_HIDDEN;
void wayland_remote_vk_swapchain_destroy(struct wayland_remote_vk_swapchain *swapchain) DECLSPEC_HIDDEN;
#endif /* __WINE_WAYLANDDRV_VULKAN_REMOTE_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment