Changeset 3598 for trunk/src/opengl/mesa/3dfx/fxdd.c
- Timestamp:
- May 23, 2000, 10:41:28 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/opengl/mesa/3dfx/fxdd.c
r2938 r3598 3 3 /* 4 4 * Mesa 3-D graphics library 5 * Version: 3. 15 * Version: 3.3 6 6 * 7 7 * Copyright (C) 1999 Brian Paul All Rights Reserved. … … 53 53 #if defined(FX) 54 54 55 #include "image.h" 55 56 #include "types.h" 56 57 #include "fxdrv.h" 57 58 #include "enums.h" 58 59 #include "extensions.h" 59 60 #include "pb.h" 60 61 61 62 /* These lookup table are used to extract RGB values in [0,255] from … … 71 72 * Input: bgrOrder - if TRUE, pixels are in BGR order, else RGB order. 72 73 */ 73 void fxInitPixelTables( GLboolean bgrOrder)74 void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder) 74 75 { 75 76 GLuint pixel; 77 78 fxMesa->bgrOrder=bgrOrder; 76 79 for (pixel = 0; pixel <= 0xffff; pixel++) { 77 80 GLuint r, g, b; … … 101 104 102 105 /* Enalbe/Disable dithering */ 103 void fxDDDither(GLcontext *ctx, GLboolean enable)106 static void fxDDDither(GLcontext *ctx, GLboolean enable) 104 107 { 105 108 if (MESA_VERBOSE&VERBOSE_DRIVER) { … … 116 119 117 120 /* Return buffer size information */ 118 void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height)121 static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height) 119 122 { 120 123 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; … … 140 143 GLubyte col[4]; 141 144 ASSIGN_4V( col, red, green, blue, alpha ); 142 145 143 146 if (MESA_VERBOSE&VERBOSE_DRIVER) { 144 147 fprintf(stderr,"fxmesa: fxDDSetColor(%d,%d,%d,%d)\n",red,green,blue,alpha); … … 163 166 fprintf(stderr,"fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",red,green,blue,alpha); 164 167 } 165 168 166 169 fxMesa->clearC=FXCOLOR4( col ); 167 170 fxMesa->clearA=alpha; … … 173 176 { 174 177 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 175 GLbitfield newmask; 178 const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); 179 const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff); 180 GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT); 176 181 177 182 if (MESA_VERBOSE&VERBOSE_DRIVER) { … … 179 184 } 180 185 181 switch(mask & (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)) { 182 case (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT): 183 /* clear color and depth buffer */ 184 185 if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) { 186 if (colorMask != 0xffffffff) { 187 /* do color buffer clears in software */ 188 softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)); 189 mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT); 190 } 191 192 /* 193 * This could probably be done fancier but doing each possible case 194 * explicitly is less error prone. 195 */ 196 switch (mask) { 197 case DD_BACK_LEFT_BIT | DD_DEPTH_BIT: 198 /* back buffer & depth */ 199 FX_grDepthMask(FXTRUE); 186 200 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); 187 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 188 (FxU16)(ctx->Depth.Clear*0xffff)); 189 } 190 if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) { 201 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 202 if (!ctx->Depth.Mask) { 203 FX_grDepthMask(FXFALSE); 204 } 205 break; 206 case DD_FRONT_LEFT_BIT | DD_DEPTH_BIT: 207 /* XXX it appears that the depth buffer isn't cleared when 208 * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set. 209 * This is a work-around/ 210 */ 211 /* clear depth */ 212 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); 213 FX_grColorMask(FXFALSE,FXFALSE); 214 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 215 /* clear front */ 216 FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 191 217 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 192 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 193 (FxU16)(ctx->Depth.Clear*0xffff)); 194 } 195 196 newmask=mask & (~(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT)); 197 break; 198 case (GL_COLOR_BUFFER_BIT): 199 /* clear color buffer */ 200 201 if(ctx->Color.ColorMask) { 218 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 219 break; 220 case DD_BACK_LEFT_BIT: 221 /* back buffer only */ 202 222 FX_grDepthMask(FXFALSE); 203 204 if (ctx->Color.DrawDestMask & BACK_LEFT_BIT) {205 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER);206 FX_gr BufferClear(fxMesa->clearC, fxMesa->clearA, 0);223 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); 224 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 225 if (!ctx->Depth.Mask) { 226 FX_grDepthMask(FXFALSE); 207 227 } 208 if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) { 209 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 210 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 0); 228 break; 229 case DD_FRONT_LEFT_BIT: 230 /* front buffer only */ 231 FX_grDepthMask(FXFALSE); 232 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 233 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 234 if (!ctx->Depth.Mask) { 235 FX_grDepthMask(FXFALSE); 211 236 } 212 213 if(ctx->Depth.Mask) { 214 FX_grDepthMask(FXTRUE); 237 break; 238 case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT: 239 /* front and back */ 240 FX_grDepthMask(FXFALSE); 241 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); 242 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 243 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 244 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 245 if (!ctx->Depth.Mask) { 246 FX_grDepthMask(FXFALSE); 215 247 } 216 } 217 218 newmask=mask & (~(GL_COLOR_BUFFER_BIT)); 219 break; 220 case (GL_DEPTH_BUFFER_BIT): 221 /* clear depth buffer */ 222 223 if(ctx->Depth.Mask) { 248 break; 249 case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT: 250 /* clear front */ 251 FX_grDepthMask(FXFALSE); 252 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 253 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 254 /* clear back and depth */ 255 FX_grDepthMask(FXTRUE); 256 FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); 257 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); 258 if (!ctx->Depth.Mask) { 259 FX_grDepthMask(FXFALSE); 260 } 261 break; 262 case DD_DEPTH_BIT: 263 /* just the depth buffer */ 224 264 FX_grColorMask(FXFALSE,FXFALSE); 225 265 FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, 226 (FxU16)(ctx->Depth.Clear*0xffff)); 227 228 FX_grColorMask(ctx->Color.ColorMask[RCOMP] || 229 ctx->Color.ColorMask[GCOMP] || 230 ctx->Color.ColorMask[BCOMP], 231 ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 232 } 233 234 newmask=mask & (~(GL_DEPTH_BUFFER_BIT)); 235 break; 236 default: 237 newmask=mask; 238 break; 239 } 240 241 return newmask; 242 } 243 244 245 /* Set the buffer used in double buffering */ 246 static GLboolean fxDDSetBuffer(GLcontext *ctx, GLenum mode ) 266 (FxU16)(ctx->Depth.Clear*0xffff)); 267 FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); 268 break; 269 default: 270 /* error */ 271 ; 272 } 273 274 return softwareMask; 275 } 276 277 278 /* Set the buffer used for reading */ 279 static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode ) 247 280 { 248 281 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; … … 267 300 } 268 301 302 /* Set the buffer used for reading */ 303 static void fxDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer, 304 GLenum mode ) 305 { 306 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 307 (void) buffer; 308 309 if (MESA_VERBOSE&VERBOSE_DRIVER) { 310 fprintf(stderr,"fxmesa: fxDDSetBuffer(%x)\n", (int) mode); 311 } 312 313 if (mode == GL_FRONT_LEFT) { 314 fxMesa->currentFB = GR_BUFFER_FRONTBUFFER; 315 FX_grRenderBuffer(fxMesa->currentFB); 316 } 317 else if (mode == GL_BACK_LEFT) { 318 fxMesa->currentFB = GR_BUFFER_BACKBUFFER; 319 FX_grRenderBuffer(fxMesa->currentFB); 320 } 321 } 322 323 269 324 270 325 #ifdef XF86DRI 326 /* test if window coord (px,py) is visible */ 271 327 static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py) 272 328 { 273 329 int i; 274 275 py=fxMesa->height+fxMesa->y_offset-py;276 330 for (i=0; i<fxMesa->numClipRects; i++) { 277 if ((px>=fxMesa->pClipRects[i].x1) && 278 279 (py>=fxMesa->pClipRects[i].y1) && 280 331 if ((px>=fxMesa->pClipRects[i].x1) && 332 (px<fxMesa->pClipRects[i].x2) && 333 (py>=fxMesa->pClipRects[i].y1) && 334 (py<fxMesa->pClipRects[i].y2)) return GL_TRUE; 281 335 } 282 336 return GL_FALSE; … … 291 345 { 292 346 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 293 FxU16 *p;294 347 GrLfbInfo_t info; 295 const GLubyte *pb;296 int x,y,xmin,xmax,ymin,ymax;297 GLint r,g,b,a,scrwidth,scrheight,stride;298 348 FxU16 color; 299 300 /* TODO: with a little work, these bitmap unpacking parameter restrictions 301 * could be removed. 302 */ 303 if((unpack->Alignment!=1) || 304 (unpack->RowLength!=0) || 305 (unpack->SkipPixels!=0) || 306 (unpack->SkipRows!=0) || 307 (unpack->SwapBytes) || 308 (unpack->LsbFirst)) 349 const struct gl_pixelstore_attrib *finalUnpack; 350 struct gl_pixelstore_attrib scissoredUnpack; 351 352 /* check if there's any raster operations enabled which we can't handle */ 353 if (ctx->RasterMask & (ALPHATEST_BIT | 354 BLEND_BIT | 355 DEPTH_BIT | 356 FOG_BIT | 357 LOGIC_OP_BIT | 358 SCISSOR_BIT | 359 STENCIL_BIT | 360 MASKING_BIT | 361 ALPHABUF_BIT | 362 MULTI_DRAW_BIT)) 309 363 return GL_FALSE; 310 364 311 365 if (ctx->Scissor.Enabled) { 312 xmin=ctx->Scissor.X; 313 xmax=ctx->Scissor.X+ctx->Scissor.Width; 314 ymin=ctx->Scissor.Y; 315 ymax=ctx->Scissor.Y+ctx->Scissor.Height; 316 } else { 317 xmin=0; 318 xmax=fxMesa->width; 319 ymin=0; 320 ymax=fxMesa->height; 321 } 322 323 xmin+=fxMesa->x_offset; 324 xmax+=fxMesa->x_offset; 325 326 #ifdef XF86DRI 327 #define ISCLIPPED(rx, ry) ( ((rx)<xmin) || ((rx)>=xmax) || !inClipRects(fxMesa, rx, ry)) 328 #else 329 #define ISCLIPPED(rx, ry) ( ((rx)<xmin) || ((rx)>=xmax) ) 330 #endif 331 #define DRAWBIT(i) { \ 332 if(!ISCLIPPED(x+px, y)) \ 333 if( (*pb) & (1<<(i)) ) \ 334 (*p)=color; \ 335 p++; \ 336 x++; \ 337 if(x>=width) { \ 338 pb++; \ 339 break; \ 340 } \ 341 } 342 343 scrwidth=fxMesa->width; 344 scrheight=fxMesa->height; 345 346 if ((px>=scrwidth) || (px+width<=0) || (py>=scrheight) || (py+height<=0)) 347 return GL_TRUE; 348 349 pb=bitmap; 350 351 if(py<0) { 352 pb+=(height*(-py)) >> (3+1); 353 height+=py; 354 py=0; 355 } 356 357 if (py+height>=scrheight) 358 height-=(py+height)-scrheight; 359 360 info.size=sizeof(info); 361 if(!FX_grLfbLock(GR_LFB_WRITE_ONLY, 362 fxMesa->currentFB, 363 GR_LFBWRITEMODE_565, 364 GR_ORIGIN_UPPER_LEFT, 365 FXFALSE, 366 &info)) { 366 /* This is a bit tricky, but by carefully adjusting the px, py, 367 * width, height, skipPixels and skipRows values we can do 368 * scissoring without special code in the rendering loop. 369 */ 370 371 /* we'll construct a new pixelstore struct */ 372 finalUnpack = &scissoredUnpack; 373 scissoredUnpack = *unpack; 374 if (scissoredUnpack.RowLength == 0) 375 scissoredUnpack.RowLength = width; 376 377 /* clip left */ 378 if (px < ctx->Scissor.X) { 379 scissoredUnpack.SkipPixels += (ctx->Scissor.X - px); 380 width -= (ctx->Scissor.X - px); 381 px = ctx->Scissor.X; 382 } 383 /* clip right */ 384 if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) { 385 width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width)); 386 } 387 /* clip bottom */ 388 if (py < ctx->Scissor.Y) { 389 scissoredUnpack.SkipRows += (ctx->Scissor.Y - py); 390 height -= (ctx->Scissor.Y - py); 391 py = ctx->Scissor.Y; 392 } 393 /* clip top */ 394 if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) { 395 height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height)); 396 } 397 398 if (width <= 0 || height <= 0) 399 return GL_TRUE; /* totally scissored away */ 400 } 401 else { 402 finalUnpack = unpack; 403 } 404 405 /* compute pixel value */ 406 { 407 GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f); 408 GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f); 409 GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f); 410 /*GLint a = (GLint)(ctx->Current.RasterColor[3]*255.0f);*/ 411 if (fxMesa->bgrOrder) 412 color = (FxU16) 413 ( ((FxU16)0xf8 & b) << (11-3)) | 414 ( ((FxU16)0xfc & g) << (5-3+1)) | 415 ( ((FxU16)0xf8 & r) >> 3); 416 else 417 color = (FxU16) 418 ( ((FxU16)0xf8 & r) << (11-3)) | 419 ( ((FxU16)0xfc & g) << (5-3+1)) | 420 ( ((FxU16)0xf8 & b) >> 3); 421 } 422 423 info.size = sizeof(info); 424 if (!FX_grLfbLock(GR_LFB_WRITE_ONLY, 425 fxMesa->currentFB, 426 GR_LFBWRITEMODE_565, 427 GR_ORIGIN_UPPER_LEFT, 428 FXFALSE, 429 &info)) { 367 430 #ifndef FX_SILENT 368 431 fprintf(stderr,"fx Driver: error locking the linear frame buffer\n"); … … 371 434 } 372 435 373 r=(GLint)(ctx->Current.RasterColor[0]*255.0f); 374 g=(GLint)(ctx->Current.RasterColor[1]*255.0f); 375 b=(GLint)(ctx->Current.RasterColor[2]*255.0f); 376 a=(GLint)(ctx->Current.RasterColor[3]*255.0f); 377 color=(FxU16) 378 ( ((FxU16)0xf8 & b) <<(11-3)) | 379 ( ((FxU16)0xfc & g) <<(5-3+1)) | 380 ( ((FxU16)0xf8 & r) >> 3); 381 382 stride=info.strideInBytes>>1; 383 384 /* This code is a bit slow... */ 385 386 if (py>ymin) ymin=py; 387 if (py+height<ymax) ymax=py+height; 388 389 px+=fxMesa->x_offset; 390 scrheight=fxMesa->height+fxMesa->y_offset; 391 392 for(y=ymin; y<ymax; y++) { 393 394 p=((FxU16 *)info.lfbPtr)+px+((scrheight-y)*stride); 395 396 for(x=0;;) { 397 DRAWBIT(7); DRAWBIT(6); DRAWBIT(5); DRAWBIT(4); 398 DRAWBIT(3); DRAWBIT(2); DRAWBIT(1); DRAWBIT(0); 399 pb++; 400 } 401 } 436 #ifdef XF86DRI 437 #define INSIDE(c, x, y) inClipRects((c), (x), (y)) 438 #else 439 #define INSIDE(c, x, y) (1) 440 #endif 441 442 { 443 const GLint winX = fxMesa->x_offset; 444 const GLint winY = fxMesa->y_offset + fxMesa->height - 1; 445 /* The dest stride depends on the hardware and whether we're drawing 446 * to the front or back buffer. This compile-time test seems to do 447 * the job for now. 448 */ 449 #ifdef XF86DRI 450 const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) 451 ? (fxMesa->screen_width) : (info.strideInBytes / 2); 452 #else 453 const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */ 454 #endif 455 GLint row; 456 /* compute dest address of bottom-left pixel in bitmap */ 457 GLushort *dst = (GLushort *) info.lfbPtr 458 + (winY - py) * dstStride 459 + (winX + px); 460 461 for (row = 0; row < height; row++) { 462 const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack, 463 bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); 464 if (finalUnpack->LsbFirst) { 465 /* least significan bit first */ 466 GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); 467 GLint col; 468 for (col=0; col<width; col++) { 469 if (*src & mask) { 470 if (INSIDE(fxMesa, winX + px + col, winY - py - row)) 471 dst[col] = color; 472 } 473 if (mask == 128U) { 474 src++; 475 mask = 1U; 476 } 477 else { 478 mask = mask << 1; 479 } 480 } 481 if (mask != 1) 482 src++; 483 } 484 else { 485 /* most significan bit first */ 486 GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7); 487 GLint col; 488 for (col=0; col<width; col++) { 489 if (*src & mask) { 490 if (INSIDE(fxMesa, winX + px + col, winY - py - row)) 491 dst[col] = color; 492 } 493 if (mask == 1U) { 494 src++; 495 mask = 128U; 496 } 497 else { 498 mask = mask >> 1; 499 } 500 } 501 if (mask != 128) 502 src++; 503 } 504 dst -= dstStride; 505 } 506 } 507 508 #undef INSIDE 402 509 403 510 FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB); 404 405 #undef ISCLIPPED406 #undef DRAWBIT407 408 511 return GL_TRUE; 409 512 } … … 423 526 fprintf(stderr,"fx Driver: internal error in fxDDGetParameteri(): %x\n",param); 424 527 fxCloseHardware(); 425 exit(-1);528 EXIT(-1); 426 529 return 0; 427 530 } … … 441 544 static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name) 442 545 { 443 switch (name) {444 case GL_RENDERER:445 546 #if defined(GLX_DIRECT_RENDERING) 446 return "Mesa Glide - DRI VB/V3"; 547 /* Building for DRI driver */ 548 switch (name) { 549 case GL_RENDERER: 550 { 551 static char buffer[100]; 552 char hardware[100]; 553 strcpy(hardware, grGetString(GR_HARDWARE)); 554 if (strcmp(hardware, "Voodoo3 (tm)") == 0) 555 strcpy(hardware, "Voodoo3"); 556 else if (strcmp(hardware, "Voodoo Banshee (tm)") == 0) 557 strcpy(hardware, "VoodooBanshee"); 558 else { 559 /* unexpected result: replace spaces with hyphens */ 560 int i; 561 for (i = 0; hardware[i]; i++) { 562 if (hardware[i] == ' ' || hardware[i] == '\t') 563 hardware[i] = '-'; 564 } 565 } 566 /* now make the GL_RENDERER string */ 567 sprintf(buffer, "Mesa DRI %s 20000322", hardware); 568 return buffer; 569 } 570 case GL_VENDOR: 571 return "Precision Insight, Inc."; 572 default: 573 return NULL; 574 } 575 447 576 #else 577 578 /* Building for Voodoo1/2 stand-alone Mesa */ 579 switch (name) { 580 case GL_RENDERER: 448 581 { 449 static char buf[80]; 450 451 if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) 452 { 453 GrVoodooConfig_t *vc = 454 &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; 455 456 sprintf(buf, 457 "Mesa Glide v0.30 Voodoo_Graphics %d " 458 "CARD/%d FB/%d TM/%d TMU/%s", 459 glbCurrentBoard, 460 (vc->sliDetect ? (vc->fbRam*2) : vc->fbRam), 461 (vc->tmuConfig[GR_TMU0].tmuRam + 462 ((vc->nTexelfx>1) ? vc->tmuConfig[GR_TMU1].tmuRam : 0)), 463 vc->nTexelfx, 464 (vc->sliDetect ? "SLI" : "NOSLI")); 465 } 466 else if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) 467 { 468 GrSst96Config_t *sc = 469 &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config; 470 471 sprintf(buf, 472 "Glide v0.30 Voodoo_Rush %d " 473 "CARD/%d FB/%d TM/%d TMU/NOSLI", 474 glbCurrentBoard, 475 sc->fbRam, 476 sc->tmuConfig.tmuRam, 477 sc->nTexelfx); 478 } 479 else 480 { 481 strcpy(buf, "Glide v0.30 UNKNOWN"); 482 } 483 484 return (GLubyte *) buf; 582 static char buf[80]; 583 584 if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) { 585 GrVoodooConfig_t *vc = 586 &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; 587 588 sprintf(buf, 589 "Mesa Glide v0.30 Voodoo_Graphics %d " 590 "CARD/%d FB/%d TM/%d TMU/%s", 591 glbCurrentBoard, 592 (vc->sliDetect ? (vc->fbRam*2) : vc->fbRam), 593 (vc->tmuConfig[GR_TMU0].tmuRam + 594 ((vc->nTexelfx>1) ? vc->tmuConfig[GR_TMU1].tmuRam : 0)), 595 vc->nTexelfx, 596 (vc->sliDetect ? "SLI" : "NOSLI")); 597 } 598 else if (glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) { 599 GrSst96Config_t *sc = 600 &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config; 601 602 sprintf(buf, 603 "Glide v0.30 Voodoo_Rush %d " 604 "CARD/%d FB/%d TM/%d TMU/NOSLI", 605 glbCurrentBoard, 606 sc->fbRam, 607 sc->tmuConfig.tmuRam, 608 sc->nTexelfx); 609 } 610 else { 611 strcpy(buf, "Glide v0.30 UNKNOWN"); 612 } 613 return (GLubyte *) buf; 485 614 } 615 default: 616 return NULL; 617 } 486 618 #endif 487 default:488 return NULL;489 }490 619 } 491 620 … … 493 622 int fxDDInitFxMesaContext( fxMesaContext fxMesa ) 494 623 { 495 624 496 625 FX_setupGrVertexLayout(); 497 498 if (getenv("FX_EMULATE_SINGLE_TMU")) 626 627 if (getenv("FX_EMULATE_SINGLE_TMU")) 499 628 fxMesa->haveTwoTMUs = GL_FALSE; 500 629 501 630 fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs; 502 503 if (!getenv("FX_DONT_FAKE_MULTITEX")) 631 632 if (!getenv("FX_DONT_FAKE_MULTITEX")) 504 633 fxMesa->emulateTwoTMUs = GL_TRUE; 505 634 506 635 if(getenv("FX_GLIDE_SWAPINTERVAL")) 507 636 fxMesa->swapInterval=atoi(getenv("FX_GLIDE_SWAPINTERVAL")); … … 513 642 else 514 643 fxMesa->maxPendingSwapBuffers=2; 515 644 645 if(getenv("MESA_FX_INFO")) 646 fxMesa->verbose=GL_TRUE; 647 else 648 fxMesa->verbose=GL_FALSE; 649 516 650 fxMesa->color=0xffffffff; 517 651 fxMesa->clearC=0; … … 539 673 fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO; 540 674 541 fxMesa->unitsState.depthTestEnabled 542 fxMesa->unitsState.depthMask 543 fxMesa->unitsState.depthTestFunc 675 fxMesa->unitsState.depthTestEnabled =GL_FALSE; 676 fxMesa->unitsState.depthMask =GL_TRUE; 677 fxMesa->unitsState.depthTestFunc =GR_CMP_LESS; 544 678 545 679 FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE); … … 551 685 FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); 552 686 } 553 554 fxMesa->state 555 fxMesa->fogTable 556 557 fxMesa->state 558 fxMesa->fogTable 559 687 688 fxMesa->state = NULL; 689 fxMesa->fogTable = NULL; 690 691 fxMesa->state = malloc(FX_grGetInteger(FX_GLIDE_STATE_SIZE)); 692 fxMesa->fogTable = (GrFog_t*)malloc(FX_grGetInteger(FX_FOG_TABLE_ENTRIES)*sizeof(GrFog_t)); 693 560 694 if (!fxMesa->state || !fxMesa->fogTable) { 561 695 if (fxMesa->state) free(fxMesa->state); … … 566 700 if(fxMesa->haveZBuffer) 567 701 FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); 568 702 569 703 #if (!FXMESA_USE_ARGB) 570 704 FX_grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); /* Not every Glide has this */ 571 705 #endif 572 706 707 fxMesa->textureAlign=FX_grGetInteger(FX_TEXTURE_ALIGN); 573 708 fxMesa->glCtx->Const.MaxTextureLevels=9; 574 709 fxMesa->glCtx->Const.MaxTextureSize=256; … … 576 711 fxMesa->glCtx->NewState|=NEW_DRVSTATE1; 577 712 fxMesa->new_state = NEW_ALL; 578 713 579 714 fxDDSetupInit(); 580 715 fxDDCvaInit(); … … 585 720 fxSetupDDPointers(fxMesa->glCtx); 586 721 fxDDRenderInit(fxMesa->glCtx); 587 fxDDInitExtensions(fxMesa->glCtx); 722 fxDDInitExtensions(fxMesa->glCtx); 588 723 589 724 fxDDSetNearFar(fxMesa->glCtx,1.0,100.0); 590 725 591 726 FX_grGlideGetState((GrState*)fxMesa->state); 592 727 593 728 /* XXX Fix me: callback not registered when main VB is created. 594 729 */ 595 if (fxMesa->glCtx->VB) 730 if (fxMesa->glCtx->VB) 596 731 fxDDRegisterVB( fxMesa->glCtx->VB ); 597 732 598 733 /* XXX Fix me too: need to have the 'struct dd' prepared prior to 599 734 * creating the context... The below is broken if you try to insert 600 * new stages. 735 * new stages. 601 736 */ 602 737 if (fxMesa->glCtx->NrPipelineStages) 603 fxMesa->glCtx->NrPipelineStages = fxDDRegisterPipelineStages( 604 605 606 738 fxMesa->glCtx->NrPipelineStages = fxDDRegisterPipelineStages( 739 fxMesa->glCtx->PipelineStage, 740 fxMesa->glCtx->PipelineStage, 741 fxMesa->glCtx->NrPipelineStages); 607 742 608 743 /* Run the config file */ … … 620 755 fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; 621 756 622 gl_extensions_add( ctx, DEFAULT_ON, "3DFX_set_global_palette", 0 ); 623 gl_extensions_add( ctx, DEFAULT_ON, "GL_FXMESA_global_texture_lod_bias", 0); 624 625 if(fxMesa->haveTwoTMUs) 626 gl_extensions_add( ctx, DEFAULT_ON, "GL_EXT_texture_env_add", 0); 627 628 if (!fxMesa->emulateTwoTMUs) 629 gl_extensions_disable( ctx, "GL_ARB_multitexture" ); 757 gl_extensions_disable(ctx, "GL_EXT_blend_logic_op"); 758 gl_extensions_disable(ctx, "GL_EXT_blend_minmax"); 759 gl_extensions_disable(ctx, "GL_EXT_blend_subtract"); 760 gl_extensions_disable(ctx, "GL_EXT_blend_color"); 761 gl_extensions_disable(ctx, "GL_EXT_paletted_texture"); 762 763 gl_extensions_add(ctx, DEFAULT_ON, "3DFX_set_global_palette", 0); 764 765 if (!fxMesa->haveTwoTMUs) 766 gl_extensions_disable(ctx, "GL_EXT_texture_env_add"); 767 768 if (!fxMesa->emulateTwoTMUs) 769 gl_extensions_disable(ctx, "GL_ARB_multitexture"); 770 771 772 /* Example of hooking in an extension function. 773 * For DRI-based drivers, also see __driRegisterExtensions in the 774 * tdfx_xmesa.c file. 775 */ 776 #if 0 777 { 778 void **dispatchTable = (void **) ctx->Exec; 779 const int _gloffset_FooBarEXT = 555; /* just an example number! */ 780 const int tabSize = _glapi_get_dispatch_table_size(); 781 assert(_gloffset_FooBarEXT < tabSize); 782 dispatchTable[_gloffset_FooBarEXT] = (void *) fxFooBarEXT; 783 /* XXX You would also need to hook into the display list dispatch 784 * table. Really, the implementation of extensions might as well 785 * be in the core of Mesa since core Mesa and the device driver 786 * is one big shared lib. 787 */ 788 } 789 #endif 630 790 } 631 791 … … 640 800 /************************************************************************/ 641 801 642 /* This is a no-op, since the z-buffer is in hardware */ 643 static void fxAllocDepthBuffer(GLcontext *ctx) 644 { 645 if (MESA_VERBOSE&VERBOSE_DRIVER) { 646 fprintf(stderr,"fxmesa: fxAllocDepthBuffer()\n"); 647 } 648 } 649 650 /************************************************************************/ 651 /************************************************************************/ 652 /************************************************************************/ 653 654 /* Check if the hardware supports the current context 802 /* Check if the hardware supports the current context 655 803 * 656 804 * Performs similar work to fxDDChooseRenderState() - should be merged. … … 661 809 662 810 if (!ctx->Hint.AllowDrawMem) 663 return GL_TRUE; 811 return GL_TRUE; /* you'll take it and like it */ 664 812 665 813 if((ctx->RasterMask & STENCIL_BIT) || … … 679 827 if((ctx->Enabled & (TEXTURE0_3D | TEXTURE1_3D)) || 680 828 /* Not very well written ... */ 681 ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) && 829 ((ctx->Enabled & (TEXTURE0_1D | TEXTURE1_1D)) && 682 830 ((ctx->Enabled & (TEXTURE0_2D | TEXTURE1_2D))!=(TEXTURE0_2D | TEXTURE1_2D))) 683 831 ) { … … 698 846 if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) 699 847 fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n", 700 701 848 gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), 849 gl_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode)); 702 850 703 851 /* KW: This was wrong (I think) and I changed it... which doesn't mean … … 708 856 { 709 857 /* Can't use multipass to blend a multitextured triangle - fall 710 711 858 * back to software. 859 */ 712 860 if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) { 713 861 return GL_FALSE; 714 862 } 715 863 716 864 if ((ctx->Texture.Unit[0].EnvMode!=ctx->Texture.Unit[1].EnvMode) && 717 718 865 (ctx->Texture.Unit[0].EnvMode!=GL_MODULATE) && 866 (ctx->Texture.Unit[0].EnvMode!=GL_REPLACE)) /* q2, seems ok... */ 719 867 { 720 721 722 868 if (MESA_VERBOSE&VERBOSE_DRIVER) 869 fprintf(stderr, "fxMesa: unsupported multitex env mode\n"); 870 return GL_FALSE; 723 871 } 724 872 } … … 726 874 if((ctx->Enabled & (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D)) || 727 875 /* Not very well written ... */ 728 ((ctx->Enabled & TEXTURE0_1D) && 876 ((ctx->Enabled & TEXTURE0_1D) && 729 877 (!(ctx->Enabled & TEXTURE0_2D))) 730 878 ) { … … 732 880 } 733 881 734 882 735 883 if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) && 736 884 (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) { … … 751 899 GLuint new_state = ctx->NewState; 752 900 753 if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_STATE)) 901 if (MESA_VERBOSE&(VERBOSE_DRIVER|VERBOSE_STATE)) 754 902 fprintf(stderr,"fxmesa: fxDDUpdateDDPointers(...)\n"); 755 903 756 if (new_state & (NEW_RASTER_OPS|NEW_TEXTURING)) 904 if (new_state & (NEW_RASTER_OPS|NEW_TEXTURING)) 757 905 fxMesa->is_in_hardware = fxIsInHardware(ctx); 758 906 … … 770 918 ctx->Driver.RasterSetup=fxDDChooseSetupFunction(ctx); 771 919 } 772 920 773 921 ctx->Driver.PointsFunc=fxMesa->PointsFunc; 774 922 ctx->Driver.LineFunc=fxMesa->LineFunc; … … 780 928 } 781 929 930 static void fxDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim) 931 { 932 if (ctx->Polygon.CullFlag) { 933 if (ctx->PB->primitive != GL_POLYGON) { /* Lines or Points */ 934 FX_grCullMode(GR_CULL_DISABLE); 935 FX_CONTEXT(ctx)->cullMode=GR_CULL_DISABLE; 936 } 937 } 938 } 939 782 940 void fxSetupDDPointers(GLcontext *ctx) 783 941 { … … 788 946 ctx->Driver.UpdateState=fxDDUpdateDDPointers; 789 947 790 ctx->Driver.AllocDepthBuffer=fxAllocDepthBuffer; 791 ctx->Driver.DepthTestSpan=fxDDDepthTestSpanGeneric; 792 ctx->Driver.DepthTestPixels=fxDDDepthTestPixelsGeneric; 793 ctx->Driver.ReadDepthSpanFloat=fxDDReadDepthSpanFloat; 794 ctx->Driver.ReadDepthSpanInt=fxDDReadDepthSpanInt; 795 948 ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan; 949 ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels; 950 ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan; 951 ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels; 952 796 953 ctx->Driver.GetString=fxDDGetString; 797 954 … … 809 966 ctx->Driver.Color=fxDDSetColor; 810 967 811 ctx->Driver.SetBuffer=fxDDSetBuffer; 968 ctx->Driver.SetDrawBuffer=fxDDSetDrawBuffer; 969 ctx->Driver.SetReadBuffer=fxDDSetReadBuffer; 812 970 ctx->Driver.GetBufferSize=fxDDBufferSize; 813 971 … … 828 986 ctx->Driver.DeleteTexture=fxDDTexDel; 829 987 ctx->Driver.UpdateTexturePalette=fxDDTexPalette; 830 ctx->Driver.UseGlobalTexturePalette=fxDDTexUseGlbPalette;831 988 832 989 ctx->Driver.RectFunc=NULL; … … 843 1000 ctx->Driver.ShadeModel=fxDDShadeModel; 844 1001 ctx->Driver.Enable=fxDDEnable; 1002 ctx->Driver.ReducedPrimitiveChange=fxDDReducedPrimitiveChange; 845 1003 846 1004 ctx->Driver.RegisterVB=fxDDRegisterVB; … … 855 1013 /* ctx->Driver.OptimizePrecalcPipeline = fxDDOptimizePrecalcPipeline; */ 856 1014 857 if (!getenv("FX_NO_FAST")) 858 ctx->Driver.BuildPrecalcPipeline = fxDDBuildPrecalcPipeline; 1015 if (!getenv("FX_NO_FAST")) 1016 ctx->Driver.BuildPrecalcPipeline = fxDDBuildPrecalcPipeline; 859 1017 860 1018 ctx->Driver.TriangleCaps = DD_TRI_CULL|DD_TRI_OFFSET|DD_TRI_LIGHT_TWOSIDE;
Note:
See TracChangeset
for help on using the changeset viewer.