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
3 of the GLX
1.3 Specification
(Functions and Errors
)
66 Remove the following sentence from section
3.3.7 Rendering Contexts
:
67 If ctx is current to some other thread
, then
68 glXMakeContextCurrent will generate a BadAccess error.
70 Remove the following sentence from section
3.5 Rendering Contexts
:
71 If ctx is current to some other thread
, then
72 glXMakeCurrent will generate a BadAccess error.
76 None. The GLX extension is client
-side.
88 (1) What happens
if the app binds a context
/drawable
in multiple
89 threads
, then binds a different context
/thread
in one of them?
91 As with binding a new context from the current thread
, the old
92 context's refcount is reduced and the new context's refcount is
95 (2) What happens
if the app binds a context
/drawable
in multiple
96 threads
, then binds None
/None
in one of them?
98 The GLX context is unreferenced from that thread
, and the other
99 threads retain their GLX context binding.
101 (3) What happens
if the app binds a context
/drawable
in 7 threads
,
102 then destroys the context
in one of them?
104 As with GLX context destruction previously
, the XID is destroyed
105 but the context remains usable by threads that have the context
108 (4) What happens
if the app binds a new drawable
/readable with
109 glXMakeCurrent
() when it is already bound to another thread?
111 The context becomes bound to the new drawable
/readable
, and
112 further rendering
in either thread will use the new
115 (5) What requirements should be placed on the user managing contexts
116 from multiple threads?
118 The intention is to allow multithreaded access to the GL at the
119 minimal performance cost
, so requiring that the GL
do general
120 synchronization
(beyond that already required by context sharing
)
121 is not an option
, and synchronizing of GL's access to the GL
122 context between multiple threads is left to the application to
do
123 across GL calls. However
, it would be unfortunate
for a library
124 doing multithread_makecurrent to require that other libraries
125 share
in synchronization
for binding of their own contexts
, so the
126 refcounting of the contexts is required to be threadsafe.
130 20 November
2009 Eric Anholt
- initial specification
131 22 November
2009 Eric Anholt
- added issues from Ian Romanick.
132 3 February
2011 Eric Anholt
- updated with resolution to issues
1-3
133 3 February
2011 Eric Anholt
- added issue
4, 5
134 21 February
2011 Eric Anholt
- Include glXMakeCurrent
() sentence
135 along with glXMakeContextCurrent
() for removal.