···5353};
54545555/*!
5656+ * What's the reason to make the context current, this is needed currently for
5757+ * EGL where we have to create a shared context in some cases. But when we
5858+ * want to synchronize (insert a fence or call glFinish) we can not use the
5959+ * shared context and must use the context that the app provided on creation.
6060+ */
6161+enum client_gl_context_reason
6262+{
6363+ /*!
6464+ * Used when the compositor needs to insert a fence in the command
6565+ * stream of the apps context, this needs to be done in the given
6666+ * context and not the shared one that may be created.
6767+ */
6868+ CLIENT_GL_CONTEXT_REASON_SYNCHRONIZE,
6969+ /*!
7070+ * Any other reason to make the context current,
7171+ * the shared may be used by now.
7272+ */
7373+ CLIENT_GL_CONTEXT_REASON_OTHER,
7474+};
7575+7676+/*!
5677 * Fetches the OpenGL context that is current on this thread and makes the
5778 * OpenGL context given in the graphics binding current instead. Only one thread
5879 * at a time can operate on the sections between
···6788 * If the return value is not XRT_SUCCESS,
6889 * @ref client_gl_context_end_locked_func_t should not be called.
6990 */
7070-typedef xrt_result_t (*client_gl_context_begin_locked_func_t)(struct xrt_compositor *xc);
9191+typedef xrt_result_t (*client_gl_context_begin_locked_func_t)(struct xrt_compositor *xc,
9292+ enum client_gl_context_reason reason);
71937294/*!
7395 * Makes the OpenGL context current that was current before
···78100 * not released by this function, but @ref client_gl_compositor_context_end does
79101 * release it.
80102 */
8181-typedef void (*client_gl_context_end_locked_func_t)(struct xrt_compositor *xc);
103103+typedef void (*client_gl_context_end_locked_func_t)(struct xrt_compositor *xc, enum client_gl_context_reason reason);
8210483105/*!
84106 * The type of a swapchain create constructor.
···207229 * @public @memberof client_gl_compositor
208230 */
209231static inline xrt_result_t
210210-client_gl_compositor_context_begin(struct xrt_compositor *xc)
232232+client_gl_compositor_context_begin(struct xrt_compositor *xc, enum client_gl_context_reason reason)
211233{
212234 struct client_gl_compositor *cgc = client_gl_compositor(xc);
213235214236 os_mutex_lock(&cgc->context_mutex);
215237216216- xrt_result_t xret = cgc->context_begin_locked(xc);
238238+ xrt_result_t xret = cgc->context_begin_locked(xc, reason);
217239 if (xret != XRT_SUCCESS) {
218240 os_mutex_unlock(&cgc->context_mutex);
219241 }
···229251 * @public @memberof client_gl_compositor
230252 */
231253static inline void
232232-client_gl_compositor_context_end(struct xrt_compositor *xc)
254254+client_gl_compositor_context_end(struct xrt_compositor *xc, enum client_gl_context_reason reason)
233255{
234256 struct client_gl_compositor *cgc = client_gl_compositor(xc);
235257236236- cgc->context_end_locked(xc);
258258+ cgc->context_end_locked(xc, reason);
237259238260 os_mutex_unlock(&cgc->context_mutex);
239261}