source: trunk/src/opengl/mesa/3dfx/fxglidew.c

Last change on this file was 3598, checked in by jeroen, 25 years ago

* empty log message *

File size: 11.2 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
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#ifdef HAVE_CONFIG_H
47#include "conf.h"
48#endif
49
50#if defined(FX)
51#include "glide.h"
52#include "fxglidew.h"
53#include "fxdrv.h"
54
55#include <stdlib.h>
56#include <string.h>
57
58FxI32 FX_grGetInteger_NoLock(FxU32 pname)
59{
60#if !defined(FX_GLIDE3)
61 switch (pname)
62 {
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:
68 return FXFALSE;
69 case FX_PENDING_BUFFERSWAPS:
70 return grBufferNumPending();
71 case FX_TEXTURE_ALIGN:
72 /* This is a guess from reading the glide3 docs */
73 return 8;
74 default:
75 if (MESA_VERBOSE&VERBOSE_DRIVER) {
76 fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
77 }
78 return -1;
79 }
80#else
81 FxU32 grname;
82 FxI32 result;
83
84 switch (pname)
85 {
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:
91 grname = pname;
92 break;
93 default:
94 if (MESA_VERBOSE&VERBOSE_DRIVER) {
95 fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n");
96 }
97 return -1;
98 }
99
100 grGet(grname,4,&result);
101 return result;
102#endif
103}
104
105FxI32 FX_grGetInteger(FxU32 pname)
106{
107 int result;
108
109 BEGIN_BOARD_LOCK();
110 result=FX_grGetInteger_NoLock(pname);
111 END_BOARD_LOCK();
112 return result;
113}
114
115
116FxBool FX_grLfbLock(GrLock_t type, GrBuffer_t buffer,
117 GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
118 FxBool pixelPipeline, GrLfbInfo_t *info ) {
119 FxBool result;
120
121 BEGIN_BOARD_LOCK();
122 result=grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
123 END_BOARD_LOCK();
124 return result;
125}
126
127FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info) {
128 FxU32 result;
129
130 BEGIN_BOARD_LOCK();
131 result=grTexTextureMemRequired(evenOdd, info);
132 END_BOARD_LOCK();
133 return result;
134}
135
136FxU32 FX_grTexMinAddress(GrChipID_t tmu) {
137 FxU32 result;
138
139 BEGIN_BOARD_LOCK();
140 result=grTexMinAddress(tmu);
141 END_BOARD_LOCK();
142 return result;
143}
144
145extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) {
146 FxU32 result;
147
148 BEGIN_BOARD_LOCK();
149 result=grTexMaxAddress(tmu);
150 END_BOARD_LOCK();
151 return result;
152}
153
154FxBool FX_grSstControl(FxU32 code)
155{
156#if defined(FX_GLIDE3)
157 (void) code;
158 return 1; /* OK? */
159#else
160 FxU32 result;
161 BEGIN_BOARD_LOCK();
162 result = grSstControl(code);
163 END_BOARD_LOCK();
164 return result;
165#endif
166}
167
168
169#if defined(FX_GLIDE3)
170
171void FX_grGammaCorrectionValue(float val)
172{
173 (void)val;
174/* ToDo */
175}
176
177int FX_getFogTableSize(void)
178{
179 int result;
180 BEGIN_BOARD_LOCK();
181 grGet(GR_FOG_TABLE_ENTRIES,sizeof(int),(void*)&result);
182 END_BOARD_LOCK();
183 return result;
184}
185
186int FX_getGrStateSize(void)
187{
188 int result;
189 BEGIN_BOARD_LOCK();
190 grGet(GR_GLIDE_STATE_SIZE,sizeof(int),(void*)&result);
191 END_BOARD_LOCK();
192
193 return result;
194
195}
196
197int FX_grSstScreenWidth()
198{
199 FxI32 result[4];
200
201 BEGIN_BOARD_LOCK();
202 grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
203 END_BOARD_LOCK();
204
205 return result[2];
206}
207
208int FX_grSstScreenHeight()
209{
210 FxI32 result[4];
211
212 BEGIN_BOARD_LOCK();
213 grGet(GR_VIEWPORT,sizeof(FxI32)*4,result);
214 END_BOARD_LOCK();
215
216 return result[3];
217}
218
219void FX_grGlideGetVersion(char *buf)
220{
221 BEGIN_BOARD_LOCK();
222 strcpy(buf,grGetString(GR_VERSION));
223 END_BOARD_LOCK();
224}
225
226void FX_grSstPerfStats(GrSstPerfStats_t *st)
227{
228 int n;
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;
234}
235
236void FX_grAADrawLine(GrVertex *a,GrVertex *b)
237{
238 /* ToDo */
239 BEGIN_CLIP_LOOP();
240 grDrawLine(a,b);
241 END_CLIP_LOOP();
242}
243
244void FX_grAADrawPoint(GrVertex *a)
245{
246 BEGIN_CLIP_LOOP();
247 grDrawPoint(a);
248 END_CLIP_LOOP();
249}
250
251void FX_grDrawPolygonVertexList(int n, GrVertex *verts)
252{
253 BEGIN_CLIP_LOOP();
254 grDrawVertexArrayContiguous(GR_POLYGON, n, verts, sizeof(GrVertex));
255 END_CLIP_LOOP();
256}
257
258#if FX_USE_PARGB
259void FX_setupGrVertexLayout(void)
260{
261 BEGIN_BOARD_LOCK();
262 grReset(GR_VERTEX_PARAMETER);
263
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);
273 END_BOARD_LOCK();
274}
275#else /* FX_USE_PARGB */
276void FX_setupGrVertexLayout(void)
277{
278 BEGIN_BOARD_LOCK();
279 grReset(GR_VERTEX_PARAMETER);
280
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);
291 END_BOARD_LOCK();
292}
293#endif
294
295void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
296{
297 switch(hintType) {
298 case GR_HINT_STWHINT:
299 {
300 if (hintMask & GR_STWHINT_W_DIFF_TMU0)
301 grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_ENABLE);
302 else
303 grVertexLayout(GR_PARAM_Q0,GR_VERTEX_OOW_TMU0_OFFSET << 2, GR_PARAM_DISABLE);
304
305 if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
306 grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
307 else
308 grVertexLayout(GR_PARAM_ST1,GR_VERTEX_SOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
309
310 if (hintMask & GR_STWHINT_W_DIFF_TMU1)
311 grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_ENABLE);
312 else
313 grVertexLayout(GR_PARAM_Q1,GR_VERTEX_OOW_TMU1_OFFSET << 2, GR_PARAM_DISABLE);
314
315 }
316 }
317}
318
319void FX_grHints(GrHint_t hintType, FxU32 hintMask) {
320 BEGIN_BOARD_LOCK();
321 FX_grHints_NoLock(hintType, hintMask);
322 END_BOARD_LOCK();
323}
324
325int FX_grSstQueryHardware(GrHwConfiguration *config)
326{
327 int i,j;
328 int numFB;
329
330 BEGIN_BOARD_LOCK();
331 grGet(GR_NUM_BOARDS,4,(void*)&(config->num_sst));
332 if (config->num_sst == 0)
333 return 0;
334 for (i = 0; i< config->num_sst; i++)
335 {
336 config->SSTs[i].type = GR_SSTTYPE_VOODOO;
337 grSstSelect(i);
338 grGet(GR_MEMORY_FB,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.fbRam));
339 config->SSTs[i].sstBoard.VoodooConfig.fbRam/= 1024*1024;
340
341 grGet(GR_NUM_TMU,4,(void*)&(config->SSTs[i].sstBoard.VoodooConfig.nTexelfx));
342
343
344 grGet(GR_NUM_FB,4,(void*)&numFB);
345 if (numFB > 1)
346 config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXTRUE;
347 else
348 config->SSTs[i].sstBoard.VoodooConfig.sliDetect = FXFALSE;
349 for (j = 0; j < config->SSTs[i].sstBoard.VoodooConfig.nTexelfx; j++)
350 {
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;
353 }
354 }
355 END_BOARD_LOCK();
356 return 1;
357}
358
359#else
360
361int FX_grSstScreenWidth()
362{
363 int i;
364 BEGIN_BOARD_LOCK();
365 i = grSstScreenWidth();
366 END_BOARD_LOCK();
367 return i;
368}
369
370int FX_grSstScreenHeight()
371{
372 int i;
373 BEGIN_BOARD_LOCK();
374 i = grSstScreenHeight();
375 END_BOARD_LOCK();
376 return i;
377}
378
379int FX_grSstQueryHardware(GrHwConfiguration *c)
380{
381 int i;
382 BEGIN_BOARD_LOCK();
383 i = grSstQueryHardware(c);
384 END_BOARD_LOCK();
385 return i;
386}
387
388FX_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,
393 int nColBuffers,
394 int nAuxBuffers)
395{
396 FX_GrContext_t i;
397 BEGIN_BOARD_LOCK();
398 i = grSstWinOpen( hWnd,
399 screen_resolution,
400 refresh_rate,
401 color_format,
402 origin_location,
403 nColBuffers,
404 nAuxBuffers );
405
406#if 0
407 fprintf(stderr,
408 "grSstWinOpen( win %d res %d ref %d fmt %d\n"
409 " org %d ncol %d naux %d )\n"
410 " ==> %d\n",
411 hWnd,
412 screen_resolution,
413 refresh_rate,
414 color_format,
415 origin_location,
416 nColBuffers,
417 nAuxBuffers,
418 i);
419#endif
420 END_BOARD_LOCK();
421 return i;
422}
423
424
425
426#endif
427#else
428
429/*
430 * Need this to provide at least one external definition.
431 */
432
433int gl_fx_dummy_function_glidew(void)
434{
435 return 0;
436}
437
438#endif /* FX */
Note: See TracBrowser for help on using the repository browser.