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