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)
157 /* The glide 3 sources call for grEnable/grDisable to be called in exchange
158 * for grSstControl. */
160 case GR_CONTROL_ACTIVATE
:
161 grEnable(GR_PASSTHRU
);
163 case GR_CONTROL_DEACTIVATE
:
164 grDisable(GR_PASSTHRU
);
167 /* Appearently GR_CONTROL_RESIZE can be ignored. */
172 result
= grSstControl(code
);
179 #if defined(FX_GLIDE3)
181 void FX_grGammaCorrectionValue(float val
)
187 int FX_getFogTableSize(void)
191 grGet(GR_FOG_TABLE_ENTRIES
,sizeof(int),(void*)&result
);
196 int FX_getGrStateSize(void)
200 grGet(GR_GLIDE_STATE_SIZE
,sizeof(int),(void*)&result
);
207 int FX_grSstScreenWidth()
212 grGet(GR_VIEWPORT
,sizeof(FxI32
)*4,result
);
218 int FX_grSstScreenHeight()
223 grGet(GR_VIEWPORT
,sizeof(FxI32
)*4,result
);
229 void FX_grGlideGetVersion(char *buf
)
232 strcpy(buf
,grGetString(GR_VERSION
));
236 void FX_grSstPerfStats(GrSstPerfStats_t
*st
)
239 grGet(GR_STATS_PIXELS_IN
, 4, &n
); st
->pixelsIn
= n
;
240 grGet(GR_STATS_PIXELS_CHROMA_FAIL
, 4, &n
); st
->chromaFail
= n
;
241 grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL
, 4, &n
); st
->zFuncFail
= n
;
242 grGet(GR_STATS_PIXELS_AFUNC_FAIL
, 4, &n
); st
->aFuncFail
= n
;
243 grGet(GR_STATS_PIXELS_OUT
, 4, &n
); st
->pixelsOut
= n
;
246 void FX_grAADrawLine(GrVertex
*a
,GrVertex
*b
)
254 void FX_grAADrawPoint(GrVertex
*a
)
261 void FX_grDrawPolygonVertexList(int n
, GrVertex
*verts
)
264 grDrawVertexArrayContiguous(GR_POLYGON
, n
, verts
, sizeof(GrVertex
));
269 void FX_setupGrVertexLayout(void)
272 grReset(GR_VERTEX_PARAMETER
);
274 grCoordinateSpace(GR_WINDOW_COORDS
);
275 grVertexLayout(GR_PARAM_XY
, GR_VERTEX_X_OFFSET
<< 2, GR_PARAM_ENABLE
);
276 grVertexLayout(GR_PARAM_PARGB
, GR_VERTEX_PARGB_OFFSET
<< 2, GR_PARAM_ENABLE
);
277 grVertexLayout(GR_PARAM_Q
, GR_VERTEX_OOW_OFFSET
<< 2, GR_PARAM_ENABLE
);
278 grVertexLayout(GR_PARAM_Z
, GR_VERTEX_OOZ_OFFSET
<< 2, GR_PARAM_ENABLE
);
279 grVertexLayout(GR_PARAM_ST0
, GR_VERTEX_SOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
280 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
281 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
282 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
285 #else /* FX_USE_PARGB */
286 void FX_setupGrVertexLayout(void)
289 grReset(GR_VERTEX_PARAMETER
);
291 grCoordinateSpace(GR_WINDOW_COORDS
);
292 grVertexLayout(GR_PARAM_XY
, GR_VERTEX_X_OFFSET
<< 2, GR_PARAM_ENABLE
);
293 grVertexLayout(GR_PARAM_RGB
, GR_VERTEX_R_OFFSET
<< 2, GR_PARAM_ENABLE
);
294 grVertexLayout(GR_PARAM_A
, GR_VERTEX_A_OFFSET
<< 2, GR_PARAM_ENABLE
);
295 grVertexLayout(GR_PARAM_Q
, GR_VERTEX_OOW_OFFSET
<< 2, GR_PARAM_ENABLE
);
296 grVertexLayout(GR_PARAM_Z
, GR_VERTEX_OOZ_OFFSET
<< 2, GR_PARAM_ENABLE
);
297 grVertexLayout(GR_PARAM_ST0
, GR_VERTEX_SOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
298 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
299 grVertexLayout(GR_PARAM_ST1
, GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
300 grVertexLayout(GR_PARAM_Q1
, GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
305 void FX_grHints_NoLock(GrHint_t hintType
, FxU32 hintMask
)
308 case GR_HINT_STWHINT
:
310 if (hintMask
& GR_STWHINT_W_DIFF_TMU0
)
311 grVertexLayout(GR_PARAM_Q0
, GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_ENABLE
);
313 grVertexLayout(GR_PARAM_Q0
,GR_VERTEX_OOW_TMU0_OFFSET
<< 2, GR_PARAM_DISABLE
);
315 if (hintMask
& GR_STWHINT_ST_DIFF_TMU1
)
316 grVertexLayout(GR_PARAM_ST1
,GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_ENABLE
);
318 grVertexLayout(GR_PARAM_ST1
,GR_VERTEX_SOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
320 if (hintMask
& GR_STWHINT_W_DIFF_TMU1
)
321 grVertexLayout(GR_PARAM_Q1
,GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_ENABLE
);
323 grVertexLayout(GR_PARAM_Q1
,GR_VERTEX_OOW_TMU1_OFFSET
<< 2, GR_PARAM_DISABLE
);
329 void FX_grHints(GrHint_t hintType
, FxU32 hintMask
) {
331 FX_grHints_NoLock(hintType
, hintMask
);
335 int FX_grSstQueryHardware(GrHwConfiguration
*config
)
341 grGet(GR_NUM_BOARDS
,4,(void*)&(config
->num_sst
));
342 if (config
->num_sst
== 0)
344 for (i
= 0; i
< config
->num_sst
; i
++)
346 config
->SSTs
[i
].type
= GR_SSTTYPE_VOODOO
;
348 grGet(GR_MEMORY_FB
,4,(void*)&(config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbRam
));
349 config
->SSTs
[i
].sstBoard
.VoodooConfig
.fbRam
/= 1024*1024;
351 grGet(GR_NUM_TMU
,4,(void*)&(config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
));
354 grGet(GR_NUM_FB
,4,(void*)&numFB
);
356 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXTRUE
;
358 config
->SSTs
[i
].sstBoard
.VoodooConfig
.sliDetect
= FXFALSE
;
359 for (j
= 0; j
< config
->SSTs
[i
].sstBoard
.VoodooConfig
.nTexelfx
; j
++)
361 grGet(GR_MEMORY_TMU
,4,(void*)&(config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRam
));
362 config
->SSTs
[i
].sstBoard
.VoodooConfig
.tmuConfig
[j
].tmuRam
/= 1024*1024;
371 int FX_grSstScreenWidth()
375 i
= grSstScreenWidth();
380 int FX_grSstScreenHeight()
384 i
= grSstScreenHeight();
389 int FX_grSstQueryHardware(GrHwConfiguration
*c
)
393 i
= grSstQueryHardware(c
);
399 #endif /* FX_GLIDE3 */
401 /* It appears to me that this function is needed either way. */
402 FX_GrContext_t
FX_grSstWinOpen( FxU32 hWnd
,
403 GrScreenResolution_t screen_resolution
,
404 GrScreenRefresh_t refresh_rate
,
405 GrColorFormat_t color_format
,
406 GrOriginLocation_t origin_location
,
412 i
= grSstWinOpen( hWnd
,
422 "grSstWinOpen( win %d res %d ref %d fmt %d\n"
423 " org %d ncol %d naux %d )\n"
443 * Need this to provide at least one external definition.
446 int gl_fx_dummy_function_glidew(void)