vrclient: Make get_our_compositor() thread-safe.

get_our_compositor() is also called from the wined3d command stream
thread.
This commit is contained in:
Józef Kucia 2018-06-08 19:24:49 +02:00 committed by Andrew Eikum
parent 5d073d3f40
commit 3f2b30d351

View file

@ -485,10 +485,19 @@ VRCompositorError ivrcompositor_008_submit(
static void *our_compositor; static void *our_compositor;
static void get_our_compositor(void) static BOOL WINAPI create_our_compositor(INIT_ONCE *once, void *param, void **context)
{ {
void *client_core = vrclient_VRClientCoreFactory("IVRClientCore_003", NULL); void *core = vrclient_VRClientCoreFactory("IVRClientCore_003", NULL);
our_compositor = cppIVRClientCore_IVRClientCore_003_GetGenericInterface(client_core, "IVRCompositor_022", NULL); our_compositor = cppIVRClientCore_IVRClientCore_003_GetGenericInterface(core, "IVRCompositor_022", NULL);
WARN("Created our compositor %p.\n", our_compositor);
return TRUE;
}
static void *get_our_compositor(void)
{
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
InitOnceExecuteOnce(&init_once, create_our_compositor, NULL, NULL);
return our_compositor;
} }
EVRCompositorError ivrcompositor_submit( EVRCompositorError ivrcompositor_submit(
@ -551,14 +560,9 @@ EVRCompositorError ivrcompositor_submit(
VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff); VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff);
break; break;
default: default:
{ timing_compositor = get_our_compositor();
if(!our_compositor){ WARN("Performing our compositor hack for old compositor version %u.\n", version);
TRACE("Performing hack for old compositor version %u.\n", version); /* fall through, below version MUST match version in create_our_compositor() */
get_our_compositor();
}
timing_compositor = our_compositor;
}
/* fall through, below version MUST match version in get_our_compositor() */
case 22: case 22:
cppIVRCompositor_IVRCompositor_022_SetExplicitTimingMode(timing_compositor, cppIVRCompositor_IVRCompositor_022_SetExplicitTimingMode(timing_compositor,
VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff); VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff);
@ -823,14 +827,8 @@ static CDECL void d3d11_explicit_timing_callback(const void *data, unsigned int
error = cppIVRCompositor_IVRCompositor_021_SubmitExplicitTimingData(callback_data->linux_side); error = cppIVRCompositor_IVRCompositor_021_SubmitExplicitTimingData(callback_data->linux_side);
break; break;
default: default:
{ timing_compositor = get_our_compositor();
if(!our_compositor){ /* fall through, below version MUST match version in create_our_compositor() */
TRACE("Performing hack for old compositor version %u.\n", callback_data->version);
get_our_compositor();
}
timing_compositor = our_compositor;
}
/* fall through, below version MUST match version in get_our_compositor() */
case 22: case 22:
error = cppIVRCompositor_IVRCompositor_022_SubmitExplicitTimingData(timing_compositor); error = cppIVRCompositor_IVRCompositor_022_SubmitExplicitTimingData(timing_compositor);
break; break;