glx: drop unnecessary pointer deref for function calls
[mesa.git] / src / glx / dri_common.c
1 /*
2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright © 2008 Red Hat, Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Soft-
7 * ware"), to deal in the Software without restriction, including without
8 * limitation the rights to use, copy, modify, merge, publish, distribute,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, provided that the above copyright
11 * notice(s) and this permission notice appear in all copies of the Soft-
12 * ware and that both the above copyright notice(s) and this permission
13 * notice appear in supporting documentation.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17 * ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY
18 * RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN
19 * THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSE-
20 * QUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFOR-
23 * MANCE OF THIS SOFTWARE.
24 *
25 * Except as contained in this notice, the name of a copyright holder shall
26 * not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization of
28 * the copyright holder.
29 *
30 * Authors:
31 * Kevin E. Martin <kevin@precisioninsight.com>
32 * Brian Paul <brian@precisioninsight.com>
33 * Kristian Høgsberg (krh@redhat.com)
34 */
35
36 #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL)
37
38 #include <unistd.h>
39 #include <dlfcn.h>
40 #include <stdarg.h>
41 #include "glxclient.h"
42 #include "dri_common.h"
43 #include "loader.h"
44
45 #ifndef RTLD_NOW
46 #define RTLD_NOW 0
47 #endif
48 #ifndef RTLD_GLOBAL
49 #define RTLD_GLOBAL 0
50 #endif
51
52 _X_HIDDEN void
53 dri_message(int level, const char *f, ...)
54 {
55 va_list args;
56 int threshold = _LOADER_WARNING;
57 const char *libgl_debug;
58
59 libgl_debug = getenv("LIBGL_DEBUG");
60 if (libgl_debug) {
61 if (strstr(libgl_debug, "quiet"))
62 threshold = _LOADER_FATAL;
63 else if (strstr(libgl_debug, "verbose"))
64 threshold = _LOADER_DEBUG;
65 }
66
67 /* Note that the _LOADER_* levels are lower numbers for more severe. */
68 if (level <= threshold) {
69 fprintf(stderr, "libGL%s: ", level <= _LOADER_WARNING ? " error" : "");
70 va_start(args, f);
71 vfprintf(stderr, f, args);
72 va_end(args);
73 }
74 }
75
76 #ifndef GL_LIB_NAME
77 #define GL_LIB_NAME "libGL.so.1"
78 #endif
79
80 /**
81 * Try to \c dlopen the named driver.
82 *
83 * This function adds the "_dri.so" suffix to the driver name and searches the
84 * directories specified by the \c LIBGL_DRIVERS_PATH environment variable in
85 * order to find the driver.
86 *
87 * \param driverName - a name like "i965", "radeon", "nouveau", etc.
88 * \param out_driver_handle - Address to return the resulting dlopen() handle.
89 *
90 * \returns
91 * The __DRIextension entrypoint table for the driver, or \c NULL if driver
92 * file not found.
93 */
94 _X_HIDDEN const __DRIextension **
95 driOpenDriver(const char *driverName, void **out_driver_handle)
96 {
97 void *glhandle;
98
99 /* Attempt to make sure libGL symbols will be visible to the driver */
100 glhandle = dlopen(GL_LIB_NAME, RTLD_NOW | RTLD_GLOBAL);
101
102 static const char *search_path_vars[] = {
103 "LIBGL_DRIVERS_PATH",
104 "LIBGL_DRIVERS_DIR", /* deprecated */
105 NULL
106 };
107
108 const __DRIextension **extensions =
109 loader_open_driver(driverName, out_driver_handle, search_path_vars);
110
111 if (glhandle)
112 dlclose(glhandle);
113
114 return extensions;
115 }
116
117 static GLboolean
118 __driGetMSCRate(__DRIdrawable *draw,
119 int32_t * numerator, int32_t * denominator,
120 void *loaderPrivate)
121 {
122 __GLXDRIdrawable *glxDraw = loaderPrivate;
123
124 return __glxGetMscRate(glxDraw->psc, numerator, denominator);
125 }
126
127 _X_HIDDEN const __DRIsystemTimeExtension systemTimeExtension = {
128 .base = {__DRI_SYSTEM_TIME, 1 },
129
130 .getUST = __glXGetUST,
131 .getMSCRate = __driGetMSCRate
132 };
133
134 #define __ATTRIB(attrib, field) \
135 { attrib, offsetof(struct glx_config, field) }
136
137 static const struct
138 {
139 unsigned int attrib, offset;
140 } attribMap[] = {
141 __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
142 __ATTRIB(__DRI_ATTRIB_LEVEL, level),
143 __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
144 __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
145 __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
146 __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
147 __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
148 __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
149 __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
150 __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
151 __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
152 __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
153 __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
154 __ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
155 __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
156 __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
157 __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
158 #if 0
159 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
160 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentIndex),
161 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
162 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
163 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
164 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
165 __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
166 __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
167 __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
168 __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
169 #endif
170 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
171 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
172 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
173 __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
174 __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
175 __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
176 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
177 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
178 __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,
179 bindToMipmapTexture),
180 __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
181 __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable)
182 };
183
184 static int
185 scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value)
186 {
187 unsigned glxValue, i;
188
189 for (i = 0; i < ARRAY_SIZE(attribMap); i++)
190 if (attribMap[i].attrib == attrib) {
191 glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset);
192 return glxValue == GLX_DONT_CARE || glxValue == value;
193 }
194
195 return GL_TRUE; /* Is a non-existing attribute equal to value? */
196 }
197
198 static int
199 driConfigEqual(const __DRIcoreExtension *core,
200 struct glx_config *config, const __DRIconfig *driConfig)
201 {
202 unsigned int attrib, value, glxValue;
203 int i;
204
205 i = 0;
206 while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
207 switch (attrib) {
208 case __DRI_ATTRIB_RENDER_TYPE:
209 glxValue = 0;
210 if (value & __DRI_ATTRIB_RGBA_BIT) {
211 glxValue |= GLX_RGBA_BIT;
212 }
213 if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
214 glxValue |= GLX_COLOR_INDEX_BIT;
215 }
216 if (value & __DRI_ATTRIB_FLOAT_BIT) {
217 glxValue |= GLX_RGBA_FLOAT_BIT_ARB;
218 }
219 if (value & __DRI_ATTRIB_UNSIGNED_FLOAT_BIT) {
220 glxValue |= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
221 }
222 if (glxValue != config->renderType)
223 return GL_FALSE;
224 break;
225
226 case __DRI_ATTRIB_CONFIG_CAVEAT:
227 if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
228 glxValue = GLX_NON_CONFORMANT_CONFIG;
229 else if (value & __DRI_ATTRIB_SLOW_BIT)
230 glxValue = GLX_SLOW_CONFIG;
231 else
232 glxValue = GLX_NONE;
233 if (glxValue != config->visualRating)
234 return GL_FALSE;
235 break;
236
237 case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
238 glxValue = 0;
239 if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
240 glxValue |= GLX_TEXTURE_1D_BIT_EXT;
241 if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
242 glxValue |= GLX_TEXTURE_2D_BIT_EXT;
243 if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
244 glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
245 if (config->bindToTextureTargets != GLX_DONT_CARE &&
246 glxValue != config->bindToTextureTargets)
247 return GL_FALSE;
248 break;
249
250 case __DRI_ATTRIB_SWAP_METHOD:
251 if (value == __DRI_ATTRIB_SWAP_EXCHANGE)
252 glxValue = GLX_SWAP_EXCHANGE_OML;
253 else if (value == __DRI_ATTRIB_SWAP_COPY)
254 glxValue = GLX_SWAP_COPY_OML;
255 else
256 glxValue = GLX_SWAP_UNDEFINED_OML;
257
258 if (!scalarEqual(config, attrib, glxValue))
259 return GL_FALSE;
260
261 break;
262
263 default:
264 if (!scalarEqual(config, attrib, value))
265 return GL_FALSE;
266 }
267 }
268
269 return GL_TRUE;
270 }
271
272 static struct glx_config *
273 createDriMode(const __DRIcoreExtension * core,
274 struct glx_config *config, const __DRIconfig **driConfigs)
275 {
276 __GLXDRIconfigPrivate *driConfig;
277 int i;
278
279 for (i = 0; driConfigs[i]; i++) {
280 if (driConfigEqual(core, config, driConfigs[i]))
281 break;
282 }
283
284 if (driConfigs[i] == NULL)
285 return NULL;
286
287 driConfig = malloc(sizeof *driConfig);
288 if (driConfig == NULL)
289 return NULL;
290
291 driConfig->base = *config;
292 driConfig->driConfig = driConfigs[i];
293
294 return &driConfig->base;
295 }
296
297 _X_HIDDEN struct glx_config *
298 driConvertConfigs(const __DRIcoreExtension * core,
299 struct glx_config *configs, const __DRIconfig **driConfigs)
300 {
301 struct glx_config head, *tail, *m;
302
303 tail = &head;
304 head.next = NULL;
305 for (m = configs; m; m = m->next) {
306 tail->next = createDriMode(core, m, driConfigs);
307 if (tail->next == NULL) {
308 /* no matching dri config for m */
309 continue;
310 }
311
312
313 tail = tail->next;
314 }
315
316 return head.next;
317 }
318
319 _X_HIDDEN void
320 driDestroyConfigs(const __DRIconfig **configs)
321 {
322 int i;
323
324 for (i = 0; configs[i]; i++)
325 free((__DRIconfig *) configs[i]);
326 free(configs);
327 }
328
329 static struct glx_config *
330 driInferDrawableConfig(struct glx_screen *psc, GLXDrawable draw)
331 {
332 unsigned int fbconfig = 0;
333
334 if (__glXGetDrawableAttribute(psc->dpy, draw, GLX_FBCONFIG_ID, &fbconfig)) {
335 return glx_config_find_fbconfig(psc->configs, fbconfig);
336 }
337
338 return NULL;
339 }
340
341 _X_HIDDEN __GLXDRIdrawable *
342 driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
343 {
344 struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
345 __GLXDRIdrawable *pdraw;
346 struct glx_screen *psc;
347 struct glx_config *config = gc->config;
348
349 if (priv == NULL)
350 return NULL;
351
352 if (glxDrawable == None)
353 return NULL;
354
355 psc = priv->screens[gc->screen];
356 if (priv->drawHash == NULL)
357 return NULL;
358
359 if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) {
360 pdraw->refcount ++;
361 return pdraw;
362 }
363
364 if (config == NULL)
365 config = driInferDrawableConfig(gc->psc, glxDrawable);
366 if (config == NULL)
367 return NULL;
368
369 pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
370 config);
371
372 if (pdraw == NULL) {
373 ErrorMessageF("failed to create drawable\n");
374 return NULL;
375 }
376
377 if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
378 (*pdraw->destroyDrawable) (pdraw);
379 return NULL;
380 }
381 pdraw->refcount = 1;
382
383 return pdraw;
384 }
385
386 _X_HIDDEN void
387 driReleaseDrawables(struct glx_context *gc)
388 {
389 const struct glx_display *priv = gc->psc->display;
390 __GLXDRIdrawable *pdraw;
391
392 if (priv == NULL)
393 return;
394
395 if (__glxHashLookup(priv->drawHash,
396 gc->currentDrawable, (void *) &pdraw) == 0) {
397 if (pdraw->drawable == pdraw->xDrawable) {
398 pdraw->refcount --;
399 if (pdraw->refcount == 0) {
400 pdraw->destroyDrawable(pdraw);
401 __glxHashDelete(priv->drawHash, gc->currentDrawable);
402 }
403 }
404 }
405
406 if (__glxHashLookup(priv->drawHash,
407 gc->currentReadable, (void *) &pdraw) == 0) {
408 if (pdraw->drawable == pdraw->xDrawable) {
409 pdraw->refcount --;
410 if (pdraw->refcount == 0) {
411 pdraw->destroyDrawable(pdraw);
412 __glxHashDelete(priv->drawHash, gc->currentReadable);
413 }
414 }
415 }
416
417 gc->currentDrawable = None;
418 gc->currentReadable = None;
419
420 }
421
422 _X_HIDDEN bool
423 dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
424 unsigned *major_ver, unsigned *minor_ver,
425 uint32_t *render_type, uint32_t *flags, unsigned *api,
426 int *reset, int *release, unsigned *error)
427 {
428 unsigned i;
429 bool got_profile = false;
430 int no_error = 0;
431 uint32_t profile;
432
433 *major_ver = 1;
434 *minor_ver = 0;
435 *render_type = GLX_RGBA_TYPE;
436 *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
437 *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
438 *flags = 0;
439 *api = __DRI_API_OPENGL;
440
441 if (num_attribs == 0) {
442 return true;
443 }
444
445 /* This is actually an internal error, but what the heck.
446 */
447 if (attribs == NULL) {
448 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
449 return false;
450 }
451
452 for (i = 0; i < num_attribs; i++) {
453 switch (attribs[i * 2]) {
454 case GLX_CONTEXT_MAJOR_VERSION_ARB:
455 *major_ver = attribs[i * 2 + 1];
456 break;
457 case GLX_CONTEXT_MINOR_VERSION_ARB:
458 *minor_ver = attribs[i * 2 + 1];
459 break;
460 case GLX_CONTEXT_FLAGS_ARB:
461 *flags = attribs[i * 2 + 1];
462 break;
463 case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
464 no_error = attribs[i * 2 + 1];
465 break;
466 case GLX_CONTEXT_PROFILE_MASK_ARB:
467 profile = attribs[i * 2 + 1];
468 got_profile = true;
469 break;
470 case GLX_RENDER_TYPE:
471 *render_type = attribs[i * 2 + 1];
472 break;
473 case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
474 switch (attribs[i * 2 + 1]) {
475 case GLX_NO_RESET_NOTIFICATION_ARB:
476 *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
477 break;
478 case GLX_LOSE_CONTEXT_ON_RESET_ARB:
479 *reset = __DRI_CTX_RESET_LOSE_CONTEXT;
480 break;
481 default:
482 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
483 return false;
484 }
485 break;
486 case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
487 switch (attribs[i * 2 + 1]) {
488 case GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB:
489 *release = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
490 break;
491 case GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB:
492 *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
493 break;
494 default:
495 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
496 return false;
497 }
498 break;
499 default:
500 /* If an unknown attribute is received, fail.
501 */
502 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
503 return false;
504 }
505 }
506
507 if (no_error) {
508 *flags |= __DRI_CTX_FLAG_NO_ERROR;
509 }
510
511 if (!got_profile) {
512 if (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
513 *api = __DRI_API_OPENGL_CORE;
514 } else {
515 switch (profile) {
516 case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
517 /* There are no profiles before OpenGL 3.2. The
518 * GLX_ARB_create_context_profile spec says:
519 *
520 * "If the requested OpenGL version is less than 3.2,
521 * GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
522 * of the context is determined solely by the requested version."
523 */
524 *api = (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
525 ? __DRI_API_OPENGL_CORE : __DRI_API_OPENGL;
526 break;
527 case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
528 *api = __DRI_API_OPENGL;
529 break;
530 case GLX_CONTEXT_ES_PROFILE_BIT_EXT:
531 if (*major_ver >= 3)
532 *api = __DRI_API_GLES3;
533 else if (*major_ver == 2 && *minor_ver == 0)
534 *api = __DRI_API_GLES2;
535 else if (*major_ver == 1 && *minor_ver < 2)
536 *api = __DRI_API_GLES;
537 else {
538 *error = __DRI_CTX_ERROR_BAD_API;
539 return false;
540 }
541 break;
542 default:
543 *error = __DRI_CTX_ERROR_BAD_API;
544 return false;
545 }
546 }
547
548 /* Unknown flag value.
549 */
550 if (*flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
551 | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS
552 | __DRI_CTX_FLAG_NO_ERROR)) {
553 *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
554 return false;
555 }
556
557 /* There are no forward-compatible contexts before OpenGL 3.0. The
558 * GLX_ARB_create_context spec says:
559 *
560 * "Forward-compatible contexts are defined only for OpenGL versions
561 * 3.0 and later."
562 */
563 if (*major_ver < 3 && (*flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
564 *error = __DRI_CTX_ERROR_BAD_FLAG;
565 return false;
566 }
567
568 if (*major_ver >= 3 && *render_type == GLX_COLOR_INDEX_TYPE) {
569 *error = __DRI_CTX_ERROR_BAD_FLAG;
570 return false;
571 }
572
573 *error = __DRI_CTX_ERROR_SUCCESS;
574 return true;
575 }
576
577 _X_HIDDEN bool
578 dri2_check_no_error(uint32_t flags, struct glx_context *share_context,
579 int major, unsigned *error)
580 {
581 Bool noError = flags & __DRI_CTX_FLAG_NO_ERROR;
582
583 /* The KHR_no_error specs say:
584 *
585 * Requires OpenGL ES 2.0 or OpenGL 2.0.
586 */
587 if (noError && major < 2) {
588 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
589 return false;
590 }
591
592 /* The GLX_ARB_create_context_no_error specs say:
593 *
594 * BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
595 * used to create <share_context> does not match the value of
596 * GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
597 */
598 if (share_context && !!share_context->noError != !!noError) {
599 *error = __DRI_CTX_ERROR_BAD_FLAG;
600 return false;
601 }
602
603 /* The GLX_ARB_create_context_no_error specs say:
604 *
605 * BadMatch is generated if the GLX_CONTEXT_OPENGL_NO_ERROR_ARB is TRUE at
606 * the same time as a debug or robustness context is specified.
607 *
608 */
609 if (noError && ((flags & __DRI_CTX_FLAG_DEBUG) ||
610 (flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS))) {
611 *error = __DRI_CTX_ERROR_BAD_FLAG;
612 return false;
613 }
614
615 return true;
616 }
617
618 #endif /* GLX_DIRECT_RENDERING */