winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
November 2023
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
989 discussions
Start a n
N
ew thread
Alexandros Frantzis : winewayland.drv: Set client area subsurface size.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: 4c9c991faea025bf63a24a185daf05f99c486a91 URL:
https://gitlab.winehq.org/wine/wine/-/commit/4c9c991faea025bf63a24a185daf05…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Wed Nov 8 14:00:18 2023 +0200 winewayland.drv: Set client area subsurface size. Use the viewporter Wayland protocol to set the size of the client area subsurface, so that it always covers the client area bounds exactly. This may transiently lead to scaled contents. --- dlls/winewayland.drv/wayland.c | 5 +++++ dlls/winewayland.drv/wayland_surface.c | 33 ++++++++++++++++++++++++++++++++- dlls/winewayland.drv/waylanddrv.h | 1 + 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index 31cd27f7a76..f7119367543 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -154,6 +154,11 @@ static void registry_handle_global(void *data, struct wl_registry *registry, process_wayland.wl_subcompositor = wl_registry_bind(registry, id, &wl_subcompositor_interface, 1); } + else if (strcmp(interface, "wp_viewporter") == 0) + { + process_wayland.wp_viewporter = + wl_registry_bind(registry, id, &wp_viewporter_interface, 1); + } } static void registry_handle_global_remove(void *data, struct wl_registry *registry, diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index f4a64d19ecd..b83709c5a8a 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -477,6 +477,7 @@ static void wayland_surface_reconfigure_client(struct wayland_surface *surface) { struct wayland_window_config *window = &surface->window; int client_x, client_y, x, y; + int client_width, client_height, width, height; if (!surface->client) return; @@ -484,11 +485,32 @@ static void wayland_surface_reconfigure_client(struct wayland_surface *surface) client_x = window->client_rect.left - window->rect.left; client_y = window->client_rect.top - window->rect.top; + client_width = window->client_rect.right - window->client_rect.left; + client_height = window->client_rect.bottom - window->client_rect.top; + wayland_surface_coords_from_window(surface, client_x, client_y, &x, &y); + wayland_surface_coords_from_window(surface, client_width, client_height, + &width, &height); - TRACE("hwnd=%p subsurface=%d,%d\n", surface->hwnd, x, y); + TRACE("hwnd=%p subsurface=%d,%d+%dx%d\n", surface->hwnd, x, y, width, height); wl_subsurface_set_position(surface->client->wl_subsurface, x, y); + + if (surface->client->wp_viewport) + { + if (width != 0 && height != 0) + { + wp_viewport_set_destination(surface->client->wp_viewport, + width, height); + } + else + { + /* We can't have a 0x0 destination, use 1x1 instead. */ + wp_viewport_set_destination(surface->client->wp_viewport, 1, 1); + } + } + + wl_surface_commit(surface->client->wl_surface); } /********************************************************************** @@ -719,6 +741,8 @@ BOOL wayland_client_surface_release(struct wayland_client_surface *client) { if (InterlockedDecrement(&client->ref)) return FALSE; + if (client->wp_viewport) + wp_viewport_destroy(client->wp_viewport); if (client->wl_subsurface) wl_subsurface_destroy(client->wl_subsurface); if (client->wl_surface) @@ -768,6 +792,13 @@ struct wayland_client_surface *wayland_surface_get_client(struct wayland_surface goto err; } + if (process_wayland.wp_viewporter) + { + surface->client->wp_viewport = + wp_viewporter_get_viewport(process_wayland.wp_viewporter, + surface->client->wl_surface); + } + wayland_surface_reconfigure_client(surface); return surface->client; diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 2dc49a2fd4b..00c9112d5de 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -170,6 +170,7 @@ struct wayland_client_surface LONG ref; struct wl_surface *wl_surface; struct wl_subsurface *wl_subsurface; + struct wp_viewport *wp_viewport; }; struct wayland_surface
1
0
0
0
Alexandros Frantzis : winewayland.drv: Set client area subsurface position.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: 65a4789a7c8170a3864b0aa5d89106a8bfba25d9 URL:
https://gitlab.winehq.org/wine/wine/-/commit/65a4789a7c8170a3864b0aa5d89106…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Mon Nov 6 10:40:59 2023 +0200 winewayland.drv: Set client area subsurface position. Set the position of the client area subsurface relative to its parent surface. --- dlls/winewayland.drv/wayland_surface.c | 26 ++++++++++++++++++++++++++ dlls/winewayland.drv/waylanddrv.h | 1 + dlls/winewayland.drv/window.c | 11 +++++++++-- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index cdcee27a042..f4a64d19ecd 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -468,6 +468,29 @@ static void wayland_surface_reconfigure_size(struct wayland_surface *surface, } } +/********************************************************************** + * wayland_surface_reconfigure_client + * + * Reconfigures the subsurface covering the client area. + */ +static void wayland_surface_reconfigure_client(struct wayland_surface *surface) +{ + struct wayland_window_config *window = &surface->window; + int client_x, client_y, x, y; + + if (!surface->client) return; + + /* The offset of the client area origin relatively to the window origin. */ + client_x = window->client_rect.left - window->rect.left; + client_y = window->client_rect.top - window->rect.top; + + wayland_surface_coords_from_window(surface, client_x, client_y, &x, &y); + + TRACE("hwnd=%p subsurface=%d,%d\n", surface->hwnd, x, y); + + wl_subsurface_set_position(surface->client->wl_subsurface, x, y); +} + /********************************************************************** * wayland_surface_reconfigure * @@ -525,6 +548,7 @@ BOOL wayland_surface_reconfigure(struct wayland_surface *surface) wayland_surface_reconfigure_geometry(surface, width, height); wayland_surface_reconfigure_size(surface, width, height); + wayland_surface_reconfigure_client(surface); return TRUE; } @@ -744,6 +768,8 @@ struct wayland_client_surface *wayland_surface_get_client(struct wayland_surface goto err; } + wayland_surface_reconfigure_client(surface); + return surface->client; err: diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 928c2f023eb..2dc49a2fd4b 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -159,6 +159,7 @@ struct wayland_surface_config struct wayland_window_config { RECT rect; + RECT client_rect; enum wayland_surface_config_state state; /* The scale (i.e., normalized dpi) the window is rendering at. */ double scale; diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index 1423164834e..fff3749e9ad 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -45,6 +45,8 @@ struct wayland_win_data struct window_surface *window_surface; /* USER window rectangle relative to win32 parent window client area */ RECT window_rect; + /* USER client rectangle relative to win32 parent window client area */ + RECT client_rect; }; static int wayland_win_data_cmp_rb(const void *key, @@ -68,7 +70,8 @@ static struct rb_tree win_data_rb = { wayland_win_data_cmp_rb }; * Create a data window structure for an existing window. */ static struct wayland_win_data *wayland_win_data_create(HWND hwnd, - const RECT *window_rect) + const RECT *window_rect, + const RECT *client_rect) { struct wayland_win_data *data; struct rb_entry *rb_entry; @@ -83,6 +86,7 @@ static struct wayland_win_data *wayland_win_data_create(HWND hwnd, data->hwnd = hwnd; data->window_rect = *window_rect; + data->client_rect = *client_rect; pthread_mutex_lock(&win_data_mutex); @@ -157,6 +161,7 @@ static void wayland_win_data_get_config(struct wayland_win_data *data, DWORD style; conf->rect = data->window_rect; + conf->client_rect = data->client_rect; style = NtUserGetWindowLongW(data->hwnd, GWL_STYLE); TRACE("window=%s style=%#lx\n", wine_dbgstr_rect(&conf->rect), (long)style); @@ -310,7 +315,8 @@ BOOL WAYLAND_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, hwnd, wine_dbgstr_rect(window_rect), wine_dbgstr_rect(client_rect), wine_dbgstr_rect(visible_rect), insert_after, swp_flags); - if (!data && !(data = wayland_win_data_create(hwnd, window_rect))) return TRUE; + if (!data && !(data = wayland_win_data_create(hwnd, window_rect, client_rect))) + return TRUE; /* Release the dummy surface wine provides for toplevels. */ if (*surface) window_surface_release(*surface); @@ -361,6 +367,7 @@ void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, if (!data) return; data->window_rect = *window_rect; + data->client_rect = *client_rect; if (surface) window_surface_add_ref(surface); if (data->window_surface) window_surface_release(data->window_surface);
1
0
0
0
Alexandros Frantzis : winewayland.drv: Use a client area subsurface as the Vulkan target.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: 9439b3c3ee695ca46ca99fa40f939137dec93514 URL:
https://gitlab.winehq.org/wine/wine/-/commit/9439b3c3ee695ca46ca99fa40f9391…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Tue Nov 7 17:42:05 2023 +0200 winewayland.drv: Use a client area subsurface as the Vulkan target. Since we can't render to parts of surfaces, use a dedicated client area subsurface as the target of Vulkan rendering. --- dlls/winewayland.drv/vulkan.c | 33 +++++++++++++++-- dlls/winewayland.drv/wayland.c | 10 +++++ dlls/winewayland.drv/wayland_surface.c | 67 ++++++++++++++++++++++++++++++++++ dlls/winewayland.drv/waylanddrv.h | 11 ++++++ 4 files changed, 117 insertions(+), 4 deletions(-) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index da1b644f9e5..be7f048f9d3 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -64,7 +64,7 @@ static const struct vulkan_funcs vulkan_funcs; struct wine_vk_surface { - struct wl_surface *client; + struct wayland_client_surface *client; VkSurfaceKHR native; }; @@ -75,7 +75,20 @@ static struct wine_vk_surface *wine_vk_surface_from_handle(VkSurfaceKHR handle) static void wine_vk_surface_destroy(struct wine_vk_surface *wine_vk_surface) { - if (wine_vk_surface->client) wl_surface_destroy(wine_vk_surface->client); + if (wine_vk_surface->client) + { + HWND hwnd = wl_surface_get_user_data(wine_vk_surface->client->wl_surface); + struct wayland_surface *wayland_surface = wayland_surface_lock_hwnd(hwnd); + + if (wayland_client_surface_release(wine_vk_surface->client) && + wayland_surface) + { + wayland_surface->client = NULL; + } + + if (wayland_surface) pthread_mutex_unlock(&wayland_surface->mutex); + } + free(wine_vk_surface); } @@ -166,6 +179,7 @@ static VkResult wayland_vkCreateWin32SurfaceKHR(VkInstance instance, VkResult res; VkWaylandSurfaceCreateInfoKHR create_info_host; struct wine_vk_surface *wine_vk_surface; + struct wayland_surface *wayland_surface; TRACE("%p %p %p %p\n", instance, create_info, allocator, vk_surface); @@ -180,7 +194,18 @@ static VkResult wayland_vkCreateWin32SurfaceKHR(VkInstance instance, goto err; } - wine_vk_surface->client = wl_compositor_create_surface(process_wayland.wl_compositor); + wayland_surface = wayland_surface_lock_hwnd(create_info->hwnd); + if (!wayland_surface) + { + ERR("Failed to find wayland surface 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; + } + + wine_vk_surface->client = wayland_surface_get_client(wayland_surface); + pthread_mutex_unlock(&wayland_surface->mutex); + if (!wine_vk_surface->client) { ERR("Failed to create client surface for hwnd=%p\n", create_info->hwnd); @@ -193,7 +218,7 @@ static VkResult wayland_vkCreateWin32SurfaceKHR(VkInstance instance, create_info_host.pNext = NULL; create_info_host.flags = 0; /* reserved */ create_info_host.display = process_wayland.wl_display; - create_info_host.surface = wine_vk_surface->client; + create_info_host.surface = wine_vk_surface->client->wl_surface; res = pvkCreateWaylandSurfaceKHR(instance, &create_info_host, NULL /* allocator */, diff --git a/dlls/winewayland.drv/wayland.c b/dlls/winewayland.drv/wayland.c index ddb25209804..31cd27f7a76 100644 --- a/dlls/winewayland.drv/wayland.c +++ b/dlls/winewayland.drv/wayland.c @@ -149,6 +149,11 @@ static void registry_handle_global(void *data, struct wl_registry *registry, process_wayland.wp_viewporter = wl_registry_bind(registry, id, &wp_viewporter_interface, 1); } + else if (strcmp(interface, "wl_subcompositor") == 0) + { + process_wayland.wl_subcompositor = + wl_registry_bind(registry, id, &wl_subcompositor_interface, 1); + } } static void registry_handle_global_remove(void *data, struct wl_registry *registry, @@ -249,6 +254,11 @@ BOOL wayland_process_init(void) ERR("Wayland compositor doesn't support wl_shm\n"); return FALSE; } + if (!process_wayland.wl_subcompositor) + { + ERR("Wayland compositor doesn't support wl_subcompositor\n"); + return FALSE; + } wayland_init_display_devices(FALSE); diff --git a/dlls/winewayland.drv/wayland_surface.c b/dlls/winewayland.drv/wayland_surface.c index 8cfefefb969..cdcee27a042 100644 --- a/dlls/winewayland.drv/wayland_surface.c +++ b/dlls/winewayland.drv/wayland_surface.c @@ -687,3 +687,70 @@ void wayland_surface_coords_to_window(struct wayland_surface *surface, *window_x = round(surface_x * surface->window.scale); *window_y = round(surface_y * surface->window.scale); } + +/********************************************************************** + * wayland_client_surface_release + */ +BOOL wayland_client_surface_release(struct wayland_client_surface *client) +{ + if (InterlockedDecrement(&client->ref)) return FALSE; + + if (client->wl_subsurface) + wl_subsurface_destroy(client->wl_subsurface); + if (client->wl_surface) + wl_surface_destroy(client->wl_surface); + + free(client); + + return TRUE; +} + +/********************************************************************** + * wayland_surface_get_client + */ +struct wayland_client_surface *wayland_surface_get_client(struct wayland_surface *surface) +{ + if (surface->client) + { + InterlockedIncrement(&surface->client->ref); + return surface->client; + } + + surface->client = calloc(1, sizeof(*surface->client)); + if (!surface->client) + { + ERR("Failed to allocate space for client surface\n"); + goto err; + } + + surface->client->ref = 1; + + surface->client->wl_surface = + wl_compositor_create_surface(process_wayland.wl_compositor); + if (!surface->client->wl_surface) + { + ERR("Failed to create client wl_surface\n"); + goto err; + } + wl_surface_set_user_data(surface->client->wl_surface, surface->hwnd); + + surface->client->wl_subsurface = + wl_subcompositor_get_subsurface(process_wayland.wl_subcompositor, + surface->client->wl_surface, + surface->wl_surface); + if (!surface->client->wl_subsurface) + { + ERR("Failed to create client wl_subsurface\n"); + goto err; + } + + return surface->client; + +err: + if (surface->client) + { + wayland_client_surface_release(surface->client); + surface->client = NULL; + } + return NULL; +} diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 9bc6aedf356..928c2f023eb 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -111,6 +111,7 @@ struct wayland struct xdg_wm_base *xdg_wm_base; struct wl_shm *wl_shm; struct wp_viewporter *wp_viewporter; + struct wl_subcompositor *wl_subcompositor; struct wayland_seat seat; struct wayland_keyboard keyboard; struct wayland_pointer pointer; @@ -163,6 +164,13 @@ struct wayland_window_config double scale; }; +struct wayland_client_surface +{ + LONG ref; + struct wl_surface *wl_surface; + struct wl_subsurface *wl_subsurface; +}; + struct wayland_surface { HWND hwnd; @@ -175,6 +183,7 @@ struct wayland_surface struct wayland_shm_buffer *latest_window_buffer; BOOL resizing; struct wayland_window_config window; + struct wayland_client_surface *client; }; struct wayland_shm_buffer @@ -226,6 +235,8 @@ void wayland_surface_coords_from_window(struct wayland_surface *surface, void wayland_surface_coords_to_window(struct wayland_surface *surface, double surface_x, double surface_y, int *window_x, int *window_y) DECLSPEC_HIDDEN; +struct wayland_client_surface *wayland_surface_get_client(struct wayland_surface *surface) DECLSPEC_HIDDEN; +BOOL wayland_client_surface_release(struct wayland_client_surface *client) DECLSPEC_HIDDEN; /********************************************************************** * Wayland SHM buffer
1
0
0
0
Alexandros Frantzis : winewayland.drv: Implement vkDestroySurfaceKHR.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: 51dbd708b08564f39fee902846a16918834af195 URL:
https://gitlab.winehq.org/wine/wine/-/commit/51dbd708b08564f39fee902846a169…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Tue Nov 7 13:25:18 2023 +0200 winewayland.drv: Implement vkDestroySurfaceKHR. --- dlls/winewayland.drv/vulkan.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index 15e5edf503b..da1b644f9e5 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -54,6 +54,7 @@ typedef struct VkWaylandSurfaceCreateInfoKHR static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *); static VkResult (*pvkCreateWaylandSurfaceKHR)(VkInstance, const VkWaylandSurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *); static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *); +static void (*pvkDestroySurfaceKHR)(VkInstance, VkSurfaceKHR, const VkAllocationCallbacks *); static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *); static void * (*pvkGetDeviceProcAddr)(VkDevice, const char *); static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *); @@ -224,6 +225,23 @@ static void wayland_vkDestroyInstance(VkInstance instance, pvkDestroyInstance(instance, NULL /* allocator */); } +static void wayland_vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, + const VkAllocationCallbacks *allocator) +{ + struct wine_vk_surface *wine_vk_surface = wine_vk_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"); + + /* vkDestroySurfaceKHR must handle VK_NULL_HANDLE (0) for surface. */ + if (!wine_vk_surface) return; + + pvkDestroySurfaceKHR(instance, wine_vk_surface->native, NULL /* allocator */); + wine_vk_surface_destroy(wine_vk_surface); +} + static VkResult wayland_vkEnumerateInstanceExtensionProperties(const char *layer_name, uint32_t *count, VkExtensionProperties* properties) @@ -317,6 +335,7 @@ static void wine_vk_init(void) LOAD_FUNCPTR(vkCreateInstance); LOAD_FUNCPTR(vkCreateWaylandSurfaceKHR); LOAD_FUNCPTR(vkDestroyInstance); + LOAD_FUNCPTR(vkDestroySurfaceKHR); LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties); LOAD_FUNCPTR(vkGetDeviceProcAddr); LOAD_FUNCPTR(vkGetInstanceProcAddr); @@ -334,6 +353,7 @@ static const struct vulkan_funcs vulkan_funcs = .p_vkCreateInstance = wayland_vkCreateInstance, .p_vkCreateWin32SurfaceKHR = wayland_vkCreateWin32SurfaceKHR, .p_vkDestroyInstance = wayland_vkDestroyInstance, + .p_vkDestroySurfaceKHR = wayland_vkDestroySurfaceKHR, .p_vkEnumerateInstanceExtensionProperties = wayland_vkEnumerateInstanceExtensionProperties, .p_vkGetDeviceProcAddr = wayland_vkGetDeviceProcAddr, .p_vkGetInstanceProcAddr = wayland_vkGetInstanceProcAddr,
1
0
0
0
Alexandros Frantzis : winewayland.drv: Implement vkCreateWin32SurfaceKHR.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: b6e9e8deda5d9ef3cccc81211fdd06a9fc41aeab URL:
https://gitlab.winehq.org/wine/wine/-/commit/b6e9e8deda5d9ef3cccc81211fdd06…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Wed Sep 15 19:08:53 2021 +0300 winewayland.drv: Implement vkCreateWin32SurfaceKHR. Create Win32 VkSurfaceKHR objects which are backed by native Wayland VkSurfaceKHR objects. For now we associate a dummy Wayland surface with the VkSurfaceKHR. --- dlls/winewayland.drv/vulkan.c | 111 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index d22b8401422..15e5edf503b 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -40,7 +40,19 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); #ifdef SONAME_LIBVULKAN +#define VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR 1000006000 + +typedef struct VkWaylandSurfaceCreateInfoKHR +{ + VkStructureType sType; + const void *pNext; + VkWaylandSurfaceCreateFlagsKHR flags; + struct wl_display *display; + struct wl_surface *surface; +} VkWaylandSurfaceCreateInfoKHR; + static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *); +static VkResult (*pvkCreateWaylandSurfaceKHR)(VkInstance, const VkWaylandSurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *); static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *); static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *); static void * (*pvkGetDeviceProcAddr)(VkDevice, const char *); @@ -49,6 +61,23 @@ static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *); static void *vulkan_handle; static const struct vulkan_funcs vulkan_funcs; +struct wine_vk_surface +{ + struct wl_surface *client; + VkSurfaceKHR native; +}; + +static struct wine_vk_surface *wine_vk_surface_from_handle(VkSurfaceKHR handle) +{ + return (struct wine_vk_surface *)(uintptr_t)handle; +} + +static void wine_vk_surface_destroy(struct wine_vk_surface *wine_vk_surface) +{ + if (wine_vk_surface->client) wl_surface_destroy(wine_vk_surface->client); + free(wine_vk_surface); +} + /* Helper function for converting between win32 and Wayland compatible VkInstanceCreateInfo. * Caller is responsible for allocation and cleanup of 'dst'. */ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo *src, @@ -92,6 +121,14 @@ static VkResult wine_vk_instance_convert_create_info(const VkInstanceCreateInfo return VK_SUCCESS; } +static const char *wine_vk_native_fn_name(const char *name) +{ + if (!strcmp(name, "vkCreateWin32SurfaceKHR")) + return "vkCreateWaylandSurfaceKHR"; + + return name; +} + static VkResult wayland_vkCreateInstance(const VkInstanceCreateInfo *create_info, const VkAllocationCallbacks *allocator, VkInstance *instance) @@ -120,6 +157,62 @@ static VkResult wayland_vkCreateInstance(const VkInstanceCreateInfo *create_info return res; } +static VkResult wayland_vkCreateWin32SurfaceKHR(VkInstance instance, + const VkWin32SurfaceCreateInfoKHR *create_info, + const VkAllocationCallbacks *allocator, + VkSurfaceKHR *vk_surface) +{ + VkResult res; + VkWaylandSurfaceCreateInfoKHR create_info_host; + struct wine_vk_surface *wine_vk_surface; + + TRACE("%p %p %p %p\n", instance, create_info, allocator, vk_surface); + + if (allocator) + FIXME("Support for allocation callbacks not implemented yet\n"); + + wine_vk_surface = calloc(1, sizeof(*wine_vk_surface)); + if (!wine_vk_surface) + { + ERR("Failed to allocate memory for wayland vulkan surface\n"); + res = VK_ERROR_OUT_OF_HOST_MEMORY; + goto err; + } + + wine_vk_surface->client = wl_compositor_create_surface(process_wayland.wl_compositor); + if (!wine_vk_surface->client) + { + ERR("Failed to create client surface 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_WAYLAND_SURFACE_CREATE_INFO_KHR; + create_info_host.pNext = NULL; + create_info_host.flags = 0; /* reserved */ + create_info_host.display = process_wayland.wl_display; + create_info_host.surface = wine_vk_surface->client; + + res = pvkCreateWaylandSurfaceKHR(instance, &create_info_host, + NULL /* allocator */, + &wine_vk_surface->native); + if (res != VK_SUCCESS) + { + ERR("Failed to create vulkan wayland surface, res=%d\n", res); + goto err; + } + + *vk_surface = (uintptr_t)wine_vk_surface; + + TRACE("Created surface=0x%s\n", wine_dbgstr_longlong(*vk_surface)); + return VK_SUCCESS; + +err: + if (wine_vk_surface) wine_vk_surface_destroy(wine_vk_surface); + return res; +} + static void wayland_vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *allocator) { @@ -179,6 +272,11 @@ static void *wayland_vkGetDeviceProcAddr(VkDevice device, const char *name) TRACE("%p, %s\n", device, debugstr_a(name)); + /* Do not return the driver function if the corresponding native function + * is not available. */ + if (!pvkGetDeviceProcAddr(device, wine_vk_native_fn_name(name))) + return NULL; + if ((proc_addr = get_vulkan_driver_device_proc_addr(&vulkan_funcs, name))) return proc_addr; @@ -191,12 +289,22 @@ static void *wayland_vkGetInstanceProcAddr(VkInstance instance, const char *name TRACE("%p, %s\n", instance, debugstr_a(name)); + /* Do not return the driver function if the corresponding native function + * is not available. */ + if (!pvkGetInstanceProcAddr(instance, wine_vk_native_fn_name(name))) + return NULL; + if ((proc_addr = get_vulkan_driver_instance_proc_addr(&vulkan_funcs, instance, name))) return proc_addr; return pvkGetInstanceProcAddr(instance, name); } +static VkSurfaceKHR wayland_wine_get_native_surface(VkSurfaceKHR surface) +{ + return wine_vk_surface_from_handle(surface)->native; +} + static void wine_vk_init(void) { if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) @@ -207,6 +315,7 @@ static void wine_vk_init(void) #define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail LOAD_FUNCPTR(vkCreateInstance); + LOAD_FUNCPTR(vkCreateWaylandSurfaceKHR); LOAD_FUNCPTR(vkDestroyInstance); LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties); LOAD_FUNCPTR(vkGetDeviceProcAddr); @@ -223,10 +332,12 @@ fail: static const struct vulkan_funcs vulkan_funcs = { .p_vkCreateInstance = wayland_vkCreateInstance, + .p_vkCreateWin32SurfaceKHR = wayland_vkCreateWin32SurfaceKHR, .p_vkDestroyInstance = wayland_vkDestroyInstance, .p_vkEnumerateInstanceExtensionProperties = wayland_vkEnumerateInstanceExtensionProperties, .p_vkGetDeviceProcAddr = wayland_vkGetDeviceProcAddr, .p_vkGetInstanceProcAddr = wayland_vkGetInstanceProcAddr, + .p_wine_get_native_surface = wayland_wine_get_native_surface, }; /**********************************************************************
1
0
0
0
Alexandros Frantzis : winewayland.drv: Implement vkGetDeviceProcAddr and vkGetInstanceProcAddr.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: 902465f23603586fdb4f601c91618982f4071fe4 URL:
https://gitlab.winehq.org/wine/wine/-/commit/902465f23603586fdb4f601c916189…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Mon Sep 20 10:56:18 2021 +0300 winewayland.drv: Implement vkGetDeviceProcAddr and vkGetInstanceProcAddr. --- dlls/winewayland.drv/vulkan.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index 9b8ee6ee9e2..d22b8401422 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -43,8 +43,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *); static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *); static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *); +static void * (*pvkGetDeviceProcAddr)(VkDevice, const char *); +static void * (*pvkGetInstanceProcAddr)(VkInstance, const char *); static void *vulkan_handle; +static const struct vulkan_funcs vulkan_funcs; /* Helper function for converting between win32 and Wayland compatible VkInstanceCreateInfo. * Caller is responsible for allocation and cleanup of 'dst'. */ @@ -170,6 +173,30 @@ static VkResult wayland_vkEnumerateInstanceExtensionProperties(const char *layer return res; } +static void *wayland_vkGetDeviceProcAddr(VkDevice device, const char *name) +{ + void *proc_addr; + + TRACE("%p, %s\n", device, debugstr_a(name)); + + if ((proc_addr = get_vulkan_driver_device_proc_addr(&vulkan_funcs, name))) + return proc_addr; + + return pvkGetDeviceProcAddr(device, name); +} + +static void *wayland_vkGetInstanceProcAddr(VkInstance instance, const char *name) +{ + void *proc_addr; + + TRACE("%p, %s\n", instance, debugstr_a(name)); + + if ((proc_addr = get_vulkan_driver_instance_proc_addr(&vulkan_funcs, instance, name))) + return proc_addr; + + return pvkGetInstanceProcAddr(instance, name); +} + static void wine_vk_init(void) { if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) @@ -182,6 +209,8 @@ static void wine_vk_init(void) LOAD_FUNCPTR(vkCreateInstance); LOAD_FUNCPTR(vkDestroyInstance); LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties); + LOAD_FUNCPTR(vkGetDeviceProcAddr); + LOAD_FUNCPTR(vkGetInstanceProcAddr); #undef LOAD_FUNCPTR return; @@ -196,6 +225,8 @@ static const struct vulkan_funcs vulkan_funcs = .p_vkCreateInstance = wayland_vkCreateInstance, .p_vkDestroyInstance = wayland_vkDestroyInstance, .p_vkEnumerateInstanceExtensionProperties = wayland_vkEnumerateInstanceExtensionProperties, + .p_vkGetDeviceProcAddr = wayland_vkGetDeviceProcAddr, + .p_vkGetInstanceProcAddr = wayland_vkGetInstanceProcAddr, }; /**********************************************************************
1
0
0
0
Alexandros Frantzis : winewayland.drv: Implement vkDestroyInstance.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: 36a2e6b1f1b4c1fe47d2c4af533c17704a1f2721 URL:
https://gitlab.winehq.org/wine/wine/-/commit/36a2e6b1f1b4c1fe47d2c4af533c17…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Wed Sep 15 18:44:10 2021 +0300 winewayland.drv: Implement vkDestroyInstance. --- dlls/winewayland.drv/vulkan.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index 7f0f5652f97..9b8ee6ee9e2 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -41,6 +41,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); #ifdef SONAME_LIBVULKAN static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *); +static void (*pvkDestroyInstance)(VkInstance, const VkAllocationCallbacks *); static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *); static void *vulkan_handle; @@ -116,6 +117,17 @@ static VkResult wayland_vkCreateInstance(const VkInstanceCreateInfo *create_info return res; } +static void wayland_vkDestroyInstance(VkInstance instance, + const VkAllocationCallbacks *allocator) +{ + TRACE("%p %p\n", instance, allocator); + + if (allocator) + FIXME("Support for allocation callbacks not implemented yet\n"); + + pvkDestroyInstance(instance, NULL /* allocator */); +} + static VkResult wayland_vkEnumerateInstanceExtensionProperties(const char *layer_name, uint32_t *count, VkExtensionProperties* properties) @@ -168,6 +180,7 @@ static void wine_vk_init(void) #define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail LOAD_FUNCPTR(vkCreateInstance); + LOAD_FUNCPTR(vkDestroyInstance); LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties); #undef LOAD_FUNCPTR @@ -181,6 +194,7 @@ fail: static const struct vulkan_funcs vulkan_funcs = { .p_vkCreateInstance = wayland_vkCreateInstance, + .p_vkDestroyInstance = wayland_vkDestroyInstance, .p_vkEnumerateInstanceExtensionProperties = wayland_vkEnumerateInstanceExtensionProperties, };
1
0
0
0
Alexandros Frantzis : winewayland.drv: Implement vkCreateInstance.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: bd0d88261d3d8f9436d3a1c53ef7345640893ae5 URL:
https://gitlab.winehq.org/wine/wine/-/commit/bd0d88261d3d8f9436d3a1c53ef734…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Wed Sep 15 18:41:32 2021 +0300 winewayland.drv: Implement vkCreateInstance. Create a Vulkan instance, ensuring we use the proper (Wayland) SurfaceKHR extension when forwarding the request to the native Vulkan platform. --- dlls/winewayland.drv/vulkan.c | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index 81d109acd8f..7f0f5652f97 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -25,6 +25,7 @@ #include "config.h" #include <dlfcn.h> +#include <stdlib.h> #include "waylanddrv.h" #include "wine/debug.h" @@ -39,10 +40,82 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); #ifdef SONAME_LIBVULKAN +static VkResult (*pvkCreateInstance)(const VkInstanceCreateInfo *, const VkAllocationCallbacks *, VkInstance *); static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *); static void *vulkan_handle; +/* Helper function for converting between win32 and Wayland 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 = 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 Wayland 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_wayland_surface"; + else + enabled_extensions[i] = src->ppEnabledExtensionNames[i]; + } + dst->ppEnabledExtensionNames = enabled_extensions; + dst->enabledExtensionCount = src->enabledExtensionCount; + } + + return VK_SUCCESS; +} + +static VkResult wayland_vkCreateInstance(const VkInstanceCreateInfo *create_info, + const VkAllocationCallbacks *allocator, + VkInstance *instance) +{ + VkInstanceCreateInfo create_info_host; + VkResult res; + + TRACE("create_info %p, allocator %p, instance %p\n", create_info, allocator, instance); + + if (allocator) + FIXME("Support for allocation callbacks not implemented yet\n"); + + /* 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) + { + ERR("Failed to convert instance create info, res=%d\n", res); + return res; + } + + res = pvkCreateInstance(&create_info_host, NULL /* allocator */, instance); + + free((void *)create_info_host.ppEnabledExtensionNames); + return res; +} + static VkResult wayland_vkEnumerateInstanceExtensionProperties(const char *layer_name, uint32_t *count, VkExtensionProperties* properties) @@ -94,6 +167,7 @@ static void wine_vk_init(void) } #define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail + LOAD_FUNCPTR(vkCreateInstance); LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties); #undef LOAD_FUNCPTR @@ -106,6 +180,7 @@ fail: static const struct vulkan_funcs vulkan_funcs = { + .p_vkCreateInstance = wayland_vkCreateInstance, .p_vkEnumerateInstanceExtensionProperties = wayland_vkEnumerateInstanceExtensionProperties, };
1
0
0
0
Alexandros Frantzis : winewayland.drv: Implement vkEnumerateInstanceExtensionProperties.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: a9ed32b0bf6566ecce948e7d95927ffb5a9cdefc URL:
https://gitlab.winehq.org/wine/wine/-/commit/a9ed32b0bf6566ecce948e7d95927f…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Mon Sep 20 10:34:43 2021 +0300 winewayland.drv: Implement vkEnumerateInstanceExtensionProperties. Return the native instance extension properties, substituting VK_KHR_wayland_surface for VK_KHR_win32_surface. --- dlls/winewayland.drv/vulkan.c | 62 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c index f807256c9e4..81d109acd8f 100644 --- a/dlls/winewayland.drv/vulkan.c +++ b/dlls/winewayland.drv/vulkan.c @@ -39,15 +39,75 @@ WINE_DEFAULT_DEBUG_CHANNEL(vulkan); #ifdef SONAME_LIBVULKAN +static VkResult (*pvkEnumerateInstanceExtensionProperties)(const char *, uint32_t *, VkExtensionProperties *); + static void *vulkan_handle; +static VkResult wayland_vkEnumerateInstanceExtensionProperties(const char *layer_name, + uint32_t *count, + VkExtensionProperties* properties) +{ + unsigned int i; + VkResult res; + + TRACE("layer_name %s, count %p, properties %p\n", debugstr_a(layer_name), count, properties); + + /* 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; + } + + /* 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; + + for (i = 0; i < *count; i++) + { + /* For now the only wayland extension we need to fixup. Long-term we may need an array. */ + if (!strcmp(properties[i].extensionName, "VK_KHR_wayland_surface")) + { + TRACE("Substituting VK_KHR_wayland_surface for VK_KHR_win32_surface\n"); + + snprintf(properties[i].extensionName, sizeof(properties[i].extensionName), + VK_KHR_WIN32_SURFACE_EXTENSION_NAME); + properties[i].specVersion = VK_KHR_WIN32_SURFACE_SPEC_VERSION; + } + } + + TRACE("Returning %u extensions.\n", *count); + return res; +} + static void wine_vk_init(void) { if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) + { ERR("Failed to load %s.\n", SONAME_LIBVULKAN); + return; + } + +#define LOAD_FUNCPTR(f) if (!(p##f = dlsym(vulkan_handle, #f))) goto fail + LOAD_FUNCPTR(vkEnumerateInstanceExtensionProperties); +#undef LOAD_FUNCPTR + + return; + +fail: + dlclose(vulkan_handle); + vulkan_handle = NULL; } -static const struct vulkan_funcs vulkan_funcs; +static const struct vulkan_funcs vulkan_funcs = +{ + .p_vkEnumerateInstanceExtensionProperties = wayland_vkEnumerateInstanceExtensionProperties, +}; /********************************************************************** * WAYLAND_wine_get_vulkan_driver
1
0
0
0
Alexandros Frantzis : winewayland.drv: Add skeleton Vulkan driver.
by Alexandre Julliard
17 Nov '23
17 Nov '23
Module: wine Branch: master Commit: f6e800172b11a25ed8bb3a62e060559ccf3f97e2 URL:
https://gitlab.winehq.org/wine/wine/-/commit/f6e800172b11a25ed8bb3a62e06055…
Author: Alexandros Frantzis <alexandros.frantzis(a)collabora.com> Date: Wed Sep 15 18:33:07 2021 +0300 winewayland.drv: Add skeleton Vulkan driver. --- dlls/winewayland.drv/Makefile.in | 1 + dlls/winewayland.drv/vulkan.c | 80 ++++++++++++++++++++++++++++++++++ dlls/winewayland.drv/waylanddrv.h | 1 + dlls/winewayland.drv/waylanddrv_main.c | 3 +- 4 files changed, 84 insertions(+), 1 deletion(-) diff --git a/dlls/winewayland.drv/Makefile.in b/dlls/winewayland.drv/Makefile.in index 95ddbcedf8b..fa2beaad79c 100644 --- a/dlls/winewayland.drv/Makefile.in +++ b/dlls/winewayland.drv/Makefile.in @@ -8,6 +8,7 @@ SOURCES = \ dllmain.c \ version.rc \ viewporter.xml \ + vulkan.c \ wayland.c \ wayland_keyboard.c \ wayland_output.c \ diff --git a/dlls/winewayland.drv/vulkan.c b/dlls/winewayland.drv/vulkan.c new file mode 100644 index 00000000000..f807256c9e4 --- /dev/null +++ b/dlls/winewayland.drv/vulkan.c @@ -0,0 +1,80 @@ +/* WAYLANDDRV Vulkan implementation + * + * Copyright 2017 Roderick Colenbrander + * Copyright 2021 Alexandros Frantzis + * + * 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 <dlfcn.h> + +#include "waylanddrv.h" +#include "wine/debug.h" + +#define VK_NO_PROTOTYPES +#define WINE_VK_HOST + +#include "wine/vulkan.h" +#include "wine/vulkan_driver.h" + +WINE_DEFAULT_DEBUG_CHANNEL(vulkan); + +#ifdef SONAME_LIBVULKAN + +static void *vulkan_handle; + +static void wine_vk_init(void) +{ + if (!(vulkan_handle = dlopen(SONAME_LIBVULKAN, RTLD_NOW))) + ERR("Failed to load %s.\n", SONAME_LIBVULKAN); +} + +static const struct vulkan_funcs vulkan_funcs; + +/********************************************************************** + * WAYLAND_wine_get_vulkan_driver + */ +const struct vulkan_funcs *WAYLAND_wine_get_vulkan_driver(UINT version) +{ + static pthread_once_t init_once = PTHREAD_ONCE_INIT; + + if (version != WINE_VULKAN_DRIVER_VERSION) + { + ERR("version mismatch, vulkan wants %u but driver has %u\n", version, WINE_VULKAN_DRIVER_VERSION); + return NULL; + } + + pthread_once(&init_once, wine_vk_init); + if (vulkan_handle) + return &vulkan_funcs; + + return NULL; +} + +#else /* No vulkan */ + +const struct vulkan_funcs *WAYLAND_wine_get_vulkan_driver(UINT version) +{ + ERR("Wine was built without Vulkan support.\n"); + return NULL; +} + +#endif /* SONAME_LIBVULKAN */ diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 6bb30447f30..9bc6aedf356 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -297,5 +297,6 @@ void WAYLAND_WindowPosChanged(HWND hwnd, HWND insert_after, UINT swp_flags, BOOL WAYLAND_WindowPosChanging(HWND hwnd, HWND insert_after, UINT swp_flags, const RECT *window_rect, const RECT *client_rect, RECT *visible_rect, struct window_surface **surface) DECLSPEC_HIDDEN; +const struct vulkan_funcs *WAYLAND_wine_get_vulkan_driver(UINT version) DECLSPEC_HIDDEN; #endif /* __WINE_WAYLANDDRV_H */ diff --git a/dlls/winewayland.drv/waylanddrv_main.c b/dlls/winewayland.drv/waylanddrv_main.c index 7151d7b931a..be898f9e2c3 100644 --- a/dlls/winewayland.drv/waylanddrv_main.c +++ b/dlls/winewayland.drv/waylanddrv_main.c @@ -38,7 +38,8 @@ static const struct user_driver_funcs waylanddrv_funcs = .pUpdateDisplayDevices = WAYLAND_UpdateDisplayDevices, .pWindowMessage = WAYLAND_WindowMessage, .pWindowPosChanged = WAYLAND_WindowPosChanged, - .pWindowPosChanging = WAYLAND_WindowPosChanging + .pWindowPosChanging = WAYLAND_WindowPosChanging, + .pwine_get_vulkan_driver = WAYLAND_wine_get_vulkan_driver, }; static NTSTATUS waylanddrv_unix_init(void *arg)
1
0
0
0
← Newer
1
...
39
40
41
42
43
44
45
...
99
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
Results per page:
10
25
50
100
200