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