[PATCH 1/2] winemac.drv: Pass the CAMetalLayer to MoltenVK.

Ken Thomases ken at codeweavers.com
Mon Dec 16 18:47:17 CST 2019


On Dec 13, 2019, at 10:57 AM, Chip Davis <cdavis at codeweavers.com> wrote:
> 
> It isn't safe to access the view object from any thread other than the
> main thread. In fact, if you try to call vkCreateMacOSSurfaceMVK() from
> any other thread, MoltenVK prints out a big, scary warning telling you
> not to do this! Instead, get the layer from the view ourselves and pass
> that to MoltenVK. Recent versions of MoltenVK can accept either the view
> or the layer.
> 
> Signed-off-by: Chip Davis <cdavis at codeweavers.com>
> ---
> dlls/winemac.drv/cocoa_window.m | 14 ++++++++++++++
> dlls/winemac.drv/macdrv_cocoa.h |  2 ++
> dlls/winemac.drv/vulkan.c       |  2 +-
> 3 files changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/dlls/winemac.drv/cocoa_window.m b/dlls/winemac.drv/cocoa_window.m
> index 877653ea007..6ac30843025 100644
> --- a/dlls/winemac.drv/cocoa_window.m
> +++ b/dlls/winemac.drv/cocoa_window.m
> @@ -3796,6 +3796,20 @@ macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_devi
>     return (macdrv_metal_view)metalView;
> }
> 
> +macdrv_metal_layer macdrv_view_get_metal_layer(macdrv_metal_view v)
> +{
> +    WineMetalView* view = (WineMetalView*)v;
> +    __block CAMetalLayer* layer;
> +
> +    if ([NSThread isMainThread])
> +        layer = (CAMetalLayer*)view.layer;

This will never be called from the main thread.

> +    else OnMainThread(^{
> +        layer = (CAMetalLayer*)view.layer;
> +    });
> +
> +    return (macdrv_metal_layer)layer;
> +}
> +
> void macdrv_view_release_metal_view(macdrv_metal_view v)
> {
>     WineMetalView* view = (WineMetalView*)v;





More information about the wine-devel mailing list