[PATCH v2] winex11.drv: Handle Vulkan surface creation with NULL hwnd.

Rémi Bernon rbernon at codeweavers.com
Sat May 1 02:21:42 CDT 2021


A few style nitpicks, otherwise it looks good to me.

On 4/30/21 4:42 PM, Paul Gofman wrote:
> @@ -292,8 +297,10 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance,
>           return VK_ERROR_OUT_OF_HOST_MEMORY;
>   
>       x11_surface->ref = 1;
> +    x11_surface->hwnd = create_info->hwnd;
> +    x11_surface->window = x11_surface->hwnd ? create_client_window(create_info->hwnd, &default_visual)
> +            : create_dummy_client_window();

Indentation feels weird here, I think it would be better if ':' was 
aligned with the '?' above.

>   
> -    x11_surface->window = create_client_window(create_info->hwnd, &default_visual);
>       if (!x11_surface->window)
>       {
>           ERR("Failed to allocate client window for hwnd=%p\n", create_info->hwnd);
> @@ -316,13 +323,16 @@ static VkResult X11DRV_vkCreateWin32SurfaceKHR(VkInstance instance,
>           goto err;
>       }
>   
> -    EnterCriticalSection(&context_section);
> -    if (!XFindContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char **)&prev))
> +    if (x11_surface->hwnd)
>       {
> -        wine_vk_surface_release(prev);
> +        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);
>       }
> -    XSaveContext(gdi_display, (XID)create_info->hwnd, vulkan_hwnd_context, (char *)wine_vk_surface_grab(x11_surface));
> -    LeaveCriticalSection(&context_section);
>   
>       *surface = (uintptr_t)x11_surface;
>   
> @@ -456,6 +466,15 @@ static VkResult X11DRV_vkGetPhysicalDevicePresentRectanglesKHR(VkPhysicalDevice
>   
>       TRACE("%p, 0x%s, %p, %p\n", phys_dev, wine_dbgstr_longlong(surface), count, rects);
>   
> +    if (!x11_surface->hwnd)
> +    {
> +        if (rects)
> +            return VK_ERROR_SURFACE_LOST_KHR;
> +
> +        *count = 1;
> +        return VK_SUCCESS;
> +    }
> +
>       return pvkGetPhysicalDevicePresentRectanglesKHR(phys_dev, x11_surface->surface, count, rects);
>   }
>   
> @@ -485,6 +504,9 @@ static VkResult X11DRV_vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevic
>   
>       TRACE("%p, 0x%s, %p\n", phys_dev, wine_dbgstr_longlong(surface), capabilities);
>   
> +    if (!x11_surface->hwnd)
> +        return VK_ERROR_SURFACE_LOST_KHR;
> +
>       return pvkGetPhysicalDeviceSurfaceCapabilitiesKHR(phys_dev, x11_surface->surface, capabilities);
>   }
>   
> diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
> index baaa30d74e3..1f0d636a142 100644
> --- a/dlls/winex11.drv/window.c
> +++ b/dlls/winex11.drv/window.c
> @@ -1466,6 +1466,26 @@ static Window get_dummy_parent(void)
>   }
>   
>   
> +/**********************************************************************
> + *		create_dummy_window

Should probably be create_dummy_client_window

> + */
> +Window create_dummy_client_window(void)
> +{
> +    XSetWindowAttributes attr;
> +
> +    attr.colormap = default_colormap;
> +    attr.bit_gravity = NorthWestGravity;
> +    attr.win_gravity = NorthWestGravity;
> +    attr.backing_store = NotUseful;
> +    attr.border_pixel = 0;
> +
> +    return XCreateWindow( gdi_display,
> +                                       get_dummy_parent(),
> +                                       0, 0, 1, 1, 0, default_visual.depth, InputOutput,
> +                                       default_visual.visual, CWBitGravity | CWWinGravity |
> +                                       CWBackingStore | CWColormap | CWBorderPixel, &attr );

Here as well, indentation is pretty weird.
-- 
Rémi Bernon <rbernon at codeweavers.com>



More information about the wine-devel mailing list