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