After wglMakeCurrent(NULL, NULL); wglSwapBuffers(HDC) actually swaps buffers for the device context. That works on Windows and basically with Wine glx (as glxSwapBuffers also works on drawable and doesn't need GLX context). But that doesn't work for child window rendering: first because of NULL ctx dereference (checked for NULL elsewhere) and next because of GLX_OML_sync_control path.
Fixes Black Desert Online launcher being black screen. The launcher does the following for drawing a frame (while drawing on the child window): ``` wglMakeCurrent(hdc, valid context); <gl drawing> wglMakeCurrent(NULL, NULL); wglSwapBuffers(hdc); ```
-- v3: winex11.drv: Fix wglSwapBuffers() with NULL current context with child window rendering.
From: Paul Gofman pgofman@codeweavers.com
--- dlls/winex11.drv/opengl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/winex11.drv/opengl.c b/dlls/winex11.drv/opengl.c index bb8f13f78b9..d70f1928655 100644 --- a/dlls/winex11.drv/opengl.c +++ b/dlls/winex11.drv/opengl.c @@ -3378,7 +3378,7 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) case DC_GL_PIXMAP_WIN: if (ctx) sync_context( ctx ); escape.gl_drawable = gl->pixmap; - if (pglXCopySubBufferMESA) { + if (ctx && pglXCopySubBufferMESA) { /* (glX)SwapBuffers has an implicit glFlush effect, however * GLX_MESA_copy_sub_buffer doesn't. Make sure GL is flushed before * copying */ @@ -3387,7 +3387,7 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) gl->pixmap_size.cx, gl->pixmap_size.cy ); break; } - if (pglXSwapBuffersMscOML) + if (ctx && pglXSwapBuffersMscOML) { pglFlush(); target_sbc = pglXSwapBuffersMscOML( gdi_display, gl->drawable, 0, 0, 0 ); @@ -3401,7 +3401,7 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) if (gl->type == DC_GL_CHILD_WIN) escape.gl_drawable = gl->window; /* fall through */ default: - if (escape.gl_drawable && pglXSwapBuffersMscOML) + if (ctx && escape.gl_drawable && pglXSwapBuffersMscOML) { pglFlush(); target_sbc = pglXSwapBuffersMscOML( gdi_display, gl->drawable, 0, 0, 0 ); @@ -3411,13 +3411,13 @@ static BOOL glxdrv_wglSwapBuffers( HDC hdc ) break; }
- if (escape.gl_drawable && pglXWaitForSbcOML) + if (ctx && escape.gl_drawable && pglXWaitForSbcOML) pglXWaitForSbcOML( gdi_display, gl->drawable, target_sbc, &ust, &msc, &sbc );
release_gl_drawable( gl );
if (escape.gl_drawable) - NtGdiExtEscape( ctx->hdc, NULL, 0, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); + NtGdiExtEscape( ctx ? ctx->hdc : hdc, NULL, 0, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL ); return TRUE; }
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=142256
Your paranoid android.
=== debian11b (64 bit WoW report) ===
mf: transform.c:2469: Test failed: aacdec: got 0 output samples Unhandled exception: divide by zero in 64-bit code (0x0000000042e22c).
user32: input.c:3646: Test failed: error 0
@zfigura suggested to include an interactive test for this functionality, which is probably a good idea. I am planning to do so after waiting for some comment from Matteo.
This seems like a clear improvement to the current situation and I'm okay with approving it (although I won't for the time being, as you mention a new test and I'd like to see it first :slight_smile:).
I was thinking, maybe it makes sense to add a WARN() if we get in `glxdrv_wglSwapBuffers()` without a GL context? Probably not, now that I look at it in detail. The implicit flush in `glXSwapBuffers()` only happens when a GL context is current. win32's `SwapBuffers()` doesn't say, of course, but it would be sensible if it did the same, which means that the application gives up to the implicit flush by calling `wglMakeCurrent(NULL)`. Also we're currently printing no messages when `GLX_OML_sync_control` is not supported, so it's probably fine as is.