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>
This commit is contained in:
Chip Davis 2020-05-17 17:44:15 -05:00 committed by Alexandre Julliard
parent 14d97456a9
commit a55320f00b
1 changed files with 4 additions and 2 deletions

View File

@ -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;
}