[PATCH 0/1] MR9653: wined3d: Remove now unnecessary pixel format restoration.
wglSetPixelFormatWINE now sets the internal pixel format privately on each DC, and it is unnecessary to restore the window pixel format. That call is even undesirable as it allocates and destroys a private OpenGL drawable when the DC is acquired, its internal pixel format is set, and the DC is then immediately released. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9653
From: Rémi Bernon <rbernon(a)codeweavers.com> wglSetPixelFormatWINE now sets the internal pixel format privately on each DC, and it is unnecessary to restore the window pixel format. That call is even undesirable as it allocates and destroys a private OpenGL drawable when the DC is acquired, its internal pixel format is set, and the DC is then immediately released. --- dlls/wined3d/context_gl.c | 44 ++------------------------------------- dlls/wined3d/wined3d_gl.h | 1 - 2 files changed, 2 insertions(+), 43 deletions(-) diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index ac1b9370fc1..82e44161598 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -1162,38 +1162,6 @@ void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl, } } -static BOOL wined3d_context_gl_restore_pixel_format(struct wined3d_context_gl *context_gl) -{ - const struct wined3d_gl_info *gl_info = context_gl->gl_info; - BOOL ret = FALSE; - - if (context_gl->restore_pf && IsWindow(context_gl->restore_pf_win)) - { - if (gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH]) - { - HDC dc = GetDCEx(context_gl->restore_pf_win, 0, DCX_USESTYLE | DCX_CACHE); - if (dc) - { - if (!(ret = GL_EXTCALL(wglSetPixelFormatWINE(dc, context_gl->restore_pf)))) - { - ERR("Failed to restore pixel format %d on window %p.\n", - context_gl->restore_pf, context_gl->restore_pf_win); - } - ReleaseDC(context_gl->restore_pf_win, dc); - } - } - else - { - ERR("Unable to restore pixel format %d on window %p.\n", - context_gl->restore_pf, context_gl->restore_pf_win); - } - } - - context_gl->restore_pf = 0; - context_gl->restore_pf_win = NULL; - return ret; -} - static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *context_gl) { const struct wined3d_gl_info *gl_info = context_gl->gl_info; @@ -1201,7 +1169,6 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte int format = context_gl->pixel_format; HDC dc = context_gl->dc; int current; - HWND win; if (private && context_gl->dc_has_format) return TRUE; @@ -1246,12 +1213,6 @@ static BOOL wined3d_context_gl_set_pixel_format(struct wined3d_context_gl *conte return FALSE; } - win = private ? NULL : WindowFromDC(dc); - if (win != context_gl->restore_pf_win) - wined3d_context_gl_restore_pixel_format(context_gl); - context_gl->restore_pf = private ? 0 : current; - context_gl->restore_pf_win = win; - success: if (private) context_gl->dc_has_format = TRUE; @@ -1536,7 +1497,6 @@ static void wined3d_context_gl_cleanup(struct wined3d_context_gl *context_gl) free(context_gl->texture_type); - wined3d_context_gl_restore_pixel_format(context_gl); if (restore_ctx) context_restore_gl_context(gl_info, restore_dc, restore_ctx); else if (wglGetCurrentContext() && !wglMakeCurrent(NULL, NULL)) @@ -1642,8 +1602,8 @@ void wined3d_context_gl_release(struct wined3d_context_gl *context_gl) if (!--context_gl->level) { - if (wined3d_context_gl_restore_pixel_format(context_gl)) - context_gl->needs_set = 1; + context_gl->needs_set = 1; + if (context_gl->restore_ctx) { TRACE("Restoring GL context %p on device context %p.\n", context_gl->restore_ctx, context_gl->restore_dc); diff --git a/dlls/wined3d/wined3d_gl.h b/dlls/wined3d/wined3d_gl.h index ed537686007..c37b3299f73 100644 --- a/dlls/wined3d/wined3d_gl.h +++ b/dlls/wined3d/wined3d_gl.h @@ -645,7 +645,6 @@ struct wined3d_context_gl HGLRC restore_ctx; HDC restore_dc; int restore_pf; - HWND restore_pf_win; HGLRC gl_ctx; HDC dc; int pixel_format; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9653
Any chance this could get reviewed before the code freeze tomorrow? There's no reported bug so I'm getting a bit worried whether this can make it. I still think it fixes a performance regression in Steam, from either a085746bbe3594e4ea01ea578823383e6447b6b6 or some previous change with the OpenGL surface management (although things have not been very stable anyway). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9653#note_124758
Any chance this could get reviewed before the code freeze tomorrow? There's no reported bug so I'm getting a bit worried whether this can make it.
Yes, there's a chance. Again, sorry, I've got a lot of review to catch up on. If it's a regression / bug fix it should be eligible for the freeze anyway, so I wouldn't be too worried. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9653#note_124777
This merge request was approved by Elizabeth Figura. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9653
participants (2)
-
Elizabeth Figura (@zfigura) -
Rémi Bernon