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