3
MESA_multithread_makecurrent
7
GLX_MESA_multithread_makecurrent
11
Eric Anholt (eric@anholt.net)
19
Last Modified Date: 21 February 2011
27
OpenGL 1.0 or later is required.
28
GLX 1.3 or later is required.
32
The GLX context setup encourages multithreaded applications to
33
create a context per thread which each operate on their own
34
objects in parallel, and leaves synchronization for write access
35
to shared objects up to the application.
37
For some applications, maintaining per-thread contexts and
38
ensuring that the glFlush happens in one thread before another
39
thread starts working on that object is difficult. For them,
40
using the same context across multiple threads and protecting its
41
usage with a mutex is both higher performance and easier to
42
implement. This extension gives those applications that option by
43
relaxing the context binding requirements.
45
This new behavior matches the requirements of AGL, while providing
46
a feature not specified in WGL.
50
Open-source; freely implementable.
56
New Procedures and Functions
64
Changes to Chapter 2 of the GLX 1.3 Specification (Functions and Errors)
66
Replace the following sentence from section 2.2 Rendering Contexts:
67
In addition, a rendering context can be current for only one
70
In addition, an indirect rendering context can be current for
71
only one thread at a time. A direct rendering context may be
72
current to multiple threads, with synchronization of access to
73
the context through the GL managed by the application through
76
Changes to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
78
Replace the following sentence from section 3.3.7 Rendering Contexts:
79
If ctx is current to some other thread, then
80
glXMakeContextCurrent will generate a BadAccess error.
82
If ctx is an indirect context current to some other thread,
83
then glXMakeContextCurrent will generate a BadAccess error.
85
Replace the following sentence from section 3.5 Rendering Contexts:
86
If ctx is current to some other thread, then
87
glXMakeCurrent will generate a BadAccess error.
89
If ctx is an indirect context current to some other thread,
90
then glXMakeCurrent will generate a BadAccess error.
94
None. The GLX extension only extends to direct rendering contexts.
106
(1) What happens if the app binds a context/drawable in multiple
107
threads, then binds a different context/thread in one of them?
109
As with binding a new context from the current thread, the old
110
context's refcount is reduced and the new context's refcount is
113
(2) What happens if the app binds a context/drawable in multiple
114
threads, then binds None/None in one of them?
116
The GLX context is unreferenced from that thread, and the other
117
threads retain their GLX context binding.
119
(3) What happens if the app binds a context/drawable in 7 threads,
120
then destroys the context in one of them?
122
As with GLX context destruction previously, the XID is destroyed
123
but the context remains usable by threads that have the context
126
(4) What happens if the app binds a new drawable/readable with
127
glXMakeCurrent() when it is already bound to another thread?
129
The context becomes bound to the new drawable/readable, and
130
further rendering in either thread will use the new
133
(5) What requirements should be placed on the user managing contexts
134
from multiple threads?
136
The intention is to allow multithreaded access to the GL at the
137
minimal performance cost, so requiring that the GL do general
138
synchronization (beyond that already required by context sharing)
139
is not an option, and synchronizing of GL's access to the GL
140
context between multiple threads is left to the application to do
141
across GL calls. However, it would be unfortunate for a library
142
doing multithread_makecurrent to require that other libraries
143
share in synchronization for binding of their own contexts, so the
144
refcounting of the contexts is required to be threadsafe.
146
(6) Does this apply to indirect contexts?
148
This was ignored in the initial revision of the spec. Behavior
149
for indirect contexts is left as-is.
153
20 November 2009 Eric Anholt - initial specification
154
22 November 2009 Eric Anholt - added issues from Ian Romanick.
155
3 February 2011 Eric Anholt - updated with resolution to issues 1-3
156
3 February 2011 Eric Anholt - added issue 4, 5
157
21 February 2011 Eric Anholt - Include glXMakeCurrent() sentence
158
along with glXMakeContextCurrent() for removal.