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