mesa: merge gallium-0.2 into gallium-master-merge
[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 ctx->Const.MaxDrawBuffers = 1;
313
314 /* Initialize the software rasterizer and helper modules.
315 */
316 _swrast_CreateContext( ctx );
317 _vbo_CreateContext( ctx );
318 _tnl_CreateContext( ctx );
319 _swsetup_CreateContext( ctx );
320
321 /* Install the customized pipeline:
322 */
323 _tnl_destroy_pipeline( ctx );
324 _tnl_install_pipeline( ctx, tdfx_pipeline );
325
326 /* Configure swrast and T&L to match hardware characteristics:
327 */
328 _swrast_allow_pixel_fog( ctx, GL_TRUE );
329 _swrast_allow_vertex_fog( ctx, GL_FALSE );
330 _tnl_allow_pixel_fog( ctx, GL_TRUE );
331 _tnl_allow_vertex_fog( ctx, GL_FALSE );
332
333 tdfxDDInitExtensions( ctx );
334 /* XXX these should really go right after _mesa_init_driver_functions() */
335 tdfxDDInitSpanFuncs( ctx );
336 tdfxDDInitStateFuncs( ctx );
337 tdfxDDInitTriFuncs( ctx );
338 tdfxInitVB( ctx );
339 tdfxInitState( fxMesa );
340
341 #if DO_DEBUG
342 TDFX_DEBUG = driParseDebugString( getenv( "TDFX_DEBUG" ), debug_control );
343 #endif
344
345 if (driQueryOptionb(&fxMesa->optionCache, "no_rast")) {
346 fprintf(stderr, "disabling 3D acceleration\n");
347 FALLBACK(fxMesa, TDFX_FALLBACK_DISABLE, 1);
348 }
349
350 return GL_TRUE;
351 }
352
353
354 static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
355 {
356 FxI32 result;
357 int i;
358
359 LOCK_HARDWARE( fxMesa );
360
361 fxMesa->Glide.grGet( GR_GLIDE_VERTEXLAYOUT_SIZE, sizeof(FxI32), &result );
362 for ( i = 0 ; i < TDFX_NUM_LAYOUTS ; i++ ) {
363 fxMesa->layout[i] = MALLOC( result );
364 if ( !fxMesa->layout[i] ) {
365 UNLOCK_HARDWARE( fxMesa );
366 return GL_FALSE;
367 }
368 }
369
370 /* Tiny vertex format - 16 bytes.
371 */
372 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
373 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
374 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
375 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
376 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
377 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_TINY] );
378
379 /* Non textured vertex format - 24 bytes (Need w for table fog)
380 */
381 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
382 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
383 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
384 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
385 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
386 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
387 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_NOTEX] );
388
389 /* Single textured vertex format - 32 bytes.
390 */
391 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
392 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
393 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
394 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
395 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
396 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
397 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
398 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_SINGLE] );
399
400 /* Multitextured vertex format - 40 bytes.
401 */
402 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
403 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
404 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
405 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
406 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
407 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
408 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
409 fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
410 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] );
411
412 /* Projected texture vertex format - 36 bytes.
413 */
414 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
415 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
416 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
417 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
418 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
419 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
420 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
421 fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
422 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ1] );
423
424 /* Projected multitexture vertex format - 48 bytes.
425 */
426 fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
427 fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
428 fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
429 fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
430 fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
431 fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
432 fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
433 fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
434 fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
435 fxMesa->Glide.grVertexLayout( GR_PARAM_Q1, TDFX_Q1_OFFSET, GR_PARAM_ENABLE );
436 fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ2] );
437
438 UNLOCK_HARDWARE( fxMesa );
439
440 return GL_TRUE;
441 }
442
443
444 /*
445 * Initialize the state in an tdfxContextPtr struct.
446 */
447 static GLboolean
448 tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
449 {
450 /* KW: Would be nice to make one of these a member of the other.
451 */
452 FxI32 result[2];
453 const char *gext;
454
455 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
456 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
457 }
458
459 #if DEBUG_LOCKING
460 fprintf(stderr, "Debug locking enabled\n");
461 #endif
462
463 if ( fxMesa->Glide.Initialized )
464 return GL_TRUE;
465
466 fxMesa->width = driDrawPriv->w;
467 fxMesa->height = driDrawPriv->h;
468
469 /* We have to use a light lock here, because we can't do any glide
470 * operations yet. No use of FX_* functions in this function.
471 */
472 DRM_LIGHT_LOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext );
473
474 fxMesa->Glide.grGlideInit();
475 fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
476
477 fxMesa->Glide.Context = fxMesa->Glide.grSstWinOpen( (FxU32) -1,
478 GR_RESOLUTION_NONE,
479 GR_REFRESH_NONE,
480 fxMesa->Glide.ColorFormat,
481 fxMesa->Glide.Origin,
482 2, 1 );
483
484 fxMesa->Glide.grDRIResetSAREA();
485
486 DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext );
487
488 if ( !fxMesa->Glide.Context )
489 return GL_FALSE;
490
491
492 /* Perform the Glide-dependant part of the context initialization.
493 */
494 FX_grColorMaskv( fxMesa->glCtx, true4 );
495
496 tdfxTMInit( fxMesa );
497
498 LOCK_HARDWARE( fxMesa );
499
500 /* JJJ - COMMAND_TRANSPORT, PALETTE6666 */
501 gext = fxMesa->Glide.grGetString( GR_EXTENSION );
502 fxMesa->Glide.HaveCombineExt = strstr(gext, "COMBINE") && !getenv("MESA_FX_IGNORE_CMBEXT");
503 fxMesa->Glide.HaveCommandTransportExt = GL_FALSE;
504 fxMesa->Glide.HaveFogCoordExt = GL_TRUE;
505 fxMesa->Glide.HavePixelExt = strstr(gext, "PIXEXT") && !getenv("MESA_FX_IGNORE_PIXEXT");
506 fxMesa->Glide.HaveTextureBufferExt = GL_TRUE;
507 fxMesa->Glide.HaveTexFmtExt = strstr(gext, "TEXFMT") && !getenv("MESA_FX_IGNORE_TEXFMT");
508 fxMesa->Glide.HaveTexUMAExt = strstr(gext, "TEXUMA") && !getenv("MESA_FX_IGNORE_TEXUMA");
509 fxMesa->Glide.HaveMirrorExt = strstr(gext, "TEXMIRROR") && !getenv("MESA_FX_IGNORE_MIREXT");
510 fxMesa->Glide.HaveTexus2 = GL_FALSE;
511
512 if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
513 fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
514 } else {
515 fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_DISABLE);
516 }
517
518 fxMesa->Glide.grLfbWriteColorFormat( GR_COLORFORMAT_ABGR );
519
520 fxMesa->Glide.grGet( GR_TEXTURE_ALIGN, sizeof(FxI32), result );
521 fxMesa->Glide.TextureAlign = result[0];
522
523 fxMesa->Glide.State = NULL;
524 fxMesa->Glide.grGet( GR_GLIDE_STATE_SIZE, sizeof(FxI32), result );
525 fxMesa->Glide.State = MALLOC( result[0] );
526
527 fxMesa->Fog.Table = NULL;
528 fxMesa->Glide.grGet( GR_FOG_TABLE_ENTRIES, sizeof(FxI32), result );
529 fxMesa->Fog.Table = MALLOC( result[0] * sizeof(GrFog_t) );
530
531 UNLOCK_HARDWARE( fxMesa );
532
533 if ( !fxMesa->Glide.State || !fxMesa->Fog.Table ) {
534 if ( fxMesa->Glide.State )
535 FREE( fxMesa->Glide.State );
536 if ( fxMesa->Fog.Table )
537 FREE( fxMesa->Fog.Table );
538 return GL_FALSE;
539 }
540
541 if ( !tdfxInitVertexFormats( fxMesa ) ) {
542 return GL_FALSE;
543 }
544
545 LOCK_HARDWARE( fxMesa );
546
547 fxMesa->Glide.grGlideGetState( fxMesa->Glide.State );
548
549 if ( getenv( "FX_GLIDE_INFO" ) ) {
550 printf( "GR_RENDERER = %s\n", (char *) fxMesa->Glide.grGetString( GR_RENDERER ) );
551 printf( "GR_VERSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_VERSION ) );
552 printf( "GR_VENDOR = %s\n", (char *) fxMesa->Glide.grGetString( GR_VENDOR ) );
553 printf( "GR_HARDWARE = %s\n", (char *) fxMesa->Glide.grGetString( GR_HARDWARE ) );
554 printf( "GR_EXTENSION = %s\n", (char *) gext );
555 }
556
557 UNLOCK_HARDWARE( fxMesa );
558
559 fxMesa->numClipRects = 0;
560 fxMesa->pClipRects = NULL;
561 fxMesa->scissoredClipRects = GL_FALSE;
562
563 fxMesa->Glide.Initialized = GL_TRUE;
564
565 return GL_TRUE;
566 }
567
568
569 void
570 tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
571 {
572 tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
573
574 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
575 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
576 }
577
578 if ( fxMesa ) {
579 if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) {
580 /* This share group is about to go away, free our private
581 * texture object data.
582 */
583 struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
584 GLuint id;
585 for (id = _mesa_HashFirstEntry(textures);
586 id;
587 id = _mesa_HashNextEntry(textures, id)) {
588 struct gl_texture_object *tObj
589 = _mesa_lookup_texture(fxMesa->glCtx, id);
590 tdfxTMFreeTexture(fxMesa, tObj);
591 }
592 }
593
594 tdfxTMClose(fxMesa); /* free texture memory */
595
596 _swsetup_DestroyContext( fxMesa->glCtx );
597 _tnl_DestroyContext( fxMesa->glCtx );
598 _vbo_DestroyContext( fxMesa->glCtx );
599 _swrast_DestroyContext( fxMesa->glCtx );
600
601 tdfxFreeVB( fxMesa->glCtx );
602
603 /* Free Mesa context */
604 fxMesa->glCtx->DriverCtx = NULL;
605 _mesa_destroy_context(fxMesa->glCtx);
606
607 /* free the tdfx context */
608 FREE( fxMesa );
609 }
610 }
611
612
613 GLboolean
614 tdfxUnbindContext( __DRIcontextPrivate *driContextPriv )
615 {
616 GET_CURRENT_CONTEXT(ctx);
617 tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
618
619 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
620 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
621 }
622
623 if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) {
624 LOCK_HARDWARE(fxMesa);
625 fxMesa->Glide.grGlideGetState(fxMesa->Glide.State);
626 UNLOCK_HARDWARE(fxMesa);
627 }
628 return GL_TRUE;
629 }
630
631
632 GLboolean
633 tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
634 __DRIdrawablePrivate *driDrawPriv,
635 __DRIdrawablePrivate *driReadPriv )
636 {
637 if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
638 fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
639 }
640
641 if ( driContextPriv ) {
642 tdfxContextPtr newFx = (tdfxContextPtr) driContextPriv->driverPrivate;
643 GLcontext *newCtx = newFx->glCtx;
644 GET_CURRENT_CONTEXT(curCtx);
645
646 if ((newFx->driDrawable != driDrawPriv)
647 || (newFx->driReadable != driReadPriv)) {
648 newFx->driDrawable = driDrawPriv;
649 newFx->driReadable = driReadPriv;
650 newFx->dirty = ~0;
651 }
652 else {
653 if (curCtx == newCtx) {
654 /* same drawable, same context -> no-op */
655 /* Need to call _mesa_make_current2() in order to make sure API
656 * dispatch is set correctly.
657 */
658 _mesa_make_current( newCtx,
659 (GLframebuffer *) driDrawPriv->driverPrivate,
660 (GLframebuffer *) driReadPriv->driverPrivate );
661 return GL_TRUE;
662 }
663 /* [dBorca] tunnel2 requires this */
664 newFx->dirty = ~0;
665 }
666
667 driUpdateFramebufferSize(newCtx, driDrawPriv);
668 if (driDrawPriv != driReadPriv) {
669 driUpdateFramebufferSize(newCtx, driReadPriv);
670 }
671
672 if ( !newFx->Glide.Initialized ) {
673 if ( !tdfxInitContext( driDrawPriv, newFx ) )
674 return GL_FALSE;
675
676 LOCK_HARDWARE( newFx );
677
678 /* FIXME: Force loading of window information */
679 newFx->width = 0;
680 tdfxUpdateClipping(newCtx);
681 tdfxUploadClipping(newFx);
682
683 UNLOCK_HARDWARE( newFx );
684 } else {
685 LOCK_HARDWARE( newFx );
686
687 newFx->Glide.grSstSelect( newFx->Glide.Board );
688 newFx->Glide.grGlideSetState( newFx->Glide.State );
689
690 tdfxUpdateClipping(newCtx);
691 tdfxUploadClipping(newFx);
692
693 UNLOCK_HARDWARE( newFx );
694 }
695
696 _mesa_make_current( newCtx,
697 (GLframebuffer *) driDrawPriv->driverPrivate,
698 (GLframebuffer *) driReadPriv->driverPrivate );
699 } else {
700 _mesa_make_current( NULL, NULL, NULL );
701 }
702
703 return GL_TRUE;
704 }
705
706
707 /*
708 * Enable this to trace calls to various Glide functions.
709 */
710 /*#define DEBUG_TRAP*/
711 #ifdef DEBUG_TRAP
712 static void (*real_grDrawTriangle)( const void *a, const void *b, const void *c );
713 static void (*real_grDrawPoint)( const void *a );
714 static void (*real_grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers);
715 static void (*real_grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count,
716 void *pointers, FxU32 stride);
717 static void (*real_grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy );
718
719 static void (*real_grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode);
720 static void (*real_grGlideGetVertexLayout)( void *layout );
721 static void (*real_grGlideSetVertexLayout)( const void *layout );
722
723 static void (*real_grTexDownloadMipMapLevel)( GrChipID_t tmu,
724 FxU32 startAddress,
725 GrLOD_t thisLod,
726 GrLOD_t largeLod,
727 GrAspectRatio_t aspectRatio,
728 GrTextureFormat_t format,
729 FxU32 evenOdd,
730 void *data );
731
732
733 static void debug_grDrawTriangle( const void *a, const void *b, const void *c )
734 {
735 printf("%s\n", __FUNCTION__);
736 (*real_grDrawTriangle)(a, b, c);
737 }
738
739 static void debug_grDrawPoint( const void *a )
740 {
741 const float *f = (const float *) a;
742 printf("%s %g %g\n", __FUNCTION__, f[0], f[1]);
743 (*real_grDrawPoint)(a);
744 }
745
746 static void debug_grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers)
747 {
748 printf("%s count=%d\n", __FUNCTION__, (int) Count);
749 (*real_grDrawVertexArray)(mode, Count, pointers);
750 }
751
752 static void debug_grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count,
753 void *pointers, FxU32 stride)
754 {
755 printf("%s mode=0x%x count=%d\n", __FUNCTION__, (int) mode, (int) Count);
756 (*real_grDrawVertexArrayContiguous)(mode, Count, pointers, stride);
757 }
758
759 static void debug_grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
760 {
761 printf("%s %d,%d .. %d,%d\n", __FUNCTION__,
762 (int) minx, (int) miny, (int) maxx, (int) maxy);
763 (*real_grClipWindow)(minx, miny, maxx, maxy);
764 }
765
766 static void debug_grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
767 {
768 (*real_grVertexLayout)(param, offset, mode);
769 }
770
771 static void debug_grGlideGetVertexLayout( void *layout )
772 {
773 (*real_grGlideGetVertexLayout)(layout);
774 }
775
776 static void debug_grGlideSetVertexLayout( const void *layout )
777 {
778 (*real_grGlideSetVertexLayout)(layout);
779 }
780
781 static void debug_grTexDownloadMipMapLevel( GrChipID_t tmu,
782 FxU32 startAddress,
783 GrLOD_t thisLod,
784 GrLOD_t largeLod,
785 GrAspectRatio_t aspectRatio,
786 GrTextureFormat_t format,
787 FxU32 evenOdd,
788 void *data )
789 {
790 (*real_grTexDownloadMipMapLevel)(tmu, startAddress, thisLod, largeLod,
791 aspectRatio, format, evenOdd, data);
792 }
793
794 #endif
795
796
797 /*
798 * Examine the context's deviceID to determine what kind of 3dfx hardware
799 * is installed. dlopen() the appropriate Glide library and initialize
800 * this context's Glide function pointers.
801 * Return: true/false = success/failure
802 */
803 GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
804 {
805 static const char *defaultGlide = "libglide3.so";
806 const char *libName;
807 void *libHandle;
808
809 /*
810 * XXX this code which selects a Glide library filename given the
811 * deviceID may need to be cleaned up a bit.
812 * Non-Linux systems may have different filenames, for example.
813 */
814 switch (tmesa->fxScreen->deviceID) {
815 case PCI_CHIP_BANSHEE:
816 case PCI_CHIP_VOODOO3:
817 libName = "libglide3-v3.so";
818 break;
819 case PCI_CHIP_VOODOO5: /* same as PCI_CHIP_VOODOO4 */
820 libName = "libglide3-v5.so";
821 break;
822 default:
823 {
824 __driUtilMessage("unrecognized 3dfx deviceID: 0x%x",
825 tmesa->fxScreen->deviceID);
826 }
827 return GL_FALSE;
828 }
829
830 libHandle = dlopen(libName, RTLD_NOW);
831 if (!libHandle) {
832 /* The device-specific Glide library filename didn't work, try the
833 * old, generic libglide3.so library.
834 */
835 libHandle = dlopen(defaultGlide, RTLD_NOW);
836 if (!libHandle) {
837 __driUtilMessage(
838 "can't find Glide library, dlopen(%s) and dlopen(%s) both failed.",
839 libName, defaultGlide);
840 __driUtilMessage("dlerror() message: %s", dlerror());
841 return GL_FALSE;
842 }
843 libName = defaultGlide;
844 }
845
846 {
847 const char *env = getenv("LIBGL_DEBUG");
848 if (env && strstr(env, "verbose")) {
849 fprintf(stderr, "libGL: using Glide library %s\n", libName);
850 }
851 }
852
853 #define GET_FUNCTION(PTR, NAME) \
854 tmesa->Glide.PTR = dlsym(libHandle, NAME); \
855 if (!tmesa->Glide.PTR) { \
856 __driUtilMessage("couldn't find Glide function %s in %s.", \
857 NAME, libName); \
858 }
859
860 GET_FUNCTION(grDrawPoint, "grDrawPoint");
861 GET_FUNCTION(grDrawLine, "grDrawLine");
862 GET_FUNCTION(grDrawTriangle, "grDrawTriangle");
863 GET_FUNCTION(grVertexLayout, "grVertexLayout");
864 GET_FUNCTION(grDrawVertexArray, "grDrawVertexArray");
865 GET_FUNCTION(grDrawVertexArrayContiguous, "grDrawVertexArrayContiguous");
866 GET_FUNCTION(grBufferClear, "grBufferClear");
867 /*GET_FUNCTION(grBufferSwap, "grBufferSwap");*/
868 GET_FUNCTION(grRenderBuffer, "grRenderBuffer");
869 GET_FUNCTION(grErrorSetCallback, "grErrorSetCallback");
870 GET_FUNCTION(grFinish, "grFinish");
871 GET_FUNCTION(grFlush, "grFlush");
872 GET_FUNCTION(grSstWinOpen, "grSstWinOpen");
873 GET_FUNCTION(grSstWinClose, "grSstWinClose");
874 #if 0
875 /* Not in V3 lib, and not used anyway. */
876 GET_FUNCTION(grSetNumPendingBuffers, "grSetNumPendingBuffers");
877 #endif
878 GET_FUNCTION(grSelectContext, "grSelectContext");
879 GET_FUNCTION(grSstOrigin, "grSstOrigin");
880 GET_FUNCTION(grSstSelect, "grSstSelect");
881 GET_FUNCTION(grAlphaBlendFunction, "grAlphaBlendFunction");
882 GET_FUNCTION(grAlphaCombine, "grAlphaCombine");
883 GET_FUNCTION(grAlphaControlsITRGBLighting, "grAlphaControlsITRGBLighting");
884 GET_FUNCTION(grAlphaTestFunction, "grAlphaTestFunction");
885 GET_FUNCTION(grAlphaTestReferenceValue, "grAlphaTestReferenceValue");
886 GET_FUNCTION(grChromakeyMode, "grChromakeyMode");
887 GET_FUNCTION(grChromakeyValue, "grChromakeyValue");
888 GET_FUNCTION(grClipWindow, "grClipWindow");
889 GET_FUNCTION(grColorCombine, "grColorCombine");
890 GET_FUNCTION(grColorMask, "grColorMask");
891 GET_FUNCTION(grCullMode, "grCullMode");
892 GET_FUNCTION(grConstantColorValue, "grConstantColorValue");
893 GET_FUNCTION(grDepthBiasLevel, "grDepthBiasLevel");
894 GET_FUNCTION(grDepthBufferFunction, "grDepthBufferFunction");
895 GET_FUNCTION(grDepthBufferMode, "grDepthBufferMode");
896 GET_FUNCTION(grDepthMask, "grDepthMask");
897 GET_FUNCTION(grDisableAllEffects, "grDisableAllEffects");
898 GET_FUNCTION(grDitherMode, "grDitherMode");
899 GET_FUNCTION(grFogColorValue, "grFogColorValue");
900 GET_FUNCTION(grFogMode, "grFogMode");
901 GET_FUNCTION(grFogTable, "grFogTable");
902 GET_FUNCTION(grLoadGammaTable, "grLoadGammaTable");
903 GET_FUNCTION(grSplash, "grSplash");
904 GET_FUNCTION(grGet, "grGet");
905 GET_FUNCTION(grGetString, "grGetString");
906 GET_FUNCTION(grQueryResolutions, "grQueryResolutions");
907 GET_FUNCTION(grReset, "grReset");
908 GET_FUNCTION(grGetProcAddress, "grGetProcAddress");
909 GET_FUNCTION(grEnable, "grEnable");
910 GET_FUNCTION(grDisable, "grDisable");
911 GET_FUNCTION(grCoordinateSpace, "grCoordinateSpace");
912 GET_FUNCTION(grDepthRange, "grDepthRange");
913 GET_FUNCTION(grStippleMode, "grStippleMode");
914 GET_FUNCTION(grStipplePattern, "grStipplePattern");
915 GET_FUNCTION(grViewport, "grViewport");
916 GET_FUNCTION(grTexCalcMemRequired, "grTexCalcMemRequired");
917 GET_FUNCTION(grTexTextureMemRequired, "grTexTextureMemRequired");
918 GET_FUNCTION(grTexMinAddress, "grTexMinAddress");
919 GET_FUNCTION(grTexMaxAddress, "grTexMaxAddress");
920 GET_FUNCTION(grTexNCCTable, "grTexNCCTable");
921 GET_FUNCTION(grTexSource, "grTexSource");
922 GET_FUNCTION(grTexClampMode, "grTexClampMode");
923 GET_FUNCTION(grTexCombine, "grTexCombine");
924 GET_FUNCTION(grTexDetailControl, "grTexDetailControl");
925 GET_FUNCTION(grTexFilterMode, "grTexFilterMode");
926 GET_FUNCTION(grTexLodBiasValue, "grTexLodBiasValue");
927 GET_FUNCTION(grTexDownloadMipMap, "grTexDownloadMipMap");
928 GET_FUNCTION(grTexDownloadMipMapLevel, "grTexDownloadMipMapLevel");
929 GET_FUNCTION(grTexDownloadMipMapLevelPartial, "grTexDownloadMipMapLevelPartial");
930 GET_FUNCTION(grTexDownloadTable, "grTexDownloadTable");
931 GET_FUNCTION(grTexDownloadTablePartial, "grTexDownloadTablePartial");
932 GET_FUNCTION(grTexMipMapMode, "grTexMipMapMode");
933 GET_FUNCTION(grTexMultibase, "grTexMultibase");
934 GET_FUNCTION(grTexMultibaseAddress, "grTexMultibaseAddress");
935 GET_FUNCTION(grLfbLock, "grLfbLock");
936 GET_FUNCTION(grLfbUnlock, "grLfbUnlock");
937 GET_FUNCTION(grLfbConstantAlpha, "grLfbConstantAlpha");
938 GET_FUNCTION(grLfbConstantDepth, "grLfbConstantDepth");
939 GET_FUNCTION(grLfbWriteColorSwizzle, "grLfbWriteColorSwizzle");
940 GET_FUNCTION(grLfbWriteColorFormat, "grLfbWriteColorFormat");
941 GET_FUNCTION(grLfbWriteRegion, "grLfbWriteRegion");
942 GET_FUNCTION(grLfbReadRegion, "grLfbReadRegion");
943 GET_FUNCTION(grGlideInit, "grGlideInit");
944 GET_FUNCTION(grGlideShutdown, "grGlideShutdown");
945 GET_FUNCTION(grGlideGetState, "grGlideGetState");
946 GET_FUNCTION(grGlideSetState, "grGlideSetState");
947 GET_FUNCTION(grGlideGetVertexLayout, "grGlideGetVertexLayout");
948 GET_FUNCTION(grGlideSetVertexLayout, "grGlideSetVertexLayout");
949
950 /* Glide utility functions */
951 GET_FUNCTION(guFogGenerateExp, "guFogGenerateExp");
952 GET_FUNCTION(guFogGenerateExp2, "guFogGenerateExp2");
953 GET_FUNCTION(guFogGenerateLinear, "guFogGenerateLinear");
954
955 /* DRI functions */
956 GET_FUNCTION(grDRIOpen, "grDRIOpen");
957 GET_FUNCTION(grDRIPosition, "grDRIPosition");
958 /*GET_FUNCTION(grDRILostContext, "grDRILostContext");*/
959 GET_FUNCTION(grDRIImportFifo, "grDRIImportFifo");
960 GET_FUNCTION(grDRIInvalidateAll, "grDRIInvalidateAll");
961 GET_FUNCTION(grDRIResetSAREA, "grDRIResetSAREA");
962 GET_FUNCTION(grDRIBufferSwap, "grDRIBufferSwap");
963
964 /*
965 * Extension functions:
966 * Just use dlysm() because we want a NULL pointer if the function is
967 * not found.
968 */
969 /* PIXEXT extension */
970 tmesa->Glide.grStencilFunc = dlsym(libHandle, "grStencilFunc");
971 tmesa->Glide.grStencilMask = dlsym(libHandle, "grStencilMask");
972 tmesa->Glide.grStencilOp = dlsym(libHandle, "grStencilOp");
973 tmesa->Glide.grBufferClearExt = dlsym(libHandle, "grBufferClearExt");
974 tmesa->Glide.grColorMaskExt = dlsym(libHandle, "grColorMaskExt");
975 /* COMBINE extension */
976 tmesa->Glide.grColorCombineExt = dlsym(libHandle, "grColorCombineExt");
977 tmesa->Glide.grTexColorCombineExt = dlsym(libHandle, "grTexColorCombineExt");
978 tmesa->Glide.grAlphaCombineExt = dlsym(libHandle, "grAlphaCombineExt");
979 tmesa->Glide.grTexAlphaCombineExt = dlsym(libHandle, "grTexAlphaCombineExt");
980 tmesa->Glide.grAlphaBlendFunctionExt = dlsym(libHandle, "grAlphaBlendFunctionExt");
981 tmesa->Glide.grConstantColorValueExt = dlsym(libHandle, "grConstantColorValueExt");
982 /* Texus 2 */
983 tmesa->Glide.txImgQuantize = dlsym(libHandle, "txImgQuantize");
984 tmesa->Glide.txImgDequantizeFXT1 = dlsym(libHandle, "_txImgDequantizeFXT1");
985 tmesa->Glide.txErrorSetCallback = dlsym(libHandle, "txErrorSetCallback");
986
987 #ifdef DEBUG_TRAP
988 /* wrap the drawing functions so we can trap them */
989 real_grDrawTriangle = tmesa->Glide.grDrawTriangle;
990 tmesa->Glide.grDrawTriangle = debug_grDrawTriangle;
991
992 real_grDrawPoint = tmesa->Glide.grDrawPoint;
993 tmesa->Glide.grDrawPoint = debug_grDrawPoint;
994
995 real_grDrawVertexArray = tmesa->Glide.grDrawVertexArray;
996 tmesa->Glide.grDrawVertexArray = debug_grDrawVertexArray;
997
998 real_grDrawVertexArrayContiguous = tmesa->Glide.grDrawVertexArrayContiguous;
999 tmesa->Glide.grDrawVertexArrayContiguous = debug_grDrawVertexArrayContiguous;
1000
1001 real_grClipWindow = tmesa->Glide.grClipWindow;
1002 tmesa->Glide.grClipWindow = debug_grClipWindow;
1003
1004 real_grVertexLayout = tmesa->Glide.grVertexLayout;
1005 tmesa->Glide.grVertexLayout = debug_grVertexLayout;
1006
1007 real_grGlideGetVertexLayout = tmesa->Glide.grGlideGetVertexLayout;
1008 tmesa->Glide.grGlideGetVertexLayout = debug_grGlideGetVertexLayout;
1009
1010 real_grGlideSetVertexLayout = tmesa->Glide.grGlideSetVertexLayout;
1011 tmesa->Glide.grGlideSetVertexLayout = debug_grGlideSetVertexLayout;
1012
1013 real_grTexDownloadMipMapLevel = tmesa->Glide.grTexDownloadMipMapLevel;
1014 tmesa->Glide.grTexDownloadMipMapLevel = debug_grTexDownloadMipMapLevel;
1015
1016 #endif
1017 return GL_TRUE;
1018 }