1 | /* -*- mode: C; tab-width:8; -*- */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | *
|
---|
26 | *
|
---|
27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
---|
28 | * terms stated above.
|
---|
29 | *
|
---|
30 | * Thank you for your contribution, David!
|
---|
31 | *
|
---|
32 | * Please make note of the above copyright/license statement. If you
|
---|
33 | * contributed code or bug fixes to this code under the previous (GNU
|
---|
34 | * Library) license and object to the new license, your code will be
|
---|
35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
---|
36 | * for more information.
|
---|
37 | *
|
---|
38 | * Additional Mesa/3Dfx driver developers:
|
---|
39 | * Daryll Strauss <daryll@precisioninsight.com>
|
---|
40 | * Keith Whitwell <keith@precisioninsight.com>
|
---|
41 | *
|
---|
42 | * See fxapi.h for more revision/author details.
|
---|
43 | */
|
---|
44 |
|
---|
45 |
|
---|
46 | /* fxapi.c - 3Dfx VooDoo/Mesa interface */
|
---|
47 |
|
---|
48 |
|
---|
49 | /********************************************************************
|
---|
50 | *
|
---|
51 | * Function names:
|
---|
52 | * fxMesa.... (The driver API)
|
---|
53 | * fxDD.... (Mesa device driver functions)
|
---|
54 | * fxTM.... (Texture manager functions)
|
---|
55 | * fxSetup.... (Voodoo units setup functions)
|
---|
56 | * fx.... (Internal driver functions)
|
---|
57 | *
|
---|
58 | * Data type names:
|
---|
59 | * fxMesa.... (Public driver data types)
|
---|
60 | * tfx.... (Private driver data types)
|
---|
61 | *
|
---|
62 | ********************************************************************
|
---|
63 | *
|
---|
64 | * V0.30 - David Bucciarelli (davibu@tin.it) Humanware s.r.l.
|
---|
65 | * - introduced a new MESA_GLX_FX related behavior
|
---|
66 | * - the Glide fog table was built in a wrong way (using
|
---|
67 | * gu* Glide function). Added the code for building the
|
---|
68 | * table following the OpenGL specs. Thanks to Steve Baker
|
---|
69 | * for highlighting the problem.
|
---|
70 | * - fixed few problems in my and Keith's fxDDClear code
|
---|
71 | * - merged my code with the Keith's one
|
---|
72 | * - used the new BlendFunc Mesa device driver function
|
---|
73 | * - used the new AlphaFunc Mesa device driver function
|
---|
74 | * - used the new Enable Mesa device driver function
|
---|
75 | * - fixed a bug related to fog in the Mesa core. Fog
|
---|
76 | * were applied two times: at vertex level and at fragment
|
---|
77 | * level (thanks to Steve Baker for reporting the problem)
|
---|
78 | * - glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE) now works
|
---|
79 | * (thanks to Jiri Pop for reporting the problem)
|
---|
80 | * - the driver works fine with OpenGL Unreal
|
---|
81 | * - fixed a bug in the Mesa core clipping code (related
|
---|
82 | * to the q texture coordinate)
|
---|
83 | * - introduced the support for the q texture coordinate
|
---|
84 | *
|
---|
85 | * Keith Whitwell (keithw@cableinet.co.uk)
|
---|
86 | * - optimized the driver and written all the new code
|
---|
87 | * required by the new Mesa-3.1 device driver API
|
---|
88 | * and by the new Mesa-3.1 core changes
|
---|
89 | * - written the cva support and many other stuff
|
---|
90 | *
|
---|
91 | * Brian Paul (brian_paul@avid.com) Avid Technology
|
---|
92 | * - fixed display list share bug for MESA_GLX_FX = window/fullscreen
|
---|
93 | * - fixed glClear/gl...Mask related problem
|
---|
94 | *
|
---|
95 | * Bert Schoenwaelder (bert@prinz-atm.CS.Uni-Magdeburg.De)
|
---|
96 | * - the driver is now able to sleep when waiting for the completation
|
---|
97 | * of multiple swapbuffer operations instead of wasting
|
---|
98 | * CPU time (NOTE: you must uncomment the lines in the
|
---|
99 | * fxMesaSwapBuffers function in order to enable this option)
|
---|
100 | *
|
---|
101 | * Eero Pajarre (epajarre@koti.tpo.fi)
|
---|
102 | * - enabled the macro FLOAT_COLOR_TO_UBYTE_COLOR under
|
---|
103 | * windows
|
---|
104 | * - written an asm x86 optimized float->integer conversions
|
---|
105 | * for windows
|
---|
106 | *
|
---|
107 | * Theodore Jump (tjump@cais.com)
|
---|
108 | * - fixed a small problem in the __wglMonitor function of the
|
---|
109 | * wgl emulator
|
---|
110 | * - written the in-window-rendering hack support for windows
|
---|
111 | * and Vooodoo1/2 cards
|
---|
112 | *
|
---|
113 | * V0.29 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
114 | * - included in Mesa-3.0
|
---|
115 | * - now glGetString(GL_RENDERER) returns more information
|
---|
116 | * about the hardware configuration: "Mesa Glide <version>
|
---|
117 | * <Voodoo_Graphics|Voodoo_Rush|UNKNOWN> <num> CARD/<num> FB/
|
---|
118 | * <num> TM/<num> TMU/<NOSLI|SLI>"
|
---|
119 | * where: <num> CARD is the card used for the current context,
|
---|
120 | * <num> FB is the number of MB for the framebuffer,
|
---|
121 | * <num> TM is the number of MB for the texture memory,
|
---|
122 | * <num> TMU is the number of TMU. You can try to run
|
---|
123 | * Mesa/demos/glinfo in order to have an example of the
|
---|
124 | * output
|
---|
125 | * - fixed a problem of the WGL emulator with the
|
---|
126 | * OpenGL Optimizer 1.1 (thanks to Erwin Coumans for
|
---|
127 | * the bug report)
|
---|
128 | * - fixed some bug in the fxwgl.c code (thanks to
|
---|
129 | * Peter Pettersson for a patch and a bug report)
|
---|
130 | *
|
---|
131 | * Theodore Jump (tjump@cais.com)
|
---|
132 | * - written the SST_DUALHEAD support in the WGL emulator
|
---|
133 | *
|
---|
134 | * Daryll Strauss (daryll@harlot.rb.ca.us)
|
---|
135 | * - fixed the Voodoo Rush support for the in window rendering
|
---|
136 | *
|
---|
137 | * V0.28 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
138 | * - the only supported multitexture functions are GL_MODULATE
|
---|
139 | * for texture set 0 and GL_MODULATE for texture set 1. In
|
---|
140 | * all other cases, the driver falls back to pure software
|
---|
141 | * rendering
|
---|
142 | * - written the support for the new GL_EXT_multitexture
|
---|
143 | * - written the DD_MAX_TEXTURE_COORD_SETS support in the
|
---|
144 | * fxDDGetParameteri() function
|
---|
145 | * - the driver falls back to pure software rendering when
|
---|
146 | * texture mapping function is GL_BLEND
|
---|
147 | *
|
---|
148 | * V0.27 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
149 | * - inluded in the Mesa-3.0beta5
|
---|
150 | * - written a smal extension (GL_FXMESA_global_texture_lod_bias) in
|
---|
151 | * order to expose the LOD bias related Glide function
|
---|
152 | * - fixed a bug fxDDWriteMonoRGBAPixels()
|
---|
153 | * - the driver is now able to fallback to software rendering in
|
---|
154 | * any case not directly supported by the hardware
|
---|
155 | * - written the support for enabling/disabling dithering
|
---|
156 | * - the in-window-rendering hack now works with any X11 screen
|
---|
157 | * depth
|
---|
158 | * - fixed a problem related to color/depth/alpha buffer clears
|
---|
159 | * - fixed a problem when clearing buffer for a context with the
|
---|
160 | * alpha buffer
|
---|
161 | * - fixed a problem in the fxTMReloadSubMipMapLevel() function,
|
---|
162 | * I have forget a "break;" (thanks to Joe Waters for the bug report)
|
---|
163 | * - fixed a problem in the color format for the in window
|
---|
164 | * rendering hack
|
---|
165 | * - written the fxDDReadRGBAPixels function
|
---|
166 | * - written the fxDDDepthTestPixelsGeneric function
|
---|
167 | * - written the fxDDDepthTestSpanGeneric function
|
---|
168 | * - written the fxDDWriteMonoRGBAPixels function
|
---|
169 | * - written the fxDDWriteRGBAPixels function
|
---|
170 | * - removed the multitexture emulation code for Voodoo board
|
---|
171 | * with only one TMU
|
---|
172 | *
|
---|
173 | * Chris Prince <cprince@cs.washington.edu>
|
---|
174 | * - fixed a new bug in the wglUseFontBitmaps code
|
---|
175 | *
|
---|
176 | * Ralf Knoesel (rknoesel@Stormfront.com)
|
---|
177 | * - fixed a bug in the wglUseFontBitmaps code
|
---|
178 | *
|
---|
179 | * Rune Hasvold (runeh@ifi.uio.no)
|
---|
180 | * - fixed a problem related to the aux usage in the fxBestResolution
|
---|
181 | * function
|
---|
182 | * - fixed the order of pixel formats in the WGL emulator
|
---|
183 | *
|
---|
184 | * Fredrik Hubinette (hubbe@hubbe.net)
|
---|
185 | * - the driver shutdown the Glide for most common signals
|
---|
186 | *
|
---|
187 | * V0.26 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
188 | * - included in the Mesa-3.0beta4
|
---|
189 | * - fixed a problem related to a my optimization for the Rune's
|
---|
190 | * pixel-span optimization
|
---|
191 | * - fixed a problem related to fxDDSetNearFar() and ctx->ProjectionMatrixType
|
---|
192 | * (thanks to Ben "Ctrl-Alt-Delete" and the Raul Alonso's ssystem)
|
---|
193 | * - fixed a small bug in the Rune's pixel-span optimization
|
---|
194 | * - fixed a problem with GL_CCW (thanks to Curt Olson for and example
|
---|
195 | * of the problem)
|
---|
196 | * - grVertex setup code is now ready for the internal thread support
|
---|
197 | * - fixed a no used optimization with clipped vertices in
|
---|
198 | * grVertex setup code
|
---|
199 | * - fixed a problem in the GL_LIGHT_MODEL_TWO_SIDE support (thanks
|
---|
200 | * to Patrick H. Madden for a complete example of the bug)
|
---|
201 | *
|
---|
202 | * Rune Hasvold (runeh@ifi.uio.no)
|
---|
203 | * - highly optimized the driver functions for writing pixel
|
---|
204 | * span (2-3 times faster !)
|
---|
205 | *
|
---|
206 | * Axel W. Volley (volley@acm.org) Krauss-Maffei Wehrtechnik
|
---|
207 | * - written the fxDDReadDepthSpanFloat() and fxDDReadDepthSpanInt()
|
---|
208 | * functions
|
---|
209 | *
|
---|
210 | * V0.25 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
211 | * - fixed a problem with Voodoo boards with only one TMU
|
---|
212 | * - fixed a bug in the fxMesaCreateContext()
|
---|
213 | * - now the GL_FRONT_AND_BACK works fine also with
|
---|
214 | * the alpha buffer and/or antialiasing
|
---|
215 | * - written the support for GL_FRONT_AND_BACK drawing but
|
---|
216 | * it doesn't works with the alpha buffer and/or antialiasing
|
---|
217 | * - fixed some bug in the Mesa core for glCopyTexSubImage
|
---|
218 | * and glCopyTexImage functions (thanks to Mike Connell
|
---|
219 | * for an example of the problem)
|
---|
220 | * - make some small optimizations in the Mesa core in order
|
---|
221 | * to save same driver call and state change for not very
|
---|
222 | * well written applications
|
---|
223 | * - introduced the NEW_DRVSTATE and make other optimizations
|
---|
224 | * for minimizing state changes
|
---|
225 | * - made a lot of optimizations in order to minimize state
|
---|
226 | * changes
|
---|
227 | * - it isn't more possible to create a context with the
|
---|
228 | * depth buffer and the stancil buffer (it isn't yet supported)
|
---|
229 | * - now the partial support for the Multitexture extension
|
---|
230 | * works with Quake2 for windows
|
---|
231 | * - vertex snap is not longer used for the Voodoo2 (FX_V2
|
---|
232 | * must be defined)
|
---|
233 | * - done a lot of cleanup in the fxsetup.c file
|
---|
234 | * - now the partial support for the Multitexture extension
|
---|
235 | * works with GLQuake for windows
|
---|
236 | *
|
---|
237 | * Dieter Nuetzel (nuetzel@kogs.informatik.uni-hamburg.de) University of Hamburg
|
---|
238 | * - fixed a problem in the asm code for Linux of the fxvsetup.c file
|
---|
239 | * highlighted by the binutils-2.8.1.0.29. 'fildw' asm instruction
|
---|
240 | * changed in 'fild'
|
---|
241 | *
|
---|
242 | * Kevin Hester (kevinh@glassworks.net)
|
---|
243 | * - written the wglUseFontBitmaps() function in the WGL emulator
|
---|
244 | *
|
---|
245 | * V0.24 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
246 | * - now the drive always uses per fragment fog
|
---|
247 | * - written a small optimization in the points drawing function
|
---|
248 | * - written the support for trilinear filtering with 2 TMUs
|
---|
249 | * - written the first partial support for the Multitexture extension.
|
---|
250 | * This task is quite hard because the color combine units work after
|
---|
251 | * the two texture combine units and not before as required by the
|
---|
252 | * Multitexture extension
|
---|
253 | * - written a workaround in fxBestResolution() in order to solve a
|
---|
254 | * problem with bzflag (it asks for 1x1 window !)
|
---|
255 | * - changed the fxBestResolution() behavior. It now returns the larger
|
---|
256 | * screen resolution supported by the hardware (instead of 640x480)
|
---|
257 | * when it is unable to find an appropriate resolution that is large
|
---|
258 | * enough for the requested size
|
---|
259 | * - the driver is now able to use also the texture memory attached to
|
---|
260 | * second TMU
|
---|
261 | * - the texture memory manager is now able to work with two TMUs and
|
---|
262 | * store texture maps in the memory attached to TMU0, TMU1 or to split
|
---|
263 | * the mimpmap levels across TMUs in order to support trilinear filtering
|
---|
264 | * - I have bought a Voodoo2 board !
|
---|
265 | * - the amount of frambuffer ram is now doubled when an SLI configuration
|
---|
266 | * is detected
|
---|
267 | * - solved a problem related to the fxDDTexParam() and fxTexInvalidate()
|
---|
268 | * functions (thanks to Rune Hasvold for highlighting the problem)
|
---|
269 | * - done some cleanup in the fxvsetup.c file, written
|
---|
270 | * the FXVSETUP_FUNC macro
|
---|
271 | * - done a lot of cleanup in data types and field names
|
---|
272 | *
|
---|
273 | * Rune Hasvold (runeh@ifi.uio.no)
|
---|
274 | * - written the support for a right management of the auxiliary buffer.
|
---|
275 | * You can now use an 800x600 screen without the depth and alpha
|
---|
276 | * buffer
|
---|
277 | * - written the support for a new pixel format (without the depth
|
---|
278 | * and alpha buffer) in the WGL emulator
|
---|
279 | * - fixed a bug in the window version of the GLUT (it was ever asking
|
---|
280 | * for depth buffer)
|
---|
281 | *
|
---|
282 | * V0.23 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
283 | * - included in the Mesa-3.0beta2 release
|
---|
284 | * - written the support for the OpenGL 1.2 GL_TEXTURE_BASE_LEVEL
|
---|
285 | * and GL_TEXTURE_MAX_LEVEL
|
---|
286 | * - rewritten several functions for a more clean support of texture
|
---|
287 | * mapping and in order to solve some bug
|
---|
288 | * - the accumulation buffer works (it is bit slow beacuase it requires
|
---|
289 | * to read/write from/to the Voodoo frame buffer but it works)
|
---|
290 | * - fixed a bug in the fxDDReadRGBASpan driver function (the R and
|
---|
291 | * B channels were read in the wrong order). Thanks to Jason Heym
|
---|
292 | * for highlighting the problem
|
---|
293 | * - written the support for multiple contexts on multiple boards.
|
---|
294 | * you can now use the Mesa/Voodoo with multiple Voodoo Graphics
|
---|
295 | * boards (for example with multiple screens or an HMD)
|
---|
296 | * - the fxBestResolution() now check all available resolutions
|
---|
297 | * and it is able to check the amount of framebuffer memory
|
---|
298 | * before return a resolution
|
---|
299 | * - modified the GLX/X11 driver in order to support all the
|
---|
300 | * resolution available
|
---|
301 | * - changed all function names. They should be now a bit more
|
---|
302 | * readable
|
---|
303 | * - written the Glide grVertex setup code for two TMU or
|
---|
304 | * for Multitexture support with emulationa dn one TMU
|
---|
305 | * - written the support for the new Mesa driver
|
---|
306 | * function GetParametri
|
---|
307 | * - small optimization/clean up in the texbind() function
|
---|
308 | * - fixed a FPU precision problem for glOrtho and texture
|
---|
309 | * mapping (thanks to Antti Juhani Huovilainen for an example
|
---|
310 | * of the problem)
|
---|
311 | * - written some small SGI OpenGL emulation code for the wgl,
|
---|
312 | * the OpenGL Optimizer and Cosmo3D work fine under windows !
|
---|
313 | * - moved the point/line/triangle/quad support in the fxmesa7.c
|
---|
314 | * - fixed a bug in the clear_color_depth() (thanks to Henk Kok
|
---|
315 | * for an example of the problem)
|
---|
316 | * - written a small workaround for Linux GLQuake, it asks
|
---|
317 | * for the alpha buffer and the depth buffer at the some time
|
---|
318 | * (but it never uses the alpha buffer)
|
---|
319 | * - checked the antialiasing points, lines and polygons support.
|
---|
320 | * It works fine
|
---|
321 | * - written the support for standard OpenGL antialiasing using
|
---|
322 | * blending. Lines support works fine (tested with BZflag)
|
---|
323 | * while I have still to check the polygons and points support
|
---|
324 | * - written the support for the alpha buffer. The driver is now
|
---|
325 | * able to use the Voodoo auxiliary buffer as an alpha buffer
|
---|
326 | * instead of a depth buffer. Also all the OpenGL blending
|
---|
327 | * modes are now supported. But you can't request a context
|
---|
328 | * with an alpha buffer AND a depth buffer at the some time
|
---|
329 | * (this is an hardware limitation)
|
---|
330 | * - written the support for switching between the fullscreen
|
---|
331 | * rendering and the in-window-rendering hack on the fly
|
---|
332 | *
|
---|
333 | * Rune Hasvold (runeh@ifi.uio.no)
|
---|
334 | * - fixed a bug in the texparam() function
|
---|
335 | *
|
---|
336 | * Brian Paul (brianp@elastic.avid.com) Avid Technology
|
---|
337 | * - sources accomodated for the new Mesa 3.0beta1
|
---|
338 | *
|
---|
339 | * V0.22 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
340 | * - included with some v0.23 bug fix in the final release
|
---|
341 | * of the Mesa-2.6
|
---|
342 | * - written the support for the MESA_WGL_FX env. var. but
|
---|
343 | * not tested because I have only Voodoo Graphics boards
|
---|
344 | * - fixed a bug in the backface culling code
|
---|
345 | * (thanks to David Farrell for an example of the problem)
|
---|
346 | * - fixed the "Quake2 elevator" bug
|
---|
347 | * - GL_POLYGONS with 3/4 vertices are now drawn as
|
---|
348 | * GL_TRIANLGES/GL_QUADS (a small optimization for GLQuake)
|
---|
349 | * - fixed a bug in fxmesa6.h for GL_LINE_LOOP
|
---|
350 | * - fixed a NearFarStack bug in the Mesa when applications
|
---|
351 | * directly call glLoadMatrix to load a projection matrix
|
---|
352 | * - done some cleanup in the fxmesa2.c file
|
---|
353 | * - the driver no longer translates the texture maps
|
---|
354 | * when the Mesa internal format and the Voodoo
|
---|
355 | * format are the some (usefull for 1 byte texture maps
|
---|
356 | * where the driver can directly use the Mesa texture
|
---|
357 | * map). Also the amount of used memory is halfed
|
---|
358 | * - fixed a bug for GL_DECAL and GL_RGBA
|
---|
359 | * - fixed a bug in the clear_color_depth()
|
---|
360 | * - tested the v0.22 with the Mesa-2.6beta2. Impressive
|
---|
361 | * performances improvement thanks to the new Josh's
|
---|
362 | * asm code (+10fps in the isosurf demo, +5fps in GLQuake
|
---|
363 | * TIMEREFRESH)
|
---|
364 | * - written a optimized version of the RenderVB Mesa driver
|
---|
365 | * function. The Voodoo driver is now able to upload polygons
|
---|
366 | * in the most common cases at a very good speed. Good
|
---|
367 | * performance improvement for large set of small polygons
|
---|
368 | * - optimized the asm code for setting up the color information
|
---|
369 | * in the Glide grVertex structure
|
---|
370 | * - fixed a bug in the fxmesa2.c asm code (the ClipMask[]
|
---|
371 | * wasn't working)
|
---|
372 | *
|
---|
373 | * Josh Vanderhoof (joshv@planet.net)
|
---|
374 | * - removed the flush() function because it isn't required
|
---|
375 | * - limited the maximum number of swapbuffers in the Voodoo
|
---|
376 | * commands FIFO (controlled by the env. var. MESA_FX_SWAP_PENDING)
|
---|
377 | *
|
---|
378 | * Holger Kleemiss (holger.kleemiss@metronet.de) STN Atlas Elektronik GmbH
|
---|
379 | * - applied some patch for the Voodoo Rush
|
---|
380 | *
|
---|
381 | * V0.21 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
382 | * - the driver is now able to take advantage of the ClipMask[],
|
---|
383 | * ClipOrMask and ClipAndMask information also under Windows
|
---|
384 | * - introduced a new function in the Mesa driver interface
|
---|
385 | * ClearColorAndDepth(). Now the glClear() function is
|
---|
386 | * 2 times faster (!) when you have to clear the color buffer
|
---|
387 | * and the depth buffer at some time
|
---|
388 | * - written the first version of the fxRenderVB() driver
|
---|
389 | * function
|
---|
390 | * - optimized the glTexImage() path
|
---|
391 | * - removed the fxMesaTextureUsePalette() support
|
---|
392 | * - fixed a bug in the points support (thanks to David Farrell
|
---|
393 | * for an example of the problem)
|
---|
394 | * - written the optimized path for glSubTexImage(),
|
---|
395 | * introduced a new function in the Mesa driver interface
|
---|
396 | * TexSubImage(...)
|
---|
397 | * - fixed a bug for glColorMask and glDepthMask
|
---|
398 | * - the wbuffer is not more used. The Voodoo driver uses
|
---|
399 | * a standard 16bit zbuffer in all cases. It is more consistent
|
---|
400 | * and now GLQuake and GLQuake2test work also with a GL_ZTRICK 0
|
---|
401 | * - the driver is now able to take advantage of the ClipMask[],
|
---|
402 | * ClipOrMask and ClipAndMask information (under Linux);
|
---|
403 | * - rewritten the setup_fx_units() function, now the texture
|
---|
404 | * mapping support is compliant to the OpenGL specs (GL_BLEND
|
---|
405 | * support is still missing). The LinuxGLQuake console correctly
|
---|
406 | * fade in/out and transparent water of GLQuake2test works fine
|
---|
407 | * - written the support for the env. var. FX_GLIDE_SWAPINTERVAL
|
---|
408 | * - found a bug in the Mesa core. There is a roundup problem for
|
---|
409 | * color values out of the [0.0,1.0] range
|
---|
410 | *
|
---|
411 | * Wonko <matt@khm.de>
|
---|
412 | * - fixed a Voodoo Rush related problem in the fxwgl.c
|
---|
413 | *
|
---|
414 | * Daryll Strauss <daryll@harlot.rb.ca.us>
|
---|
415 | * - written the scissor test support
|
---|
416 | *
|
---|
417 | * V0.20 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
418 | * - written the closetmmanger() function in order to free all the memory
|
---|
419 | * allocated by the Texture Memory Manager (it will be useful
|
---|
420 | * when the support for multiple contexts/boards will be ready)
|
---|
421 | * - now the Voodoo driver runs without printing any information,
|
---|
422 | * define the env. var. MESA_FX_INFO if you want to read some
|
---|
423 | * information about the hardware and some statistic
|
---|
424 | * - written a small workaround for the "GLQuake multiplayer white box bug"
|
---|
425 | * in the setup_fx_units() funxtions. I'm already rewriting
|
---|
426 | * this function because it is the source of nearly all the current
|
---|
427 | * Voodoo driver problems
|
---|
428 | * - fixed the GLQuake texture misalignment problem (the texture
|
---|
429 | * coordinates must be scaled between 0.0 and 256.0 and not
|
---|
430 | * between 0.0 and 255.0)
|
---|
431 | * - written the support for the GL_EXT_shared_texture_palette
|
---|
432 | * - some small change for supporting the automatic building of the
|
---|
433 | * OpenGL32.dll under the Windows platform
|
---|
434 | * - the redefinition of a mipmap level is now a LOT faster. This path
|
---|
435 | * is used by GLQuake for dynamic lighting with some call to glTexSubImage2D()
|
---|
436 | * - the texture memory is now managed a set of 2MB blocks so
|
---|
437 | * texture maps can't be allocated on a 2MB boundary. The new Pure3D
|
---|
438 | * needs this kind of support (and probably any other Voodoo Graphics
|
---|
439 | * board with more than 2MB of texture memory)
|
---|
440 | *
|
---|
441 | * Brian Paul (brianp@elastic.avid.com) Avid Technology
|
---|
442 | * - added write_monocolor_span(), fixed bug in write_color_span()
|
---|
443 | * - added test for stenciling in choosepoint/line/triangle functions
|
---|
444 | *
|
---|
445 | * Joe Waters (falc@attila.aegistech.com) Aegis
|
---|
446 | * - written the support for the env. var. SST_SCREENREFRESH
|
---|
447 | *
|
---|
448 | * V0.19 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
449 | * - written the 3Dfx Global Palette extension for GLQuake
|
---|
450 | * - written the support for the GL_EXT_paletted_texture (it works only with GL_RGBA
|
---|
451 | * palettes and the alpha value is ignored ... this is a limitation of the
|
---|
452 | * the current Glide version and Voodoo hardware)
|
---|
453 | * - fixed the amount of memory allocated for 8bit textures
|
---|
454 | * - merged the under construction v0.19 driver with the Mesa 2.5
|
---|
455 | * - finally written the support for deleting textures
|
---|
456 | * - introduced a new powerful texture memory manager: the texture memory
|
---|
457 | * is used as a cache of the set of all defined texture maps. You can
|
---|
458 | * now define several MB of texture maps also with a 2MB of texture memory
|
---|
459 | * (the texture memory manager will do automatically all the swap out/swap in
|
---|
460 | * work). The new texture memory manager has also
|
---|
461 | * solved a lot of other bugs/no specs compliance/problems
|
---|
462 | * related to the texture memory usage. The texture
|
---|
463 | * manager code is inside the new fxmesa3.c file
|
---|
464 | * - broken the fxmesa.c file in two files (fxmesa1.c and fxmesa2.c)
|
---|
465 | * and done some code cleanup
|
---|
466 | * - now is possible to redefine texture mipmap levels already defined
|
---|
467 | * - fixed a problem with the amount of texture memory allocated for textures
|
---|
468 | * with not all mipmap levels defined
|
---|
469 | * - fixed a small problem with single buffer rendering
|
---|
470 | *
|
---|
471 | * Brian Paul (brianp@elastic.avid.com) Avid Technology
|
---|
472 | * - read/write_color_span() now use front/back buffer correctly
|
---|
473 | * - create GLvisual with 5,6,5 bits per pixel, not 8,8,8
|
---|
474 | * - removed a few ^M characters from fxmesa2.c file
|
---|
475 | *
|
---|
476 | * V0.18 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
477 | * - the Mesa-2.4beta3 is finally using the driver quads support (the
|
---|
478 | * previous Mesa versions have never taken any advantage from the quads support !)
|
---|
479 | * - tested with the Glide 2.4 for Win
|
---|
480 | * - ported all asm code to Linux
|
---|
481 | * - ported the v0.18 to Linux (without asm code)
|
---|
482 | * - back to Linux !!!
|
---|
483 | * - optimized the SETUP macro (no more vertex snap for points and lines)
|
---|
484 | * - optimized the SETUP macro (added one argument)
|
---|
485 | * - the Mesa/Voodoo is now 20/30% for points, lines and small triangles !
|
---|
486 | * - performance improvement setting VBSIZE to 72
|
---|
487 | * - the GrVertex texture code is now written in asm
|
---|
488 | * - the GrVertex zbuffer code is now written in asm
|
---|
489 | * - the GrVertex wbuffer code is now written in asm
|
---|
490 | * - the GrVertex gouraud code is now written in asm
|
---|
491 | * - the GrVertex snap code is now written in asm
|
---|
492 | * - changed the 8bit compressed texture maps in 8bit palette texture maps
|
---|
493 | * support (it has the some advantage of compressed texture maps without the
|
---|
494 | * problem of a fixed NCC table for all mipmap levels)
|
---|
495 | * - written the support for 8bit compressed texture maps (but texture maps with
|
---|
496 | * more than one mipmap level aren't working fine)
|
---|
497 | * - finnaly everthing is working fine in MesaQuake !
|
---|
498 | * - fixed a bug in the computation of texture mapping coordinates (I have found
|
---|
499 | * the bug thanks to MesaQuake !)
|
---|
500 | * - written the GL_REPLACE support (mainly for MesaQuake)
|
---|
501 | * - written the support for textures with not all mipmap levels defined
|
---|
502 | * - rewritten all the Texture memory stuff
|
---|
503 | * - written the MesaQuake support (define MESAQUAKE)
|
---|
504 | * - working with a ZBuffer if glOrtho or not int the default glDepthRange,
|
---|
505 | * otherwise working with the WBuffer
|
---|
506 | * written the glDepthRange support
|
---|
507 | *
|
---|
508 | * Diego Picciani (d.picciani@novacomp.it) Nova Computer s.r.l.
|
---|
509 | * - written the fxCloseHardware() and the fxQuaryHardware() (mainly
|
---|
510 | * for the VoodooWGL emulator)
|
---|
511 | *
|
---|
512 | * Brian Paul (brianp@elastic.avid.com) Avid Technology
|
---|
513 | * - implemented read/write_color_span() so glRead/DrawPixels() works
|
---|
514 | * - now needs Glide 2.3 or later. Removed GLIDE_FULL_SCREEN and call to grSstOpen()
|
---|
515 | *
|
---|
516 | * V0.17 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
517 | * - optimized the bitmap support (66% faster)
|
---|
518 | * - tested with the Mesa 2.3beta2
|
---|
519 | *
|
---|
520 | * Diego Picciani (d.picciani@novacomp.it) Nova Computer s.r.l.
|
---|
521 | * - solved a problem with the drawbitmap() and the Voodoo Rush
|
---|
522 | * (GR_ORIGIN_LOWER_LEFT did not work with the Stingray)
|
---|
523 | *
|
---|
524 | * Brian Paul (brianp@elastic.avid.com) Avid Technology
|
---|
525 | * - linux stuff
|
---|
526 | * - general code clean-up
|
---|
527 | * - added attribList parameter to fxMesaCreateContext()
|
---|
528 | * - single buffering works now
|
---|
529 | * - VB colors are now GLubytes, removed ColorShift stuff
|
---|
530 | *
|
---|
531 | * Paul Metzger
|
---|
532 | * - linux stuff
|
---|
533 | *
|
---|
534 | * V0.16 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
535 | * - written the quadfunc support (no performance improvement)
|
---|
536 | * - written the support for the new Mesa 2.3beta1 driver interface (Wow ! It is faaaster)
|
---|
537 | * - rewritten the glBitmap support for the Glide 2.3 (~35% slower !)
|
---|
538 | * - written the glBitmap support for the most common case (fonts)
|
---|
539 | *
|
---|
540 | * Jack Palevich
|
---|
541 | * - Glide 2.3 porting
|
---|
542 | *
|
---|
543 | * Diego Picciani (d.picciani@novacomp.it) Nova Computer s.r.l.
|
---|
544 | * - extended the fxMesaCreateContext() and fxMesaCreateBestContext()
|
---|
545 | * functions in order to support also the Voodoo Rush
|
---|
546 | * - tested with the Hercules Stingray 128/3D (The rendering in a window works !)
|
---|
547 | *
|
---|
548 | * V0.15 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
549 | * - written the GL_LUMINANCE_ALPHA support
|
---|
550 | * - written the GL_ALPHA support
|
---|
551 | * - written the GL_LUMINANCE support
|
---|
552 | * - now SETUP correctly set color for mono color sequences
|
---|
553 | * - written the 9x1,10x1,...,1x9,1x10,... texture map ratio support
|
---|
554 | * - written the no square texture map support
|
---|
555 | * - the fog table is no more rebuilt inside setup_fx_units() each time
|
---|
556 | *
|
---|
557 | * Henri Fousse (arnaud@pobox.oleane.com) Thomson Training & Simulation
|
---|
558 | * - written (not yet finished: no texture mapping) support for glOrtho
|
---|
559 | * - some change to setup functions
|
---|
560 | * - the fog support is now fully compatible with the standard OpenGL
|
---|
561 | * - rewritten several parts of the driver in order to take
|
---|
562 | * advantage of meshes (40% faster !!!)
|
---|
563 | *
|
---|
564 | * V0.14 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
565 | * - now glAlphaFunc() works
|
---|
566 | * - now glDepthMask() works
|
---|
567 | * - solved a mipmap problem when using more than one texture
|
---|
568 | * - moved ti, texid and wscale inside the fxMesaContext (now we can
|
---|
569 | * easy support more ctx and more boards)
|
---|
570 | * - the management of the fxMesaContext was completly broken !
|
---|
571 | * - solved several problems about Alpha and texture Alpha
|
---|
572 | * - 4 (RGBA) texture channels supported
|
---|
573 | * - setting the default color to white
|
---|
574 | *
|
---|
575 | * Henri Fousse (arnaud@pobox.oleane.com) Thomson Training & Simulation
|
---|
576 | * - small change to fxMesaCreateContext() and fxMesaMakeCurrent()
|
---|
577 | * - written the fog support
|
---|
578 | * - setting the default clear color to black
|
---|
579 | * - written cleangraphics() for the onexit() function
|
---|
580 | * - written fxMesaCreateBestContext()
|
---|
581 | *
|
---|
582 | * V0.13 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
583 | * - now glBlendFunc() works for all glBlendFunc without DST_ALPHA
|
---|
584 | * (because the alpha buffer is not yet implemented)
|
---|
585 | * - now fxMesaCreateContext() accept resolution and refresh rate
|
---|
586 | * - fixed a bug for texture mapping: the w (alias z) must be set
|
---|
587 | * also without depth buffer
|
---|
588 | * - fixed a bug for texture image with width!=256
|
---|
589 | * - written texparam()
|
---|
590 | * - written all point, line and triangle functions for all possible supported
|
---|
591 | * contexts and the driver is slight faster with points, lines and small triangles
|
---|
592 | * - fixed a small bug in fx/fxmesa.h (glOrtho)
|
---|
593 | *
|
---|
594 | * V0.12 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
595 | * - glDepthFunc supported
|
---|
596 | * - introduced a trick to discover the far plane distance
|
---|
597 | * (see fxMesaSetFar and fx/fxmesa.h)
|
---|
598 | * - now the wbuffer works with homogeneous coordinate (and it
|
---|
599 | * doesn't work with a glOrtho projection :)
|
---|
600 | * - solved several problems with homogeneous coordinate and texture mapping
|
---|
601 | * - fixed a bug in all line functions
|
---|
602 | * - fixed a clear framebuffer bug
|
---|
603 | * - solved a display list/teximg problem (but use
|
---|
604 | * glBindTexture: it is several times faster)
|
---|
605 | *
|
---|
606 | * V0.11 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
607 | * - introduced texture mapping support (not yet finished !)
|
---|
608 | * - tested with Mesa2.2b6
|
---|
609 | * - the driver is faster
|
---|
610 | * - written glFlush/glFinish
|
---|
611 | * - the driver print a lot of info about the Glide lib
|
---|
612 | *
|
---|
613 | * v0.1 - David Bucciarelli (tech.hmw@plus.it) Humanware s.r.l.
|
---|
614 | * - Initial revision
|
---|
615 | *
|
---|
616 | */
|
---|
617 |
|
---|
618 |
|
---|
619 | #ifdef HAVE_CONFIG_H
|
---|
620 | #include "conf.h"
|
---|
621 | #endif
|
---|
622 |
|
---|
623 | #if defined(FX)
|
---|
624 | #include "fxdrv.h"
|
---|
625 |
|
---|
626 | fxMesaContext fxMesaCurrentCtx=NULL;
|
---|
627 |
|
---|
628 | /*
|
---|
629 | * Status of 3Dfx hardware initialization
|
---|
630 | */
|
---|
631 |
|
---|
632 | static int glbGlideInitialized=0;
|
---|
633 | static int glb3DfxPresent=0;
|
---|
634 | static int glbTotNumCtx=0;
|
---|
635 |
|
---|
636 | GrHwConfiguration glbHWConfig;
|
---|
637 | int glbCurrentBoard=0;
|
---|
638 |
|
---|
639 |
|
---|
640 | #if defined(__WIN32__)
|
---|
641 | //Called from detach process handler in initterm.cpp
|
---|
642 | int cleangraphics(void)
|
---|
643 | {
|
---|
644 | glbTotNumCtx=1;
|
---|
645 | fxMesaDestroyContext(fxMesaCurrentCtx);
|
---|
646 |
|
---|
647 | return 0;
|
---|
648 | }
|
---|
649 | #elif defined(__WIN32OS2__)
|
---|
650 | void cleangraphics(void)
|
---|
651 | {
|
---|
652 | glbTotNumCtx=1;
|
---|
653 | fxMesaDestroyContext(fxMesaCurrentCtx);
|
---|
654 | }
|
---|
655 | #elif defined(__linux__)
|
---|
656 | static void cleangraphics(void)
|
---|
657 | {
|
---|
658 | glbTotNumCtx=1;
|
---|
659 | fxMesaDestroyContext(fxMesaCurrentCtx);
|
---|
660 | }
|
---|
661 |
|
---|
662 | static void cleangraphics_handler(int s)
|
---|
663 | {
|
---|
664 | fprintf(stderr,"fxmesa: Received a not handled signal %d\n",s);
|
---|
665 |
|
---|
666 | cleangraphics();
|
---|
667 | /* ABORT(); */
|
---|
668 | EXIT(1);
|
---|
669 | }
|
---|
670 | #endif
|
---|
671 |
|
---|
672 |
|
---|
673 | /*
|
---|
674 | * Select the Voodoo board to use when creating
|
---|
675 | * a new context.
|
---|
676 | */
|
---|
677 | GLboolean GLAPIENTRY fxMesaSelectCurrentBoard(int n)
|
---|
678 | {
|
---|
679 | fxQueryHardware();
|
---|
680 |
|
---|
681 | if((n<0) || (n>=glbHWConfig.num_sst))
|
---|
682 | return GL_FALSE;
|
---|
683 |
|
---|
684 | glbCurrentBoard=n;
|
---|
685 |
|
---|
686 | return GL_TRUE;
|
---|
687 | }
|
---|
688 |
|
---|
689 |
|
---|
690 | fxMesaContext GLAPIENTRY fxMesaGetCurrentContext(void)
|
---|
691 | {
|
---|
692 | return fxMesaCurrentCtx;
|
---|
693 | }
|
---|
694 |
|
---|
695 |
|
---|
696 | void GLAPIENTRY fxMesaSetNearFar(GLfloat n, GLfloat f)
|
---|
697 | {
|
---|
698 | if(fxMesaCurrentCtx)
|
---|
699 | fxDDSetNearFar(fxMesaCurrentCtx->glCtx,n,f);
|
---|
700 | }
|
---|
701 |
|
---|
702 |
|
---|
703 | /*
|
---|
704 | * The 3Dfx Global Palette extension for GLQuake.
|
---|
705 | * More a trick than a real extesion, use the shared global
|
---|
706 | * palette extension.
|
---|
707 | */
|
---|
708 | extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */
|
---|
709 | void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal)
|
---|
710 | {
|
---|
711 | fxMesaContext fxMesa =fxMesaCurrentCtx;
|
---|
712 |
|
---|
713 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
714 | int i;
|
---|
715 |
|
---|
716 | fprintf(stderr,"fxmesa: gl3DfxSetPaletteEXT()\n");
|
---|
717 |
|
---|
718 | for(i=0;i<256;i++)
|
---|
719 | fprintf(stderr,"%x\n",pal[i]);
|
---|
720 | }
|
---|
721 |
|
---|
722 | if(fxMesa) {
|
---|
723 | fxMesa->haveGlobalPaletteTexture=1;
|
---|
724 |
|
---|
725 | FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
|
---|
726 | if (fxMesa->haveTwoTMUs)
|
---|
727 | FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,(GuTexPalette *)pal);
|
---|
728 | }
|
---|
729 | }
|
---|
730 |
|
---|
731 |
|
---|
732 | static GrScreenResolution_t fxBestResolution(int width, int height, int aux)
|
---|
733 | {
|
---|
734 | static int resolutions[][5]={
|
---|
735 | { 512, 384, GR_RESOLUTION_512x384, 2, 2 },
|
---|
736 | { 640, 400, GR_RESOLUTION_640x400, 2, 2 },
|
---|
737 | { 640, 480, GR_RESOLUTION_640x480, 2, 2 },
|
---|
738 | { 800, 600, GR_RESOLUTION_800x600, 4, 2 },
|
---|
739 | { 960, 720, GR_RESOLUTION_960x720, 6, 4 }
|
---|
740 | #ifdef GR_RESOLUTION_1024x768
|
---|
741 | ,{ 1024, 768, GR_RESOLUTION_1024x768, 8, 4 }
|
---|
742 | #endif
|
---|
743 | #ifdef GR_RESOLUTION_1280x1024
|
---|
744 | ,{ 1024, 768, GR_RESOLUTION_1280x1024, 8, 8 }
|
---|
745 | #endif
|
---|
746 | #ifdef GR_RESOLUTION_1600x1200
|
---|
747 | ,{ 1024, 768, GR_RESOLUTION_1600x1200, 16, 8 }
|
---|
748 | #endif
|
---|
749 | };
|
---|
750 | int NUM_RESOLUTIONS = sizeof(resolutions) / (sizeof(int)*5);
|
---|
751 | int i,fbmem;
|
---|
752 | GrScreenResolution_t lastvalidres=resolutions[1][2];
|
---|
753 |
|
---|
754 | fxQueryHardware();
|
---|
755 |
|
---|
756 | if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
|
---|
757 | fbmem=glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam;
|
---|
758 |
|
---|
759 | if(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect)
|
---|
760 | fbmem*=2;
|
---|
761 | } else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
|
---|
762 | fbmem=glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam;
|
---|
763 | else
|
---|
764 | fbmem=2;
|
---|
765 |
|
---|
766 | /* A work around for BZFlag */
|
---|
767 |
|
---|
768 | if((width==1) && (height==1)) {
|
---|
769 | width=640;
|
---|
770 | height=480;
|
---|
771 | }
|
---|
772 |
|
---|
773 | for(i=0;i<NUM_RESOLUTIONS;i++)
|
---|
774 | if(resolutions[i][4-aux]<=fbmem) {
|
---|
775 | if((width<=resolutions[i][0]) && (height<=resolutions[i][1]))
|
---|
776 | return resolutions[i][2];
|
---|
777 |
|
---|
778 | lastvalidres=resolutions[i][2];
|
---|
779 | }
|
---|
780 |
|
---|
781 | return lastvalidres;
|
---|
782 | }
|
---|
783 |
|
---|
784 |
|
---|
785 | fxMesaContext GLAPIENTRY fxMesaCreateBestContext(GLuint win,GLint width, GLint height,
|
---|
786 | const GLint attribList[])
|
---|
787 | {
|
---|
788 | GrScreenRefresh_t refresh;
|
---|
789 | int i;
|
---|
790 | int res,aux;
|
---|
791 | refresh=GR_REFRESH_75Hz;
|
---|
792 |
|
---|
793 | if(getenv("SST_SCREENREFRESH")) {
|
---|
794 | if(!strcmp(getenv("SST_SCREENREFRESH"),"60"))
|
---|
795 | refresh=GR_REFRESH_60Hz;
|
---|
796 | if(!strcmp(getenv("SST_SCREENREFRESH"),"70"))
|
---|
797 | refresh=GR_REFRESH_70Hz;
|
---|
798 | if(!strcmp(getenv("SST_SCREENREFRESH"),"72"))
|
---|
799 | refresh=GR_REFRESH_72Hz;
|
---|
800 | if(!strcmp(getenv("SST_SCREENREFRESH"),"75"))
|
---|
801 | refresh=GR_REFRESH_75Hz;
|
---|
802 | if(!strcmp(getenv("SST_SCREENREFRESH"),"80"))
|
---|
803 | refresh=GR_REFRESH_80Hz;
|
---|
804 | if(!strcmp(getenv("SST_SCREENREFRESH"),"85"))
|
---|
805 | refresh=GR_REFRESH_85Hz;
|
---|
806 | if(!strcmp(getenv("SST_SCREENREFRESH"),"90"))
|
---|
807 | refresh=GR_REFRESH_90Hz;
|
---|
808 | if(!strcmp(getenv("SST_SCREENREFRESH"),"100"))
|
---|
809 | refresh=GR_REFRESH_100Hz;
|
---|
810 | if(!strcmp(getenv("SST_SCREENREFRESH"),"120"))
|
---|
811 | refresh=GR_REFRESH_120Hz;
|
---|
812 | }
|
---|
813 |
|
---|
814 | aux=0;
|
---|
815 | for(i=0;attribList[i]!=FXMESA_NONE;i++)
|
---|
816 | if((attribList[i]==FXMESA_ALPHA_SIZE) ||
|
---|
817 | (attribList[i]==FXMESA_DEPTH_SIZE)) {
|
---|
818 | if(attribList[++i]>0) {
|
---|
819 | aux=1;
|
---|
820 | break;
|
---|
821 | }
|
---|
822 | }
|
---|
823 |
|
---|
824 | res=fxBestResolution(width,height,aux);
|
---|
825 |
|
---|
826 | return fxMesaCreateContext(win,res,refresh,attribList);
|
---|
827 | }
|
---|
828 |
|
---|
829 |
|
---|
830 | #if 0
|
---|
831 | void fxsignals()
|
---|
832 | {
|
---|
833 | signal(SIGINT,SIG_IGN);
|
---|
834 | signal(SIGHUP,SIG_IGN);
|
---|
835 | signal(SIGPIPE,SIG_IGN);
|
---|
836 | signal(SIGFPE,SIG_IGN);
|
---|
837 | signal(SIGBUS,SIG_IGN);
|
---|
838 | signal(SIGILL,SIG_IGN);
|
---|
839 | signal(SIGSEGV,SIG_IGN);
|
---|
840 | signal(SIGTERM,SIG_IGN);
|
---|
841 | }
|
---|
842 | #endif
|
---|
843 |
|
---|
844 | /*
|
---|
845 | * Create a new FX/Mesa context and return a handle to it.
|
---|
846 | */
|
---|
847 | fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
|
---|
848 | GrScreenResolution_t res,
|
---|
849 | GrScreenRefresh_t ref,
|
---|
850 | const GLint attribList[])
|
---|
851 | {
|
---|
852 | fxMesaContext fxMesa = NULL;
|
---|
853 | int i,type;
|
---|
854 | int aux;
|
---|
855 | GLboolean doubleBuffer=GL_FALSE;
|
---|
856 | GLboolean alphaBuffer=GL_FALSE;
|
---|
857 | GLboolean verbose=GL_FALSE;
|
---|
858 | GLint depthSize=0;
|
---|
859 | GLint stencilSize=0;
|
---|
860 | GLint accumSize=0;
|
---|
861 | GLcontext *shareCtx = NULL;
|
---|
862 | GLcontext *ctx = 0;
|
---|
863 | /*FX_GrContext_t glideContext = 0;*/
|
---|
864 | char *errorstr;
|
---|
865 |
|
---|
866 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
867 | fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n");
|
---|
868 | }
|
---|
869 |
|
---|
870 | if(getenv("MESA_FX_INFO"))
|
---|
871 | verbose=GL_TRUE;
|
---|
872 |
|
---|
873 | aux=0;
|
---|
874 | i=0;
|
---|
875 | while(attribList[i]!=FXMESA_NONE) {
|
---|
876 | switch (attribList[i]) {
|
---|
877 | case FXMESA_DOUBLEBUFFER:
|
---|
878 | doubleBuffer=GL_TRUE;
|
---|
879 | break;
|
---|
880 | case FXMESA_ALPHA_SIZE:
|
---|
881 | i++;
|
---|
882 | alphaBuffer=attribList[i]>0;
|
---|
883 | if(alphaBuffer)
|
---|
884 | aux=1;
|
---|
885 | break;
|
---|
886 | case FXMESA_DEPTH_SIZE:
|
---|
887 | i++;
|
---|
888 | depthSize=attribList[i];
|
---|
889 | if(depthSize) {
|
---|
890 | aux=1;
|
---|
891 | depthSize = 16;
|
---|
892 | }
|
---|
893 | break;
|
---|
894 | case FXMESA_STENCIL_SIZE:
|
---|
895 | i++;
|
---|
896 | stencilSize=attribList[i];
|
---|
897 | break;
|
---|
898 | case FXMESA_ACCUM_SIZE:
|
---|
899 | i++;
|
---|
900 | accumSize=attribList[i];
|
---|
901 | break;
|
---|
902 | /* XXX ugly hack here for sharing display lists */
|
---|
903 | #define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with xmesa1.c! */
|
---|
904 | case FXMESA_SHARE_CONTEXT:
|
---|
905 | i++;
|
---|
906 | {
|
---|
907 | const void *vPtr = &attribList[i];
|
---|
908 | GLcontext **ctx = (GLcontext **) vPtr;
|
---|
909 | shareCtx = *ctx;
|
---|
910 | }
|
---|
911 | break;
|
---|
912 | default:
|
---|
913 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
914 | fprintf(stderr,"fxmesa: fxMesaCreateContext() End (defualt)\n");
|
---|
915 | }
|
---|
916 | return NULL;
|
---|
917 | }
|
---|
918 | i++;
|
---|
919 | }
|
---|
920 |
|
---|
921 | /* A workaround for Linux GLQuake */
|
---|
922 | if(depthSize && alphaBuffer)
|
---|
923 | alphaBuffer=0;
|
---|
924 |
|
---|
925 | if(verbose)
|
---|
926 | fprintf(stderr,"Mesa fx Voodoo Device Driver v0.30\nWritten by David Bucciarelli (davibu@tin.it.it)\n");
|
---|
927 |
|
---|
928 | if((type=fxQueryHardware()) < 0) {
|
---|
929 | fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n");
|
---|
930 | return NULL;
|
---|
931 | }
|
---|
932 |
|
---|
933 | if(type==GR_SSTTYPE_VOODOO)
|
---|
934 | win=0;
|
---|
935 |
|
---|
936 | grSstSelect(glbCurrentBoard);
|
---|
937 |
|
---|
938 | fxMesa=(fxMesaContext)calloc(1,sizeof(struct tfxMesaContext));
|
---|
939 | if(!fxMesa) {
|
---|
940 | errorstr = "malloc";
|
---|
941 | goto errorhandler;
|
---|
942 | }
|
---|
943 |
|
---|
944 | if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO)
|
---|
945 | fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx > 1);
|
---|
946 | else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96)
|
---|
947 | fxMesa->haveTwoTMUs=(glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx > 1);
|
---|
948 | else
|
---|
949 | fxMesa->haveTwoTMUs=GL_FALSE;
|
---|
950 |
|
---|
951 | fxMesa->haveDoubleBuffer=doubleBuffer;
|
---|
952 | fxMesa->haveAlphaBuffer=alphaBuffer;
|
---|
953 | fxMesa->haveGlobalPaletteTexture=GL_FALSE;
|
---|
954 | fxMesa->haveZBuffer=depthSize ? 1 : 0;
|
---|
955 | fxMesa->verbose=verbose;
|
---|
956 | fxMesa->board=glbCurrentBoard;
|
---|
957 |
|
---|
958 |
|
---|
959 | fxMesa->glideContext = FX_grSstWinOpen((FxU32)win,res,ref,
|
---|
960 | #if FXMESA_USE_ARGB
|
---|
961 | GR_COLORFORMAT_ARGB,
|
---|
962 | #else
|
---|
963 | GR_COLORFORMAT_ABGR,
|
---|
964 | #endif
|
---|
965 | GR_ORIGIN_LOWER_LEFT,
|
---|
966 | 2,aux);
|
---|
967 | if (!fxMesa->glideContext){
|
---|
968 | errorstr = "grSstWinOpen";
|
---|
969 | goto errorhandler;
|
---|
970 | }
|
---|
971 |
|
---|
972 | /* Pixel tables are use during pixel read-back */
|
---|
973 | #if FXMESA_USE_ARGB
|
---|
974 | fxInitPixelTables(fxMesa, GL_FALSE); /* Force RGB pixel order */
|
---|
975 | #else
|
---|
976 | if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) {
|
---|
977 | /* jk991130 - GROSS HACK!!! - Voodoo 3s don't use BGR!!
|
---|
978 | * the only way to tell if it's a Voodoo 3 at this stage of the
|
---|
979 | * ballgame (no Glide 3.x for linux *yet*) is to query the # of TMUs
|
---|
980 | * as Voodoo3s have 2 TMUs on board, Banshee has only 1
|
---|
981 | * Thanks to Joseph Kain for that one
|
---|
982 | */
|
---|
983 | GrVoodooConfig_t *voodoo;
|
---|
984 | voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
|
---|
985 |
|
---|
986 | if (voodoo->nTexelfx == 2 && voodoo->fbiRev != 260) {
|
---|
987 | /* RGB pixel order (Voodoo3, but some Quantum3D models) */
|
---|
988 | fxInitPixelTables(fxMesa, GL_FALSE);
|
---|
989 | }
|
---|
990 | else {
|
---|
991 | /* BGR pixel order on Voodoo1/2, or certain Quantum3D models */
|
---|
992 | fxInitPixelTables(fxMesa, GL_TRUE);
|
---|
993 | }
|
---|
994 | }
|
---|
995 | else {
|
---|
996 | fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order otherwise */
|
---|
997 | }
|
---|
998 | #endif
|
---|
999 |
|
---|
1000 | fxMesa->width=FX_grSstScreenWidth();
|
---|
1001 | fxMesa->height=FX_grSstScreenHeight();
|
---|
1002 |
|
---|
1003 | fxMesa->clipMinX = 0;
|
---|
1004 | fxMesa->clipMaxX = fxMesa->width;
|
---|
1005 | fxMesa->clipMinY = 0;
|
---|
1006 | fxMesa->clipMaxY = fxMesa->height;
|
---|
1007 |
|
---|
1008 | fxMesa->screen_width = fxMesa->width;
|
---|
1009 | fxMesa->screen_height = fxMesa->height;
|
---|
1010 | fxMesa->x_offset = 0;
|
---|
1011 | fxMesa->y_offset = 0;
|
---|
1012 | fxMesa->y_delta = 0;
|
---|
1013 |
|
---|
1014 | fxMesa->needClip = 0;
|
---|
1015 |
|
---|
1016 | if(verbose)
|
---|
1017 | fprintf(stderr,"Glide screen size: %dx%d\n",
|
---|
1018 | (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight());
|
---|
1019 |
|
---|
1020 | fxMesa->glVis=gl_create_visual(GL_TRUE, /* RGB mode */
|
---|
1021 | alphaBuffer,
|
---|
1022 | doubleBuffer,
|
---|
1023 | GL_FALSE, /* stereo */
|
---|
1024 | depthSize, /* depth_size */
|
---|
1025 | stencilSize, /* stencil_size */
|
---|
1026 | accumSize, /* accum_size */
|
---|
1027 | 0, /* index bits */
|
---|
1028 | 5,6,5,0); /* RGBA bits */
|
---|
1029 | if (!fxMesa->glVis) {
|
---|
1030 | errorstr = "gl_create_visual";
|
---|
1031 | goto errorhandler;
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 | ctx = fxMesa->glCtx=gl_create_context(fxMesa->glVis,
|
---|
1035 | shareCtx, /* share list context */
|
---|
1036 | (void *) fxMesa, GL_TRUE);
|
---|
1037 | if (!ctx) {
|
---|
1038 | errorstr = "gl_create_context";
|
---|
1039 | goto errorhandler;
|
---|
1040 | }
|
---|
1041 |
|
---|
1042 |
|
---|
1043 | if (!fxDDInitFxMesaContext( fxMesa )) {
|
---|
1044 | errorstr = "fxDDInitFxMesaContext failed";
|
---|
1045 | goto errorhandler;
|
---|
1046 | }
|
---|
1047 |
|
---|
1048 |
|
---|
1049 | fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis,
|
---|
1050 | GL_FALSE, /* no software depth */
|
---|
1051 | fxMesa->glVis->StencilBits > 0,
|
---|
1052 | fxMesa->glVis->AccumBits > 0,
|
---|
1053 | fxMesa->glVis->AlphaBits > 0 );
|
---|
1054 | if (!fxMesa->glBuffer) {
|
---|
1055 | errorstr = "gl_create_framebuffer";
|
---|
1056 | goto errorhandler;
|
---|
1057 | }
|
---|
1058 |
|
---|
1059 | glbTotNumCtx++;
|
---|
1060 |
|
---|
1061 | /* install signal handlers */
|
---|
1062 | #if defined(__linux__)
|
---|
1063 | /* Only install if environment var. is not set. */
|
---|
1064 | if (fxMesa->glCtx->CatchSignals && !getenv("MESA_FX_NO_SIGNALS")) {
|
---|
1065 | signal(SIGINT,cleangraphics_handler);
|
---|
1066 | signal(SIGHUP,cleangraphics_handler);
|
---|
1067 | signal(SIGPIPE,cleangraphics_handler);
|
---|
1068 | signal(SIGFPE,cleangraphics_handler);
|
---|
1069 | signal(SIGBUS,cleangraphics_handler);
|
---|
1070 | signal(SIGILL,cleangraphics_handler);
|
---|
1071 | signal(SIGSEGV,cleangraphics_handler);
|
---|
1072 | signal(SIGTERM,cleangraphics_handler);
|
---|
1073 | }
|
---|
1074 | #endif
|
---|
1075 |
|
---|
1076 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1077 | fprintf(stderr,"fxmesa: fxMesaCreateContext() End\n");
|
---|
1078 | }
|
---|
1079 |
|
---|
1080 | return fxMesa;
|
---|
1081 |
|
---|
1082 | errorhandler:
|
---|
1083 | if (fxMesa) {
|
---|
1084 | if (fxMesa->glideContext)
|
---|
1085 | FX_grSstWinClose(fxMesa->glideContext);
|
---|
1086 | fxMesa->glideContext = 0;
|
---|
1087 |
|
---|
1088 | if (fxMesa->state)
|
---|
1089 | free(fxMesa->state);
|
---|
1090 | if (fxMesa->fogTable)
|
---|
1091 | free(fxMesa->fogTable);
|
---|
1092 | if (fxMesa->glBuffer)
|
---|
1093 | gl_destroy_framebuffer(fxMesa->glBuffer);
|
---|
1094 | if (fxMesa->glVis)
|
---|
1095 | gl_destroy_visual(fxMesa->glVis);
|
---|
1096 | if (fxMesa->glCtx)
|
---|
1097 | gl_destroy_context(fxMesa->glCtx);
|
---|
1098 | free(fxMesa);
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1102 | fprintf(stderr,"fxmesa: fxMesaCreateContext() End (%s)\n",errorstr);
|
---|
1103 | }
|
---|
1104 | return NULL;
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 |
|
---|
1108 | /*
|
---|
1109 | * Function to set the new window size in the context (mainly for the Voodoo Rush)
|
---|
1110 | */
|
---|
1111 | void GLAPIENTRY fxMesaUpdateScreenSize(fxMesaContext fxMesa)
|
---|
1112 | {
|
---|
1113 | fxMesa->width=FX_grSstScreenWidth();
|
---|
1114 | fxMesa->height=FX_grSstScreenHeight();
|
---|
1115 | }
|
---|
1116 |
|
---|
1117 |
|
---|
1118 | /*
|
---|
1119 | * Destroy the given FX/Mesa context.
|
---|
1120 | */
|
---|
1121 | void GLAPIENTRY fxMesaDestroyContext(fxMesaContext fxMesa)
|
---|
1122 | {
|
---|
1123 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1124 | fprintf(stderr,"fxmesa: fxMesaDestroyContext()\n");
|
---|
1125 | }
|
---|
1126 |
|
---|
1127 | if(fxMesa) {
|
---|
1128 | gl_destroy_visual(fxMesa->glVis);
|
---|
1129 | gl_destroy_context(fxMesa->glCtx);
|
---|
1130 | gl_destroy_framebuffer(fxMesa->glBuffer);
|
---|
1131 |
|
---|
1132 | glbTotNumCtx--;
|
---|
1133 |
|
---|
1134 | fxCloseHardware();
|
---|
1135 | FX_grSstWinClose(fxMesa->glideContext);
|
---|
1136 |
|
---|
1137 | if(fxMesa->verbose) {
|
---|
1138 | fprintf(stderr,"Misc Stats:\n");
|
---|
1139 | fprintf(stderr," # swap buffer: %u\n",fxMesa->stats.swapBuffer);
|
---|
1140 |
|
---|
1141 | if(!fxMesa->stats.swapBuffer)
|
---|
1142 | fxMesa->stats.swapBuffer=1;
|
---|
1143 |
|
---|
1144 | fprintf(stderr,"Textures Stats:\n");
|
---|
1145 | fprintf(stderr," Free texture memory on TMU0: %d:\n",fxMesa->freeTexMem[FX_TMU0]);
|
---|
1146 | if(fxMesa->haveTwoTMUs)
|
---|
1147 | fprintf(stderr," Free texture memory on TMU1: %d:\n",fxMesa->freeTexMem[FX_TMU1]);
|
---|
1148 | fprintf(stderr," # request to TMM to upload a texture objects: %u\n",
|
---|
1149 | fxMesa->stats.reqTexUpload);
|
---|
1150 | fprintf(stderr," # request to TMM to upload a texture objects per swapbuffer: %.2f\n",
|
---|
1151 | fxMesa->stats.reqTexUpload/(float)fxMesa->stats.swapBuffer);
|
---|
1152 | fprintf(stderr," # texture objects uploaded: %u\n",
|
---|
1153 | fxMesa->stats.texUpload);
|
---|
1154 | fprintf(stderr," # texture objects uploaded per swapbuffer: %.2f\n",
|
---|
1155 | fxMesa->stats.texUpload/(float)fxMesa->stats.swapBuffer);
|
---|
1156 | fprintf(stderr," # MBs uploaded to texture memory: %.2f\n",
|
---|
1157 | fxMesa->stats.memTexUpload/(float)(1<<20));
|
---|
1158 | fprintf(stderr," # MBs uploaded to texture memory per swapbuffer: %.2f\n",
|
---|
1159 | (fxMesa->stats.memTexUpload/(float)fxMesa->stats.swapBuffer)/(float)(1<<20));
|
---|
1160 | }
|
---|
1161 | if (fxMesa->state)
|
---|
1162 | free(fxMesa->state);
|
---|
1163 | if (fxMesa->fogTable)
|
---|
1164 | free(fxMesa->fogTable);
|
---|
1165 | fxTMClose(fxMesa);
|
---|
1166 |
|
---|
1167 | free(fxMesa);
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | if(fxMesa==fxMesaCurrentCtx)
|
---|
1171 | fxMesaCurrentCtx=NULL;
|
---|
1172 | }
|
---|
1173 |
|
---|
1174 |
|
---|
1175 | /*
|
---|
1176 | * Make the specified FX/Mesa context the current one.
|
---|
1177 | */
|
---|
1178 | void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext fxMesa)
|
---|
1179 | {
|
---|
1180 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1181 | fprintf(stderr,"fxmesa: fxMesaMakeCurrent(...) Start\n");
|
---|
1182 | }
|
---|
1183 |
|
---|
1184 | if(!fxMesa) {
|
---|
1185 | gl_make_current(NULL,NULL);
|
---|
1186 | fxMesaCurrentCtx=NULL;
|
---|
1187 |
|
---|
1188 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1189 | fprintf(stderr,"fxmesa: fxMesaMakeCurrent(NULL) End\n");
|
---|
1190 | }
|
---|
1191 |
|
---|
1192 | return;
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | /* if this context is already the current one, we can return early */
|
---|
1196 | if (fxMesaCurrentCtx == fxMesa
|
---|
1197 | && fxMesaCurrentCtx->glCtx == gl_get_current_context()) {
|
---|
1198 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1199 | fprintf(stderr,"fxmesa: fxMesaMakeCurrent(fxMesaCurrentCtx==fxMesa) End\n");
|
---|
1200 | }
|
---|
1201 |
|
---|
1202 | return;
|
---|
1203 | }
|
---|
1204 |
|
---|
1205 | if(fxMesaCurrentCtx)
|
---|
1206 | grGlideGetState((GrState*)fxMesaCurrentCtx->state);
|
---|
1207 |
|
---|
1208 | fxMesaCurrentCtx=fxMesa;
|
---|
1209 |
|
---|
1210 | grSstSelect(fxMesa->board);
|
---|
1211 | grGlideSetState((GrState*)fxMesa->state);
|
---|
1212 |
|
---|
1213 | gl_make_current(fxMesa->glCtx,fxMesa->glBuffer);
|
---|
1214 |
|
---|
1215 | fxSetupDDPointers(fxMesa->glCtx);
|
---|
1216 |
|
---|
1217 | /* The first time we call MakeCurrent we set the initial viewport size */
|
---|
1218 | if(fxMesa->glCtx->Viewport.Width==0)
|
---|
1219 | gl_Viewport(fxMesa->glCtx,0,0,fxMesa->width,fxMesa->height);
|
---|
1220 |
|
---|
1221 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1222 | fprintf(stderr,"fxmesa: fxMesaMakeCurrent(...) End\n");
|
---|
1223 | }
|
---|
1224 | }
|
---|
1225 |
|
---|
1226 |
|
---|
1227 | /*
|
---|
1228 | * Swap front/back buffers for current context if double buffered.
|
---|
1229 | */
|
---|
1230 | void GLAPIENTRY fxMesaSwapBuffers(void)
|
---|
1231 | {
|
---|
1232 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1233 | fprintf(stderr,"fxmesa: ------------------------------- fxMesaSwapBuffers() -------------------------------\n");
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | if(fxMesaCurrentCtx) {
|
---|
1237 | FLUSH_VB( fxMesaCurrentCtx->glCtx, "swap buffers" );
|
---|
1238 |
|
---|
1239 | if(fxMesaCurrentCtx->haveDoubleBuffer) {
|
---|
1240 |
|
---|
1241 | grBufferSwap(fxMesaCurrentCtx->swapInterval);
|
---|
1242 |
|
---|
1243 | /*
|
---|
1244 | * Don't allow swap buffer commands to build up!
|
---|
1245 | */
|
---|
1246 | while(FX_grGetInteger(FX_PENDING_BUFFERSWAPS)>fxMesaCurrentCtx->maxPendingSwapBuffers)
|
---|
1247 | /* The driver is able to sleep when waiting for the completation
|
---|
1248 | of multiple swapbuffer operations instead of wasting
|
---|
1249 | CPU time (NOTE: you must uncomment the following line in the
|
---|
1250 | in order to enable this option) */
|
---|
1251 | /* usleep(10000); */
|
---|
1252 | ;
|
---|
1253 |
|
---|
1254 | fxMesaCurrentCtx->stats.swapBuffer++;
|
---|
1255 | }
|
---|
1256 | }
|
---|
1257 | }
|
---|
1258 |
|
---|
1259 |
|
---|
1260 | /*
|
---|
1261 | * Query 3Dfx hardware presence/kind
|
---|
1262 | */
|
---|
1263 | int GLAPIENTRY fxQueryHardware(void)
|
---|
1264 | {
|
---|
1265 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1266 | fprintf(stderr,"fxmesa: fxQueryHardware() Start\n");
|
---|
1267 | }
|
---|
1268 |
|
---|
1269 | if(!glbGlideInitialized) {
|
---|
1270 | grGlideInit();
|
---|
1271 | if(FX_grSstQueryHardware(&glbHWConfig)) {
|
---|
1272 | grSstSelect(glbCurrentBoard);
|
---|
1273 | glb3DfxPresent=1;
|
---|
1274 |
|
---|
1275 | if(getenv("MESA_FX_INFO")) {
|
---|
1276 | char buf[80];
|
---|
1277 |
|
---|
1278 | FX_grGlideGetVersion(buf);
|
---|
1279 | fprintf(stderr,"Using Glide V%s\n","");
|
---|
1280 | fprintf(stderr,"Number of boards: %d\n",glbHWConfig.num_sst);
|
---|
1281 |
|
---|
1282 | if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) {
|
---|
1283 | fprintf(stderr,"Framebuffer RAM: %d\n",
|
---|
1284 | glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect ?
|
---|
1285 | (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam*2) :
|
---|
1286 | glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam);
|
---|
1287 | fprintf(stderr,"Number of TMUs: %d\n",
|
---|
1288 | glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx);
|
---|
1289 | fprintf(stderr,"SLI detected: %d\n",
|
---|
1290 | glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect);
|
---|
1291 | } else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) {
|
---|
1292 | fprintf(stderr,"Framebuffer RAM: %d\n",
|
---|
1293 | glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam);
|
---|
1294 | fprintf(stderr,"Number of TMUs: %d\n",
|
---|
1295 | glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx);
|
---|
1296 | }
|
---|
1297 |
|
---|
1298 | }
|
---|
1299 | } else
|
---|
1300 | glb3DfxPresent=0;
|
---|
1301 |
|
---|
1302 | glbGlideInitialized=1;
|
---|
1303 |
|
---|
1304 | #if defined(__WIN32__)
|
---|
1305 | onexit((_onexit_t)cleangraphics);
|
---|
1306 | #elif defined(__linux__)
|
---|
1307 | /* Only register handler if environment variable is not defined. */
|
---|
1308 | if (!getenv("MESA_FX_NO_SIGNALS")) {
|
---|
1309 | atexit(cleangraphics);
|
---|
1310 | }
|
---|
1311 | #endif
|
---|
1312 | }
|
---|
1313 |
|
---|
1314 | if(!glb3DfxPresent) {
|
---|
1315 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1316 | fprintf(stderr,"fxmesa: fxQueryHardware() End (-1)\n");
|
---|
1317 | }
|
---|
1318 | return(-1);
|
---|
1319 | }
|
---|
1320 |
|
---|
1321 | if (MESA_VERBOSE&VERBOSE_DRIVER) {
|
---|
1322 | fprintf(stderr,"fxmesa: fxQueryHardware() End (voodooo)\n");
|
---|
1323 | }
|
---|
1324 | return(glbHWConfig.SSTs[glbCurrentBoard].type);
|
---|
1325 | }
|
---|
1326 |
|
---|
1327 |
|
---|
1328 | /*
|
---|
1329 | * Shutdown Glide library
|
---|
1330 | */
|
---|
1331 | void GLAPIENTRY fxCloseHardware(void)
|
---|
1332 | {
|
---|
1333 | if(glbGlideInitialized) {
|
---|
1334 | if(getenv("MESA_FX_INFO")) {
|
---|
1335 | GrSstPerfStats_t st;
|
---|
1336 |
|
---|
1337 | FX_grSstPerfStats(&st);
|
---|
1338 | fprintf(stderr,"Pixels Stats:\n");
|
---|
1339 | fprintf(stderr," # pixels processed (minus buffer clears): %u\n",(unsigned)st.pixelsIn);
|
---|
1340 | fprintf(stderr," # pixels not drawn due to chroma key test failure: %u\n",(unsigned)st.chromaFail);
|
---|
1341 | fprintf(stderr," # pixels not drawn due to depth test failure: %u\n",(unsigned)st.zFuncFail);
|
---|
1342 | fprintf(stderr," # pixels not drawn due to alpha test failure: %u\n",(unsigned)st.aFuncFail);
|
---|
1343 | fprintf(stderr," # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut);
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 | if(glbTotNumCtx==0) {
|
---|
1347 | grGlideShutdown();
|
---|
1348 | glbGlideInitialized=0;
|
---|
1349 | }
|
---|
1350 | }
|
---|
1351 | }
|
---|
1352 |
|
---|
1353 |
|
---|
1354 | #else
|
---|
1355 |
|
---|
1356 |
|
---|
1357 | /*
|
---|
1358 | * Need this to provide at least one external definition.
|
---|
1359 | */
|
---|
1360 |
|
---|
1361 | int gl_fx_dummy_function_api(void)
|
---|
1362 | {
|
---|
1363 | return 0;
|
---|
1364 | }
|
---|
1365 |
|
---|
1366 | #endif /* FX */
|
---|