utils.c revision 3cce4a1e10361458630511543b7a8a6438544775
193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell/* 274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * (C) Copyright IBM Corporation 2002, 2004 393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * All Rights Reserved. 493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * 593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * copy of this software and associated documentation files (the "Software"), 793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * to deal in the Software without restriction, including without limitation 893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * on the rights to use, copy, modify, merge, publish, distribute, sub 993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * license, and/or sell copies of the Software, and to permit persons to whom 1093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * the Software is furnished to do so, subject to the following conditions: 1193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * 1293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * The above copyright notice and this permission notice (including the next 1393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * paragraph) shall be included in all copies or substantial portions of the 1493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * Software. 1593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * 1693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 1993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 2093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 2193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 2293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * USE OR OTHER DEALINGS IN THE SOFTWARE. 23447cdd536fe4539b724e8a7024659e3f4cd724d1Ian Romanick */ 24447cdd536fe4539b724e8a7024659e3f4cd724d1Ian Romanick 25447cdd536fe4539b724e8a7024659e3f4cd724d1Ian Romanick/** 26447cdd536fe4539b724e8a7024659e3f4cd724d1Ian Romanick * \file utils.c 27447cdd536fe4539b724e8a7024659e3f4cd724d1Ian Romanick * Utility functions for DRI drivers. 2893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell * 29447cdd536fe4539b724e8a7024659e3f4cd724d1Ian Romanick * \author Ian Romanick <idr@us.ibm.com> 3093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell */ 3193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 3293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell#include <string.h> 3393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell#include <stdlib.h> 34ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/mtypes.h" 35bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul#include "main/cpuinfo.h" 36ecadb51bbcb972a79f3ed79e65a7986b9396e757Brian Paul#include "main/extensions.h" 3793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell#include "utils.h" 381585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick 3993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 4093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwellunsigned 4193a458840c77b784fb74738f734ba2c5d22ca7a7Keith WhitwelldriParseDebugString( const char * debug, 4293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell const struct dri_debug_control * control ) 4393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell{ 4493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell unsigned flag; 4593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 4693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 4793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell flag = 0; 4893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell if ( debug != NULL ) { 4993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell while( control->string != NULL ) { 50462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihane if ( !strcmp( debug, "all" ) || 51462183fe4cb6df6d90632d9e2cee881c8d26b1cbAlan Hourihane strstr( debug, control->string ) != NULL ) { 5293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell flag |= control->flag; 5393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell } 5493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 5593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell control++; 5693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell } 5793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell } 5893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 5993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell return flag; 6093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell} 6193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 6293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 6393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 64b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick/** 65b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * Create the \c GL_RENDERER string for DRI drivers. 66b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * 67b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * Almost all DRI drivers use a \c GL_RENDERER string of the form: 68b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * 69b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * "Mesa DRI <chip> <driver date> <AGP speed) <CPU information>" 70b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * 71b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * Using the supplied chip name, driver data, and AGP speed, this function 72b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * creates the string. 73b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * 74b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * \param buffer Buffer to hold the \c GL_RENDERER string. 75b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * \param hardware_name Name of the hardware. 76b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * \param driver_date Driver date. 77b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * \param agp_mode AGP mode (speed). 78b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * 79b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * \returns 80b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * The length of the string stored in \c buffer. This does \b not include 81b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick * the terminating \c NUL character. 82b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick */ 8393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwellunsigned 8493a458840c77b784fb74738f734ba2c5d22ca7a7Keith WhitwelldriGetRendererString( char * buffer, const char * hardware_name, 8593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell const char * driver_date, GLuint agp_mode ) 8693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell{ 87bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul unsigned offset; 88bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul char *cpu; 8993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 9093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell offset = sprintf( buffer, "Mesa DRI %s %s", hardware_name, driver_date ); 9193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 9293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell /* Append any AGP-specific information. 9393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell */ 9493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell switch ( agp_mode ) { 9593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell case 1: 9693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell case 2: 9793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell case 4: 9893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell case 8: 9993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell offset += sprintf( & buffer[ offset ], " AGP %ux", agp_mode ); 10093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell break; 10193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 10293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell default: 10393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell break; 10493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell } 10593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 10693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell /* Append any CPU-specific information. 10793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell */ 108bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul cpu = _mesa_get_cpu_string(); 109bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul if (cpu) { 110bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul offset += sprintf(buffer + offset, " %s", cpu); 111bed3a8e1f6049a5c01d16004fc9a65225103ab9bBrian Paul _mesa_free(cpu); 112b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick } 113b72ed81818e63a70c1ded2789b9e22ee4c516aaeIan Romanick 11493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell return offset; 11593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell} 11693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 11793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 11893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 11993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 1208aa209c766b79144db499063dd1c8482562b07bfIan Romanick#define need_GL_ARB_draw_buffers 1211585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_ARB_multisample 12233fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick#define need_GL_ARB_texture_compression 1231585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_ARB_transpose_matrix 12482b9661894315362f857192439bdcbc9db090387Ian Romanick#define need_GL_ARB_vertex_buffer_object 1251585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_ARB_window_pos 1261585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_EXT_compiled_vertex_array 127474cda6fa912a766821d20b5b21d6eeba6ea9225Ian Romanick#define need_GL_EXT_multi_draw_arrays 1281585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_EXT_polygon_offset 1291585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_EXT_texture_object 1301585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_EXT_vertex_array 131474cda6fa912a766821d20b5b21d6eeba6ea9225Ian Romanick#define need_GL_IBM_multimode_draw_arrays 1321585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick#define need_GL_MESA_window_pos 1331585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick 1341b8d0f149e0afac859c4c1e1e47772bb19da0187Ian Romanick/* These are needed in *all* drivers because Mesa internally implements 1351b8d0f149e0afac859c4c1e1e47772bb19da0187Ian Romanick * certain functionality in terms of functions provided by these extensions. 1361b8d0f149e0afac859c4c1e1e47772bb19da0187Ian Romanick * For example, glBlendFunc is implemented by calling glBlendFuncSeparateEXT. 137126c89e35fb5179fe077f7593f31ea874c89dd65Ian Romanick */ 138126c89e35fb5179fe077f7593f31ea874c89dd65Ian Romanick#define need_GL_EXT_blend_func_separate 1391b8d0f149e0afac859c4c1e1e47772bb19da0187Ian Romanick#define need_GL_NV_vertex_program 140126c89e35fb5179fe077f7593f31ea874c89dd65Ian Romanick 14117ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu#include "main/remap_helper.h" 1421585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick 1431585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanickstatic const struct dri_extension all_mesa_extensions[] = { 1448aa209c766b79144db499063dd1c8482562b07bfIan Romanick { "GL_ARB_draw_buffers", GL_ARB_draw_buffers_functions }, 1451585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_ARB_multisample", GL_ARB_multisample_functions }, 14633fa5e4bfad8005f09ad3c9fc92c40fa863935d1Ian Romanick { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions }, 1471585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_ARB_transpose_matrix", GL_ARB_transpose_matrix_functions }, 14882b9661894315362f857192439bdcbc9db090387Ian Romanick { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions}, 1491585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_ARB_window_pos", GL_ARB_window_pos_functions }, 150126c89e35fb5179fe077f7593f31ea874c89dd65Ian Romanick { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions }, 1511585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions }, 152474cda6fa912a766821d20b5b21d6eeba6ea9225Ian Romanick { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions }, 1531585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_EXT_polygon_offset", GL_EXT_polygon_offset_functions }, 1541585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_EXT_texture_object", GL_EXT_texture_object_functions }, 1551585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_EXT_vertex_array", GL_EXT_vertex_array_functions }, 156474cda6fa912a766821d20b5b21d6eeba6ea9225Ian Romanick { "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions }, 1571585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { "GL_MESA_window_pos", GL_MESA_window_pos_functions }, 1581b8d0f149e0afac859c4c1e1e47772bb19da0187Ian Romanick { "GL_NV_vertex_program", GL_NV_vertex_program_functions }, 1591585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick { NULL, NULL } 1601585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick}; 1611585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick 1621585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick 163c212abf99af494f024b0b981a83350f7ac9821efIan Romanick/** 16417ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * Enable and map extensions supported by the driver. 165c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * 16617ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * When ctx is NULL, extensions are not enabled, but their functions 16717ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * are still mapped. When extensions_to_enable is NULL, all static 16817ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * functions known to mesa core are mapped. 16917ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * 170c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * \bug 171c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * ARB_imaging isn't handled properly. In Mesa, enabling ARB_imaging also 172c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * enables all the sub-extensions that are folded into it. This means that 173c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * we need to add entry-points (via \c driInitSingleExtension) for those 174c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * new functions here. 175c212abf99af494f024b0b981a83350f7ac9821efIan Romanick */ 17693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwellvoid driInitExtensions( GLcontext * ctx, 177c212abf99af494f024b0b981a83350f7ac9821efIan Romanick const struct dri_extension * extensions_to_enable, 178c212abf99af494f024b0b981a83350f7ac9821efIan Romanick GLboolean enable_imaging ) 17993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell{ 1801585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick static int first_time = 1; 18193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell unsigned i; 18293a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 1831585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick if ( first_time ) { 1841585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick first_time = 0; 18517ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu driInitExtensions( NULL, all_mesa_extensions, GL_FALSE ); 1861585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick } 1871585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick 1881585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick if ( (ctx != NULL) && enable_imaging ) { 18993a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell _mesa_enable_imaging_extensions( ctx ); 19093a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell } 19193a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 19217ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu /* The caller is too lazy to list any extension */ 19317ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu if ( extensions_to_enable == NULL ) { 19417ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu /* Map the static functions. Together with those mapped by remap 19517ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * table, this should cover everything mesa core knows. 19617ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu */ 19717ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu _mesa_map_static_functions(); 19817ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu return; 19917ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu } 20017ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu 201c212abf99af494f024b0b981a83350f7ac9821efIan Romanick for ( i = 0 ; extensions_to_enable[i].name != NULL ; i++ ) { 202c212abf99af494f024b0b981a83350f7ac9821efIan Romanick driInitSingleExtension( ctx, & extensions_to_enable[i] ); 20393a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell } 20493a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell} 20593a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 20693a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 20793a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 20893a458840c77b784fb74738f734ba2c5d22ca7a7Keith Whitwell 209c212abf99af494f024b0b981a83350f7ac9821efIan Romanick/** 21017ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * Enable and map functions for a single extension 211c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * 212c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * \param ctx Context where extension is to be enabled. 213c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * \param ext Extension that is to be enabled. 214c212abf99af494f024b0b981a83350f7ac9821efIan Romanick * 21517ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu * \sa driInitExtensions, _mesa_enable_extension, _mesa_map_function_array 216c212abf99af494f024b0b981a83350f7ac9821efIan Romanick */ 217c212abf99af494f024b0b981a83350f7ac9821efIan Romanickvoid driInitSingleExtension( GLcontext * ctx, 218c212abf99af494f024b0b981a83350f7ac9821efIan Romanick const struct dri_extension * ext ) 219c212abf99af494f024b0b981a83350f7ac9821efIan Romanick{ 220c212abf99af494f024b0b981a83350f7ac9821efIan Romanick if ( ext->functions != NULL ) { 22117ef1f6074d6107c167f1956a5c60993904c0b72Chia-I Wu _mesa_map_function_array(ext->functions); 222c212abf99af494f024b0b981a83350f7ac9821efIan Romanick } 223c212abf99af494f024b0b981a83350f7ac9821efIan Romanick 2241585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick if ( ctx != NULL ) { 2251585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick _mesa_enable_extension( ctx, ext->name ); 2261585c234e0db4bfb7cd85c4111594f6da1582e6fIan Romanick } 227c212abf99af494f024b0b981a83350f7ac9821efIan Romanick} 228c212abf99af494f024b0b981a83350f7ac9821efIan Romanick 229c212abf99af494f024b0b981a83350f7ac9821efIan Romanick 2305b98ada88071a752b6000756949a1951183cdd0bIan Romanick/** 2315b98ada88071a752b6000756949a1951183cdd0bIan Romanick * Utility function used by drivers to test the verions of other components. 2325b98ada88071a752b6000756949a1951183cdd0bIan Romanick * 2335b98ada88071a752b6000756949a1951183cdd0bIan Romanick * If one of the version requirements is not met, a message is logged using 2345b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \c __driUtilMessage. 2355b98ada88071a752b6000756949a1951183cdd0bIan Romanick * 2365b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \param driver_name Name of the driver. Used in error messages. 2375b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \param driActual Actual DRI version supplied __driCreateNewScreen. 2385b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \param driExpected Minimum DRI version required by the driver. 2395b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \param ddxActual Actual DDX version supplied __driCreateNewScreen. 2407104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger * \param ddxExpected Minimum DDX minor and range of DDX major version required by the driver. 2415b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \param drmActual Actual DRM version supplied __driCreateNewScreen. 2425b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \param drmExpected Minimum DRM version required by the driver. 2435b98ada88071a752b6000756949a1951183cdd0bIan Romanick * 2445b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \returns \c GL_TRUE if all version requirements are met. Otherwise, 2455b98ada88071a752b6000756949a1951183cdd0bIan Romanick * \c GL_FALSE is returned. 2465b98ada88071a752b6000756949a1951183cdd0bIan Romanick * 247c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2, __driUtilMessage 248c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * 249c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * \todo 250c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * Now that the old \c driCheckDriDdxDrmVersions function is gone, this 251c39bf5e273a4995a279ae2af59fc29e06ab47e29Ian Romanick * function and \c driCheckDriDdxDrmVersions2 should be renamed. 2525b98ada88071a752b6000756949a1951183cdd0bIan Romanick */ 2535b98ada88071a752b6000756949a1951183cdd0bIan RomanickGLboolean 2547104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland ScheideggerdriCheckDriDdxDrmVersions3(const char * driver_name, 2555b98ada88071a752b6000756949a1951183cdd0bIan Romanick const __DRIversion * driActual, 2565b98ada88071a752b6000756949a1951183cdd0bIan Romanick const __DRIversion * driExpected, 2575b98ada88071a752b6000756949a1951183cdd0bIan Romanick const __DRIversion * ddxActual, 2587104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIutilversion2 * ddxExpected, 2595b98ada88071a752b6000756949a1951183cdd0bIan Romanick const __DRIversion * drmActual, 2605b98ada88071a752b6000756949a1951183cdd0bIan Romanick const __DRIversion * drmExpected) 2615b98ada88071a752b6000756949a1951183cdd0bIan Romanick{ 2625b98ada88071a752b6000756949a1951183cdd0bIan Romanick static const char format[] = "%s DRI driver expected %s version %d.%d.x " 263278736ff6f0659163e69392cf9e96006138746caDave Airlie "but got version %d.%d.%d\n"; 2647104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger static const char format2[] = "%s DRI driver expected %s version %d-%d.%d.x " 265278736ff6f0659163e69392cf9e96006138746caDave Airlie "but got version %d.%d.%d\n"; 2665b98ada88071a752b6000756949a1951183cdd0bIan Romanick 2675b98ada88071a752b6000756949a1951183cdd0bIan Romanick 2685b98ada88071a752b6000756949a1951183cdd0bIan Romanick /* Check the DRI version */ 2695b98ada88071a752b6000756949a1951183cdd0bIan Romanick if ( (driActual->major != driExpected->major) 2705b98ada88071a752b6000756949a1951183cdd0bIan Romanick || (driActual->minor < driExpected->minor) ) { 271278736ff6f0659163e69392cf9e96006138746caDave Airlie fprintf(stderr, format, driver_name, "DRI", 2725b98ada88071a752b6000756949a1951183cdd0bIan Romanick driExpected->major, driExpected->minor, 2735b98ada88071a752b6000756949a1951183cdd0bIan Romanick driActual->major, driActual->minor, driActual->patch); 2745b98ada88071a752b6000756949a1951183cdd0bIan Romanick return GL_FALSE; 2755b98ada88071a752b6000756949a1951183cdd0bIan Romanick } 2765b98ada88071a752b6000756949a1951183cdd0bIan Romanick 2775b98ada88071a752b6000756949a1951183cdd0bIan Romanick /* Check that the DDX driver version is compatible */ 278225148ea0719a28d9b4eb286c4ab2bac52610bb3Dave Airlie /* for miniglx we pass in -1 so we can ignore the DDX version */ 279225148ea0719a28d9b4eb286c4ab2bac52610bb3Dave Airlie if ( (ddxActual->major != -1) && ((ddxActual->major < ddxExpected->major_min) 2807104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger || (ddxActual->major > ddxExpected->major_max) 281225148ea0719a28d9b4eb286c4ab2bac52610bb3Dave Airlie || (ddxActual->minor < ddxExpected->minor)) ) { 282278736ff6f0659163e69392cf9e96006138746caDave Airlie fprintf(stderr, format2, driver_name, "DDX", 2837104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger ddxExpected->major_min, ddxExpected->major_max, ddxExpected->minor, 2845b98ada88071a752b6000756949a1951183cdd0bIan Romanick ddxActual->major, ddxActual->minor, ddxActual->patch); 2855b98ada88071a752b6000756949a1951183cdd0bIan Romanick return GL_FALSE; 2865b98ada88071a752b6000756949a1951183cdd0bIan Romanick } 2875b98ada88071a752b6000756949a1951183cdd0bIan Romanick 2885b98ada88071a752b6000756949a1951183cdd0bIan Romanick /* Check that the DRM driver version is compatible */ 2895b98ada88071a752b6000756949a1951183cdd0bIan Romanick if ( (drmActual->major != drmExpected->major) 2905b98ada88071a752b6000756949a1951183cdd0bIan Romanick || (drmActual->minor < drmExpected->minor) ) { 291278736ff6f0659163e69392cf9e96006138746caDave Airlie fprintf(stderr, format, driver_name, "DRM", 2925b98ada88071a752b6000756949a1951183cdd0bIan Romanick drmExpected->major, drmExpected->minor, 2935b98ada88071a752b6000756949a1951183cdd0bIan Romanick drmActual->major, drmActual->minor, drmActual->patch); 2945b98ada88071a752b6000756949a1951183cdd0bIan Romanick return GL_FALSE; 2955b98ada88071a752b6000756949a1951183cdd0bIan Romanick } 2965b98ada88071a752b6000756949a1951183cdd0bIan Romanick 2975b98ada88071a752b6000756949a1951183cdd0bIan Romanick return GL_TRUE; 2985b98ada88071a752b6000756949a1951183cdd0bIan Romanick} 2995b98ada88071a752b6000756949a1951183cdd0bIan Romanick 3007104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland ScheideggerGLboolean 3017104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland ScheideggerdriCheckDriDdxDrmVersions2(const char * driver_name, 3027104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIversion * driActual, 3037104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIversion * driExpected, 3047104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIversion * ddxActual, 3057104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIversion * ddxExpected, 3067104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIversion * drmActual, 3077104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger const __DRIversion * drmExpected) 3087104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger{ 3097104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger __DRIutilversion2 ddx_expected; 3107104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger ddx_expected.major_min = ddxExpected->major; 3117104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger ddx_expected.major_max = ddxExpected->major; 3127104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger ddx_expected.minor = ddxExpected->minor; 3137104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger ddx_expected.patch = ddxExpected->patch; 3147104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger return driCheckDriDdxDrmVersions3(driver_name, driActual, 3157104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger driExpected, ddxActual, & ddx_expected, 3167104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger drmActual, drmExpected); 3177104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger} 3187104ce0a0e8f25bf097ad695d007b1a4b3e5d051Roland Scheidegger 3197ed58285abede813fbf5fa0a2e29982043f1bbbeKeith WhitwellGLboolean driClipRectToFramebuffer( const GLframebuffer *buffer, 3207ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell GLint *x, GLint *y, 3217ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell GLsizei *width, GLsizei *height ) 3227ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell{ 3237ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell /* left clipping */ 3247ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell if (*x < buffer->_Xmin) { 3257ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell *width -= (buffer->_Xmin - *x); 3267ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell *x = buffer->_Xmin; 3277ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell } 3287ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell 3297ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell /* right clipping */ 3307ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell if (*x + *width > buffer->_Xmax) 3317ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell *width -= (*x + *width - buffer->_Xmax - 1); 3327ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell 3337ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell if (*width <= 0) 3347ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell return GL_FALSE; 3357ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell 3367ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell /* bottom clipping */ 3377ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell if (*y < buffer->_Ymin) { 3387ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell *height -= (buffer->_Ymin - *y); 3397ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell *y = buffer->_Ymin; 3407ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell } 3417ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell 3427ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell /* top clipping */ 3437ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell if (*y + *height > buffer->_Ymax) 3447ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell *height -= (*y + *height - buffer->_Ymax - 1); 3457ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell 3467ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell if (*height <= 0) 3477ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell return GL_FALSE; 3487ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell 3497ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell return GL_TRUE; 3507ed58285abede813fbf5fa0a2e29982043f1bbbeKeith Whitwell} 35174396056977776919aaa7c22be1a3d17774ae321Ian Romanick 35274396056977776919aaa7c22be1a3d17774ae321Ian Romanick/** 35374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * Creates a set of \c __GLcontextModes that a driver will expose. 35474396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 35574396056977776919aaa7c22be1a3d17774ae321Ian Romanick * A set of \c __GLcontextModes will be created based on the supplied 35674396056977776919aaa7c22be1a3d17774ae321Ian Romanick * parameters. The number of modes processed will be 2 * 35774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c num_depth_stencil_bits * \c num_db_modes. 35874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 35974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * For the most part, data is just copied from \c depth_bits, \c stencil_bits, 36074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c db_modes, and \c visType into each \c __GLcontextModes element. 36174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * However, the meanings of \c fb_format and \c fb_type require further 36274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * explanation. The \c fb_format specifies which color components are in 36374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * each pixel and what the default order is. For example, \c GL_RGB specifies 36474396056977776919aaa7c22be1a3d17774ae321Ian Romanick * that red, green, blue are available and red is in the "most significant" 36574396056977776919aaa7c22be1a3d17774ae321Ian Romanick * position and blue is in the "least significant". The \c fb_type specifies 36674396056977776919aaa7c22be1a3d17774ae321Ian Romanick * the bit sizes of each component and the actual ordering. For example, if 36774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11] 36874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * are the blue value, bits [10:5] are the green value, and bits [4:0] are 36974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * the red value. 37074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 37174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either 37274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the 37374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or 37474396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as 37574396056977776919aaa7c22be1a3d17774ae321Ian Romanick * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8 37674396056977776919aaa7c22be1a3d17774ae321Ian Romanick * still uses 32-bits. 37774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 37874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * If in doubt, look at the tables used in the function. 37974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 38074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param ptr_to_modes Pointer to a pointer to a linked list of 38174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c __GLcontextModes. Upon completion, a pointer to 38274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * the next element to be process will be stored here. 38374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * If the function fails and returns \c GL_FALSE, this 38474396056977776919aaa7c22be1a3d17774ae321Ian Romanick * value will be unmodified, but some elements in the 38574396056977776919aaa7c22be1a3d17774ae321Ian Romanick * linked list may be modified. 38674396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param fb_format Format of the framebuffer. Currently only \c GL_RGB, 38774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported. 38874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param fb_type Type of the pixels in the framebuffer. Currently only 38974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_UNSIGNED_SHORT_5_6_5, 39074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_UNSIGNED_SHORT_5_6_5_REV, 39174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_UNSIGNED_INT_8_8_8_8, and 39274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported. 39374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param depth_bits Array of depth buffer sizes to be exposed. 39474396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param stencil_bits Array of stencil buffer sizes to be exposed. 39574396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param num_depth_stencil_bits Number of entries in both \c depth_bits and 39674396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c stencil_bits. 39774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param db_modes Array of buffer swap modes. If an element has a 39874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * value of \c GLX_NONE, then it represents a 39974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * single-buffered mode. Other valid values are 40074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and 40174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GLX_SWAP_UNDEFINED_OML. See the 40274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * GLX_OML_swap_method extension spec for more details. 40374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param num_db_modes Number of entries in \c db_modes. 404429a08384c2ea66d446e46beb28e33ee3b764d52Roland Scheidegger * \param msaa_samples Array of msaa sample count. 0 represents a visual 405429a08384c2ea66d446e46beb28e33ee3b764d52Roland Scheidegger * without a multisample buffer. 406429a08384c2ea66d446e46beb28e33ee3b764d52Roland Scheidegger * \param num_msaa_modes Number of entries in \c msaa_samples. 40774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or 40874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GLX_DIRECT_COLOR. 40974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 41074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \returns 41174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only 41274396056977776919aaa7c22be1a3d17774ae321Ian Romanick * cause of failure is a bad parameter (i.e., unsupported \c fb_format or 41374396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c fb_type). 41474396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 41574396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \todo 41674396056977776919aaa7c22be1a3d17774ae321Ian Romanick * There is currently no way to support packed RGB modes (i.e., modes with 41774396056977776919aaa7c22be1a3d17774ae321Ian Romanick * exactly 3 bytes per pixel) or floating-point modes. This could probably 41874396056977776919aaa7c22be1a3d17774ae321Ian Romanick * be done by creating some new, private enums with clever names likes 41974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32, 42074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it. 42174396056977776919aaa7c22be1a3d17774ae321Ian Romanick */ 422e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg__DRIconfig ** 423e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian HøgsbergdriCreateConfigs(GLenum fb_format, GLenum fb_type, 4245a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell const uint8_t * depth_bits, const uint8_t * stencil_bits, 425e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg unsigned num_depth_stencil_bits, 426f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane const GLenum * db_modes, unsigned num_db_modes, 4273cce4a1e10361458630511543b7a8a6438544775Ian Romanick const uint8_t * msaa_samples, unsigned num_msaa_modes, 4283cce4a1e10361458630511543b7a8a6438544775Ian Romanick GLboolean enable_accum) 42974396056977776919aaa7c22be1a3d17774ae321Ian Romanick{ 4305a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell static const uint8_t bits_table[4][4] = { 43174396056977776919aaa7c22be1a3d17774ae321Ian Romanick /* R G B A */ 432b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 3, 3, 2, 0 }, /* Any GL_UNSIGNED_BYTE_3_3_2 */ 43374396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */ 43474396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */ 43574396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */ 43674396056977776919aaa7c22be1a3d17774ae321Ian Romanick }; 43774396056977776919aaa7c22be1a3d17774ae321Ian Romanick 4385a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell static const uint32_t masks_table_rgb[6][4] = { 439b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 3_3_2 */ 440b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 2_3_3_REV */ 441fff749e893b0adbfb57d08370cb4d2a10608bc52Ian Romanick { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */ 44274396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */ 44374396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 }, /* 8_8_8_8 */ 44474396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 } /* 8_8_8_8_REV */ 44574396056977776919aaa7c22be1a3d17774ae321Ian Romanick }; 44674396056977776919aaa7c22be1a3d17774ae321Ian Romanick 4475a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell static const uint32_t masks_table_rgba[6][4] = { 448b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 3_3_2 */ 449b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 2_3_3_REV */ 450fff749e893b0adbfb57d08370cb4d2a10608bc52Ian Romanick { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */ 45174396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */ 45274396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF }, /* 8_8_8_8 */ 45374396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }, /* 8_8_8_8_REV */ 45474396056977776919aaa7c22be1a3d17774ae321Ian Romanick }; 45574396056977776919aaa7c22be1a3d17774ae321Ian Romanick 4565a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell static const uint32_t masks_table_bgr[6][4] = { 457b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 3_3_2 */ 458b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 2_3_3_REV */ 45974396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */ 460fff749e893b0adbfb57d08370cb4d2a10608bc52Ian Romanick { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */ 46174396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 }, /* 8_8_8_8 */ 46274396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, /* 8_8_8_8_REV */ 46374396056977776919aaa7c22be1a3d17774ae321Ian Romanick }; 46474396056977776919aaa7c22be1a3d17774ae321Ian Romanick 4655a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell static const uint32_t masks_table_bgra[6][4] = { 466b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x00000007, 0x00000038, 0x000000C0, 0x00000000 }, /* 3_3_2 */ 467b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis { 0x000000E0, 0x0000001C, 0x00000003, 0x00000000 }, /* 2_3_3_REV */ 46874396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */ 469fff749e893b0adbfb57d08370cb4d2a10608bc52Ian Romanick { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */ 47074396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF }, /* 8_8_8_8 */ 47174396056977776919aaa7c22be1a3d17774ae321Ian Romanick { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }, /* 8_8_8_8_REV */ 47274396056977776919aaa7c22be1a3d17774ae321Ian Romanick }; 47374396056977776919aaa7c22be1a3d17774ae321Ian Romanick 4745a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell static const uint8_t bytes_per_pixel[6] = { 475b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 1, /* 3_3_2 */ 476b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 1, /* 2_3_3_REV */ 477b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 2, /* 5_6_5 */ 478b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 2, /* 5_6_5_REV */ 479b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 4, /* 8_8_8_8 */ 480b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 4 /* 8_8_8_8_REV */ 48174396056977776919aaa7c22be1a3d17774ae321Ian Romanick }; 48274396056977776919aaa7c22be1a3d17774ae321Ian Romanick 4835a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell const uint8_t * bits; 4845a46e176715b0eae7b8a715e8aec42f5a27214fcKeith Whitwell const uint32_t * masks; 485b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis int index; 486e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __DRIconfig **configs, **c; 487e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg __GLcontextModes *modes; 488f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane unsigned i, j, k, h; 489e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg unsigned num_modes; 4903cce4a1e10361458630511543b7a8a6438544775Ian Romanick unsigned num_accum_bits = (enable_accum) ? 2 : 1; 49174396056977776919aaa7c22be1a3d17774ae321Ian Romanick 492b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis switch ( fb_type ) { 493b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case GL_UNSIGNED_BYTE_3_3_2: 494b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis index = 0; 495b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 496b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case GL_UNSIGNED_BYTE_2_3_3_REV: 497b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis index = 1; 498b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 499b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case GL_UNSIGNED_SHORT_5_6_5: 500b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis index = 2; 501b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 502b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case GL_UNSIGNED_SHORT_5_6_5_REV: 503b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis index = 3; 504b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 505b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case GL_UNSIGNED_INT_8_8_8_8: 506b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis index = 4; 507b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 508b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case GL_UNSIGNED_INT_8_8_8_8_REV: 509b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis index = 5; 510b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 511b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis default: 512b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis fprintf( stderr, "[%s:%u] Unknown framebuffer type 0x%04x.\n", 513b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis __FUNCTION__, __LINE__, fb_type ); 514b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis return NULL; 51574396056977776919aaa7c22be1a3d17774ae321Ian Romanick } 51674396056977776919aaa7c22be1a3d17774ae321Ian Romanick 51774396056977776919aaa7c22be1a3d17774ae321Ian Romanick 51874396056977776919aaa7c22be1a3d17774ae321Ian Romanick /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and 51974396056977776919aaa7c22be1a3d17774ae321Ian Romanick * the _REV versions. 52074396056977776919aaa7c22be1a3d17774ae321Ian Romanick * 52174396056977776919aaa7c22be1a3d17774ae321Ian Romanick * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA. 52274396056977776919aaa7c22be1a3d17774ae321Ian Romanick */ 52374396056977776919aaa7c22be1a3d17774ae321Ian Romanick 52474396056977776919aaa7c22be1a3d17774ae321Ian Romanick switch ( fb_format ) { 52574396056977776919aaa7c22be1a3d17774ae321Ian Romanick case GL_RGB: 52674396056977776919aaa7c22be1a3d17774ae321Ian Romanick masks = masks_table_rgb[ index ]; 52774396056977776919aaa7c22be1a3d17774ae321Ian Romanick break; 52874396056977776919aaa7c22be1a3d17774ae321Ian Romanick 52974396056977776919aaa7c22be1a3d17774ae321Ian Romanick case GL_RGBA: 53074396056977776919aaa7c22be1a3d17774ae321Ian Romanick masks = masks_table_rgba[ index ]; 53174396056977776919aaa7c22be1a3d17774ae321Ian Romanick break; 53274396056977776919aaa7c22be1a3d17774ae321Ian Romanick 53374396056977776919aaa7c22be1a3d17774ae321Ian Romanick case GL_BGR: 53474396056977776919aaa7c22be1a3d17774ae321Ian Romanick masks = masks_table_bgr[ index ]; 53574396056977776919aaa7c22be1a3d17774ae321Ian Romanick break; 53674396056977776919aaa7c22be1a3d17774ae321Ian Romanick 53774396056977776919aaa7c22be1a3d17774ae321Ian Romanick case GL_BGRA: 53874396056977776919aaa7c22be1a3d17774ae321Ian Romanick masks = masks_table_bgra[ index ]; 53974396056977776919aaa7c22be1a3d17774ae321Ian Romanick break; 54074396056977776919aaa7c22be1a3d17774ae321Ian Romanick 54174396056977776919aaa7c22be1a3d17774ae321Ian Romanick default: 542b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis fprintf( stderr, "[%s:%u] Unknown framebuffer format 0x%04x.\n", 543b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis __FUNCTION__, __LINE__, fb_format ); 544e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return NULL; 54574396056977776919aaa7c22be1a3d17774ae321Ian Romanick } 54674396056977776919aaa7c22be1a3d17774ae321Ian Romanick 547b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis switch ( bytes_per_pixel[ index ] ) { 548b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case 1: 549b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis bits = bits_table[0]; 550b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 551b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis case 2: 552b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis bits = bits_table[1]; 553b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 554b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis default: 555b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis bits = ((fb_format == GL_RGB) || (fb_format == GL_BGR)) 556b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis ? bits_table[2] 557b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis : bits_table[3]; 558b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis break; 559b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis } 560b4a4829cd50f7110ddbdd0770297cd845ab4764dGeorge Sapountzis 561256592807cea9d543d13c1bb04d3f82852293f5cAlan Hourihane num_modes = num_depth_stencil_bits * num_db_modes * num_accum_bits * num_msaa_modes; 562e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg configs = _mesa_calloc((num_modes + 1) * sizeof *configs); 563e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg if (configs == NULL) 564e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return NULL; 56574396056977776919aaa7c22be1a3d17774ae321Ian Romanick 566e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg c = configs; 56774396056977776919aaa7c22be1a3d17774ae321Ian Romanick for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) { 56874396056977776919aaa7c22be1a3d17774ae321Ian Romanick for ( i = 0 ; i < num_db_modes ; i++ ) { 569f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane for ( h = 0 ; h < num_msaa_modes; h++ ) { 570f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane for ( j = 0 ; j < num_accum_bits ; j++ ) { 571f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane *c = _mesa_malloc (sizeof **c); 572f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes = &(*c)->modes; 573f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane c++; 574f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 575f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane memset(modes, 0, sizeof *modes); 576f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->redBits = bits[0]; 577f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->greenBits = bits[1]; 578f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->blueBits = bits[2]; 579f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->alphaBits = bits[3]; 580f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->redMask = masks[0]; 581f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->greenMask = masks[1]; 582f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->blueMask = masks[2]; 583f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->alphaMask = masks[3]; 584f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->rgbBits = modes->redBits + modes->greenBits 585f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane + modes->blueBits + modes->alphaBits; 586f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 587f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->accumRedBits = 16 * j; 588f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->accumGreenBits = 16 * j; 589f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->accumBlueBits = 16 * j; 590f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0; 591f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG; 592f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 593f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->stencilBits = stencil_bits[k]; 594f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->depthBits = depth_bits[k]; 595f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 596f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->transparentPixel = GLX_NONE; 597f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->transparentRed = GLX_DONT_CARE; 598f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->transparentGreen = GLX_DONT_CARE; 599f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->transparentBlue = GLX_DONT_CARE; 600f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->transparentAlpha = GLX_DONT_CARE; 601f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->transparentIndex = GLX_DONT_CARE; 602f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->visualType = GLX_DONT_CARE; 603f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->renderType = GLX_RGBA_BIT; 604f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->drawableType = GLX_WINDOW_BIT; 605f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->rgbMode = GL_TRUE; 606f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 607f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane if ( db_modes[i] == GLX_NONE ) { 608f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->doubleBufferMode = GL_FALSE; 609f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane } 610f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane else { 611f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->doubleBufferMode = GL_TRUE; 612f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->swapMethod = db_modes[i]; 613f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane } 614f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 615f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->samples = msaa_samples[h]; 616f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->sampleBuffers = modes->samples ? 1 : 0; 617f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 618f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 619f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->haveAccumBuffer = ((modes->accumRedBits + 6207f8e10f96c1970d2c81ec8d4f3a45a3b006b3be1Keith Whitwell modes->accumGreenBits + 6217f8e10f96c1970d2c81ec8d4f3a45a3b006b3be1Keith Whitwell modes->accumBlueBits + 6227f8e10f96c1970d2c81ec8d4f3a45a3b006b3be1Keith Whitwell modes->accumAlphaBits) > 0); 623f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->haveDepthBuffer = (modes->depthBits > 0); 624f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->haveStencilBuffer = (modes->stencilBits > 0); 625f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 626f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->bindToTextureRgb = GL_TRUE; 627f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->bindToTextureRgba = GL_TRUE; 628f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->bindToMipmapTexture = GL_FALSE; 629f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane modes->bindToTextureTargets = modes->rgbMode ? 630f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane __DRI_ATTRIB_TEXTURE_1D_BIT | 631f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane __DRI_ATTRIB_TEXTURE_2D_BIT | 632f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT : 633f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane 0; 634f7d80aa00611917bc8ce637136d982b151b8f44fAlan Hourihane } 63574396056977776919aaa7c22be1a3d17774ae321Ian Romanick } 63674396056977776919aaa7c22be1a3d17774ae321Ian Romanick } 63774396056977776919aaa7c22be1a3d17774ae321Ian Romanick } 638e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg *c = NULL; 639e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 640e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return configs; 641e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg} 64274396056977776919aaa7c22be1a3d17774ae321Ian Romanick 6435d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt__DRIconfig **driConcatConfigs(__DRIconfig **a, 6445d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt __DRIconfig **b) 645e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg{ 6465d5ae371eaeca7e33e638af3aee1ae8e162db0a7Eric Anholt __DRIconfig **all; 647e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg int i, j, index; 648e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 649e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg i = 0; 650e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg while (a[i] != NULL) 651e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg i++; 652e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg j = 0; 653e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg while (b[j] != NULL) 654e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg j++; 655e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 656e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg all = _mesa_malloc((i + j + 1) * sizeof *all); 657e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg index = 0; 658e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg for (i = 0; a[i] != NULL; i++) 659e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg all[index++] = a[i]; 660e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg for (j = 0; b[j] != NULL; j++) 661e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg all[index++] = b[j]; 662e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg all[index++] = NULL; 663e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 664e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg _mesa_free(a); 665e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg _mesa_free(b); 666e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg 667e82dd8c6e1fa2fff5b960de26961080ba5e9651dKristian Høgsberg return all; 66874396056977776919aaa7c22be1a3d17774ae321Ian Romanick} 669c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 670c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis#define __ATTRIB(attrib, field) \ 671c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis { attrib, offsetof(__GLcontextModes, field) } 672c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 673c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzisstatic const struct { unsigned int attrib, offset; } attribMap[] = { 674c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BUFFER_SIZE, rgbBits), 675c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_LEVEL, level), 676c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_RED_SIZE, redBits), 677c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_GREEN_SIZE, greenBits), 678c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BLUE_SIZE, blueBits), 679c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_ALPHA_SIZE, alphaBits), 680c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_DEPTH_SIZE, depthBits), 681c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_STENCIL_SIZE, stencilBits), 682c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_ACCUM_RED_SIZE, accumRedBits), 683c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_ACCUM_GREEN_SIZE, accumGreenBits), 684c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_ACCUM_BLUE_SIZE, accumBlueBits), 685c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_ACCUM_ALPHA_SIZE, accumAlphaBits), 686c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_SAMPLE_BUFFERS, sampleBuffers), 687c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_SAMPLES, samples), 688c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_DOUBLE_BUFFER, doubleBufferMode), 689c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_STEREO, stereoMode), 690c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_AUX_BUFFERS, numAuxBuffers), 691c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_TRANSPARENT_TYPE, transparentPixel), 692c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_TRANSPARENT_INDEX_VALUE, transparentPixel), 693c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_TRANSPARENT_RED_VALUE, transparentRed), 694c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_TRANSPARENT_GREEN_VALUE, transparentGreen), 695c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_TRANSPARENT_BLUE_VALUE, transparentBlue), 696c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE, transparentAlpha), 697c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_FLOAT_MODE, floatMode), 698c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_RED_MASK, redMask), 699c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_GREEN_MASK, greenMask), 700c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BLUE_MASK, blueMask), 701c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_ALPHA_MASK, alphaMask), 702c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_WIDTH, maxPbufferWidth), 703c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_HEIGHT, maxPbufferHeight), 704c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_MAX_PBUFFER_PIXELS, maxPbufferPixels), 705c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH, optimalPbufferWidth), 706c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT, optimalPbufferHeight), 707c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, swapMethod), 708c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGB, bindToTextureRgb), 709c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_RGBA, bindToTextureRgba), 710c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE, bindToMipmapTexture), 711c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS, bindToTextureTargets), 712c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_YINVERTED, yInverted), 713c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 714c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis /* The struct field doesn't matter here, these are handled by the 715c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis * switch in driGetConfigAttribIndex. We need them in the array 716c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis * so the iterator includes them though.*/ 717c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_RENDER_TYPE, level), 718c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_CONFIG_CAVEAT, level), 719c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis __ATTRIB(__DRI_ATTRIB_SWAP_METHOD, level) 720c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis}; 721c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 722c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) 723c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 724c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzisstatic int 725c95e66120be049ee51ff84868b1da3379b312fabGeorge SapountzisdriGetConfigAttribIndex(const __DRIconfig *config, 726c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis unsigned int index, unsigned int *value) 727c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis{ 728c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis switch (attribMap[index].attrib) { 729c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis case __DRI_ATTRIB_RENDER_TYPE: 730c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis if (config->modes.rgbMode) 731c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *value = __DRI_ATTRIB_RGBA_BIT; 732c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis else 733c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *value = __DRI_ATTRIB_COLOR_INDEX_BIT; 734c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis break; 735c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis case __DRI_ATTRIB_CONFIG_CAVEAT: 736c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis if (config->modes.visualRating == GLX_NON_CONFORMANT_CONFIG) 737c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *value = __DRI_ATTRIB_NON_CONFORMANT_CONFIG; 738c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis else if (config->modes.visualRating == GLX_SLOW_CONFIG) 739c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *value = __DRI_ATTRIB_SLOW_BIT; 740c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis else 741c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *value = 0; 742c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis break; 743c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis case __DRI_ATTRIB_SWAP_METHOD: 744c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis break; 745c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 7461724334d7c82abe55b6506dfe369df4facae6f06Dave Miller case __DRI_ATTRIB_FLOAT_MODE: 7471724334d7c82abe55b6506dfe369df4facae6f06Dave Miller *value = config->modes.floatMode; 7481724334d7c82abe55b6506dfe369df4facae6f06Dave Miller break; 7491724334d7c82abe55b6506dfe369df4facae6f06Dave Miller 750c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis default: 751c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *value = *(unsigned int *) 752c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis ((char *) &config->modes + attribMap[index].offset); 753c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 754c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis break; 755c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis } 756c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 757c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis return GL_TRUE; 758c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis} 759c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 760c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzisint 761c95e66120be049ee51ff84868b1da3379b312fabGeorge SapountzisdriGetConfigAttrib(const __DRIconfig *config, 762c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis unsigned int attrib, unsigned int *value) 763c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis{ 764c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis int i; 765c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 766c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis for (i = 0; i < ARRAY_SIZE(attribMap); i++) 767c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis if (attribMap[i].attrib == attrib) 768c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis return driGetConfigAttribIndex(config, i, value); 769c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 770c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis return GL_FALSE; 771c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis} 772c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 773c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzisint 774c95e66120be049ee51ff84868b1da3379b312fabGeorge SapountzisdriIndexConfigAttrib(const __DRIconfig *config, int index, 775c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis unsigned int *attrib, unsigned int *value) 776c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis{ 777c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis if (index >= 0 && index < ARRAY_SIZE(attribMap)) { 778c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis *attrib = attribMap[index].attrib; 779c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis return driGetConfigAttribIndex(config, index, value); 780c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis } 781c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis 782c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis return GL_FALSE; 783c95e66120be049ee51ff84868b1da3379b312fabGeorge Sapountzis} 784