1 /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
27 * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
30 * Thank you for your contribution, David!
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.
38 * Additional Mesa/3Dfx driver developers:
39 * Daryll Strauss <daryll@precisioninsight.com>
40 * Keith Whitwell <keith@precisioninsight.com>
42 * See fxapi.h for more revision/author details.
58 FxI32
FX_grGetInteger_NoLock(FxU32 pname
)
60 #if !defined(FX_GLIDE3)
63 case FX_FOG_TABLE_ENTRIES
:
64 return GR_FOG_TABLE_SIZE
;
65 case FX_GLIDE_STATE_SIZE
:
66 return sizeof(GrState
);
67 case FX_LFB_PIXEL_PIPE
:
69 case FX_PENDING_BUFFERSWAPS
:
70 return grBufferNumPending();
71 case FX_TEXTURE_ALIGN
:
72 /* This is a guess from reading the glide3 docs */
75 if (MESA_VERBOSE
&VERBOSE_DRIVER
) {
76 fprintf(stderr
,"Wrong parameter in FX_grGetInteger!\n");
86 case FX_FOG_TABLE_ENTRIES
:
87 case FX_GLIDE_STATE_SIZE
:
88 case FX_LFB_PIXEL_PIPE
:
89 case FX_PENDING_BUFFERSWAPS
:
90 case FX_TEXTURE_ALIGN
:
94 if (MESA_VERBOSE
&VERBOSE_DRIVER
) {
95 fprintf(stderr
,"Wrong parameter in FX_grGetInteger!\n");
100 grGet(grname
,4,&result
);
105 FxI32
FX_grGetInteger(FxU32 pname
)
110 result
=FX_grGetInteger_NoLock(pname
);
116 FxBool
FX_grLfbLock(GrLock_t type
, GrBuffer_t buffer
,
117 GrLfbWriteMode_t writeMode
, GrOriginLocation_t origin
,
118 FxBool pixelPipeline
, GrLfbInfo_t
*info
) {
122 result
=grLfbLock(type
, buffer
, writeMode
, origin
, pixelPipeline
, info
);
127 FxU32
FX_grTexTextureMemRequired(FxU32 evenOdd
, GrTexInfo
*info
) {
131 result
=grTexTextureMemRequired(evenOdd
, info
);
136 FxU32
FX_grTexMinAddress(GrChipID_t tmu
) {
140 result
=grTexMinAddress(tmu
);
145 extern FxU32
FX_grTexMaxAddress(GrChipID_t tmu
) {
149 result
=grTexMaxAddress(tmu
);
154 FxBool
FX_grSstControl(FxU32 code
)
156 #if defined(FX_GLIDE3)
162 result
= grSstControl(code
);
169 #if defined(FX_GLIDE3)
171 void FX_grGammaCorrectionValue(float val
)
177 int FX_getFogTableSize(void)
181 grGet(GR_FOG_TABLE_ENTRIES
,sizeof(int),(void*)&result
);
186 int FX_getGrStateSize(void)
190 grGet(GR_GLIDE_STATE_SIZE
,sizeof(int),(void*)&result
);
197 int FX_grSstScreenWidth()
202 grGet(GR_VIEWPORT
,sizeof(FxI32
)*4,result
);
208 int FX_grSstScreenHeight()
213 grGet(GR_VIEWPORT
,sizeof(FxI32
)*4,result
);
219 void FX_grGlideGetVersion(char *buf
)
222 strcpy(buf
,grGetString(GR_VERSION
));
226 void FX_grSstPerfStats(GrSstPerfStats_t
*st
)
229 grGet(GR_STATS_PIXELS_IN
, 4, &n
); st
->pixelsIn
= n
;
230 grGet(GR_STATS_PIXELS_CHROMA_FAIL
, 4, &n
); st
->chromaFail
= n
;
231 grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL
, 4, &n
); st
->zFuncFail
= n
;
232 grGet(GR_STATS_PIXELS_AFUNC_FAIL
, 4, &n
); st
->aFuncFail
= n
;
233 grGet(GR_STATS_PIXELS_OUT
, 4, &n
); st
->pixelsOut
= n
;
236 void FX_grAADrawLine(GrVertex
*a
,GrVertex
*b
)
244 void FX_grAADrawPoint(GrVertex
*a
)
251 void FX_grDrawPolygonVertexList(int n
, GrVertex
*verts
)
254 grDrawVertexArrayContiguous(GR_POLYGON
, n
, verts
, sizeof(GrVertex
));
259 void FX_setupGrVertexLayout(void)
262 grReset(GR_VERTEX_PARAMETER
);
264 grCoordinateSpace(GR_WINDOW_COORDS
);
265 grVertexLayout(GR_PARAM_XY
, GR_VERTEX_X_OFFSET
<< 2, GR_PARAM_ENABLE
);
266 grVertexLayout(GR_PARAM_PARGB
, GR_VERTEX_PARGB_OFFSET
<< 2, GR_PARAM_ENABLE
);
267 grVertexLayout(GR_PARAM_Q
, GR_VERTEX_OOW_OFFSET
<< 2, GR_PARAM_ENABLE
);
268 grVertexLayout(GR_PARAM_Z
, GR_VERTEX_OOZ_OFFSET
<< 2, GR_PARAM_ENABLE
);
269 grVertexLayout(GR_PARAM_ST0
, GR_VERTEX_SOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
270 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
271 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
272 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
275 #else /* FX_USE_PARGB */
276 void FX_setupGrVertexLayout(void)
279 grReset(GR_VERTEX_PARAMETER
);
281 grCoordinateSpace(GR_WINDOW_COORDS
);
282 grVertexLayout(GR_PARAM_XY
, GR_VERTEX_X_OFFSET
<< 2, GR_PARAM_ENABLE
);
283 grVertexLayout(GR_PARAM_RGB
, GR_VERTEX_R_OFFSET
<< 2, GR_PARAM_ENABLE
);
284 grVertexLayout(GR_PARAM_A
, GR_VERTEX_A_OFFSET
<< 2, GR_PARAM_ENABLE
);
285 grVertexLayout(GR_PARAM_Q
, GR_VERTEX_OOW_OFFSET
<< 2, GR_PARAM_ENABLE
);
286 grVertexLayout(GR_PARAM_Z
, GR_VERTEX_OOZ_OFFSET
<< 2, GR_PARAM_ENABLE
);
287 grVertexLayout(GR_PARAM_ST0
, GR_VERTEX_SOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
288 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
289 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
290 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
295 void FX_grHints_NoLock(GrHint_t hintType
, FxU32 hintMask
)
298 case GR_HINT_STWHINT
:
300 if (hintMask
& GR_STWHINT_W_DIFF_TMU0
)
301 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
303 grVertexLayout(GR_PARAM_Q0
,GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
305 if (hintMask
& GR_STWHINT_ST_DIFF_TMU1
)
306 grVertexLayout(GR_PARAM_ST1
,GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_ENABLE
);
308 grVertexLayout(GR_PARAM_ST1
,GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
310 if (hintMask
& GR_STWHINT_W_DIFF_TMU1
)
311 grVertexLayout(GR_PARAM_Q1
,GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_ENABLE
);
313 grVertexLayout(GR_PARAM_Q1
,GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
319 void FX_grHints(GrHint_t hintType
, FxU32 hintMask
) {
321 FX_grHints_NoLock(hintType
, hintMask
);
325 int FX_grSstQueryHardware(GrHwConfiguration
*config
)
331 grGet(GR_NUM_BOARDS
,4,(void*)&(config
->num_sst
));
332 if (config
->num_sst
== 0)
334 for (i
= 0; i
< config
->num_sst
; i
++)
336 config
->SSTs
[i
].type
= GR_SSTTYPE_VOODOO
;
338 grGet(GR_MEMORY_FB
,4,(void*)&(config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbRam
));
339 config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbRam
/= 1024*1024;
341 grGet(GR_NUM_TMU
,4,(void*)&(config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
));
344 grGet(GR_NUM_FB
,4,(void*)&numFB
);
346 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXTRUE
;
348 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXFALSE
;
349 for (j
= 0; j
< config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
; j
++)
351 grGet(GR_MEMORY_TMU
,4,(void*)&(config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRam
));
352 config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRam
/= 1024*1024;
361 int FX_grSstScreenWidth()
365 i
= grSstScreenWidth();
370 int FX_grSstScreenHeight()
374 i
= grSstScreenHeight();
379 int FX_grSstQueryHardware(GrHwConfiguration
*c
)
383 i
= grSstQueryHardware(c
);
388 FX_GrContext_t
FX_grSstWinOpen( FxU32 hWnd
,
389 GrScreenResolution_t screen_resolution
,
390 GrScreenRefresh_t refresh_rate
,
391 GrColorFormat_t color_format
,
392 GrOriginLocation_t origin_location
,
398 i
= grSstWinOpen( hWnd
,
408 "grSstWinOpen( win %d res %d ref %d fmt %d\n"
409 " org %d ncol %d naux %d )\n"
430 * Need this to provide at least one external definition.
433 int gl_fx_dummy_function_glidew(void)