xref: /OK3568_Linux_fs/external/xserver/glx/createcontext.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright © 2011 Intel Corporation
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a
5*4882a593Smuzhiyun  * copy of this software and associated documentation files (the "Software"),
6*4882a593Smuzhiyun  * to deal in the Software without restriction, including without limitation
7*4882a593Smuzhiyun  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*4882a593Smuzhiyun  * and/or sell copies of the Software, and to permit persons to whom the
9*4882a593Smuzhiyun  * Software is furnished to do so, subject to the following conditions:
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * The above copyright notice and this permission notice (including the next
12*4882a593Smuzhiyun  * paragraph) shall be included in all copies or substantial portions of the
13*4882a593Smuzhiyun  * Software.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*4882a593Smuzhiyun  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*4882a593Smuzhiyun  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*4882a593Smuzhiyun  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21*4882a593Smuzhiyun  * DEALINGS IN THE SOFTWARE.
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
24*4882a593Smuzhiyun #include <dix-config.h>
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #include <GL/glxtokens.h>
28*4882a593Smuzhiyun #include "glxserver.h"
29*4882a593Smuzhiyun #include "glxext.h"
30*4882a593Smuzhiyun #include "indirect_dispatch.h"
31*4882a593Smuzhiyun #include "opaque.h"
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #define ALL_VALID_FLAGS \
34*4882a593Smuzhiyun     (GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB \
35*4882a593Smuzhiyun      | GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB)
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun static Bool
validate_GL_version(int major_version,int minor_version)38*4882a593Smuzhiyun validate_GL_version(int major_version, int minor_version)
39*4882a593Smuzhiyun {
40*4882a593Smuzhiyun     if (major_version <= 0 || minor_version < 0)
41*4882a593Smuzhiyun         return FALSE;
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun     switch (major_version) {
44*4882a593Smuzhiyun     case 1:
45*4882a593Smuzhiyun         if (minor_version > 5)
46*4882a593Smuzhiyun             return FALSE;
47*4882a593Smuzhiyun         break;
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun     case 2:
50*4882a593Smuzhiyun         if (minor_version > 1)
51*4882a593Smuzhiyun             return FALSE;
52*4882a593Smuzhiyun         break;
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun     case 3:
55*4882a593Smuzhiyun         if (minor_version > 3)
56*4882a593Smuzhiyun             return FALSE;
57*4882a593Smuzhiyun         break;
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun     default:
60*4882a593Smuzhiyun         break;
61*4882a593Smuzhiyun     }
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun     return TRUE;
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun static Bool
validate_render_type(uint32_t render_type)67*4882a593Smuzhiyun validate_render_type(uint32_t render_type)
68*4882a593Smuzhiyun {
69*4882a593Smuzhiyun     switch (render_type) {
70*4882a593Smuzhiyun     case GLX_RGBA_TYPE:
71*4882a593Smuzhiyun     case GLX_COLOR_INDEX_TYPE:
72*4882a593Smuzhiyun     case GLX_RGBA_FLOAT_TYPE_ARB:
73*4882a593Smuzhiyun     case GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT:
74*4882a593Smuzhiyun         return TRUE;
75*4882a593Smuzhiyun     default:
76*4882a593Smuzhiyun         return FALSE;
77*4882a593Smuzhiyun     }
78*4882a593Smuzhiyun }
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun int
__glXDisp_CreateContextAttribsARB(__GLXclientState * cl,GLbyte * pc)81*4882a593Smuzhiyun __glXDisp_CreateContextAttribsARB(__GLXclientState * cl, GLbyte * pc)
82*4882a593Smuzhiyun {
83*4882a593Smuzhiyun     ClientPtr client = cl->client;
84*4882a593Smuzhiyun     xGLXCreateContextAttribsARBReq *req = (xGLXCreateContextAttribsARBReq *) pc;
85*4882a593Smuzhiyun     int32_t *attribs = (req->numAttribs != 0) ? (int32_t *) (req + 1) : NULL;
86*4882a593Smuzhiyun     unsigned i;
87*4882a593Smuzhiyun     int major_version = 1;
88*4882a593Smuzhiyun     int minor_version = 0;
89*4882a593Smuzhiyun     uint32_t flags = 0;
90*4882a593Smuzhiyun     uint32_t render_type = GLX_RGBA_TYPE;
91*4882a593Smuzhiyun #ifdef GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
92*4882a593Smuzhiyun     uint32_t flush = GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB;
93*4882a593Smuzhiyun #endif
94*4882a593Smuzhiyun     __GLXcontext *ctx = NULL;
95*4882a593Smuzhiyun     __GLXcontext *shareCtx = NULL;
96*4882a593Smuzhiyun     __GLXscreen *glxScreen;
97*4882a593Smuzhiyun     __GLXconfig *config = NULL;
98*4882a593Smuzhiyun     int err;
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun     /* The GLX_ARB_create_context_robustness spec says:
101*4882a593Smuzhiyun      *
102*4882a593Smuzhiyun      *     "The default value for GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
103*4882a593Smuzhiyun      *     is GLX_NO_RESET_NOTIFICATION_ARB."
104*4882a593Smuzhiyun      */
105*4882a593Smuzhiyun     int reset = GLX_NO_RESET_NOTIFICATION_ARB;
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun     /* The GLX_ARB_create_context_profile spec says:
108*4882a593Smuzhiyun      *
109*4882a593Smuzhiyun      *     "The default value for GLX_CONTEXT_PROFILE_MASK_ARB is
110*4882a593Smuzhiyun      *     GLX_CONTEXT_CORE_PROFILE_BIT_ARB."
111*4882a593Smuzhiyun      *
112*4882a593Smuzhiyun      * The core profile only makes sense for OpenGL versions 3.2 and later.
113*4882a593Smuzhiyun      * If the version ultimately specified is less than 3.2, the core profile
114*4882a593Smuzhiyun      * bit is cleared (see below).
115*4882a593Smuzhiyun      */
116*4882a593Smuzhiyun     int profile = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
117*4882a593Smuzhiyun 
118*4882a593Smuzhiyun     /* Verify that the size of the packet matches the size inferred from the
119*4882a593Smuzhiyun      * sizes specified for the various fields.
120*4882a593Smuzhiyun      */
121*4882a593Smuzhiyun     const unsigned expected_size = (sz_xGLXCreateContextAttribsARBReq
122*4882a593Smuzhiyun                                     + (req->numAttribs * 8)) / 4;
123*4882a593Smuzhiyun 
124*4882a593Smuzhiyun     if (req->length != expected_size)
125*4882a593Smuzhiyun         return BadLength;
126*4882a593Smuzhiyun 
127*4882a593Smuzhiyun     /* The GLX_ARB_create_context spec says:
128*4882a593Smuzhiyun      *
129*4882a593Smuzhiyun      *     "* If <config> is not a valid GLXFBConfig, GLXBadFBConfig is
130*4882a593Smuzhiyun      *        generated."
131*4882a593Smuzhiyun      *
132*4882a593Smuzhiyun      * On the client, the screen comes from the FBConfig, so GLXBadFBConfig
133*4882a593Smuzhiyun      * should be issued if the screen is nonsense.
134*4882a593Smuzhiyun      */
135*4882a593Smuzhiyun     if (!validGlxScreen(client, req->screen, &glxScreen, &err))
136*4882a593Smuzhiyun         return __glXError(GLXBadFBConfig);
137*4882a593Smuzhiyun 
138*4882a593Smuzhiyun     if (req->fbconfig) {
139*4882a593Smuzhiyun         if (!validGlxFBConfig(client, glxScreen, req->fbconfig, &config, &err))
140*4882a593Smuzhiyun             return __glXError(GLXBadFBConfig);
141*4882a593Smuzhiyun     }
142*4882a593Smuzhiyun 
143*4882a593Smuzhiyun     /* Validate the context with which the new context should share resources.
144*4882a593Smuzhiyun      */
145*4882a593Smuzhiyun     if (req->shareList != None) {
146*4882a593Smuzhiyun         if (!validGlxContext(client, req->shareList, DixReadAccess,
147*4882a593Smuzhiyun                              &shareCtx, &err))
148*4882a593Smuzhiyun             return err;
149*4882a593Smuzhiyun 
150*4882a593Smuzhiyun         /* The crazy condition is because C doesn't have a logical XOR
151*4882a593Smuzhiyun          * operator.  Comparing directly for equality may fail if one is 1 and
152*4882a593Smuzhiyun          * the other is 2 even though both are logically true.
153*4882a593Smuzhiyun          */
154*4882a593Smuzhiyun         if (!!req->isDirect != !!shareCtx->isDirect) {
155*4882a593Smuzhiyun             client->errorValue = req->shareList;
156*4882a593Smuzhiyun             return BadMatch;
157*4882a593Smuzhiyun         }
158*4882a593Smuzhiyun 
159*4882a593Smuzhiyun         /* The GLX_ARB_create_context spec says:
160*4882a593Smuzhiyun          *
161*4882a593Smuzhiyun          *     "* If the server context state for <share_context>...was
162*4882a593Smuzhiyun          *        created on a different screen than the one referenced by
163*4882a593Smuzhiyun          *        <config>...BadMatch is generated."
164*4882a593Smuzhiyun          */
165*4882a593Smuzhiyun         if (glxScreen != shareCtx->pGlxScreen) {
166*4882a593Smuzhiyun             client->errorValue = shareCtx->pGlxScreen->pScreen->myNum;
167*4882a593Smuzhiyun             return BadMatch;
168*4882a593Smuzhiyun         }
169*4882a593Smuzhiyun     }
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun     for (i = 0; i < req->numAttribs; i++) {
172*4882a593Smuzhiyun         switch (attribs[i * 2]) {
173*4882a593Smuzhiyun         case GLX_CONTEXT_MAJOR_VERSION_ARB:
174*4882a593Smuzhiyun             major_version = attribs[2 * i + 1];
175*4882a593Smuzhiyun             break;
176*4882a593Smuzhiyun 
177*4882a593Smuzhiyun         case GLX_CONTEXT_MINOR_VERSION_ARB:
178*4882a593Smuzhiyun             minor_version = attribs[2 * i + 1];
179*4882a593Smuzhiyun             break;
180*4882a593Smuzhiyun 
181*4882a593Smuzhiyun         case GLX_CONTEXT_FLAGS_ARB:
182*4882a593Smuzhiyun             flags = attribs[2 * i + 1];
183*4882a593Smuzhiyun             break;
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun         case GLX_RENDER_TYPE:
186*4882a593Smuzhiyun             /* Not valid for GLX_EXT_no_config_context */
187*4882a593Smuzhiyun             if (!req->fbconfig)
188*4882a593Smuzhiyun                 return BadValue;
189*4882a593Smuzhiyun             render_type = attribs[2 * i + 1];
190*4882a593Smuzhiyun             break;
191*4882a593Smuzhiyun 
192*4882a593Smuzhiyun         case GLX_CONTEXT_PROFILE_MASK_ARB:
193*4882a593Smuzhiyun             profile = attribs[2 * i + 1];
194*4882a593Smuzhiyun             break;
195*4882a593Smuzhiyun 
196*4882a593Smuzhiyun         case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
197*4882a593Smuzhiyun             reset = attribs[2 * i + 1];
198*4882a593Smuzhiyun             if (reset != GLX_NO_RESET_NOTIFICATION_ARB
199*4882a593Smuzhiyun                 && reset != GLX_LOSE_CONTEXT_ON_RESET_ARB)
200*4882a593Smuzhiyun                 return BadValue;
201*4882a593Smuzhiyun 
202*4882a593Smuzhiyun             break;
203*4882a593Smuzhiyun 
204*4882a593Smuzhiyun #ifdef GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
205*4882a593Smuzhiyun         case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
206*4882a593Smuzhiyun             flush = attribs[2 * i + 1];
207*4882a593Smuzhiyun             if (flush != GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
208*4882a593Smuzhiyun                 && flush != GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB)
209*4882a593Smuzhiyun                 return BadValue;
210*4882a593Smuzhiyun             break;
211*4882a593Smuzhiyun #endif
212*4882a593Smuzhiyun 
213*4882a593Smuzhiyun         case GLX_SCREEN:
214*4882a593Smuzhiyun             /* Only valid for GLX_EXT_no_config_context */
215*4882a593Smuzhiyun             if (req->fbconfig)
216*4882a593Smuzhiyun                 return BadValue;
217*4882a593Smuzhiyun             /* Must match the value in the request header */
218*4882a593Smuzhiyun             if (attribs[2 * i + 1] != req->screen)
219*4882a593Smuzhiyun                 return BadValue;
220*4882a593Smuzhiyun             break;
221*4882a593Smuzhiyun 
222*4882a593Smuzhiyun         case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
223*4882a593Smuzhiyun             /* ignore */
224*4882a593Smuzhiyun             break;
225*4882a593Smuzhiyun 
226*4882a593Smuzhiyun         default:
227*4882a593Smuzhiyun             if (!req->isDirect)
228*4882a593Smuzhiyun                 return BadValue;
229*4882a593Smuzhiyun             break;
230*4882a593Smuzhiyun         }
231*4882a593Smuzhiyun     }
232*4882a593Smuzhiyun 
233*4882a593Smuzhiyun     /* The GLX_ARB_create_context spec says:
234*4882a593Smuzhiyun      *
235*4882a593Smuzhiyun      *     "If attributes GLX_CONTEXT_MAJOR_VERSION_ARB and
236*4882a593Smuzhiyun      *     GLX_CONTEXT_MINOR_VERSION_ARB, when considered together
237*4882a593Smuzhiyun      *     with attributes GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB and
238*4882a593Smuzhiyun      *     GLX_RENDER_TYPE, specify an OpenGL version and feature set
239*4882a593Smuzhiyun      *     that are not defined, BadMatch is generated.
240*4882a593Smuzhiyun      *
241*4882a593Smuzhiyun      *     ...Feature deprecation was introduced with OpenGL 3.0, so
242*4882a593Smuzhiyun      *     forward-compatible contexts may only be requested for
243*4882a593Smuzhiyun      *     OpenGL 3.0 and above. Thus, examples of invalid
244*4882a593Smuzhiyun      *     combinations of attributes include:
245*4882a593Smuzhiyun      *
246*4882a593Smuzhiyun      *       - Major version < 1 or > 3
247*4882a593Smuzhiyun      *       - Major version == 1 and minor version < 0 or > 5
248*4882a593Smuzhiyun      *       - Major version == 2 and minor version < 0 or > 1
249*4882a593Smuzhiyun      *       - Major version == 3 and minor version > 2
250*4882a593Smuzhiyun      *       - Forward-compatible flag set and major version < 3
251*4882a593Smuzhiyun      *       - Color index rendering and major version >= 3"
252*4882a593Smuzhiyun      */
253*4882a593Smuzhiyun     if (!validate_GL_version(major_version, minor_version))
254*4882a593Smuzhiyun         return BadMatch;
255*4882a593Smuzhiyun 
256*4882a593Smuzhiyun     if (major_version < 3
257*4882a593Smuzhiyun         && ((flags & GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB) != 0))
258*4882a593Smuzhiyun         return BadMatch;
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun     if (major_version >= 3 && render_type == GLX_COLOR_INDEX_TYPE)
261*4882a593Smuzhiyun         return BadMatch;
262*4882a593Smuzhiyun 
263*4882a593Smuzhiyun     if (!validate_render_type(render_type))
264*4882a593Smuzhiyun         return BadValue;
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun     if ((flags & ~ALL_VALID_FLAGS) != 0)
267*4882a593Smuzhiyun         return BadValue;
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun     /* The GLX_ARB_create_context_profile spec says:
270*4882a593Smuzhiyun      *
271*4882a593Smuzhiyun      *     "* If attribute GLX_CONTEXT_PROFILE_MASK_ARB has no bits set; has
272*4882a593Smuzhiyun      *        any bits set other than GLX_CONTEXT_CORE_PROFILE_BIT_ARB and
273*4882a593Smuzhiyun      *        GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; has more than one of
274*4882a593Smuzhiyun      *        these bits set; or if the implementation does not support the
275*4882a593Smuzhiyun      *        requested profile, then GLXBadProfileARB is generated."
276*4882a593Smuzhiyun      *
277*4882a593Smuzhiyun      * The GLX_EXT_create_context_es2_profile spec doesn't exactly say what
278*4882a593Smuzhiyun      * is supposed to happen if an invalid version is set, but it doesn't
279*4882a593Smuzhiyun      * much matter as support for GLES contexts is only defined for direct
280*4882a593Smuzhiyun      * contexts (at the moment anyway) so we can leave it up to the driver
281*4882a593Smuzhiyun      * to validate.
282*4882a593Smuzhiyun      */
283*4882a593Smuzhiyun     switch (profile) {
284*4882a593Smuzhiyun     case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
285*4882a593Smuzhiyun     case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
286*4882a593Smuzhiyun     case GLX_CONTEXT_ES2_PROFILE_BIT_EXT:
287*4882a593Smuzhiyun         break;
288*4882a593Smuzhiyun     default:
289*4882a593Smuzhiyun         return __glXError(GLXBadProfileARB);
290*4882a593Smuzhiyun     }
291*4882a593Smuzhiyun 
292*4882a593Smuzhiyun     /* The GLX_ARB_create_context_robustness spec says:
293*4882a593Smuzhiyun      *
294*4882a593Smuzhiyun      *     "* If the reset notification behavior of <share_context> and the
295*4882a593Smuzhiyun      *        newly created context are different, BadMatch is generated."
296*4882a593Smuzhiyun      */
297*4882a593Smuzhiyun     if (shareCtx != NULL && shareCtx->resetNotificationStrategy != reset)
298*4882a593Smuzhiyun         return BadMatch;
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun     /* There is no GLX protocol for desktop OpenGL versions after 1.4.  There
301*4882a593Smuzhiyun      * is no GLX protocol for any version of OpenGL ES.  If the application is
302*4882a593Smuzhiyun      * requested an indirect rendering context for a version that cannot be
303*4882a593Smuzhiyun      * satisfied, reject it.
304*4882a593Smuzhiyun      *
305*4882a593Smuzhiyun      * The GLX_ARB_create_context spec says:
306*4882a593Smuzhiyun      *
307*4882a593Smuzhiyun      *     "* If <config> does not support compatible OpenGL contexts
308*4882a593Smuzhiyun      *        providing the requested API major and minor version,
309*4882a593Smuzhiyun      *        forward-compatible flag, and debug context flag, GLXBadFBConfig
310*4882a593Smuzhiyun      *        is generated."
311*4882a593Smuzhiyun      */
312*4882a593Smuzhiyun     if (!req->isDirect && (major_version > 1 || minor_version > 4
313*4882a593Smuzhiyun                            || profile == GLX_CONTEXT_ES2_PROFILE_BIT_EXT)) {
314*4882a593Smuzhiyun         return __glXError(GLXBadFBConfig);
315*4882a593Smuzhiyun     }
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun     /* Allocate memory for the new context
318*4882a593Smuzhiyun      */
319*4882a593Smuzhiyun     if (req->isDirect) {
320*4882a593Smuzhiyun         ctx = __glXdirectContextCreate(glxScreen, config, shareCtx);
321*4882a593Smuzhiyun         err = BadAlloc;
322*4882a593Smuzhiyun     }
323*4882a593Smuzhiyun     else {
324*4882a593Smuzhiyun         /* Only allow creating indirect GLX contexts if allowed by
325*4882a593Smuzhiyun          * server command line.  Indirect GLX is of limited use (since
326*4882a593Smuzhiyun          * it's only GL 1.4), it's slower than direct contexts, and
327*4882a593Smuzhiyun          * it's a massive attack surface for buffer overflow type
328*4882a593Smuzhiyun          * errors.
329*4882a593Smuzhiyun          */
330*4882a593Smuzhiyun         if (!enableIndirectGLX) {
331*4882a593Smuzhiyun             client->errorValue = req->isDirect;
332*4882a593Smuzhiyun             return BadValue;
333*4882a593Smuzhiyun         }
334*4882a593Smuzhiyun 
335*4882a593Smuzhiyun         ctx = glxScreen->createContext(glxScreen, config, shareCtx,
336*4882a593Smuzhiyun                                        req->numAttribs, (uint32_t *) attribs,
337*4882a593Smuzhiyun                                        &err);
338*4882a593Smuzhiyun     }
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun     if (ctx == NULL)
341*4882a593Smuzhiyun         return err;
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun     ctx->pGlxScreen = glxScreen;
344*4882a593Smuzhiyun     ctx->config = config;
345*4882a593Smuzhiyun     ctx->id = req->context;
346*4882a593Smuzhiyun     ctx->share_id = req->shareList;
347*4882a593Smuzhiyun     ctx->idExists = TRUE;
348*4882a593Smuzhiyun     ctx->isDirect = req->isDirect;
349*4882a593Smuzhiyun     ctx->renderMode = GL_RENDER;
350*4882a593Smuzhiyun     ctx->resetNotificationStrategy = reset;
351*4882a593Smuzhiyun #ifdef GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
352*4882a593Smuzhiyun     ctx->releaseBehavior = flush;
353*4882a593Smuzhiyun #endif
354*4882a593Smuzhiyun 
355*4882a593Smuzhiyun     /* Add the new context to the various global tables of GLX contexts.
356*4882a593Smuzhiyun      */
357*4882a593Smuzhiyun     if (!__glXAddContext(ctx)) {
358*4882a593Smuzhiyun         (*ctx->destroy) (ctx);
359*4882a593Smuzhiyun         client->errorValue = req->context;
360*4882a593Smuzhiyun         return BadAlloc;
361*4882a593Smuzhiyun     }
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun     return Success;
364*4882a593Smuzhiyun }
365*4882a593Smuzhiyun 
366*4882a593Smuzhiyun int
__glXDispSwap_CreateContextAttribsARB(__GLXclientState * cl,GLbyte * pc)367*4882a593Smuzhiyun __glXDispSwap_CreateContextAttribsARB(__GLXclientState * cl, GLbyte * pc)
368*4882a593Smuzhiyun {
369*4882a593Smuzhiyun     return BadRequest;
370*4882a593Smuzhiyun }
371