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