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