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