Module: wine Branch: master Commit: a55320f00b7d2b69e709d45fdf6c2afde84d1b23 URL: https://source.winehq.org/git/wine.git/?a=commit;h=a55320f00b7d2b69e709d45fd...
Author: Chip Davis cdavis@codeweavers.com Date: Sun May 17 17:44:15 2020 -0500
winemac.drv: Use InitOnceExecuteOnce to initialize OpenGL.
Currently, there is a race condition where if two threads call into OpenGL at the same time, one of them will initialize OpenGL, but the other will barrel on ahead, thinking GL is already initialized, even though the first thread hasn't finished initializing it yet. One of the symptoms of this is that no pixel formats appear to be available, because the first thread hasn't yet enumerated the available pixel formats.
Signed-off-by: Chip Davis cdavis@codeweavers.com Signed-off-by: Ken Thomases ken@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winemac.drv/opengl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dlls/winemac.drv/opengl.c b/dlls/winemac.drv/opengl.c index b80c8fffb0..b66af0f1c4 100644 --- a/dlls/winemac.drv/opengl.c +++ b/dlls/winemac.drv/opengl.c @@ -4242,7 +4242,7 @@ static void load_extensions(void) }
-static BOOL init_opengl(void) +static BOOL CALLBACK init_opengl(INIT_ONCE *init_once, void *context, void **param) { static BOOL init_done = FALSE; unsigned int i; @@ -4654,13 +4654,15 @@ static struct opengl_funcs opengl_funcs = */ struct opengl_funcs * CDECL macdrv_wine_get_wgl_driver(PHYSDEV dev, UINT version) { + static INIT_ONCE opengl_init = INIT_ONCE_STATIC_INIT; + if (version != WINE_WGL_DRIVER_VERSION) { ERR("version mismatch, opengl32 wants %u but macdrv has %u\n", version, WINE_WGL_DRIVER_VERSION); return NULL; }
- if (!init_opengl()) return (void *)-1; + if (!InitOnceExecuteOnce(&opengl_init, init_opengl, NULL, NULL)) return (void *)-1;
return &opengl_funcs; }