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