if (dpy->host_dpy == host_dpy) {
pthread_mutex_unlock(&g_displays_mutex);
+ /*
+ * We need to make sure fence_dpy is setup properly for current
+ * thread state. Otherwise we may not be able to create fences in
+ * transport layer and eventually will face a race condition between
+ * host and target.
+ *
+ * E.g. the app may initialize all EGL stuff (i.e. get display,
+ * choose config, etc.) and save it to some global state var. If
+ * then it tries to create new context in some other thread,
+ * fence_dpy will be NULL and as a result we may not get proper
+ * values returned from the host.
+ */
+ yagl_set_fence_display(dpy);
+
return dpy;
}
}