Added few more stubs so that control reaches to DestroyDevice().
[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 __ATTRIB(__DRI_ATTRIB_RED_SHIFT, redShift),
170 __ATTRIB(__DRI_ATTRIB_GREEN_SHIFT, greenShift),
171 __ATTRIB(__DRI_ATTRIB_BLUE_SHIFT, blueShift),
172 __ATTRIB(__DRI_ATTRIB_ALPHA_SHIFT, alphaShift),
173 #endif
174 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
175 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
176 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
177 __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
178 __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
179 __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
180 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
181 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
182 __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE,
183 bindToMipmapTexture),
184 __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
185 __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable)
186 };
187
188 static int
189 scalarEqual(struct glx_config *mode, unsigned int attrib, unsigned int value)
190 {
191 unsigned glxValue, i;
192
193 for (i = 0; i < ARRAY_SIZE(attribMap); i++)
194 if (attribMap[i].attrib == attrib) {
195 glxValue = *(unsigned int *) ((char *) mode + attribMap[i].offset);
196 return glxValue == GLX_DONT_CARE || glxValue == value;
197 }
198
199 return GL_TRUE; /* Is a non-existing attribute equal to value? */
200 }
201
202 static int
203 driConfigEqual(const __DRIcoreExtension *core,
204 struct glx_config *config, const __DRIconfig *driConfig)
205 {
206 unsigned int attrib, value, glxValue;
207 int i;
208
209 i = 0;
210 while (core->indexConfigAttrib(driConfig, i++, &attrib, &value)) {
211 switch (attrib) {
212 case __DRI_ATTRIB_RENDER_TYPE:
213 glxValue = 0;
214 if (value & __DRI_ATTRIB_RGBA_BIT) {
215 glxValue |= GLX_RGBA_BIT;
216 }
217 if (value & __DRI_ATTRIB_COLOR_INDEX_BIT) {
218 glxValue |= GLX_COLOR_INDEX_BIT;
219 }
220 if (value & __DRI_ATTRIB_FLOAT_BIT) {
221 glxValue |= GLX_RGBA_FLOAT_BIT_ARB;
222 }
223 if (value & __DRI_ATTRIB_UNSIGNED_FLOAT_BIT) {
224 glxValue |= GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT;
225 }
226 if (glxValue != config->renderType)
227 return GL_FALSE;
228 break;
229
230 case __DRI_ATTRIB_CONFIG_CAVEAT:
231 if (value & __DRI_ATTRIB_NON_CONFORMANT_CONFIG)
232 glxValue = GLX_NON_CONFORMANT_CONFIG;
233 else if (value & __DRI_ATTRIB_SLOW_BIT)
234 glxValue = GLX_SLOW_CONFIG;
235 else
236 glxValue = GLX_NONE;
237 if (glxValue != config->visualRating)
238 return GL_FALSE;
239 break;
240
241 case __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS:
242 glxValue = 0;
243 if (value & __DRI_ATTRIB_TEXTURE_1D_BIT)
244 glxValue |= GLX_TEXTURE_1D_BIT_EXT;
245 if (value & __DRI_ATTRIB_TEXTURE_2D_BIT)
246 glxValue |= GLX_TEXTURE_2D_BIT_EXT;
247 if (value & __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT)
248 glxValue |= GLX_TEXTURE_RECTANGLE_BIT_EXT;
249 if (config->bindToTextureTargets != GLX_DONT_CARE &&
250 glxValue != config->bindToTextureTargets)
251 return GL_FALSE;
252 break;
253
254 case __DRI_ATTRIB_SWAP_METHOD:
255 if (value == __DRI_ATTRIB_SWAP_EXCHANGE)
256 glxValue = GLX_SWAP_EXCHANGE_OML;
257 else if (value == __DRI_ATTRIB_SWAP_COPY)
258 glxValue = GLX_SWAP_COPY_OML;
259 else
260 glxValue = GLX_SWAP_UNDEFINED_OML;
261
262 if (!scalarEqual(config, attrib, glxValue))
263 return GL_FALSE;
264
265 break;
266
267 default:
268 if (!scalarEqual(config, attrib, value))
269 return GL_FALSE;
270 }
271 }
272
273 return GL_TRUE;
274 }
275
276 static struct glx_config *
277 createDriMode(const __DRIcoreExtension * core,
278 struct glx_config *config, const __DRIconfig **driConfigs)
279 {
280 __GLXDRIconfigPrivate *driConfig;
281 int i;
282
283 for (i = 0; driConfigs[i]; i++) {
284 if (driConfigEqual(core, config, driConfigs[i]))
285 break;
286 }
287
288 if (driConfigs[i] == NULL)
289 return NULL;
290
291 driConfig = malloc(sizeof *driConfig);
292 if (driConfig == NULL)
293 return NULL;
294
295 driConfig->base = *config;
296 driConfig->driConfig = driConfigs[i];
297
298 return &driConfig->base;
299 }
300
301 _X_HIDDEN struct glx_config *
302 driConvertConfigs(const __DRIcoreExtension * core,
303 struct glx_config *configs, const __DRIconfig **driConfigs)
304 {
305 struct glx_config head, *tail, *m;
306
307 tail = &head;
308 head.next = NULL;
309 for (m = configs; m; m = m->next) {
310 tail->next = createDriMode(core, m, driConfigs);
311 if (tail->next == NULL) {
312 /* no matching dri config for m */
313 continue;
314 }
315
316
317 tail = tail->next;
318 }
319
320 return head.next;
321 }
322
323 _X_HIDDEN void
324 driDestroyConfigs(const __DRIconfig **configs)
325 {
326 int i;
327
328 for (i = 0; configs[i]; i++)
329 free((__DRIconfig *) configs[i]);
330 free(configs);
331 }
332
333 static struct glx_config *
334 driInferDrawableConfig(struct glx_screen *psc, GLXDrawable draw)
335 {
336 unsigned int fbconfig = 0;
337
338 if (__glXGetDrawableAttribute(psc->dpy, draw, GLX_FBCONFIG_ID, &fbconfig)) {
339 return glx_config_find_fbconfig(psc->configs, fbconfig);
340 }
341
342 return NULL;
343 }
344
345 _X_HIDDEN __GLXDRIdrawable *
346 driFetchDrawable(struct glx_context *gc, GLXDrawable glxDrawable)
347 {
348 struct glx_display *const priv = __glXInitialize(gc->psc->dpy);
349 __GLXDRIdrawable *pdraw;
350 struct glx_screen *psc;
351 struct glx_config *config = gc->config;
352
353 if (priv == NULL)
354 return NULL;
355
356 if (glxDrawable == None)
357 return NULL;
358
359 psc = priv->screens[gc->screen];
360 if (priv->drawHash == NULL)
361 return NULL;
362
363 if (__glxHashLookup(priv->drawHash, glxDrawable, (void *) &pdraw) == 0) {
364 pdraw->refcount ++;
365 return pdraw;
366 }
367
368 if (config == NULL)
369 config = driInferDrawableConfig(gc->psc, glxDrawable);
370 if (config == NULL)
371 return NULL;
372
373 pdraw = psc->driScreen->createDrawable(psc, glxDrawable, glxDrawable,
374 config);
375
376 if (pdraw == NULL) {
377 ErrorMessageF("failed to create drawable\n");
378 return NULL;
379 }
380
381 if (__glxHashInsert(priv->drawHash, glxDrawable, pdraw)) {
382 (*pdraw->destroyDrawable) (pdraw);
383 return NULL;
384 }
385 pdraw->refcount = 1;
386
387 return pdraw;
388 }
389
390 _X_HIDDEN void
391 driReleaseDrawables(struct glx_context *gc)
392 {
393 const struct glx_display *priv = gc->psc->display;
394 __GLXDRIdrawable *pdraw;
395
396 if (priv == NULL)
397 return;
398
399 if (__glxHashLookup(priv->drawHash,
400 gc->currentDrawable, (void *) &pdraw) == 0) {
401 if (pdraw->drawable == pdraw->xDrawable) {
402 pdraw->refcount --;
403 if (pdraw->refcount == 0) {
404 pdraw->destroyDrawable(pdraw);
405 __glxHashDelete(priv->drawHash, gc->currentDrawable);
406 }
407 }
408 }
409
410 if (__glxHashLookup(priv->drawHash,
411 gc->currentReadable, (void *) &pdraw) == 0) {
412 if (pdraw->drawable == pdraw->xDrawable) {
413 pdraw->refcount --;
414 if (pdraw->refcount == 0) {
415 pdraw->destroyDrawable(pdraw);
416 __glxHashDelete(priv->drawHash, gc->currentReadable);
417 }
418 }
419 }
420
421 gc->currentDrawable = None;
422 gc->currentReadable = None;
423
424 }
425
426 _X_HIDDEN bool
427 dri2_convert_glx_attribs(unsigned num_attribs, const uint32_t *attribs,
428 unsigned *major_ver, unsigned *minor_ver,
429 uint32_t *render_type, uint32_t *flags, unsigned *api,
430 int *reset, int *release, unsigned *error)
431 {
432 unsigned i;
433 bool got_profile = false;
434 int no_error = 0;
435 uint32_t profile;
436
437 *major_ver = 1;
438 *minor_ver = 0;
439 *render_type = GLX_RGBA_TYPE;
440 *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
441 *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
442 *flags = 0;
443 *api = __DRI_API_OPENGL;
444
445 if (num_attribs == 0) {
446 return true;
447 }
448
449 /* This is actually an internal error, but what the heck.
450 */
451 if (attribs == NULL) {
452 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
453 return false;
454 }
455
456 for (i = 0; i < num_attribs; i++) {
457 switch (attribs[i * 2]) {
458 case GLX_CONTEXT_MAJOR_VERSION_ARB:
459 *major_ver = attribs[i * 2 + 1];
460 break;
461 case GLX_CONTEXT_MINOR_VERSION_ARB:
462 *minor_ver = attribs[i * 2 + 1];
463 break;
464 case GLX_CONTEXT_FLAGS_ARB:
465 *flags = attribs[i * 2 + 1];
466 break;
467 case GLX_CONTEXT_OPENGL_NO_ERROR_ARB:
468 no_error = attribs[i * 2 + 1];
469 break;
470 case GLX_CONTEXT_PROFILE_MASK_ARB:
471 profile = attribs[i * 2 + 1];
472 got_profile = true;
473 break;
474 case GLX_RENDER_TYPE:
475 *render_type = attribs[i * 2 + 1];
476 break;
477 case GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB:
478 switch (attribs[i * 2 + 1]) {
479 case GLX_NO_RESET_NOTIFICATION_ARB:
480 *reset = __DRI_CTX_RESET_NO_NOTIFICATION;
481 break;
482 case GLX_LOSE_CONTEXT_ON_RESET_ARB:
483 *reset = __DRI_CTX_RESET_LOSE_CONTEXT;
484 break;
485 default:
486 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
487 return false;
488 }
489 break;
490 case GLX_CONTEXT_RELEASE_BEHAVIOR_ARB:
491 switch (attribs[i * 2 + 1]) {
492 case GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB:
493 *release = __DRI_CTX_RELEASE_BEHAVIOR_NONE;
494 break;
495 case GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB:
496 *release = __DRI_CTX_RELEASE_BEHAVIOR_FLUSH;
497 break;
498 default:
499 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
500 return false;
501 }
502 break;
503 default:
504 /* If an unknown attribute is received, fail.
505 */
506 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
507 return false;
508 }
509 }
510
511 if (no_error) {
512 *flags |= __DRI_CTX_FLAG_NO_ERROR;
513 }
514
515 if (!got_profile) {
516 if (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
517 *api = __DRI_API_OPENGL_CORE;
518 } else {
519 switch (profile) {
520 case GLX_CONTEXT_CORE_PROFILE_BIT_ARB:
521 /* There are no profiles before OpenGL 3.2. The
522 * GLX_ARB_create_context_profile spec says:
523 *
524 * "If the requested OpenGL version is less than 3.2,
525 * GLX_CONTEXT_PROFILE_MASK_ARB is ignored and the functionality
526 * of the context is determined solely by the requested version."
527 */
528 *api = (*major_ver > 3 || (*major_ver == 3 && *minor_ver >= 2))
529 ? __DRI_API_OPENGL_CORE : __DRI_API_OPENGL;
530 break;
531 case GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB:
532 *api = __DRI_API_OPENGL;
533 break;
534 case GLX_CONTEXT_ES_PROFILE_BIT_EXT:
535 if (*major_ver >= 3)
536 *api = __DRI_API_GLES3;
537 else if (*major_ver == 2 && *minor_ver == 0)
538 *api = __DRI_API_GLES2;
539 else if (*major_ver == 1 && *minor_ver < 2)
540 *api = __DRI_API_GLES;
541 else {
542 *error = __DRI_CTX_ERROR_BAD_API;
543 return false;
544 }
545 break;
546 default:
547 *error = __DRI_CTX_ERROR_BAD_API;
548 return false;
549 }
550 }
551
552 /* Unknown flag value.
553 */
554 if (*flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE
555 | __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS
556 | __DRI_CTX_FLAG_NO_ERROR)) {
557 *error = __DRI_CTX_ERROR_UNKNOWN_FLAG;
558 return false;
559 }
560
561 /* There are no forward-compatible contexts before OpenGL 3.0. The
562 * GLX_ARB_create_context spec says:
563 *
564 * "Forward-compatible contexts are defined only for OpenGL versions
565 * 3.0 and later."
566 */
567 if (*major_ver < 3 && (*flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) {
568 *error = __DRI_CTX_ERROR_BAD_FLAG;
569 return false;
570 }
571
572 if (*major_ver >= 3 && *render_type == GLX_COLOR_INDEX_TYPE) {
573 *error = __DRI_CTX_ERROR_BAD_FLAG;
574 return false;
575 }
576
577 *error = __DRI_CTX_ERROR_SUCCESS;
578 return true;
579 }
580
581 _X_HIDDEN bool
582 dri2_check_no_error(uint32_t flags, struct glx_context *share_context,
583 int major, unsigned *error)
584 {
585 Bool noError = flags & __DRI_CTX_FLAG_NO_ERROR;
586
587 /* The KHR_no_error specs say:
588 *
589 * Requires OpenGL ES 2.0 or OpenGL 2.0.
590 */
591 if (noError && major < 2) {
592 *error = __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE;
593 return false;
594 }
595
596 /* The GLX_ARB_create_context_no_error specs say:
597 *
598 * BadMatch is generated if the value of GLX_CONTEXT_OPENGL_NO_ERROR_ARB
599 * used to create <share_context> does not match the value of
600 * GLX_CONTEXT_OPENGL_NO_ERROR_ARB for the context being created.
601 */
602 if (share_context && !!share_context->noError != !!noError) {
603 *error = __DRI_CTX_ERROR_BAD_FLAG;
604 return false;
605 }
606
607 /* The GLX_ARB_create_context_no_error specs say:
608 *
609 * BadMatch is generated if the GLX_CONTEXT_OPENGL_NO_ERROR_ARB is TRUE at
610 * the same time as a debug or robustness context is specified.
611 *
612 */
613 if (noError && ((flags & __DRI_CTX_FLAG_DEBUG) ||
614 (flags & __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS))) {
615 *error = __DRI_CTX_ERROR_BAD_FLAG;
616 return false;
617 }
618
619 return true;
620 }
621
622 #endif /* GLX_DIRECT_RENDERING */