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.
57 FxI32
FX_grGetInteger_NoLock(FxU32 pname
)
59 #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");
85 case FX_FOG_TABLE_ENTRIES
:
86 case FX_GLIDE_STATE_SIZE
:
87 case FX_LFB_PIXEL_PIPE
:
88 case FX_PENDING_BUFFERSWAPS
:
89 case FX_TEXTURE_ALIGN
:
93 if (MESA_VERBOSE
&VERBOSE_DRIVER
) {
94 fprintf(stderr
,"Wrong parameter in FX_grGetInteger!\n");
99 grGet(grname
,4,&result
);
104 FxI32
FX_grGetInteger(FxU32 pname
)
109 result
=FX_grGetInteger_NoLock(pname
);
115 FxBool
FX_grLfbLock(GrLock_t type
, GrBuffer_t buffer
,
116 GrLfbWriteMode_t writeMode
, GrOriginLocation_t origin
,
117 FxBool pixelPipeline
, GrLfbInfo_t
*info
) {
121 result
=grLfbLock(type
, buffer
, writeMode
, origin
, pixelPipeline
, info
);
126 FxU32
FX_grTexTextureMemRequired(FxU32 evenOdd
, GrTexInfo
*info
) {
130 result
=grTexTextureMemRequired(evenOdd
, info
);
135 FxU32
FX_grTexMinAddress(GrChipID_t tmu
) {
139 result
=grTexMinAddress(tmu
);
144 extern FxU32
FX_grTexMaxAddress(GrChipID_t tmu
) {
148 result
=grTexMaxAddress(tmu
);
153 FxBool
FX_grSstControl(FxU32 code
)
155 #if defined(FX_GLIDE3)
156 /* The glide 3 sources call for grEnable/grDisable to be called in exchange
157 * for grSstControl. */
159 case GR_CONTROL_ACTIVATE
:
160 grEnable(GR_PASSTHRU
);
162 case GR_CONTROL_DEACTIVATE
:
163 grDisable(GR_PASSTHRU
);
166 /* Appearently GR_CONTROL_RESIZE can be ignored. */
171 result
= grSstControl(code
);
178 #if defined(FX_GLIDE3)
180 void FX_grGammaCorrectionValue(float val
)
186 int FX_getFogTableSize(void)
190 grGet(GR_FOG_TABLE_ENTRIES
,sizeof(int),(void*)&result
);
195 int FX_getGrStateSize(void)
199 grGet(GR_GLIDE_STATE_SIZE
,sizeof(int),(void*)&result
);
206 int FX_grSstScreenWidth()
211 grGet(GR_VIEWPORT
,sizeof(FxI32
)*4,result
);
217 int FX_grSstScreenHeight()
222 grGet(GR_VIEWPORT
,sizeof(FxI32
)*4,result
);
228 void FX_grGlideGetVersion(char *buf
)
231 strcpy(buf
,grGetString(GR_VERSION
));
235 void FX_grSstPerfStats(GrSstPerfStats_t
*st
)
238 grGet(GR_STATS_PIXELS_IN
, 4, &n
); st
->pixelsIn
= n
;
239 grGet(GR_STATS_PIXELS_CHROMA_FAIL
, 4, &n
); st
->chromaFail
= n
;
240 grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL
, 4, &n
); st
->zFuncFail
= n
;
241 grGet(GR_STATS_PIXELS_AFUNC_FAIL
, 4, &n
); st
->aFuncFail
= n
;
242 grGet(GR_STATS_PIXELS_OUT
, 4, &n
); st
->pixelsOut
= n
;
245 void FX_grAADrawLine(GrVertex
*a
,GrVertex
*b
)
253 void FX_grAADrawPoint(GrVertex
*a
)
260 void FX_grDrawPolygonVertexList(int n
, GrVertex
*verts
)
263 grDrawVertexArrayContiguous(GR_POLYGON
, n
, verts
, sizeof(GrVertex
));
267 void FX_setupGrVertexLayout(void)
270 grReset(GR_VERTEX_PARAMETER
);
272 grCoordinateSpace(GR_WINDOW_COORDS
);
273 grVertexLayout(GR_PARAM_XY
, GR_VERTEX_X_OFFSET
<< 2, GR_PARAM_ENABLE
);
274 grVertexLayout(GR_PARAM_RGB
, GR_VERTEX_R_OFFSET
<< 2, GR_PARAM_ENABLE
);
275 grVertexLayout(GR_PARAM_A
, GR_VERTEX_A_OFFSET
<< 2, GR_PARAM_ENABLE
);
276 grVertexLayout(GR_PARAM_Q
, GR_VERTEX_OOW_OFFSET
<< 2, GR_PARAM_ENABLE
);
277 grVertexLayout(GR_PARAM_Z
, GR_VERTEX_OOZ_OFFSET
<< 2, GR_PARAM_ENABLE
);
278 grVertexLayout(GR_PARAM_ST0
, GR_VERTEX_SOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
279 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
280 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
281 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
285 void FX_grHints_NoLock(GrHint_t hintType
, FxU32 hintMask
)
288 case GR_HINT_STWHINT
:
290 if (hintMask
& GR_STWHINT_W_DIFF_TMU0
)
291 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
293 grVertexLayout(GR_PARAM_Q0
,GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
295 if (hintMask
& GR_STWHINT_ST_DIFF_TMU1
)
296 grVertexLayout(GR_PARAM_ST1
,GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_ENABLE
);
298 grVertexLayout(GR_PARAM_ST1
,GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
300 if (hintMask
& GR_STWHINT_W_DIFF_TMU1
)
301 grVertexLayout(GR_PARAM_Q1
,GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_ENABLE
);
303 grVertexLayout(GR_PARAM_Q1
,GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
309 void FX_grHints(GrHint_t hintType
, FxU32 hintMask
) {
311 FX_grHints_NoLock(hintType
, hintMask
);
316 * Glide3 doesn't have the grSstQueryHardware function anymore.
317 * Instead, we call grGet() and fill in the data structures ourselves.
319 int FX_grSstQueryHardware(GrHwConfiguration
*config
)
326 grGet(GR_NUM_BOARDS
, 4, (void*)&(config
->num_sst
));
327 if (config
->num_sst
== 0)
330 for (i
= 0; i
< config
->num_sst
; i
++) {
333 config
->SSTs
[i
].type
= GR_SSTTYPE_VOODOO
;
336 grGet(GR_MEMORY_FB
, 4, &result
);
337 config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbRam
= result
/ (1024 * 1024);
339 grGet(GR_NUM_TMU
, 4, &result
);
340 config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
= result
;
342 grGet(GR_REVISION_FB
, 4, &result
);
343 config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbiRev
= result
;
345 grGet(GR_NUM_FB
,4,(void*)&numFB
);
347 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXTRUE
;
349 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXFALSE
;
351 for (j
= 0; j
< config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
; j
++) {
352 grGet(GR_MEMORY_TMU
, 4, &result
);
353 config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRam
= result
/ (1024*1024);
354 grGet(GR_REVISION_TMU
, 4, &result
);
355 config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRev
= result
;
364 int FX_grSstScreenWidth()
368 i
= grSstScreenWidth();
373 int FX_grSstScreenHeight()
377 i
= grSstScreenHeight();
382 int FX_grSstQueryHardware(GrHwConfiguration
*c
)
386 i
= grSstQueryHardware(c
);
392 #endif /* FX_GLIDE3 */
394 /* It appears to me that this function is needed either way. */
395 FX_GrContext_t
FX_grSstWinOpen( FxU32 hWnd
,
396 GrScreenResolution_t screen_resolution
,
397 GrScreenRefresh_t refresh_rate
,
398 GrColorFormat_t color_format
,
399 GrOriginLocation_t origin_location
,
405 i
= grSstWinOpen( hWnd
,
415 "grSstWinOpen( win %d res %d ref %d fmt %d\n"
416 " org %d ncol %d naux %d )\n"
436 * Need this to provide at least one external definition.
439 extern int gl_fx_dummy_function_glidew(void);
440 int gl_fx_dummy_function_glidew(void)