I think this dates from a time where every window had its own window surface, and unless I'm missing something this isn't needed anymore. My intention is to refactor the client surfaces, so that they can be manipulated directly from win32u, and unify GL/VK client surfaces. This would make the code simpler, in preparation for that.
-- v2: winemac: Get rid of now unnecessary child cocoa views. winemac: Use the new client surface views for GL rendering. winemac: Create new client views with each VK/GL surface.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/macdrv.h | 11 ++++ dlls/winemac.drv/opengl.c | 72 ++++---------------------- dlls/winemac.drv/vulkan.c | 90 +++------------------------------ dlls/winemac.drv/window.c | 104 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 131 insertions(+), 146 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 9c76fe78c38..522b8d95ee8 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -180,6 +180,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p macdrv_window cocoa_window; macdrv_view cocoa_view; macdrv_view client_cocoa_view; + macdrv_view client_view; struct window_rects rects; /* window rects in monitor DPI, relative to parent client area */ int pixel_format; /* pixel format for GL */ HANDLE drag_event; /* event to signal that Cocoa-driven window dragging has ended */ @@ -191,6 +192,16 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p unsigned int minimized : 1; /* is window minimized? */ };
+struct macdrv_client_surface +{ + struct client_surface client; + macdrv_view cocoa_view; + macdrv_metal_device metal_device; + macdrv_metal_view metal_view; +}; + +extern struct macdrv_client_surface *macdrv_client_surface_create(HWND hwnd); + extern struct macdrv_win_data *get_win_data(HWND hwnd); extern void release_win_data(struct macdrv_win_data *data); extern void init_win_context(void); diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 172b0d60226..3675d49eeb5 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -43,7 +43,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
- struct gl_info { char *glExtensions;
@@ -96,7 +95,6 @@ static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER; static void *opengl_handle; static const struct opengl_funcs *funcs; static const struct opengl_driver_funcs macdrv_driver_funcs; -static const struct client_surface_funcs macdrv_client_surface_funcs; static const struct opengl_drawable_funcs macdrv_surface_funcs; static const struct opengl_drawable_funcs macdrv_pbuffer_funcs;
@@ -1471,7 +1469,7 @@ static BOOL create_context(struct macdrv_context *context, CGLContextObj share,
static BOOL macdrv_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_drawable **drawable) { - struct client_surface *client; + struct macdrv_client_surface *client; struct macdrv_win_data *data; struct gl_drawable *gl;
@@ -1486,9 +1484,9 @@ static BOOL macdrv_surface_create(HWND hwnd, HDC hdc, int format, struct opengl_ data->pixel_format = format; release_win_data(data);
- if (!(client = client_surface_create(sizeof(*client), &macdrv_client_surface_funcs, hwnd))) return FALSE; - gl = opengl_drawable_create(sizeof(*gl), &macdrv_surface_funcs, format, client); - client_surface_release(client); + if (!(client = macdrv_client_surface_create(hwnd))) return FALSE; + gl = opengl_drawable_create(sizeof(*gl), &macdrv_surface_funcs, format, &client->client); + client_surface_release(&client->client); if (!gl) return FALSE;
*drawable = &gl->base; @@ -1500,22 +1498,6 @@ static void macdrv_surface_destroy(struct opengl_drawable *base) TRACE("drawable %s\n", debugstr_opengl_drawable(base)); }
-/********************************************************************** - * mark_contexts_for_moved_view - */ -static void mark_contexts_for_moved_view(macdrv_view view) -{ - struct macdrv_context *context; - - pthread_mutex_lock(&context_mutex); - LIST_FOR_EACH_ENTRY(context, &context_list, struct macdrv_context, entry) - { - if (context->draw_view == view) - InterlockedExchange(&context->view_moved, TRUE); - } - pthread_mutex_unlock(&context_mutex); -} - /********************************************************************** * sync_context_rect */ @@ -1525,7 +1507,7 @@ static BOOL sync_context_rect(struct macdrv_context *context) RECT rect; struct macdrv_win_data *data = get_win_data(context->draw_hwnd);
- if (data && data->client_cocoa_view == context->draw_view) + if (data && data->client_view == context->draw_view) { if (InterlockedCompareExchange(&context->view_moved, FALSE, TRUE)) { @@ -2391,7 +2373,7 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl }
context->draw_hwnd = hwnd; - context->draw_view = data->client_cocoa_view; + context->draw_view = data->client_view; context->draw_rect = data->rects.client; OffsetRect(&context->draw_rect, -data->rects.visible.left, -data->rects.visible.top); NtUserGetClientRect(hwnd, &context->draw_rect_win_dpi, NtUserGetDpiForWindow(hwnd)); @@ -2414,9 +2396,9 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl HWND hwnd = read->base.client->hwnd; if ((data = get_win_data(hwnd))) { - if (data->client_cocoa_view != context->draw_view) + if (data->client_view != context->draw_view) { - context->read_view = data->client_cocoa_view; + context->read_view = data->client_view; context->read_rect = data->rects.client; OffsetRect(&context->read_rect, -data->rects.visible.left, -data->rects.visible.top); } @@ -2904,7 +2886,7 @@ static BOOL macdrv_surface_swap(struct opengl_drawable *base) return FALSE; }
- if (context && context->draw_view == data->client_cocoa_view) + if (context && context->draw_view == data->client_view) match = TRUE;
release_win_data(data); @@ -2934,42 +2916,6 @@ static const struct opengl_driver_funcs macdrv_driver_funcs = .p_pbuffer_bind = macdrv_pbuffer_bind, };
-static void macdrv_client_surface_destroy(struct client_surface *client) -{ - TRACE("%s\n", debugstr_client_surface(client)); -} - -static void macdrv_client_surface_detach(struct client_surface *client) -{ -} - -static void macdrv_client_surface_update(struct client_surface *client) -{ - struct macdrv_win_data *data = get_win_data(client->hwnd); - - TRACE("%s\n", debugstr_client_surface(client)); - - if (data->client_cocoa_view && data->pixel_format) - { - TRACE("GL view %p changed position; marking contexts\n", data->client_cocoa_view); - mark_contexts_for_moved_view(data->client_cocoa_view); - } - - release_win_data(data); -} - -static void macdrv_client_surface_present(struct client_surface *client, HDC hdc) -{ -} - -static const struct client_surface_funcs macdrv_client_surface_funcs = -{ - .destroy = macdrv_client_surface_destroy, - .detach = macdrv_client_surface_detach, - .update = macdrv_client_surface_update, - .present = macdrv_client_surface_present, -}; - static const struct opengl_drawable_funcs macdrv_surface_funcs = { .destroy = macdrv_surface_destroy, diff --git a/dlls/winemac.drv/vulkan.c b/dlls/winemac.drv/vulkan.c index cfdac1acdde..c67b007705a 100644 --- a/dlls/winemac.drv/vulkan.c +++ b/dlls/winemac.drv/vulkan.c @@ -49,18 +49,6 @@ typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; typedef VkFlags VkMetalSurfaceCreateFlagsEXT; #define VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT 1000217000
-struct wine_vk_surface -{ - struct client_surface client; - macdrv_metal_device device; - macdrv_metal_view view; -}; - -static struct wine_vk_surface *impl_from_client_surface(struct client_surface *client) -{ - return CONTAINING_RECORD(client, struct wine_vk_surface, client); -} - typedef struct VkMacOSSurfaceCreateInfoMVK { VkStructureType sType; @@ -80,47 +68,19 @@ typedef struct VkMetalSurfaceCreateInfoEXT static VkResult (*pvkCreateMacOSSurfaceMVK)(VkInstance, const VkMacOSSurfaceCreateInfoMVK*, const VkAllocationCallbacks *, VkSurfaceKHR *); static VkResult (*pvkCreateMetalSurfaceEXT)(VkInstance, const VkMetalSurfaceCreateInfoEXT*, const VkAllocationCallbacks *, VkSurfaceKHR *);
-static const struct client_surface_funcs macdrv_vulkan_surface_funcs; static const struct vulkan_driver_funcs macdrv_vulkan_driver_funcs;
static VkResult macdrv_vulkan_surface_create(HWND hwnd, const struct vulkan_instance *instance, VkSurfaceKHR *handle, struct client_surface **client) { VkResult res; - struct wine_vk_surface *surface; - struct macdrv_win_data *data; + struct macdrv_client_surface *surface;
TRACE("%p %p %p %p\n", hwnd, instance, handle, client);
- if (!(data = get_win_data(hwnd))) - { - FIXME("DC for window %p of other process: not implemented\n", hwnd); - return VK_ERROR_INCOMPATIBLE_DRIVER; - } - - if (!(surface = client_surface_create(sizeof(*surface), &macdrv_vulkan_surface_funcs, hwnd))) - { - release_win_data(data); - return VK_ERROR_OUT_OF_HOST_MEMORY; - } - - surface->device = macdrv_create_metal_device(); - if (!surface->device) - { - ERR("Failed to allocate Metal device for hwnd=%p\n", hwnd); - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto err; - } - - surface->view = macdrv_view_create_metal_view(data->client_cocoa_view, surface->device); - if (!surface->view) - { - ERR("Failed to allocate Metal view for hwnd=%p\n", hwnd); - - /* VK_KHR_win32_surface only allows out of host and device memory as errors. */ - res = VK_ERROR_OUT_OF_HOST_MEMORY; - goto err; - } + if (!(surface = macdrv_client_surface_create(hwnd))) return VK_ERROR_OUT_OF_HOST_MEMORY; + if (!(surface->metal_device = macdrv_create_metal_device())) goto err; + if (!(surface->metal_view = macdrv_view_create_metal_view(surface->cocoa_view, surface->metal_device))) goto err;
if (pvkCreateMetalSurfaceEXT) { @@ -128,7 +88,7 @@ static VkResult macdrv_vulkan_surface_create(HWND hwnd, const struct vulkan_inst create_info_host.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; create_info_host.pNext = NULL; create_info_host.flags = 0; /* reserved */ - create_info_host.pLayer = macdrv_view_get_metal_layer(surface->view); + create_info_host.pLayer = macdrv_view_get_metal_layer(surface->metal_view);
res = pvkCreateMetalSurfaceEXT(instance->host.instance, &create_info_host, NULL /* allocator */, handle); } @@ -138,7 +98,7 @@ static VkResult macdrv_vulkan_surface_create(HWND hwnd, const struct vulkan_inst create_info_host.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; create_info_host.pNext = NULL; create_info_host.flags = 0; /* reserved */ - create_info_host.pView = macdrv_view_get_metal_layer(surface->view); + create_info_host.pView = macdrv_view_get_metal_layer(surface->metal_view);
res = pvkCreateMacOSSurfaceMVK(instance->host.instance, &create_info_host, NULL /* allocator */, handle); } @@ -148,41 +108,13 @@ static VkResult macdrv_vulkan_surface_create(HWND hwnd, const struct vulkan_inst goto err; }
- release_win_data(data); - *client = &surface->client; - TRACE("Created surface=0x%s, client=%p\n", wine_dbgstr_longlong(*handle), *client); return VK_SUCCESS;
err: client_surface_release(&surface->client); - release_win_data(data); - return res; -} - -static void macdrv_vulkan_surface_destroy(struct client_surface *client) -{ - struct wine_vk_surface *surface = impl_from_client_surface(client); - - TRACE("%s\n", debugstr_client_surface(client)); - - if (surface->view) - macdrv_view_release_metal_view(surface->view); - if (surface->device) - macdrv_release_metal_device(surface->device); -} - -static void macdrv_vulkan_surface_detach(struct client_surface *client) -{ -} - -static void macdrv_vulkan_surface_update(struct client_surface *client) -{ -} - -static void macdrv_vulkan_surface_present(struct client_surface *client, HDC hdc) -{ + return VK_ERROR_INCOMPATIBLE_DRIVER; }
static VkBool32 macdrv_vkGetPhysicalDeviceWin32PresentationSupportKHR(VkPhysicalDevice phys_dev, @@ -198,14 +130,6 @@ static const char *macdrv_get_host_surface_extension(void) return pvkCreateMetalSurfaceEXT ? "VK_EXT_metal_surface" : "VK_MVK_macos_surface"; }
-static const struct client_surface_funcs macdrv_vulkan_surface_funcs = -{ - .destroy = macdrv_vulkan_surface_destroy, - .detach = macdrv_vulkan_surface_detach, - .update = macdrv_vulkan_surface_update, - .present = macdrv_vulkan_surface_present, -}; - static const struct vulkan_driver_funcs macdrv_vulkan_driver_funcs = { .p_vulkan_surface_create = macdrv_vulkan_surface_create, diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index c9a4fcd5060..a0a97ac2f7a 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1295,6 +1295,110 @@ static void perform_window_command(HWND hwnd, unsigned int style_any, unsigned i NtUserPostMessage(hwnd, WM_SYSCOMMAND, command, 0); }
+static struct macdrv_client_surface *impl_from_client_surface(struct client_surface *client) +{ + return CONTAINING_RECORD(client, struct macdrv_client_surface, client); +} + +static void macdrv_client_surface_destroy(struct client_surface *client) +{ + struct macdrv_client_surface *surface = impl_from_client_surface(client); + + TRACE("%s\n", debugstr_client_surface(client)); + + if (surface->metal_view) macdrv_view_release_metal_view(surface->metal_view); + if (surface->metal_device) macdrv_release_metal_device(surface->metal_device); +} + +static void macdrv_client_surface_detach(struct client_surface *client) +{ + struct macdrv_client_surface *surface = impl_from_client_surface(client); + + TRACE("%s\n", debugstr_client_surface(client)); + + if (surface->cocoa_view) + { + struct macdrv_win_data *data; + + if ((data = get_win_data(client->hwnd))) + { + if (data->client_view == surface->cocoa_view) + data->client_view = NULL; + release_win_data(data); + } + + macdrv_dispose_view(surface->cocoa_view); + } +} + +static void macdrv_client_surface_update(struct client_surface *client) +{ + struct macdrv_client_surface *surface = impl_from_client_surface(client); + HWND hwnd = client->hwnd, toplevel = NtUserGetAncestor(hwnd, GA_ROOT); + struct macdrv_win_data *data; + RECT rect; + + TRACE("%s\n", debugstr_client_surface(client)); + + NtUserGetClientRect(hwnd, &rect, NtUserGetWinMonitorDpi(hwnd, MDT_RAW_DPI)); + NtUserMapWindowPoints(hwnd, toplevel, (POINT *)&rect, 2, NtUserGetWinMonitorDpi(toplevel, MDT_RAW_DPI)); + + if (!(data = get_win_data(toplevel))) return; + OffsetRect(&rect, data->rects.client.left - data->rects.visible.left, data->rects.client.top - data->rects.visible.top); + macdrv_set_view_frame(surface->cocoa_view, cgrect_from_rect(rect)); + macdrv_set_view_superview(surface->cocoa_view, toplevel == hwnd ? NULL : data->client_view, data->cocoa_window, NULL, NULL); + release_win_data(data); +} + +static void macdrv_client_surface_present(struct client_surface *client, HDC hdc) +{ + struct macdrv_client_surface *surface = impl_from_client_surface(client); + struct macdrv_win_data *data; + + TRACE("%s\n", debugstr_client_surface(client)); + + if (!(data = get_win_data(surface->client.hwnd))) return; + if (data->client_view != surface->cocoa_view) + { + if (data->client_view) macdrv_set_view_hidden(data->client_view, TRUE); + macdrv_set_view_hidden(surface->cocoa_view, FALSE); + data->client_view = surface->cocoa_view; + } + release_win_data(data); +} + +static const struct client_surface_funcs macdrv_client_surface_funcs = +{ + .destroy = macdrv_client_surface_destroy, + .detach = macdrv_client_surface_detach, + .update = macdrv_client_surface_update, + .present = macdrv_client_surface_present, +}; + +struct macdrv_client_surface *macdrv_client_surface_create(HWND hwnd) +{ + HWND toplevel = NtUserGetAncestor(hwnd, GA_ROOT); + struct macdrv_client_surface *surface; + struct macdrv_win_data *data; + RECT rect; + + NtUserGetClientRect(hwnd, &rect, NtUserGetWinMonitorDpi(hwnd, MDT_RAW_DPI)); + NtUserMapWindowPoints(hwnd, toplevel, (POINT *)&rect, 2, NtUserGetWinMonitorDpi(toplevel, MDT_RAW_DPI)); + + if (!(data = get_win_data(toplevel))) return FALSE; + surface = client_surface_create(sizeof(*surface), &macdrv_client_surface_funcs, hwnd); + surface->cocoa_view = macdrv_create_view(cgrect_from_rect(rect)); + macdrv_set_view_hidden(surface->cocoa_view, TRUE); + release_win_data(data); + + if (surface) + { + macdrv_client_surface_update(&surface->client); + macdrv_client_surface_present(&surface->client, 0); + } + + return surface; +}
/********************************************************************** * SetDesktopWindow (MACDRV.@)
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/macdrv.h | 5 ++ dlls/winemac.drv/opengl.c | 125 +++++--------------------------------- dlls/winemac.drv/window.c | 5 -- 3 files changed, 20 insertions(+), 115 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 522b8d95ee8..065f38b728f 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -200,6 +200,11 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p macdrv_metal_view metal_view; };
+static inline struct macdrv_client_surface *impl_from_client_surface(struct client_surface *client) +{ + return CONTAINING_RECORD(client, struct macdrv_client_surface, client); +} + extern struct macdrv_client_surface *macdrv_client_surface_create(HWND hwnd);
extern struct macdrv_win_data *get_win_data(HWND hwnd); diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index 3675d49eeb5..7a20ce16a7f 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -58,24 +58,19 @@ static struct gl_info gl_info;
struct macdrv_context { - struct list entry; int format; GLint renderer_id; macdrv_opengl_context context; CGLContextObj cglcontext; HWND draw_hwnd; macdrv_view draw_view; - RECT draw_rect; - RECT draw_rect_win_dpi; CGLPBufferObj draw_pbuffer; GLenum draw_pbuffer_face; GLint draw_pbuffer_level; + HWND read_hwnd; macdrv_view read_view; - RECT read_rect; CGLPBufferObj read_pbuffer; int swap_interval; - LONG view_moved; - UINT major; };
struct gl_drawable @@ -89,9 +84,6 @@ static struct gl_drawable *impl_from_opengl_drawable(struct opengl_drawable *bas return CONTAINING_RECORD(base, struct gl_drawable, base); }
-static struct list context_list = LIST_INIT(context_list); -static pthread_mutex_t context_mutex = PTHREAD_MUTEX_INITIALIZER; - static void *opengl_handle; static const struct opengl_funcs *funcs; static const struct opengl_driver_funcs macdrv_driver_funcs; @@ -1459,7 +1451,6 @@ static BOOL create_context(struct macdrv_context *context, CGLContextObj share, RtlSetLastWin32Error(ERROR_INVALID_OPERATION); return FALSE; } - context->major = major; context->swap_interval = INT_MIN;
TRACE("created context %p/%p/%p\n", context, context->context, context->cglcontext); @@ -1498,41 +1489,6 @@ static void macdrv_surface_destroy(struct opengl_drawable *base) TRACE("drawable %s\n", debugstr_opengl_drawable(base)); }
-/********************************************************************** - * sync_context_rect - */ -static BOOL sync_context_rect(struct macdrv_context *context) -{ - BOOL ret = FALSE; - RECT rect; - struct macdrv_win_data *data = get_win_data(context->draw_hwnd); - - if (data && data->client_view == context->draw_view) - { - if (InterlockedCompareExchange(&context->view_moved, FALSE, TRUE)) - { - rect = data->rects.client; - OffsetRect(&rect, -data->rects.visible.left, -data->rects.visible.top); - if (!EqualRect(&context->draw_rect, &rect)) - { - context->draw_rect = rect; - ret = TRUE; - } - } - - NtUserGetClientRect(context->draw_hwnd, &rect, NtUserGetDpiForWindow(context->draw_hwnd)); - if (!EqualRect(&context->draw_rect_win_dpi, &rect)) - { - context->draw_rect_win_dpi = rect; - ret = TRUE; - } - } - - release_win_data(data); - return ret; -} - - /********************************************************************** * make_context_current */ @@ -1544,16 +1500,14 @@ static void make_context_current(struct macdrv_context *context, BOOL read)
if (read) { + if (context->read_hwnd) NtUserGetClientRect(context->read_hwnd, &view_rect, NtUserGetDpiForWindow(context->read_hwnd)); view = context->read_view; - view_rect = context->read_rect; pbuffer = context->read_pbuffer; } else { - sync_context_rect(context); - + if (context->draw_hwnd) NtUserGetClientRect(context->draw_hwnd, &view_rect, NtUserGetDpiForWindow(context->draw_hwnd)); view = context->draw_view; - view_rect = context->draw_rect_win_dpi; pbuffer = context->draw_pbuffer; }
@@ -2300,10 +2254,6 @@ static BOOL macdrv_context_create(int format, void *shared, const int *attrib_li return FALSE; }
- pthread_mutex_lock(&context_mutex); - list_add_tail(&context_list, &context->entry); - pthread_mutex_unlock(&context_mutex); - *private = context; return TRUE; } @@ -2352,7 +2302,6 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl { struct gl_drawable *draw = impl_from_opengl_drawable(draw_base), *read = impl_from_opengl_drawable(read_base); struct macdrv_context *context = private; - struct macdrv_win_data *data;
TRACE("draw %s, read %s, context %p\n", debugstr_opengl_drawable(draw_base), debugstr_opengl_drawable(read_base), private);
@@ -2363,47 +2312,28 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl return TRUE; }
+ context->read_hwnd = context->draw_hwnd = NULL; + context->read_view = context->draw_view = NULL; + context->read_pbuffer = context->draw_pbuffer = NULL; + if (draw->base.client) { - HWND hwnd = draw->base.client->hwnd; - if (!(data = get_win_data(hwnd))) - { - FIXME("draw DC for window %p of other process: not implemented\n", hwnd); - return FALSE; - } - - context->draw_hwnd = hwnd; - context->draw_view = data->client_view; - context->draw_rect = data->rects.client; - OffsetRect(&context->draw_rect, -data->rects.visible.left, -data->rects.visible.top); - NtUserGetClientRect(hwnd, &context->draw_rect_win_dpi, NtUserGetDpiForWindow(hwnd)); - context->draw_pbuffer = NULL; - release_win_data(data); + struct macdrv_client_surface *client = impl_from_client_surface(draw->base.client); + context->draw_hwnd = draw->base.client->hwnd; + context->draw_view = client->cocoa_view; } else { - context->draw_hwnd = NULL; - context->draw_view = NULL; context->draw_pbuffer = draw->pbuffer; }
- context->read_view = NULL; - context->read_pbuffer = NULL; if (read != draw) { if (read->base.client) { - HWND hwnd = read->base.client->hwnd; - if ((data = get_win_data(hwnd))) - { - if (data->client_view != context->draw_view) - { - context->read_view = data->client_view; - context->read_rect = data->rects.client; - OffsetRect(&context->read_rect, -data->rects.visible.left, -data->rects.visible.top); - } - release_win_data(data); - } + struct macdrv_client_surface *client = impl_from_client_surface(read->base.client); + context->read_hwnd = read->base.client->hwnd; + context->read_view = client->cocoa_view; } else { @@ -2411,9 +2341,8 @@ static BOOL macdrv_make_current(struct opengl_drawable *draw_base, struct opengl } }
- TRACE("making context current with draw_view %p %s draw_pbuffer %p read_view %p %s read_pbuffer %p format %u\n", - context->draw_view, wine_dbgstr_rect(&context->draw_rect), context->draw_pbuffer, - context->read_view, wine_dbgstr_rect(&context->read_rect), context->read_pbuffer, context->format); + TRACE("making context current with draw_view %p draw_pbuffer %p read_view %p read_pbuffer %p format %u\n", + context->draw_view, context->draw_pbuffer, context->read_view, context->read_pbuffer, context->format);
make_context_current(context, FALSE); NtCurrentTeb()->glReserved2 = context; @@ -2849,10 +2778,6 @@ static BOOL macdrv_context_destroy(void *private)
TRACE("deleting context %p/%p/%p\n", context, context->context, context->cglcontext);
- pthread_mutex_lock(&context_mutex); - list_remove(&context->entry); - pthread_mutex_unlock(&context_mutex); - macdrv_dispose_opengl_context(context->context); free(context); return TRUE; @@ -2873,30 +2798,10 @@ static void *macdrv_get_proc_address(const char *name) static BOOL macdrv_surface_swap(struct opengl_drawable *base) { struct macdrv_context *context = NtCurrentTeb()->glReserved2; - struct macdrv_win_data *data; - HWND hwnd = base->client->hwnd; - BOOL match = FALSE;
TRACE("%s context %p/%p/%p\n", debugstr_opengl_drawable(base), context, (context ? context->context : NULL), (context ? context->cglcontext : NULL));
- if (!(data = get_win_data(hwnd))) - { - RtlSetLastWin32Error(ERROR_INVALID_HANDLE); - return FALSE; - } - - if (context && context->draw_view == data->client_view) - match = TRUE; - - release_win_data(data); - - if (!match) - { - FIXME("current context %p doesn't match; can't swap\n", context); - return FALSE; - } - macdrv_flush_opengl_context(context->context); return TRUE; } diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index a0a97ac2f7a..d6426915a3e 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1295,11 +1295,6 @@ static void perform_window_command(HWND hwnd, unsigned int style_any, unsigned i NtUserPostMessage(hwnd, WM_SYSCOMMAND, command, 0); }
-static struct macdrv_client_surface *impl_from_client_surface(struct client_surface *client) -{ - return CONTAINING_RECORD(client, struct macdrv_client_surface, client); -} - static void macdrv_client_surface_destroy(struct client_surface *client) { struct macdrv_client_surface *surface = impl_from_client_surface(client);
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/macdrv.h | 2 - dlls/winemac.drv/window.c | 319 +++++--------------------------------- 2 files changed, 42 insertions(+), 279 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 065f38b728f..9b545cbf29c 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -178,8 +178,6 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p { HWND hwnd; /* hwnd that this private data belongs to */ macdrv_window cocoa_window; - macdrv_view cocoa_view; - macdrv_view client_cocoa_view; macdrv_view client_view; struct window_rects rects; /* window rects in monitor DPI, relative to parent client area */ int pixel_format; /* pixel format for GL */ diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index d6426915a3e..5fa90223004 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -231,36 +231,6 @@ macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen) }
-/*********************************************************************** - * macdrv_get_cocoa_view - * - * Return the Cocoa view associated with a window - */ -macdrv_view macdrv_get_cocoa_view(HWND hwnd) -{ - struct macdrv_win_data *data = get_win_data(hwnd); - macdrv_view ret = data ? data->cocoa_view : NULL; - - release_win_data(data); - return ret; -} - - -/*********************************************************************** - * macdrv_get_client_cocoa_view - * - * Return the Cocoa view associated with a window's client area - */ -macdrv_view macdrv_get_client_cocoa_view(HWND hwnd) -{ - struct macdrv_win_data *data = get_win_data(hwnd); - macdrv_view ret = data ? data->client_cocoa_view : NULL; - - release_win_data(data); - return ret; -} - - /*********************************************************************** * set_cocoa_window_properties * @@ -474,27 +444,6 @@ static void sync_window_min_max_info(HWND hwnd) }
-/********************************************************************** - * create_client_cocoa_view - * - * Create the Cocoa view for a window's client area - */ -static void create_client_cocoa_view(struct macdrv_win_data *data) -{ - RECT rect = data->rects.client; - OffsetRect(&rect, -data->rects.visible.left, -data->rects.visible.top); - - if (data->client_cocoa_view) - macdrv_set_view_frame(data->client_cocoa_view, cgrect_from_rect(rect)); - else - { - data->client_cocoa_view = macdrv_create_view(cgrect_from_rect(rect)); - macdrv_set_view_hidden(data->client_cocoa_view, FALSE); - } - macdrv_set_view_superview(data->client_cocoa_view, data->cocoa_view, data->cocoa_window, NULL, NULL); -} - - /********************************************************************** * create_cocoa_window * @@ -535,7 +484,6 @@ static void create_cocoa_window(struct macdrv_win_data *data)
data->cocoa_window = macdrv_create_cocoa_window(&wf, frame, data->hwnd, thread_data->queue); if (!data->cocoa_window) goto done; - create_client_cocoa_view(data);
set_cocoa_window_properties(data);
@@ -572,71 +520,6 @@ static void destroy_cocoa_window(struct macdrv_win_data *data) }
-/********************************************************************** - * create_cocoa_view - * - * Create the Cocoa view for a given Windows child window - */ -static void create_cocoa_view(struct macdrv_win_data *data) -{ - BOOL equal = EqualRect(&data->rects.window, &data->rects.client); - CGRect frame = cgrect_from_rect(data->rects.window); - - data->shaped = FALSE; - data->rects.visible = data->rects.window; - - TRACE("creating %p window %s whole %s client %s\n", data->hwnd, wine_dbgstr_rect(&data->rects.window), - wine_dbgstr_rect(&data->rects.visible), wine_dbgstr_rect(&data->rects.client)); - - if (!equal) - data->cocoa_view = macdrv_create_view(frame); - create_client_cocoa_view(data); - if (equal) - { - data->cocoa_view = data->client_cocoa_view; - macdrv_set_view_hidden(data->cocoa_view, TRUE); - macdrv_set_view_frame(data->cocoa_view, frame); - } -} - - -/********************************************************************** - * destroy_cocoa_view - * - * Destroy the Cocoa view for a given window. - */ -static void destroy_cocoa_view(struct macdrv_win_data *data) -{ - if (!data->cocoa_view) return; - - TRACE("win %p Cocoa view %p\n", data->hwnd, data->cocoa_view); - - if (data->cocoa_view != data->client_cocoa_view) - macdrv_dispose_view(data->cocoa_view); - data->cocoa_view = NULL; - data->on_screen = FALSE; -} - - -/*********************************************************************** - * set_cocoa_view_parent - */ -static void set_cocoa_view_parent(struct macdrv_win_data *data, HWND parent) -{ - struct macdrv_win_data *parent_data = get_win_data(parent); - macdrv_window cocoa_window = parent_data ? parent_data->cocoa_window : NULL; - macdrv_view superview = parent_data ? parent_data->client_cocoa_view : NULL; - - TRACE("win %p/%p parent %p/%p\n", data->hwnd, data->cocoa_view, parent, cocoa_window ? (void*)cocoa_window : (void*)superview); - - if (!cocoa_window && !superview) - WARN("hwnd %p new parent %p has no Cocoa window or view in this process\n", data->hwnd, parent); - - macdrv_set_view_superview(data->cocoa_view, superview, cocoa_window, NULL, NULL); - release_win_data(parent_data); -} - - /*********************************************************************** * macdrv_create_win_data * @@ -668,16 +551,10 @@ static struct macdrv_win_data *macdrv_create_win_data(HWND hwnd, const struct wi hwnd, data->cocoa_window, wine_dbgstr_rect(&data->rects.window), wine_dbgstr_rect(&data->rects.visible), wine_dbgstr_rect(&data->rects.client)); } - else - { - create_cocoa_view(data); - TRACE("win %p/%p window %s whole %s client %s\n", - hwnd, data->cocoa_view, wine_dbgstr_rect(&data->rects.window), - wine_dbgstr_rect(&data->rects.visible), wine_dbgstr_rect(&data->rects.client)); - - set_cocoa_view_parent(data, parent); - }
+ TRACE("win %p/%p window %s whole %s client %s\n", + hwnd, data->cocoa_window, wine_dbgstr_rect(&data->rects.window), + wine_dbgstr_rect(&data->rects.visible), wine_dbgstr_rect(&data->rects.client)); return data; }
@@ -753,51 +630,41 @@ static void set_focus(HWND hwnd, BOOL raise) */ static void show_window(struct macdrv_win_data *data) { - if (data->cocoa_window) - { - HWND prev = NULL; - HWND next = NULL; - macdrv_window prev_window = NULL; - macdrv_window next_window = NULL; - BOOL activate = FALSE; - GUITHREADINFO info; - - /* find window that this one must be after */ - prev = NtUserGetWindowRelative(data->hwnd, GW_HWNDPREV); - while (prev && !((NtUserGetWindowLongW(prev, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && - (prev_window = macdrv_get_cocoa_window(prev, TRUE)))) - prev = NtUserGetWindowRelative(prev, GW_HWNDPREV); - if (!prev_window) - { - /* find window that this one must be before */ - next = NtUserGetWindowRelative(data->hwnd, GW_HWNDNEXT); - while (next && !((NtUserGetWindowLongW(next, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && - (next_window = macdrv_get_cocoa_window(next, TRUE)))) - next = NtUserGetWindowRelative(next, GW_HWNDNEXT); - } + HWND prev = NULL; + HWND next = NULL; + macdrv_window prev_window = NULL; + macdrv_window next_window = NULL; + BOOL activate = FALSE; + GUITHREADINFO info;
- TRACE("win %p/%p below %p/%p above %p/%p\n", - data->hwnd, data->cocoa_window, prev, prev_window, next, next_window); + /* find window that this one must be after */ + prev = NtUserGetWindowRelative(data->hwnd, GW_HWNDPREV); + while (prev && !((NtUserGetWindowLongW(prev, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && + (prev_window = macdrv_get_cocoa_window(prev, TRUE)))) + prev = NtUserGetWindowRelative(prev, GW_HWNDPREV); + if (!prev_window) + { + /* find window that this one must be before */ + next = NtUserGetWindowRelative(data->hwnd, GW_HWNDNEXT); + while (next && !((NtUserGetWindowLongW(next, GWL_STYLE) & (WS_VISIBLE | WS_MINIMIZE)) == WS_VISIBLE && + (next_window = macdrv_get_cocoa_window(next, TRUE)))) + next = NtUserGetWindowRelative(next, GW_HWNDNEXT); + }
- if (!prev_window) - activate = activate_on_focus_time && (NtGetTickCount() - activate_on_focus_time < 2000); - macdrv_order_cocoa_window(data->cocoa_window, prev_window, next_window, activate); - data->on_screen = TRUE; + TRACE("win %p/%p below %p/%p above %p/%p\n", + data->hwnd, data->cocoa_window, prev, prev_window, next, next_window);
- info.cbSize = sizeof(info); - if (NtUserGetGUIThreadInfo(NtUserGetWindowThread(data->hwnd, NULL), &info) && info.hwndFocus && - (data->hwnd == info.hwndFocus || NtUserIsChild(data->hwnd, info.hwndFocus))) - set_focus(info.hwndFocus, FALSE); - if (activate) - activate_on_focus_time = 0; - } - else - { - TRACE("win %p/%p showing view\n", data->hwnd, data->cocoa_view); + if (!prev_window) + activate = activate_on_focus_time && (NtGetTickCount() - activate_on_focus_time < 2000); + macdrv_order_cocoa_window(data->cocoa_window, prev_window, next_window, activate); + data->on_screen = TRUE;
- macdrv_set_view_hidden(data->cocoa_view, FALSE); - data->on_screen = TRUE; - } + info.cbSize = sizeof(info); + if (NtUserGetGUIThreadInfo(NtUserGetWindowThread(data->hwnd, NULL), &info) && info.hwndFocus && + (data->hwnd == info.hwndFocus || NtUserIsChild(data->hwnd, info.hwndFocus))) + set_focus(info.hwndFocus, FALSE); + if (activate) + activate_on_focus_time = 0; }
@@ -810,56 +677,10 @@ static void hide_window(struct macdrv_win_data *data)
if (data->cocoa_window) macdrv_hide_cocoa_window(data->cocoa_window); - else - macdrv_set_view_hidden(data->cocoa_view, TRUE); data->on_screen = FALSE; }
-/*********************************************************************** - * sync_window_z_order - */ -static void sync_window_z_order(struct macdrv_win_data *data) -{ - if (data->cocoa_view) - { - HWND parent = NtUserGetAncestor(data->hwnd, GA_PARENT); - macdrv_view superview = macdrv_get_client_cocoa_view(parent); - macdrv_window window = NULL; - HWND prev; - HWND next = NULL; - macdrv_view prev_view = NULL; - macdrv_view next_view = NULL; - - if (!superview) - { - window = macdrv_get_cocoa_window(parent, FALSE); - if (!window) - WARN("hwnd %p/%p parent %p has no Cocoa window or view in this process\n", data->hwnd, data->cocoa_view, parent); - } - - /* find window that this one must be after */ - prev = NtUserGetWindowRelative(data->hwnd, GW_HWNDPREV); - while (prev && !(prev_view = macdrv_get_cocoa_view(prev))) - prev = NtUserGetWindowRelative(prev, GW_HWNDPREV); - if (!prev_view) - { - /* find window that this one must be before */ - next = NtUserGetWindowRelative(data->hwnd, GW_HWNDNEXT); - while (next && !(next_view = macdrv_get_cocoa_view(next))) - next = NtUserGetWindowRelative(next, GW_HWNDNEXT); - } - - TRACE("win %p/%p below %p/%p above %p/%p\n", - data->hwnd, data->cocoa_view, prev, prev_view, next, next_view); - - macdrv_set_view_superview(data->cocoa_view, superview, window, prev_view, next_view); - } - else if (data->on_screen) - show_window(data); -} - - /*********************************************************************** * get_region_data * @@ -927,21 +748,6 @@ RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp) }
-/*********************************************************************** - * sync_client_view_position - */ -static void sync_client_view_position(struct macdrv_win_data *data) -{ - if (data->cocoa_view != data->client_cocoa_view) - { - RECT rect = data->rects.client; - OffsetRect(&rect, -data->rects.visible.left, -data->rects.visible.top); - macdrv_set_view_frame(data->client_cocoa_view, cgrect_from_rect(rect)); - TRACE("win %p/%p client %s\n", data->hwnd, data->client_cocoa_view, wine_dbgstr_rect(&rect)); - } -} - - /*********************************************************************** * sync_window_position * @@ -950,7 +756,6 @@ static void sync_client_view_position(struct macdrv_win_data *data) static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags, const struct window_rects *old_rects) { CGRect frame = cgrect_from_rect(data->rects.visible); - BOOL force_z_order = FALSE;
if (data->cocoa_window) { @@ -962,32 +767,6 @@ static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags, c
macdrv_set_cocoa_window_frame(data->cocoa_window, &frame); } - else - { - BOOL were_equal = (data->cocoa_view == data->client_cocoa_view); - BOOL now_equal = EqualRect(&data->rects.visible, &data->rects.client); - - if (were_equal && !now_equal) - { - data->cocoa_view = macdrv_create_view(frame); - macdrv_set_view_hidden(data->cocoa_view, !data->on_screen); - macdrv_set_view_superview(data->client_cocoa_view, data->cocoa_view, NULL, NULL, NULL); - macdrv_set_view_hidden(data->client_cocoa_view, FALSE); - force_z_order = TRUE; - } - else if (!were_equal && now_equal) - { - macdrv_dispose_view(data->cocoa_view); - data->cocoa_view = data->client_cocoa_view; - macdrv_set_view_hidden(data->cocoa_view, !data->on_screen); - macdrv_set_view_frame(data->cocoa_view, frame); - force_z_order = TRUE; - } - else if (!EqualRect(&data->rects.visible, &old_rects->visible)) - macdrv_set_view_frame(data->cocoa_view, frame); - } - - sync_client_view_position(data);
if (old_rects && (IsRectEmpty(&old_rects->window) != IsRectEmpty(&data->rects.window) || @@ -995,12 +774,11 @@ static void sync_window_position(struct macdrv_win_data *data, UINT swp_flags, c old_rects->window.top - old_rects->visible.top != data->rects.window.top - data->rects.visible.top)) sync_window_region(data, (HRGN)1);
- TRACE("win %p/%p whole_rect %s frame %s\n", data->hwnd, - data->cocoa_window ? (void*)data->cocoa_window : (void*)data->cocoa_view, + TRACE("win %p/%p whole_rect %s frame %s\n", data->hwnd, data->cocoa_window, wine_dbgstr_rect(&data->rects.visible), wine_dbgstr_cgrect(frame));
- if (force_z_order || !(swp_flags & SWP_NOZORDER) || (swp_flags & SWP_SHOWWINDOW)) - sync_window_z_order(data); + if (data->cocoa_window && data->on_screen && (!(swp_flags & SWP_NOZORDER) || (swp_flags & SWP_SHOWWINDOW))) + show_window(data); }
@@ -1476,8 +1254,6 @@ void macdrv_DestroyWindow(HWND hwnd) if (data->drag_event) NtSetEvent(data->drag_event, NULL);
destroy_cocoa_window(data); - destroy_cocoa_view(data); - if (data->client_cocoa_view) macdrv_dispose_view(data->client_cocoa_view);
CFDictionaryRemoveValue(win_datas, hwnd); release_win_data(data); @@ -1549,14 +1325,10 @@ void macdrv_SetParent(HWND hwnd, HWND parent, HWND old_parent) { /* destroy the old Mac window */ destroy_cocoa_window(data); - create_cocoa_view(data); } - - set_cocoa_view_parent(data, parent); } else /* new top level window */ { - destroy_cocoa_view(data); create_cocoa_window(data); } release_win_data(data); @@ -1835,7 +1607,7 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UINT TRACE("win %p/%p new_rects %s style %08x flags %08x surface %p\n", hwnd, data->cocoa_window, debugstr_window_rects(new_rects), new_style, swp_flags, surface);
- if (!data->cocoa_window && !data->cocoa_view) goto done; + if (!data->cocoa_window) goto done;
if (data->on_screen) { @@ -1844,15 +1616,10 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UINT }
/* check if we are currently processing an event relevant to this window */ - if (thread_data && thread_data->current_event && - data->cocoa_window && thread_data->current_event->window == data->cocoa_window && - (thread_data->current_event->type == WINDOW_FRAME_CHANGED || - thread_data->current_event->type == WINDOW_DID_UNMINIMIZE)) - { - if (thread_data->current_event->type == WINDOW_FRAME_CHANGED) - sync_client_view_position(data); - } - else + if (!thread_data || !thread_data->current_event || + !data->cocoa_window || thread_data->current_event->window != data->cocoa_window || + (thread_data->current_event->type != WINDOW_FRAME_CHANGED && + thread_data->current_event->type != WINDOW_DID_UNMINIMIZE)) { sync_window_position(data, swp_flags, &old_rects); if (data->cocoa_window) @@ -1871,8 +1638,6 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UINT (data->layered || !(NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED))) show_window(data); } - else if (!data->on_screen) - show_window(data); }
done:
On Fri Aug 1 15:33:17 2025 +0000, Brendan Shanks wrote:
I found the commit that added the child views and it describes the issue pretty well (d91e568635c7cd23bd56f3ed688a2ba0b7219097), I don't know if there have been changes since then which make it unnecessary? There's also an internal CodeWeavers bug for this general issue (9949) which links to http://www.alsprogrammingresource.com/opengl_mdi.html as an example that's problematic. I was able to rebuild that EXE, and the problem is still present (GL draws on top of the MDI window borders). Here's my modified source, and an EXE is included: [oglmdi2_bshanks.zip](/uploads/0323c1f97f80387aeb69e419946f2343/oglmdi2_bshanks.zip) With this patch, the app crashes when I open a window:
Backtrace: =>0 0x7a53830f halveImage_ubyte+0xcf(components=0x3, width=<internal error>, height=<internal error>, datain=<is not available>, dataout=<is not available>, element_size=0x1, ysize=0x7ffc2000, group_size=0x3) [/Users/pip/wine/build64ntools/../dlls/glu32/mipmap.c:341] in glu32 (0x0022f884) 1 0x7a52b9ee gluBuild2DMipmapLevelsCore+0x9e8(userLevel=<internal error>, baseLevel=<internal error>, target=<internal error>, internalFormat=<internal error>, width=<internal error>, height=<internal error>, widthPowerOf2=<internal error>, heightPowerOf2=<internal error>, format=<internal error>, type=<internal error>, maxLevel=<internal error>, data=<internal error>) [/Users/pip/wine/build64ntools/../dlls/glu32/mipmap.c:3839] in glu32 (0x0022f9d8) 2 0x7a52b9ee gluBuild2DMipmaps+0xb0e(target=<couldn't compute location>, internalFormat=<couldn't compute location>, width=<couldn't compute location>, height=<couldn't compute location>, format=<couldn't compute location>, type=<couldn't compute location>, data=<couldn't compute location>) [/Users/pip/wine/build64ntools/../dlls/glu32/mipmap.c:4410] in glu32 (0x0022f9d8) 3 0x0040da70 in oglmdi2 (+0xda70) (0x0022fa70)
I'm not sure what the ultimate fix would be for this kind of GDI/OpenGL layering issue--have each Cocoa/GDI child window draw its own content? (Possibly combined with having OpenGL content draw into an IOSurface-backed texture rather than taking over an NSView?) Or Wine having a compositor itself that draws everything?
Thanks, I can indeed reproduce the breakage with your sample app and some other, as soon as child windows are being used.
But it turns out that my plan to replace winemac child surface management with something more similar to the other drivers also fixes that issue, it only needs to be in place prior to this code removal. I have updated the MR with the complete set of changes instead.
On Fri Aug 1 21:58:05 2025 +0000, Rémi Bernon wrote:
Thanks, I can indeed reproduce the breakage with your sample app and some other, as soon as child windows are being used. But it turns out that my plan to replace winemac child surface management with something more similar to the other drivers also fixes that issue, it only needs to be in place prior to this code removal. I have updated the MR with the complete set of changes instead.
The sample app is fixed, and I tested some other games successfully too.