mesa: Add new MESA_multithread_makecurrent extension.
[mesa.git] / docs / MESA_multithread_makecurrent.spec
1 Name
2
3 MESA_multithread_makecurrent
4
5 Name Strings
6
7 GLX_MESA_multithread_makecurrent
8
9 Contact
10
11 Eric Anholt (eric@anholt.net)
12
13 Status
14
15 Not shipping.
16
17 Version
18
19 Last Modified Date: 21 February 2011
20
21 Number
22
23 TBD
24
25 Dependencies
26
27 OpenGL 1.0 or later is required.
28 GLX 1.3 or later is required.
29
30 Overview
31
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.
36
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.
44
45 This new behavior matches the requirements of AGL, while providing
46 a feature not specified in WGL.
47
48 IP Status
49
50 Open-source; freely implementable.
51
52 Issues
53
54 None.
55
56 New Procedures and Functions
57
58 None.
59
60 New Tokens
61
62 None.
63
64 Changes to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
65
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.
69
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.
73
74 GLX Protocol
75
76 None. The GLX extension is client-side.
77
78 Errors
79
80 None.
81
82 New State
83
84 None.
85
86 Issues
87
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?
90
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
93 increased.
94
95 (2) What happens if the app binds a context/drawable in multiple
96 threads, then binds None/None in one of them?
97
98 The GLX context is unreferenced from that thread, and the other
99 threads retain their GLX context binding.
100
101 (3) What happens if the app binds a context/drawable in 7 threads,
102 then destroys the context in one of them?
103
104 As with GLX context destruction previously, the XID is destroyed
105 but the context remains usable by threads that have the context
106 current.
107
108 (4) What happens if the app binds a new drawable/readable with
109 glXMakeCurrent() when it is already bound to another thread?
110
111 The context becomes bound to the new drawable/readable, and
112 further rendering in either thread will use the new
113 drawable/readable.
114
115 (5) What requirements should be placed on the user managing contexts
116 from multiple threads?
117
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.
127
128 Revision History
129
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.