winemac.drv: Pass the CAMetalLayer to MoltenVK.
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@codeweavers.com> Signed-off-by: Ken Thomases <ken@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
bfb1908055
commit
606424bbbc
|
@ -3796,6 +3796,18 @@ macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_devi
|
||||||
return (macdrv_metal_view)metalView;
|
return (macdrv_metal_view)metalView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macdrv_metal_layer macdrv_view_get_metal_layer(macdrv_metal_view v)
|
||||||
|
{
|
||||||
|
WineMetalView* view = (WineMetalView*)v;
|
||||||
|
__block CAMetalLayer* layer;
|
||||||
|
|
||||||
|
OnMainThread(^{
|
||||||
|
layer = (CAMetalLayer*)view.layer;
|
||||||
|
});
|
||||||
|
|
||||||
|
return (macdrv_metal_layer)layer;
|
||||||
|
}
|
||||||
|
|
||||||
void macdrv_view_release_metal_view(macdrv_metal_view v)
|
void macdrv_view_release_metal_view(macdrv_metal_view v)
|
||||||
{
|
{
|
||||||
WineMetalView* view = (WineMetalView*)v;
|
WineMetalView* view = (WineMetalView*)v;
|
||||||
|
|
|
@ -140,6 +140,7 @@
|
||||||
#ifdef HAVE_METAL_METAL_H
|
#ifdef HAVE_METAL_METAL_H
|
||||||
typedef struct macdrv_opaque_metal_device* macdrv_metal_device;
|
typedef struct macdrv_opaque_metal_device* macdrv_metal_device;
|
||||||
typedef struct macdrv_opaque_metal_view* macdrv_metal_view;
|
typedef struct macdrv_opaque_metal_view* macdrv_metal_view;
|
||||||
|
typedef struct macdrv_opaque_metal_layer* macdrv_metal_layer;
|
||||||
#endif
|
#endif
|
||||||
typedef struct macdrv_opaque_status_item* macdrv_status_item;
|
typedef struct macdrv_opaque_status_item* macdrv_status_item;
|
||||||
struct macdrv_event;
|
struct macdrv_event;
|
||||||
|
@ -587,6 +588,7 @@ extern void macdrv_set_window_color_key(macdrv_window w, CGFloat keyRed, CGFloat
|
||||||
extern macdrv_metal_device macdrv_create_metal_device(void) DECLSPEC_HIDDEN;
|
extern macdrv_metal_device macdrv_create_metal_device(void) DECLSPEC_HIDDEN;
|
||||||
extern void macdrv_release_metal_device(macdrv_metal_device d) DECLSPEC_HIDDEN;
|
extern void macdrv_release_metal_device(macdrv_metal_device d) DECLSPEC_HIDDEN;
|
||||||
extern macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d) DECLSPEC_HIDDEN;
|
extern macdrv_metal_view macdrv_view_create_metal_view(macdrv_view v, macdrv_metal_device d) DECLSPEC_HIDDEN;
|
||||||
|
extern macdrv_metal_layer macdrv_view_get_metal_layer(macdrv_metal_view v) DECLSPEC_HIDDEN;
|
||||||
extern void macdrv_view_release_metal_view(macdrv_metal_view v) DECLSPEC_HIDDEN;
|
extern void macdrv_view_release_metal_view(macdrv_metal_view v) DECLSPEC_HIDDEN;
|
||||||
#endif
|
#endif
|
||||||
extern int macdrv_get_view_backing_size(macdrv_view v, int backing_size[2]) DECLSPEC_HIDDEN;
|
extern int macdrv_get_view_backing_size(macdrv_view v, int backing_size[2]) DECLSPEC_HIDDEN;
|
||||||
|
|
|
@ -282,7 +282,7 @@ static VkResult macdrv_vkCreateWin32SurfaceKHR(VkInstance instance,
|
||||||
create_info_host.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
create_info_host.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
|
||||||
create_info_host.pNext = NULL;
|
create_info_host.pNext = NULL;
|
||||||
create_info_host.flags = 0; /* reserved */
|
create_info_host.flags = 0; /* reserved */
|
||||||
create_info_host.pView = mac_surface->view;
|
create_info_host.pView = macdrv_view_get_metal_layer(mac_surface->view);
|
||||||
|
|
||||||
res = pvkCreateMacOSSurfaceMVK(instance, &create_info_host, NULL /* allocator */, &mac_surface->surface);
|
res = pvkCreateMacOSSurfaceMVK(instance, &create_info_host, NULL /* allocator */, &mac_surface->surface);
|
||||||
if (res != VK_SUCCESS)
|
if (res != VK_SUCCESS)
|
||||||
|
|
Loading…
Reference in New Issue