Make GL_ARB_texture_compression mandatory
[mesa.git] / src / mesa / drivers / dri / tdfx / tdfx_context.c
1 /* -*- mode: c; c-basic-offset: 3 -*-
2 *
3 * Copyright 2000 VA Linux Systems Inc., Fremont, California.
4 *
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * VA LINUX SYSTEMS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
23 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 * SOFTWARE.
25 */
26
27 /**
28 * \file tdfx_context.c
29 * Context management functions for 3Dfx hardware.
30 *
31 * \author Gareth Hughes <gareth@valinux.com> (original rewrite 29 Sep - 1 Oct 2000)
32 * \author Brian Paul <brianp@valinux.com>
33 * \author Daniel Borca <dborca@users.sourceforge.net> (new fixes 19 Jul 2004)
34 */
35
36 #include <dlfcn.h>
37 #include "tdfx_context.h"
38 #include "tdfx_dd.h"
39 #include "tdfx_state.h"
40 #include "tdfx_vb.h"
41 #include "tdfx_tex.h"
42 #include "tdfx_tris.h"
43 #include "tdfx_render.h"
44 #include "tdfx_span.h"
45 #include "tdfx_texman.h"
46 #include "main/extensions.h"
47 #include "main/hash.h"
48 #include "main/texobj.h"
49
50 #include "swrast/swrast.h"
51 #include "swrast_setup/swrast_setup.h"
52 #include "vbo/vbo.h"
53
54 #include "tnl/tnl.h"
55 #include "tnl/t_pipeline.h"
56
57 #include "drivers/common/driverfuncs.h"
58
59 #include "utils.h"
60
61 #define need_GL_ARB_multisample
62 /* #define need_GL_ARB_point_parameters */
63 #define need_GL_ARB_occlusion_query
64 #define need_GL_ARB_vertex_buffer_object
65 /* #define need_GL_ARB_vertex_program */
66 #define need_GL_EXT_blend_equation_separate
67 #define need_GL_EXT_blend_func_separate
68 #define need_GL_EXT_blend_minmax
69 #define need_GL_EXT_fog_coord
70 #define need_GL_EXT_multi_draw_arrays
71 #define need_GL_EXT_paletted_texture
72 /* #define need_GL_EXT_secondary_color */
73 #define need_GL_IBM_multimode_draw_arrays
74 /* #define need_GL_MESA_program_debug */
75 /* #define need_GL_NV_vertex_program */
76 #include "extension_helper.h"
77
78
79 /**
80 * Common extension strings exported by all cards
81 */
82 const struct dri_extension card_extensions[] =
83 {
84 { "GL_ARB_multisample", GL_ARB_multisample_functions },
85 { "GL_ARB_occlusion_query", GL_ARB_occlusion_query_functions },
86 { "GL_ARB_texture_mirrored_repeat", NULL },
87 { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
88
89 { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
90 { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
91 { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions },
92 { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions },
93 { "GL_EXT_shared_texture_palette", NULL },
94 { "GL_EXT_stencil_wrap", NULL },
95 { "GL_EXT_texture_env_add", NULL },
96 { "GL_EXT_texture_lod_bias", NULL },
97 { "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions },
98
99 #ifdef need_GL_ARB_point_parameters
100 { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
101 { "GL_ARB_point_sprite", NULL },
102 #endif
103 #ifdef need_GL_EXT_secondary_color
104 { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
105 #endif
106 #ifdef need_GL_ARB_vertex_program
107 { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }
108 #endif
109 #ifdef need_GL_NV_vertex_program
110 { "GL_NV_vertex_program", GL_NV_vertex_program_functions }
111 { "GL_NV_vertex_program1_1", NULL },
112 #endif
113 #ifdef need_GL_MESA_program_debug
114 { "GL_MESA_program_debug", GL_MESA_program_debug_functions },
115 #endif
116 { NULL, NULL }
117 };
118
119 /**
120 * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards.
121 */
122 const struct dri_extension napalm_extensions[] =
123 {
124 { "GL_ARB_texture_env_combine", NULL },
125 { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
126 { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions },
127 { "GL_EXT_texture_compression_s3tc", NULL },
128 { "GL_EXT_texture_env_combine", NULL },
129
130 { "GL_3DFX_texture_compression_FXT1", NULL },
131 { "GL_NV_blend_square", NULL },
132 { "GL_S3_s3tc", NULL },
133 { NULL, NULL }
134 };
135
136 /*
137 * Enable/Disable the extensions for this context.
138 */
139 static void tdfxDDInitExtensions( GLcontext *ctx )
140 {
141 tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
142
143 driInitExtensions( ctx, card_extensions, GL_FALSE );
144
145 if ( fxMesa->haveTwoTMUs ) {
146 _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
147 }
148
149 if ( TDFX_IS_NAPALM( fxMesa ) ) {
150 driInitExtensions( ctx, napalm_extensions, GL_FALSE );
151 } else {
152 _mesa_enable_extension( ctx, "GL_SGIS_generate_mipmap" );
153 }
154 }
155
156
157
158 static const struct tnl_pipeline_stage *tdfx_pipeline[] = {
159 &_tnl_vertex_transform_stage,
160 &_tnl_normal_transform_stage,
161 &_tnl_lighting_stage,
162 &_tnl_fog_coordinate_stage,
163 &_tnl_texgen_stage,
164 &_tnl_texture_transform_stage,
165 &_tnl_point_attenuation_stage,
166 &_tnl_render_stage,
167 0,
168 };
169
170 static const struct dri_debug_control debug_control[] =
171 {
172 { "dri", DEBUG_VERBOSE_DRI },
173 { "sync", DEBUG_ALWAYS_SYNC },
174 { "api", DEBUG_VERBOSE_API },
175 { "fall", DEBUG_VERBOSE_FALL },
176 { NULL, 0 }
177 };
178
179 GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
180 __DRIcontextPrivate *driContextPriv,
181 void *sharedContextPrivate )
182 {
183 tdfxContextPtr fxMesa;
184 GLcontext *ctx, *shareCtx;
185 __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
186 tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
187 TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
188 sizeof(drm_sarea_t));
189 struct dd_function_table functions;
190
191 /* Allocate tdfx context */
192 fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );
193 if (!fxMesa)
194 return GL_FALSE;
195
196 /* Init default driver functions then plug in our tdfx-specific functions
197 * (the texture functions are especially important)
198 */
199 _mesa_init_driver_functions(&functions);
200 tdfxDDInitDriverFuncs(mesaVis, &functions);
201 tdfxInitTextureFuncs(&functions);
202 tdfxInitRenderFuncs(&functions);
203
204 /* Allocate the Mesa context */
205 if (sharedContextPrivate)
206 shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
207 else
208 shareCtx = NULL;
209
210 fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
211 &functions, (void *) fxMesa);
212 if (!fxMesa->glCtx) {
213 FREE(fxMesa);
214 return GL_FALSE;
215 }
216 driContextPriv->driverPrivate = fxMesa;
217
218 /* Mirror some important DRI state
219 */
220 fxMesa->hHWContext = driContextPriv->hHWContext;
221 fxMesa->driHwLock = &sPriv->pSAREA->lock;
222 fxMesa->driFd = sPriv->fd;
223
224 fxMesa->driScreen = sPriv;
225 fxMesa->driContext = driContextPriv;
226 fxMesa->fxScreen = fxScreen;
227 fxMesa->sarea = saPriv;
228
229 /*JJJ - really?*/
230 fxMesa->haveHwAlpha = ( mesaVis->alphaBits &&
231 ((mesaVis->greenBits == 8) ||
232 (mesaVis->depthBits == 0)) );
233 fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) &&
234 mesaVis->stencilBits &&
235 mesaVis->depthBits == 24 );
236
237 fxMesa->screen_width = fxScreen->width;
238 fxMesa->screen_height = fxScreen->height;
239
240 fxMesa->new_gl_state = ~0;
241 fxMesa->new_state = ~0;
242 fxMesa->dirty = ~0;
243
244 /* Parse configuration files */
245 driParseConfigFiles (&fxMesa->optionCache, &fxScreen->optionCache,
246 fxMesa->driScreen->myNum, "tdfx");
247
248 /* NOTE: This must be here before any Glide calls! */
249 if (!tdfxInitGlide( fxMesa )) {
250 FREE(fxMesa);
251 return GL_FALSE;
252 }
253
254 fxMesa->Glide.grDRIOpen( (char*) sPriv->pFB, fxScreen->regs.map, fxScreen->deviceID,
255 fxScreen->width, fxScreen->height, fxScreen->mem, fxScreen->cpp,
256 fxScreen->stride, fxScreen->fifoOffset, fxScreen->fifoSize,
257 fxScreen->fbOffset, fxScreen->backOffset, fxScreen->depthOffset,
258 fxScreen->textureOffset, fxScreen->textureSize, &saPriv->fifoPtr,
259 &saPriv->fifoRead );
260
261 if ( getenv( "FX_GLIDE_SWAPINTERVAL" ) ) {
262 fxMesa->Glide.SwapInterval = atoi( getenv( "FX_GLIDE_SWAPINTERVAL" ) );
263 } else {
264 fxMesa->Glide.SwapInterval = 0;
265 }
266 if ( getenv( "FX_MAX_PENDING_SWAPS" ) ) {
267 fxMesa->Glide.MaxPendingSwaps = atoi( getenv( "FX_MAX_PENDING_SWAPS" ) );
268 } else {
269 fxMesa->Glide.MaxPendingSwaps = 2;
270 }
271
272 fxMesa->Glide.Initialized = GL_FALSE;
273 fxMesa->Glide.Board = 0;
274
275
276 if (getenv("FX_EMULATE_SINGLE_TMU")) {
277 fxMesa->haveTwoTMUs = GL_FALSE;
278 }
279 else {
280 if ( TDFX_IS_BANSHEE( fxMesa ) ) {
281 fxMesa->haveTwoTMUs = GL_FALSE;
282 } else {
283 fxMesa->haveTwoTMUs = GL_TRUE;
284 }
285 }
286
287 fxMesa->stats.swapBuffer = 0;
288 fxMesa->stats.reqTexUpload = 0;
289 fxMesa->stats.texUpload = 0;
290 fxMesa->stats.memTexUpload = 0;
291
292 fxMesa->tmuSrc = TDFX_TMU_NONE;
293
294 ctx = fxMesa->glCtx;
295 if ( TDFX_IS_NAPALM( fxMesa ) ) {
296 ctx->Const.MaxTextureLevels = 12;
297 } else {
298 ctx->Const.MaxTextureLevels = 9;
299 }
300 ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2;
301 ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
302 ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
303
304 /* No wide points.
305 */
306 ctx->Const.MinPointSize = 1.0;
307 ctx->Const.MinPointSizeAA = 1.0;
308 ctx->Const.MaxPointSize = 1.0;
309 ctx->Const.MaxPointSizeAA = 1.0;
310
311 /* Disable wide lines as we can't antialias them correctly in
312 * hardware.
313 */
314 ctx->Const.MinLineWidth = 1.0;
315 ctx->Const.MinLineWidthAA = 1.0;
316 ctx->Const.MaxLineWidth = 1.0;
317 ctx->Const.MaxLineWidthAA = 1.0;
318 ctx->Const.LineWidthGranularity = 1.0;
319
320 /* Initialize the software rasterizer and helper modules.
321 */
322 _swrast_CreateContext( ctx );
323 _vbo_CreateContext( ctx );
324 _tnl_CreateContext( ctx );
325 _swsetup_CreateContext( ctx );
326
327 /* Install the customized pipeline:
328 */
329 _tnl_destroy_pipeline( ctx );
330 _tnl_install_pipeline( ctx, tdfx_pipeline );
331
332 /* Configure swrast and T&L to match hardware characteristics:
333 */
334 _swrast_allow_pixel_fog( ctx, GL_TRUE );
335 _swrast_allow_vertex_fog( ctx, GL_FALSE );
336 _tnl_allow_pixel_fog( ctx, GL_TRUE );
337 _tnl_allow_vertex_fog( ctx, GL_FALSE );
338
339 tdfxDDInitExtensions( ctx );
340 /* XXX these should really go right after _mesa_init_driver_functions() */
341 tdfxDDInitSpanFuncs( ctx );
342 tdfxDDInitStateFuncs( ctx );
343 tdfxDDInitTriFuncs( ctx );
344 tdfxInitVB( ctx );
345 tdfxInitState( fxMesa );
346
347 #if DO_DEBUG
348 TDFX_DEBUG = driParseDebugString( getenv( "TDFX_DEBUG" ), debug_control );
349 #endif
350
351 if (driQueryOptionb(&fxMesa->optionCache, "no_rast")) {
352 fprintf(stderr, "disabling 3D acceleration\n");
353 FALLBACK(fxMesa, TDFX_FALLBACK_DISABLE, 1);
354 }
355
356 return GL_TRUE;
357 }
358
359
360 static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
361 {
362 FxI32 result;
363 int i;
364
365 LOCK_HARDWARE( fxMesa );
366
367 fxMesa->Glide.grGet( GR_GLIDE_VERTEXLAYOUT_SIZE, sizeof(FxI32), &result );
368 for ( i = 0 ; i < TDFX_NUM_LAYOUTS ; i++ ) {
369 fxMesa->layout[i] = MALLOC( result );
370 if ( !fxMesa->layout[i] ) {
371 UNLOCK_HARDWARE( fxMesa );
372 return GL_FALSE;
373 }
374 }
375
376 /* Tiny vertex format - 16 bytes.
377 */
378 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
379 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
380 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
381 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
382 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
383 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_TINY] );
384
385 /* Non textured vertex format - 24 bytes (Need w for table fog)
386 */
387 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
388 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
389 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
390 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
391 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
392 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
393 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_NOTEX] );
394
395 /* Single textured vertex format - 32 bytes.
396 */
397 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
398 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
399 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
400 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
401 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
402 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
403 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
404 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_SINGLE] );
405
406 /* Multitextured vertex format - 40 bytes.
407 */
408 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
409 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
410 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
411 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
412 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
413 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
414 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
415 fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
416 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] );
417
418 /* Projected texture vertex format - 36 bytes.
419 */
420 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
421 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
422 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
423 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
424 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
425 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
426 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
427 fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
428 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ1] );
429
430 /* Projected multitexture vertex format - 48 bytes.
431 */
432 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
433 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
434 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
435 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
436 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
437 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
438 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
439 fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
440 fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
441 fxMesa->Glide.grVertexLayout( GR_PARAM_Q1, TDFX_Q1_OFFSET, GR_PARAM_ENABLE );
442 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ2] );
443
444 UNLOCK_HARDWARE( fxMesa );
445
446 return GL_TRUE;
447 }
448
449
450 /*
451 * Initialize the state in an tdfxContextPtr struct.
452 */
453 static GLboolean
454 tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
455 {
456 /* KW: Would be nice to make one of these a member of the other.
457 */
458 FxI32 result[2];
459 const char *gext;
460
461 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
462 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
463 }
464
465 #if DEBUG_LOCKING
466 fprintf(stderr, "Debug locking enabled\n");
467 #endif
468
469 if ( fxMesa->Glide.Initialized )
470 return GL_TRUE;
471
472 fxMesa->width = driDrawPriv->w;
473 fxMesa->height = driDrawPriv->h;
474
475 /* We have to use a light lock here, because we can't do any glide
476 * operations yet. No use of FX_* functions in this function.
477 */
478 DRM_LIGHT_LOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext );
479
480 fxMesa->Glide.grGlideInit();
481 fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
482
483 fxMesa->Glide.Context = fxMesa->Glide.grSstWinOpen( (FxU32) -1,
484 GR_RESOLUTION_NONE,
485 GR_REFRESH_NONE,
486 fxMesa->Glide.ColorFormat,
487 fxMesa->Glide.Origin,
488 2, 1 );
489
490 fxMesa->Glide.grDRIResetSAREA();
491
492 DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext );
493
494 if ( !fxMesa->Glide.Context )
495 return GL_FALSE;
496
497
498 /* Perform the Glide-dependant part of the context initialization.
499 */
500 FX_grColorMaskv( fxMesa->glCtx, true4 );
501
502 tdfxTMInit( fxMesa );
503
504 LOCK_HARDWARE( fxMesa );
505
506 /* JJJ - COMMAND_TRANSPORT, PALETTE6666 */
507 gext = fxMesa->Glide.grGetString( GR_EXTENSION );
508 fxMesa->Glide.HaveCombineExt = strstr(gext, "COMBINE") && !getenv("MESA_FX_IGNORE_CMBEXT");
509 fxMesa->Glide.HaveCommandTransportExt = GL_FALSE;
510 fxMesa->Glide.HaveFogCoordExt = GL_TRUE;
511 fxMesa->Glide.HavePixelExt = strstr(gext, "PIXEXT") && !getenv("MESA_FX_IGNORE_PIXEXT");
512 fxMesa->Glide.HaveTextureBufferExt = GL_TRUE;
513 fxMesa->Glide.HaveTexFmtExt = strstr(gext, "TEXFMT") && !getenv("MESA_FX_IGNORE_TEXFMT");
514 fxMesa->Glide.HaveTexUMAExt = strstr(gext, "TEXUMA") && !getenv("MESA_FX_IGNORE_TEXUMA");
515 fxMesa->Glide.HaveMirrorExt = strstr(gext, "TEXMIRROR") && !getenv("MESA_FX_IGNORE_MIREXT");
516 fxMesa->Glide.HaveTexus2 = GL_FALSE;
517
518 if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
519 fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
520 } else {
521 fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_DISABLE);
522 }
523
524 fxMesa->Glide.grLfbWriteColorFormat( GR_COLORFORMAT_ABGR );
525
526 fxMesa->Glide.grGet( GR_TEXTURE_ALIGN, sizeof(FxI32), result );
527 fxMesa->Glide.TextureAlign = result[0];
528
529 fxMesa->Glide.State = NULL;
530 fxMesa->Glide.grGet( GR_GLIDE_STATE_SIZE, sizeof(FxI32), result );
531 fxMesa->Glide.State = MALLOC( result[0] );
532
533 fxMesa->Fog.Table = NULL;
534 fxMesa->Glide.grGet( GR_FOG_TABLE_ENTRIES, sizeof(FxI32), result );
535 fxMesa->Fog.Table = MALLOC( result[0] * sizeof(GrFog_t) );
536
537 UNLOCK_HARDWARE( fxMesa );
538
539 if ( !fxMesa->Glide.State || !fxMesa->Fog.Table ) {
540 if ( fxMesa->Glide.State )
541 FREE( fxMesa->Glide.State );
542 if ( fxMesa->Fog.Table )
543 FREE( fxMesa->Fog.Table );
544 return GL_FALSE;
545 }
546
547 if ( !tdfxInitVertexFormats( fxMesa ) ) {
548 return GL_FALSE;
549 }
550
551 LOCK_HARDWARE( fxMesa );
552
553 fxMesa->Glide.grGlideGetState( fxMesa->Glide.State );
554
555 if ( getenv( "FX_GLIDE_INFO" ) ) {
556 printf( "GR_RENDERER = %s\n", (char *) fxMesa->Glide.grGetString( GR_RENDERER ) );
557 printf( "GR_VERSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_VERSION ) );
558 printf( "GR_VENDOR = %s\n", (char *) fxMesa->Glide.grGetString( GR_VENDOR ) );
559 printf( "GR_HARDWARE = %s\n", (char *) fxMesa->Glide.grGetString( GR_HARDWARE ) );
560 printf( "GR_EXTENSION = %s\n", (char *) gext );
561 }
562
563 UNLOCK_HARDWARE( fxMesa );
564
565 fxMesa->numClipRects = 0;
566 fxMesa->pClipRects = NULL;
567 fxMesa->scissoredClipRects = GL_FALSE;
568
569 fxMesa->Glide.Initialized = GL_TRUE;
570
571 return GL_TRUE;
572 }
573
574
575 void
576 tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
577 {
578 tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
579
580 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
581 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
582 }
583
584 if ( fxMesa ) {
585 if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) {
586 /* This share group is about to go away, free our private
587 * texture object data.
588 */
589 struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
590 GLuint id;
591 for (id = _mesa_HashFirstEntry(textures);
592 id;
593 id = _mesa_HashNextEntry(textures, id)) {
594 struct gl_texture_object *tObj
595 = _mesa_lookup_texture(fxMesa->glCtx, id);
596 tdfxTMFreeTexture(fxMesa, tObj);
597 }
598 }
599
600 tdfxTMClose(fxMesa); /* free texture memory */
601
602 _swsetup_DestroyContext( fxMesa->glCtx );
603 _tnl_DestroyContext( fxMesa->glCtx );
604 _vbo_DestroyContext( fxMesa->glCtx );
605 _swrast_DestroyContext( fxMesa->glCtx );
606
607 tdfxFreeVB( fxMesa->glCtx );
608
609 /* Free Mesa context */
610 fxMesa->glCtx->DriverCtx = NULL;
611 _mesa_destroy_context(fxMesa->glCtx);
612
613 /* free the tdfx context */
614 FREE( fxMesa );
615 }
616 }
617
618
619 GLboolean
620 tdfxUnbindContext( __DRIcontextPrivate *driContextPriv )
621 {
622 GET_CURRENT_CONTEXT(ctx);
623 tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
624
625 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
626 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
627 }
628
629 if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) {
630 LOCK_HARDWARE(fxMesa);
631 fxMesa->Glide.grGlideGetState(fxMesa->Glide.State);
632 UNLOCK_HARDWARE(fxMesa);
633 }
634 return GL_TRUE;
635 }
636
637
638 GLboolean
639 tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
640 __DRIdrawablePrivate *driDrawPriv,
641 __DRIdrawablePrivate *driReadPriv )
642 {
643 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
644 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
645 }
646
647 if ( driContextPriv ) {
648 tdfxContextPtr newFx = (tdfxContextPtr) driContextPriv->driverPrivate;
649 GLcontext *newCtx = newFx->glCtx;
650 GET_CURRENT_CONTEXT(curCtx);
651
652 if ((newFx->driDrawable != driDrawPriv)
653 || (newFx->driReadable != driReadPriv)) {
654 newFx->driDrawable = driDrawPriv;
655 newFx->driReadable = driReadPriv;
656 newFx->dirty = ~0;
657 }
658 else {
659 if (curCtx == newCtx) {
660 /* same drawable, same context -> no-op */
661 /* Need to call _mesa_make_current2() in order to make sure API
662 * dispatch is set correctly.
663 */
664 _mesa_make_current( newCtx,
665 (GLframebuffer *) driDrawPriv->driverPrivate,
666 (GLframebuffer *) driReadPriv->driverPrivate );
667 return GL_TRUE;
668 }
669 /* [dBorca] tunnel2 requires this */
670 newFx->dirty = ~0;
671 }
672
673 driUpdateFramebufferSize(newCtx, driDrawPriv);
674 if (driDrawPriv != driReadPriv) {
675 driUpdateFramebufferSize(newCtx, driReadPriv);
676 }
677
678 if ( !newFx->Glide.Initialized ) {
679 if ( !tdfxInitContext( driDrawPriv, newFx ) )
680 return GL_FALSE;
681
682 LOCK_HARDWARE( newFx );
683
684 /* FIXME: Force loading of window information */
685 newFx->width = 0;
686 tdfxUpdateClipping(newCtx);
687 tdfxUploadClipping(newFx);
688
689 UNLOCK_HARDWARE( newFx );
690 } else {
691 LOCK_HARDWARE( newFx );
692
693 newFx->Glide.grSstSelect( newFx->Glide.Board );
694 newFx->Glide.grGlideSetState( newFx->Glide.State );
695
696 tdfxUpdateClipping(newCtx);
697 tdfxUploadClipping(newFx);
698
699 UNLOCK_HARDWARE( newFx );
700 }
701
702 _mesa_make_current( newCtx,
703 (GLframebuffer *) driDrawPriv->driverPrivate,
704 (GLframebuffer *) driReadPriv->driverPrivate );
705 } else {
706 _mesa_make_current( NULL, NULL, NULL );
707 }
708
709 return GL_TRUE;
710 }
711
712
713 /*
714 * Enable this to trace calls to various Glide functions.
715 */
716 /*#define DEBUG_TRAP*/
717 #ifdef DEBUG_TRAP
718 static void (*real_grDrawTriangle)( const void *a, const void *b, const void *c );
719 static void (*real_grDrawPoint)( const void *a );
720 static void (*real_grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers);
721 static void (*real_grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count,
722 void *pointers, FxU32 stride);
723 static void (*real_grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy );
724
725 static void (*real_grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode);
726 static void (*real_grGlideGetVertexLayout)( void *layout );
727 static void (*real_grGlideSetVertexLayout)( const void *layout );
728
729 static void (*real_grTexDownloadMipMapLevel)( GrChipID_t tmu,
730 FxU32 startAddress,
731 GrLOD_t thisLod,
732 GrLOD_t largeLod,
733 GrAspectRatio_t aspectRatio,
734 GrTextureFormat_t format,
735 FxU32 evenOdd,
736 void *data );
737
738
739 static void debug_grDrawTriangle( const void *a, const void *b, const void *c )
740 {
741 printf("%s\n", __FUNCTION__);
742 (*real_grDrawTriangle)(a, b, c);
743 }
744
745 static void debug_grDrawPoint( const void *a )
746 {
747 const float *f = (const float *) a;
748 printf("%s %g %g\n", __FUNCTION__, f[0], f[1]);
749 (*real_grDrawPoint)(a);
750 }
751
752 static void debug_grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers)
753 {
754 printf("%s count=%d\n", __FUNCTION__, (int) Count);
755 (*real_grDrawVertexArray)(mode, Count, pointers);
756 }
757
758 static void debug_grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count,
759 void *pointers, FxU32 stride)
760 {
761 printf("%s mode=0x%x count=%d\n", __FUNCTION__, (int) mode, (int) Count);
762 (*real_grDrawVertexArrayContiguous)(mode, Count, pointers, stride);
763 }
764
765 static void debug_grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
766 {
767 printf("%s %d,%d .. %d,%d\n", __FUNCTION__,
768 (int) minx, (int) miny, (int) maxx, (int) maxy);
769 (*real_grClipWindow)(minx, miny, maxx, maxy);
770 }
771
772 static void debug_grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
773 {
774 (*real_grVertexLayout)(param, offset, mode);
775 }
776
777 static void debug_grGlideGetVertexLayout( void *layout )
778 {
779 (*real_grGlideGetVertexLayout)(layout);
780 }
781
782 static void debug_grGlideSetVertexLayout( const void *layout )
783 {
784 (*real_grGlideSetVertexLayout)(layout);
785 }
786
787 static void debug_grTexDownloadMipMapLevel( GrChipID_t tmu,
788 FxU32 startAddress,
789 GrLOD_t thisLod,
790 GrLOD_t largeLod,
791 GrAspectRatio_t aspectRatio,
792 GrTextureFormat_t format,
793 FxU32 evenOdd,
794 void *data )
795 {
796 (*real_grTexDownloadMipMapLevel)(tmu, startAddress, thisLod, largeLod,
797 aspectRatio, format, evenOdd, data);
798 }
799
800 #endif
801
802
803 /*
804 * Examine the context's deviceID to determine what kind of 3dfx hardware
805 * is installed. dlopen() the appropriate Glide library and initialize
806 * this context's Glide function pointers.
807 * Return: true/false = success/failure
808 */
809 GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
810 {
811 static const char *defaultGlide = "libglide3.so";
812 const char *libName;
813 void *libHandle;
814
815 /*
816 * XXX this code which selects a Glide library filename given the
817 * deviceID may need to be cleaned up a bit.
818 * Non-Linux systems may have different filenames, for example.
819 */
820 switch (tmesa->fxScreen->deviceID) {
821 case PCI_CHIP_BANSHEE:
822 case PCI_CHIP_VOODOO3:
823 libName = "libglide3-v3.so";
824 break;
825 case PCI_CHIP_VOODOO5: /* same as PCI_CHIP_VOODOO4 */
826 libName = "libglide3-v5.so";
827 break;
828 default:
829 {
830 __driUtilMessage("unrecognized 3dfx deviceID: 0x%x",
831 tmesa->fxScreen->deviceID);
832 }
833 return GL_FALSE;
834 }
835
836 libHandle = dlopen(libName, RTLD_NOW);
837 if (!libHandle) {
838 /* The device-specific Glide library filename didn't work, try the
839 * old, generic libglide3.so library.
840 */
841 libHandle = dlopen(defaultGlide, RTLD_NOW);
842 if (!libHandle) {
843 __driUtilMessage(
844 "can't find Glide library, dlopen(%s) and dlopen(%s) both failed.",
845 libName, defaultGlide);
846 __driUtilMessage("dlerror() message: %s", dlerror());
847 return GL_FALSE;
848 }
849 libName = defaultGlide;
850 }
851
852 {
853 const char *env = getenv("LIBGL_DEBUG");
854 if (env && strstr(env, "verbose")) {
855 fprintf(stderr, "libGL: using Glide library %s\n", libName);
856 }
857 }
858
859 #define GET_FUNCTION(PTR, NAME) \
860 tmesa->Glide.PTR = dlsym(libHandle, NAME); \
861 if (!tmesa->Glide.PTR) { \
862 __driUtilMessage("couldn't find Glide function %s in %s.", \
863 NAME, libName); \
864 }
865
866 GET_FUNCTION(grDrawPoint, "grDrawPoint");
867 GET_FUNCTION(grDrawLine, "grDrawLine");
868 GET_FUNCTION(grDrawTriangle, "grDrawTriangle");
869 GET_FUNCTION(grVertexLayout, "grVertexLayout");
870 GET_FUNCTION(grDrawVertexArray, "grDrawVertexArray");
871 GET_FUNCTION(grDrawVertexArrayContiguous, "grDrawVertexArrayContiguous");
872 GET_FUNCTION(grBufferClear, "grBufferClear");
873 /*GET_FUNCTION(grBufferSwap, "grBufferSwap");*/
874 GET_FUNCTION(grRenderBuffer, "grRenderBuffer");
875 GET_FUNCTION(grErrorSetCallback, "grErrorSetCallback");
876 GET_FUNCTION(grFinish, "grFinish");
877 GET_FUNCTION(grFlush, "grFlush");
878 GET_FUNCTION(grSstWinOpen, "grSstWinOpen");
879 GET_FUNCTION(grSstWinClose, "grSstWinClose");
880 #if 0
881 /* Not in V3 lib, and not used anyway. */
882 GET_FUNCTION(grSetNumPendingBuffers, "grSetNumPendingBuffers");
883 #endif
884 GET_FUNCTION(grSelectContext, "grSelectContext");
885 GET_FUNCTION(grSstOrigin, "grSstOrigin");
886 GET_FUNCTION(grSstSelect, "grSstSelect");
887 GET_FUNCTION(grAlphaBlendFunction, "grAlphaBlendFunction");
888 GET_FUNCTION(grAlphaCombine, "grAlphaCombine");
889 GET_FUNCTION(grAlphaControlsITRGBLighting, "grAlphaControlsITRGBLighting");
890 GET_FUNCTION(grAlphaTestFunction, "grAlphaTestFunction");
891 GET_FUNCTION(grAlphaTestReferenceValue, "grAlphaTestReferenceValue");
892 GET_FUNCTION(grChromakeyMode, "grChromakeyMode");
893 GET_FUNCTION(grChromakeyValue, "grChromakeyValue");
894 GET_FUNCTION(grClipWindow, "grClipWindow");
895 GET_FUNCTION(grColorCombine, "grColorCombine");
896 GET_FUNCTION(grColorMask, "grColorMask");
897 GET_FUNCTION(grCullMode, "grCullMode");
898 GET_FUNCTION(grConstantColorValue, "grConstantColorValue");
899 GET_FUNCTION(grDepthBiasLevel, "grDepthBiasLevel");
900 GET_FUNCTION(grDepthBufferFunction, "grDepthBufferFunction");
901 GET_FUNCTION(grDepthBufferMode, "grDepthBufferMode");
902 GET_FUNCTION(grDepthMask, "grDepthMask");
903 GET_FUNCTION(grDisableAllEffects, "grDisableAllEffects");
904 GET_FUNCTION(grDitherMode, "grDitherMode");
905 GET_FUNCTION(grFogColorValue, "grFogColorValue");
906 GET_FUNCTION(grFogMode, "grFogMode");
907 GET_FUNCTION(grFogTable, "grFogTable");
908 GET_FUNCTION(grLoadGammaTable, "grLoadGammaTable");
909 GET_FUNCTION(grSplash, "grSplash");
910 GET_FUNCTION(grGet, "grGet");
911 GET_FUNCTION(grGetString, "grGetString");
912 GET_FUNCTION(grQueryResolutions, "grQueryResolutions");
913 GET_FUNCTION(grReset, "grReset");
914 GET_FUNCTION(grGetProcAddress, "grGetProcAddress");
915 GET_FUNCTION(grEnable, "grEnable");
916 GET_FUNCTION(grDisable, "grDisable");
917 GET_FUNCTION(grCoordinateSpace, "grCoordinateSpace");
918 GET_FUNCTION(grDepthRange, "grDepthRange");
919 GET_FUNCTION(grStippleMode, "grStippleMode");
920 GET_FUNCTION(grStipplePattern, "grStipplePattern");
921 GET_FUNCTION(grViewport, "grViewport");
922 GET_FUNCTION(grTexCalcMemRequired, "grTexCalcMemRequired");
923 GET_FUNCTION(grTexTextureMemRequired, "grTexTextureMemRequired");
924 GET_FUNCTION(grTexMinAddress, "grTexMinAddress");
925 GET_FUNCTION(grTexMaxAddress, "grTexMaxAddress");
926 GET_FUNCTION(grTexNCCTable, "grTexNCCTable");
927 GET_FUNCTION(grTexSource, "grTexSource");
928 GET_FUNCTION(grTexClampMode, "grTexClampMode");
929 GET_FUNCTION(grTexCombine, "grTexCombine");
930 GET_FUNCTION(grTexDetailControl, "grTexDetailControl");
931 GET_FUNCTION(grTexFilterMode, "grTexFilterMode");
932 GET_FUNCTION(grTexLodBiasValue, "grTexLodBiasValue");
933 GET_FUNCTION(grTexDownloadMipMap, "grTexDownloadMipMap");
934 GET_FUNCTION(grTexDownloadMipMapLevel, "grTexDownloadMipMapLevel");
935 GET_FUNCTION(grTexDownloadMipMapLevelPartial, "grTexDownloadMipMapLevelPartial");
936 GET_FUNCTION(grTexDownloadTable, "grTexDownloadTable");
937 GET_FUNCTION(grTexDownloadTablePartial, "grTexDownloadTablePartial");
938 GET_FUNCTION(grTexMipMapMode, "grTexMipMapMode");
939 GET_FUNCTION(grTexMultibase, "grTexMultibase");
940 GET_FUNCTION(grTexMultibaseAddress, "grTexMultibaseAddress");
941 GET_FUNCTION(grLfbLock, "grLfbLock");
942 GET_FUNCTION(grLfbUnlock, "grLfbUnlock");
943 GET_FUNCTION(grLfbConstantAlpha, "grLfbConstantAlpha");
944 GET_FUNCTION(grLfbConstantDepth, "grLfbConstantDepth");
945 GET_FUNCTION(grLfbWriteColorSwizzle, "grLfbWriteColorSwizzle");
946 GET_FUNCTION(grLfbWriteColorFormat, "grLfbWriteColorFormat");
947 GET_FUNCTION(grLfbWriteRegion, "grLfbWriteRegion");
948 GET_FUNCTION(grLfbReadRegion, "grLfbReadRegion");
949 GET_FUNCTION(grGlideInit, "grGlideInit");
950 GET_FUNCTION(grGlideShutdown, "grGlideShutdown");
951 GET_FUNCTION(grGlideGetState, "grGlideGetState");
952 GET_FUNCTION(grGlideSetState, "grGlideSetState");
953 GET_FUNCTION(grGlideGetVertexLayout, "grGlideGetVertexLayout");
954 GET_FUNCTION(grGlideSetVertexLayout, "grGlideSetVertexLayout");
955
956 /* Glide utility functions */
957 GET_FUNCTION(guFogGenerateExp, "guFogGenerateExp");
958 GET_FUNCTION(guFogGenerateExp2, "guFogGenerateExp2");
959 GET_FUNCTION(guFogGenerateLinear, "guFogGenerateLinear");
960
961 /* DRI functions */
962 GET_FUNCTION(grDRIOpen, "grDRIOpen");
963 GET_FUNCTION(grDRIPosition, "grDRIPosition");
964 /*GET_FUNCTION(grDRILostContext, "grDRILostContext");*/
965 GET_FUNCTION(grDRIImportFifo, "grDRIImportFifo");
966 GET_FUNCTION(grDRIInvalidateAll, "grDRIInvalidateAll");
967 GET_FUNCTION(grDRIResetSAREA, "grDRIResetSAREA");
968 GET_FUNCTION(grDRIBufferSwap, "grDRIBufferSwap");
969
970 /*
971 * Extension functions:
972 * Just use dlysm() because we want a NULL pointer if the function is
973 * not found.
974 */
975 /* PIXEXT extension */
976 tmesa->Glide.grStencilFunc = dlsym(libHandle, "grStencilFunc");
977 tmesa->Glide.grStencilMask = dlsym(libHandle, "grStencilMask");
978 tmesa->Glide.grStencilOp = dlsym(libHandle, "grStencilOp");
979 tmesa->Glide.grBufferClearExt = dlsym(libHandle, "grBufferClearExt");
980 tmesa->Glide.grColorMaskExt = dlsym(libHandle, "grColorMaskExt");
981 /* COMBINE extension */
982 tmesa->Glide.grColorCombineExt = dlsym(libHandle, "grColorCombineExt");
983 tmesa->Glide.grTexColorCombineExt = dlsym(libHandle, "grTexColorCombineExt");
984 tmesa->Glide.grAlphaCombineExt = dlsym(libHandle, "grAlphaCombineExt");
985 tmesa->Glide.grTexAlphaCombineExt = dlsym(libHandle, "grTexAlphaCombineExt");
986 tmesa->Glide.grAlphaBlendFunctionExt = dlsym(libHandle, "grAlphaBlendFunctionExt");
987 tmesa->Glide.grConstantColorValueExt = dlsym(libHandle, "grConstantColorValueExt");
988 /* Texus 2 */
989 tmesa->Glide.txImgQuantize = dlsym(libHandle, "txImgQuantize");
990 tmesa->Glide.txImgDequantizeFXT1 = dlsym(libHandle, "_txImgDequantizeFXT1");
991 tmesa->Glide.txErrorSetCallback = dlsym(libHandle, "txErrorSetCallback");
992
993 #ifdef DEBUG_TRAP
994 /* wrap the drawing functions so we can trap them */
995 real_grDrawTriangle = tmesa->Glide.grDrawTriangle;
996 tmesa->Glide.grDrawTriangle = debug_grDrawTriangle;
997
998 real_grDrawPoint = tmesa->Glide.grDrawPoint;
999 tmesa->Glide.grDrawPoint = debug_grDrawPoint;
1000
1001 real_grDrawVertexArray = tmesa->Glide.grDrawVertexArray;
1002 tmesa->Glide.grDrawVertexArray = debug_grDrawVertexArray;
1003
1004 real_grDrawVertexArrayContiguous = tmesa->Glide.grDrawVertexArrayContiguous;
1005 tmesa->Glide.grDrawVertexArrayContiguous = debug_grDrawVertexArrayContiguous;
1006
1007 real_grClipWindow = tmesa->Glide.grClipWindow;
1008 tmesa->Glide.grClipWindow = debug_grClipWindow;
1009
1010 real_grVertexLayout = tmesa->Glide.grVertexLayout;
1011 tmesa->Glide.grVertexLayout = debug_grVertexLayout;
1012
1013 real_grGlideGetVertexLayout = tmesa->Glide.grGlideGetVertexLayout;
1014 tmesa->Glide.grGlideGetVertexLayout = debug_grGlideGetVertexLayout;
1015
1016 real_grGlideSetVertexLayout = tmesa->Glide.grGlideSetVertexLayout;
1017 tmesa->Glide.grGlideSetVertexLayout = debug_grGlideSetVertexLayout;
1018
1019 real_grTexDownloadMipMapLevel = tmesa->Glide.grTexDownloadMipMapLevel;
1020 tmesa->Glide.grTexDownloadMipMapLevel = debug_grTexDownloadMipMapLevel;
1021
1022 #endif
1023 return GL_TRUE;
1024 }