Commit a55320f0 authored by Chip Davis's avatar Chip Davis Committed by Alexandre Julliard

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: 's avatarChip Davis <cdavis@codeweavers.com> Signed-off-by: 's avatarKen Thomases <ken@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 14d97456
......@@ -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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment