3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
29 * Thank you for your contribution, David!
31 * Please make note of the above copyright/license statement. If you
32 * contributed code or bug fixes to this code under the previous (GNU
33 * Library) license and object to the new license, your code will be
34 * removed at your request. Please see the Mesa docs/COPYRIGHT file
35 * for more information.
37 * Additional Mesa/3Dfx driver developers:
38 * Daryll Strauss <daryll@precisioninsight.com>
39 * Keith Whitwell <keith@precisioninsight.com>
41 * See fxapi.h for more revision/author details.
58 FX_grGetInteger_NoLock(FxU32 pname
)
60 #if !defined(FX_GLIDE3)
62 case FX_FOG_TABLE_ENTRIES
:
63 return GR_FOG_TABLE_SIZE
;
64 case FX_GLIDE_STATE_SIZE
:
65 return sizeof(GrState
);
66 case FX_LFB_PIXEL_PIPE
:
68 case FX_PENDING_BUFFERSWAPS
:
69 return grBufferNumPending();
70 case FX_TEXTURE_ALIGN
:
71 /* This is a guess from reading the glide3 docs */
74 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
75 fprintf(stderr
, "Wrong parameter in FX_grGetInteger!\n");
84 case FX_FOG_TABLE_ENTRIES
:
85 case FX_GLIDE_STATE_SIZE
:
86 case FX_LFB_PIXEL_PIPE
:
87 case FX_PENDING_BUFFERSWAPS
:
88 case FX_TEXTURE_ALIGN
:
92 if (MESA_VERBOSE
& VERBOSE_DRIVER
) {
93 fprintf(stderr
, "Wrong parameter in FX_grGetInteger!\n");
98 grGet(grname
, 4, &result
);
104 FX_grGetInteger(FxU32 pname
)
109 result
= FX_grGetInteger_NoLock(pname
);
116 FX_grLfbLock(GrLock_t type
, GrBuffer_t buffer
,
117 GrLfbWriteMode_t writeMode
, GrOriginLocation_t origin
,
118 FxBool pixelPipeline
, GrLfbInfo_t
* info
)
123 result
= grLfbLock(type
, buffer
, writeMode
, origin
, pixelPipeline
, info
);
129 FX_grTexTextureMemRequired(FxU32 evenOdd
, GrTexInfo
* info
)
134 result
= grTexTextureMemRequired(evenOdd
, info
);
140 FX_grTexMinAddress(GrChipID_t tmu
)
145 result
= grTexMinAddress(tmu
);
151 FX_grTexMaxAddress(GrChipID_t tmu
)
156 result
= grTexMaxAddress(tmu
);
162 FX_grSstControl(FxU32 code
)
164 #if defined(FX_GLIDE3)
165 /* The glide 3 sources call for grEnable/grDisable to be called in exchange
166 * for grSstControl. */
168 case GR_CONTROL_ACTIVATE
:
169 grEnable(GR_PASSTHRU
);
171 case GR_CONTROL_DEACTIVATE
:
172 grDisable(GR_PASSTHRU
);
175 /* Appearently GR_CONTROL_RESIZE can be ignored. */
180 result
= grSstControl(code
);
187 #if defined(FX_GLIDE3)
190 FX_grGammaCorrectionValue(float val
)
197 FX_getFogTableSize(void)
201 grGet(GR_FOG_TABLE_ENTRIES
, sizeof(int), (void *) &result
);
207 FX_getGrStateSize(void)
211 grGet(GR_GLIDE_STATE_SIZE
, sizeof(int), (void *) &result
);
219 FX_grSstScreenWidth()
224 grGet(GR_VIEWPORT
, sizeof(FxI32
) * 4, result
);
231 FX_grSstScreenHeight()
236 grGet(GR_VIEWPORT
, sizeof(FxI32
) * 4, result
);
243 FX_grGlideGetVersion(char *buf
)
246 strcpy(buf
, grGetString(GR_VERSION
));
251 FX_grSstPerfStats(GrSstPerfStats_t
* st
)
254 grGet(GR_STATS_PIXELS_IN
, 4, &n
);
256 grGet(GR_STATS_PIXELS_CHROMA_FAIL
, 4, &n
);
258 grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL
, 4, &n
);
260 grGet(GR_STATS_PIXELS_AFUNC_FAIL
, 4, &n
);
262 grGet(GR_STATS_PIXELS_OUT
, 4, &n
);
267 FX_grAADrawLine(GrVertex
* a
, GrVertex
* b
)
276 FX_grAADrawPoint(GrVertex
* a
)
284 FX_grDrawPolygonVertexList(int n
, GrVertex
* verts
)
287 grDrawVertexArrayContiguous(GR_POLYGON
, n
, verts
, sizeof(GrVertex
));
292 FX_setupGrVertexLayout(void)
295 grReset(GR_VERTEX_PARAMETER
);
297 grCoordinateSpace(GR_WINDOW_COORDS
);
298 grVertexLayout(GR_PARAM_XY
, GR_VERTEX_X_OFFSET
<< 2, GR_PARAM_ENABLE
);
299 grVertexLayout(GR_PARAM_RGB
, GR_VERTEX_R_OFFSET
<< 2, GR_PARAM_ENABLE
);
300 grVertexLayout(GR_PARAM_A
, GR_VERTEX_A_OFFSET
<< 2, GR_PARAM_ENABLE
);
301 grVertexLayout(GR_PARAM_Q
, GR_VERTEX_OOW_OFFSET
<< 2, GR_PARAM_ENABLE
);
302 grVertexLayout(GR_PARAM_Z
, GR_VERTEX_OOZ_OFFSET
<< 2, GR_PARAM_ENABLE
);
303 grVertexLayout(GR_PARAM_ST0
, GR_VERTEX_SOW_TMU0_OFFSET
<< 2,
305 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2,
307 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2,
309 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2,
315 FX_grHints_NoLock(GrHint_t hintType
, FxU32 hintMask
)
318 case GR_HINT_STWHINT
:
320 if (hintMask
& GR_STWHINT_W_DIFF_TMU0
)
321 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2,
324 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2,
327 if (hintMask
& GR_STWHINT_ST_DIFF_TMU1
)
328 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2,
331 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2,
334 if (hintMask
& GR_STWHINT_W_DIFF_TMU1
)
335 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2,
338 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2,
346 FX_grHints(GrHint_t hintType
, FxU32 hintMask
)
349 FX_grHints_NoLock(hintType
, hintMask
);
354 * Glide3 doesn't have the grSstQueryHardware function anymore.
355 * Instead, we call grGet() and fill in the data structures ourselves.
358 FX_grSstQueryHardware(GrHwConfiguration
* config
)
365 grGet(GR_NUM_BOARDS
, 4, (void *) &(config
->num_sst
));
366 if (config
->num_sst
== 0)
369 for (i
= 0; i
< config
->num_sst
; i
++) {
372 config
->SSTs
[i
].type
= GR_SSTTYPE_VOODOO
;
375 grGet(GR_MEMORY_FB
, 4, &result
);
376 config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbRam
= result
/ (1024 * 1024);
378 grGet(GR_NUM_TMU
, 4, &result
);
379 config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
= result
;
381 grGet(GR_REVISION_FB
, 4, &result
);
382 config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbiRev
= result
;
384 grGet(GR_NUM_FB
, 4, (void *) &numFB
);
386 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXTRUE
;
388 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXFALSE
;
390 for (j
= 0; j
< config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
; j
++) {
391 grGet(GR_MEMORY_TMU
, 4, &result
);
392 config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRam
=
393 result
/ (1024 * 1024);
394 grGet(GR_REVISION_TMU
, 4, &result
);
395 config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRev
= result
;
405 FX_grSstScreenWidth()
409 i
= grSstScreenWidth();
415 FX_grSstScreenHeight()
419 i
= grSstScreenHeight();
425 FX_grSstQueryHardware(GrHwConfiguration
* c
)
429 i
= grSstQueryHardware(c
);
435 #endif /* FX_GLIDE3 */
437 /* It appears to me that this function is needed either way. */
439 FX_grSstWinOpen(FxU32 hWnd
,
440 GrScreenResolution_t screen_resolution
,
441 GrScreenRefresh_t refresh_rate
,
442 GrColorFormat_t color_format
,
443 GrOriginLocation_t origin_location
,
444 int nColBuffers
, int nAuxBuffers
)
448 i
= grSstWinOpen(hWnd
,
451 color_format
, origin_location
, nColBuffers
, nAuxBuffers
);
455 "grSstWinOpen( win %d res %d ref %d fmt %d\n"
456 " org %d ncol %d naux %d )\n"
476 * Need this to provide at least one external definition.
479 extern int gl_fx_dummy_function_glidew(void);
481 gl_fx_dummy_function_glidew(void)