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