Fixes for bugs that were nailed down when compairing against software vertex shading.
[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 <stdlib.h>
34 #include "mtypes.h"
35 #include "extensions.h"
36 #include "utils.h"
37
38 #if !defined( DRI_NEW_INTERFACE_ONLY )
39 #include "xf86dri.h" /* For XF86DRIQueryVersion prototype. */
40 #endif
41
42 #if defined(USE_X86_ASM)
43 #include "x86/common_x86_asm.h"
44 #endif
45
46 #if defined(USE_PPC_ASM)
47 #include "ppc/common_ppc_features.h"
48 #endif
49
50 unsigned
51 driParseDebugString( const char * debug,
52 const struct dri_debug_control * control )
53 {
54 unsigned flag;
55
56
57 flag = 0;
58 if ( debug != NULL ) {
59 while( control->string != NULL ) {
60 if ( !strcmp( debug, "all" ) ||
61 strstr( debug, control->string ) != NULL ) {
62 flag |= control->flag;
63 }
64
65 control++;
66 }
67 }
68
69 return flag;
70 }
71
72
73
74 /**
75 * Create the \c GL_RENDERER string for DRI drivers.
76 *
77 * Almost all DRI drivers use a \c GL_RENDERER string of the form:
78 *
79 * "Mesa DRI <chip> <driver date> <AGP speed) <CPU information>"
80 *
81 * Using the supplied chip name, driver data, and AGP speed, this function
82 * creates the string.
83 *
84 * \param buffer Buffer to hold the \c GL_RENDERER string.
85 * \param hardware_name Name of the hardware.
86 * \param driver_date Driver date.
87 * \param agp_mode AGP mode (speed).
88 *
89 * \returns
90 * The length of the string stored in \c buffer. This does \b not include
91 * the terminating \c NUL character.
92 */
93 unsigned
94 driGetRendererString( char * buffer, const char * hardware_name,
95 const char * driver_date, GLuint agp_mode )
96 {
97 #define MAX_INFO 4
98 const char * cpu[MAX_INFO];
99 unsigned next = 0;
100 unsigned i;
101 unsigned offset;
102
103
104 offset = sprintf( buffer, "Mesa DRI %s %s", hardware_name, driver_date );
105
106 /* Append any AGP-specific information.
107 */
108 switch ( agp_mode ) {
109 case 1:
110 case 2:
111 case 4:
112 case 8:
113 offset += sprintf( & buffer[ offset ], " AGP %ux", agp_mode );
114 break;
115
116 default:
117 break;
118 }
119
120 /* Append any CPU-specific information.
121 */
122 #ifdef USE_X86_ASM
123 if ( _mesa_x86_cpu_features ) {
124 cpu[next] = " x86";
125 next++;
126 }
127 # ifdef USE_MMX_ASM
128 if ( cpu_has_mmx ) {
129 cpu[next] = (cpu_has_mmxext) ? "/MMX+" : "/MMX";
130 next++;
131 }
132 # endif
133 # ifdef USE_3DNOW_ASM
134 if ( cpu_has_3dnow ) {
135 cpu[next] = (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!";
136 next++;
137 }
138 # endif
139 # ifdef USE_SSE_ASM
140 if ( cpu_has_xmm ) {
141 cpu[next] = (cpu_has_xmm2) ? "/SSE2" : "/SSE";
142 next++;
143 }
144 # endif
145
146 #elif defined(USE_SPARC_ASM)
147
148 cpu[0] = " SPARC";
149 next = 1;
150
151 #elif defined(USE_PPC_ASM)
152 if ( _mesa_ppc_cpu_features ) {
153 cpu[next] = (cpu_has_64) ? " PowerPC 64" : " PowerPC";
154 next++;
155 }
156
157 # ifdef USE_VMX_ASM
158 if ( cpu_has_vmx ) {
159 cpu[next] = "/Altivec";
160 next++;
161 }
162 # endif
163
164 if ( ! cpu_has_fpu ) {
165 cpu[next] = "/No FPU";
166 next++;
167 }
168 #endif
169
170 for ( i = 0 ; i < next ; i++ ) {
171 const size_t len = strlen( cpu[i] );
172
173 strncpy( & buffer[ offset ], cpu[i], len );
174 offset += len;
175 }
176
177 return offset;
178 }
179
180
181
182
183 void driInitExtensions( GLcontext * ctx,
184 const char * const extensions_to_enable[],
185 GLboolean enable_imaging )
186 {
187 unsigned i;
188
189 if ( enable_imaging ) {
190 _mesa_enable_imaging_extensions( ctx );
191 }
192
193 for ( i = 0 ; extensions_to_enable[i] != NULL ; i++ ) {
194 _mesa_enable_extension( ctx, extensions_to_enable[i] );
195 }
196 }
197
198
199
200
201 #ifndef DRI_NEW_INTERFACE_ONLY
202 /**
203 * Utility function used by drivers to test the verions of other components.
204 *
205 * \deprecated
206 * All drivers using the new interface should use \c driCheckDriDdxVersions2
207 * instead. This function is implemented using a call that is not available
208 * to drivers using the new interface. Furthermore, the information gained
209 * by this call (the DRI and DDX version information) is already provided to
210 * the driver via the new interface.
211 */
212 GLboolean
213 driCheckDriDdxDrmVersions(__DRIscreenPrivate *sPriv,
214 const char * driver_name,
215 int dri_major, int dri_minor,
216 int ddx_major, int ddx_minor,
217 int drm_major, int drm_minor)
218 {
219 static const char format[] = "%s DRI driver expected %s version %d.%d.x "
220 "but got version %d.%d.%d";
221 int major, minor, patch;
222
223 /* Check the DRI version */
224 if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) {
225 if (major != dri_major || minor < dri_minor) {
226 __driUtilMessage(format, driver_name, "DRI", dri_major, dri_minor,
227 major, minor, patch);
228 return GL_FALSE;
229 }
230 }
231
232 /* Check that the DDX driver version is compatible */
233 if (sPriv->ddxMajor != ddx_major || sPriv->ddxMinor < ddx_minor) {
234 __driUtilMessage(format, driver_name, "DDX", ddx_major, ddx_minor,
235 sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch);
236 return GL_FALSE;
237 }
238
239 /* Check that the DRM driver version is compatible */
240 if (sPriv->drmMajor != drm_major || sPriv->drmMinor < drm_minor) {
241 __driUtilMessage(format, driver_name, "DRM", drm_major, drm_minor,
242 sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch);
243 return GL_FALSE;
244 }
245
246 return GL_TRUE;
247 }
248 #endif /* DRI_NEW_INTERFACE_ONLY */
249
250 /**
251 * Utility function used by drivers to test the verions of other components.
252 *
253 * If one of the version requirements is not met, a message is logged using
254 * \c __driUtilMessage.
255 *
256 * \param driver_name Name of the driver. Used in error messages.
257 * \param driActual Actual DRI version supplied __driCreateNewScreen.
258 * \param driExpected Minimum DRI version required by the driver.
259 * \param ddxActual Actual DDX version supplied __driCreateNewScreen.
260 * \param ddxExpected Minimum DDX minor and range of DDX major version required by the driver.
261 * \param drmActual Actual DRM version supplied __driCreateNewScreen.
262 * \param drmExpected Minimum DRM version required by the driver.
263 *
264 * \returns \c GL_TRUE if all version requirements are met. Otherwise,
265 * \c GL_FALSE is returned.
266 *
267 * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions, __driUtilMessage
268 */
269 GLboolean
270 driCheckDriDdxDrmVersions3(const char * driver_name,
271 const __DRIversion * driActual,
272 const __DRIversion * driExpected,
273 const __DRIversion * ddxActual,
274 const __DRIutilversion2 * ddxExpected,
275 const __DRIversion * drmActual,
276 const __DRIversion * drmExpected)
277 {
278 static const char format[] = "%s DRI driver expected %s version %d.%d.x "
279 "but got version %d.%d.%d";
280 static const char format2[] = "%s DRI driver expected %s version %d-%d.%d.x "
281 "but got version %d.%d.%d";
282
283
284 /* Check the DRI version */
285 if ( (driActual->major != driExpected->major)
286 || (driActual->minor < driExpected->minor) ) {
287 __driUtilMessage(format, driver_name, "DRI",
288 driExpected->major, driExpected->minor,
289 driActual->major, driActual->minor, driActual->patch);
290 return GL_FALSE;
291 }
292
293 /* Check that the DDX driver version is compatible */
294 if ( (ddxActual->major < ddxExpected->major_min)
295 || (ddxActual->major > ddxExpected->major_max)
296 || (ddxActual->minor < ddxExpected->minor) ) {
297 __driUtilMessage(format2, driver_name, "DDX",
298 ddxExpected->major_min, ddxExpected->major_max, ddxExpected->minor,
299 ddxActual->major, ddxActual->minor, ddxActual->patch);
300 return GL_FALSE;
301 }
302
303 /* Check that the DRM driver version is compatible */
304 if ( (drmActual->major != drmExpected->major)
305 || (drmActual->minor < drmExpected->minor) ) {
306 __driUtilMessage(format, driver_name, "DRM",
307 drmExpected->major, drmExpected->minor,
308 drmActual->major, drmActual->minor, drmActual->patch);
309 return GL_FALSE;
310 }
311
312 return GL_TRUE;
313 }
314
315 GLboolean
316 driCheckDriDdxDrmVersions2(const char * driver_name,
317 const __DRIversion * driActual,
318 const __DRIversion * driExpected,
319 const __DRIversion * ddxActual,
320 const __DRIversion * ddxExpected,
321 const __DRIversion * drmActual,
322 const __DRIversion * drmExpected)
323 {
324 __DRIutilversion2 ddx_expected;
325 ddx_expected.major_min = ddxExpected->major;
326 ddx_expected.major_max = ddxExpected->major;
327 ddx_expected.minor = ddxExpected->minor;
328 ddx_expected.patch = ddxExpected->patch;
329 return driCheckDriDdxDrmVersions3(driver_name, driActual,
330 driExpected, ddxActual, & ddx_expected,
331 drmActual, drmExpected);
332 }
333
334
335
336 GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
337 GLint *x, GLint *y,
338 GLsizei *width, GLsizei *height )
339 {
340 /* left clipping */
341 if (*x < buffer->_Xmin) {
342 *width -= (buffer->_Xmin - *x);
343 *x = buffer->_Xmin;
344 }
345
346 /* right clipping */
347 if (*x + *width > buffer->_Xmax)
348 *width -= (*x + *width - buffer->_Xmax - 1);
349
350 if (*width <= 0)
351 return GL_FALSE;
352
353 /* bottom clipping */
354 if (*y < buffer->_Ymin) {
355 *height -= (buffer->_Ymin - *y);
356 *y = buffer->_Ymin;
357 }
358
359 /* top clipping */
360 if (*y + *height > buffer->_Ymax)
361 *height -= (*y + *height - buffer->_Ymax - 1);
362
363 if (*height <= 0)
364 return GL_FALSE;
365
366 return GL_TRUE;
367 }
368
369
370
371 /**
372 * Creates a set of \c __GLcontextModes that a driver will expose.
373 *
374 * A set of \c __GLcontextModes will be created based on the supplied
375 * parameters. The number of modes processed will be 2 *
376 * \c num_depth_stencil_bits * \c num_db_modes.
377 *
378 * For the most part, data is just copied from \c depth_bits, \c stencil_bits,
379 * \c db_modes, and \c visType into each \c __GLcontextModes element.
380 * However, the meanings of \c fb_format and \c fb_type require further
381 * explanation. The \c fb_format specifies which color components are in
382 * each pixel and what the default order is. For example, \c GL_RGB specifies
383 * that red, green, blue are available and red is in the "most significant"
384 * position and blue is in the "least significant". The \c fb_type specifies
385 * the bit sizes of each component and the actual ordering. For example, if
386 * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11]
387 * are the blue value, bits [10:5] are the green value, and bits [4:0] are
388 * the red value.
389 *
390 * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either
391 * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the
392 * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or
393 * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as
394 * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8
395 * still uses 32-bits.
396 *
397 * If in doubt, look at the tables used in the function.
398 *
399 * \param ptr_to_modes Pointer to a pointer to a linked list of
400 * \c __GLcontextModes. Upon completion, a pointer to
401 * the next element to be process will be stored here.
402 * If the function fails and returns \c GL_FALSE, this
403 * value will be unmodified, but some elements in the
404 * linked list may be modified.
405 * \param fb_format Format of the framebuffer. Currently only \c GL_RGB,
406 * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported.
407 * \param fb_type Type of the pixels in the framebuffer. Currently only
408 * \c GL_UNSIGNED_SHORT_5_6_5,
409 * \c GL_UNSIGNED_SHORT_5_6_5_REV,
410 * \c GL_UNSIGNED_INT_8_8_8_8, and
411 * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported.
412 * \param depth_bits Array of depth buffer sizes to be exposed.
413 * \param stencil_bits Array of stencil buffer sizes to be exposed.
414 * \param num_depth_stencil_bits Number of entries in both \c depth_bits and
415 * \c stencil_bits.
416 * \param db_modes Array of buffer swap modes. If an element has a
417 * value of \c GLX_NONE, then it represents a
418 * single-buffered mode. Other valid values are
419 * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and
420 * \c GLX_SWAP_UNDEFINED_OML. See the
421 * GLX_OML_swap_method extension spec for more details.
422 * \param num_db_modes Number of entries in \c db_modes.
423 * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or
424 * \c GLX_DIRECT_COLOR.
425 *
426 * \returns
427 * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only
428 * cause of failure is a bad parameter (i.e., unsupported \c fb_format or
429 * \c fb_type).
430 *
431 * \todo
432 * There is currently no way to support packed RGB modes (i.e., modes with
433 * exactly 3 bytes per pixel) or floating-point modes. This could probably
434 * be done by creating some new, private enums with clever names likes
435 * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32,
436 * \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it.
437 */
438 GLboolean
439 driFillInModes( __GLcontextModes ** ptr_to_modes,
440 GLenum fb_format, GLenum fb_type,
441 const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
442 unsigned num_depth_stencil_bits,
443 const GLenum * db_modes, unsigned num_db_modes,
444 int visType )
445 {
446 static const u_int8_t bits_table[3][4] = {
447 /* R G B A */
448 { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */
449 { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */
450 { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */
451 };
452
453 /* The following arrays are all indexed by the fb_type masked with 0x07.
454 * Given the four supported fb_type values, this results in valid array
455 * indices of 3, 4, 5, and 7.
456 */
457 static const u_int32_t masks_table_rgb[8][4] = {
458 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
459 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
460 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
461 { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */
462 { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */
463 { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 }, /* 8_8_8_8 */
464 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
465 { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 } /* 8_8_8_8_REV */
466 };
467
468 static const u_int32_t masks_table_rgba[8][4] = {
469 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
470 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
471 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
472 { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */
473 { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */
474 { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF }, /* 8_8_8_8 */
475 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
476 { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }, /* 8_8_8_8_REV */
477 };
478
479 static const u_int32_t masks_table_bgr[8][4] = {
480 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
481 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
482 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
483 { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */
484 { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */
485 { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 }, /* 8_8_8_8 */
486 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
487 { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, /* 8_8_8_8_REV */
488 };
489
490 static const u_int32_t masks_table_bgra[8][4] = {
491 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
492 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
493 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
494 { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */
495 { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */
496 { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF }, /* 8_8_8_8 */
497 { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
498 { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }, /* 8_8_8_8_REV */
499 };
500
501 static const u_int8_t bytes_per_pixel[8] = {
502 0, 0, 0, 2, 2, 4, 0, 4
503 };
504
505 const u_int8_t * bits;
506 const u_int32_t * masks;
507 const int index = fb_type & 0x07;
508 __GLcontextModes * modes = *ptr_to_modes;
509 unsigned i;
510 unsigned j;
511 unsigned k;
512
513
514 if ( bytes_per_pixel[ index ] == 0 ) {
515 fprintf( stderr, "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.\n",
516 __FUNCTION__, __LINE__, fb_type );
517 return GL_FALSE;
518 }
519
520
521 /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and
522 * the _REV versions.
523 *
524 * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA.
525 */
526
527 switch ( fb_format ) {
528 case GL_RGB:
529 bits = (bytes_per_pixel[ index ] == 2)
530 ? bits_table[0] : bits_table[1];
531 masks = masks_table_rgb[ index ];
532 break;
533
534 case GL_RGBA:
535 bits = (bytes_per_pixel[ index ] == 2)
536 ? bits_table[0] : bits_table[2];
537 masks = masks_table_rgba[ index ];
538 break;
539
540 case GL_BGR:
541 bits = (bytes_per_pixel[ index ] == 2)
542 ? bits_table[0] : bits_table[1];
543 masks = masks_table_bgr[ index ];
544 break;
545
546 case GL_BGRA:
547 bits = (bytes_per_pixel[ index ] == 2)
548 ? bits_table[0] : bits_table[2];
549 masks = masks_table_bgra[ index ];
550 break;
551
552 default:
553 fprintf( stderr, "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.\n",
554 __FUNCTION__, __LINE__, fb_format );
555 return GL_FALSE;
556 }
557
558
559 for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
560 for ( i = 0 ; i < num_db_modes ; i++ ) {
561 for ( j = 0 ; j < 2 ; j++ ) {
562
563 modes->redBits = bits[0];
564 modes->greenBits = bits[1];
565 modes->blueBits = bits[2];
566 modes->alphaBits = bits[3];
567 modes->redMask = masks[0];
568 modes->greenMask = masks[1];
569 modes->blueMask = masks[2];
570 modes->alphaMask = masks[3];
571 modes->rgbBits = modes->redBits + modes->greenBits
572 + modes->blueBits + modes->alphaBits;
573
574 modes->accumRedBits = 16 * j;
575 modes->accumGreenBits = 16 * j;
576 modes->accumBlueBits = 16 * j;
577 modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
578 modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
579
580 modes->stencilBits = stencil_bits[k];
581 modes->depthBits = depth_bits[k];
582
583 modes->visualType = visType;
584 modes->renderType = GLX_RGBA_BIT;
585 modes->drawableType = GLX_WINDOW_BIT;
586 modes->rgbMode = GL_TRUE;
587
588 if ( db_modes[i] == GLX_NONE ) {
589 modes->doubleBufferMode = GL_FALSE;
590 }
591 else {
592 modes->doubleBufferMode = GL_TRUE;
593 modes->swapMethod = db_modes[i];
594 }
595
596 modes->haveAccumBuffer = ((modes->accumRedBits +
597 modes->accumGreenBits +
598 modes->accumBlueBits +
599 modes->accumAlphaBits) > 0);
600 modes->haveDepthBuffer = (modes->depthBits > 0);
601 modes->haveStencilBuffer = (modes->stencilBits > 0);
602
603 modes = modes->next;
604 }
605 }
606 }
607
608 *ptr_to_modes = modes;
609 return GL_TRUE;
610 }