ScummVM API documentation
libretro-gl-context-handoff.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef LIBRETRO_GL_CONTEXT_HANDOFF_H
23#define LIBRETRO_GL_CONTEXT_HANDOFF_H
24
25/* The frontend makes its rendering context current on the thread that drives
26 * retro_run(). ScummVM issues its GL calls from inside scummvm_main(), which
27 * runs on the emulation thread, so the context has to travel with control at
28 * every handoff.
29 *
30 * The two threads never run concurrently, so no reference counting is needed:
31 * whichever thread is about to block releases the context, and whichever
32 * thread is about to run acquires it. Visibility of the saved handles between
33 * the two threads is provided by the lock in libretro-threads.cpp.
34 *
35 * These are no-ops when no context is current (software rendering) and when
36 * the core is built with libco, where both halves share one OS thread.
37 */
38
39/* Unbind the context from the calling thread, remembering what was bound.
40 * Call immediately before handing control to the other thread. */
41void retro_gl_context_release(void);
42
43/* Rebind whatever the last retro_gl_context_release() unbound. Call
44 * immediately after regaining control. */
45void retro_gl_context_acquire(void);
46
47/* Whether a context handoff backend is available on this platform. Requesting
48 * hardware rendering without one would leave the emulation thread issuing GL
49 * calls against no current context, so the caller falls back to software. */
50bool retro_gl_context_handoff_available(void);
51
52#endif