diff options
author | brianp <brianp> | 2000-05-27 23:31:05 +0000 |
---|---|---|
committer | brianp <brianp> | 2000-05-27 23:31:05 +0000 |
commit | d5fe9755f49cde78f58e012771735055db57087f (patch) | |
tree | c9c72daf5f51ab2a9c8345d1f2ab374dfdeff405 /xc | |
parent | 83a1de3d095ec934ae1401a24501d7d8d3ce7213 (diff) |
implemented span clipping, more 32bpp rendering work, misc clean-ups
Diffstat (limited to 'xc')
-rw-r--r-- | xc/extras/Mesa/src/FX/fxapi.c | 202 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxdd.c | 43 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxddspan.c | 439 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxdrv.h | 8 | ||||
-rw-r--r-- | xc/extras/Mesa/src/FX/fxsetup.c | 14 |
5 files changed, 396 insertions, 310 deletions
diff --git a/xc/extras/Mesa/src/FX/fxapi.c b/xc/extras/Mesa/src/FX/fxapi.c index 0b96cf439..425778a12 100644 --- a/xc/extras/Mesa/src/FX/fxapi.c +++ b/xc/extras/Mesa/src/FX/fxapi.c @@ -694,22 +694,11 @@ void GLAPIENTRY fxMesaSetNearFar(GLfloat n, GLfloat f) /* - * The extension GL_FXMESA_global_texture_lod_bias - */ -void GLAPIENTRY glGlobalTextureLODBiasFXMESA(GLfloat biasVal) -{ - grTexLodBiasValue(GR_TMU0,biasVal); - - if(fxMesaCurrentCtx->haveTwoTMUs) - grTexLodBiasValue(GR_TMU1,biasVal); -} - - -/* * The 3Dfx Global Palette extension for GLQuake. * More a trick than a real extesion, use the shared global * palette extension. */ +extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */ void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal) { fxMesaContext fxMesa =fxMesaCurrentCtx; @@ -866,6 +855,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, GLcontext *ctx = 0; /*FX_GrContext_t glideContext = 0;*/ char *errorstr; + GLboolean useBGR; + char *system = NULL; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n"); @@ -890,8 +881,10 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, case FXMESA_DEPTH_SIZE: i++; depthSize=attribList[i]; - if(depthSize) + if(depthSize) { aux=1; + depthSize = 16; + } break; case FXMESA_STENCIL_SIZE: i++; @@ -924,10 +917,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, if(depthSize && alphaBuffer) alphaBuffer=0; - if(verbose) - fprintf(stderr,"Mesa fx Voodoo Device Driver v0.30\nWritten by David Bucciarelli (davibu@tin.it.it)\n"); - - if((type=fxQueryHardware()) < 0) { + if ((type=fxQueryHardware()) < 0) { fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n"); return NULL; } @@ -950,10 +940,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, else fxMesa->haveTwoTMUs=GL_FALSE; - fxMesa->haveDoubleBuffer=doubleBuffer; fxMesa->haveAlphaBuffer=alphaBuffer; fxMesa->haveGlobalPaletteTexture=GL_FALSE; - fxMesa->haveZBuffer=depthSize ? 1 : 0; fxMesa->verbose=verbose; fxMesa->board=glbCurrentBoard; @@ -971,28 +959,82 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, goto errorhandler; } - /* Pixel tables are use during pixel read-back */ + /* + * Pixel tables are use during pixel read-back + * Either initialize them for RGB or BGR order. + */ #if FXMESA_USE_ARGB - fxInitPixelTables(fxMesa, GL_FALSE); /* Force RGB pixel order */ + useBGR = GL_FALSE; /* Force RGB pixel order */ + system = "FXMESA_USE_ARGB"; #else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) { - /* jk991130 - GROSS HACK!!! - Voodoo 3s don't use BGR!! - * the only way to tell if it's a Voodoo 3 at this stage of the - * ballgame (no Glide 3.x for linux *yet*) is to query the # of TMUs + /* jk991130 - Voodoo 3s don't use BGR. Query the # of TMUs * as Voodoo3s have 2 TMUs on board, Banshee has only 1 - * Thanks to Joseph Kain for that one + * bk000413 - another suggestion from Joseph Kain is using + * VendorID 0x121a for all 3dfx boards + * DeviceID VG 1/V2 2/VB 3/V3 5 + * For now we cehck for known BGR devices, and presume + * everything else to be a V3/RGB. */ - if (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx == 2) { - fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order (Voodoo3) */ + GrVoodooConfig_t *voodoo; + voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; + + if (voodoo->nTexelfx == 1) { + /* Voodoo1 or Banshee */ + useBGR = GL_TRUE; + system = "Voodoo1"; + } + else if (voodoo->nTexelfx == 2 && + voodoo->fbiRev == 260 && + voodoo->tmuConfig[0].tmuRev == 4 && + voodoo->tmuConfig[0].tmuRam == 2) { + /* Voodoo 2 */ + useBGR = GL_TRUE; + system = "Voodoo2"; + } + else if (voodoo->nTexelfx == 2 && + voodoo->fbiRev == 2 && + voodoo->tmuConfig[0].tmuRev == 1 && + voodoo->tmuConfig[0].tmuRam == 4) { + /* Quantum3D Obsidian 50/100 */ + useBGR = GL_TRUE; + system = "Quantum3D Obsidian"; + } + else + /* Brian + * (voodoo->nTexelfx == 2 && + * voodoo->fbiRev == 0 && + * voodoo->tmuConfig[0].tmuRev == 148441048 && + * voodoo->tmuConfig[0].tmuRam == 3) + * Bernd + * (voodoo->nTexelfx == 2 && + * voodoo->fbiRev == 69634 && + * voodoo->tmuConfig[0].tmuRev == 69634 && + * voodoo->tmuConfig[0].tmuRam == 2 ) + */ + { + /* Presumed Voodoo3 */ + useBGR = GL_FALSE; + system = "Voodoo3"; } - else { - fxInitPixelTables(fxMesa, GL_TRUE); /* use BGR pixel order on Voodoo1/2 */ + if (getenv("MESA_FX_INFO")) { + printf("Voodoo: Texelfx: %d / FBI Rev.: %d / TMU Rev.: %d / TMU RAM: %d\n", + voodoo->nTexelfx, + voodoo->fbiRev, + voodoo->tmuConfig[0].tmuRev, + voodoo->tmuConfig[0].tmuRam ); } } else { - fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order otherwise */ + useBGR = GL_FALSE; /* use RGB pixel order otherwise */ + system = "non-voodoo"; } -#endif +#endif /*FXMESA_USE_ARGB*/ + + if (getenv("MESA_FX_INFO")) + printf("Voodoo pixel order: %s (%s)\n", useBGR ? "BGR" : "RGB", system); + + fxInitPixelTables(fxMesa, useBGR); fxMesa->width=FX_grSstScreenWidth(); fxMesa->height=FX_grSstScreenHeight(); @@ -1011,7 +1053,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, fxMesa->needClip = 0; if(verbose) - fprintf(stderr,"Glide screen size: %dx%d\n", + fprintf(stderr,"Voodoo Glide screen size: %dx%d\n", (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight()); fxMesa->glVis=gl_create_visual(GL_TRUE, /* RGB mode */ @@ -1046,7 +1088,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis, GL_FALSE, /* no software depth */ fxMesa->glVis->StencilBits > 0, - fxMesa->glVis->AccumBits > 0, + fxMesa->glVis->AccumRedBits > 0, fxMesa->glVis->AlphaBits > 0 ); if (!fxMesa->glBuffer) { errorstr = "gl_create_framebuffer"; @@ -1221,6 +1263,25 @@ void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext fxMesa) } +#if 0 +static void QueryCounters(void) +{ + static GLuint prevPassed = 0; + static GLuint prevFailed = 0; + GLuint failed, passed; + GrSstPerfStats_t st; + + FX_grSstPerfStats(&st); + failed = st.zFuncFail - st.aFuncFail - st.chromaFail; + passed = st.pixelsIn - failed; + printf("failed: %d passed: %d\n", failed - prevFailed, passed - prevPassed); + + prevPassed = passed; + prevFailed = failed; +} +#endif + + /* * Swap front/back buffers for current context if double buffered. */ @@ -1233,7 +1294,7 @@ void GLAPIENTRY fxMesaSwapBuffers(void) if(fxMesaCurrentCtx) { FLUSH_VB( fxMesaCurrentCtx->glCtx, "swap buffers" ); - if(fxMesaCurrentCtx->haveDoubleBuffer) { + if (fxMesaCurrentCtx->glVis->DBflag) { grBufferSwap(fxMesaCurrentCtx->swapInterval); @@ -1263,40 +1324,45 @@ int GLAPIENTRY fxQueryHardware(void) fprintf(stderr,"fxmesa: fxQueryHardware() Start\n"); } - if(!glbGlideInitialized) { + if (!glbGlideInitialized) { grGlideInit(); - if(FX_grSstQueryHardware(&glbHWConfig)) { + if (FX_grSstQueryHardware(&glbHWConfig)) { grSstSelect(glbCurrentBoard); - glb3DfxPresent=1; + glb3DfxPresent = 1; - if(getenv("MESA_FX_INFO")) { + if (getenv("MESA_FX_INFO")) { char buf[80]; FX_grGlideGetVersion(buf); - fprintf(stderr,"Using Glide V%s\n",""); - fprintf(stderr,"Number of boards: %d\n",glbHWConfig.num_sst); - - if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) { - fprintf(stderr,"Framebuffer RAM: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect ? - (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam*2) : - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam); - fprintf(stderr,"Number of TMUs: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx); - fprintf(stderr,"SLI detected: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect); - } else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) { - fprintf(stderr,"Framebuffer RAM: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam); - fprintf(stderr,"Number of TMUs: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx); + fprintf(stderr, "Voodoo Using Glide V%s\n", buf); + fprintf(stderr, "Voodoo Number of boards: %d\n", glbHWConfig.num_sst); + + if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) { + GrVoodooConfig_t *voodoo; + voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; + + fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", + voodoo->sliDetect ? (voodoo->fbRam*2) : voodoo->fbRam); + fprintf(stderr, "Voodoo Number of TMUs: %d\n", voodoo->nTexelfx); + fprintf(stderr, "Voodoo fbRam: %d\n", voodoo->fbRam); + fprintf(stderr, "Voodoo fbiRev: %d\n", voodoo->fbiRev); + + fprintf(stderr,"Voodoo SLI detected: %d\n", voodoo->sliDetect); + } + else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96) { + GrSst96Config_t *sst96; + sst96 = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config; + fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", sst96->fbRam); + fprintf(stderr, "Voodoo Number of TMUs: %d\n", sst96->nTexelfx); } } - } else - glb3DfxPresent=0; + } + else { + glb3DfxPresent = 0; + } - glbGlideInitialized=1; + glbGlideInitialized = 1; #if defined(__WIN32__) onexit((_onexit_t)cleangraphics); @@ -1308,17 +1374,11 @@ int GLAPIENTRY fxQueryHardware(void) #endif } - if(!glb3DfxPresent) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxQueryHardware() End (-1)\n"); - } - return(-1); - } - if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxQueryHardware() End (voodooo)\n"); } - return(glbHWConfig.SSTs[glbCurrentBoard].type); + + return glbHWConfig.SSTs[glbCurrentBoard].type; } @@ -1327,8 +1387,8 @@ int GLAPIENTRY fxQueryHardware(void) */ void GLAPIENTRY fxCloseHardware(void) { - if(glbGlideInitialized) { - if(getenv("MESA_FX_INFO")) { + if (glbGlideInitialized) { + if (getenv("MESA_FX_INFO")) { GrSstPerfStats_t st; FX_grSstPerfStats(&st); @@ -1340,9 +1400,9 @@ void GLAPIENTRY fxCloseHardware(void) fprintf(stderr," # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut); } - if(glbTotNumCtx==0) { + if (glbTotNumCtx == 0) { grGlideShutdown(); - glbGlideInitialized=0; + glbGlideInitialized = 0; } } } @@ -1354,7 +1414,7 @@ void GLAPIENTRY fxCloseHardware(void) /* * Need this to provide at least one external definition. */ - +extern int gl_fx_dummy_function_api(void); int gl_fx_dummy_function_api(void) { return 0; diff --git a/xc/extras/Mesa/src/FX/fxdd.c b/xc/extras/Mesa/src/FX/fxdd.c index 1d2a53b00..e9687b3e8 100644 --- a/xc/extras/Mesa/src/FX/fxdd.c +++ b/xc/extras/Mesa/src/FX/fxdd.c @@ -150,38 +150,6 @@ static void fxDDClearColor(GLcontext *ctx, GLubyte red, GLubyte green, } -#if 000 -/* - * Set up the stencil state for clear. - * - * If the mask bit is off, and stencil is enabled, we want - * to set the write mask to 0. - */ -#define fxSetStencilStateForClear(fxMesa, mask) \ -{ \ - if ((fxMesa)->unitsState.stencilEnabled \ - && !((mask) & DD_STENCIL_BIT)) { \ - FX_grStencilMask(0); \ - } \ -} - -/* - * Restore the stencil state. - * - * If the mask bit is off and stencil is enabled, we just set - * the write mask to 0, so we need to restore it. - */ -#define fxResetStencilStateForClear(fxMesa, mask) \ -{ \ - if ((fxMesa)->unitsState.stencilEnabled \ - && !((mask) & DD_STENCIL_BIT)) { \ - FX_grStencilMask((fxMesa)->unitsState.stencilWriteMask); \ - } \ -} -#endif - - - /* Clear the color and/or depth buffers */ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, GLint x, GLint y, GLint width, GLint height ) @@ -1077,11 +1045,12 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) */ FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE); - if(fxMesa->haveDoubleBuffer) { - fxMesa->currentFB=GR_BUFFER_BACKBUFFER; + if (fxMesa->glVis->DBflag) { + fxMesa->currentFB = GR_BUFFER_BACKBUFFER; FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); - } else { - fxMesa->currentFB=GR_BUFFER_FRONTBUFFER; + } + else { + fxMesa->currentFB = GR_BUFFER_FRONTBUFFER; FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); } @@ -1097,7 +1066,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) return 0; } - if(fxMesa->haveZBuffer) + if (fxMesa->glVis->DepthBits > 0) FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); #if (!FXMESA_USE_ARGB) diff --git a/xc/extras/Mesa/src/FX/fxddspan.c b/xc/extras/Mesa/src/FX/fxddspan.c index 5a2f8e960..63de10848 100644 --- a/xc/extras/Mesa/src/FX/fxddspan.c +++ b/xc/extras/Mesa/src/FX/fxddspan.c @@ -46,28 +46,76 @@ /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */ -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif +#include "fxdrv.h" -#if defined(FX) -#include "fxdrv.h" -#ifdef _MSC_VER -#ifdef _WIN32 -#pragma warning( disable : 4090 4022 ) -/* 4101 : "different 'const' qualifier" - * 4022 : "pointer mistmatch for actual parameter 'n' +/* + * Examine the cliprects to generate an array of flags to indicate + * which pixels in a span are visible. Note: (x,y) is a screen + * coordinate. */ -#endif -#endif +static void +generate_vismask(const fxMesaContext fxMesa, GLint x, GLint y, GLint n, + GLubyte vismask[]) +{ + GLboolean initialized = GL_FALSE; + GLint i, j; + + /* turn on flags for all visible pixels */ + for (i = 0; i < fxMesa->numClipRects; i++) { + const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i]; + + if (y >= rect->y1 && y < rect->y2) { + if (x >= rect->x1 && x + n <= rect->x2) { + /* common case, whole span inside cliprect */ + MEMSET(vismask, 1, n); + return; + } + if (x < rect->x2 && x + n >= rect->x1) { + /* some of the span is inside the rect */ + GLint start, end; + if (!initialized) { + MEMSET(vismask, 0, n); + initialized = GL_TRUE; + } + if (x < rect->x1) + start = rect->x1 - x; + else + start = 0; + if (x + n > rect->x2) + end = rect->x2 - x; + else + end = n; + assert(start >= 0); + assert(end <= n); + for (j = start; j < end; j++) + vismask[j] = 1; + } + } + } +} -#if !defined(FXMESA_USE_ARGB) +/* + * Examine cliprects and determine if the given screen pixel is visible. + */ +static GLboolean +visible_pixel(const fxMesaContext fxMesa, int scrX, int scrY) +{ + int i; + for (i = 0; i < fxMesa->numClipRects; i++) { + const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i]; + if (scrX >= rect->x1 && + scrX < rect->x2 && + scrY >= rect->y1 && + scrY < rect->y2) + return GL_TRUE; + } + return GL_FALSE; +} -#if defined(FX_GLIDE3) && defined(XF86DRI) typedef enum { FBS_READ, FBS_WRITE } FBS_DIRECTION; /* @@ -231,12 +279,6 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, return GL_TRUE; } -#else - -#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) - -#endif /* KW: Rearranged the args in the call to grLfbWriteRegion(). @@ -257,55 +299,15 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, src_data) \ -#else /* !defined(FXMESA_USE_RGBA) */ - -#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) - -#define MESACOLOR_TO_ARGB(c) ( \ - ( ((unsigned int)(c[ACOMP]))<<24 ) | \ - ( ((unsigned int)(c[RCOMP]))<<16 ) | \ - ( ((unsigned int)(c[GCOMP]))<<8 ) | \ - ( (unsigned int)(c[BCOMP])) ) - -inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer, - FxU32 dst_x, - FxU32 dst_y, - FxU32 src_width, - FxI32 src_stride, - void *src_data ) -{ - /* Covert to ARGB */ - GLubyte (*rgba)[4] = src_data; - GLuint argb[MAX_WIDTH]; - int i; - - for (i = 0; i < src_width; i++) - { - argb[i] = MESACOLOR_TO_ARGB(rgba[i]); - } - writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer, - dst_x, - dst_y, - GR_LFB_SRC_FMT_8888, - src_width, - 1, - src_stride, - (void*)argb); -} - -#endif /* !defined(FXMESA_USE_RGBA) */ - - -/************************************************************************/ -/***** Span functions *****/ -/************************************************************************/ +/* + * 16bpp span/pixel functions + */ -static void fxDDWriteRGBASpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], const GLubyte mask[]) +static void +write_R5G6B5_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; @@ -340,9 +342,9 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx, } -static void fxDDWriteRGBSpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgb[][3], const GLubyte mask[]) +static void +write_R5G6B5_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgb[][3], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; @@ -390,9 +392,9 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx, } -static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte mask[]) +static void +write_R5G6B5_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; @@ -496,8 +498,73 @@ read_R5G6B5_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, } +static void +write_R5G6B5_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[]) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + GLuint i; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; + + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n"); + } + + for(i=0;i<n;i++) + if(mask[i]) + LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i], + 1, 1, (void *)rgba[i]); +} + + +static void +write_R5G6B5_mono_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[]) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + GLuint i; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; + + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n"); + } + + for(i=0;i<n;i++) + if(mask[i]) + writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i], + GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color); +} + +static void +read_R5G6B5_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + GLuint i; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; + + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n"); + } + + for(i=0;i<n;i++) { + if(mask[i]) { + GLushort pixel; + FX_grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&pixel); + rgba[i][RCOMP] = FX_PixelToR[pixel]; + rgba[i][GCOMP] = FX_PixelToG[pixel]; + rgba[i][BCOMP] = FX_PixelToB[pixel]; + rgba[i][ACOMP] = 255; + } + } +} + + /* - * 32bpp pixel read/write + * 16bpp span/pixel functions */ static void @@ -523,25 +590,19 @@ write_R8G8B8A8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, &info)) { const GLint winY = fxMesa->y_offset + fxMesa->height - 1; const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { - /* XXX have to do cliprect clipping! */ GLint dstStride = fxMesa->screen_width * 4; GLubyte * dst = (GLubyte *) info.lfbPtr + (winY - y) * dstStride + (winX + x) * 4; - if (mask) { - GLuint *dst32 = (GLuint *) dst; - GLuint i; - for (i = 0; i < n; i++) { - if (mask[i]) { - dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); - } - } - } - else { - GLuint *dst32 = (GLuint *) dst; - GLuint i; - for (i = 0; i < n; i++) { + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); } } @@ -616,29 +677,21 @@ write_R8G8B8A8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, &info)) { const GLint winY = fxMesa->y_offset + fxMesa->height - 1; const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { /* XXX have to do cliprect clipping! */ GLint dstStride = fxMesa->screen_width * 4; GLubyte *dst = (GLubyte *) info.lfbPtr + (winY - y) * dstStride + (winX + x) * 4; - if (mask) { - GLuint *dst32 = (GLuint *) dst; - GLuint i; - for (i = 0; i < n; i++) { - if (mask[i]) { - dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]); - } - } - } - else { - /* no mask, write all pixels */ - GLuint *dst32 = (GLuint *) dst; - GLuint i; - for (i = 0; i < n; i++) { - if (mask && mask[i]) { - dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]); - } + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { + dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]); } } } @@ -742,75 +795,96 @@ read_R8G8B8A8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, } - -/************************************************************************/ -/***** Pixel functions *****/ -/************************************************************************/ - -static void fxDDWriteRGBAPixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - CONST GLubyte rgba[][4], const GLubyte mask[]) +static void +write_R8G8B8A8_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; +#if 00 GLuint i; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n"); + for (i = 0; i < n; i++) { + write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i); } - for(i=0;i<n;i++) - if(mask[i]) - LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i], - 1, 1, (void *)rgba[i]); -} +#else + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; -static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLubyte mask[]) -{ - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLuint i; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888 /*565*/; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n"); + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLuint i; + for (i = 0; i < n; i++) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x[i]; + const GLint scrY = winY - y[i]; + if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) { + GLint dstStride = fxMesa->screen_width * 4; + GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4; + GLuint *dst32 = (GLuint *) dst; + *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1], + rgba[i][2], rgba[i][3]); + } + } + } + else { + /* back buffer */ + GLuint i; + for (i = 0; i < n; i++) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x[i]; + const GLint scrY = winY - y[i]; + if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) { + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4; + GLuint *dst32 = (GLuint *) dst; + const GLuint *src32 = (const GLuint *) rgba; + *dst32 = src32[i]; + } + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); } - - for(i=0;i<n;i++) - if(mask[i]) - writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i], - GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color); + END_BOARD_LOCK(); +#endif } -static void fxDDReadRGBAPixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[]) + +static void +write_R8G8B8A8_mono_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLuint i; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; +} - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n"); - } - for(i=0;i<n;i++) { - if(mask[i]) { - GLushort pixel; - FX_grLfbReadRegion(fxMesa->currentFB,x[i],bottom-y[i],1,1,0,&pixel); - rgba[i][RCOMP] = FX_PixelToR[pixel]; - rgba[i][GCOMP] = FX_PixelToG[pixel]; - rgba[i][BCOMP] = FX_PixelToB[pixel]; - rgba[i][ACOMP] = 255; - } - } +static void +read_R8G8B8A8_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) +{ + printf("read_R8G8B8A8_pixels %d\n", n); } -/************************************************************************/ -/***** Depth functions *****/ -/************************************************************************/ + +/* + * Depth buffer read/write functions. + */ void fxDDWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth depth[], @@ -1055,10 +1129,10 @@ void fxDDReadDepthPixels(GLcontext *ctx, GLuint n, } +/* + * Stencil buffer read/write functions. + */ -/************************************************************************/ -/***** Stencil functions *****/ -/************************************************************************/ #define DEPTH_VALUE_TO_STENCIL_VALUE(d) (((d) >> 24) & 0xFF) #define STENCIL_VALUE_TO_DEPTH_VALUE(s,d) \ ((((s) & 0xFF) << 24) | ((d) & 0xFFFFFF)) @@ -1255,15 +1329,20 @@ static void write_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, &info)) { const GLint winY = fxMesa->y_offset + fxMesa->height - 1; const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; + GLint dstStride = info.strideInBytes; GLubyte *dst = (GLubyte *) info.lfbPtr + (winY - y) * dstStride + (winX + x) * 4; GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); s = dstStride; d = dst32; for (i = 0; i < n; i++) { - if (!mask || mask[i]) { + if (visMask[i] && (!mask || mask[i])) { GLuint zs = dst32[i]; GLuint z = EXTRACT_Z_FROM_ZS(zs); zs = BUILD_ZS(z, stencil[i]); @@ -1322,21 +1401,19 @@ read_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, } -/************************************************************************/ - void fxSetupDDSpanPointers(GLcontext *ctx) { if (ctx->Visual->RedBits == 5 && ctx->Visual->GreenBits == 6 && ctx->Visual->BlueBits == 5 && ctx->Visual->AlphaBits == 0) { - ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan; - ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan; - ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan; - ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels; - ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels; + ctx->Driver.WriteRGBASpan = write_R5G6B5_rgba_span; + ctx->Driver.WriteRGBSpan = write_R5G6B5_rgb_span; + ctx->Driver.WriteMonoRGBASpan = write_R5G6B5_mono_span; + ctx->Driver.WriteRGBAPixels = write_R5G6B5_pixels; + ctx->Driver.WriteMonoRGBAPixels = write_R5G6B5_mono_pixels; ctx->Driver.ReadRGBASpan = read_R5G6B5_span; - ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels; + ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels; } else if (ctx->Visual->RedBits == 8 && ctx->Visual->GreenBits == 8 && @@ -1345,10 +1422,10 @@ void fxSetupDDSpanPointers(GLcontext *ctx) ctx->Driver.WriteRGBASpan = write_R8G8B8A8_rgba_span; ctx->Driver.WriteRGBSpan = write_R8G8B8A8_rgb_span; ctx->Driver.WriteMonoRGBASpan = write_R8G8B8A8_mono_span; - ctx->Driver.WriteRGBAPixels = NULL; /* XXX TODO */ - ctx->Driver.WriteMonoRGBAPixels = NULL; /* XXX TODO */ + ctx->Driver.WriteRGBAPixels = write_R8G8B8A8_pixels; + ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8A8_mono_pixels; ctx->Driver.ReadRGBASpan = read_R8G8B8A8_span; - ctx->Driver.ReadRGBAPixels = NULL; /* XXX TODO */ + ctx->Driver.ReadRGBAPixels = read_R8G8B8A8_pixels; ctx->Driver.ReadStencilSpan = read_stencil_span; ctx->Driver.WriteStencilSpan = write_stencil_span; } @@ -1365,19 +1442,3 @@ void fxSetupDDSpanPointers(GLcontext *ctx) ctx->Driver.ReadCI32Span = NULL; ctx->Driver.ReadCI32Pixels = NULL; } - - - -#else - - -/* - * Need this to provide at least one external definition. - */ - -int gl_fx_dummy_function_span(void) -{ - return 0; -} - -#endif /* FX */ diff --git a/xc/extras/Mesa/src/FX/fxdrv.h b/xc/extras/Mesa/src/FX/fxdrv.h index e6693d1d8..e71c0d873 100644 --- a/xc/extras/Mesa/src/FX/fxdrv.h +++ b/xc/extras/Mesa/src/FX/fxdrv.h @@ -434,8 +434,6 @@ extern GLubyte FX_PixelToB[0x10000]; struct tfxMesaContext { - GuTexPalette glbPalette; - GLcontext *glCtx; /* the core Mesa context */ GLvisual *glVis; /* describes the color buffer */ GLframebuffer *glBuffer; /* the ancillary buffers */ @@ -456,6 +454,8 @@ struct tfxMesaContext { tfxUnitsState unitsState; tfxUnitsState restoreUnitsState; /* saved during multipass */ + GuTexPalette glbPalette; + GLuint tmu_source[FX_NUM_TMU]; GLuint tex_dest[MAX_TEXTURE_UNITS]; GLuint setupindex; @@ -514,9 +514,7 @@ struct tfxMesaContext { GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */ GLboolean emulateTwoTMUs; /* True if we present 2 tmu's to mesa. */ GLboolean haveAlphaBuffer; - GLboolean haveZBuffer; - GLboolean haveStencilBuffer; - GLboolean haveDoubleBuffer; + GLboolean haveHwStencil; GLboolean haveGlobalPaletteTexture; GLint swapInterval; GLint maxPendingSwapBuffers; diff --git a/xc/extras/Mesa/src/FX/fxsetup.c b/xc/extras/Mesa/src/FX/fxsetup.c index 3555e8986..599b8911e 100644 --- a/xc/extras/Mesa/src/FX/fxsetup.c +++ b/xc/extras/Mesa/src/FX/fxsetup.c @@ -63,15 +63,11 @@ static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj0, struct gl_texture_object *tObj1); static void fxSetupTexture_NoLock(GLcontext *ctx); -static void fxSetupTexture(GLcontext *ctx); -static void fxSetupBlend(GLcontext *ctx); -static void fxSetupDepthTest(GLcontext *ctx); -static void fxSetupScissor(GLcontext *ctx); -static void fxSetupCull(GLcontext *ctx); static void gl_print_fx_state_flags( const char *msg, GLuint flags); -/*static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);*/ static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint ); + + static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj) { tfxTexInfo *ti=fxTMGetTexInfo(tObj); @@ -1325,7 +1321,8 @@ static void fxSetupAlphaTest(GLcontext *ctx) /* * Evaluate all depth-test state and make the Glide calls. */ -static void fxSetupDepthTest(GLcontext *ctx) +static void +fxSetupDepthTest(GLcontext *ctx) { if (ctx->Depth.Test) { GrCmpFnc_t dfunc; @@ -1398,7 +1395,8 @@ fxConvertGLStencilOp(GLenum op) * This function is called just before any rendering is done. * It will validate the stencil parameters. */ -static void fxSetupStencilTest(GLcontext *ctx) +static void +fxSetupStencilTest(GLcontext *ctx) { if (ctx->Stencil.Enabled) { GrStencil_t sfail = fxConvertGLStencilOp(ctx->Stencil.FailFunc); |