1cffd3ad08eeafab0080ea739fa16039281eab45
[mesa.git] / src / mesa / drivers / dri / common / utils.c
1 /*
2 * (C) Copyright IBM Corporation 2002, 2004
3 * All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /**
26 * \file utils.c
27 * Utility functions for DRI drivers.
28 *
29 * \author Ian Romanick <idr@us.ibm.com>
30 */
31
32 #include <string.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <stdbool.h>
36 #include <stdint.h>
37 #include "main/macros.h"
38 #include "main/mtypes.h"
39 #include "main/cpuinfo.h"
40 #include "main/extensions.h"
41 #include "utils.h"
42 #include "dri_util.h"
43
44 /**
45 * Create the \c GL_RENDERER string for DRI drivers.
46 *
47 * Almost all DRI drivers use a \c GL_RENDERER string of the form:
48 *
49 * "Mesa DRI <chip> <driver date> <AGP speed) <CPU information>"
50 *
51 * Using the supplied chip name, driver data, and AGP speed, this function
52 * creates the string.
53 *
54 * \param buffer Buffer to hold the \c GL_RENDERER string.
55 * \param hardware_name Name of the hardware.
56 * \param agp_mode AGP mode (speed).
57 *
58 * \returns
59 * The length of the string stored in \c buffer. This does \b not include
60 * the terminating \c NUL character.
61 */
62 unsigned
63 driGetRendererString( char * buffer, const char * hardware_name,
64 GLuint agp_mode )
65 {
66 unsigned offset;
67 char *cpu;
68
69 offset = sprintf( buffer, "Mesa DRI %s", hardware_name );
70
71 /* Append any AGP-specific information.
72 */
73 switch ( agp_mode ) {
74 case 1:
75 case 2:
76 case 4:
77 case 8:
78 offset += sprintf( & buffer[ offset ], " AGP %ux", agp_mode );
79 break;
80
81 default:
82 break;
83 }
84
85 /* Append any CPU-specific information.
86 */
87 cpu = _mesa_get_cpu_string();
88 if (cpu) {
89 offset += sprintf(buffer + offset, " %s", cpu);
90 free(cpu);
91 }
92
93 return offset;
94 }
95
96
97 /**
98 * Creates a set of \c struct gl_config that a driver will expose.
99 *
100 * A set of \c struct gl_config will be created based on the supplied
101 * parameters. The number of modes processed will be 2 *
102 * \c num_depth_stencil_bits * \c num_db_modes.
103 *
104 * For the most part, data is just copied from \c depth_bits, \c stencil_bits,
105 * \c db_modes, and \c visType into each \c struct gl_config element.
106 * However, the meanings of \c fb_format and \c fb_type require further
107 * explanation. The \c fb_format specifies which color components are in
108 * each pixel and what the default order is. For example, \c GL_RGB specifies
109 * that red, green, blue are available and red is in the "most significant"
110 * position and blue is in the "least significant". The \c fb_type specifies
111 * the bit sizes of each component and the actual ordering. For example, if
112 * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11]
113 * are the blue value, bits [10:5] are the green value, and bits [4:0] are
114 * the red value.
115 *
116 * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either
117 * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the
118 * \c struct gl_config structure is \b identical to the \c GL_RGBA or
119 * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as
120 * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8
121 * still uses 32-bits.
122 *
123 * If in doubt, look at the tables used in the function.
124 *
125 * \param ptr_to_modes Pointer to a pointer to a linked list of
126 * \c struct gl_config. Upon completion, a pointer to
127 * the next element to be process will be stored here.
128 * If the function fails and returns \c GL_FALSE, this
129 * value will be unmodified, but some elements in the
130 * linked list may be modified.
131 * \param format Mesa mesa_format enum describing the pixel format
132 * \param depth_bits Array of depth buffer sizes to be exposed.
133 * \param stencil_bits Array of stencil buffer sizes to be exposed.
134 * \param num_depth_stencil_bits Number of entries in both \c depth_bits and
135 * \c stencil_bits.
136 * \param db_modes Array of buffer swap modes. If an element has a
137 * value of \c GLX_NONE, then it represents a
138 * single-buffered mode. Other valid values are
139 * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and
140 * \c GLX_SWAP_UNDEFINED_OML. See the
141 * GLX_OML_swap_method extension spec for more details.
142 * \param num_db_modes Number of entries in \c db_modes.
143 * \param msaa_samples Array of msaa sample count. 0 represents a visual
144 * without a multisample buffer.
145 * \param num_msaa_modes Number of entries in \c msaa_samples.
146 * \param enable_accum Add an accum buffer to the configs
147 * \param color_depth_match Whether the color depth must match the zs depth
148 * This forces 32-bit color to have 24-bit depth, and
149 * 16-bit color to have 16-bit depth.
150 *
151 * \returns
152 * Pointer to any array of pointers to the \c __DRIconfig structures created
153 * for the specified formats. If there is an error, \c NULL is returned.
154 * Currently the only cause of failure is a bad parameter (i.e., unsupported
155 * \c format).
156 */
157 __DRIconfig **
158 driCreateConfigs(mesa_format format,
159 const uint8_t * depth_bits, const uint8_t * stencil_bits,
160 unsigned num_depth_stencil_bits,
161 const GLenum * db_modes, unsigned num_db_modes,
162 const uint8_t * msaa_samples, unsigned num_msaa_modes,
163 GLboolean enable_accum, GLboolean color_depth_match)
164 {
165 static const uint32_t masks_table[][4] = {
166 /* MESA_FORMAT_B5G6R5_UNORM */
167 { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 },
168 /* MESA_FORMAT_B8G8R8X8_UNORM */
169 { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 },
170 /* MESA_FORMAT_B8G8R8A8_UNORM */
171 { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 },
172 /* MESA_FORMAT_B10G10R10X2_UNORM */
173 { 0x3FF00000, 0x000FFC00, 0x000003FF, 0x00000000 },
174 /* MESA_FORMAT_B10G10R10A2_UNORM */
175 { 0x3FF00000, 0x000FFC00, 0x000003FF, 0xC0000000 },
176 /* MESA_FORMAT_R8G8B8A8_UNORM */
177 { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 },
178 /* MESA_FORMAT_R8G8B8X8_UNORM */
179 { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 },
180 /* MESA_FORMAT_R10G10B10X2_UNORM */
181 { 0x000003FF, 0x000FFC00, 0x3FF00000, 0x00000000 },
182 /* MESA_FORMAT_R10G10B10A2_UNORM */
183 { 0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000 },
184 };
185
186 const uint32_t * masks;
187 __DRIconfig **configs, **c;
188 struct gl_config *modes;
189 unsigned i, j, k, h;
190 unsigned num_modes;
191 unsigned num_accum_bits = (enable_accum) ? 2 : 1;
192 int red_bits;
193 int green_bits;
194 int blue_bits;
195 int alpha_bits;
196 bool is_srgb;
197
198 switch (format) {
199 case MESA_FORMAT_B5G6R5_UNORM:
200 masks = masks_table[0];
201 break;
202 case MESA_FORMAT_B8G8R8X8_UNORM:
203 case MESA_FORMAT_B8G8R8X8_SRGB:
204 masks = masks_table[1];
205 break;
206 case MESA_FORMAT_B8G8R8A8_UNORM:
207 case MESA_FORMAT_B8G8R8A8_SRGB:
208 masks = masks_table[2];
209 break;
210 case MESA_FORMAT_R8G8B8A8_UNORM:
211 masks = masks_table[5];
212 break;
213 case MESA_FORMAT_R8G8B8X8_UNORM:
214 masks = masks_table[6];
215 break;
216 case MESA_FORMAT_B10G10R10X2_UNORM:
217 masks = masks_table[3];
218 break;
219 case MESA_FORMAT_B10G10R10A2_UNORM:
220 masks = masks_table[4];
221 break;
222 case MESA_FORMAT_R10G10B10X2_UNORM:
223 masks = masks_table[7];
224 break;
225 case MESA_FORMAT_R10G10B10A2_UNORM:
226 masks = masks_table[8];
227 break;
228 default:
229 fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n",
230 __func__, __LINE__,
231 _mesa_get_format_name(format), format);
232 return NULL;
233 }
234
235 red_bits = _mesa_get_format_bits(format, GL_RED_BITS);
236 green_bits = _mesa_get_format_bits(format, GL_GREEN_BITS);
237 blue_bits = _mesa_get_format_bits(format, GL_BLUE_BITS);
238 alpha_bits = _mesa_get_format_bits(format, GL_ALPHA_BITS);
239 is_srgb = _mesa_get_format_color_encoding(format) == GL_SRGB;
240
241 num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * num_msaa_modes;
242 configs = calloc(num_modes + 1, sizeof *configs);
243 if (configs == NULL)
244 return NULL;
245
246 c = configs;
247 for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
248 for ( i = 0 ; i < num_db_modes ; i++ ) {
249 for ( h = 0 ; h < num_msaa_modes; h++ ) {
250 for ( j = 0 ; j < num_accum_bits ; j++ ) {
251 if (color_depth_match &&
252 (depth_bits[k] || stencil_bits[k])) {
253 /* Depth can really only be 0, 16, 24, or 32. A 32-bit
254 * color format still matches 24-bit depth, as there
255 * is an implicit 8-bit stencil. So really we just
256 * need to make sure that color/depth are both 16 or
257 * both non-16.
258 */
259 if ((depth_bits[k] + stencil_bits[k] == 16) !=
260 (red_bits + green_bits + blue_bits + alpha_bits == 16))
261 continue;
262 }
263
264 *c = malloc (sizeof **c);
265 modes = &(*c)->modes;
266 c++;
267
268 memset(modes, 0, sizeof *modes);
269 modes->redBits = red_bits;
270 modes->greenBits = green_bits;
271 modes->blueBits = blue_bits;
272 modes->alphaBits = alpha_bits;
273 modes->redMask = masks[0];
274 modes->greenMask = masks[1];
275 modes->blueMask = masks[2];
276 modes->alphaMask = masks[3];
277 modes->rgbBits = modes->redBits + modes->greenBits
278 + modes->blueBits + modes->alphaBits;
279
280 modes->accumRedBits = 16 * j;
281 modes->accumGreenBits = 16 * j;
282 modes->accumBlueBits = 16 * j;
283 modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
284 modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
285
286 modes->stencilBits = stencil_bits[k];
287 modes->depthBits = depth_bits[k];
288
289 modes->transparentPixel = GLX_NONE;
290 modes->transparentRed = GLX_DONT_CARE;
291 modes->transparentGreen = GLX_DONT_CARE;
292 modes->transparentBlue = GLX_DONT_CARE;
293 modes->transparentAlpha = GLX_DONT_CARE;
294 modes->transparentIndex = GLX_DONT_CARE;
295 modes->rgbMode = GL_TRUE;
296
297 if (db_modes[i] == __DRI_ATTRIB_SWAP_NONE) {
298 modes->doubleBufferMode = GL_FALSE;
299 modes->swapMethod = __DRI_ATTRIB_SWAP_UNDEFINED;
300 }
301 else {
302 modes->doubleBufferMode = GL_TRUE;
303 modes->swapMethod = db_modes[i];
304 }
305
306 modes->samples = msaa_samples[h];
307 modes->sampleBuffers = modes->samples ? 1 : 0;
308
309
310 modes->haveAccumBuffer = ((modes->accumRedBits +
311 modes->accumGreenBits +
312 modes->accumBlueBits +
313 modes->accumAlphaBits) > 0);
314 modes->haveDepthBuffer = (modes->depthBits > 0);
315 modes->haveStencilBuffer = (modes->stencilBits > 0);
316
317 modes->bindToTextureRgb = GL_TRUE;
318 modes->bindToTextureRgba = GL_TRUE;
319 modes->bindToMipmapTexture = GL_FALSE;
320 modes->bindToTextureTargets =
321 __DRI_ATTRIB_TEXTURE_1D_BIT |
322 __DRI_ATTRIB_TEXTURE_2D_BIT |
323 __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT;
324
325 modes->yInverted = GL_TRUE;
326 modes->sRGBCapable = is_srgb;
327 }
328 }
329 }
330 }
331 *c = NULL;
332
333 return configs;
334 }
335
336 __DRIconfig **driConcatConfigs(__DRIconfig **a,
337 __DRIconfig **b)
338 {
339 __DRIconfig **all;
340 int i, j, index;
341
342 if (a == NULL || a[0] == NULL)
343 return b;
344 else if (b == NULL || b[0] == NULL)
345 return a;
346
347 i = 0;
348 while (a[i] != NULL)
349 i++;
350 j = 0;
351 while (b[j] != NULL)
352 j++;
353
354 all = malloc((i + j + 1) * sizeof *all);
355 index = 0;
356 for (i = 0; a[i] != NULL; i++)
357 all[index++] = a[i];
358 for (j = 0; b[j] != NULL; j++)
359 all[index++] = b[j];
360 all[index++] = NULL;
361
362 free(a);
363 free(b);
364
365 return all;
366 }
367
368 #define __ATTRIB(attrib, field) \
369 { attrib, offsetof(struct gl_config, field) }
370
371 static const struct { unsigned int attrib, offset; } attribMap[] = {
372 __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits),
373 __ATTRIB(__DRI_ATTRIB_LEVEL, level),
374 __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits),
375 __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits),
376 __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits),
377 __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits),
378 __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits),
379 __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits),
380 __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits),
381 __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits),
382 __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits),
383 __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits),
384 __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers),
385 __ATTRIB(__DRI_ATTRIB_SAMPLES, samples),
386 __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode),
387 __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode),
388 __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers),
389 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel),
390 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentPixel),
391 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed),
392 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen),
393 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue),
394 __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha),
395 __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask),
396 __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask),
397 __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask),
398 __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask),
399 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth),
400 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight),
401 __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels),
402 __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth),
403 __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight),
404 __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod),
405 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb),
406 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba),
407 __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture),
408 __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS, bindToTextureTargets),
409 __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted),
410 __ATTRIB(__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE, sRGBCapable),
411
412 /* The struct field doesn't matter here, these are handled by the
413 * switch in driGetConfigAttribIndex. We need them in the array
414 * so the iterator includes them though.*/
415 __ATTRIB(__DRI_ATTRIB_RENDER_TYPE, level),
416 __ATTRIB(__DRI_ATTRIB_CONFIG_CAVEAT, level),
417 };
418
419
420 /**
421 * Return the value of a configuration attribute. The attribute is
422 * indicated by the index.
423 */
424 static int
425 driGetConfigAttribIndex(const __DRIconfig *config,
426 unsigned int index, unsigned int *value)
427 {
428 switch (attribMap[index].attrib) {
429 case __DRI_ATTRIB_RENDER_TYPE:
430 /* no support for color index mode */
431 *value = __DRI_ATTRIB_RGBA_BIT;
432 break;
433 case __DRI_ATTRIB_CONFIG_CAVEAT:
434 if (config->modes.visualRating == GLX_NON_CONFORMANT_CONFIG)
435 *value = __DRI_ATTRIB_NON_CONFORMANT_CONFIG;
436 else if (config->modes.visualRating == GLX_SLOW_CONFIG)
437 *value = __DRI_ATTRIB_SLOW_BIT;
438 else
439 *value = 0;
440 break;
441 default:
442 /* any other int-sized field */
443 *value = *(unsigned int *)
444 ((char *) &config->modes + attribMap[index].offset);
445
446 break;
447 }
448
449 return GL_TRUE;
450 }
451
452
453 /**
454 * Get the value of a configuration attribute.
455 * \param attrib the attribute (one of the _DRI_ATTRIB_x tokens)
456 * \param value returns the attribute's value
457 * \return 1 for success, 0 for failure
458 */
459 int
460 driGetConfigAttrib(const __DRIconfig *config,
461 unsigned int attrib, unsigned int *value)
462 {
463 unsigned i;
464
465 for (i = 0; i < ARRAY_SIZE(attribMap); i++)
466 if (attribMap[i].attrib == attrib)
467 return driGetConfigAttribIndex(config, i, value);
468
469 return GL_FALSE;
470 }
471
472
473 /**
474 * Get a configuration attribute name and value, given an index.
475 * \param index which field of the __DRIconfig to query
476 * \param attrib returns the attribute name (one of the _DRI_ATTRIB_x tokens)
477 * \param value returns the attribute's value
478 * \return 1 for success, 0 for failure
479 */
480 int
481 driIndexConfigAttrib(const __DRIconfig *config, int index,
482 unsigned int *attrib, unsigned int *value)
483 {
484 if (index >= 0 && index < ARRAY_SIZE(attribMap)) {
485 *attrib = attribMap[index].attrib;
486 return driGetConfigAttribIndex(config, index, value);
487 }
488
489 return GL_FALSE;
490 }
491
492 /**
493 * Implement queries for values that are common across all Mesa drivers
494 *
495 * Currently only the following queries are supported by this function:
496 *
497 * - \c __DRI2_RENDERER_VERSION
498 * - \c __DRI2_RENDERER_PREFERRED_PROFILE
499 * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION
500 * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION
501 * - \c __DRI2_RENDERER_ES_PROFILE_VERSION
502 * - \c __DRI2_RENDERER_ES2_PROFILE_VERSION
503 *
504 * \returns
505 * Zero if a recognized value of \c param is supplied, -1 otherwise.
506 */
507 int
508 driQueryRendererIntegerCommon(__DRIscreen *psp, int param, unsigned int *value)
509 {
510 switch (param) {
511 case __DRI2_RENDERER_VERSION: {
512 static const char *const ver = PACKAGE_VERSION;
513 char *endptr;
514 int v[3];
515
516 v[0] = strtol(ver, &endptr, 10);
517 assert(endptr[0] == '.');
518 if (endptr[0] != '.')
519 return -1;
520
521 v[1] = strtol(endptr + 1, &endptr, 10);
522 assert(endptr[0] == '.');
523 if (endptr[0] != '.')
524 return -1;
525
526 v[2] = strtol(endptr + 1, &endptr, 10);
527
528 value[0] = v[0];
529 value[1] = v[1];
530 value[2] = v[2];
531 return 0;
532 }
533 case __DRI2_RENDERER_PREFERRED_PROFILE:
534 value[0] = (psp->max_gl_core_version != 0)
535 ? (1U << __DRI_API_OPENGL_CORE) : (1U << __DRI_API_OPENGL);
536 return 0;
537 case __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION:
538 value[0] = psp->max_gl_core_version / 10;
539 value[1] = psp->max_gl_core_version % 10;
540 return 0;
541 case __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION:
542 value[0] = psp->max_gl_compat_version / 10;
543 value[1] = psp->max_gl_compat_version % 10;
544 return 0;
545 case __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION:
546 value[0] = psp->max_gl_es1_version / 10;
547 value[1] = psp->max_gl_es1_version % 10;
548 return 0;
549 case __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION:
550 value[0] = psp->max_gl_es2_version / 10;
551 value[1] = psp->max_gl_es2_version % 10;
552 return 0;
553 default:
554 break;
555 }
556
557 return -1;
558 }