diff options
Diffstat (limited to 'xc/extras/Mesa/src')
88 files changed, 4979 insertions, 1896 deletions
diff --git a/xc/extras/Mesa/src/FX/fxapi.c b/xc/extras/Mesa/src/FX/fxapi.c index 6aea93fbf..4beff2cfe 100644 --- a/xc/extras/Mesa/src/FX/fxapi.c +++ b/xc/extras/Mesa/src/FX/fxapi.c @@ -855,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"); @@ -915,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; } @@ -962,37 +961,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. */ GrVoodooConfig_t *voodoo; voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; - printf("nTexelfx %d\n", voodoo->nTexelfx); - printf("fbRam %d\n", voodoo->fbRam); - printf("fbiRev %d\n", voodoo->fbiRev); - - if (voodoo->nTexelfx == 2 && voodoo->fbiRev != 260) { - /* RGB pixel order (Voodoo3, but some Quantum3D models) */ - fxInitPixelTables(fxMesa, GL_FALSE); + 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 { - /* BGR pixel order on Voodoo1/2, or certain Quantum3D models */ - fxInitPixelTables(fxMesa, GL_TRUE); + 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"; + } + 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 +1055,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 +1090,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 +1265,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. */ @@ -1263,40 +1326,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 +1376,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 +1389,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 +1402,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 +1416,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 b5d700a74..d37943f0c 100644 --- a/xc/extras/Mesa/src/FX/fxdd.c +++ b/xc/extras/Mesa/src/FX/fxdd.c @@ -535,7 +535,7 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y, else { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GrLfbInfo_t info; - GLboolean result; + GLboolean result = GL_FALSE; BEGIN_BOARD_LOCK(); if (grLfbLock(GR_LFB_READ_ONLY, @@ -546,8 +546,12 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y, &info)) { const GLint winX = fxMesa->x_offset; const GLint winY = fxMesa->y_offset + fxMesa->height - 1; +#ifdef XF86DRI const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) - ? (fxMesa->screen_width) : (info.strideInBytes / 2); + ? (fxMesa->screen_width) : (info.strideInBytes / 2); +#else + const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ +#endif const GLushort *src = (const GLushort *) info.lfbPtr + (winY - y) * srcStride + (winX + x); GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, @@ -633,7 +637,6 @@ static GLboolean fxDDReadPixels( GLcontext *ctx, GLint x, GLint y, grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); } END_BOARD_LOCK(); - return result; } } @@ -693,7 +696,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name) } } /* now make the GL_RENDERER string */ - sprintf(buffer, "Mesa DRI %s 20000329", hardware); + sprintf(buffer, "Mesa DRI %s 20000420", hardware); return buffer; } case GL_VENDOR: diff --git a/xc/extras/Mesa/src/FX/fxddspan.c b/xc/extras/Mesa/src/FX/fxddspan.c index 89abdda95..c7479ebb7 100644 --- a/xc/extras/Mesa/src/FX/fxddspan.c +++ b/xc/extras/Mesa/src/FX/fxddspan.c @@ -99,7 +99,7 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) { if (dst_x<fxMesa->pClipRects[i].x1) { x=fxMesa->pClipRects[i].x1; - data=((char*)src_data)+srcElt*(dst_x-x); + data=((char*)src_data)+srcElt*(x - dst_x); w=src_width-(x-dst_x); } else { x=dst_x; @@ -324,6 +324,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, } +#if 0 static void fxDDReadRGBASpan(const GLcontext *ctx, GLuint n, GLint x, GLint y, GLubyte rgba[][4]) { @@ -332,6 +333,7 @@ static void fxDDReadRGBASpan(const GLcontext *ctx, GLuint i; GLint bottom=fxMesa->height+fxMesa->y_offset-1; + printf("read span %d, %d, %d\n", x,y,n); if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n"); } @@ -349,6 +351,66 @@ static void fxDDReadRGBASpan(const GLcontext *ctx, rgba[i][ACOMP] = 255; } } +#endif + + +/* + * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects + * since OpenGL says obscured pixels have undefined values. + */ +static void read_R5G6B5_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte rgba[][4]) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + GrLfbInfo_t info; + BEGIN_BOARD_LOCK(); + if (grLfbLock(GR_LFB_READ_ONLY, + fxMesa->currentFB, + GR_LFBWRITEMODE_ANY, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winX = fxMesa->x_offset; + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; +#ifdef XF86DRI + const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + ? (fxMesa->screen_width) : (info.strideInBytes / 2); +#else + const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ +#endif + const GLushort *data16 = (const GLushort *) info.lfbPtr + + (winY - y) * srcStride + + (winX + x); + const GLuint *data32 = (const GLuint *) data16; + GLuint i, j; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = j = 0; i < n; i += 2, j++) { + GLuint pixel = data32[j]; + GLuint pixel0 = pixel & 0xffff; + GLuint pixel1 = pixel >> 16; + rgba[i][RCOMP] = FX_PixelToR[pixel0]; + rgba[i][GCOMP] = FX_PixelToG[pixel0]; + rgba[i][BCOMP] = FX_PixelToB[pixel0]; + rgba[i][ACOMP] = 255; + rgba[i+1][RCOMP] = FX_PixelToR[pixel1]; + rgba[i+1][GCOMP] = FX_PixelToG[pixel1]; + rgba[i+1][BCOMP] = FX_PixelToB[pixel1]; + rgba[i+1][ACOMP] = 255; + } + if (extraPixel) { + GLushort pixel = data16[n]; + rgba[n][RCOMP] = FX_PixelToR[pixel]; + rgba[n][GCOMP] = FX_PixelToG[pixel]; + rgba[n][BCOMP] = FX_PixelToB[pixel]; + rgba[n][ACOMP] = 255; + } + + grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +} + /************************************************************************/ /***** Pixel functions *****/ @@ -539,7 +601,8 @@ void fxSetupDDSpanPointers(GLcontext *ctx) ctx->Driver.WriteCI32Pixels =NULL; ctx->Driver.WriteMonoCIPixels =NULL; - ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan; + /* ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan;*/ + ctx->Driver.ReadRGBASpan = read_R5G6B5_span; ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels; ctx->Driver.ReadCI32Span =NULL; diff --git a/xc/extras/Mesa/src/FX/fxddtex.c b/xc/extras/Mesa/src/FX/fxddtex.c index 0007167cc..55e0be6bf 100644 --- a/xc/extras/Mesa/src/FX/fxddtex.c +++ b/xc/extras/Mesa/src/FX/fxddtex.c @@ -332,7 +332,7 @@ void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj) fprintf(stderr,"fxmesa: fxDDTexDel(%d,%x)\n",tObj->Name,(GLuint)ti); } - if(!ti) + if (!ti) return; fxTMFreeTexture(fxMesa,tObj); @@ -343,77 +343,105 @@ void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj) ctx->NewState|=NEW_TEXTURING; } -void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj) + + +/* + * Convert gl_color_table table to Glide's format. + */ + +static void convertPalette(FxU32 data[256], const struct gl_color_table *table) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - int i; - FxU32 r,g,b,a; - tfxTexInfo *ti; + const GLubyte *tableUB = (const GLubyte *) table->Table; + GLint width = table->Size; + FxU32 r, g, b, a; + GLint i; - if(tObj) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDTexPalette(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData); - } + ASSERT(table->TableType == GL_UNSIGNED_BYTE); - if(tObj->Palette.Format!=GL_RGBA) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n"); -#endif - return; - } + switch (table->Format) { + case GL_INTENSITY: + for (i = 0; i < width; i++) { + r = tableUB[i]; + g = tableUB[i]; + b = tableUB[i]; + a = tableUB[i]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_LUMINANCE: + for (i = 0; i < width; i++) { + r = tableUB[i]; + g = tableUB[i]; + b = tableUB[i]; + a = 255; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_ALPHA: + for (i = 0; i < width; i++) { + r = g = b = 255; + a = tableUB[i]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_LUMINANCE_ALPHA: + for (i = 0; i < width; i++) { + r = g = b = tableUB[i*2+0]; + a = tableUB[i*2+1]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_RGB: + for (i = 0; i < width; i++) { + r = tableUB[i*3+0]; + g = tableUB[i*3+1]; + b = tableUB[i*3+2]; + a = 255; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_RGBA: + for (i = 0; i < width; i++) { + r = tableUB[i*4+0]; + g = tableUB[i*4+1]; + b = tableUB[i*4+2]; + a = tableUB[i*4+3]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + } +} - if(tObj->Palette.Size>256) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n"); -#endif - return; - } +void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + + if (tObj) { + /* per-texture palette */ + tfxTexInfo *ti; + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxDDTexPalette(%d,%x)\n", + tObj->Name,(GLuint)tObj->DriverData); + } if (!tObj->DriverData) tObj->DriverData=fxAllocTexObjData(fxMesa); - ti=fxTMGetTexInfo(tObj); - - for(i=0;i<tObj->Palette.Size;i++) { - r=tObj->Palette.Table[i*4]; - g=tObj->Palette.Table[i*4+1]; - b=tObj->Palette.Table[i*4+2]; - a=tObj->Palette.Table[i*4+3]; - ti->palette.data[i]=(a<<24)|(r<<16)|(g<<8)|b; - } - + convertPalette(ti->palette.data, &tObj->Palette); fxTexInvalidate(ctx,tObj); - } else { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDTexPalette(global)\n"); - } - if(ctx->Texture.Palette.Format!=GL_RGBA) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n"); -#endif - return; - } - - if(ctx->Texture.Palette.Size>256) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n"); -#endif - return; - } - - for(i=0;i<ctx->Texture.Palette.Size;i++) { - r=ctx->Texture.Palette.Table[i*4]; - g=ctx->Texture.Palette.Table[i*4+1]; - b=ctx->Texture.Palette.Table[i*4+2]; - a=ctx->Texture.Palette.Table[i*4+3]; - fxMesa->glbPalette.data[i]=(a<<24)|(r<<16)|(g<<8)|b; + } + else { + /* global texture palette */ + if (MESA_VERBOSE&VERBOSE_DRIVER) { + fprintf(stderr,"fxmesa: fxDDTexPalette(global)\n"); } - + convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette); fxMesa->new_state|=FX_NEW_TEXTURING; ctx->Driver.RenderStart = fxSetupFXUnits; } } + void fxDDTexUseGlbPalette(GLcontext *ctx, GLboolean state) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; diff --git a/xc/extras/Mesa/src/FX/fxdrv.h b/xc/extras/Mesa/src/FX/fxdrv.h index 64ac9ee49..924b4a164 100644 --- a/xc/extras/Mesa/src/FX/fxdrv.h +++ b/xc/extras/Mesa/src/FX/fxdrv.h @@ -187,9 +187,9 @@ typedef struct { } #if FX_USE_PARGB -#define GOURAUD2(v, c) { \ - GLubyte *col = c; \ - v->argb=MESACOLOR2PARGB(col); \ +#define GOURAUD2(v, c) { \ + GLubyte *col = c; \ + v->argb=MESACOLOR2PARGB(col); \ } #else #define GOURAUD2(v, c) { \ @@ -230,13 +230,13 @@ typedef struct { #define FX_UM_E0_MODULATE 0x00000002 #define FX_UM_E0_DECAL 0x00000004 #define FX_UM_E0_BLEND 0x00000008 -#define FX_UM_E0_ADD 0x00000010 +#define FX_UM_E0_ADD 0x00000010 #define FX_UM_E1_REPLACE 0x00000020 #define FX_UM_E1_MODULATE 0x00000040 #define FX_UM_E1_DECAL 0x00000080 #define FX_UM_E1_BLEND 0x00000100 -#define FX_UM_E1_ADD 0x00000200 +#define FX_UM_E1_ADD 0x00000200 #define FX_UM_E_ENVMODE 0x000003ff diff --git a/xc/extras/Mesa/src/FX/fxglidew.c b/xc/extras/Mesa/src/FX/fxglidew.c index 5d24e14ea..0303054bf 100644 --- a/xc/extras/Mesa/src/FX/fxglidew.c +++ b/xc/extras/Mesa/src/FX/fxglidew.c @@ -225,7 +225,7 @@ void FX_grGlideGetVersion(char *buf) void FX_grSstPerfStats(GrSstPerfStats_t *st) { - int n; + FxI32 n; grGet(GR_STATS_PIXELS_IN, 4, &n); st->pixelsIn = n; grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n); st->chromaFail = n; grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n); st->zFuncFail = n; diff --git a/xc/extras/Mesa/src/FX/fxpipeline.c b/xc/extras/Mesa/src/FX/fxpipeline.c index c77e21ffa..cf4c9ebbc 100644 --- a/xc/extras/Mesa/src/FX/fxpipeline.c +++ b/xc/extras/Mesa/src/FX/fxpipeline.c @@ -104,7 +104,7 @@ static void fxDDRenderVB( struct vertex_buffer *VB ) GLcontext *ctx = VB->ctx; fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; - if ((fxMesa->render_index & ~FX_FLAT) || + if ((fxMesa->render_index != 0) || ((ctx->Texture.ReallyEnabled & 0xf) && VB->TexCoordPtr[0]->size>2) || ((ctx->Texture.ReallyEnabled & 0xf0) && VB->TexCoordPtr[1]->size>2)) gl_render_vb( VB ); diff --git a/xc/extras/Mesa/src/FX/fxrender.c b/xc/extras/Mesa/src/FX/fxrender.c index 8ce4b0618..5935998f8 100644 --- a/xc/extras/Mesa/src/FX/fxrender.c +++ b/xc/extras/Mesa/src/FX/fxrender.c @@ -722,8 +722,8 @@ render_func **fxDDChooseRenderVBTables(GLcontext *ctx) return null_tables; switch (fxMesa->render_index) { - case FX_FLAT: - return fxDDRenderVBFlat_tables; +/* case FX_FLAT: */ +/* return fxDDRenderVBFlat_tables; */ case 0: return fxDDRenderVBSmooth_tables; default: diff --git a/xc/extras/Mesa/src/FX/fxsetup.c b/xc/extras/Mesa/src/FX/fxsetup.c index 9e00d152a..e8c75b7c4 100644 --- a/xc/extras/Mesa/src/FX/fxsetup.c +++ b/xc/extras/Mesa/src/FX/fxsetup.c @@ -183,7 +183,7 @@ static GLuint fxGetTexSetConfiguration(GLcontext *ctx, GLuint envmode=0; GLuint ifmt=0; - if((ctx->Light.ShadeModel==GL_SMOOTH) || + if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 || (ctx->Point.SmoothFlag) || (ctx->Line.SmoothFlag) || (ctx->Polygon.SmoothFlag)) @@ -191,11 +191,13 @@ static GLuint fxGetTexSetConfiguration(GLcontext *ctx, else unitsmode|=FX_UM_ALPHA_CONSTANT; - if(ctx->Light.ShadeModel==GL_SMOOTH) + if(ctx->Light.ShadeModel==GL_SMOOTH || 1) unitsmode|=FX_UM_COLOR_ITERATED; else unitsmode|=FX_UM_COLOR_CONSTANT; + + /* OpenGL Feeds Texture 0 into Texture 1 Glide Feeds Texture 1 into Texture 0 @@ -356,8 +358,8 @@ static void fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_obje FX_grTexClampMode_NoLock(GR_TMU1,ti->sClamp,ti->tClamp); FX_grTexFilterMode_NoLock(GR_TMU0,ti->minFilt,ti->maxFilt); FX_grTexFilterMode_NoLock(GR_TMU1,ti->minFilt,ti->maxFilt); - FX_grTexMipMapMode_NoLock(GR_TMU0,GR_MIPMAP_NEAREST,FXTRUE); - FX_grTexMipMapMode_NoLock(GR_TMU1,GR_MIPMAP_NEAREST,FXTRUE); + FX_grTexMipMapMode_NoLock(GR_TMU0,ti->mmMode,ti->LODblend); + FX_grTexMipMapMode_NoLock(GR_TMU1,ti->mmMode,ti->LODblend); FX_grTexSource_NoLock(GR_TMU0,ti->tm[FX_TMU0]->startAddr, GR_MIPMAPLEVELMASK_ODD,&(ti->info)); @@ -391,7 +393,7 @@ static void fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_obje } static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, - FxBool LODblend, FxBool negate) + FxBool LODblend) { if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxSelectSingleTMUSrc(%d,%d)\n",tmu,LODblend); @@ -414,45 +416,23 @@ static void fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, } else { if (tmu!=FX_TMU1) { - if (negate) - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL, - GR_COMBINE_FACTOR_ZERO, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE, FXFALSE); - else - FX_grTexCombine_NoLock(GR_TMU0, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU0, + GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, + FXFALSE,FXFALSE); if (fxMesa->haveTwoTMUs) { FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_ZERO, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_ZERO, - GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_ZERO, GR_COMBINE_FACTOR_NONE, FXFALSE,FXFALSE); } fxMesa->tmuSrc=FX_TMU0; } else { - if (negate) - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL, - GR_COMBINE_FACTOR_ZERO, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE, FXFALSE); - else - FX_grTexCombine_NoLock(GR_TMU1, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - GR_COMBINE_FUNCTION_LOCAL, - GR_COMBINE_FACTOR_NONE, - FXFALSE,FXFALSE); + FX_grTexCombine_NoLock(GR_TMU1, + GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, + GR_COMBINE_FUNCTION_LOCAL,GR_COMBINE_FACTOR_NONE, + FXFALSE,FXFALSE); /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */ @@ -490,23 +470,16 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) if (ti->whichTMU==FX_TMU_BOTH) tmu=FX_TMU0; else tmu=ti->whichTMU; - - if (fxMesa->tmuSrc!=tmu || - (unitsmode&FX_UM_E0_BLEND != - fxMesa->lastUnitsMode&FX_UM_E0_BLEND)) { - if (unitsmode&FX_UM_E0_BLEND) - fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend, GL_FALSE); - else - fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend, GL_FALSE); - } + if (fxMesa->tmuSrc!=tmu) + fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend); if(textureset==0 || !fxMesa->haveTwoTMUs) unitsmode=fxGetTexSetConfiguration(ctx,tObj,NULL); else unitsmode=fxGetTexSetConfiguration(ctx,NULL,tObj); - if(fxMesa->lastUnitsMode==unitsmode) - return; +/* if(fxMesa->lastUnitsMode==unitsmode) */ +/* return; */ fxMesa->lastUnitsMode=unitsmode; @@ -564,6 +537,7 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) FXFALSE); break; case GL_BLEND: +#if 0 FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER, GR_COMBINE_FACTOR_LOCAL, locala, @@ -581,10 +555,11 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) localc, GR_COMBINE_OTHER_TEXTURE, FXTRUE); -#if 0 - /* We're not enabling blending that requires multipass */ ctx->Driver.MultipassFunc = fxMultipassBlend; -#endif +#else + if (MESA_VERBOSE&VERBOSE_DRIVER) + fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n"); +#endif break; case GL_REPLACE: if((ifmt==GL_RGB) || (ifmt==GL_LUMINANCE)) @@ -614,9 +589,9 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) FXFALSE); break; default: -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: %x Texture.EnvMode not yet supported\n",ctx->Texture.Unit[textureset].EnvMode); -#endif + if (MESA_VERBOSE&VERBOSE_DRIVER) + fprintf(stderr, "fx Driver: %x Texture.EnvMode not yet supported\n", + ctx->Texture.Unit[textureset].EnvMode); break; } @@ -790,8 +765,8 @@ static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx) unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1); - if(fxMesa->lastUnitsMode==unitsmode) - return; +/* if(fxMesa->lastUnitsMode==unitsmode) */ +/* return; */ fxMesa->lastUnitsMode=unitsmode; @@ -1056,7 +1031,7 @@ static void fxSetupTextureNone_NoLock(GLcontext *ctx) fprintf(stderr,"fxmesa: fxSetupTextureNone(...)\n"); } - if((ctx->Light.ShadeModel==GL_SMOOTH) || + if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 || (ctx->Point.SmoothFlag) || (ctx->Line.SmoothFlag) || (ctx->Polygon.SmoothFlag)) @@ -1064,7 +1039,7 @@ static void fxSetupTextureNone_NoLock(GLcontext *ctx) else locala=GR_COMBINE_LOCAL_CONSTANT; - if(ctx->Light.ShadeModel==GL_SMOOTH) + if(ctx->Light.ShadeModel==GL_SMOOTH || 1) localc=GR_COMBINE_LOCAL_ITERATED; else localc=GR_COMBINE_LOCAL_CONSTANT; @@ -1542,8 +1517,6 @@ void fxSetScissorValues(GLcontext *ctx) static void fxSetupScissor(GLcontext *ctx) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - /* If we're not going to be setting the clip values in the CLIP_LOOP - then make a call to it here to set it once */ if (!fxMesa->needClip) { BEGIN_BOARD_LOCK(); fxSetScissorValues(ctx); diff --git a/xc/extras/Mesa/src/FX/fxtexman.c b/xc/extras/Mesa/src/FX/fxtexman.c index bc20fa10b..2ffaeadd7 100644 --- a/xc/extras/Mesa/src/FX/fxtexman.c +++ b/xc/extras/Mesa/src/FX/fxtexman.c @@ -146,10 +146,10 @@ static void fxTMUInit(fxMesaContext fxMesa, int tmu) end=FX_grTexMaxAddress(tmu); if(fxMesa->verbose) { - fprintf(stderr,"%s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1"); - fprintf(stderr," Lower texture memory address (%u)\n",(unsigned int)start); - fprintf(stderr," Higher texture memory address (%u)\n",(unsigned int)end); - fprintf(stderr," Splitting Texture memory in 2b blocks:\n"); + fprintf(stderr,"Voodoo %s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1"); + fprintf(stderr,"Voodoo Lower texture memory address (%u)\n",(unsigned int)start); + fprintf(stderr,"Voodoo Higher texture memory address (%u)\n",(unsigned int)end); + fprintf(stderr,"Voodoo Splitting Texture memory in 2b blocks:\n"); } fxMesa->freeTexMem[tmu]=end-start; @@ -162,7 +162,7 @@ static void fxTMUInit(fxMesaContext fxMesa, int tmu) else blockend=blockstart+FX_2MB_SPLIT; if(fxMesa->verbose) - fprintf(stderr," %07u-%07u\n", + fprintf(stderr,"Voodoo %07u-%07u\n", (unsigned int)blockstart,(unsigned int)blockend); tmn=fxTMNewRangeNode(fxMesa, blockstart, blockend); diff --git a/xc/extras/Mesa/src/FX/fxtritmp.h b/xc/extras/Mesa/src/FX/fxtritmp.h index 10bf5ca18..8e5da291f 100644 --- a/xc/extras/Mesa/src/FX/fxtritmp.h +++ b/xc/extras/Mesa/src/FX/fxtritmp.h @@ -66,7 +66,9 @@ static void TAG(fx_tri)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit; GLubyte (*color)[4] = VB->Color[facing]->data; if (IND & FX_FLAT) { - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); } else { GOURAUD2(v1,color[e1]); GOURAUD2(v2,color[e2]); @@ -103,7 +105,9 @@ static void TAG(fx_tri)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint } else if (IND & FX_FLAT) { GLubyte (*color)[4] = VB->Color[0]->data; - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); } if (IND & FX_FRONT_BACK) { @@ -168,7 +172,10 @@ static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit; GLubyte (*color)[4] = VB->Color[facing]->data; if (IND & FX_FLAT) { - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); + GOURAUD2(v4,color[pv]); } else { GOURAUD2(v1,color[e1]); GOURAUD2(v2,color[e2]); @@ -206,7 +213,10 @@ static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, } else if (IND & FX_FLAT) { GLubyte (*color)[4] = VB->Color[0]->data; - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); + GOURAUD2(v4,color[pv]); } if (IND & FX_FRONT_BACK) { diff --git a/xc/extras/Mesa/src/FX/fxvs_tmp.h b/xc/extras/Mesa/src/FX/fxvs_tmp.h index e3a30bf5d..d9001db5e 100644 --- a/xc/extras/Mesa/src/FX/fxvs_tmp.h +++ b/xc/extras/Mesa/src/FX/fxvs_tmp.h @@ -142,10 +142,39 @@ static void NAME(struct vertex_buffer *VB, GLuint start, GLuint end) DO_SETUP; } } - } else + } + else { for (;v!=vend;v+=16 INCR) { DO_SETUP; } + } + + if (ctx->FogMode == FOG_FRAGMENT && ctx->ProjectionMatrix.m[15] != 0.0F) { + /* need to compute W values for fogging purposes */ + const GLfloat m10 = ctx->ProjectionMatrix.m[10]; + const GLfloat m14 = ctx->ProjectionMatrix.m[14]; + const GLfloat v10 = ctx->Viewport.WindowMap.m[10]; + const GLfloat v14 = ctx->Viewport.WindowMap.m[14]; + GLfloat *v = gWin[start].f; + GLfloat *win = VB->Win.data[start]; + if (VB->ClipOrMask) { + GLubyte *clipmask = &VB->ClipMask[start]; + for (;v!=vend;v+=16,clipmask++, win+=4) { + if (*clipmask == 0) { + GLfloat zNDC = (win[2] - v14) / v10; + GLfloat zEye = (zNDC - m14) / m10; + v[OOWCOORD] = -1.0F / zEye; + } + } + } + else { + for (;v!=vend;v+=16, win+=4) { + GLfloat zNDC = (win[2] - v14) / v10; + GLfloat zEye = (zNDC - m14) / m10; + v[OOWCOORD] = -1.0F / zEye; + } + } + } /* rare - I hope */ FIXUP; diff --git a/xc/extras/Mesa/src/FX/fxvsetup.c b/xc/extras/Mesa/src/FX/fxvsetup.c index 78a311f25..c7c1218b4 100644 --- a/xc/extras/Mesa/src/FX/fxvsetup.c +++ b/xc/extras/Mesa/src/FX/fxvsetup.c @@ -341,12 +341,14 @@ void fxDDDoRasterSetup( struct vertex_buffer *VB ) GLcontext *ctx = VB->ctx; FX_DRIVER_DATA(VB)->last_vert = FX_DRIVER_DATA(VB)->verts + VB->Count; +#if 0 /* leaving this out fixes the Heretic2 stray polygon bug */ if ((ctx->IndirectTriangles & DD_SW_RASTERIZE) == DD_SW_RASTERIZE) { fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; fxMesa->setupdone = 0; return; } - +#endif + if (VB->Type == VB_CVA_PRECALC) fxDDPartialRasterSetup( VB ); else diff --git a/xc/extras/Mesa/src/X/fakeglx.c b/xc/extras/Mesa/src/X/fakeglx.c index 16fb2f622..deba5af3d 100644 --- a/xc/extras/Mesa/src/X/fakeglx.c +++ b/xc/extras/Mesa/src/X/fakeglx.c @@ -70,6 +70,7 @@ /* Silence compiler warnings */ +extern void Fake_glXDummyFunc( void ); void Fake_glXDummyFunc( void ) { (void) kernel8; @@ -226,7 +227,9 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint depth_size, GLint stencil_size, - GLint accum_size, GLint level ) + GLint accumRedSize, GLint accumGreenSize, + GLint accumBlueSize, GLint accumAlphaSize, + GLint level ) { GLboolean ximageFlag = GL_TRUE; XMesaVisual xmvis; @@ -269,7 +272,10 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, && (v->gl_visual->AlphaBits > 0) == alphaFlag && (v->gl_visual->DepthBits >= depth_size || depth_size == 0) && (v->gl_visual->StencilBits >= stencil_size || stencil_size == 0) - && (v->gl_visual->AccumBits >= accum_size || accum_size == 0)) { + && (v->gl_visual->AccumRedBits >= accumRedSize || accumRedSize == 0) + && (v->gl_visual->AccumGreenBits >= accumGreenSize || accumGreenSize == 0) + && (v->gl_visual->AccumBlueBits >= accumBlueSize || accumBlueSize == 0) + && (v->gl_visual->AccumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { /* now either compare XVisualInfo pointers or visual IDs */ if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) || (comparePointers && v->vishandle == vinfo)) { @@ -287,7 +293,10 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, stereoFlag, ximageFlag, - depth_size, stencil_size, accum_size, level ); + depth_size, stencil_size, + accumRedSize, accumBlueSize, + accumBlueSize, accumAlphaSize, 0, level, + GLX_NONE_EXT ); if (xmvis) { VisualTable[NumVisuals] = xmvis; NumVisuals++; @@ -299,6 +308,11 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, /* * Create a GLX visual from a regular XVisualInfo. + * This is called when Fake GLX is given an XVisualInfo which wasn't + * returned by glXChooseVisual. Since this is the first time we're + * considering this visual we'll take a guess at reasonable values + * for depth buffer size, stencil size, accum size, etc. + * This is the best we can do with a client-side emulation of GLX. */ static XMesaVisual create_glx_visual( Display *dpy, XVisualInfo *visinfo ) @@ -315,7 +329,7 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) GL_FALSE, /* stereo */ 0, /* depth bits */ 0, /* stencil bits */ - 0, /* accum bits */ + 0,0,0,0, /* accum bits */ vislevel /* level */ ); } @@ -328,9 +342,12 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) GL_FALSE, /* alpha */ GL_TRUE, /* double */ GL_FALSE, /* stereo */ - 8*sizeof(GLdepth), - 8*sizeof(GLstencil), - 8*sizeof(GLaccum), + DEFAULT_SOFTWARE_DEPTH_BITS, + 8 * sizeof(GLstencil), + 8 * sizeof(GLaccum), /* r */ + 8 * sizeof(GLaccum), /* g */ + 8 * sizeof(GLaccum), /* b */ + 8 * sizeof(GLaccum), /* a */ 0 /* level */ ); } @@ -860,11 +877,15 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) GLboolean stereo_flag = GL_FALSE; GLint depth_size = 0; GLint stencil_size = 0; - GLint accum_size = 0; + GLint accumRedSize = 0; + GLint accumGreenSize = 0; + GLint accumBlueSize = 0; + GLint accumAlphaSize = 0; int level = 0; int visual_type = DONT_CARE; int trans_type = DONT_CARE; int trans_value = DONT_CARE; + GLint caveat = DONT_CARE; parselist = list; @@ -927,13 +948,31 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) stencil_size = *parselist++; break; case GLX_ACCUM_RED_SIZE: + parselist++; + { + GLint size = *parselist++; + accumRedSize = MAX2( accumRedSize, size ); + } + break; case GLX_ACCUM_GREEN_SIZE: + parselist++; + { + GLint size = *parselist++; + accumGreenSize = MAX2( accumGreenSize, size ); + } + break; case GLX_ACCUM_BLUE_SIZE: + parselist++; + { + GLint size = *parselist++; + accumBlueSize = MAX2( accumBlueSize, size ); + } + break; case GLX_ACCUM_ALPHA_SIZE: parselist++; { GLint size = *parselist++; - accum_size = MAX2( accum_size, size ); + accumAlphaSize = MAX2( accumAlphaSize, size ); } break; @@ -961,6 +1000,14 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) parselist++; break; + /* + * GLX_EXT_visual_info extension + */ + case GLX_VISUAL_CAVEAT_EXT: + parselist++; + caveat = *parselist++; /* ignored for now */ + break; + case None: break; default: @@ -990,7 +1037,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) else { /* Get a color index visual */ vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); - accum_size = 0; + accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; } } else { @@ -1013,9 +1060,33 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) } if (vis) { + /* Note: we're not exactly obeying the glXChooseVisual rules here. + * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the + * largest depth buffer size, which is 32bits/value. However, we + * return 16 to maintain performance with earlier versions of Mesa. + */ + if (depth_size == 1) + depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; + else if (depth_size > 24) + depth_size = 31; + else if (depth_size > 16) + depth_size = 24; + /* we only support one size of stencil and accum buffers. */ + if (stencil_size > 0) + stencil_size = STENCIL_BITS; + if (accumRedSize > 0) + accumRedSize = ACCUM_BITS; + if (accumGreenSize > 0) + accumGreenSize = ACCUM_BITS; + if (accumBlueSize > 0) + accumBlueSize = ACCUM_BITS; + if (accumAlphaSize > 0) + accumAlphaSize = ACCUM_BITS; if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, - stereo_flag, - depth_size, stencil_size, accum_size, level )) + stereo_flag, depth_size, stencil_size, + accumRedSize, accumGreenSize, + accumBlueSize, accumAlphaSize, + level )) return NULL; } @@ -1227,6 +1298,7 @@ Fake_glXQueryExtension( Display *dpy, int *errorb, int *event ) } +extern void _kw_ungrab_all( Display *dpy ); void _kw_ungrab_all( Display *dpy ) { XUngrabPointer( dpy, CurrentTime ); @@ -1372,15 +1444,16 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, *value = glxvis->gl_visual->StencilBits; return 0; case GLX_ACCUM_RED_SIZE: + *value = glxvis->gl_visual->AccumRedBits; + return 0; case GLX_ACCUM_GREEN_SIZE: + *value = glxvis->gl_visual->AccumGreenBits; + return 0; case GLX_ACCUM_BLUE_SIZE: - *value = glxvis->gl_visual->AccumBits; + *value = glxvis->gl_visual->AccumBlueBits; return 0; case GLX_ACCUM_ALPHA_SIZE: - if (glxvis->gl_visual->AlphaBits > 0) - *value = glxvis->gl_visual->AccumBits; - else - *value = 0; + *value = glxvis->gl_visual->AccumAlphaBits; return 0; /* @@ -1438,6 +1511,17 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, return 0; /* + * GLX_EXT_visual_info extension + */ + case GLX_VISUAL_CAVEAT_EXT: + /* test for zero, just in case */ + if (glxvis->VisualCaveat > 0) + *value = glxvis->VisualCaveat; + else + *value = GLX_NONE_EXT; + return 0; + + /* * Extensions */ default: @@ -1472,10 +1556,10 @@ static const char *get_extensions( void ) #ifdef FX const char *fx = getenv("MESA_GLX_FX"); if (fx && fx[0] != 'd') { - return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address"; + return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address"; } #endif - return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address"; + return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address"; } @@ -1544,7 +1628,7 @@ Fake_glXGetClientString( Display *dpy, int name ) * GLX 1.3 and later */ -static GLXFBConfig +static GLXFBConfig * Fake_glXChooseFBConfig( Display *dpy, int screen, const int *attribList, int *nitems ) { @@ -1568,6 +1652,16 @@ Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, } +static GLXFBConfig * +Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) +{ + (void) dpy; + (void) screen; + (void) nelements; + return 0; +} + + static XVisualInfo * Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) { @@ -1745,6 +1839,7 @@ Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) extern void Fake_glXUseXFont( Font font, int first, int count, int listbase ); +extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); struct _glxapi_table *_mesa_GetGLXDispatchTable(void) { static struct _glxapi_table glx; diff --git a/xc/extras/Mesa/src/X/glxapi.c b/xc/extras/Mesa/src/X/glxapi.c index 5ee5d7419..85b81c900 100644 --- a/xc/extras/Mesa/src/X/glxapi.c +++ b/xc/extras/Mesa/src/X/glxapi.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -168,8 +168,7 @@ XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *list) } -void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, - unsigned long mask) +void glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask) { struct _glxapi_table *t = get_dispatch(dpy); if (!t) @@ -359,7 +358,7 @@ Display *glXGetCurrentDisplay(void) #ifdef _GLXAPI_VERSION_1_3 -GLXFBConfig glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems) +GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems) { struct _glxapi_table *t = get_dispatch(dpy); if (!t) @@ -446,6 +445,14 @@ int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *v } +GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements) +{ + struct _glxapi_table *t = get_dispatch(dpy); + if (!t) + return 0; + return (t->GetFBConfigs)(dpy, screen, nelements); +} + void glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask) { struct _glxapi_table *t = get_dispatch(dpy); diff --git a/xc/extras/Mesa/src/X/glxapi.h b/xc/extras/Mesa/src/X/glxapi.h index ae8433987..7d017dadc 100644 --- a/xc/extras/Mesa/src/X/glxapi.h +++ b/xc/extras/Mesa/src/X/glxapi.h @@ -83,7 +83,7 @@ struct _glxapi_table { #endif #ifdef _GLXAPI_VERSION_1_3 - GLXFBConfig (*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems); + GLXFBConfig *(*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems); GLXContext (*CreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct); GLXPbuffer (*CreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList); GLXPixmap (*CreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList); @@ -93,6 +93,7 @@ struct _glxapi_table { void (*DestroyWindow)(Display *dpy, GLXWindow window); /*GLXDrawable (*GetCurrentReadDrawable)(void);*/ int (*GetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value); + GLXFBConfig *(*GetFBConfigs)(Display *dpy, int screen, int *nelements); void (*GetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigned long *mask); XVisualInfo *(*GetVisualFromFBConfig)(Display *dpy, GLXFBConfig config); Bool (*MakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); diff --git a/xc/extras/Mesa/src/X/xmesa1.c b/xc/extras/Mesa/src/X/xmesa1.c index 4eb5cc82b..618475d1c 100644 --- a/xc/extras/Mesa/src/X/xmesa1.c +++ b/xc/extras/Mesa/src/X/xmesa1.c @@ -72,6 +72,11 @@ #endif +#ifndef GLX_NONE_EXT +#define GLX_NONE_EXT 0x8000 +#endif + + /* * Current X/Mesa context pointer: */ @@ -418,7 +423,7 @@ static void free_xmesa_buffer(int client, XMesaBuffer buffer) } -/* Copy X color table stuff from on XMesaBuffer to another. */ +/* Copy X color table stuff from one XMesaBuffer to another. */ static void copy_colortable_info(XMesaBuffer dst, const XMesaBuffer src) { MEMCPY(dst->color_table, src->color_table, sizeof(src->color_table)); @@ -1408,21 +1413,29 @@ unsigned long xmesa_color_to_pixel( XMesaContext xmesa, /* * Create a new X/Mesa visual. - * Input: display - the X display - * visinfo - the XVisualInfo - * rgb_flag - TRUE=RGB(A) mode, FALSE=CI mode - * alpha_flag - need alpha planes? - * db_flag - TRUE=double bufferd, FALSE=single - * stereo_flag - true/false - * ximage_flag - TRUE=use XImage for back buffer, FALSE=use Pixmap - * depth_size - requested min bits per depth buffer value - * stencil_size - requested min bits per stencil buffer value - * accum_size - requested min bits per accum buffer value (per channel) - * level - 0=normal, 1=overaly, -1=underlay, etc. - * Return: New XMesaVisual or NULL if something goes wrong + * Input: display - X11 display + * visinfo - an XVisualInfo pointer + * rgb_flag - GL_TRUE = RGB mode, + * GL_FALSE = color index mode + * alpha_flag - alpha buffer requested? + * db_flag - GL_TRUE = double-buffered, + * GL_FALSE = single buffered + * stereo_flag - stereo visual? + * ximage_flag - GL_TRUE = use an XImage for back buffer, + * GL_FALSE = use an off-screen pixmap for back buffer + * depth_size - requested bits/depth values, or zero + * stencil_size - requested bits/stencil values, or zero + * accum_red_size - requested bits/red accum values, or zero + * accum_green_size - requested bits/green accum values, or zero + * accum_blue_size - requested bits/blue accum values, or zero + * accum_alpha_size - requested bits/alpha accum values, or zero + * num_samples - number of samples/pixel if multisampling, or zero + * level - visual level, usually 0 + * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT + * Return; a new XMesaVisual or 0 if error. */ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, - XMesaVisualInfo visinfo, + XMesaVisualInfo visinfo, GLboolean rgb_flag, GLboolean alpha_flag, GLboolean db_flag, @@ -1430,8 +1443,13 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, GLboolean ximage_flag, GLint depth_size, GLint stencil_size, - GLint accum_size, - GLint level ) + GLint accum_red_size, + GLint accum_green_size, + GLint accum_blue_size, + GLint accum_alpha_size, + GLint num_samples, + GLint level, + GLint visualCaveat ) { char *gamma; XMesaVisual v; @@ -1506,6 +1524,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, v->ximage_flag = ximage_flag; v->level = level; + v->VisualCaveat = visualCaveat; (void) initialize_visual_and_buffer( 0, v, NULL, rgb_flag, 0, 0 ); @@ -1532,11 +1551,16 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, } } - v->gl_visual = gl_create_visual( rgb_flag, alpha_flag, db_flag, stereo_flag, - depth_size, stencil_size, accum_size, - v->index_bits, - red_bits, green_bits, - blue_bits, alpha_bits ); + v->gl_visual = _mesa_create_visual( rgb_flag, alpha_flag, + db_flag, stereo_flag, + red_bits, green_bits, + blue_bits, alpha_bits, + v->index_bits, + depth_size, + stencil_size, + accum_red_size, accum_green_size, + accum_blue_size, accum_alpha_size, + 0 ); if (!v->gl_visual) { #ifndef XFree86Server FREE(v->visinfo); @@ -1557,7 +1581,7 @@ void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v ) void XMesaDestroyVisual( XMesaVisual v ) { - gl_destroy_visual( v->gl_visual ); + _mesa_destroy_visual( v->gl_visual ); #ifndef XFree86Server FREE(v->visinfo); #endif @@ -1594,6 +1618,8 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list return NULL; } + gl_extensions_enable(c->gl_ctx, "GL_HP_occlusion_test"); + if (CHECK_BYTE_ORDER(v)) { c->swapbytes = GL_FALSE; } @@ -1750,7 +1776,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, b->gl_buffer = gl_create_framebuffer( v->gl_visual, v->gl_visual->DepthBits > 0, v->gl_visual->StencilBits > 0, - v->gl_visual->AccumBits > 0, + v->gl_visual->AccumRedBits > 0, v->gl_visual->AlphaBits > 0 ); if (!b->gl_buffer) { free_xmesa_buffer(client, b); @@ -1778,9 +1804,9 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, if (v->gl_visual->DBflag) { attribs[numAttribs++] = FXMESA_DOUBLEBUFFER; } - if (v->gl_visual->AccumBits > 0) { + if (v->gl_visual->AccumRedBits > 0) { attribs[numAttribs++] = FXMESA_ACCUM_SIZE; - attribs[numAttribs++] = v->gl_visual->AccumBits; + attribs[numAttribs++] = v->gl_visual->AccumRedBits; } if (v->gl_visual->StencilBits > 0) { attribs[numAttribs++] = FXMESA_STENCIL_SIZE; @@ -1897,7 +1923,9 @@ XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, b->gl_buffer = gl_create_framebuffer( v->gl_visual, v->gl_visual->DepthBits > 0, v->gl_visual->StencilBits > 0, - v->gl_visual->AccumBits > 0, + v->gl_visual->AccumRedBits + + v->gl_visual->AccumGreenBits + + v->gl_visual->AccumBlueBits > 0, v->gl_visual->AlphaBits > 0 ); if (!b->gl_buffer) { free_xmesa_buffer(client, b); diff --git a/xc/extras/Mesa/src/X/xmesa2.c b/xc/extras/Mesa/src/X/xmesa2.c index 3d56184b8..b02dc66d6 100644 --- a/xc/extras/Mesa/src/X/xmesa2.c +++ b/xc/extras/Mesa/src/X/xmesa2.c @@ -36,8 +36,12 @@ #include "drawpix.h" #include "mem.h" #include "state.h" +#include "depth.h" +#include "macros.h" +#include "vb.h" #include "types.h" #include "xmesaP.h" +#include "extensions.h" @@ -713,7 +717,7 @@ clear_16bit_ximage( GLcontext *ctx, GLboolean all, } -/* Optimized code provided by Nozomi Ytow <nozomi@biol.tsukuba.ac.jp> */ +/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */ static void clear_24bit_ximage( GLcontext *ctx, GLboolean all, GLint x, GLint y, GLint width, GLint height ) @@ -731,14 +735,31 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, } if (all) { - register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height; - register bgr_t *ptr3 = (bgr_t *) xmesa->xm_buffer->backimage->data; if (r==g && g==b) { /* same value for all three components (gray) */ - MEMSET(ptr3, r, 3 * n); + const GLint w3 = xmesa->xm_buffer->width * 3; + const GLint h = xmesa->xm_buffer->height; + GLint i; + for (i = 0; i < h; i++) { + bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i); + MEMSET(ptr3, r, w3); + } } else { /* the usual case */ + const GLint w = xmesa->xm_buffer->width; + const GLint h = xmesa->xm_buffer->height; + GLint i, j; + for (i = 0; i < h; i++) { + bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i); + for (j = 0; j < w; j++) { + ptr3->r = r; + ptr3->g = g; + ptr3->b = b; + ptr3++; + } + } +#if 0 /* this code doesn't work for all window widths */ register GLuint *ptr4 = (GLuint *) ptr3; register GLuint px; GLuint pixel4[3]; @@ -805,6 +826,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, case 0: break; } +#endif } } else { @@ -819,6 +841,17 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, } else { /* non-gray clear color */ + GLint i, j; + for (j = 0; j < height; j++) { + bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j ); + for (i = 0; i < width; i++) { + ptr3->r = r; + ptr3->g = g; + ptr3->b = b; + ptr3++; + } + } +#if 0 /* this code might not always (seems ptr3 always == ptr4) */ GLint j; GLuint pixel4[3]; pixel4[0] = clearPixel | (clearPixel << 24); @@ -889,6 +922,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, break; } } +#endif } } } @@ -2342,9 +2376,24 @@ static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS ) } else { /* draw all pixels */ - for (i=0;i<n;i++) { - ptr[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ); +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2) { + GLuint p0, p1; + p0 = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); + p1 = PACK_5R6G5B(rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP]); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + ptr[n] = PACK_5R6G5B(rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]); + } +#else + for (i = 0; i < n; i++) { + ptr[i] = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); } +#endif } } @@ -2366,9 +2415,24 @@ static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS ) } else { /* draw all pixels */ - for (i=0;i<n;i++,x++) { - PACK_TRUEDITHER( ptr[i], x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ); +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2, x += 2) { + GLuint p0, p1; + PACK_TRUEDITHER( p0, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ); + PACK_TRUEDITHER( p1, x+1, y, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] ); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + PACK_TRUEDITHER( ptr[n], x+n, y, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]); } +#else + for (i = 0; i < n; i++, x++) { + PACK_TRUEDITHER( ptr[i], x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); + } +#endif } } @@ -2390,9 +2454,24 @@ static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS ) } else { /* draw all pixels */ +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2) { + GLuint p0, p1; + p0 = PACK_5R6G5B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]); + p1 = PACK_5R6G5B(rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP]); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + ptr[n] = PACK_5R6G5B(rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]); + } +#else for (i=0;i<n;i++) { ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ); } +#endif } } @@ -2414,9 +2493,24 @@ static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS ) } else { /* draw all pixels */ +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2, x += 2) { + GLuint p0, p1; + PACK_TRUEDITHER( p0, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ); + PACK_TRUEDITHER( p1, x+1, y, rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP] ); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + PACK_TRUEDITHER( ptr[n], x+n, y, rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]); + } +#else for (i=0;i<n;i++,x++) { PACK_TRUEDITHER( ptr[i], x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ); } +#endif } } @@ -4280,7 +4374,6 @@ static void read_color_span( const GLcontext *ctx, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaBuffer source; - register GLuint i; if (xmesa->use_read_buffer) source = xmesa->xm_read_buffer; @@ -4288,6 +4381,7 @@ static void read_color_span( const GLcontext *ctx, source = xmesa->xm_buffer; if (source->buffer) { + /* Read from Pixmap or Window */ XMesaImage *span = NULL; int error; #ifdef XFree86Server @@ -4307,18 +4401,17 @@ static void read_color_span( const GLcontext *ctx, switch (xmesa->pixelformat) { case PF_TRUECOLOR: case PF_TRUEDITHER: - case PF_5R6G5B: - case PF_DITHER_5R6G5B: { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; unsigned long rMask = GET_REDMASK(xmesa->xm_visual); unsigned long gMask = GET_GREENMASK(xmesa->xm_visual); unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual); - GLubyte *pixelToR = xmesa->xm_visual->PixelToR; - GLubyte *pixelToG = xmesa->xm_visual->PixelToG; - GLubyte *pixelToB = xmesa->xm_visual->PixelToB; GLint rShift = xmesa->xm_visual->rshift; GLint gShift = xmesa->xm_visual->gshift; GLint bShift = xmesa->xm_visual->bshift; + GLuint i; for (i=0;i<n;i++) { unsigned long p; p = XMesaGetPixel( span, i, 0 ); @@ -4329,9 +4422,31 @@ static void read_color_span( const GLcontext *ctx, } } break; + case PF_5R6G5B: + case PF_DITHER_5R6G5B: + { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; + GLuint i; + for (i=0;i<n;i++) { + unsigned long p = XMesaGetPixel( span, i, 0 ); + /* fast, but not quite accurate + rgba[i][RCOMP] = ((p >> 8) & 0xf8); + rgba[i][GCOMP] = ((p >> 3) & 0xfc); + rgba[i][BCOMP] = ((p << 3) & 0xff); + */ + rgba[i][RCOMP] = pixelToR[p >> 11]; + rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f]; + rgba[i][BCOMP] = pixelToB[p & 0x1f]; + rgba[i][ACOMP] = 255; + } + } + break; case PF_8A8B8G8R: { - GLuint *ptr4 = (GLuint *) span->data; + const GLuint *ptr4 = (GLuint *) span->data; + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff); @@ -4343,7 +4458,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B: { - GLuint *ptr4 = (GLuint *) span->data; + const GLuint *ptr4 = (GLuint *) span->data; + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff); @@ -4355,7 +4471,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B24: { - bgr_t *ptr3 = (bgr_t *) span->data; + const bgr_t *ptr3 = (bgr_t *) span->data; + GLuint i; for (i=0;i<n;i++) { rgba[i][RCOMP] = ptr3[i].r; rgba[i][GCOMP] = ptr3[i].g; @@ -4367,6 +4484,7 @@ static void read_color_span( const GLcontext *ctx, case PF_HPCR: { GLubyte *ptr1 = (GLubyte *) span->data; + GLuint i; for (i=0;i<n;i++) { GLubyte p = *ptr1++; rgba[i][RCOMP] = p & 0xE0; @@ -4384,7 +4502,8 @@ static void read_color_span( const GLcontext *ctx, GLubyte *gTable = source->pixel_to_g; GLubyte *bTable = source->pixel_to_b; if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) { - GLubyte *ptr1 = (GLubyte *) span->data; + const GLubyte *ptr1 = (GLubyte *) span->data; + GLuint i; for (i=0;i<n;i++) { unsigned long p = *ptr1++; rgba[i][RCOMP] = rTable[p]; @@ -4394,9 +4513,9 @@ static void read_color_span( const GLcontext *ctx, } } else { + GLuint i; for (i=0;i<n;i++) { - unsigned long p; - p = XMesaGetPixel( span, i, 0 ); + unsigned long p = XMesaGetPixel( span, i, 0 ); rgba[i][RCOMP] = rTable[p]; rgba[i][GCOMP] = gTable[p]; rgba[i][BCOMP] = bTable[p]; @@ -4408,6 +4527,7 @@ static void read_color_span( const GLcontext *ctx, case PF_1BIT: { int bitFlip = xmesa->xm_visual->bitFlip; + GLuint i; for (i=0;i<n;i++) { unsigned long p; p = XMesaGetPixel( span, i, 0 ) ^ bitFlip; @@ -4425,6 +4545,7 @@ static void read_color_span( const GLcontext *ctx, } else { /* return black pixels */ + GLuint i; for (i=0;i<n;i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = 0; } @@ -4434,22 +4555,22 @@ static void read_color_span( const GLcontext *ctx, } } else if (source->backimage) { + /* Read from XImage back buffer */ switch (xmesa->pixelformat) { case PF_TRUECOLOR: case PF_TRUEDITHER: - case PF_5R6G5B: - case PF_DITHER_5R6G5B: { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; unsigned long rMask = GET_REDMASK(xmesa->xm_visual); unsigned long gMask = GET_GREENMASK(xmesa->xm_visual); unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual); - GLubyte *pixelToR = xmesa->xm_visual->PixelToR; - GLubyte *pixelToG = xmesa->xm_visual->PixelToG; - GLubyte *pixelToB = xmesa->xm_visual->PixelToB; GLint rShift = xmesa->xm_visual->rshift; GLint gShift = xmesa->xm_visual->gshift; GLint bShift = xmesa->xm_visual->bshift; XMesaImage *img = source->backimage; + GLuint i; y = FLIP(source, y); for (i=0;i<n;i++) { unsigned long p; @@ -4461,9 +4582,58 @@ static void read_color_span( const GLcontext *ctx, } } break; + case PF_5R6G5B: + case PF_DITHER_5R6G5B: + { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; + const GLushort *ptr2 = PIXELADDR2( source, x, y ); + const GLuint *ptr4 = (const GLuint *) ptr2; + GLuint i; +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2) { + const GLuint p = *ptr4++; + const GLuint p0 = p & 0xffff; + const GLuint p1 = p >> 16; + /* fast, but not quite accurate + rgba[i][RCOMP] = ((p >> 8) & 0xf8); + rgba[i][GCOMP] = ((p >> 3) & 0xfc); + rgba[i][BCOMP] = ((p << 3) & 0xff); + */ + rgba[i][RCOMP] = pixelToR[p0 >> 11]; + rgba[i][GCOMP] = pixelToG[(p0 >> 5) & 0x3f]; + rgba[i][BCOMP] = pixelToB[p0 & 0x1f]; + rgba[i][ACOMP] = 255; + rgba[i+1][RCOMP] = pixelToR[p1 >> 11]; + rgba[i+1][GCOMP] = pixelToG[(p1 >> 5) & 0x3f]; + rgba[i+1][BCOMP] = pixelToB[p1 & 0x1f]; + rgba[i+1][ACOMP] = 255; + } + if (extraPixel) { + GLushort p = ptr2[n]; + rgba[n][RCOMP] = pixelToR[p >> 11]; + rgba[n][GCOMP] = pixelToG[(p >> 5) & 0x3f]; + rgba[n][BCOMP] = pixelToB[p & 0x1f]; + rgba[n][ACOMP] = 255; + } +#else + for (i = 0; i < n; i++) { + const GLushort p = ptr2[i]; + rgba[i][RCOMP] = pixelToR[p >> 11]; + rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f]; + rgba[i][BCOMP] = pixelToB[p & 0x1f]; + rgba[i][ACOMP] = 255; + } +#endif + } + break; case PF_8A8B8G8R: { - GLuint *ptr4 = PIXELADDR4( source, x, y ); + const GLuint *ptr4 = PIXELADDR4( source, x, y ); + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff); @@ -4475,7 +4645,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B: { - GLuint *ptr4 = PIXELADDR4( source, x, y ); + const GLuint *ptr4 = PIXELADDR4( source, x, y ); + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff); @@ -4487,7 +4658,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B24: { - bgr_t *ptr3 = PIXELADDR3( source, x, y ); + const bgr_t *ptr3 = PIXELADDR3( source, x, y ); + GLuint i; for (i=0;i<n;i++) { rgba[i][RCOMP] = ptr3[i].r; rgba[i][GCOMP] = ptr3[i].g; @@ -4498,7 +4670,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_HPCR: { - GLubyte *ptr1 = PIXELADDR1( source, x, y ); + const GLubyte *ptr1 = PIXELADDR1( source, x, y ); + GLuint i; for (i=0;i<n;i++) { GLubyte p = *ptr1++; rgba[i][RCOMP] = p & 0xE0; @@ -4512,11 +4685,12 @@ static void read_color_span( const GLcontext *ctx, case PF_LOOKUP: case PF_GRAYSCALE: { - GLubyte *rTable = source->pixel_to_r; - GLubyte *gTable = source->pixel_to_g; - GLubyte *bTable = source->pixel_to_b; + const GLubyte *rTable = source->pixel_to_r; + const GLubyte *gTable = source->pixel_to_g; + const GLubyte *bTable = source->pixel_to_b; if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) { GLubyte *ptr1 = PIXELADDR1( source, x, y ); + GLuint i; for (i=0;i<n;i++) { unsigned long p = *ptr1++; rgba[i][RCOMP] = rTable[p]; @@ -4527,10 +4701,10 @@ static void read_color_span( const GLcontext *ctx, } else { XMesaImage *img = source->backimage; + GLuint i; y = FLIP(source, y); for (i=0;i<n;i++,x++) { - unsigned long p; - p = XMesaGetPixel( img, x, y ); + unsigned long p = XMesaGetPixel( img, x, y ); rgba[i][RCOMP] = rTable[p]; rgba[i][GCOMP] = gTable[p]; rgba[i][BCOMP] = bTable[p]; @@ -4543,6 +4717,7 @@ static void read_color_span( const GLcontext *ctx, { XMesaImage *img = source->backimage; int bitFlip = xmesa->xm_visual->bitFlip; + GLuint i; y = FLIP(source, y); for (i=0;i<n;i++,x++) { unsigned long p; @@ -4936,7 +5111,6 @@ static const GLubyte *get_string( GLcontext *ctx, GLenum name ) } - static void update_span_funcs( GLcontext *ctx ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; diff --git a/xc/extras/Mesa/src/X/xmesaP.h b/xc/extras/Mesa/src/X/xmesaP.h index 9b79f4314..bba11808e 100644 --- a/xc/extras/Mesa/src/X/xmesaP.h +++ b/xc/extras/Mesa/src/X/xmesaP.h @@ -85,6 +85,7 @@ struct xmesa_visual { GLint BitsPerPixel; /* True bits per pixel for XImages */ GLint level; /* 0=normal, 1=overlay, etc */ + GLint VisualCaveat; /* for GLX_EXT_visual_rating extension */ GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */ diff --git a/xc/extras/Mesa/src/X86/assyntax.h b/xc/extras/Mesa/src/X86/assyntax.h index 43164d907..2a1034870 100644 --- a/xc/extras/Mesa/src/X86/assyntax.h +++ b/xc/extras/Mesa/src/X86/assyntax.h @@ -243,10 +243,7 @@ #endif /* ACK_ASSEMBLER */ -#if (defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) \ - || (defined(linux) || defined(__OS2ELF__)) && defined(__ELF__) \ - || defined(__FreeBSD__) && __FreeBSD__ >= 3) \ - || (defined(__NetBSD__) && defined(__ELF__)) +#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) #define GLNAME(a) a #else #define GLNAME(a) CONCAT(_,a) @@ -851,6 +848,8 @@ #define P_XMM6 xmm6 #define P_XMM7 xmm7 +#define CONCAT(x, y) x ## y + #if defined(NASM_ASSEMBLER) #define ST(n) st ## n diff --git a/xc/extras/Mesa/src/X86/x86.c b/xc/extras/Mesa/src/X86/x86.c index 223cf61c8..d145810c2 100644 --- a/xc/extras/Mesa/src/X86/x86.c +++ b/xc/extras/Mesa/src/X86/x86.c @@ -39,6 +39,7 @@ #include "xform.h" #include "x86.h" +#ifdef USE_X86_ASM extern void _ASMAPI gl_v16_x86_cliptest_points4(GLfloat *first_vert, GLfloat *last_vert, GLubyte *or_mask, @@ -51,7 +52,7 @@ extern void _ASMAPI gl_v16_x86_general_xform(GLfloat *dest, const GLfloat *src, GLuint src_stride, GLuint count); - +#endif #define XFORM_ARGS GLvector4f *to_vec, \ @@ -110,6 +111,7 @@ void gl_init_x86_asm_transforms( void ) ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 3, masked ) ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 4, masked ) + /* XXX this function has been found to cause FP overflow exceptions */ gl_clip_tab[4] = gl_x86_cliptest_points4; #ifdef DEBUG diff --git a/xc/extras/Mesa/src/aatriangle.c b/xc/extras/Mesa/src/aatriangle.c index 28a1952b5..cb6adcd6f 100644 --- a/xc/extras/Mesa/src/aatriangle.c +++ b/xc/extras/Mesa/src/aatriangle.c @@ -44,7 +44,7 @@ * Compute coefficients of a plane using the X,Y coords of the v0, v1, v2 * vertices and the given Z values. */ -static void +static INLINE void compute_plane(const GLfloat v0[], const GLfloat v1[], const GLfloat v2[], GLfloat z0, GLfloat z1, GLfloat z2, GLfloat plane[4]) { @@ -71,7 +71,7 @@ compute_plane(const GLfloat v0[], const GLfloat v1[], const GLfloat v2[], /* * Compute coefficients of a plane with a constant Z value. */ -static void +static INLINE void constant_plane(GLfloat value, GLfloat plane[4]) { plane[0] = 0.0; @@ -93,7 +93,7 @@ do { \ /* * Solve plane equation for Z at (X,Y). */ -static GLfloat +static INLINE GLfloat solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) { GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; @@ -108,7 +108,7 @@ solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) /* * Return 1 / solve_plane(). */ -static GLfloat +static INLINE GLfloat solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4]) { GLfloat z = -plane[2] / (plane[3] + plane[0] * x + plane[1] * y); @@ -120,7 +120,7 @@ solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4]) /* * Solve plane and return clamped GLubyte value. */ -static GLubyte +static INLINE GLubyte solve_plane_0_255(GLfloat x, GLfloat y, const GLfloat plane[4]) { GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2] + 0.5F; @@ -323,7 +323,7 @@ index_aa_tri(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv) /* * Compute mipmap level of detail. */ -static GLfloat +static INLINE GLfloat compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4], GLfloat invQ, GLfloat width, GLfloat height) { diff --git a/xc/extras/Mesa/src/aatritemp.h b/xc/extras/Mesa/src/aatritemp.h index 94727b1a4..976ee9689 100644 --- a/xc/extras/Mesa/src/aatritemp.h +++ b/xc/extras/Mesa/src/aatritemp.h @@ -124,6 +124,10 @@ return; } +#ifndef DO_OCCLUSION_TEST + ctx->OcclusionResult = GL_TRUE; +#endif + /* plane setup */ #ifdef DO_Z compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane); @@ -480,3 +484,7 @@ #ifdef DO_STUV1 #undef DO_STUV1 #endif + +#ifdef DO_OCCLUSION_TEST +#undef DO_OCCLUSION_TEST +#endif diff --git a/xc/extras/Mesa/src/accum.c b/xc/extras/Mesa/src/accum.c index e4e7cfec8..28f92a2d3 100644 --- a/xc/extras/Mesa/src/accum.c +++ b/xc/extras/Mesa/src/accum.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -144,7 +144,7 @@ _mesa_Accum( GLenum op, GLfloat value ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glAccum"); - if (ctx->Visual->AccumBits == 0 || ctx->DrawBuffer != ctx->ReadBuffer) { + if (ctx->Visual->AccumRedBits == 0 || ctx->DrawBuffer != ctx->ReadBuffer) { gl_error(ctx, GL_INVALID_OPERATION, "glAccum"); return; } @@ -374,7 +374,7 @@ _mesa_Accum( GLenum op, GLfloat value ) rgba[i][ACOMP] = multTable[acc[i4+3]]; } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, width, xpos, ypos, rgba ); + _mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba ); } (*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos, (const GLubyte (*)[4])rgba, NULL ); @@ -401,7 +401,7 @@ _mesa_Accum( GLenum op, GLfloat value ) rgba[i][ACOMP] = CLAMP( a, 0, iChanMax ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, width, xpos, ypos, rgba ); + _mesa_mask_rgba_span( ctx, width, xpos, ypos, rgba ); } (*ctx->Driver.WriteRGBASpan)( ctx, width, xpos, ypos, (const GLubyte (*)[4])rgba, NULL ); @@ -426,7 +426,7 @@ _mesa_clear_accum_buffer( GLcontext *ctx ) GLuint buffersize; GLfloat acc_scale; - if (ctx->Visual->AccumBits==0) { + if (ctx->Visual->AccumRedBits==0) { /* No accumulation buffer! */ return; } @@ -486,7 +486,7 @@ _mesa_clear_accum_buffer( GLcontext *ctx ) ctx->Accum.ClearColor[2]==0.0 && ctx->Accum.ClearColor[3]==0.0) { /* Black */ - MEMSET( ctx->DrawBuffer->Accum, 0, buffersize * 4 * sizeof(GLaccum) ); + BZERO( ctx->DrawBuffer->Accum, buffersize * 4 * sizeof(GLaccum) ); } else { /* Not black */ diff --git a/xc/extras/Mesa/src/alphabuf.c b/xc/extras/Mesa/src/alphabuf.c index 50bc80d4b..ab65a71dc 100644 --- a/xc/extras/Mesa/src/alphabuf.c +++ b/xc/extras/Mesa/src/alphabuf.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -122,7 +122,8 @@ alloc_alpha_buffers( GLcontext *ctx, GLframebuffer *buf ) /* * Allocate a new front and back alpha buffer. */ -void gl_alloc_alpha_buffers( GLcontext *ctx ) +void +_mesa_alloc_alpha_buffers( GLcontext *ctx ) { alloc_alpha_buffers( ctx, ctx->DrawBuffer ); if (ctx->ReadBuffer != ctx->DrawBuffer) { @@ -134,7 +135,8 @@ void gl_alloc_alpha_buffers( GLcontext *ctx ) /* * Clear all the alpha buffers */ -void gl_clear_alpha_buffers( GLcontext *ctx ) +void +_mesa_clear_alpha_buffers( GLcontext *ctx ) { const GLubyte aclear = (GLint) (ctx->Color.ClearColor[3] * 255.0F); GLuint bufferBit; @@ -183,8 +185,9 @@ void gl_clear_alpha_buffers( GLcontext *ctx ) -void gl_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - CONST GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + CONST GLubyte rgba[][4], const GLubyte mask[] ) { GLubyte *aptr = ALPHA_DRAW_ADDR( x, y ); GLuint i; @@ -205,8 +208,9 @@ void gl_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, } -void gl_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - GLubyte alpha, const GLubyte mask[] ) +void +_mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte alpha, const GLubyte mask[] ) { GLubyte *aptr = ALPHA_DRAW_ADDR( x, y ); GLuint i; @@ -227,9 +231,10 @@ void gl_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, } -void gl_write_alpha_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - CONST GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_write_alpha_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[] ) { GLuint i; @@ -250,9 +255,10 @@ void gl_write_alpha_pixels( GLcontext *ctx, } -void gl_write_mono_alpha_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte alpha, const GLubyte mask[] ) +void +_mesa_write_mono_alpha_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte alpha, const GLubyte mask[] ) { GLuint i; @@ -274,8 +280,9 @@ void gl_write_mono_alpha_pixels( GLcontext *ctx, -void gl_read_alpha_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLubyte rgba[][4] ) +void +_mesa_read_alpha_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte rgba[][4] ) { GLubyte *aptr = ALPHA_READ_ADDR( x, y ); GLuint i; @@ -285,9 +292,10 @@ void gl_read_alpha_span( GLcontext *ctx, } -void gl_read_alpha_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_read_alpha_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ) { GLuint i; for (i=0;i<n;i++) { diff --git a/xc/extras/Mesa/src/alphabuf.h b/xc/extras/Mesa/src/alphabuf.h index 260b1c910..22f4b253e 100644 --- a/xc/extras/Mesa/src/alphabuf.h +++ b/xc/extras/Mesa/src/alphabuf.h @@ -31,42 +31,49 @@ #include "types.h" -extern void gl_alloc_alpha_buffers( GLcontext *ctx ); +extern void +_mesa_alloc_alpha_buffers( GLcontext *ctx ); -extern void gl_clear_alpha_buffers( GLcontext *ctx ); +extern void +_mesa_clear_alpha_buffers( GLcontext *ctx ); -extern void gl_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - CONST GLubyte rgba[][4], const GLubyte mask[] ); +extern void +_mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + CONST GLubyte rgba[][4], const GLubyte mask[] ); -extern void gl_write_mono_alpha_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte alpha, const GLubyte mask[] ); +extern void +_mesa_write_mono_alpha_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte alpha, const GLubyte mask[] ); -extern void gl_write_alpha_pixels( GLcontext* ctx, - GLuint n, const GLint x[], const GLint y[], - CONST GLubyte rgba[][4], - const GLubyte mask[] ); +extern void +_mesa_write_alpha_pixels( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], + const GLubyte mask[] ); -extern void gl_write_mono_alpha_pixels( GLcontext* ctx, - GLuint n, const GLint x[], - const GLint y[], GLubyte alpha, - const GLubyte mask[] ); +extern void +_mesa_write_mono_alpha_pixels( GLcontext* ctx, + GLuint n, const GLint x[], + const GLint y[], GLubyte alpha, + const GLubyte mask[] ); -extern void gl_read_alpha_span( GLcontext* ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4] ); +extern void +_mesa_read_alpha_span( GLcontext* ctx, + GLuint n, GLint x, GLint y, GLubyte rgba[][4] ); -extern void gl_read_alpha_pixels( GLcontext* ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ); +extern void +_mesa_read_alpha_pixels( GLcontext* ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ); #endif diff --git a/xc/extras/Mesa/src/attrib.c b/xc/extras/Mesa/src/attrib.c index 8ff30b023..d4f765c3f 100644 --- a/xc/extras/Mesa/src/attrib.c +++ b/xc/extras/Mesa/src/attrib.c @@ -176,6 +176,8 @@ _mesa_PushAttrib(GLbitfield mask) attr->Lighting = ctx->Light.Enabled; attr->LineSmooth = ctx->Line.SmoothFlag; attr->LineStipple = ctx->Line.StippleFlag; + attr->Histogram = ctx->Pixel.HistogramEnabled; + attr->MinMax = ctx->Pixel.MinMaxEnabled; attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; attr->Map1Color4 = ctx->Eval.Map1Color4; @@ -197,6 +199,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; attr->Normalize = ctx->Transform.Normalize; + attr->PixelTexture = ctx->Pixel.PixelTextureEnabled; attr->PointSmooth = ctx->Point.SmoothFlag; attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; @@ -530,6 +533,7 @@ _mesa_PopAttrib(void) TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, GL_MAP2_VERTEX_4); TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, GL_RESCALE_NORMAL_EXT); + TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture, GL_POINT_SMOOTH); TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, GL_POINT_SMOOTH); TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, GL_POLYGON_OFFSET_POINT); TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, GL_POLYGON_OFFSET_LINE); diff --git a/xc/extras/Mesa/src/bitmap.c b/xc/extras/Mesa/src/bitmap.c index d729b5436..642bc7d33 100644 --- a/xc/extras/Mesa/src/bitmap.c +++ b/xc/extras/Mesa/src/bitmap.c @@ -167,6 +167,8 @@ _mesa_Bitmap( GLsizei width, GLsizei height, gl_reduced_prim_change( ctx, GL_BITMAP ); } + ctx->OcclusionResult = GL_TRUE; + if (ctx->Driver.Bitmap) { /* let device driver try to render the bitmap */ completed = (*ctx->Driver.Bitmap)( ctx, x, y, width, height, diff --git a/xc/extras/Mesa/src/blend.c b/xc/extras/Mesa/src/blend.c index ab06b695b..86edbd34a 100644 --- a/xc/extras/Mesa/src/blend.c +++ b/xc/extras/Mesa/src/blend.c @@ -825,7 +825,7 @@ _mesa_blend_pixels( GLcontext *ctx, /* Read pixels from current color buffer */ (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_read_alpha_pixels( ctx, n, x, y, dest, mask ); + _mesa_read_alpha_pixels( ctx, n, x, y, dest, mask ); } if (!ctx->Color.BlendFunc) diff --git a/xc/extras/Mesa/src/buffers.c b/xc/extras/Mesa/src/buffers.c index 7bfcc7cfa..a99110ab6 100644 --- a/xc/extras/Mesa/src/buffers.c +++ b/xc/extras/Mesa/src/buffers.c @@ -109,7 +109,7 @@ clear_color_buffer_with_masking( GLcontext *ctx ) rgba[j][BCOMP] = b; rgba[j][ACOMP] = a; } - gl_mask_rgba_span( ctx, width, x, y + i, rgba ); + _mesa_mask_rgba_span( ctx, width, x, y + i, rgba ); (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y + i, (CONST GLubyte (*)[4])rgba, NULL ); } @@ -124,7 +124,7 @@ clear_color_buffer_with_masking( GLcontext *ctx ) for (j=0;j<width;j++) { span[j] = ctx->Color.ClearIndex; } - gl_mask_index_span( ctx, width, x, y + i, span ); + _mesa_mask_index_span( ctx, width, x, y + i, span ); (*ctx->Driver.WriteCI32Span)( ctx, width, x, y + i, span, mask ); } } @@ -290,16 +290,16 @@ _mesa_Clear( GLbitfield mask ) /* do software clearing here */ if (newMask) { - if (newMask & ctx->Color.DrawDestMask) clear_color_buffers( ctx ); - if (newMask & GL_DEPTH_BUFFER_BIT) _mesa_clear_depth_buffer( ctx ); - if (newMask & GL_ACCUM_BUFFER_BIT) _mesa_clear_accum_buffer( ctx ); - if (newMask & GL_STENCIL_BUFFER_BIT) gl_clear_stencil_buffer( ctx ); + if (newMask & ctx->Color.DrawDestMask) clear_color_buffers(ctx); + if (newMask & GL_DEPTH_BUFFER_BIT) _mesa_clear_depth_buffer(ctx); + if (newMask & GL_ACCUM_BUFFER_BIT) _mesa_clear_accum_buffer(ctx); + if (newMask & GL_STENCIL_BUFFER_BIT) _mesa_clear_stencil_buffer(ctx); } /* clear software-based alpha buffer(s) */ if ( (mask & GL_COLOR_BUFFER_BIT) && ctx->Visual->SoftwareAlpha && ctx->Color.ColorMask[RCOMP]) { - gl_clear_alpha_buffers( ctx ); + _mesa_clear_alpha_buffers( ctx ); } #ifdef PROFILE @@ -552,12 +552,12 @@ _mesa_ResizeBuffersMESA( void ) _mesa_alloc_depth_buffer( ctx ); } if (ctx->DrawBuffer->UseSoftwareStencilBuffer) { - gl_alloc_stencil_buffer( ctx ); + _mesa_alloc_stencil_buffer( ctx ); } if (ctx->DrawBuffer->UseSoftwareAccumBuffer) { _mesa_alloc_accum_buffer( ctx ); } if (ctx->Visual->SoftwareAlpha) { - gl_alloc_alpha_buffers( ctx ); + _mesa_alloc_alpha_buffers( ctx ); } } diff --git a/xc/extras/Mesa/src/clip.c b/xc/extras/Mesa/src/clip.c index ed986ad6b..6cfd9e245 100644 --- a/xc/extras/Mesa/src/clip.c +++ b/xc/extras/Mesa/src/clip.c @@ -301,10 +301,12 @@ GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] ) -#if defined(__i386__) +#if 0 #define NEGATIVE(x) ((*(int *)&x)<0) +#define DIFFERENT_SIGNS(a,b) ((a*b) < 0) #else #define NEGATIVE(x) (x < 0) +#define DIFFERENT_SIGNS(a,b) ((a*b) < 0) #endif @@ -374,13 +376,10 @@ void gl_update_clipmask( GLcontext *ctx ) if (ctx->Visual->RGBAflag) { - if (ctx->Light.ShadeModel==GL_SMOOTH) - { - mask |= CLIP_RGBA0; + mask |= CLIP_RGBA0; - if (ctx->TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_SEPERATE_SPECULAR)) - mask |= CLIP_RGBA1; - } + if (ctx->TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_SEPERATE_SPECULAR)) + mask |= CLIP_RGBA1; if (ctx->Texture.ReallyEnabled & 0xf0) mask |= CLIP_TEX1|CLIP_TEX0; diff --git a/xc/extras/Mesa/src/clip_funcs.h b/xc/extras/Mesa/src/clip_funcs.h index 8c51fe070..5f0591872 100644 --- a/xc/extras/Mesa/src/clip_funcs.h +++ b/xc/extras/Mesa/src/clip_funcs.h @@ -41,7 +41,6 @@ static GLuint TAG(viewclip_line)( struct vertex_buffer *VB, GLubyte mask ) { GLfloat (*coord)[4] = VB->ClipPtr->data; - GLfloat t, dx, dy, dz, dw, neww; GLuint ii = *i, jj = *j; GLuint vlist[2]; GLuint n; @@ -50,31 +49,29 @@ static GLuint TAG(viewclip_line)( struct vertex_buffer *VB, /* * We use 6 instances of this code to clip agains the 6 planes. - * For each plane, we define the OUTSIDE and COMPUTE_INTERSECTION - * macros apprpriately. */ -#define GENERAL_CLIP \ - if (mask & PLANE) { \ - GLuint flagI = INSIDE( ii ); \ - GLuint flagJ = INSIDE( jj ); \ - \ - if (!(flagI|flagJ)) \ - return 0; \ - \ - if (flagI ^ flagJ) { \ - COMPUTE_INTERSECTION( jj, ii, vb_free ); \ - interp( VB, vb_free, t, jj, ii); \ - \ - if (flagI) { \ - VB->ClipMask[jj] |= PLANE; \ - jj = vb_free; \ - } else { \ - VB->ClipMask[ii] |= PLANE; \ - ii = vb_free; \ - } \ - \ - VB->ClipMask[vb_free++] = 0; \ - } \ +#define GENERAL_CLIP \ + if (mask & PLANE) { \ + GLfloat dpI = CLIP_DOTPROD( ii ); \ + GLfloat dpJ = CLIP_DOTPROD( jj ); \ + \ + if (DIFFERENT_SIGNS(dpI, dpJ)) { \ + GLfloat t = dpI / (dpI - dpJ); \ + INTERP_SZ( t, VB->ClipPtr->data, vb_free, ii, jj, SIZE ); \ + interp( VB, vb_free, t, ii, jj); \ + \ + if (NEGATIVE(dpJ)) { \ + VB->ClipMask[jj] |= PLANE; \ + jj = vb_free; \ + VB->ClipMask[vb_free++] = 0; \ + } else { \ + VB->ClipMask[ii] |= PLANE; \ + ii = vb_free; \ + VB->ClipMask[vb_free++] = 0; \ + } \ + } \ + else if (NEGATIVE(dpI)) \ + return 0; \ } #include "general_clip.h" @@ -142,74 +139,78 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB, GLfloat (*coord)[4] = VB->ClipPtr->data; GLuint vlist2[VB_SIZE-VB_MAX]; GLuint *inlist = vlist, *outlist = vlist2; - GLdouble dx, dy, dz, dw, t = 0, neww; GLuint i; GLuint vb_free = VB->FirstFree; + GLubyte *clipmask = VB->ClipMask; clip_interp_func interp = VB->ctx->ClipInterpFunc; if (mask & CLIP_ALL_BITS) { #define GENERAL_CLIP \ if (mask & PLANE) { \ - GLuint prevj = inlist[0]; \ - GLuint prevflag = INSIDE(prevj); \ + GLuint idxPrev = inlist[0]; \ + GLfloat dpPrev = CLIP_DOTPROD(idxPrev); \ GLuint outcount = 0; \ GLuint i; \ - \ + \ inlist[n] = inlist[0]; \ - \ + \ for (i = 1; i < n+1; i++) { \ - GLuint j = inlist[i]; \ - GLuint flag = INSIDE(j); \ - \ - if (prevflag) { \ - outlist[outcount++] = prevj; \ - } else { \ - VB->ClipMask[prevj] |= (PLANE&CLIP_ALL_BITS); \ + GLuint idx = inlist[i]; \ + GLfloat dp = CLIP_DOTPROD(idx); \ + \ + clipmask[idxPrev] |= (PLANE&CLIP_ALL_BITS); \ + \ + if (!NEGATIVE(dpPrev)) { \ + outlist[outcount++] = idxPrev; \ + clipmask[idxPrev] &= ~(PLANE&CLIP_ALL_BITS); \ } \ - \ - if (flag ^ prevflag) { \ - if (flag) { \ - /* Coming back in \ + \ + if (DIFFERENT_SIGNS(dp, dpPrev)) { \ + if (NEGATIVE(dp)) { \ + /* Coming back in. Avoid division by zero as we know \ + * dp != dpPrev from DIFFERENT_SIGNS, above. \ */ \ - COMPUTE_INTERSECTION( j, prevj, vb_free ); \ - interp( VB, vb_free, t, j, prevj ); \ + GLfloat t = dp / (dp - dpPrev); \ + INTERP_SZ( t, VB->ClipPtr->data, vb_free, \ + idx, idxPrev, SIZE ); \ + interp( VB, vb_free, t, idx, idxPrev ); \ \ if (IND&CLIP_TAB_EDGEFLAG) \ VB->EdgeFlagPtr->data[vb_free] = \ - VB->EdgeFlagPtr->data[prevj]; \ - \ - \ + VB->EdgeFlagPtr->data[idxPrev]; \ } else { \ /* Going out of bounds \ */ \ - COMPUTE_INTERSECTION( prevj, j, vb_free ); \ - interp( VB, vb_free, t, prevj, j ); \ + GLfloat t = dpPrev / (dpPrev - dp); \ + INTERP_SZ( t, VB->ClipPtr->data, vb_free, \ + idxPrev, idx, SIZE ); \ + interp( VB, vb_free, t, idxPrev, idx ); \ \ - if (IND&CLIP_TAB_EDGEFLAG) { \ + if (IND&CLIP_TAB_EDGEFLAG) \ VB->EdgeFlagPtr->data[vb_free] = 3; \ - } \ } \ \ - if (IND&CLIP_TAB_EDGEFLAG) { \ + if (IND&CLIP_TAB_EDGEFLAG) { \ /* Demote trailing edge to internal edge. \ */ \ - if (outcount && \ + if (outcount && \ (VB->EdgeFlagPtr->data[outlist[outcount-1]] & 0x2)) \ VB->EdgeFlagPtr->data[outlist[outcount-1]] = 1; \ } \ \ outlist[outcount++] = vb_free; \ - VB->ClipMask[vb_free++] = 0; \ + clipmask[vb_free++] = 0; \ } \ \ - prevj = j; \ - prevflag = flag; \ + idxPrev = idx; \ + dpPrev = dp; \ } \ \ if (outcount < 3) \ return 0; \ - else { \ + \ + { \ GLuint *tmp = inlist; \ inlist = outlist; \ outlist = tmp; \ diff --git a/xc/extras/Mesa/src/colortab.c b/xc/extras/Mesa/src/colortab.c index 95c2a7d84..341ceaa25 100644 --- a/xc/extras/Mesa/src/colortab.c +++ b/xc/extras/Mesa/src/colortab.c @@ -32,175 +32,341 @@ #include "context.h" #include "image.h" #include "macros.h" +#include "mem.h" +#include "mmath.h" +#include "span.h" +#include "teximage.h" #endif -/* - * Return GL_TRUE if k is a power of two, else return GL_FALSE. - */ -static GLboolean -power_of_two( GLint k ) +void +_mesa_init_colortable( struct gl_color_table *p ) { - GLint i, m = 1; - for (i=0; i<32; i++) { - if (k == m) - return GL_TRUE; - m = m << 1; + p->TableType = GL_UNSIGNED_BYTE; + /* allocate a width=1 table by default */ + p->Table = CALLOC(4 * sizeof(GLubyte)); + if (p->Table) { + GLubyte *t = (GLubyte *) p->Table; + t[0] = 255; + t[1] = 255; + t[2] = 255; + t[3] = 255; } - return GL_FALSE; + p->Size = 1; + p->IntFormat = GL_RGBA; + p->Format = GL_RGBA; + p->RedSize = 8; + p->GreenSize = 8; + p->BlueSize = 8; + p->AlphaSize = 8; + p->IntensitySize = 0; + p->LuminanceSize = 0; } -static GLint -decode_internal_format( GLint format ) + +void +_mesa_free_colortable_data( struct gl_color_table *p ) { - switch (format) { + if (p->Table) { + FREE(p->Table); + p->Table = NULL; + } +} + + +/* + * Examine table's format and set the component sizes accordingly. + */ +static void +set_component_sizes( struct gl_color_table *table ) +{ + switch (table->Format) { case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - return GL_ALPHA; - case 1: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 8; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - return GL_LUMINANCE; - case 2: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 0; + table->IntensitySize = 0; + table->LuminanceSize = 8; + break; case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - return GL_LUMINANCE_ALPHA; + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 8; + table->IntensitySize = 0; + table->LuminanceSize = 8; + break; case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - return GL_INTENSITY; - case 3: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 0; + table->IntensitySize = 8; + table->LuminanceSize = 0; + break; case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - return GL_RGB; - case 4: + table->RedSize = 8; + table->GreenSize = 8; + table->BlueSize = 8; + table->AlphaSize = 0; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - return GL_RGBA; + table->RedSize = 8; + table->GreenSize = 8; + table->BlueSize = 8; + table->AlphaSize = 8; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; default: - return -1; /* error */ + gl_problem(NULL, "unexpected format in set_component_sizes"); } } + void _mesa_ColorTable( GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, - const GLvoid *table ) + const GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj; - struct gl_color_table *palette; + struct gl_texture_object *texObj = NULL; + struct gl_color_table *table = NULL; GLboolean proxy = GL_FALSE; + GLint baseFormat; + GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0; + GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0; + GLboolean floatTable = GL_FALSE; + GLint comps; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable"); switch (target) { case GL_TEXTURE_1D: texObj = texUnit->CurrentD[1]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_2D: texObj = texUnit->CurrentD[2]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_3D: texObj = texUnit->CurrentD[3]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_PROXY_TEXTURE_1D: texObj = ctx->Texture.Proxy1D; - palette = &texObj->Palette; + table = &texObj->Palette; proxy = GL_TRUE; break; case GL_PROXY_TEXTURE_2D: texObj = ctx->Texture.Proxy2D; - palette = &texObj->Palette; + table = &texObj->Palette; proxy = GL_TRUE; break; case GL_PROXY_TEXTURE_3D: texObj = ctx->Texture.Proxy3D; - palette = &texObj->Palette; + table = &texObj->Palette; proxy = GL_TRUE; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - texObj = NULL; - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + floatTable = GL_TRUE; + rScale = ctx->Pixel.ColorTableScale[0]; + gScale = ctx->Pixel.ColorTableScale[1]; + bScale = ctx->Pixel.ColorTableScale[2]; + aScale = ctx->Pixel.ColorTableScale[3]; + rBias = ctx->Pixel.ColorTableBias[0]; + gBias = ctx->Pixel.ColorTableBias[1]; + bBias = ctx->Pixel.ColorTableBias[2]; + aBias = ctx->Pixel.ColorTableBias[3]; + break; + case GL_PROXY_COLOR_TABLE: + table = &ctx->ProxyColorTable; + proxy = GL_TRUE; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + floatTable = GL_TRUE; + rScale = ctx->Pixel.PCCTscale[0]; + gScale = ctx->Pixel.PCCTscale[1]; + bScale = ctx->Pixel.PCCTscale[2]; + aScale = ctx->Pixel.PCCTscale[3]; + rBias = ctx->Pixel.PCCTbias[0]; + gBias = ctx->Pixel.PCCTbias[1]; + bBias = ctx->Pixel.PCCTbias[2]; + aBias = ctx->Pixel.PCCTbias[3]; + break; + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->ProxyPostConvolutionColorTable; + proxy = GL_TRUE; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; + floatTable = GL_TRUE; + rScale = ctx->Pixel.PCMCTscale[0]; + gScale = ctx->Pixel.PCMCTscale[1]; + bScale = ctx->Pixel.PCMCTscale[2]; + aScale = ctx->Pixel.PCMCTscale[3]; + rBias = ctx->Pixel.PCMCTbias[0]; + gBias = ctx->Pixel.PCMCTbias[1]; + bBias = ctx->Pixel.PCMCTbias[2]; + aBias = ctx->Pixel.PCMCTbias[3]; + break; + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->ProxyPostColorMatrixColorTable; + proxy = GL_TRUE; break; default: gl_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); return; } - assert(palette); + assert(table); if (!_mesa_is_legal_format_and_type(format, type)) { gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)"); return; } - if (decode_internal_format(internalFormat) < 0) { - gl_error( ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)" ); + baseFormat = _mesa_base_tex_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)"); return; } - if (width < 1 || width > MAX_TEXTURE_PALETTE_SIZE || !power_of_two(width)) { - gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)"); + if (width < 1 || width > ctx->Const.MaxColorTableSize + || _mesa_bitcount(width) != 1) { + if (width > ctx->Const.MaxColorTableSize) + gl_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)"); + else + gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)"); if (proxy) { - palette->Size = 0; - palette->IntFormat = (GLenum) 0; - palette->Format = (GLenum) 0; + table->Size = 0; + table->IntFormat = (GLenum) 0; + table->Format = (GLenum) 0; } return; } - palette->Size = width; - palette->IntFormat = internalFormat; - palette->Format = (GLenum) decode_internal_format(internalFormat); + table->Size = width; + table->IntFormat = internalFormat; + table->Format = (GLenum) baseFormat; + set_component_sizes(table); + + comps = _mesa_components_in_format(table->Format); + assert(comps > 0); /* error should have been caught sooner */ + if (!proxy) { - _mesa_unpack_ubyte_color_span(ctx, width, palette->Format, - palette->Table, /* dest */ - format, type, table, - &ctx->Unpack, GL_FALSE); - } - if (texObj) { - /* per-texture object palette */ - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); + /* free old table, if any */ + if (table->Table) { + FREE(table->Table); } - } - else { - /* shared texture palette */ + if (floatTable) { + GLubyte tableUB[MAX_COLOR_TABLE_SIZE * 4]; + GLfloat *tableF; + GLuint i; + + _mesa_unpack_ubyte_color_span(ctx, width, table->Format, + tableUB, /* dest */ + format, type, data, + &ctx->Unpack, GL_TRUE); + + table->TableType = GL_FLOAT; + table->Table = MALLOC(comps * width * sizeof(GLfloat)); + if (!table->Table) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); + return; + } + + /* Apply scale and bias and convert GLubyte values to GLfloats + * in [0, 1]. Store results in the tableF[]. + */ + rScale /= 255.0; + gScale /= 255.0; + bScale /= 255.0; + aScale /= 255.0; + tableF = (GLfloat *) table->Table; + + switch (table->Format) { + case GL_INTENSITY: + for (i = 0; i < width; i++) { + tableF[i] = tableUB[i] * rScale + rBias; + } + break; + case GL_LUMINANCE: + for (i = 0; i < width; i++) { + tableF[i] = tableUB[i] * rScale + rBias; + } + break; + case GL_ALPHA: + for (i = 0; i < width; i++) { + tableF[i] = tableUB[i] * aScale + aBias; + } + break; + case GL_LUMINANCE_ALPHA: + for (i = 0; i < width; i++) { + tableF[i*2+0] = tableUB[i*2+0] * rScale + rBias; + tableF[i*2+1] = tableUB[i*2+1] * aScale + aBias; + } + break; + case GL_RGB: + for (i = 0; i < width; i++) { + tableF[i*3+0] = tableUB[i*3+0] * rScale + rBias; + tableF[i*3+1] = tableUB[i*3+1] * gScale + gBias; + tableF[i*3+2] = tableUB[i*3+2] * bScale + bBias; + } + break; + case GL_RGBA: + for (i = 0; i < width; i++) { + tableF[i*4+0] = tableUB[i*4+0] * rScale + rBias; + tableF[i*4+1] = tableUB[i*4+1] * gScale + gBias; + tableF[i*4+2] = tableUB[i*4+2] * bScale + bBias; + tableF[i*4+3] = tableUB[i*4+3] * aScale + aBias; + } + break; + default: + gl_problem(ctx, "Bad format in _mesa_ColorTable"); + return; + } + } + else { + /* store GLubyte table */ + table->TableType = GL_UNSIGNED_BYTE; + table->Table = MALLOC(comps * width * sizeof(GLubyte)); + if (!table->Table) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); + return; + } + _mesa_unpack_ubyte_color_span(ctx, width, table->Format, + table->Table, /* dest */ + format, type, data, + &ctx->Unpack, GL_TRUE); + } /* floatTable */ + } /* proxy */ + + if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { + /* texture object palette, texObj==NULL means the shared palette */ if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, NULL ); + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } } @@ -210,40 +376,47 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, void _mesa_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, - const GLvoid *table ) + const GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj; - struct gl_color_table *palette; + struct gl_texture_object *texObj = NULL; + struct gl_color_table *table = NULL; GLint comps; - GLubyte *dest; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable"); switch (target) { case GL_TEXTURE_1D: texObj = texUnit->CurrentD[1]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_2D: texObj = texUnit->CurrentD[2]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_3D: texObj = texUnit->CurrentD[3]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - texObj = NULL; - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; break; default: gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); return; } - assert(palette); + assert(table); if (!_mesa_is_legal_format_and_type(format, type)) { gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)"); @@ -255,205 +428,618 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, return; } - comps = _mesa_components_in_format(format); - assert(comps > 0); /* error should be caught sooner */ + comps = _mesa_components_in_format(table->Format); + assert(comps > 0); /* error should have been caught sooner */ - if (start + count > palette->Size) { + if (start + count > table->Size) { gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); return; } - dest = palette->Table + start * comps * sizeof(GLubyte); - _mesa_unpack_ubyte_color_span(ctx, count, palette->Format, dest, - format, type, table, - &ctx->Unpack, GL_FALSE); - if (texObj) { - /* per-texture object palette */ - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); - } + if (!table->Table) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glColorSubTable"); + return; + } + + if (table->TableType == GL_UNSIGNED_BYTE) { + GLubyte *dest = (GLubyte *) table->Table + start * comps * sizeof(GLubyte); + _mesa_unpack_ubyte_color_span(ctx, count, table->Format, dest, + format, type, data, &ctx->Unpack, GL_TRUE); } else { - /* shared texture palette */ + GLfloat *dest = (GLfloat *) table->Table + start * comps * sizeof(GLfloat); + ASSERT(table->TableType == GL_FLOAT); + _mesa_unpack_float_color_span(ctx, count, table->Format, dest, + format, type, data, &ctx->Unpack, GL_TRUE); + } + + if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { + /* per-texture object palette */ if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, NULL ); + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } } +/* XXX not tested */ +void +_mesa_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GLubyte data[MAX_WIDTH][4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyColorTable"); + + /* Select buffer to read from */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); + + if (width > MAX_WIDTH) + width = MAX_WIDTH; + + /* read the data from framebuffer */ + gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data ); + + /* Restore reading from draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); + + _mesa_ColorTable(target, internalformat, width, + GL_RGBA, GL_UNSIGNED_BYTE, data); +} + + + +/* XXX not tested */ +void +_mesa_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GLubyte data[MAX_WIDTH][4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyColorSubTable"); + + /* Select buffer to read from */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); + + if (width > MAX_WIDTH) + width = MAX_WIDTH; + + /* read the data from framebuffer */ + gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data ); + + /* Restore reading from draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); + + _mesa_ColorSubTable(target, start, width, GL_RGBA, GL_UNSIGNED_BYTE, data); +} + + + void _mesa_GetColorTable( GLenum target, GLenum format, - GLenum type, GLvoid *table ) + GLenum type, GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_color_table *palette; - GLubyte rgba[MAX_TEXTURE_PALETTE_SIZE][4]; + struct gl_color_table *table = NULL; + GLubyte rgba[MAX_COLOR_TABLE_SIZE][4]; GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTable"); switch (target) { case GL_TEXTURE_1D: - palette = &texUnit->CurrentD[1]->Palette; + table = &texUnit->CurrentD[1]->Palette; break; case GL_TEXTURE_2D: - palette = &texUnit->CurrentD[2]->Palette; + table = &texUnit->CurrentD[2]->Palette; break; case GL_TEXTURE_3D: - palette = &texUnit->CurrentD[3]->Palette; + table = &texUnit->CurrentD[3]->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; break; default: gl_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); return; } - assert(palette); + assert(table); - switch (palette->Format) { + switch (table->Format) { case GL_ALPHA: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = 0; - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = palette->Table[i]; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = 0; + rgba[i][GCOMP] = 0; + rgba[i][BCOMP] = 0; + rgba[i][ACOMP] = (GLint) (tableF[i] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = 0; + rgba[i][GCOMP] = 0; + rgba[i][BCOMP] = 0; + rgba[i][ACOMP] = tableUB[i]; + } } break; case GL_LUMINANCE: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i]; - rgba[i][GCOMP] = palette->Table[i]; - rgba[i][BCOMP] = palette->Table[i]; - rgba[i][ACOMP] = 255; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][ACOMP] = 255; + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i]; + rgba[i][GCOMP] = tableUB[i]; + rgba[i][BCOMP] = tableUB[i]; + rgba[i][ACOMP] = 255; + } } break; case GL_LUMINANCE_ALPHA: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i*2+0]; - rgba[i][GCOMP] = palette->Table[i*2+0]; - rgba[i][BCOMP] = palette->Table[i*2+0]; - rgba[i][ACOMP] = palette->Table[i*2+1]; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i*2+0] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i*2+0] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i*2+0] * 255.0F); + rgba[i][ACOMP] = (GLint) (tableF[i*2+1] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i*2+0]; + rgba[i][GCOMP] = tableUB[i*2+0]; + rgba[i][BCOMP] = tableUB[i*2+0]; + rgba[i][ACOMP] = tableUB[i*2+1]; + } } break; case GL_INTENSITY: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i]; - rgba[i][GCOMP] = palette->Table[i]; - rgba[i][BCOMP] = palette->Table[i]; - rgba[i][ACOMP] = 255; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][ACOMP] = (GLint) (tableF[i] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i]; + rgba[i][GCOMP] = tableUB[i]; + rgba[i][BCOMP] = tableUB[i]; + rgba[i][ACOMP] = tableUB[i]; + } } break; case GL_RGB: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i*3+0]; - rgba[i][GCOMP] = palette->Table[i*3+1]; - rgba[i][BCOMP] = palette->Table[i*3+2]; - rgba[i][ACOMP] = 255; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i*3+0] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i*3+1] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i*3+2] * 255.0F); + rgba[i][ACOMP] = 255; + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i*3+0]; + rgba[i][GCOMP] = tableUB[i*3+1]; + rgba[i][BCOMP] = tableUB[i*3+2]; + rgba[i][ACOMP] = 255; + } } break; case GL_RGBA: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i*4+0]; - rgba[i][GCOMP] = palette->Table[i*4+1]; - rgba[i][BCOMP] = palette->Table[i*4+2]; - rgba[i][ACOMP] = palette->Table[i*4+3]; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * 255.0F); + rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i*4+0]; + rgba[i][GCOMP] = tableUB[i*4+1]; + rgba[i][BCOMP] = tableUB[i*4+2]; + rgba[i][ACOMP] = tableUB[i*4+3]; + } } break; default: - gl_problem(ctx, "bad palette format in glGetColorTable"); + gl_problem(ctx, "bad table format in glGetColorTable"); return; } - _mesa_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba, - format, type, table, &ctx->Pack, GL_FALSE); + _mesa_pack_rgba_span(ctx, table->Size, (const GLubyte (*)[]) rgba, + format, type, data, &ctx->Pack, GL_FALSE); +} + - (void) format; - (void) type; - (void) table; + +void +_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv"); + + switch (target) { + case GL_COLOR_TABLE_SGI: + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Pixel.ColorTableScale[0] = params[0]; + ctx->Pixel.ColorTableScale[1] = params[1]; + ctx->Pixel.ColorTableScale[2] = params[2]; + ctx->Pixel.ColorTableScale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Pixel.ColorTableBias[0] = params[0]; + ctx->Pixel.ColorTableBias[1] = params[1]; + ctx->Pixel.ColorTableBias[2] = params[2]; + ctx->Pixel.ColorTableBias[3] = params[3]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Pixel.PCCTscale[0] = params[0]; + ctx->Pixel.PCCTscale[1] = params[1]; + ctx->Pixel.PCCTscale[2] = params[2]; + ctx->Pixel.PCCTscale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Pixel.PCCTbias[0] = params[0]; + ctx->Pixel.PCCTbias[1] = params[1]; + ctx->Pixel.PCCTbias[2] = params[2]; + ctx->Pixel.PCCTbias[3] = params[3]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Pixel.PCMCTscale[0] = params[0]; + ctx->Pixel.PCMCTscale[1] = params[1]; + ctx->Pixel.PCMCTscale[2] = params[2]; + ctx->Pixel.PCMCTscale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Pixel.PCMCTbias[0] = params[0]; + ctx->Pixel.PCMCTbias[1] = params[1]; + ctx->Pixel.PCMCTbias[2] = params[2]; + ctx->Pixel.PCMCTbias[3] = params[3]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); + return; + } } void -_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) +_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) { - GLint iparams[10]; - _mesa_GetColorTableParameteriv( target, pname, iparams ); - *params = (GLfloat) iparams[0]; + GLfloat fparams[4]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { + /* four values */ + fparams[0] = (GLfloat) params[0]; + fparams[1] = (GLfloat) params[1]; + fparams[2] = (GLfloat) params[2]; + fparams[3] = (GLfloat) params[3]; + } + else { + /* one values */ + fparams[0] = (GLfloat) params[0]; + } + _mesa_ColorTableParameterfv(target, pname, fparams); } void -_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) +_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_color_table *palette; + struct gl_color_table *table = NULL; - ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameter"); + ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameterfv"); switch (target) { case GL_TEXTURE_1D: - palette = &texUnit->CurrentD[1]->Palette; + table = &texUnit->CurrentD[1]->Palette; break; case GL_TEXTURE_2D: - palette = &texUnit->CurrentD[2]->Palette; + table = &texUnit->CurrentD[2]->Palette; break; case GL_TEXTURE_3D: - palette = &texUnit->CurrentD[3]->Palette; + table = &texUnit->CurrentD[3]->Palette; break; case GL_PROXY_TEXTURE_1D: - palette = &ctx->Texture.Proxy1D->Palette; + table = &ctx->Texture.Proxy1D->Palette; break; case GL_PROXY_TEXTURE_2D: - palette = &ctx->Texture.Proxy2D->Palette; + table = &ctx->Texture.Proxy2D->Palette; break; case GL_PROXY_TEXTURE_3D: - palette = &ctx->Texture.Proxy3D->Palette; + table = &ctx->Texture.Proxy3D->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Pixel.ColorTableScale[0]; + params[1] = ctx->Pixel.ColorTableScale[1]; + params[2] = ctx->Pixel.ColorTableScale[2]; + params[3] = ctx->Pixel.ColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Pixel.ColorTableBias[0]; + params[1] = ctx->Pixel.ColorTableBias[1]; + params[2] = ctx->Pixel.ColorTableBias[2]; + params[3] = ctx->Pixel.ColorTableBias[3]; + return; + } + break; + case GL_PROXY_COLOR_TABLE: + table = &ctx->ProxyColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Pixel.PCCTscale[0]; + params[1] = ctx->Pixel.PCCTscale[1]; + params[2] = ctx->Pixel.PCCTscale[2]; + params[3] = ctx->Pixel.PCCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Pixel.PCCTbias[0]; + params[1] = ctx->Pixel.PCCTbias[1]; + params[2] = ctx->Pixel.PCCTbias[2]; + params[3] = ctx->Pixel.PCCTbias[3]; + return; + } + break; + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->ProxyPostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Pixel.PCMCTscale[0]; + params[1] = ctx->Pixel.PCMCTscale[1]; + params[2] = ctx->Pixel.PCMCTscale[2]; + params[3] = ctx->Pixel.PCMCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Pixel.PCMCTbias[0]; + params[1] = ctx->Pixel.PCMCTbias[1]; + params[2] = ctx->Pixel.PCMCTbias[2]; + params[3] = ctx->Pixel.PCMCTbias[3]; + return; + } + break; + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->ProxyPostColorMatrixColorTable; break; default: - gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); return; } + assert(table); + switch (pname) { case GL_COLOR_TABLE_FORMAT: - *params = palette->IntFormat; + *params = table->IntFormat; break; case GL_COLOR_TABLE_WIDTH: - *params = palette->Size; + *params = table->Size; break; case GL_COLOR_TABLE_RED_SIZE: - *params = 8; + *params = table->RedSize; break; case GL_COLOR_TABLE_GREEN_SIZE: - *params = 8; + *params = table->GreenSize; break; case GL_COLOR_TABLE_BLUE_SIZE: - *params = 8; + *params = table->BlueSize; break; case GL_COLOR_TABLE_ALPHA_SIZE: - *params = 8; + *params = table->AlphaSize; break; case GL_COLOR_TABLE_LUMINANCE_SIZE: - *params = 8; + *params = table->LuminanceSize; break; case GL_COLOR_TABLE_INTENSITY_SIZE: - *params = 8; + *params = table->IntensitySize; break; default: - gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter" ); + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" ); return; } } + +void +_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_color_table *table = NULL; + + ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameteriv"); + + switch (target) { + case GL_TEXTURE_1D: + table = &texUnit->CurrentD[1]->Palette; + break; + case GL_TEXTURE_2D: + table = &texUnit->CurrentD[2]->Palette; + break; + case GL_TEXTURE_3D: + table = &texUnit->CurrentD[3]->Palette; + break; + case GL_PROXY_TEXTURE_1D: + table = &ctx->Texture.Proxy1D->Palette; + break; + case GL_PROXY_TEXTURE_2D: + table = &ctx->Texture.Proxy2D->Palette; + break; + case GL_PROXY_TEXTURE_3D: + table = &ctx->Texture.Proxy3D->Palette; + break; + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.ColorTableScale[0]; + params[1] = (GLint) ctx->Pixel.ColorTableScale[1]; + params[2] = (GLint) ctx->Pixel.ColorTableScale[2]; + params[3] = (GLint) ctx->Pixel.ColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.ColorTableBias[0]; + params[1] = (GLint) ctx->Pixel.ColorTableBias[1]; + params[2] = (GLint) ctx->Pixel.ColorTableBias[2]; + params[3] = (GLint) ctx->Pixel.ColorTableBias[3]; + return; + } + break; + case GL_PROXY_COLOR_TABLE: + table = &ctx->ProxyColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.PCCTscale[0]; + params[1] = (GLint) ctx->Pixel.PCCTscale[1]; + params[2] = (GLint) ctx->Pixel.PCCTscale[2]; + params[3] = (GLint) ctx->Pixel.PCCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.PCCTbias[0]; + params[1] = (GLint) ctx->Pixel.PCCTbias[1]; + params[2] = (GLint) ctx->Pixel.PCCTbias[2]; + params[3] = (GLint) ctx->Pixel.PCCTbias[3]; + return; + } + break; + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->ProxyPostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.PCMCTscale[0]; + params[1] = (GLint) ctx->Pixel.PCMCTscale[1]; + params[2] = (GLint) ctx->Pixel.PCMCTscale[2]; + params[3] = (GLint) ctx->Pixel.PCMCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.PCMCTbias[0]; + params[1] = (GLint) ctx->Pixel.PCMCTbias[1]; + params[2] = (GLint) ctx->Pixel.PCMCTbias[2]; + params[3] = (GLint) ctx->Pixel.PCMCTbias[3]; + return; + } + break; + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->ProxyPostColorMatrixColorTable; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); + return; + } + + assert(table); + + switch (pname) { + case GL_COLOR_TABLE_FORMAT: + *params = table->IntFormat; + break; + case GL_COLOR_TABLE_WIDTH: + *params = table->Size; + break; + case GL_COLOR_TABLE_RED_SIZE: + *params = table->RedSize; + break; + case GL_COLOR_TABLE_GREEN_SIZE: + *params = table->GreenSize; + break; + case GL_COLOR_TABLE_BLUE_SIZE: + *params = table->BlueSize; + break; + case GL_COLOR_TABLE_ALPHA_SIZE: + *params = table->AlphaSize; + break; + case GL_COLOR_TABLE_LUMINANCE_SIZE: + *params = table->LuminanceSize; + break; + case GL_COLOR_TABLE_INTENSITY_SIZE: + *params = table->IntensitySize; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" ); + return; + } +} diff --git a/xc/extras/Mesa/src/colortab.h b/xc/extras/Mesa/src/colortab.h index bdcf5fa71..6a3f0cabe 100644 --- a/xc/extras/Mesa/src/colortab.h +++ b/xc/extras/Mesa/src/colortab.h @@ -32,22 +32,53 @@ extern void +_mesa_init_colortable( struct gl_color_table *p ); + +extern void +_mesa_free_colortable_data( struct gl_color_table *p ); + + +extern void _mesa_ColorTable( GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table ); + extern void _mesa_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table ); + +extern void +_mesa_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width); + + +extern void +_mesa_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width); + + extern void _mesa_GetColorTable( GLenum target, GLenum format, GLenum type, GLvoid *table ); + +extern void +_mesa_ColorTableParameterfv(GLenum target, GLenum pname, + const GLfloat *params); + + +extern void +_mesa_ColorTableParameteriv(GLenum target, GLenum pname, + const GLint *params); + + extern void _mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ); + extern void _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ); diff --git a/xc/extras/Mesa/src/config.h b/xc/extras/Mesa/src/config.h index 22ad65ca2..76b6a9d18 100644 --- a/xc/extras/Mesa/src/config.h +++ b/xc/extras/Mesa/src/config.h @@ -51,6 +51,9 @@ /* Maximum texture matrix stack depth: */ #define MAX_TEXTURE_STACK_DEPTH 10 +/* Maximum color matrix stack depth: */ +#define MAX_COLOR_STACK_DEPTH 4 + /* Maximum attribute stack depth: */ #define MAX_ATTRIB_STACK_DEPTH 16 @@ -92,8 +95,8 @@ #define MAX_LINE_WIDTH 10.0 #define LINE_WIDTH_GRANULARITY 0.1 -/* Max texture palette size */ -#define MAX_TEXTURE_PALETTE_SIZE 256 +/* Max texture palette / color table size */ +#define MAX_COLOR_TABLE_SIZE 256 /* Number of texture levels */ #define MAX_TEXTURE_LEVELS 12 @@ -111,6 +114,9 @@ /* Subpixel precision for antialiasing, window coordinate snapping */ #define SUB_PIXEL_BITS 4 +/* Size of histogram tables */ +#define HISTOGRAM_TABLE_SIZE 256 + /* diff --git a/xc/extras/Mesa/src/context.c b/xc/extras/Mesa/src/context.c index 7f76b6bf8..f72b0caa0 100644 --- a/xc/extras/Mesa/src/context.c +++ b/xc/extras/Mesa/src/context.c @@ -31,6 +31,7 @@ #include "accum.h" #include "alphabuf.h" #include "clip.h" +#include "colortab.h" #include "context.h" #include "cva.h" #include "depth.h" @@ -266,18 +267,23 @@ static void print_timings( GLcontext *ctx ) * Return: pointer to new GLvisual or NULL if requested parameters can't * be met. */ -GLvisual *gl_create_visual( GLboolean rgbFlag, - GLboolean alphaFlag, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - GLint indexBits, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits ) +GLvisual * +_mesa_create_visual( GLboolean rgbFlag, + GLboolean alphaFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint indexBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ) { GLvisual *vis; @@ -293,7 +299,16 @@ GLvisual *gl_create_visual( GLboolean rgbFlag, if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) { return NULL; } - if (accumBits < 0 || accumBits > (GLint) (8 * sizeof(GLaccum))) { + if (accumRedBits < 0 || accumRedBits > (GLint) (8 * sizeof(GLaccum))) { + return NULL; + } + if (accumGreenBits < 0 || accumGreenBits > (GLint) (8 * sizeof(GLaccum))) { + return NULL; + } + if (accumBlueBits < 0 || accumBlueBits > (GLint) (8 * sizeof(GLaccum))) { + return NULL; + } + if (accumAlphaBits < 0 || accumAlphaBits > (GLint) (8 * sizeof(GLaccum))) { return NULL; } @@ -310,10 +325,13 @@ GLvisual *gl_create_visual( GLboolean rgbFlag, vis->BlueBits = blueBits; vis->AlphaBits = alphaFlag ? (8 * sizeof(GLubyte)) : alphaBits; - vis->IndexBits = indexBits; - vis->DepthBits = depthBits; - vis->AccumBits = (accumBits > 0) ? (8 * sizeof(GLaccum)) : 0; - vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0; + vis->IndexBits = indexBits; + vis->DepthBits = depthBits; + vis->AccumRedBits = (accumRedBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->AccumGreenBits = (accumGreenBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->AccumBlueBits = (accumBlueBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->AccumAlphaBits = (accumAlphaBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0; vis->SoftwareAlpha = alphaFlag; @@ -333,10 +351,38 @@ GLvisual *gl_create_visual( GLboolean rgbFlag, } +/* This function should no longer be used. Use _mesa_create_visual() instead */ +GLvisual *gl_create_visual( GLboolean rgbFlag, + GLboolean alphaFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint depthBits, + GLint stencilBits, + GLint accumBits, + GLint indexBits, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits ) +{ + return _mesa_create_visual(rgbFlag, alphaFlag, dbFlag, stereoFlag, + redBits, greenBits, blueBits, alphaBits, + indexBits, depthBits, stencilBits, + accumBits, accumBits, accumBits, accumBits, 0); +} + +void +_mesa_destroy_visual( GLvisual *vis ) +{ + FREE(vis); +} + + +/* obsolete */ void gl_destroy_visual( GLvisual *vis ) { - FREE( vis ); + _mesa_destroy_visual(vis); } @@ -380,7 +426,9 @@ GLframebuffer *gl_create_framebuffer( GLvisual *visual, } if (softwareAccum) { assert(visual->RGBAflag); - assert(visual->AccumBits > 0); + assert(visual->AccumRedBits > 0); + assert(visual->AccumGreenBits > 0); + assert(visual->AccumBlueBits > 0); } if (softwareAlpha) { assert(visual->RGBAflag); @@ -730,18 +778,6 @@ static void init_2d_map( struct gl_2d_map *map, int n, const float *initial ) } -static void init_color_table( struct gl_color_table *p ) -{ - p->Table[0] = 255; - p->Table[1] = 255; - p->Table[2] = 255; - p->Table[3] = 255; - p->Size = 1; - p->IntFormat = GL_RGBA; - p->Format = GL_RGBA; -} - - /* * Initialize the attribute groups in a GLcontext. */ @@ -768,6 +804,7 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH; ctx->Const.LineWidthGranularity = LINE_WIDTH_GRANULARITY; ctx->Const.NumAuxBuffers = NUM_AUX_BUFFERS; + ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE; /* Modelview matrix */ gl_matrix_ctr( &ctx->ModelView ); @@ -805,6 +842,13 @@ static void init_attrib_groups( GLcontext *ctx ) } } + /* Color matrix */ + gl_matrix_ctr(&ctx->ColorMatrix); + ctx->ColorStackDepth = 0; + for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) { + gl_matrix_ctr(&ctx->ColorStack[j]); + } + /* Accumulate buffer group */ ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); @@ -941,10 +985,36 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Hint.Fog = GL_DONT_CARE; ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_TRUE; ctx->Hint.AllowDrawMem = GL_TRUE; ctx->Hint.StrictLighting = GL_TRUE; + /* Histogram group */ + ctx->Histogram.Width = 0; + ctx->Histogram.Format = GL_RGBA; + ctx->Histogram.Sink = GL_FALSE; + ctx->Histogram.RedSize = 0xffffffff; + ctx->Histogram.GreenSize = 0xffffffff; + ctx->Histogram.BlueSize = 0xffffffff; + ctx->Histogram.AlphaSize = 0xffffffff; + ctx->Histogram.LuminanceSize = 0xffffffff; + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } + + /* Min/Max group */ + ctx->MinMax.Format = GL_RGBA; + ctx->MinMax.Sink = GL_FALSE; + ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; + ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; + ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; + ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; + + + /* Pipeline */ gl_pipeline_init( ctx ); gl_cva_init( ctx ); @@ -1041,6 +1111,30 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Pixel.MapGtoG[0] = 0.0; ctx->Pixel.MapBtoB[0] = 0.0; ctx->Pixel.MapAtoA[0] = 0.0; + ctx->Pixel.HistogramEnabled = GL_FALSE; + ctx->Pixel.MinMaxEnabled = GL_FALSE; + ctx->Pixel.PixelTextureEnabled = GL_FALSE; + ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS; + ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS; + ctx->Pixel.PostColorMatrixRedBias = 0.0; + ctx->Pixel.PostColorMatrixRedScale = 1.0; + ctx->Pixel.PostColorMatrixGreenBias = 0.0; + ctx->Pixel.PostColorMatrixGreenScale = 1.0; + ctx->Pixel.PostColorMatrixBlueBias = 0.0; + ctx->Pixel.PostColorMatrixBlueScale = 1.0; + ctx->Pixel.PostColorMatrixAlphaBias = 0.0; + ctx->Pixel.PostColorMatrixAlphaScale = 1.0; + ctx->Pixel.ColorTableScale[0] = 1.0F; + ctx->Pixel.ColorTableScale[1] = 1.0F; + ctx->Pixel.ColorTableScale[2] = 1.0F; + ctx->Pixel.ColorTableScale[3] = 1.0F; + ctx->Pixel.ColorTableBias[0] = 0.0F; + ctx->Pixel.ColorTableBias[1] = 0.0F; + ctx->Pixel.ColorTableBias[2] = 0.0F; + ctx->Pixel.ColorTableBias[3] = 0.0F; + ctx->Pixel.ColorTableEnabled = GL_FALSE; + ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE; + ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE; /* Point group */ ctx->Point.SmoothFlag = GL_FALSE; @@ -1096,7 +1190,7 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Texture.Enabled = 0; for (i=0; i<MAX_TEXTURE_UNITS; i++) init_texture_unit( ctx, i ); - init_color_table(&ctx->Texture.Palette); + _mesa_init_colortable(&ctx->Texture.Palette); /* Transformation group */ ctx->Transform.MatrixMode = GL_MODELVIEW; @@ -1204,6 +1298,23 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->AttribStackDepth = 0; ctx->ClientAttribStackDepth = 0; + /* Display list */ + ctx->CallDepth = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + ctx->CurrentListPtr = NULL; + ctx->CurrentBlock = NULL; + ctx->CurrentListNum = 0; + ctx->CurrentPos = 0; + + /* Color tables */ + _mesa_init_colortable(&ctx->ColorTable); + _mesa_init_colortable(&ctx->ProxyColorTable); + _mesa_init_colortable(&ctx->PostConvolutionColorTable); + _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable); + _mesa_init_colortable(&ctx->PostColorMatrixColorTable); + _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable); + /* Miscellaneous */ ctx->NewState = NEW_ALL; ctx->RenderMode = GL_RENDER; @@ -1215,19 +1326,11 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->NeedEyeNormals = GL_FALSE; ctx->vb_proj_matrix = &ctx->ModelProjectMatrix; - /* Display list */ - ctx->CallDepth = 0; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - ctx->CurrentListPtr = NULL; - ctx->CurrentBlock = NULL; - ctx->CurrentListNum = 0; - ctx->CurrentPos = 0; - ctx->ErrorValue = (GLenum) GL_NO_ERROR; ctx->CatchSignals = GL_TRUE; ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; /* For debug/development only */ ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE; @@ -1478,7 +1581,7 @@ void gl_free_context_data( GLcontext *ctx ) FREE( ctx->PB ); - if(ctx->input != ctx->VB->IM) + if (ctx->input != ctx->VB->IM) gl_immediate_free( ctx->input ); gl_vb_free( ctx->VB ); @@ -1541,6 +1644,11 @@ void gl_free_context_data( GLcontext *ctx ) if (ctx->EvalMap.Map2Texture4.Points) FREE( ctx->EvalMap.Map2Texture4.Points ); + _mesa_free_colortable_data( &ctx->ColorTable ); + _mesa_free_colortable_data( &ctx->PostConvolutionColorTable ); + _mesa_free_colortable_data( &ctx->PostColorMatrixColorTable ); + _mesa_free_colortable_data( &ctx->Texture.Palette ); + /* Free cache of immediate buffers. */ while (ctx->nr_im_queued-- > 0) { struct immediate * next = ctx->freed_im_queue->next; diff --git a/xc/extras/Mesa/src/context.h b/xc/extras/Mesa/src/context.h index 1f0b0d063..da5ad0d72 100644 --- a/xc/extras/Mesa/src/context.h +++ b/xc/extras/Mesa/src/context.h @@ -56,6 +56,25 @@ * the colorbuffer, depth buffer, stencil buffer and accum buffer which will * be used by the GL context and framebuffer. */ +extern GLvisual * +_mesa_create_visual( GLboolean rgbFlag, + GLboolean alphaFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint indexBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +/* this function is obsolete */ extern GLvisual *gl_create_visual( GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, @@ -69,7 +88,11 @@ extern GLvisual *gl_create_visual( GLboolean rgbFlag, GLint blueBits, GLint alphaBits ); -extern void gl_destroy_visual( GLvisual *vis ); + +extern void +_mesa_destroy_visual( GLvisual *vis ); + +/*obsolete */ extern void gl_destroy_visual( GLvisual *vis ); /* diff --git a/xc/extras/Mesa/src/copypix.c b/xc/extras/Mesa/src/copypix.c index 0ca25b9f7..17175644b 100644 --- a/xc/extras/Mesa/src/copypix.c +++ b/xc/extras/Mesa/src/copypix.c @@ -36,9 +36,11 @@ #include "mem.h" #include "mmath.h" #include "pixel.h" +#include "pixeltex.h" #include "span.h" #include "state.h" #include "stencil.h" +#include "texture.h" #include "types.h" #include "zoom.h" #endif @@ -83,6 +85,7 @@ static void copy_rgba_pixels( GLcontext *ctx, GLubyte *saveReadAlpha; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; + GLboolean applyTransferOps; /* Determine if copy should be done bottom-to-top or top-to-bottom */ if (srcy < desty) { @@ -156,6 +159,14 @@ static void copy_rgba_pixels( GLcontext *ctx, p = NULL; } + applyTransferOps = ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled; + for (j = 0; j < height; j++, sy += stepy, dy += stepy) { if (overlapping) { MEMCPY(rgba, p, width * sizeof(GLubyte) * 4); @@ -188,12 +199,62 @@ static void copy_rgba_pixels( GLcontext *ctx, ctx->ReadBuffer->Alpha = saveReadAlpha; } - if (ctx->Pixel.ScaleOrBiasRGBA) { - gl_scale_and_bias_rgba( ctx, width, rgba ); + if (applyTransferOps) { + const GLfloat scale = (1.0F / 255.0F); + GLfloat rgbaFloat[MAX_WIDTH][4]; + GLuint k; + /* convert ubyte to float */ + for (k = 0; k < width; k++) { + rgbaFloat[k][RCOMP] = (GLfloat) rgba[k][RCOMP] * scale; + rgbaFloat[k][GCOMP] = (GLfloat) rgba[k][GCOMP] * scale; + rgbaFloat[k][BCOMP] = (GLfloat) rgba[k][BCOMP] * scale; + rgbaFloat[k][ACOMP] = (GLfloat) rgba[k][ACOMP] * scale; + } + /* scale & bias */ + if (ctx->Pixel.ScaleOrBiasRGBA) { + _mesa_scale_and_bias_rgba(ctx, width, rgbaFloat); + } + /* color map lookup */ + if (ctx->Pixel.MapColorFlag) { + _mesa_map_rgba(ctx, width, rgbaFloat); + } + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, width, rgbaFloat); + } + /* color matrix */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, width, rgbaFloat); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, width, rgbaFloat); + } + /* clamp to [0,1] and convert float back to ubyte */ + for (k = 0; k < width; k++) { + GLint r = (GLint) (rgbaFloat[k][RCOMP] * 255.0F); + GLint g = (GLint) (rgbaFloat[k][GCOMP] * 255.0F); + GLint b = (GLint) (rgbaFloat[k][BCOMP] * 255.0F); + GLint a = (GLint) (rgbaFloat[k][ACOMP] * 255.0F); + rgba[k][RCOMP] = (GLubyte) CLAMP(r, 0, 255); + rgba[k][GCOMP] = (GLubyte) CLAMP(g, 0, 255); + rgba[k][BCOMP] = (GLubyte) CLAMP(b, 0, 255); + rgba[k][ACOMP] = (GLubyte) CLAMP(a, 0, 255); + } } - if (ctx->Pixel.MapColorFlag) { - gl_map_rgba( ctx, width, rgba ); + + if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) { + GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH]; + GLuint unit; + /* XXX not sure how multitexture is supposed to work here */ + for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) { + _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba, + s, t, r, q); + gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba); + } } + if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) { (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy, (const GLubyte (*)[4])rgba, NULL ); @@ -298,10 +359,10 @@ static void copy_ci_pixels( GLcontext *ctx, } if (shift_or_offset) { - gl_shift_and_offset_ci( ctx, width, indexes ); + _mesa_shift_and_offset_ci( ctx, width, indexes ); } if (ctx->Pixel.MapColorFlag) { - gl_map_ci( ctx, width, indexes ); + _mesa_map_ci( ctx, width, indexes ); } if (zoom) { @@ -473,7 +534,7 @@ static void copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } p = psten; for (j = 0; j < height; j++, ssy += stepy) { - gl_read_stencil_span( ctx, width, srcx, ssy, p ); + _mesa_read_stencil_span( ctx, width, srcx, ssy, p ); p += width; } p = psten; @@ -491,21 +552,21 @@ static void copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, p += width; } else { - gl_read_stencil_span( ctx, width, srcx, sy, stencil ); + _mesa_read_stencil_span( ctx, width, srcx, sy, stencil ); } if (shift_or_offset) { - gl_shift_and_offset_stencil( ctx, width, stencil ); + _mesa_shift_and_offset_stencil( ctx, width, stencil ); } if (ctx->Pixel.MapStencilFlag) { - gl_map_stencil( ctx, width, stencil ); + _mesa_map_stencil( ctx, width, stencil ); } if (zoom) { gl_write_zoomed_stencil_span( ctx, width, destx, dy, stencil, desty ); } else { - gl_write_stencil_span( ctx, width, destx, dy, stencil ); + _mesa_write_stencil_span( ctx, width, destx, dy, stencil ); } } @@ -542,6 +603,8 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, destx = (GLint) (ctx->Current.RasterPos[0] + 0.5F); desty = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + ctx->OcclusionResult = GL_TRUE; + if (ctx->Driver.CopyPixels && (*ctx->Driver.CopyPixels)( ctx, srcx, srcy, width, height, destx, desty, type )) { diff --git a/xc/extras/Mesa/src/depth.c b/xc/extras/Mesa/src/depth.c index 73fd68fb8..ae119018e 100644 --- a/xc/extras/Mesa/src/depth.c +++ b/xc/extras/Mesa/src/depth.c @@ -381,7 +381,7 @@ depth_test_span16( GLcontext *ctx, GLuint n, GLint x, GLint y, } break; case GL_NEVER: - MEMSET(mask, 0, n * sizeof(GLubyte)); + BZERO(mask, n * sizeof(GLubyte)); break; default: gl_problem(ctx, "Bad depth func in depth_test_span16"); @@ -610,7 +610,7 @@ depth_test_span32( GLcontext *ctx, GLuint n, GLint x, GLint y, } break; case GL_NEVER: - MEMSET(mask, 0, n * sizeof(GLubyte)); + BZERO(mask, n * sizeof(GLubyte)); break; default: gl_problem(ctx, "Bad depth func in depth_test_span32"); @@ -893,7 +893,7 @@ software_depth_test_pixels16( GLcontext *ctx, GLuint n, break; case GL_NEVER: /* depth test never passes */ - MEMSET(mask, 0, n * sizeof(GLubyte)); + BZERO(mask, n * sizeof(GLubyte)); break; default: gl_problem(ctx, "Bad depth func in software_depth_test_pixels"); @@ -1139,7 +1139,7 @@ software_depth_test_pixels32( GLcontext *ctx, GLuint n, break; case GL_NEVER: /* depth test never passes */ - MEMSET(mask, 0, n * sizeof(GLubyte)); + BZERO(mask, n * sizeof(GLubyte)); break; default: gl_problem(ctx, "Bad depth func in software_depth_test_pixels"); @@ -1373,7 +1373,7 @@ hardware_depth_test_pixels( GLcontext *ctx, GLuint n, GLdepth zbuffer[], break; case GL_NEVER: /* depth test never passes */ - MEMSET(mask, 0, n * sizeof(GLubyte)); + BZERO(mask, n * sizeof(GLubyte)); break; default: gl_problem(ctx, "Bad depth func in hardware_depth_test_pixels"); @@ -1417,6 +1417,74 @@ _mesa_depth_test_pixels( GLcontext *ctx, /* + * Read a span of depth values from the depth buffer. + * This function does clipping before calling the device driver function. + */ +void +_mesa_read_depth_span( GLcontext *ctx, + GLint n, GLint x, GLint y, GLdepth depth[] ) +{ + if (y < 0 || y >= ctx->DrawBuffer->Height || + x + (GLint) n <= 0 || x >= ctx->DrawBuffer->Width) { + /* span is completely outside framebuffer */ + GLint i; + for (i = 0; i < n; i++) + depth[i] = 0; + return; + } + + if (x < 0) { + GLint dx = -x; + GLint i; + for (i = 0; i < dx; i++) + depth[i] = 0; + x = 0; + n -= dx; + depth += dx; + } + if (x + n > ctx->DrawBuffer->Width) { + GLint dx = x + n - ctx->DrawBuffer->Width; + GLint i; + for (i = 0; i < dx; i++) + depth[n - i - 1] = 0; + n -= dx; + } + if (n <= 0) { + return; + } + + if (ctx->DrawBuffer->DepthBuffer) { + /* read from software depth buffer */ + if (ctx->Visual->DepthBits <= 16) { + const GLushort *zptr = Z_ADDRESS16( ctx, x, y ); + GLuint i; + for (i = 0; i < n; i++) { + depth[i] = zptr[i]; + } + } + else { + const GLuint *zptr = Z_ADDRESS32( ctx, x, y ); + GLuint i; + for (i = 0; i < n; i++) { + depth[i] = zptr[i]; + } + } + } + else if (ctx->Driver.ReadDepthSpan) { + /* read from hardware depth buffer */ + (*ctx->Driver.ReadDepthSpan)( ctx, n, x, y, depth ); + } + else { + /* no depth buffer */ + BZERO(depth, n * sizeof(GLfloat)); + } + +} + + + + +/* * Return a span of depth values from the depth buffer as floats in [0,1]. * This is used for both hardware and software depth buffers. * Input: n - how many pixels @@ -1424,11 +1492,39 @@ _mesa_depth_test_pixels( GLcontext *ctx, * Output: depth - the array of depth values */ void -_mesa_read_depth_span_float( GLcontext* ctx, - GLuint n, GLint x, GLint y, GLfloat depth[] ) +_mesa_read_depth_span_float( GLcontext *ctx, + GLint n, GLint x, GLint y, GLfloat depth[] ) { const GLfloat scale = 1.0F / ctx->Visual->DepthMaxF; + if (y < 0 || y >= ctx->DrawBuffer->Height || + x + (GLint) n <= 0 || x >= ctx->DrawBuffer->Width) { + /* span is completely outside framebuffer */ + GLint i; + for (i = 0; i < n; i++) + depth[i] = 0.0F; + return; + } + + if (x < 0) { + GLint dx = -x; + GLint i; + for (i = 0; i < dx; i++) + depth[i] = 0.0F; + n -= dx; + x = 0; + } + if (x + n > ctx->DrawBuffer->Width) { + GLint dx = x + n - ctx->DrawBuffer->Width; + GLint i; + for (i = 0; i < dx; i++) + depth[n - i - 1] = 0.0F; + n -= dx; + } + if (n <= 0) { + return; + } + if (ctx->DrawBuffer->DepthBuffer) { /* read from software depth buffer */ if (ctx->Visual->DepthBits <= 16) { @@ -1458,7 +1554,7 @@ _mesa_read_depth_span_float( GLcontext* ctx, } else { /* no depth buffer */ - MEMSET(depth, 0, n * sizeof(GLfloat)); + BZERO(depth, n * sizeof(GLfloat)); } } @@ -1564,9 +1660,15 @@ _mesa_clear_depth_buffer( GLcontext *ctx ) if (ctx->Visual->DepthBits <= 16) { const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->Visual->DepthMax); if ((clearValue & 0xff) == (clearValue >> 8)) { - /* lower and upper bytes of clear_value are same, use MEMSET */ - MEMSET( ctx->DrawBuffer->DepthBuffer, clearValue & 0xff, - 2 * ctx->DrawBuffer->Width * ctx->DrawBuffer->Height); + if (clearValue == 0) { + BZERO(ctx->DrawBuffer->DepthBuffer, + 2*ctx->DrawBuffer->Width*ctx->DrawBuffer->Height); + } + else { + /* lower and upper bytes of clear_value are same, use MEMSET */ + MEMSET( ctx->DrawBuffer->DepthBuffer, clearValue & 0xff, + 2 * ctx->DrawBuffer->Width * ctx->DrawBuffer->Height); + } } else { GLushort *d = (GLushort *) ctx->DrawBuffer->DepthBuffer; @@ -1591,24 +1693,30 @@ _mesa_clear_depth_buffer( GLcontext *ctx ) } else { /* >16 bit depth buffer */ - GLuint *d = (GLuint *) ctx->DrawBuffer->DepthBuffer; const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->Visual->DepthMax); - GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height; - while (n >= 16) { - d[0] = clearValue; d[1] = clearValue; - d[2] = clearValue; d[3] = clearValue; - d[4] = clearValue; d[5] = clearValue; - d[6] = clearValue; d[7] = clearValue; - d[8] = clearValue; d[9] = clearValue; - d[10] = clearValue; d[11] = clearValue; - d[12] = clearValue; d[13] = clearValue; - d[14] = clearValue; d[15] = clearValue; - d += 16; - n -= 16; + if (clearValue == 0) { + BZERO(ctx->DrawBuffer->DepthBuffer, + ctx->DrawBuffer->Width*ctx->DrawBuffer->Height*sizeof(GLuint)); } - while (n > 0) { - *d++ = clearValue; - n--; + else { + GLint n = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height; + GLuint *d = (GLuint *) ctx->DrawBuffer->DepthBuffer; + while (n >= 16) { + d[0] = clearValue; d[1] = clearValue; + d[2] = clearValue; d[3] = clearValue; + d[4] = clearValue; d[5] = clearValue; + d[6] = clearValue; d[7] = clearValue; + d[8] = clearValue; d[9] = clearValue; + d[10] = clearValue; d[11] = clearValue; + d[12] = clearValue; d[13] = clearValue; + d[14] = clearValue; d[15] = clearValue; + d += 16; + n -= 16; + } + while (n > 0) { + *d++ = clearValue; + n--; + } } } } diff --git a/xc/extras/Mesa/src/depth.h b/xc/extras/Mesa/src/depth.h index 041318235..9bf009997 100644 --- a/xc/extras/Mesa/src/depth.h +++ b/xc/extras/Mesa/src/depth.h @@ -67,7 +67,12 @@ _mesa_depth_test_pixels( GLcontext *ctx, extern void -_mesa_read_depth_span_float( GLcontext *ctx, GLuint n, GLint x, GLint y, +_mesa_read_depth_span( GLcontext *ctx, + GLint n, GLint x, GLint y, GLdepth depth[] ); + + +extern void +_mesa_read_depth_span_float( GLcontext *ctx, GLint n, GLint x, GLint y, GLfloat depth[] ); diff --git a/xc/extras/Mesa/src/dlist.c b/xc/extras/Mesa/src/dlist.c index b2cc13787..929a050db 100644 --- a/xc/extras/Mesa/src/dlist.c +++ b/xc/extras/Mesa/src/dlist.c @@ -58,6 +58,7 @@ #include "mem.h" #include "pipeline.h" #include "pixel.h" +#include "pixeltex.h" #include "points.h" #include "polygon.h" #include "readpix.h" @@ -226,6 +227,9 @@ typedef enum { /* GL_ARB_multitexture */ OPCODE_ACTIVE_TEXTURE, OPCODE_CLIENT_ACTIVE_TEXTURE, + /* GL_SGIX/SGIS_pixel_texture */ + OPCODE_PIXEL_TEXGEN_SGIX, + OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */ @@ -585,6 +589,9 @@ void gl_init_lists( void ) InstSize[OPCODE_ERROR] = 3; InstSize[OPCODE_VERTEX_CASSETTE] = 9; InstSize[OPCODE_END_OF_LIST] = 1; + /* GL_SGIX/SGIS_pixel_texture */ + InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2; + InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3, /* GL_ARB_multitexture */ InstSize[OPCODE_ACTIVE_TEXTURE] = 2; InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2; @@ -3223,6 +3230,53 @@ static void save_MultTransposeMatrixfARB( const GLfloat m[16] ) } +static void save_PixelTexGenSGIX(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->PixelTexGenSGIX)( mode ); + } +} + + +static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 ); + if (n) { + n[1].e = target; + n[2].i = value; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value ); + } +} + + +static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value) +{ + save_PixelTexGenParameteriSGIS(target, (GLint) value); +} + + +static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value) +{ + save_PixelTexGenParameteriSGIS(target, *value); +} + + +static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value) +{ + save_PixelTexGenParameteriSGIS(target, (GLint) *value); +} void gl_compile_cassette( GLcontext *ctx ) { @@ -3870,6 +3924,12 @@ static void execute_list( GLcontext *ctx, GLuint list ) case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ (*ctx->Exec->ClientActiveTextureARB)( n[1].e ); break; + case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */ + (*ctx->Exec->PixelTexGenSGIX)( n[1].e ); + break; + case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */ + (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i ); + break; case OPCODE_CONTINUE: n = (Node *) n[1].next; break; @@ -4567,6 +4627,17 @@ _mesa_init_dlist_table( struct _glapi_table *table ) table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; + /* 15. GL_SGIX_pixel_texture */ + table->PixelTexGenSGIX = save_PixelTexGenSGIX; + + /* 15. GL_SGIS_pixel_texture */ + table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS; + table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS; + table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS; + table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS; + table->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; + table->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; + /* GL_EXT_compiled_vertex_array */ table->LockArraysEXT = _mesa_LockArraysEXT; table->UnlockArraysEXT = _mesa_UnlockArraysEXT; @@ -4808,7 +4879,6 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list ) case OPCODE_END_OF_LIST: fprintf(f,"END-LIST %u\n", list); done = GL_TRUE; - gl_print_cassette( (struct immediate *) n[1].data ); break; default: if (opcode < 0 || opcode > OPCODE_END_OF_LIST) { diff --git a/xc/extras/Mesa/src/dlist.h b/xc/extras/Mesa/src/dlist.h index a5233e50c..3305392d9 100644 --- a/xc/extras/Mesa/src/dlist.h +++ b/xc/extras/Mesa/src/dlist.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,15 +24,13 @@ */ - - - #ifndef DLIST_H #define DLIST_H #include "types.h" + struct display_list { union node *nodes; GLuint OrFlag; @@ -68,7 +66,6 @@ extern void _mesa_NewList( GLuint list, GLenum mode ); extern void _mesa_init_dlist_table( struct _glapi_table *table ); - extern void gl_compile_cassette( GLcontext *ctx ); extern void gl_save_error( GLcontext *ctx, GLenum error, const char *s ); diff --git a/xc/extras/Mesa/src/drawpix.c b/xc/extras/Mesa/src/drawpix.c index 283ca63e5..362e30b9c 100644 --- a/xc/extras/Mesa/src/drawpix.c +++ b/xc/extras/Mesa/src/drawpix.c @@ -36,9 +36,11 @@ #include "mem.h" #include "mmath.h" #include "pixel.h" +#include "pixeltex.h" #include "span.h" #include "state.h" #include "stencil.h" +#include "texture.h" #include "types.h" #include "zoom.h" #endif @@ -113,17 +115,16 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, return GL_TRUE; } - if (ctx->NewState) { - gl_update_state(ctx); - } - if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0 - && ctx->Pixel.RedBias==0.0 && ctx->Pixel.RedScale==1.0 - && ctx->Pixel.GreenBias==0.0 && ctx->Pixel.GreenScale==1.0 - && ctx->Pixel.BlueBias==0.0 && ctx->Pixel.BlueScale==1.0 - && ctx->Pixel.AlphaBias==0.0 && ctx->Pixel.AlphaScale==1.0 + && !ctx->Pixel.ScaleOrBiasRGBA + && !ctx->Pixel.ScaleOrBiasRGBApcm + && ctx->ColorMatrix.type == MATRIX_IDENTITY + && !ctx->Pixel.ColorTableEnabled + && !ctx->Pixel.PostColorMatrixColorTableEnabled + && !ctx->Pixel.MinMaxEnabled && ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0 && ctx->Pixel.MapColorFlag==0 + && ctx->Texture.ReallyEnabled == 0 && unpack->Alignment==1 && !unpack->SwapBytes && !unpack->LsbFirst) { @@ -341,7 +342,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, GLint row; for (row=0; row<drawHeight; row++) { assert(drawWidth < MAX_WIDTH); - gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba); + _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba); (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY, (const GLubyte (*)[4])rgba, NULL); @@ -355,7 +356,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, GLint row; for (row=0; row<drawHeight; row++) { assert(drawWidth < MAX_WIDTH); - gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba); + _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba); gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY, zSpan, (void *) rgba, zoomY0); src += rowLength; @@ -449,6 +450,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, GLenum type, const GLvoid *pixels ) { const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; + const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset; const GLint desty = y; GLint row, drawWidth; @@ -473,14 +475,20 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, const GLvoid *source = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0); _mesa_unpack_index_span(ctx, drawWidth, destType, values, - type, source, &ctx->Unpack, GL_TRUE); + type, source, &ctx->Unpack, GL_FALSE); + if (shift_or_offset) { + _mesa_shift_and_offset_stencil( ctx, drawWidth, values ); + } + if (ctx->Pixel.MapStencilFlag) { + _mesa_map_stencil( ctx, drawWidth, values ); + } if (zoom) { gl_write_zoomed_stencil_span( ctx, (GLuint) drawWidth, x, y, values, desty ); } else { - gl_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values ); + _mesa_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values ); } } } @@ -643,6 +651,19 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, pixels, width, height, format, type, 0, row, 0); _mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba, format, type, source, unpack, GL_TRUE); + if (ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) + continue; + + if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) { + GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH]; + GLuint unit; + /* XXX not sure how multitexture is supposed to work here */ + for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) { + _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba, + s, t, r, q); + gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba); + } + } if (quickDraw) { (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y, @@ -677,9 +698,15 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, return; } + if (ctx->NewState) { + gl_update_state(ctx); + } + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + ctx->OcclusionResult = GL_TRUE; + /* see if device driver can do the drawpix */ if (ctx->Driver.DrawPixels && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type, diff --git a/xc/extras/Mesa/src/enable.c b/xc/extras/Mesa/src/enable.c index cc81c8557..38a2f396d 100644 --- a/xc/extras/Mesa/src/enable.c +++ b/xc/extras/Mesa/src/enable.c @@ -454,6 +454,10 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) case GL_OCCLUSION_TEST_HP: if (ctx->Extensions.HaveHpOcclusionTest) { ctx->Depth.OcclusionTest = state; + if (state) + ctx->OcclusionResult = ctx->OcclusionResultSaved; + else + ctx->OcclusionResultSaved = ctx->OcclusionResult; ctx->NewState |= NEW_RASTER_OPS; } else { @@ -462,6 +466,27 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) } break; + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + ctx->Pixel.PixelTextureEnabled = state; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + ctx->Pixel.PixelTextureEnabled = state; + break; + + /* GL_SGI_color_table */ + case GL_COLOR_TABLE_SGI: + ctx->Pixel.ColorTableEnabled = state; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + ctx->Pixel.PostConvolutionColorTableEnabled = state; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + ctx->Pixel.PostColorMatrixColorTableEnabled = state; + break; + default: if (state) { gl_error( ctx, GL_INVALID_ENUM, "glEnable" ); @@ -666,6 +691,22 @@ _mesa_IsEnabled( GLenum cap ) return GL_FALSE; } + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + return ctx->Pixel.PixelTextureEnabled; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + return ctx->Pixel.PixelTextureEnabled; + + /* GL_SGI_color_table */ + case GL_COLOR_TABLE_SGI: + return ctx->Pixel.ColorTableEnabled; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + return ctx->Pixel.PostConvolutionColorTableEnabled; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + return ctx->Pixel.PostColorMatrixColorTableEnabled; + default: gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); return GL_FALSE; diff --git a/xc/extras/Mesa/src/extensions.c b/xc/extras/Mesa/src/extensions.c index 5c952217e..89e3ab420 100644 --- a/xc/extras/Mesa/src/extensions.c +++ b/xc/extras/Mesa/src/extensions.c @@ -48,36 +48,40 @@ struct extension { static struct { int enabled; const char *name; } default_extensions[] = { + { DEFAULT_OFF, "GL_ARB_imaging" }, + { DEFAULT_ON, "GL_ARB_multitexture" }, + { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" }, + { ALWAYS_ENABLED, "GL_EXT_abgr" }, { DEFAULT_ON, "GL_EXT_blend_color" }, - { DEFAULT_OFF, "ARB_imaging" }, - { DEFAULT_ON, "GL_EXT_blend_minmax" }, { DEFAULT_ON, "GL_EXT_blend_logic_op" }, + { DEFAULT_ON, "GL_EXT_blend_minmax" }, { DEFAULT_ON, "GL_EXT_blend_subtract" }, + { DEFAULT_ON, "GL_EXT_clip_volume_hint" }, + { DEFAULT_ON, "GL_EXT_compiled_vertex_array" }, { DEFAULT_ON, "GL_EXT_paletted_texture" }, { DEFAULT_ON, "GL_EXT_point_parameters" }, { ALWAYS_ENABLED, "GL_EXT_polygon_offset" }, - { ALWAYS_ENABLED, "GL_EXT_vertex_array" }, - { ALWAYS_ENABLED, "GL_EXT_texture_object" }, - { DEFAULT_ON, "GL_EXT_texture3D" }, - { ALWAYS_ENABLED, "GL_MESA_window_pos" }, - { ALWAYS_ENABLED, "GL_MESA_resize_buffers" }, - { DEFAULT_ON, "GL_EXT_shared_texture_palette" }, { ALWAYS_ENABLED, "GL_EXT_rescale_normal" }, - { ALWAYS_ENABLED, "GL_EXT_abgr" }, - { ALWAYS_ENABLED, "GL_SGIS_texture_edge_clamp" }, + { DEFAULT_ON, "GL_EXT_shared_texture_palette" }, { ALWAYS_ENABLED, "GL_EXT_stencil_wrap" }, + { DEFAULT_ON, "GL_EXT_texture3D" }, + { DEFAULT_OFF, "GL_EXT_texture_env" }, + { DEFAULT_ON, "GL_EXT_texture_env_add" }, + { ALWAYS_ENABLED, "GL_EXT_texture_object" }, + { DEFAULT_ON, "GL_EXT_texture_lod_bias" }, + { ALWAYS_ENABLED, "GL_EXT_vertex_array" }, + { DEFAULT_OFF, "GL_EXT_vertex_array_set" }, + { DEFAULT_OFF, "GL_HP_occlusion_test" }, { DEFAULT_ON, "GL_INGR_blend_func_separate" }, - { DEFAULT_ON, "GL_ARB_multitexture" }, + { ALWAYS_ENABLED, "GL_MESA_window_pos" }, + { ALWAYS_ENABLED, "GL_MESA_resize_buffers" }, { ALWAYS_ENABLED, "GL_NV_texgen_reflection" }, { DEFAULT_ON, "GL_PGI_misc_hints" }, - { DEFAULT_ON, "GL_EXT_compiled_vertex_array" }, - { DEFAULT_ON, "GL_EXT_clip_volume_hint" }, - { DEFAULT_ON, "GL_EXT_texture_env_add" }, - { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" }, - { DEFAULT_OFF, "GL_EXT_vertex_array_set" }, - { DEFAULT_OFF, "GL_EXT_texture_env" }, - { DEFAULT_ON, "GL_EXT_texture_lod_bias" }, - { DEFAULT_OFF, "GL_HP_occlusion_test" } + { DEFAULT_ON, "GL_SGI_color_matrix" }, + { DEFAULT_ON, "GL_SGI_color_table" }, + { DEFAULT_ON, "GL_SGIS_pixel_texture" }, + { DEFAULT_ON, "GL_SGIS_texture_edge_clamp" }, + { DEFAULT_ON, "GL_SGIX_pixel_texture" } }; diff --git a/xc/extras/Mesa/src/fog.c b/xc/extras/Mesa/src/fog.c index e35906c8f..bac41cb1d 100644 --- a/xc/extras/Mesa/src/fog.c +++ b/xc/extras/Mesa/src/fog.c @@ -35,7 +35,6 @@ #include "types.h" #include "xform.h" #endif -#include "xform.h" diff --git a/xc/extras/Mesa/src/fog.h b/xc/extras/Mesa/src/fog.h index 59d84517b..28355dd44 100644 --- a/xc/extras/Mesa/src/fog.h +++ b/xc/extras/Mesa/src/fog.h @@ -31,6 +31,9 @@ #include "types.h" +extern struct gl_pipeline_stage gl_fog_coord_stage; + + extern void _mesa_Fogf(GLenum pname, GLfloat param); @@ -65,6 +68,4 @@ extern void _mesa_init_fog( void ); -extern struct gl_pipeline_stage gl_fog_coord_stage; - #endif diff --git a/xc/extras/Mesa/src/fog_tmp.h b/xc/extras/Mesa/src/fog_tmp.h index a0fa87229..5096b0a99 100644 --- a/xc/extras/Mesa/src/fog_tmp.h +++ b/xc/extras/Mesa/src/fog_tmp.h @@ -84,12 +84,11 @@ static void TAG(make_fog_coord)( struct vertex_buffer *VB, } else { - GLubyte r = 0; + GLubyte r = 255; if (ctx->Fog.Mode == GL_LINEAR) { - GLfloat f = ctx->Fog.End * (ctx->Fog.End - ctx->Fog.Start); + GLfloat f = 1.0 - ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start); CLAMP_FLOAT_COLOR( f ); - f = 1.0 - f; FLOAT_COLOR_TO_UBYTE_COLOR(r, f); } diff --git a/xc/extras/Mesa/src/general_clip.h b/xc/extras/Mesa/src/general_clip.h index 29a8eb760..c8bc8890a 100644 --- a/xc/extras/Mesa/src/general_clip.h +++ b/xc/extras/Mesa/src/general_clip.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,144 +28,56 @@ */ - -/* - * Clip against +X - * - * The if conditions are known at compile time. - */ -#define PLANE (CLIP_RIGHT_BIT) -#define INSIDE(K) (X(K) <= W(K)) -#define COMPUTE_INTERSECTION( in, out, new ) \ - dx = X(out)-X(in); \ - dw = W(out)-W(in); \ - t = (X(in)-W(in)) / (dw-dx); \ - neww = W(in) + t * dw; \ - X(new) = neww; \ - Y(new) = Y(in) + t * (Y(out) - Y(in)); \ - if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in)); \ - if (SIZE==4) coord[new][3] = neww; +#define PLANE CLIP_RIGHT_BIT +#define CLIP_DOTPROD(K) (- X(K) + W(K)) GENERAL_CLIP -#undef INSIDE +#undef CLIP_DOTPROD #undef PLANE -#undef COMPUTE_INTERSECTION -/* - * Clip against -X - */ -#define PLANE (CLIP_LEFT_BIT) -#define INSIDE(K) (X(K) >= -W(K)) -#define COMPUTE_INTERSECTION( in, out, new ) \ - dx = X(out)-X(in); \ - dw = W(out)-W(in); \ - t = -(X(in)+W(in)) / (dw+dx); \ - neww = W(in) + t * dw; \ - X(new) = -neww; \ - Y(new) = Y(in) + t * (Y(out) - Y(in)); \ - if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in)); \ - if (SIZE==4) coord[new][3] = neww; +#define PLANE CLIP_LEFT_BIT +#define CLIP_DOTPROD(K) (X(K) + W(K)) GENERAL_CLIP -#undef INSIDE +#undef CLIP_DOTPROD #undef PLANE -#undef COMPUTE_INTERSECTION - -/* - * Clip against +Y - */ -#define PLANE (CLIP_TOP_BIT) -#define INSIDE(K) (Y(K) <= W(K)) -#define COMPUTE_INTERSECTION( in, out, new ) \ - dy = Y(out)-Y(in); \ - dw = W(out)-W(in); \ - t = (Y(in)-W(in)) / (dw-dy); \ - neww = W(in) + t * dw; \ - X(new) = X(in) + t * (X(out) - X(in)); \ - Y(new) = neww; \ - if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in)); \ - if (SIZE==4) coord[new][3] = neww; +#define PLANE CLIP_TOP_BIT +#define CLIP_DOTPROD(K) (- Y(K) + W(K)) GENERAL_CLIP -#undef INSIDE +#undef CLIP_DOTPROD #undef PLANE -#undef COMPUTE_INTERSECTION - -/* - * Clip against -Y - */ -#define PLANE (CLIP_BOTTOM_BIT) -#define INSIDE(K) (Y(K) >= -W(K)) -#define COMPUTE_INTERSECTION( in, out, new ) \ - dy = Y(out)-Y(in); \ - dw = W(out)-W(in); \ - t = -(Y(in)+W(in)) / (dw+dy); \ - neww = W(in) + t * dw; \ - X(new) = X(in) + t * (X(out) - X(in)); \ - Y(new) = -neww; \ - if (SIZE>=3) coord[new][2] = Z(in) + t * (Z(out) - Z(in)); \ - if (SIZE==4) coord[new][3] = neww; +#define PLANE CLIP_BOTTOM_BIT +#define CLIP_DOTPROD(K) (Y(K) + W(K)) GENERAL_CLIP -#undef INSIDE +#undef CLIP_DOTPROD #undef PLANE -#undef COMPUTE_INTERSECTION - +#define PLANE CLIP_FAR_BIT +#define CLIP_DOTPROD(K) (- Z(K) + W(K)) -/* - * Clip against +Z - */ -#define PLANE (CLIP_FAR_BIT) -#define INSIDE(K) (Z(K) <= W(K)) -#define COMPUTE_INTERSECTION( in, out, new ) \ - dz = Z(out)-Z(in); \ - dw = W(out)-W(in); \ - t = (Z(in)-W(in)) / (dw-dz); \ - neww = W(in) + t * dw; \ - X(new) = X(in) + t * (X(out) - X(in)); \ - Y(new) = Y(in) + t * (Y(out) - Y(in)); \ - coord[new][2] = neww; \ - if (SIZE==4) coord[new][3] = neww; - - if (SIZE>=3) { - GENERAL_CLIP - } + if (SIZE >= 3) { + GENERAL_CLIP + } -#undef INSIDE +#undef CLIP_DOTPROD #undef PLANE -#undef COMPUTE_INTERSECTION +#define PLANE CLIP_NEAR_BIT +#define CLIP_DOTPROD(K) (Z(K) + W(K)) -/* - * Clip against -Z - */ -#define PLANE (CLIP_NEAR_BIT) -#define INSIDE(K) (Z(K) >= -W(K)) -#define COMPUTE_INTERSECTION( in, out, new ) \ - dz = Z(out)-Z(in); \ - dw = W(out)-W(in); \ - t = -(Z(in)+W(in)) / (dw+dz); \ - neww = W(in) + t * dw; \ - X(new) = X(in) + t * (X(out) - X(in)); \ - Y(new) = Y(in) + t * (Y(out) - Y(in)); \ - coord[new][2] = -neww; \ - if (SIZE==4) coord[new][3] = neww; - - if (SIZE>=3) { - GENERAL_CLIP - } + if (SIZE >=3 ) { + GENERAL_CLIP + } -#undef INSIDE +#undef CLIP_DOTPROD #undef PLANE -#undef COMPUTE_INTERSECTION #undef GENERAL_CLIP - - diff --git a/xc/extras/Mesa/src/get.c b/xc/extras/Mesa/src/get.c index f43e305e5..005f88e91 100644 --- a/xc/extras/Mesa/src/get.c +++ b/xc/extras/Mesa/src/get.c @@ -57,6 +57,28 @@ #endif +static GLenum +pixel_texgen_mode(const GLcontext *ctx) +{ + if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_POSITION) { + if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_POSITION) { + return GL_RGBA; + } + else { + return GL_RGB; + } + } + else { + if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_POSITION) { + return GL_ALPHA; + } + else { + return GL_NONE; + } + } +} + + void _mesa_GetBooleanv( GLenum pname, GLboolean *params ) @@ -74,10 +96,16 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumRedBits); + break; case GL_ACCUM_GREEN_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumGreenBits); + break; case GL_ACCUM_BLUE_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumBlueBits); + break; case GL_ACCUM_ALPHA_BITS: - *params = INT_TO_BOOL(ctx->Visual->AccumBits); + *params = INT_TO_BOOL(ctx->Visual->AccumAlphaBits); break; case GL_ACCUM_CLEAR_VALUE: params[0] = FLOAT_TO_BOOL(ctx->Accum.ClearColor[0]); @@ -934,12 +962,12 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (GLboolean) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (GLboolean) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -948,8 +976,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = (GLboolean) ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = (GLboolean) ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = (GLboolean) ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = (GLboolean) ctx->Hint.AllowDrawMem; @@ -1022,14 +1050,80 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) return; case GL_OCCLUSION_TEST_RESULT_HP: if (ctx->Extensions.HaveHpOcclusionTest) { - *params = ctx->OcclusionResult; - ctx->OcclusionResult = GL_FALSE; /* reset now */ + if (ctx->Depth.OcclusionTest) + *params = ctx->OcclusionResult; + else + *params = ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; } else { gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); } return; + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLboolean) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(ctx->ColorMatrix.m[i]); + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = INT_TO_BOOL(ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = FLOAT_TO_BOOL(MAX_COLOR_STACK_DEPTH); + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixRedScale); + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixGreenScale); + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBlueScale); + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixAlphaScale); + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixRedBias); + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixGreenBias); + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBlueBias); + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixAlphaBias); + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); } @@ -1054,10 +1148,16 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = (GLdouble) ctx->Visual->AccumRedBits; + break; case GL_ACCUM_GREEN_BITS: + *params = (GLdouble) ctx->Visual->AccumGreenBits; + break; case GL_ACCUM_BLUE_BITS: + *params = (GLdouble) ctx->Visual->AccumBlueBits; + break; case GL_ACCUM_ALPHA_BITS: - *params = (GLdouble) ctx->Visual->AccumBits; + *params = (GLdouble) ctx->Visual->AccumAlphaBits; break; case GL_ACCUM_CLEAR_VALUE: params[0] = (GLdouble) ctx->Accum.ClearColor[0]; @@ -1915,12 +2015,12 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (GLdouble) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (GLdouble) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -1929,8 +2029,8 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = (GLdouble) ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = (GLdouble) ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = (GLdouble) ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = (GLdouble) ctx->Hint.AllowDrawMem; @@ -2003,14 +2103,80 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) return; case GL_OCCLUSION_TEST_RESULT_HP: if (ctx->Extensions.HaveHpOcclusionTest) { - *params = (GLdouble) ctx->OcclusionResult; - ctx->OcclusionResult = GL_FALSE; /* reset now */ + if (ctx->Depth.OcclusionTest) + *params = (GLdouble) ctx->OcclusionResult; + else + *params = (GLdouble) ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; } else { gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); } return; + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = (GLdouble) ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = (GLdouble) ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLdouble) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = (GLdouble) ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLdouble) (ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLdouble) MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixRedScale; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixGreenScale; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBlueScale; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixAlphaScale; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixRedBias; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixGreenBias; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBlueBias; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixAlphaBias; + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = (GLdouble) ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = (GLdouble) ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); } @@ -2035,10 +2201,16 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = (GLfloat) ctx->Visual->AccumRedBits; + break; case GL_ACCUM_GREEN_BITS: + *params = (GLfloat) ctx->Visual->AccumGreenBits; + break; case GL_ACCUM_BLUE_BITS: + *params = (GLfloat) ctx->Visual->AccumBlueBits; + break; case GL_ACCUM_ALPHA_BITS: - *params = (GLfloat) ctx->Visual->AccumBits; + *params = (GLfloat) ctx->Visual->AccumAlphaBits; break; case GL_ACCUM_CLEAR_VALUE: params[0] = ctx->Accum.ClearColor[0]; @@ -2894,12 +3066,12 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (GLfloat) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (GLfloat) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -2908,8 +3080,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = (GLfloat) ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = (GLfloat) ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = (GLfloat) ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = (GLfloat) ctx->Hint.AllowDrawMem; @@ -2961,14 +3133,80 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) return; case GL_OCCLUSION_TEST_RESULT_HP: if (ctx->Extensions.HaveHpOcclusionTest) { - *params = (GLfloat) ctx->OcclusionResult; - ctx->OcclusionResult = GL_FALSE; /* reset now */ + if (ctx->Depth.OcclusionTest) + *params = (GLfloat) ctx->OcclusionResult; + else + *params = (GLfloat) ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; } else { gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); } return; + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = (GLfloat) ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = (GLfloat) ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLfloat) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLfloat) (ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLfloat) MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixRedScale; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixGreenScale; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixBlueScale; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixAlphaScale; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixRedBias; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixGreenBias; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixBlueBias; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixAlphaBias; + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = (GLfloat) ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = (GLfloat) ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = (GLfloat) ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); } @@ -2993,10 +3231,16 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = (GLint) ctx->Visual->AccumRedBits; + break; case GL_ACCUM_GREEN_BITS: + *params = (GLint) ctx->Visual->AccumGreenBits; + break; case GL_ACCUM_BLUE_BITS: + *params = (GLint) ctx->Visual->AccumBlueBits; + break; case GL_ACCUM_ALPHA_BITS: - *params = (GLint) ctx->Visual->AccumBits; + *params = (GLint) ctx->Visual->AccumAlphaBits; break; case GL_ACCUM_CLEAR_VALUE: params[0] = FLOAT_TO_INT( ctx->Accum.ClearColor[0] ); @@ -3854,12 +4098,12 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -3868,8 +4112,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = ctx->Hint.AllowDrawMem; @@ -3942,14 +4186,80 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) return; case GL_OCCLUSION_TEST_RESULT_HP: if (ctx->Extensions.HaveHpOcclusionTest) { - *params = (GLint) ctx->OcclusionResult; - ctx->OcclusionResult = GL_FALSE; /* reset now */ + if (ctx->Depth.OcclusionTest) + *params = (GLint) ctx->OcclusionResult; + else + *params = (GLint) ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; } else { gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); } return; + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = (GLint) ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = (GLint) ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLint) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = (GLint) ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = ctx->ColorStackDepth + 1; + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixRedScale; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixGreenScale; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBlueScale; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixAlphaScale; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixRedBias; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixGreenBias; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBlueBias; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixAlphaBias; + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = (GLint) ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = (GLint) ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); } diff --git a/xc/extras/Mesa/src/glapitemp.h b/xc/extras/Mesa/src/glapitemp.h index 7b940def6..a04c2a327 100644 --- a/xc/extras/Mesa/src/glapitemp.h +++ b/xc/extras/Mesa/src/glapitemp.h @@ -2933,6 +2933,117 @@ KEYWORD1 void KEYWORD2 NAME(LightEnviSGIX)(GLenum pname, GLint param) } +/* 112. GL_EXT_draw_range_elements */ + +#if 00 +KEYWORD1 void KEYWORD2 NAME(DrawRangeElementsEXT)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices) +{ + DISPATCH(DrawRangeElementsEXT, (mode, start, end, count, type, indices), (F, "glDrawRangeElementsEXT(0x%x, %u %u %d 0x%x %p);", mode, start, end, count, type, indices)); +} +#endif + + +/* 117. GL_EXT_light_texture */ + +#if 00 +KEYWORD1 void KEYWORD2 NAME(ApplyTextureEXT)(GLenum mode) +{ + DISPATCH(ApplyTextureEXT, (mode), (F, "glApplyTextureEXT(0x%x);", mode)); +} + + +KEYWORD1 void KEYWORD2 NAME(TextureLightEXT)(GLenum pname) +{ + DISPATCH(TextureLightEXT, (pname), (F, "glTextureLightEXT(0x%x);", pname)); +} + +KEYWORD1 void KEYWORD2 NAME(TextureMaterialEXT)(GLenum face, GLenum mode) +{ + DISPATCH(TextureMaterialEXT, (face, mode), (F, "glTextureMaterialEXT(0x%x, 0x%x);", face, mode)); +} +#endif + + + +/* 135. GL_INTEL_texture_scissor */ +#if 00 +KEYWORD1 void KEYWORD2 NAME(TexScissorINTEL)(GLenum target, GLclampf tlow, GLclampf thigh) +{ + DISPATCH(TexScissorINTEL, (target, tlow, thigh), (F, "glTexScissorINTEL(0x%x %g %g);", target, tlow, thigh)); +} + +KEYWORD1 void KEYWORD2 NAME(TexScissorFuncINTEL)(GLenum target, GLenum lfunc, GLenum hfunc) +{ + DISPATCH(TexScissorFuncINTEL, (target, lfunc, hfunc), (F, "glTexScissorFuncINTEL(0x%x 0x%x 0x%x);", target, tlow, thigh)); +} +#endif + + + +/* 136. GL_INTEL_parallel_arrays */ +#if 00 +KEYWORD1 void KEYWORD2 NAME(VertexPointervINTEL)(GLint size, GLenum type, const void ** pointer) +{ + DISPATCH(VertexPointervINTEL, (size, type, pointer), (F, "glVertexPointervINTEL(%d, 0x%x, %p);", size, type, pointer)); +} + +KEYWORD1 void KEYWORD2 NAME(NormalPointervINTEL)(GLenum type, const void** pointer) +{ + DISPATCH(NormalPointervINTEL, (size, pointer), (F, "glNormalPointervINTEL(%d, %p);", size, pointer)); +} + +KEYWORD1 void KEYWORD2 NAME(ColorPointervINTEL)(GLint size, GLenum type, const void** pointer) +{ + DISPATCH(ColorPointervINTEL, (size, type, pointer), (F, "glColorPointervINTEL(%d, 0x%x, %p);", size, type, pointer)); +} + +KEYWORD1 void KEYWORD2 NAME(TexCoordPointervINTEL)(GLint size, GLenum type, const void** pointer) +{ + DISPATCH(TexCoordPointervINTEL, (size, type, pointer), (F, "glTexCoordPointervINTEL(%d, 0x%x, %p);", size, type, pointer)); +} +#endif + + +/* 138. GL_EXT_pixel_transform */ +#if 0 +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameteriEXT)(GLenum target, GLenum pname, const GLint param) +{ + DISPATCH(PixelTransformParameteriEXT, (target, pname, param), (F, "glPixelTransformParameteriEXT(0x%x, 0x%x, %d);", target, pname, param)); +} + +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameterfEXT)(GLenum target, GLenum pname, const GLfloat param) +{ + DISPATCH(PixelTransformParameterfEXT, (target, pname, param), (F, "glPixelTransformParameterfEXT(0x%x, 0x%x, %f);", target, pname, param)); +} + +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameterivEXT)(GLenum target, GLenum pname, const GLint *params) +{ + DISPATCH(PixelTransformParameterivEXT, (target, pname, params), (F, "glPixelTransformParameterivEXT(0x%x, 0x%x, %p);", target, pname, params)); +} + +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameterfvEXT)(GLenum target, GLenum pname, const GLfloat *params) +{ + DISPATCH(PixelTransformParameterfvEXT, (target, pname, params), (F, "glPixelTransformParameterfvEXT(0x%x, 0x%x, %p);", target, pname, params)); +} + +KEYWORD1 void KEYWORD2 NAME(GetPixelTransformParameterivEXT)(GLenum target, GLenum pname, const GLint *params) +{ + DISPATCH(GetPixelTransformParameterivEXT, (target, pname, params), (F, "glGetPixelTransformParameterivEXT(0x%x, 0x%x, %p);", target, pname, params)); +} + +KEYWORD1 void KEYWORD2 NAME(GetPixelTransformParameterfvEXT)(GLenum target, GLenum pname, const GLfloat *params) +{ + DISPATCH(GetPixelTransformParameterfvEXT, (target, pname, params), (F, "glGetPixelTransformParameterfvEXT(0x%x, 0x%x, %p);", target, pname, params)); +} +#endif + + + +/* 145. GL_EXT_secondary_color */ +/* XXX todo */ + + + /* 149. GL_EXT_fog_coord */ KEYWORD1 void KEYWORD2 NAME(FogCoordfEXT)(GLfloat coord) { diff --git a/xc/extras/Mesa/src/hint.c b/xc/extras/Mesa/src/hint.c index 2d7427f01..7f8d88b76 100644 --- a/xc/extras/Mesa/src/hint.c +++ b/xc/extras/Mesa/src/hint.c @@ -89,17 +89,17 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode ) case GL_ALWAYS_FAST_HINT_PGI: if (mode) { ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_FALSE; + ctx->Hint.AllowDrawFrg = GL_FALSE; ctx->Hint.AllowDrawMem = GL_FALSE; } else { ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_TRUE; ctx->Hint.AllowDrawMem = GL_TRUE; } break; case GL_ALWAYS_SOFT_HINT_PGI: ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_TRUE; ctx->Hint.AllowDrawMem = GL_TRUE; break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -107,8 +107,8 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode ) case GL_ALLOW_DRAW_WIN_HINT_PGI: ctx->Hint.AllowDrawWin = mode; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - ctx->Hint.AllowDrawSpn = mode; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + ctx->Hint.AllowDrawFrg = mode; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: ctx->Hint.AllowDrawMem = mode; @@ -168,7 +168,7 @@ _mesa_HintPGI( GLenum target, GLint mode ) case GL_ALWAYS_SOFT_HINT_PGI: case GL_ALLOW_DRAW_OBJ_HINT_PGI: case GL_ALLOW_DRAW_WIN_HINT_PGI: - case GL_ALLOW_DRAW_SPN_HINT_PGI: + case GL_ALLOW_DRAW_FRG_HINT_PGI: case GL_ALLOW_DRAW_MEM_HINT_PGI: case GL_CLIP_NEAR_HINT_PGI: case GL_CLIP_FAR_HINT_PGI: diff --git a/xc/extras/Mesa/src/image.c b/xc/extras/Mesa/src/image.c index 724a7995e..3f0720ea0 100644 --- a/xc/extras/Mesa/src/image.c +++ b/xc/extras/Mesa/src/image.c @@ -30,6 +30,7 @@ #include "glheader.h" #include "context.h" #include "image.h" +#include "imaging.h" #include "macros.h" #include "mem.h" #include "mmath.h" @@ -601,34 +602,39 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, * applyTransferOps - apply scale/bias/lookup-table ops? */ void -_mesa_pack_rgba_span( const GLcontext *ctx, - GLuint n, CONST GLubyte rgba[][4], +_mesa_pack_rgba_span( GLcontext *ctx, + GLuint n, CONST GLubyte srcRgba[][4], GLenum format, GLenum type, GLvoid *destination, const struct gl_pixelstore_attrib *packing, GLboolean applyTransferOps ) { - applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag); + applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled); /* Test for optimized case first */ if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { /* common simple case */ - MEMCPY( destination, rgba, n * 4 * sizeof(GLubyte) ); + MEMCPY( destination, srcRgba, n * 4 * sizeof(GLubyte) ); } else if (!applyTransferOps && format == GL_RGB && type == GL_UNSIGNED_BYTE) { /* common simple case */ GLint i; GLubyte *dest = (GLubyte *) destination; for (i = 0; i < n; i++) { - dest[0] = rgba[i][RCOMP]; - dest[1] = rgba[i][GCOMP]; - dest[2] = rgba[i][BCOMP]; + dest[0] = srcRgba[i][RCOMP]; + dest[1] = srcRgba[i][GCOMP]; + dest[2] = srcRgba[i][BCOMP]; dest += 3; } } else { /* general solution */ - GLfloat red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH]; - GLfloat alpha[MAX_WIDTH], luminance[MAX_WIDTH]; + GLfloat rgba[MAX_WIDTH][4], luminance[MAX_WIDTH]; const GLfloat rscale = 1.0F / 255.0F; const GLfloat gscale = 1.0F / 255.0F; const GLfloat bscale = 1.0F / 255.0F; @@ -640,27 +646,51 @@ _mesa_pack_rgba_span( const GLcontext *ctx, /* convert color components to floating point */ for (i=0;i<n;i++) { - red[i] = rgba[i][RCOMP] * rscale; - green[i] = rgba[i][GCOMP] * gscale; - blue[i] = rgba[i][BCOMP] * bscale; - alpha[i] = rgba[i][ACOMP] * ascale; + rgba[i][RCOMP] = srcRgba[i][RCOMP] * rscale; + rgba[i][GCOMP] = srcRgba[i][GCOMP] * gscale; + rgba[i][BCOMP] = srcRgba[i][BCOMP] * bscale; + rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale; } /* * Apply scale, bias and lookup-tables if enabled. */ if (applyTransferOps) { + /* scale & bias */ if (ctx->Pixel.ScaleOrBiasRGBA) { - gl_scale_and_bias_color( ctx, n, red, green, blue, alpha ); + _mesa_scale_and_bias_rgba( ctx, n, rgba ); } + /* color map lookup */ if (ctx->Pixel.MapColorFlag) { - gl_map_color( ctx, n, red, green, blue, alpha ); + _mesa_map_rgba( ctx, n, rgba ); + } + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } + /* XXX convolution here */ + /* XXX post-convolution color table look-up here */ + /* color matrix */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba); + } + /* XXX histogram here */ + /* XXX min/max here */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, n, (const GLfloat (*)[4]) rgba); + if (ctx->MinMax.Sink) + return; } } if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) { for (i=0;i<n;i++) { - GLfloat sum = red[i] + green[i] + blue[i]; + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; luminance[i] = CLAMP( sum, 0.0F, 1.0F ); } } @@ -675,19 +705,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(red[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(green[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(blue[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(alpha[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -696,45 +726,45 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_UBYTE(luminance[i]); - dst[i*2+1] = FLOAT_TO_UBYTE(alpha[i]); + dst[i*2+1] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UBYTE(red[i]); - dst[i*3+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*3+2] = FLOAT_TO_UBYTE(blue[i]); + dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UBYTE(red[i]); - dst[i*4+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*4+2] = FLOAT_TO_UBYTE(blue[i]); - dst[i*4+3] = FLOAT_TO_UBYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UBYTE(blue[i]); - dst[i*3+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*3+2] = FLOAT_TO_UBYTE(red[i]); + dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UBYTE(blue[i]); - dst[i*4+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*4+2] = FLOAT_TO_UBYTE(red[i]); - dst[i*4+3] = FLOAT_TO_UBYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UBYTE(alpha[i]); - dst[i*4+1] = FLOAT_TO_UBYTE(blue[i]); - dst[i*4+2] = FLOAT_TO_UBYTE(green[i]); - dst[i*4+3] = FLOAT_TO_UBYTE(red[i]); + dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); } break; default: @@ -748,19 +778,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(red[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(green[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(blue[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(alpha[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -769,44 +799,44 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_BYTE(luminance[i]); - dst[i*2+1] = FLOAT_TO_BYTE(alpha[i]); + dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_BYTE(red[i]); - dst[i*3+1] = FLOAT_TO_BYTE(green[i]); - dst[i*3+2] = FLOAT_TO_BYTE(blue[i]); + dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(red[i]); - dst[i*4+1] = FLOAT_TO_BYTE(green[i]); - dst[i*4+2] = FLOAT_TO_BYTE(blue[i]); - dst[i*4+3] = FLOAT_TO_BYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_BYTE(blue[i]); - dst[i*3+1] = FLOAT_TO_BYTE(green[i]); - dst[i*3+2] = FLOAT_TO_BYTE(red[i]); + dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(blue[i]); - dst[i*4+1] = FLOAT_TO_BYTE(green[i]); - dst[i*4+2] = FLOAT_TO_BYTE(red[i]); - dst[i*4+3] = FLOAT_TO_BYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]); } case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(alpha[i]); - dst[i*4+1] = FLOAT_TO_BYTE(blue[i]); - dst[i*4+2] = FLOAT_TO_BYTE(green[i]); - dst[i*4+3] = FLOAT_TO_BYTE(red[i]); + dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]); } break; default: @@ -820,19 +850,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(red[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(green[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(blue[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(alpha[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -841,45 +871,45 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_USHORT(luminance[i]); - dst[i*2+1] = FLOAT_TO_USHORT(alpha[i]); + dst[i*2+1] = FLOAT_TO_USHORT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_USHORT(red[i]); - dst[i*3+1] = FLOAT_TO_USHORT(green[i]); - dst[i*3+2] = FLOAT_TO_USHORT(blue[i]); + dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_USHORT(red[i]); - dst[i*4+1] = FLOAT_TO_USHORT(green[i]); - dst[i*4+2] = FLOAT_TO_USHORT(blue[i]); - dst[i*4+3] = FLOAT_TO_USHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_USHORT(blue[i]); - dst[i*3+1] = FLOAT_TO_USHORT(green[i]); - dst[i*3+2] = FLOAT_TO_USHORT(red[i]); + dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_USHORT(blue[i]); - dst[i*4+1] = FLOAT_TO_USHORT(green[i]); - dst[i*4+2] = FLOAT_TO_USHORT(red[i]); - dst[i*4+3] = FLOAT_TO_USHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_USHORT(alpha[i]); - dst[i*4+1] = FLOAT_TO_USHORT(blue[i]); - dst[i*4+2] = FLOAT_TO_USHORT(green[i]); - dst[i*4+3] = FLOAT_TO_USHORT(red[i]); + dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][RCOMP]); } break; default: @@ -896,19 +926,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(red[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(green[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(blue[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(alpha[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -917,44 +947,44 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_SHORT(luminance[i]); - dst[i*2+1] = FLOAT_TO_SHORT(alpha[i]); + dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_SHORT(red[i]); - dst[i*3+1] = FLOAT_TO_SHORT(green[i]); - dst[i*3+2] = FLOAT_TO_SHORT(blue[i]); + dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(red[i]); - dst[i*4+1] = FLOAT_TO_SHORT(green[i]); - dst[i*4+2] = FLOAT_TO_SHORT(blue[i]); - dst[i*4+3] = FLOAT_TO_SHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_SHORT(blue[i]); - dst[i*3+1] = FLOAT_TO_SHORT(green[i]); - dst[i*3+2] = FLOAT_TO_SHORT(red[i]); + dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(blue[i]); - dst[i*4+1] = FLOAT_TO_SHORT(green[i]); - dst[i*4+2] = FLOAT_TO_SHORT(red[i]); - dst[i*4+3] = FLOAT_TO_SHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]); } case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(alpha[i]); - dst[i*4+1] = FLOAT_TO_SHORT(blue[i]); - dst[i*4+2] = FLOAT_TO_SHORT(green[i]); - dst[i*4+3] = FLOAT_TO_SHORT(red[i]); + dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]); } break; default: @@ -971,19 +1001,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(red[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(green[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(blue[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(alpha[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -992,45 +1022,45 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_UINT(luminance[i]); - dst[i*2+1] = FLOAT_TO_UINT(alpha[i]); + dst[i*2+1] = FLOAT_TO_UINT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UINT(red[i]); - dst[i*3+1] = FLOAT_TO_UINT(green[i]); - dst[i*3+2] = FLOAT_TO_UINT(blue[i]); + dst[i*3+0] = FLOAT_TO_UINT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UINT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UINT(red[i]); - dst[i*4+1] = FLOAT_TO_UINT(green[i]); - dst[i*4+2] = FLOAT_TO_UINT(blue[i]); - dst[i*4+3] = FLOAT_TO_UINT(alpha[i]); + dst[i*4+0] = FLOAT_TO_UINT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UINT(blue[i]); - dst[i*3+1] = FLOAT_TO_UINT(green[i]); - dst[i*3+2] = FLOAT_TO_UINT(red[i]); + dst[i*3+0] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UINT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UINT(blue[i]); - dst[i*4+1] = FLOAT_TO_UINT(green[i]); - dst[i*4+2] = FLOAT_TO_UINT(red[i]); - dst[i*4+3] = FLOAT_TO_UINT(alpha[i]); + dst[i*4+0] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UINT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UINT(alpha[i]); - dst[i*4+1] = FLOAT_TO_UINT(blue[i]); - dst[i*4+2] = FLOAT_TO_UINT(green[i]); - dst[i*4+3] = FLOAT_TO_UINT(red[i]); + dst[i*4+0] = FLOAT_TO_UINT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_UINT(rgba[i][RCOMP]); } break; default: @@ -1047,19 +1077,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(red[i]); + dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(green[i]); + dst[i] = FLOAT_TO_INT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(blue[i]); + dst[i] = FLOAT_TO_INT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(alpha[i]); + dst[i] = FLOAT_TO_INT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -1068,45 +1098,45 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_INT(luminance[i]); - dst[i*2+1] = FLOAT_TO_INT(alpha[i]); + dst[i*2+1] = FLOAT_TO_INT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_INT(red[i]); - dst[i*3+1] = FLOAT_TO_INT(green[i]); - dst[i*3+2] = FLOAT_TO_INT(blue[i]); + dst[i*3+0] = FLOAT_TO_INT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_INT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_INT(red[i]); - dst[i*4+1] = FLOAT_TO_INT(green[i]); - dst[i*4+2] = FLOAT_TO_INT(blue[i]); - dst[i*4+3] = FLOAT_TO_INT(alpha[i]); + dst[i*4+0] = FLOAT_TO_INT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_INT(blue[i]); - dst[i*3+1] = FLOAT_TO_INT(green[i]); - dst[i*3+2] = FLOAT_TO_INT(red[i]); + dst[i*3+0] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_INT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_INT(blue[i]); - dst[i*4+1] = FLOAT_TO_INT(green[i]); - dst[i*4+2] = FLOAT_TO_INT(red[i]); - dst[i*4+3] = FLOAT_TO_INT(alpha[i]); + dst[i*4+0] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_INT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_INT(alpha[i]); - dst[i*4+1] = FLOAT_TO_INT(blue[i]); - dst[i*4+2] = FLOAT_TO_INT(green[i]); - dst[i*4+3] = FLOAT_TO_INT(red[i]); + dst[i*4+0] = FLOAT_TO_INT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_INT(rgba[i][RCOMP]); } break; default: @@ -1123,19 +1153,19 @@ _mesa_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = red[i]; + dst[i] = rgba[i][RCOMP]; break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = green[i]; + dst[i] = rgba[i][GCOMP]; break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = blue[i]; + dst[i] = rgba[i][BCOMP]; break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = alpha[i]; + dst[i] = rgba[i][ACOMP]; break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -1144,45 +1174,45 @@ _mesa_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = luminance[i]; - dst[i*2+1] = alpha[i]; + dst[i*2+1] = rgba[i][ACOMP]; } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = red[i]; - dst[i*3+1] = green[i]; - dst[i*3+2] = blue[i]; + dst[i*3+0] = rgba[i][RCOMP]; + dst[i*3+1] = rgba[i][GCOMP]; + dst[i*3+2] = rgba[i][BCOMP]; } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = red[i]; - dst[i*4+1] = green[i]; - dst[i*4+2] = blue[i]; - dst[i*4+3] = alpha[i]; + dst[i*4+0] = rgba[i][RCOMP]; + dst[i*4+1] = rgba[i][GCOMP]; + dst[i*4+2] = rgba[i][BCOMP]; + dst[i*4+3] = rgba[i][ACOMP]; } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = blue[i]; - dst[i*3+1] = green[i]; - dst[i*3+2] = red[i]; + dst[i*3+0] = rgba[i][BCOMP]; + dst[i*3+1] = rgba[i][GCOMP]; + dst[i*3+2] = rgba[i][RCOMP]; } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = blue[i]; - dst[i*4+1] = green[i]; - dst[i*4+2] = red[i]; - dst[i*4+3] = alpha[i]; + dst[i*4+0] = rgba[i][BCOMP]; + dst[i*4+1] = rgba[i][GCOMP]; + dst[i*4+2] = rgba[i][RCOMP]; + dst[i*4+3] = rgba[i][ACOMP]; } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = alpha[i]; - dst[i*4+1] = blue[i]; - dst[i*4+2] = green[i]; - dst[i*4+3] = red[i]; + dst[i*4+0] = rgba[i][ACOMP]; + dst[i*4+1] = rgba[i][BCOMP]; + dst[i*4+2] = rgba[i][GCOMP]; + dst[i*4+3] = rgba[i][RCOMP]; } break; default: @@ -1197,9 +1227,9 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLubyte *dst = (GLubyte *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 7.0F)) << 5) - | (((GLint) (green[i] * 7.0F)) << 2) - | (((GLint) (blue[i] * 3.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5) + | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2) + | (((GLint) (rgba[i][BCOMP] * 3.0F)) ); } } break; @@ -1207,9 +1237,9 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLubyte *dst = (GLubyte *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 7.0F)) ) - | (((GLint) (green[i] * 7.0F)) << 3) - | (((GLint) (blue[i] * 3.0F)) << 5); + dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3) + | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5); } } break; @@ -1217,9 +1247,9 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) << 11) - | (((GLint) (green[i] * 63.0F)) << 5) - | (((GLint) (blue[i] * 31.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11) + | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) ); } } break; @@ -1227,9 +1257,9 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) ) - | (((GLint) (green[i] * 63.0F)) << 5) - | (((GLint) (blue[i] * 31.0F)) << 11); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11); } } break; @@ -1237,10 +1267,10 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 15.0F)) << 12) - | (((GLint) (green[i] * 15.0F)) << 8) - | (((GLint) (blue[i] * 15.0F)) << 4) - | (((GLint) (alpha[i] * 15.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12) + | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8) + | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4) + | (((GLint) (rgba[i][ACOMP] * 15.0F)) ); } } break; @@ -1248,10 +1278,10 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 15.0F)) ) - | (((GLint) (green[i] * 15.0F)) << 4) - | (((GLint) (blue[i] * 15.0F)) << 8) - | (((GLint) (alpha[i] * 15.0F)) << 12); + dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4) + | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8) + | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12); } } break; @@ -1259,10 +1289,10 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) << 11) - | (((GLint) (green[i] * 31.0F)) << 6) - | (((GLint) (blue[i] * 31.0F)) << 1) - | (((GLint) (alpha[i] * 1.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11) + | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1) + | (((GLint) (rgba[i][ACOMP] * 1.0F)) ); } } break; @@ -1270,10 +1300,10 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) ) - | (((GLint) (green[i] * 31.0F)) << 5) - | (((GLint) (blue[i] * 31.0F)) << 10) - | (((GLint) (alpha[i] * 1.0F)) << 15); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10) + | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15); } } break; @@ -1281,28 +1311,28 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 255.0F)) << 24) - | (((GLuint) (green[i] * 255.0F)) << 16) - | (((GLuint) (blue[i] * 255.0F)) << 8) - | (((GLuint) (alpha[i] * 255.0F)) ); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) ); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 255.0F)) << 24) - | (((GLuint) (green[i] * 255.0F)) << 16) - | (((GLuint) (red[i] * 255.0F)) << 8) - | (((GLuint) (alpha[i] * 255.0F)) ); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) ); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 255.0F)) << 24) - | (((GLuint) (blue[i] * 255.0F)) << 16) - | (((GLuint) (green[i] * 255.0F)) << 8) - | (((GLuint) (red[i] * 255.0F)) ); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) ); } } break; @@ -1310,28 +1340,28 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 255.0F)) ) - | (((GLuint) (green[i] * 255.0F)) << 8) - | (((GLuint) (blue[i] * 255.0F)) << 16) - | (((GLuint) (alpha[i] * 255.0F)) << 24); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 255.0F)) ) - | (((GLuint) (green[i] * 255.0F)) << 8) - | (((GLuint) (red[i] * 255.0F)) << 16) - | (((GLuint) (alpha[i] * 255.0F)) << 24); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 255.0F)) ) - | (((GLuint) (blue[i] * 255.0F)) << 8) - | (((GLuint) (green[i] * 255.0F)) << 16) - | (((GLuint) (red[i] * 255.0F)) << 24); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) ) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24); } } break; @@ -1339,28 +1369,28 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 1023.0F)) << 22) - | (((GLuint) (green[i] * 1023.0F)) << 12) - | (((GLuint) (blue[i] * 1023.0F)) << 2) - | (((GLuint) (alpha[i] * 3.0F)) ); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 2) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) ); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 1023.0F)) << 22) - | (((GLuint) (green[i] * 1023.0F)) << 12) - | (((GLuint) (red[i] * 1023.0F)) << 2) - | (((GLuint) (alpha[i] * 3.0F)) ); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12) + | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 2) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) ); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 1023.0F)) << 22) - | (((GLuint) (blue[i] * 1023.0F)) << 12) - | (((GLuint) (green[i] * 1023.0F)) << 2) - | (((GLuint) (red[i] * 3.0F)) ); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 2) + | (((GLuint) (rgba[i][RCOMP] * 3.0F)) ); } } break; @@ -1368,28 +1398,28 @@ _mesa_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 1023.0F)) ) - | (((GLuint) (green[i] * 1023.0F)) << 10) - | (((GLuint) (blue[i] * 1023.0F)) << 20) - | (((GLuint) (alpha[i] * 3.0F)) << 30); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 20) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 1023.0F)) ) - | (((GLuint) (green[i] * 1023.0F)) << 10) - | (((GLuint) (red[i] * 1023.0F)) << 20) - | (((GLuint) (alpha[i] * 3.0F)) << 30); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10) + | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 20) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 1023.0F)) ) - | (((GLuint) (blue[i] * 1023.0F)) << 10) - | (((GLuint) (green[i] * 1023.0F)) << 20) - | (((GLuint) (red[i] * 3.0F)) << 30); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) ) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20) + | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30); } } break; @@ -1400,6 +1430,7 @@ _mesa_pack_rgba_span( const GLcontext *ctx, } + #define SWAP2BYTE(VALUE) \ { \ GLubyte *bytes = (GLubyte *) &(VALUE); \ @@ -2103,7 +2134,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], * XXX perhaps expand this to process whole images someday. */ void -_mesa_unpack_ubyte_color_span( const GLcontext *ctx, +_mesa_unpack_ubyte_color_span( GLcontext *ctx, GLuint n, GLenum dstFormat, GLubyte dest[], GLenum srcFormat, GLenum srcType, const GLvoid *source, @@ -2153,12 +2184,16 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, srcType == GL_UNSIGNED_INT_10_10_10_2 || srcType == GL_UNSIGNED_INT_2_10_10_10_REV); - /* this is intended for RGBA mode */ + /* this is intended for RGBA mode only */ assert(ctx->Visual->RGBAflag); applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag || - ctx->Pixel.MapColorFlag); + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled); /* Try simple cases first */ if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) { @@ -2210,8 +2245,8 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } + /* general solution begins here */ { - /* general solution */ GLfloat rgba[MAX_WIDTH][4]; GLint dstComponents; GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; @@ -2230,32 +2265,26 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, extract_uint_indexes(n, indexes, srcFormat, srcType, source, unpacking); - /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); - - if (dstFormat == GL_COLOR_INDEX) { - if (applyTransferOps) { - if (ctx->Pixel.MapColorFlag) { - /* Apply lookup table */ - gl_map_ci(ctx, n, indexes); - } - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { - - } + if (applyTransferOps) { + if (ctx->Pixel.MapColorFlag) { + _mesa_map_ci(ctx, n, indexes); } + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + } + if (dstFormat == GL_COLOR_INDEX) { /* convert to GLubyte and return */ - { - GLuint i; - for (i = 0; i < n; i++) { - dest[i] = (GLubyte) (indexes[i] & 0xff); - } + GLuint i; + for (i = 0; i < n; i++) { + dest[i] = (GLubyte) (indexes[i] & 0xff); } + return; } else { /* Convert indexes to RGBA */ - gl_map_ci_to_rgba_float(ctx, n, indexes, rgba); + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); } } else { @@ -2264,23 +2293,38 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, if (applyTransferOps) { /* scale and bias colors */ - gl_scale_and_bias_rgba_float(ctx, n, rgba); - - /* color table lookup */ + if (ctx->Pixel.ScaleOrBiasRGBA) { + _mesa_scale_and_bias_rgba(ctx, n, rgba); + } + /* color map lookup */ if (ctx->Pixel.MapColorFlag) { - gl_map_rgba_float(ctx, n, rgba); + _mesa_map_rgba(ctx, n, rgba); } } } - - /* - * XXX This is where more color table lookups, convolution, - * histograms, minmax, color matrix, etc would take place if - * implemented. - * See figure 3.7 in the OpenGL 1.2 specification for more info. - */ - + if (applyTransferOps) { + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } + /* XXX convolution here */ + /* XXX post-convolution color table look-up here */ + /* color matrix transform */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba); + } + /* XXX histogram here */ + /* XXX min/max here */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, n, (const GLfloat (*)[4]) rgba); + } + } /* clamp to [0,1] */ { @@ -2400,6 +2444,266 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } +void +_mesa_unpack_float_color_span( GLcontext *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps ) +{ + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RGB || + dstFormat == GL_RGBA || + dstFormat == GL_COLOR_INDEX); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_COLOR_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + /* this is intended for RGBA mode only */ + assert(ctx->Visual->RGBAflag); + + applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled); + + /* general solution, no special cases, yet */ + { + GLfloat rgba[MAX_WIDTH][4]; + GLint dstComponents; + GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; + GLint dstLuminanceIndex, dstIntensityIndex; + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + assert(n <= MAX_WIDTH); + if (srcFormat == GL_COLOR_INDEX) { + GLuint indexes[MAX_WIDTH]; + extract_uint_indexes(n, indexes, srcFormat, srcType, source, + unpacking); + + if (applyTransferOps) { + if (ctx->Pixel.MapColorFlag) { + _mesa_map_ci(ctx, n, indexes); + } + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + } + + if (dstFormat == GL_COLOR_INDEX) { + /* convert to GLubyte and return */ + GLuint i; + for (i = 0; i < n; i++) { + dest[i] = (GLubyte) (indexes[i] & 0xff); + } + return; + } + else { + /* Convert indexes to RGBA */ + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); + } + } + else { + extract_float_rgba(n, rgba, srcFormat, srcType, source, + unpacking->SwapBytes); + + if (applyTransferOps) { + /* scale and bias colors */ + if (ctx->Pixel.ScaleOrBiasRGBA) { + _mesa_scale_and_bias_rgba(ctx, n, rgba); + } + /* color map lookup */ + if (ctx->Pixel.MapColorFlag) { + _mesa_map_rgba(ctx, n, rgba); + } + } + } + + if (applyTransferOps) { + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } + /* XXX convolution here */ + /* XXX post-convolution color table look-up here */ + /* color matrix transform */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba); + } + /* XXX histogram here */ + /* XXX min/max here */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, n, (const GLfloat (*)[4]) rgba); + } + } + + /* clamp to [0,1] */ + { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); + } + } + + /* Now determine which color channels we need to produce. + * And determine the dest index (offset) within each color tuple. + */ + switch (dstFormat) { + case GL_ALPHA: + dstAlphaIndex = 0; + dstRedIndex = dstGreenIndex = dstBlueIndex = -1; + dstLuminanceIndex = dstIntensityIndex = -1; + break; + case GL_LUMINANCE: + dstLuminanceIndex = 0; + dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; + dstIntensityIndex = -1; + break; + case GL_LUMINANCE_ALPHA: + dstLuminanceIndex = 0; + dstAlphaIndex = 1; + dstRedIndex = dstGreenIndex = dstBlueIndex = -1; + dstIntensityIndex = -1; + break; + case GL_INTENSITY: + dstIntensityIndex = 0; + dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; + dstLuminanceIndex = -1; + break; + case GL_RGB: + dstRedIndex = 0; + dstGreenIndex = 1; + dstBlueIndex = 2; + dstAlphaIndex = dstLuminanceIndex = dstIntensityIndex = -1; + break; + case GL_RGBA: + dstRedIndex = 0; + dstGreenIndex = 1; + dstBlueIndex = 2; + dstAlphaIndex = 3; + dstLuminanceIndex = dstIntensityIndex = -1; + break; + default: + gl_problem(ctx, "bad dstFormat in _mesa_unpack_float_span()"); + return; + } + + /* Now pack results in teh requested dstFormat */ + if (dstRedIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstRedIndex] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + if (dstGreenIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstGreenIndex] = rgba[i][GCOMP]; + dst += dstComponents; + } + } + + if (dstBlueIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstBlueIndex] = rgba[i][BCOMP]; + dst += dstComponents; + } + } + + if (dstAlphaIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstAlphaIndex] = rgba[i][ACOMP]; + dst += dstComponents; + } + } + + if (dstIntensityIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(dstIntensityIndex == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + dst[i] = rgba[i][RCOMP]; + } + } + + if (dstLuminanceIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(dstLuminanceIndex == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + dst[0] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + } +} + + + /* * Unpack a row of color index data from a client buffer according to @@ -2462,12 +2766,11 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, if (applyTransferOps) { if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); } - if (ctx->Pixel.MapColorFlag) { /* Apply lookup table */ - gl_map_ci(ctx, n, indexes); + _mesa_map_ci(ctx, n, indexes); } } @@ -2562,7 +2865,7 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, if (applyTransferOps) { if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); } if (ctx->Pixel.MapStencilFlag) { diff --git a/xc/extras/Mesa/src/image.h b/xc/extras/Mesa/src/image.h index cbe0926da..25b591ec9 100644 --- a/xc/extras/Mesa/src/image.h +++ b/xc/extras/Mesa/src/image.h @@ -79,7 +79,7 @@ _mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, extern void -_mesa_pack_rgba_span( const GLcontext *ctx, +_mesa_pack_rgba_span( GLcontext *ctx, GLuint n, CONST GLubyte rgba[][4], GLenum format, GLenum type, GLvoid *dest, const struct gl_pixelstore_attrib *packing, @@ -87,7 +87,7 @@ _mesa_pack_rgba_span( const GLcontext *ctx, extern void -_mesa_unpack_ubyte_color_span( const GLcontext *ctx, +_mesa_unpack_ubyte_color_span( GLcontext *ctx, GLuint n, GLenum dstFormat, GLubyte dest[], GLenum srcFormat, GLenum srcType, const GLvoid *source, @@ -96,6 +96,15 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, extern void +_mesa_unpack_float_color_span( GLcontext *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps ); + + +extern void _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, GLenum dstType, GLvoid *dest, GLenum srcType, const GLvoid *source, diff --git a/xc/extras/Mesa/src/imaging.c b/xc/extras/Mesa/src/imaging.c index f1d912b6d..6710e2d3e 100644 --- a/xc/extras/Mesa/src/imaging.c +++ b/xc/extras/Mesa/src/imaging.c @@ -24,14 +24,25 @@ */ -/* Stub functions for GL_ARB_imaging subset */ +/* + * Stub functions for GL_ARB_imaging subset + * + * Some of the imaging functions (like blending and color tables) are + * defined elsewhere in Mesa. + * + * There's been some initial work on histogram and minmax support done + * here but there's a lot more to do. Any volunteers? + */ #ifdef PC_HEADER #include "all.h" #else #include "glheader.h" +#include "context.h" #include "imaging.h" +#include "mmath.h" +#include "teximage.h" #endif @@ -40,62 +51,6 @@ -#if 0 -void _mesa_BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) -{ - (void) r; - (void) g; - (void) b; - (void) a; - WARNING("glBlendColor"); -} - -void _mesa_BlendEquation(GLenum eq) -{ - (void) eq; - WARNING("glBlendEquation"); -} - -void _mesa_ColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data) -{ - (void) target; - (void) start; - (void) count; - (void) format; - (void) type; - (void) data; - WARNING("glColorSubTable"); -} - -void _mesa_ColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table) -{ - (void) target; - (void) internalformat; - (void) width; - (void) format; - (void) type; - (void) table; - WARNING("glColorTable"); -} -#endif - -void _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glColorTableParameterfv"); -} - -void _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glColorTableParameteriv"); -} - - void _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) { (void) target; @@ -151,26 +106,6 @@ void _mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *para WARNING("glConvolutionParameteriv"); } -void _mesa_CopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width) -{ - (void) target; - (void) start; - (void) x; - (void) y; - (void) width; - WARNING("glCopyColorSubTable"); -} - -void _mesa_CopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) -{ - (void) target; - (void) internalformat; - (void) x; - (void) y; - (void) width; - WARNING("glCopyColorTable"); -} - void _mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) { (void) target; @@ -192,33 +127,6 @@ void _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x WARNING("glCopyConvolutionFilter2D"); } -#if 0 -void _mesa_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid *table) -{ - (void) target; - (void) format; - (void) type; - (void) table; - WARNING("glGetColorTable"); -} - -void _mesa_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glGetColorTableParameterfv"); -} - -void _mesa_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glGetColorTableParameteriv"); -} -#endif - void _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image) { (void) target; @@ -256,45 +164,182 @@ void _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum types void _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) { - (void) target; - (void) reset; - (void) format; - (void) type; - (void) values; - WARNING("glGetHistogram"); -} + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogram"); -void _mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glGetHistogramParameterfv"); -} + WARNING("glGetHistogram"); -void _mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glGetHistogramParameteriv"); + if (target != GL_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogram(target)"); + return; + } + + if (format != GL_RED && + format != GL_GREEN && + format != GL_BLUE && + format != GL_ALPHA && + format != GL_RGB && + format != GL_RGBA && + format != GL_ABGR_EXT && + format != GL_LUMINANCE && + format != GL_LUMINANCE_ALPHA) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)"); + return; + } + + if (type != GL_UNSIGNED_BYTE && + type != GL_BYTE && + type != GL_UNSIGNED_SHORT && + type != GL_SHORT && + type != GL_UNSIGNED_INT && + type != GL_INT && + type != GL_FLOAT) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogram(type)"); + return; + } + + /* XXX return values */ + + + if (reset) { + GLuint i; + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } + } +} + + +void +_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogramParameterfv"); + + if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(target)"); + return; + } + + switch (pname) { + case GL_HISTOGRAM_WIDTH: + *params = (GLfloat) ctx->Histogram.Width; + break; + case GL_HISTOGRAM_FORMAT: + *params = (GLfloat) ctx->Histogram.Format; + break; + case GL_HISTOGRAM_RED_SIZE: + *params = (GLfloat) ctx->Histogram.RedSize; + break; + case GL_HISTOGRAM_GREEN_SIZE: + *params = (GLfloat) ctx->Histogram.GreenSize; + break; + case GL_HISTOGRAM_BLUE_SIZE: + *params = (GLfloat) ctx->Histogram.BlueSize; + break; + case GL_HISTOGRAM_ALPHA_SIZE: + *params = (GLfloat) ctx->Histogram.AlphaSize; + break; + case GL_HISTOGRAM_LUMINANCE_SIZE: + *params = (GLfloat) ctx->Histogram.LuminanceSize; + break; + case GL_HISTOGRAM_SINK: + *params = (GLfloat) ctx->Histogram.Sink; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(pname)"); + } +} + + +void +_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogramParameteriv"); + + if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(target)"); + return; + } + + switch (pname) { + case GL_HISTOGRAM_WIDTH: + *params = (GLint) ctx->Histogram.Width; + break; + case GL_HISTOGRAM_FORMAT: + *params = (GLint) ctx->Histogram.Format; + break; + case GL_HISTOGRAM_RED_SIZE: + *params = (GLint) ctx->Histogram.RedSize; + break; + case GL_HISTOGRAM_GREEN_SIZE: + *params = (GLint) ctx->Histogram.GreenSize; + break; + case GL_HISTOGRAM_BLUE_SIZE: + *params = (GLint) ctx->Histogram.BlueSize; + break; + case GL_HISTOGRAM_ALPHA_SIZE: + *params = (GLint) ctx->Histogram.AlphaSize; + break; + case GL_HISTOGRAM_LUMINANCE_SIZE: + *params = (GLint) ctx->Histogram.LuminanceSize; + break; + case GL_HISTOGRAM_SINK: + *params = (GLint) ctx->Histogram.Sink; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(pname)"); + } +} + + +void +_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetMinmaxParameterfv"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameterfv(target)"); + return; + } + if (pname == GL_MINMAX_FORMAT) { + *params = (GLfloat) ctx->MinMax.Format; + } + else if (pname == GL_MINMAX_SINK) { + *params = (GLfloat) ctx->MinMax.Sink; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameterfv(pname)"); + } +} + + +void +_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetMinmaxParameteriv"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameteriv(target)"); + return; + } + if (pname == GL_MINMAX_FORMAT) { + *params = (GLint) ctx->MinMax.Format; + } + else if (pname == GL_MINMAX_SINK) { + *params = (GLint) ctx->MinMax.Sink; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameteriv(pname)"); + } } -void _mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glGetMinmaxParameterfv"); -} - -void _mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) -{ - (void) target; - (void) pname; - (void) params; - WARNING("glGetMinmaxParameteriv"); -} void _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span) { @@ -307,36 +352,169 @@ void _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid WARNING("glGetSeperableFilter"); } -void _mesa_Histogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink) -{ - (void) target; - (void) width; - (void) internalformat; - (void) sink; - WARNING("glHistogram"); -} -void _mesa_Minmax(GLenum target, GLenum internalformat, GLboolean sink) +void +_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) { - (void) target; - (void) internalformat; - (void) sink; - WARNING("glMinmax"); -} + GLuint i; + GLboolean error = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glHistogram"); + + WARNING("glHistogram"); + return; + + if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glHistogram(target)"); + return; + } + + if (width < 0 || width > HISTOGRAM_TABLE_SIZE) { + if (target == GL_PROXY_HISTOGRAM) { + error = GL_TRUE; + } + else { + if (width < 0) + gl_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); + else + gl_error(ctx, GL_TABLE_TOO_LARGE, "glHistogram(width)"); + return; + } + } + + if (width != 0 && _mesa_bitcount(width) != 1) { + if (target == GL_PROXY_HISTOGRAM) { + error = GL_TRUE; + } + else { + gl_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); + return; + } + } + + if (_mesa_base_tex_format(internalFormat) < 0 || + internalFormat == 1 || + internalFormat == 2 || + internalFormat == 3 || + internalFormat == 4 || + internalFormat == GL_INTENSITY || + internalFormat == GL_INTENSITY4 || + internalFormat == GL_INTENSITY8 || + internalFormat == GL_INTENSITY12 || + internalFormat == GL_INTENSITY16) { + if (target == GL_PROXY_HISTOGRAM) { + error = GL_TRUE; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glHistogram(internalFormat)"); + return; + } + } + + /* reset histograms */ + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } + + if (error) { + ctx->Histogram.Width = 0; + ctx->Histogram.Format = 0; + ctx->Histogram.RedSize = 0; + ctx->Histogram.GreenSize = 0; + ctx->Histogram.BlueSize = 0; + ctx->Histogram.AlphaSize = 0; + ctx->Histogram.LuminanceSize = 0; + } + else { + ctx->Histogram.Width = width; + ctx->Histogram.Format = internalFormat; + ctx->Histogram.Sink = sink; + ctx->Histogram.RedSize = 0xffffffff; + ctx->Histogram.GreenSize = 0xffffffff; + ctx->Histogram.BlueSize = 0xffffffff; + ctx->Histogram.AlphaSize = 0xffffffff; + ctx->Histogram.LuminanceSize = 0xffffffff; + } +} + + +void +_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMinmax"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glMinMax(target)"); + return; + } + + if (_mesa_base_tex_format(internalFormat) < 0 || + internalFormat == 1 || + internalFormat == 2 || + internalFormat == 3 || + internalFormat == 4 || + internalFormat == GL_INTENSITY || + internalFormat == GL_INTENSITY4 || + internalFormat == GL_INTENSITY8 || + internalFormat == GL_INTENSITY12 || + internalFormat == GL_INTENSITY16) { + gl_error(ctx, GL_INVALID_ENUM, "glMinMax(internalFormat)"); + return; + } + + ctx->MinMax.Sink = sink; +} + + +void +_mesa_ResetHistogram(GLenum target) +{ + GLuint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glResetHistogram"); -void _mesa_ResetHistogram(GLenum target) -{ - (void) target; WARNING("glResetHistogram"); + + if (target != GL_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glResetHistogram(target)"); + return; + } + + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } } -void _mesa_ResetMinmax(GLenum target) + +void +_mesa_ResetMinmax(GLenum target) { - (void) target; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glResetMinmax"); + WARNING("glResetMinmax"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glResetMinMax(target)"); + return; + } + + ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; + ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; + ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; + ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; } -void _mesa_SeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) + +void +_mesa_SeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) { (void) target; (void) internalformat; @@ -348,3 +526,60 @@ void _mesa_SeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width (void) column; WARNING("glSeparableFilter2D"); } + + +/* + * Update the min/max values from an array of fragment colors. + */ +void +_mesa_update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) +{ + GLuint i; + for (i = 0; i < n; i++) { + /* update mins */ + if (rgba[i][RCOMP] < ctx->MinMax.Min[RCOMP]) + ctx->MinMax.Min[RCOMP] = rgba[i][RCOMP]; + if (rgba[i][GCOMP] < ctx->MinMax.Min[GCOMP]) + ctx->MinMax.Min[GCOMP] = rgba[i][GCOMP]; + if (rgba[i][BCOMP] < ctx->MinMax.Min[BCOMP]) + ctx->MinMax.Min[BCOMP] = rgba[i][BCOMP]; + if (rgba[i][ACOMP] < ctx->MinMax.Min[ACOMP]) + ctx->MinMax.Min[ACOMP] = rgba[i][ACOMP]; + + /* update maxs */ + if (rgba[i][RCOMP] > ctx->MinMax.Max[RCOMP]) + ctx->MinMax.Max[RCOMP] = rgba[i][RCOMP]; + if (rgba[i][GCOMP] < ctx->MinMax.Max[GCOMP]) + ctx->MinMax.Max[GCOMP] = rgba[i][GCOMP]; + if (rgba[i][BCOMP] < ctx->MinMax.Max[BCOMP]) + ctx->MinMax.Max[BCOMP] = rgba[i][BCOMP]; + if (rgba[i][ACOMP] < ctx->MinMax.Max[ACOMP]) + ctx->MinMax.Max[ACOMP] = rgba[i][ACOMP]; + } +} + + +/* + * Update the histogram values from an array of fragment colors. + */ +void +_mesa_update_histogram(GLcontext *ctx, GLuint n, const GLchan rgba[][4]) +{ + GLuint i; + switch (ctx->Histogram.Format) { + case GL_RGBA: + for (i = 0; i < n; i++) { + GLubyte r = rgba[i][RCOMP]; + GLubyte g = rgba[i][GCOMP]; + GLubyte b = rgba[i][BCOMP]; + GLubyte a = rgba[i][ACOMP]; + ctx->Histogram.Count[r][RCOMP]++; + ctx->Histogram.Count[g][RCOMP]++; + ctx->Histogram.Count[b][RCOMP]++; + ctx->Histogram.Count[a][RCOMP]++; + } + break; + default: + gl_problem(ctx, "Bad format in _mesa_update_histogram()"); + } +} diff --git a/xc/extras/Mesa/src/imaging.h b/xc/extras/Mesa/src/imaging.h index f376be5f6..220a99576 100644 --- a/xc/extras/Mesa/src/imaging.h +++ b/xc/extras/Mesa/src/imaging.h @@ -32,25 +32,11 @@ #include "all.h" #else #include "glheader.h" +#include "types.h" #endif -#if 0 -extern void _mesa_BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a); - -extern void _mesa_BlendEquation(GLenum eq); - -extern void _mesa_ColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); - -extern void _mesa_ColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -#endif - -extern void _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params); - -extern void _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params); - - extern void _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); extern void _mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); @@ -63,22 +49,10 @@ extern void _mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param extern void _mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params); -extern void _mesa_CopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); - -extern void _mesa_CopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); - extern void _mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); extern void _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -#if 0 -extern void _mesa_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid *table); - -extern void _mesa_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params); - -extern void _mesa_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params); -#endif - extern void _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image); extern void _mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params); @@ -109,4 +83,12 @@ extern void _mesa_ResetMinmax(GLenum target); extern void _mesa_SeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + +extern void +_mesa_update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]); + +extern void +_mesa_update_histogram(GLcontext *ctx, GLuint n, const GLchan rgba[][4]); + + #endif diff --git a/xc/extras/Mesa/src/logic.c b/xc/extras/Mesa/src/logic.c index 715eb9ccd..1078cca68 100644 --- a/xc/extras/Mesa/src/logic.c +++ b/xc/extras/Mesa/src/logic.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -203,8 +203,9 @@ static void index_logicop( GLcontext *ctx, GLuint n, * Apply the current logic operator to a span of CI pixels. This is only * used if the device driver can't do logic ops. */ -void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - GLuint index[], const GLubyte mask[] ) +void +_mesa_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLuint index[], const GLubyte mask[] ) { GLuint dest[MAX_WIDTH]; /* Read dest values from frame buffer */ @@ -218,9 +219,10 @@ void gl_logicop_ci_span( GLcontext *ctx, GLuint n, GLint x, GLint y, * Apply the current logic operator to an array of CI pixels. This is only * used if the device driver can't do logic ops. */ -void gl_logicop_ci_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint index[], const GLubyte mask[] ) +void +_mesa_logicop_ci_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[] ) { GLuint dest[PB_SIZE]; /* Read dest values from frame buffer */ @@ -367,9 +369,10 @@ static void rgba_logicop( const GLcontext *ctx, GLuint n, * Apply the current logic operator to a span of RGBA pixels. * This is only used if the device driver can't do logic ops. */ -void gl_logicop_rgba_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_logicop_rgba_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4], const GLubyte mask[] ) { GLubyte dest[MAX_WIDTH][4]; gl_read_rgba_span( ctx, ctx->DrawBuffer, n, x, y, dest ); @@ -382,14 +385,15 @@ void gl_logicop_rgba_span( GLcontext *ctx, * Apply the current logic operator to an array of RGBA pixels. * This is only used if the device driver can't do logic ops. */ -void gl_logicop_rgba_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_logicop_rgba_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ) { GLubyte dest[PB_SIZE][4]; (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_read_alpha_pixels( ctx, n, x, y, dest, mask ); + _mesa_read_alpha_pixels( ctx, n, x, y, dest, mask ); } rgba_logicop( ctx, n, mask, (GLuint *) rgba, (const GLuint *) dest ); } diff --git a/xc/extras/Mesa/src/logic.h b/xc/extras/Mesa/src/logic.h index 3c5aad795..ec8060d2a 100644 --- a/xc/extras/Mesa/src/logic.h +++ b/xc/extras/Mesa/src/logic.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -35,24 +35,27 @@ extern void _mesa_LogicOp( GLenum opcode ); -extern void gl_logicop_ci_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLuint index[], - const GLubyte mask[] ); +extern void +_mesa_logicop_ci_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint index[], + const GLubyte mask[] ); -extern void gl_logicop_ci_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint index[], const GLubyte mask[] ); +extern void +_mesa_logicop_ci_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[] ); -extern void gl_logicop_rgba_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4], const GLubyte mask[] ); +extern void +_mesa_logicop_rgba_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte rgba[][4], const GLubyte mask[] ); -extern void gl_logicop_rgba_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ); +extern void +_mesa_logicop_rgba_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ); #endif diff --git a/xc/extras/Mesa/src/masking.c b/xc/extras/Mesa/src/masking.c index fa651b34e..f5beda95f 100644 --- a/xc/extras/Mesa/src/masking.c +++ b/xc/extras/Mesa/src/masking.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -83,8 +83,9 @@ _mesa_ColorMask( GLboolean red, GLboolean green, /* * Apply glColorMask to a span of RGBA pixels. */ -void gl_mask_rgba_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLubyte rgba[][4] ) +void +_mesa_mask_rgba_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte rgba[][4] ) { GLubyte dest[MAX_WIDTH][4]; GLuint srcMask = *((GLuint*)ctx->Color.ColorMask); @@ -105,9 +106,10 @@ void gl_mask_rgba_span( GLcontext *ctx, /* * Apply glColorMask to an array of RGBA pixels. */ -void gl_mask_rgba_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_mask_rgba_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ) { GLubyte dest[PB_SIZE][4]; GLuint srcMask = *((GLuint*)ctx->Color.ColorMask); @@ -118,7 +120,7 @@ void gl_mask_rgba_pixels( GLcontext *ctx, (*ctx->Driver.ReadRGBAPixels)( ctx, n, x, y, dest, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_read_alpha_pixels( ctx, n, x, y, dest, mask ); + _mesa_read_alpha_pixels( ctx, n, x, y, dest, mask ); } for (i=0; i<n; i++) { @@ -131,8 +133,9 @@ void gl_mask_rgba_pixels( GLcontext *ctx, /* * Apply glIndexMask to a span of CI pixels. */ -void gl_mask_index_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLuint index[] ) +void +_mesa_mask_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint index[] ) { GLuint i; GLuint fbindexes[MAX_WIDTH]; @@ -153,9 +156,10 @@ void gl_mask_index_span( GLcontext *ctx, /* * Apply glIndexMask to an array of CI pixels. */ -void gl_mask_index_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint index[], const GLubyte mask[] ) +void +_mesa_mask_index_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[] ) { GLuint i; GLuint fbindexes[PB_SIZE]; diff --git a/xc/extras/Mesa/src/masking.h b/xc/extras/Mesa/src/masking.h index f11abe063..9e6b6892d 100644 --- a/xc/extras/Mesa/src/masking.h +++ b/xc/extras/Mesa/src/masking.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -43,35 +43,39 @@ _mesa_ColorMask( GLboolean red, GLboolean green, /* * Implement glColorMask for a span of RGBA pixels. */ -extern void gl_mask_rgba_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, - GLubyte rgba[][4] ); +extern void +_mesa_mask_rgba_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4] ); /* * Implement glColorMask for an array of RGBA pixels. */ -extern void gl_mask_rgba_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ); +extern void +_mesa_mask_rgba_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ); /* * Implement glIndexMask for a span of CI pixels. */ -extern void gl_mask_index_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLuint index[] ); +extern void +_mesa_mask_index_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint index[] ); /* * Implement glIndexMask for an array of CI pixels. */ -extern void gl_mask_index_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLuint index[], const GLubyte mask[] ); +extern void +_mesa_mask_index_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[] ); diff --git a/xc/extras/Mesa/src/matrix.c b/xc/extras/Mesa/src/matrix.c index f9270f75c..5c66ef0e3 100644 --- a/xc/extras/Mesa/src/matrix.c +++ b/xc/extras/Mesa/src/matrix.c @@ -930,6 +930,10 @@ do { \ mat = &ctx->TextureMatrix[ctx->Texture.CurrentTransformUnit]; \ flags |= NEW_TEXTURE_MATRIX; \ break; \ + case GL_COLOR: \ + mat = &ctx->ColorMatrix; \ + flags |= NEW_COLOR_MATRIX; \ + break; \ default: \ gl_problem(ctx, where); \ } \ @@ -1036,6 +1040,7 @@ _mesa_MatrixMode( GLenum mode ) case GL_MODELVIEW: case GL_PROJECTION: case GL_TEXTURE: + case GL_COLOR: ctx->Transform.MatrixMode = mode; break; default: @@ -1089,6 +1094,14 @@ _mesa_PushMatrix( void ) &ctx->TextureMatrix[t] ); } break; + case GL_COLOR: + if (ctx->ColorStackDepth >= MAX_COLOR_STACK_DEPTH - 1) { + gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix"); + return; + } + gl_matrix_copy( &ctx->ColorStack[ctx->ColorStackDepth++], + &ctx->ColorMatrix ); + break; default: gl_problem(ctx, "Bad matrix mode in gl_PushMatrix"); } @@ -1146,6 +1159,14 @@ _mesa_PopMatrix( void ) &ctx->TextureStack[t][--ctx->TextureStackDepth[t]]); } break; + case GL_COLOR: + if (ctx->ColorStackDepth==0) { + gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix"); + return; + } + gl_matrix_copy(&ctx->ColorMatrix, + &ctx->ColorStack[--ctx->ColorStackDepth]); + break; default: gl_problem(ctx, "Bad matrix mode in gl_PopMatrix"); } diff --git a/xc/extras/Mesa/src/mem.h b/xc/extras/Mesa/src/mem.h index c0203c7c4..6e9e00d73 100644 --- a/xc/extras/Mesa/src/mem.h +++ b/xc/extras/Mesa/src/mem.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -78,6 +78,15 @@ extern void _mesa_free(void *ptr); #endif +/* On some systems we might want to use bzero() (but is bzero portable?) */ +#if defined(__FreeBSD__) +#define BZERO( ADDR, N ) \ + bzero( (void *) (ADDR), (size_t) (N) ) +#else +#define BZERO( ADDR, N ) \ + memset( (void *) (ADDR), 0, (size_t) (N) ) +#endif + /* MACs and BeOS don't support static larger than 32kb, so... */ #if defined(macintosh) && !defined(__MRC__) diff --git a/xc/extras/Mesa/src/mmath.c b/xc/extras/Mesa/src/mmath.c index 06d134955..d93400d20 100644 --- a/xc/extras/Mesa/src/mmath.c +++ b/xc/extras/Mesa/src/mmath.c @@ -140,7 +140,8 @@ init_ubyte_color_tab(void) /* * Initialize tables, etc for fast math functions. */ -void _mesa_init_math(void) +void +_mesa_init_math(void) { static GLboolean initialized = GL_FALSE; @@ -166,3 +167,21 @@ void _mesa_init_math(void) #endif } } + + + +/* + * Return number of bits set in given GLuint. + */ +GLuint +_mesa_bitcount(GLuint n) +{ + GLuint bits; + for (bits = 0; n > 0; n = n >> 1) { + if (n & 1) { + bits++; + } + } + return bits; +} + diff --git a/xc/extras/Mesa/src/mmath.h b/xc/extras/Mesa/src/mmath.h index 30a300cdb..ad59b948d 100644 --- a/xc/extras/Mesa/src/mmath.h +++ b/xc/extras/Mesa/src/mmath.h @@ -22,7 +22,7 @@ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* $XFree86: xc/extras/Mesa/src/mmath.h,v 1.4 2000/03/03 18:30:08 tsi Exp $ */ + /* * Faster arithmetic functions. If the FAST_MATH preprocessor symbol is @@ -47,10 +47,7 @@ * In the worst case, we force the compiler to use a memory access to * truncate the float, by specifying the 'volatile' keyword. */ -#if defined(__linux__) && defined(__i386__) && !defined(IN_MODULE) -/* - * A libc interface is needed for this... - */ +#if defined(__linux__) && defined(__i386__) #include <fpu_control.h> #if !defined(_FPU_SETCW) @@ -82,6 +79,7 @@ typedef unsigned short fpu_control_t; } #endif + /* Put it back how the application had it. */ #define END_FAST_MATH(x) \ @@ -89,6 +87,7 @@ typedef unsigned short fpu_control_t; _FPU_SETCW( x ); \ } + #define HAVE_FAST_MATH #elif defined(__WATCOMC__) && !defined(NO_FAST_MATH) @@ -330,7 +329,13 @@ do { \ } while(0) -extern void _mesa_init_math(void); + +extern void +_mesa_init_math(void); + + +extern GLuint +_mesa_bitcount(GLuint n); #endif diff --git a/xc/extras/Mesa/src/norm_tmp.h b/xc/extras/Mesa/src/norm_tmp.h index 2548284de..074babf12 100644 --- a/xc/extras/Mesa/src/norm_tmp.h +++ b/xc/extras/Mesa/src/norm_tmp.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -28,12 +28,13 @@ */ -static void _XFORMAPI TAG(transform_normalize_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) +static void _XFORMAPI +TAG(transform_normalize_normals)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -71,8 +72,8 @@ static void _XFORMAPI TAG(transform_normalize_normals)( const GLmatrix *mat, } } } - } else { - + } + else { /* scale has been snapped to 1.0 if it is close. */ if (scale != 1.0) { @@ -102,12 +103,14 @@ static void _XFORMAPI TAG(transform_normalize_normals)( const GLmatrix *mat, dest->count = in->count; } -static void _XFORMAPI TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) + +static void _XFORMAPI +TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -144,7 +147,8 @@ static void _XFORMAPI TAG(transform_normalize_normals_no_rot)( const GLmatrix *m } } } - } else { + } + else { /* scale has been snapped to 1.0 if it is close. */ if (scale != 1.0) { @@ -175,12 +179,13 @@ static void _XFORMAPI TAG(transform_normalize_normals_no_rot)( const GLmatrix *m } -static void _XFORMAPI TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) +static void _XFORMAPI +TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -204,12 +209,13 @@ static void _XFORMAPI TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat dest->count = in->count; } -static void _XFORMAPI TAG(transform_rescale_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) +static void _XFORMAPI +TAG(transform_rescale_normals)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -237,12 +243,13 @@ static void _XFORMAPI TAG(transform_rescale_normals)( const GLmatrix *mat, } -static void _XFORMAPI TAG(transform_normals_no_rot)(const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) +static void _XFORMAPI +TAG(transform_normals_no_rot)(const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -267,12 +274,14 @@ static void _XFORMAPI TAG(transform_normals_no_rot)(const GLmatrix *mat, dest->count = in->count; } -static void _XFORMAPI TAG(transform_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) + +static void _XFORMAPI +TAG(transform_normals)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -298,12 +307,13 @@ static void _XFORMAPI TAG(transform_normals)( const GLmatrix *mat, } -static void _XFORMAPI TAG(normalize_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) +static void _XFORMAPI +TAG(normalize_normals)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -347,12 +357,13 @@ static void _XFORMAPI TAG(normalize_normals)( const GLmatrix *mat, } -static void _XFORMAPI TAG(rescale_normals)( const GLmatrix *mat, - GLfloat scale, - const GLvector3f *in, - const GLfloat *lengths, - const GLubyte mask[], - GLvector3f *dest ) +static void _XFORMAPI +TAG(rescale_normals)( const GLmatrix *mat, + GLfloat scale, + const GLvector3f *in, + const GLfloat *lengths, + const GLubyte mask[], + GLvector3f *dest ) { GLuint i; const GLfloat *from = in->start; @@ -372,7 +383,8 @@ static void _XFORMAPI TAG(rescale_normals)( const GLmatrix *mat, } -static void _XFORMAPI TAG(init_c_norm_transform)( void ) +static void _XFORMAPI +TAG(init_c_norm_transform)( void ) { gl_normal_tab[NORM_TRANSFORM_NO_ROT][IDX] = TAG(transform_normals_no_rot); @@ -397,5 +409,4 @@ static void _XFORMAPI TAG(init_c_norm_transform)( void ) gl_normal_tab[NORM_NORMALIZE][IDX] = TAG(normalize_normals); - } diff --git a/xc/extras/Mesa/src/pb.c b/xc/extras/Mesa/src/pb.c index 1e5ac03e2..9d5ec6e3d 100644 --- a/xc/extras/Mesa/src/pb.c +++ b/xc/extras/Mesa/src/pb.c @@ -115,10 +115,10 @@ static void multi_write_index_pixels( GLcontext *ctx, GLuint n, /* make copy of incoming indexes */ MEMCPY( indexTmp, indexes, n * sizeof(GLuint) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_pixels( ctx, n, x, y, indexTmp, mask ); + _mesa_logicop_ci_pixels( ctx, n, x, y, indexTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_pixels( ctx, n, x, y, indexTmp, mask ); + _mesa_mask_index_pixels( ctx, n, x, y, indexTmp, mask ); } (*ctx->Driver.WriteCI32Pixels)( ctx, n, x, y, indexTmp, mask ); } @@ -170,20 +170,20 @@ static void multi_write_rgba_pixels( GLcontext *ctx, GLuint n, MEMCPY( rgbaTmp, rgba, 4 * n * sizeof(GLubyte) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); + _mesa_logicop_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_pixels( ctx, n, x, y, rgbaTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); + _mesa_mask_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); } (*ctx->Driver.WriteRGBAPixels)( ctx, n, x, y, (const GLubyte (*)[4])rgbaTmp, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_pixels( ctx, n, x, y, - (const GLubyte (*)[4])rgbaTmp, mask ); + _mesa_write_alpha_pixels( ctx, n, x, y, + (const GLubyte (*)[4])rgbaTmp, mask ); } } } @@ -292,7 +292,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -311,21 +311,21 @@ void gl_flush_pb( GLcontext *ctx ) /* normal case: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_pixels( ctx, PB->count, PB->x, PB->y, - PB->rgba, mask); + _mesa_logicop_rgba_pixels( ctx, PB->count, PB->x, PB->y, + PB->rgba, mask); } else if (ctx->Color.BlendEnabled) { _mesa_blend_pixels( ctx, PB->count, PB->x, PB->y, PB->rgba, mask); } if (ctx->Color.SWmasking) { - gl_mask_rgba_pixels(ctx, PB->count, PB->x, PB->y, PB->rgba, mask); + _mesa_mask_rgba_pixels(ctx, PB->count, PB->x, PB->y, PB->rgba, mask); } (*ctx->Driver.WriteRGBAPixels)( ctx, PB->count, PB->x, PB->y, (const GLubyte (*)[4]) PB->rgba, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_pixels( ctx, PB->count, PB->x, PB->y, + _mesa_write_alpha_pixels( ctx, PB->count, PB->x, PB->y, (const GLubyte (*)[4]) PB->rgba, mask ); } } @@ -344,7 +344,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -382,8 +382,8 @@ void gl_flush_pb( GLcontext *ctx ) (*ctx->Driver.WriteMonoRGBAPixels)( ctx, PB->count, PB->x, PB->y, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_mono_alpha_pixels( ctx, PB->count, PB->x, PB->y, - PB->color[ACOMP], mask ); + _mesa_write_mono_alpha_pixels( ctx, PB->count, PB->x, PB->y, + PB->color[ACOMP], mask ); } } /*** ALL DONE ***/ @@ -416,7 +416,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -433,10 +433,10 @@ void gl_flush_pb( GLcontext *ctx ) /* normal case: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + _mesa_logicop_ci_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + _mesa_mask_index_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); } (*ctx->Driver.WriteCI32Pixels)( ctx, PB->count, PB->x, PB->y, @@ -452,7 +452,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } diff --git a/xc/extras/Mesa/src/pixel.c b/xc/extras/Mesa/src/pixel.c index fd42ba3a9..e70f98414 100644 --- a/xc/extras/Mesa/src/pixel.c +++ b/xc/extras/Mesa/src/pixel.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,11 +24,6 @@ */ -/* - * glPixelStore, glPixelTransfer, glPixelMap, glPixelZoom, etc. - */ - - #ifdef PC_HEADER #include "all.h" #else @@ -561,6 +556,30 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param ) case GL_DEPTH_BIAS: ctx->Pixel.DepthBias = param; break; + case GL_POST_COLOR_MATRIX_RED_SCALE: + ctx->Pixel.PostColorMatrixRedScale = param; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS: + ctx->Pixel.PostColorMatrixRedBias = param; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE: + ctx->Pixel.PostColorMatrixGreenScale = param; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS: + ctx->Pixel.PostColorMatrixGreenBias = param; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE: + ctx->Pixel.PostColorMatrixBlueScale = param; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS: + ctx->Pixel.PostColorMatrixBlueBias = param; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE: + ctx->Pixel.PostColorMatrixAlphaScale = param; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS: + ctx->Pixel.PostColorMatrixAlphaBias = param; + break; default: gl_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); return; @@ -575,6 +594,20 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param ) else { ctx->Pixel.ScaleOrBiasRGBA = GL_FALSE; } + + if (ctx->Pixel.PostColorMatrixRedScale!=1.0F || + ctx->Pixel.PostColorMatrixRedBias!=0.0F || + ctx->Pixel.PostColorMatrixGreenScale!=1.0F || + ctx->Pixel.PostColorMatrixGreenBias!=0.0F || + ctx->Pixel.PostColorMatrixBlueScale!=1.0F || + ctx->Pixel.PostColorMatrixBlueBias!=0.0F || + ctx->Pixel.PostColorMatrixAlphaScale!=1.0F || + ctx->Pixel.PostColorMatrixAlphaBias!=0.0F) { + ctx->Pixel.ScaleOrBiasRGBApcm = GL_TRUE; + } + else { + ctx->Pixel.ScaleOrBiasRGBApcm = GL_FALSE; + } } @@ -586,60 +619,16 @@ _mesa_PixelTransferi( GLenum pname, GLint param ) - -/* - * Pixel processing functions - */ - - -/* - * Apply scale and bias factors to an array of RGBA pixels. - */ -void gl_scale_and_bias_color( const GLcontext *ctx, GLuint n, - GLfloat red[], GLfloat green[], - GLfloat blue[], GLfloat alpha[] ) -{ - GLuint i; - for (i=0;i<n;i++) { - GLfloat r = red[i] * ctx->Pixel.RedScale + ctx->Pixel.RedBias; - GLfloat g = green[i] * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias; - GLfloat b = blue[i] * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias; - GLfloat a = alpha[i] * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias; - red[i] = CLAMP( r, 0.0F, 1.0F ); - green[i] = CLAMP( g, 0.0F, 1.0F ); - blue[i] = CLAMP( b, 0.0F, 1.0F ); - alpha[i] = CLAMP( a, 0.0F, 1.0F ); - } -} - - -/* - * Apply scale and bias factors to an array of RGBA pixels. - */ -void gl_scale_and_bias_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ) -{ - GLfloat rbias = ctx->Pixel.RedBias * 255.0F; - GLfloat gbias = ctx->Pixel.GreenBias * 255.0F; - GLfloat bbias = ctx->Pixel.BlueBias * 255.0F; - GLfloat abias = ctx->Pixel.AlphaBias * 255.0F; - GLuint i; - for (i=0;i<n;i++) { - GLint r = (GLint) (rgba[i][RCOMP] * ctx->Pixel.RedScale + rbias); - GLint g = (GLint) (rgba[i][GCOMP] * ctx->Pixel.GreenScale + gbias); - GLint b = (GLint) (rgba[i][BCOMP] * ctx->Pixel.BlueScale + bbias); - GLint a = (GLint) (rgba[i][ACOMP] * ctx->Pixel.AlphaScale + abias); - rgba[i][RCOMP] = CLAMP( r, 0, 255 ); - rgba[i][GCOMP] = CLAMP( g, 0, 255 ); - rgba[i][BCOMP] = CLAMP( b, 0, 255 ); - rgba[i][ACOMP] = CLAMP( a, 0, 255 ); - } -} +/**********************************************************************/ +/***** Pixel processing functions ******/ +/**********************************************************************/ /* * Apply scale and bias factors to an array of RGBA pixels. */ -void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) +void +_mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]) { if (ctx->Pixel.RedScale != 1.0 || ctx->Pixel.RedBias != 0.0) { const GLfloat scale = ctx->Pixel.RedScale; @@ -677,32 +666,10 @@ void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[ /* - * Apply pixel mapping to an array of RGBA pixels. - */ -void gl_map_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ) -{ - GLfloat rscale = (ctx->Pixel.MapRtoRsize - 1) / 255.0F; - GLfloat gscale = (ctx->Pixel.MapGtoGsize - 1) / 255.0F; - GLfloat bscale = (ctx->Pixel.MapBtoBsize - 1) / 255.0F; - GLfloat ascale = (ctx->Pixel.MapAtoAsize - 1) / 255.0F; - GLuint i; - for (i=0;i<n;i++) { - GLint ir = (GLint) (rgba[i][RCOMP] * rscale); - GLint ig = (GLint) (rgba[i][GCOMP] * gscale); - GLint ib = (GLint) (rgba[i][BCOMP] * bscale); - GLint ia = (GLint) (rgba[i][ACOMP] * ascale); - rgba[i][RCOMP] = (GLint) (ctx->Pixel.MapRtoR[ir] * 255.0F); - rgba[i][GCOMP] = (GLint) (ctx->Pixel.MapGtoG[ig] * 255.0F); - rgba[i][BCOMP] = (GLint) (ctx->Pixel.MapBtoB[ib] * 255.0F); - rgba[i][ACOMP] = (GLint) (ctx->Pixel.MapAtoA[ia] * 255.0F); - } -} - - -/* * Apply pixel mapping to an array of floating point RGBA pixels. */ -void gl_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) +void +_mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) { const GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; const GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; @@ -723,22 +690,210 @@ void gl_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) /* - * Apply pixel mapping to an array of RGBA pixels. + * Apply the color matrix and post color matrix scaling and biasing. */ -void gl_map_color( const GLcontext *ctx, GLuint n, - GLfloat red[], GLfloat green[], - GLfloat blue[], GLfloat alpha[] ) +void +_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]) { - GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; - GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; - GLfloat bscale = ctx->Pixel.MapBtoBsize - 1; - GLfloat ascale = ctx->Pixel.MapAtoAsize - 1; + const GLfloat rs = ctx->Pixel.PostColorMatrixRedScale; + const GLfloat rb = ctx->Pixel.PostColorMatrixRedBias; + const GLfloat gs = ctx->Pixel.PostColorMatrixGreenScale; + const GLfloat gb = ctx->Pixel.PostColorMatrixGreenBias; + const GLfloat bs = ctx->Pixel.PostColorMatrixBlueScale; + const GLfloat bb = ctx->Pixel.PostColorMatrixBlueBias; + const GLfloat as = ctx->Pixel.PostColorMatrixAlphaScale; + const GLfloat ab = ctx->Pixel.PostColorMatrixAlphaBias; + const GLfloat *m = ctx->ColorMatrix.m; GLuint i; - for (i=0;i<n;i++) { - red[i] = ctx->Pixel.MapRtoR[ (GLint) (red[i] * rscale + 0.5F) ]; - green[i] = ctx->Pixel.MapGtoG[ (GLint) (green[i] * gscale + 0.5F) ]; - blue[i] = ctx->Pixel.MapBtoB[ (GLint) (blue[i] * bscale + 0.5F) ]; - alpha[i] = ctx->Pixel.MapAtoA[ (GLint) (alpha[i] * ascale + 0.5F) ]; + for (i = 0; i < n; i++) { + const GLfloat r = rgba[i][RCOMP]; + const GLfloat g = rgba[i][GCOMP]; + const GLfloat b = rgba[i][BCOMP]; + const GLfloat a = rgba[i][ACOMP]; + rgba[i][RCOMP] = (m[0] * r + m[4] * g + m[ 8] * b + m[12] * a) * rs + rb; + rgba[i][GCOMP] = (m[1] * r + m[5] * g + m[ 9] * b + m[13] * a) * gs + gb; + rgba[i][BCOMP] = (m[2] * r + m[6] * g + m[10] * b + m[14] * a) * bs + bb; + rgba[i][ACOMP] = (m[3] * r + m[7] * g + m[11] * b + m[15] * a) * as + ab; + } +} + + +/* + * Apply a color table lookup to an array of colors. + */ +void +_mesa_lookup_rgba(const struct gl_color_table *table, + GLuint n, GLfloat rgba[][4]) +{ + ASSERT(table->TableType == GL_FLOAT); + if (!table->Table) + return; + + switch (table->Format) { + case GL_INTENSITY: + /* replace RGBA with I */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j] * (1.0F / 255.0F); + rgba[i][RCOMP] = rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = c; + } + + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j]; + rgba[i][RCOMP] = rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = c; + } + } + break; + case GL_LUMINANCE: + /* replace RGB with L */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j] * (1.0F / 255.0F); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j]; + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; + } + } + break; + case GL_ALPHA: + /* replace A with A */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][ACOMP] = lut[j] * (1.0F / 255.0F); + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][ACOMP] = lut[j]; + } + } + break; + case GL_LUMINANCE_ALPHA: + /* replace RGBA with LLLA */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + GLfloat luminance = lut[jL * 2 + 0] * (1.0F / 255.0F); + GLfloat alpha = lut[jA * 2 + 1] * (1.0F / 255.0F); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + GLfloat luminance = lut[jL * 2 + 0]; + GLfloat alpha = lut[jA * 2 + 1]; + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + } + break; + case GL_RGB: + /* replace RGB with RGB */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 3 + 0] * (1.0F / 255.0F); + rgba[i][GCOMP] = lut[jG * 3 + 1] * (1.0F / 255.0F); + rgba[i][BCOMP] = lut[jB * 3 + 2] * (1.0F / 255.0F); + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 3 + 0]; + rgba[i][GCOMP] = lut[jG * 3 + 1]; + rgba[i][BCOMP] = lut[jB * 3 + 2]; + } + } + break; + case GL_RGBA: + /* replace RGBA with RGBA */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 4 + 0] * (1.0F / 255.0F); + rgba[i][GCOMP] = lut[jG * 4 + 1] * (1.0F / 255.0F); + rgba[i][BCOMP] = lut[jB * 4 + 2] * (1.0F / 255.0F); + rgba[i][ACOMP] = lut[jA * 4 + 3] * (1.0F / 255.0F); + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 4 + 0]; + rgba[i][GCOMP] = lut[jG * 4 + 1]; + rgba[i][BCOMP] = lut[jB * 4 + 2]; + rgba[i][ACOMP] = lut[jA * 4 + 3]; + } + } + break; + default: + gl_problem(NULL, "Bad format in _mesa_lookup_rgba"); + return; } } @@ -747,7 +902,8 @@ void gl_map_color( const GLcontext *ctx, GLuint n, /* * Apply color index shift and offset to an array of pixels. */ -void gl_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) +void +_mesa_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) { GLint shift = ctx->Pixel.IndexShift; GLint offset = ctx->Pixel.IndexOffset; @@ -774,7 +930,8 @@ void gl_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) /* * Apply color index mapping to color indexes. */ -void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) +void +_mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) { GLuint mask = ctx->Pixel.MapItoIsize - 1; GLuint i; @@ -787,8 +944,9 @@ void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) /* * Map color indexes to rgba values. */ -void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[], - GLubyte rgba[][4] ) +void +_mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n, + const GLuint index[], GLubyte rgba[][4] ) { GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; @@ -811,8 +969,9 @@ void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[], /* * Map color indexes to float rgba values. */ -void gl_map_ci_to_rgba_float( const GLcontext *ctx, GLuint n, const GLuint index[], - GLfloat rgba[][4] ) +void +_mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n, + const GLuint index[], GLfloat rgba[][4] ) { GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; @@ -835,8 +994,9 @@ void gl_map_ci_to_rgba_float( const GLcontext *ctx, GLuint n, const GLuint index /* * Map 8-bit color indexes to rgb values. */ -void gl_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], - GLubyte rgba[][4] ) +void +_mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], + GLubyte rgba[][4] ) { GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; @@ -856,27 +1016,9 @@ void gl_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], } -void gl_map_ci_to_color( const GLcontext *ctx, GLuint n, const GLuint index[], - GLfloat r[], GLfloat g[], - GLfloat b[], GLfloat a[] ) -{ - GLuint rmask = ctx->Pixel.MapItoRsize - 1; - GLuint gmask = ctx->Pixel.MapItoGsize - 1; - GLuint bmask = ctx->Pixel.MapItoBsize - 1; - GLuint amask = ctx->Pixel.MapItoAsize - 1; - GLuint i; - for (i=0;i<n;i++) { - r[i] = ctx->Pixel.MapItoR[index[i] & rmask]; - g[i] = ctx->Pixel.MapItoG[index[i] & gmask]; - b[i] = ctx->Pixel.MapItoB[index[i] & bmask]; - a[i] = ctx->Pixel.MapItoA[index[i] & amask]; - } -} - - - -void gl_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, - GLstencil stencil[] ) +void +_mesa_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, + GLstencil stencil[] ) { GLuint i; GLint shift = ctx->Pixel.IndexShift; @@ -901,8 +1043,8 @@ void gl_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, } - -void gl_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] ) +void +_mesa_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] ) { GLuint mask = ctx->Pixel.MapStoSsize - 1; GLuint i; @@ -910,4 +1052,3 @@ void gl_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] ) stencil[i] = ctx->Pixel.MapStoS[ stencil[i] & mask ]; } } - diff --git a/xc/extras/Mesa/src/pixel.h b/xc/extras/Mesa/src/pixel.h index 3a27d03fa..1b3a459e5 100644 --- a/xc/extras/Mesa/src/pixel.h +++ b/xc/extras/Mesa/src/pixel.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -75,64 +75,56 @@ _mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor ); * Pixel processing functions */ -extern void gl_scale_and_bias_color( const GLcontext *ctx, GLuint n, - GLfloat red[], GLfloat green[], - GLfloat blue[], GLfloat alpha[] ); - - -extern void gl_scale_and_bias_rgba( const GLcontext *ctx, GLuint n, - GLubyte rgba[][4] ); - - -extern void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, - GLfloat rgba[][4] ); - - -extern void gl_map_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ); +extern void +_mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); -extern void gl_map_rgba_float( const GLcontext *ctx, GLuint n, - GLfloat rgba[][4] ); +extern void +_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); -extern void gl_map_color( const GLcontext *ctx, GLuint n, - GLfloat red[], GLfloat green[], - GLfloat blue[], GLfloat alpha[] ); +extern void +_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]); -extern void gl_shift_and_offset_ci( const GLcontext *ctx, GLuint n, - GLuint indexes[] ); +extern void +_mesa_lookup_rgba(const struct gl_color_table *table, + GLuint n, GLfloat rgba[][4]); -extern void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ); +extern void +_mesa_shift_and_offset_ci(const GLcontext *ctx, GLuint n, + GLuint indexes[]); -extern void gl_map_ci_to_rgba( const GLcontext *ctx, - GLuint n, const GLuint index[], - GLubyte rgba[][4] ); +extern void +_mesa_map_ci(const GLcontext *ctx, GLuint n, GLuint index[]); -extern void gl_map_ci_to_rgba_float( const GLcontext *ctx, - GLuint n, const GLuint index[], - GLfloat rgba[][4] ); +extern void +_mesa_map_ci_to_rgba_ubyte(const GLcontext *ctx, + GLuint n, const GLuint index[], + GLubyte rgba[][4]); -extern void gl_map_ci8_to_rgba( const GLcontext *ctx, - GLuint n, const GLubyte index[], - GLubyte rgba[][4] ); +extern void +_mesa_map_ci_to_rgba(const GLcontext *ctx, + GLuint n, const GLuint index[], GLfloat rgba[][4]); -extern void gl_map_ci_to_color( const GLcontext *ctx, - GLuint n, const GLuint index[], - GLfloat r[], GLfloat g[], - GLfloat b[], GLfloat a[] ); +extern void +_mesa_map_ci8_to_rgba(const GLcontext *ctx, + GLuint n, const GLubyte index[], + GLubyte rgba[][4]); -extern void gl_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, - GLstencil indexes[] ); +extern void +_mesa_shift_and_offset_stencil(const GLcontext *ctx, GLuint n, + GLstencil indexes[]); -extern void gl_map_stencil( const GLcontext *ctx, GLuint n, GLstencil index[] ); +extern void +_mesa_map_stencil(const GLcontext *ctx, GLuint n, GLstencil index[]); #endif diff --git a/xc/extras/Mesa/src/pixeltex.c b/xc/extras/Mesa/src/pixeltex.c new file mode 100644 index 000000000..a42869912 --- /dev/null +++ b/xc/extras/Mesa/src/pixeltex.c @@ -0,0 +1,204 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.3 + * + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/* + * This file implements both the GL_SGIX_pixel_texture and + * GL_SIGS_pixel_texture extensions. Luckily, they pretty much + * overlap in functionality so we use the same state variables + * and execution code for both. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "glheader.h" +#include "context.h" +#include "pixeltex.h" +#endif + + +void +_mesa_PixelTexGenSGIX(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPixelTexGenSGIX"); + + switch (mode) { + case GL_NONE: + ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS; + ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS; + break; + case GL_ALPHA: + ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS; + ctx->Pixel.FragmentAlphaSource = GL_CURRENT_RASTER_COLOR; + break; + case GL_RGB: + ctx->Pixel.FragmentRgbSource = GL_CURRENT_RASTER_COLOR; + ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS; + break; + case GL_RGBA: + ctx->Pixel.FragmentRgbSource = GL_CURRENT_RASTER_COLOR; + ctx->Pixel.FragmentAlphaSource = GL_CURRENT_RASTER_COLOR; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glPixelTexGenSGIX(mode)"); + return; + } +} + + +void +_mesa_PixelTexGenParameterfSGIS(GLenum target, GLfloat value) +{ + _mesa_PixelTexGenParameteriSGIS(target, (GLint) value); +} + + +void +_mesa_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value) +{ + _mesa_PixelTexGenParameteriSGIS(target, (GLint) *value); +} + + +void +_mesa_PixelTexGenParameteriSGIS(GLenum target, GLint value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPixelTexGenParameterSGIS"); + + if (value != GL_CURRENT_RASTER_COLOR && value != GL_PIXEL_GROUP_COLOR_SGIS) { + gl_error(ctx, GL_INVALID_ENUM, "glPixelTexGenParameterSGIS(value)"); + return; + } + + if (target == GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS) { + ctx->Pixel.FragmentRgbSource = (GLenum) value; + } + else if (target == GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS) { + ctx->Pixel.FragmentAlphaSource = (GLenum) value; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glPixelTexGenParameterSGIS(target)"); + } +} + + +void +_mesa_PixelTexGenParameterivSGIS(GLenum target, const GLint *value) +{ + _mesa_PixelTexGenParameteriSGIS(target, *value); +} + + +void +_mesa_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetPixelTexGenParameterfvSGIS"); + + if (target == GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS) { + *value = (GLfloat) ctx->Pixel.FragmentRgbSource; + } + else if (target == GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS) { + *value = (GLfloat) ctx->Pixel.FragmentAlphaSource; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetPixelTexGenParameterfvSGIS(target)"); + } +} + + +void +_mesa_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetPixelTexGenParameterivSGIS"); + + if (target == GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS) { + *value = (GLint) ctx->Pixel.FragmentRgbSource; + } + else if (target == GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS) { + *value = (GLint) ctx->Pixel.FragmentAlphaSource; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetPixelTexGenParameterivSGIS(target)"); + } +} + + + +/* + * Convert RGBA values into strq texture coordinates. + */ +void +_mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLubyte rgba[][4], + GLfloat s[], GLfloat t[], GLfloat r[], GLfloat q[]) +{ + static GLboolean firstCall = GL_TRUE; + static GLfloat byteToFloat[256]; + + if (firstCall) { + GLuint i; + for (i = 0; i < 256; i++) { + byteToFloat[i] = i / 255.0F; + } + firstCall = GL_FALSE; + } + + if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_COLOR) { + GLuint i; + for (i = 0; i < n; i++) { + s[i] = ctx->Current.RasterColor[RCOMP]; + t[i] = ctx->Current.RasterColor[GCOMP]; + r[i] = ctx->Current.RasterColor[BCOMP]; + } + } + else { + GLuint i; + ASSERT(ctx->Pixel.FragmentRgbSource == GL_PIXEL_GROUP_COLOR_SGIS); + for (i = 0; i < n; i++) { + s[i] = byteToFloat[rgba[i][RCOMP]]; + t[i] = byteToFloat[rgba[i][GCOMP]]; + r[i] = byteToFloat[rgba[i][BCOMP]]; + } + } + + if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_COLOR) { + GLuint i; + for (i = 0; i < n; i++) { + q[i] = ctx->Current.RasterColor[ACOMP]; + } + } + else { + GLuint i; + ASSERT(ctx->Pixel.FragmentAlphaSource == GL_PIXEL_GROUP_COLOR_SGIS); + for (i = 0; i < n; i++) { + q[i] = byteToFloat[rgba[i][ACOMP]]; + } + } +} diff --git a/xc/extras/Mesa/src/pixeltex.h b/xc/extras/Mesa/src/pixeltex.h new file mode 100644 index 000000000..d4f0718c1 --- /dev/null +++ b/xc/extras/Mesa/src/pixeltex.h @@ -0,0 +1,69 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.3 + * + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright noti_mesa_PixelTexGenParameterfvce and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef PIXELTEX_H +#define PIXELTEX_H + + +extern void +_mesa_PixelTexGenSGIX(GLenum mode); + +extern void +_mesa_PixelTexGenParameterfSGIS(GLenum target, GLfloat value); + +#ifdef VMS +#define _mesa_PixelTexGenParameterfvSGIS _mesa_PixelTexGenParameterfv +#endif +extern void +_mesa_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value); + +extern void +_mesa_PixelTexGenParameteriSGIS(GLenum target, GLint value); + +#ifdef VMS +#define _mesa_PixelTexGenParameterivSGIS _mesa_PixelTexGenParameteriv +#endif +extern void +_mesa_PixelTexGenParameterivSGIS(GLenum target, const GLint *value); + +#ifdef VMS +#define _mesa_GetPixelTexGenParameterfvSGIS _mesa_GetPixelTexGenParameterfv +#endif +extern void +_mesa_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value); + +#ifdef VMS +#define _mesa_GetPixelTexGenParameterivSGIS _mesa_GetPixelTexGenParameteriv +#endif +extern void +_mesa_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value); + +extern void +_mesa_pixeltexgen(GLcontext *ctx, GLuint n, const GLubyte rgba[][4], + GLfloat s[], GLfloat t[], GLfloat r[], GLfloat q[]); + + +#endif diff --git a/xc/extras/Mesa/src/readpix.c b/xc/extras/Mesa/src/readpix.c index 235444e03..cc1823897 100644 --- a/xc/extras/Mesa/src/readpix.c +++ b/xc/extras/Mesa/src/readpix.c @@ -75,11 +75,11 @@ static void read_index_pixels( GLcontext *ctx, (*ctx->Driver.ReadCI32Span)( ctx, readWidth, x, y, index ); if (ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0) { - gl_shift_and_offset_ci( ctx, readWidth, index); + _mesa_shift_and_offset_ci( ctx, readWidth, index); } if (ctx->Pixel.MapColorFlag) { - gl_map_ci(ctx, readWidth, index); + _mesa_map_ci(ctx, readWidth, index); } dest = _mesa_image_address(packing, pixels, @@ -199,7 +199,7 @@ static void read_depth_pixels( GLcontext *ctx, bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; - if (type==GL_UNSIGNED_SHORT && sizeof(GLdepth)==sizeof(GLushort) + if (type==GL_UNSIGNED_SHORT && ctx->Visual->DepthBits == 16 && !bias_or_scale && !packing->SwapBytes) { /* Special case: directly read 16-bit unsigned depth values. */ for (j=0;j<height;j++,y++) { @@ -207,7 +207,7 @@ static void read_depth_pixels( GLcontext *ctx, GLushort *dst = (GLushort*) _mesa_image_address( packing, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 ); GLint i; - (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, depth); + _mesa_read_depth_span(ctx, width, x, y, depth); for (i = 0; i < width; i++) dst[i] = depth[i]; } @@ -218,11 +218,11 @@ static void read_depth_pixels( GLcontext *ctx, for (j=0;j<height;j++,y++) { GLdepth *dst = (GLdepth *) _mesa_image_address( packing, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 ); - (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, dst); + _mesa_read_depth_span(ctx, width, x, y, dst); } } else { - /* General case (slow) */ + /* General case (slower) */ for (j=0;j<height;j++,y++) { GLfloat depth[MAX_WIDTH]; GLvoid *dest; @@ -358,14 +358,14 @@ static void read_stencil_pixels( GLcontext *ctx, GLvoid *dest; GLstencil stencil[MAX_WIDTH]; - gl_read_stencil_span( ctx, readWidth, x, y, stencil ); + _mesa_read_stencil_span( ctx, readWidth, x, y, stencil ); if (shift_or_offset) { - gl_shift_and_offset_stencil( ctx, readWidth, stencil ); + _mesa_shift_and_offset_stencil( ctx, readWidth, stencil ); } if (ctx->Pixel.MapStencilFlag) { - gl_map_stencil( ctx, readWidth, stencil ); + _mesa_map_stencil( ctx, readWidth, stencil ); } dest = _mesa_image_address( packing, pixels, @@ -500,8 +500,17 @@ read_fast_rgba_pixels( GLcontext *ctx, GLvoid *pixels, const struct gl_pixelstore_attrib *packing ) { - /* can't do scale, bias or mapping */ - if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) + GLboolean applyTransferOps; + + applyTransferOps = ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled; + /* can't do scale, bias, mapping, etc */ + if (applyTransferOps) return GL_FALSE; /* can't do fancy pixel packing */ @@ -559,8 +568,8 @@ read_fast_rgba_pixels( GLcontext *ctx, (*ctx->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY, (GLubyte (*)[4]) dest); if (ctx->Visual->SoftwareAlpha) { - gl_read_alpha_span(ctx, readWidth, srcX, srcY, - (GLubyte (*)[4]) dest); + _mesa_read_alpha_span(ctx, readWidth, srcX, srcY, + (GLubyte (*)[4]) dest); } dest += rowLength * 4; srcY++; @@ -641,13 +650,14 @@ static void read_rgba_pixels( GLcontext *ctx, gl_read_rgba_span( ctx, ctx->ReadBuffer, readWidth, x, y, rgba ); dest = _mesa_image_address( packing, pixels, width, height, - format, type, 0, j, 0); + format, type, 0, j, 0); _mesa_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba, format, type, dest, packing, GL_TRUE ); } } else { + /* Convert color index pixels to RGBA */ GLint j; for (j=0;j<height;j++,y++) { GLubyte rgba[MAX_WIDTH][4]; @@ -657,13 +667,13 @@ static void read_rgba_pixels( GLcontext *ctx, (*ctx->Driver.ReadCI32Span)( ctx, readWidth, x, y, index ); if (ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0) { - gl_map_ci( ctx, readWidth, index ); + _mesa_map_ci( ctx, readWidth, index ); } - gl_map_ci_to_rgba(ctx, readWidth, index, rgba ); + _mesa_map_ci_to_rgba_ubyte(ctx, readWidth, index, rgba ); dest = _mesa_image_address( packing, pixels, width, height, - format, type, 0, j, 0); + format, type, 0, j, 0); _mesa_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba, format, type, dest, packing, GL_TRUE ); diff --git a/xc/extras/Mesa/src/render_tmp.h b/xc/extras/Mesa/src/render_tmp.h index 3907ee86f..572a06c8c 100644 --- a/xc/extras/Mesa/src/render_tmp.h +++ b/xc/extras/Mesa/src/render_tmp.h @@ -55,6 +55,8 @@ static void TAG(render_vb_points)( struct vertex_buffer *VB, { LOCAL_VARS; (void) parity; + VB->ctx->OcclusionResult = GL_TRUE; + INIT(GL_POINTS); RENDER_POINTS( start, count ); POSTFIX; @@ -68,6 +70,7 @@ static void TAG(render_vb_lines)( struct vertex_buffer *VB, GLuint j; LOCAL_VARS; (void) parity; + VB->ctx->OcclusionResult = GL_TRUE; INIT(GL_LINES); for (j=start+1; j<count; j+=2 ) { @@ -86,6 +89,7 @@ static void TAG(render_vb_line_strip)( struct vertex_buffer *VB, GLuint j; LOCAL_VARS; (void) parity; + VB->ctx->OcclusionResult = GL_TRUE; INIT(GL_LINES); for (j=start+1; j<count; j++ ) { @@ -107,6 +111,7 @@ static void TAG(render_vb_line_loop)( struct vertex_buffer *VB, GLuint i = start < VB->Start ? VB->Start : start + 1; LOCAL_VARS; (void) parity; + VB->ctx->OcclusionResult = GL_TRUE; INIT(GL_LINES); for ( ; i < count ; i++) { diff --git a/xc/extras/Mesa/src/span.c b/xc/extras/Mesa/src/span.c index 39059ab3b..a5d1a7c9b 100644 --- a/xc/extras/Mesa/src/span.c +++ b/xc/extras/Mesa/src/span.c @@ -148,10 +148,10 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n, /* make copy of incoming indexes */ MEMCPY( indexTmp, indexes, n * sizeof(GLuint) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, indexTmp, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, indexTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, indexTmp ); + _mesa_mask_index_span( ctx, n, x, y, indexTmp ); } (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask ); } @@ -218,7 +218,7 @@ void gl_write_index_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } } @@ -237,10 +237,10 @@ void gl_write_index_span( GLcontext *ctx, else { /* normal situation: draw to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, index, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, index, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, index ); + _mesa_mask_index_span( ctx, n, x, y, index ); } /* write pixels */ @@ -281,7 +281,7 @@ void gl_write_monoindex_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } } @@ -311,11 +311,11 @@ void gl_write_monoindex_span( GLcontext *ctx, } if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, indexes, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, indexes, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, indexes ); + _mesa_mask_index_span( ctx, n, x, y, indexes ); } if (ctx->RasterMask & MULTI_DRAW_BIT) { @@ -325,10 +325,10 @@ void gl_write_monoindex_span( GLcontext *ctx, else { /* normal situation: draw to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, indexes, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, indexes, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, indexes ); + _mesa_mask_index_span( ctx, n, x, y, indexes ); } (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexes, mask ); } @@ -392,20 +392,20 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n, MEMCPY( rgbaTmp, rgba, 4 * n * sizeof(GLubyte) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgbaTmp, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgbaTmp, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgbaTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgbaTmp ); + _mesa_mask_rgba_span( ctx, n, x, y, rgbaTmp ); } (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4]) rgbaTmp, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, - (const GLubyte (*)[4])rgbaTmp, mask ); + _mesa_write_alpha_span( ctx, n, x, y, + (const GLubyte (*)[4])rgbaTmp, mask ); } } } @@ -476,7 +476,7 @@ void gl_write_rgba_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -504,7 +504,7 @@ void gl_write_rgba_span( GLcontext *ctx, /* normal: write to exactly one buffer */ /* logic op or blending */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); @@ -512,7 +512,7 @@ void gl_write_rgba_span( GLcontext *ctx, /* Color component masking */ if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } /* write pixels */ @@ -521,9 +521,9 @@ void gl_write_rgba_span( GLcontext *ctx, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, - (const GLubyte (*)[4]) rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, + (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } } @@ -589,7 +589,7 @@ void gl_write_monocolor_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -629,7 +629,7 @@ void gl_write_monocolor_span( GLcontext *ctx, else { /* normal: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); @@ -637,7 +637,7 @@ void gl_write_monocolor_span( GLcontext *ctx, /* Color component masking */ if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } /* write pixels */ @@ -645,9 +645,9 @@ void gl_write_monocolor_span( GLcontext *ctx, (const GLubyte (*)[4]) rgba, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, - (const GLubyte (*)[4]) rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, + (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } } } @@ -670,8 +670,8 @@ void gl_write_monocolor_span( GLcontext *ctx, else { (*ctx->Driver.WriteMonoRGBASpan)( ctx, n, x, y, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_mono_alpha_span( ctx, n, x, y, (GLubyte) color[ACOMP], - write_all ? Null : mask ); + _mesa_write_mono_alpha_span( ctx, n, x, y, (GLubyte) color[ACOMP], + write_all ? Null : mask ); } } } @@ -744,7 +744,7 @@ void gl_write_texture_span( GLcontext *ctx, } /* Texture */ - ASSERT(ctx->Texture.Enabled); + ASSERT(ctx->Texture.ReallyEnabled); gl_texture_pixels( ctx, 0, n, s, t, u, lambda, rgba ); /* Add base and specular colors */ @@ -781,7 +781,7 @@ void gl_write_texture_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -807,20 +807,20 @@ void gl_write_texture_span( GLcontext *ctx, else { /* normal: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4])rgba, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } } } @@ -871,7 +871,7 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, } /* Texture */ - ASSERT(ctx->Texture.Enabled); + ASSERT(ctx->Texture.ReallyEnabled); ASSERT(texUnits <= MAX_TEXTURE_UNITS); for (i=0;i<texUnits;i++) { gl_texture_pixels( ctx, i, n, s[i], t[i], u[i], lambda[i], rgba ); @@ -911,7 +911,7 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -938,19 +938,19 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, /* normal: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4])rgba, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4])rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4])rgba, + write_all ? Null : mask ); } } } @@ -969,7 +969,7 @@ void gl_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, || x + (GLint) n < 0 || x >= buffer->Width) { /* completely above, below, or right */ /* XXX maybe leave undefined? */ - MEMSET( rgba, 0, 4 * n * sizeof(GLubyte)); + BZERO(rgba, 4 * n * sizeof(GLubyte)); } else { GLint skip, length; @@ -1002,7 +1002,7 @@ void gl_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, (*ctx->Driver.ReadRGBASpan)( ctx, length, x + skip, y, rgba + skip ); if (ctx->Visual->SoftwareAlpha) { - gl_read_alpha_span( ctx, length, x + skip, y, rgba + skip ); + _mesa_read_alpha_span( ctx, length, x + skip, y, rgba + skip ); } } } @@ -1020,7 +1020,7 @@ void gl_read_index_span( GLcontext *ctx, GLframebuffer *buffer, if (y < 0 || y >= buffer->Height || x + (GLint) n < 0 || x >= buffer->Width) { /* completely above, below, or right */ - MEMSET(indx, 0, n * sizeof(GLuint)); + BZERO(indx, n * sizeof(GLuint)); } else { GLint skip, length; diff --git a/xc/extras/Mesa/src/state.c b/xc/extras/Mesa/src/state.c index fda6210ba..b2ec15607 100644 --- a/xc/extras/Mesa/src/state.c +++ b/xc/extras/Mesa/src/state.c @@ -63,6 +63,7 @@ #include "mmath.h" #include "pipeline.h" #include "pixel.h" +#include "pixeltex.h" #include "points.h" #include "polygon.h" #include "quads.h" @@ -524,6 +525,17 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; + /* GL_SGIX_pixel_texture */ + exec->PixelTexGenSGIX = _mesa_PixelTexGenSGIX; + + /* GL_SGIS_pixel_texture */ + exec->PixelTexGenParameteriSGIS = _mesa_PixelTexGenParameteriSGIS; + exec->PixelTexGenParameterivSGIS = _mesa_PixelTexGenParameterivSGIS; + exec->PixelTexGenParameterfSGIS = _mesa_PixelTexGenParameterfSGIS; + exec->PixelTexGenParameterfvSGIS = _mesa_PixelTexGenParameterfvSGIS; + exec->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; + exec->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; + /* GL_EXT_compiled_vertex_array */ exec->LockArraysEXT = _mesa_LockArraysEXT; exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; @@ -790,16 +802,9 @@ static void update_rasterflags( GLcontext *ctx ) ctx->RasterMask |= WINCLIP_BIT; } - if (ctx->Depth.OcclusionTest) { - if (ctx->Color.ColorMask[0] == 0 && - ctx->Color.ColorMask[1] == 0 && - ctx->Color.ColorMask[2] == 0 && - ctx->Color.ColorMask[3] == 0 && - ctx->Depth.Mask == GL_FALSE && - !ctx->Stencil.Enabled) { - ctx->RasterMask |= OCCLUSION_BIT; - } - } + if (ctx->Depth.OcclusionTest) + ctx->RasterMask |= OCCLUSION_BIT; + /* If we're not drawing to exactly one color buffer set the * MULTI_DRAW_BIT flag. Also set it if we're drawing to no @@ -1142,6 +1147,10 @@ void gl_update_state( GLcontext *ctx ) ctx->ModelProjectWinMatrixUptodate = 0; } + if (ctx->NewState & NEW_COLOR_MATRIX) { + gl_matrix_analyze( &ctx->ColorMatrix ); + } + /* Figure out whether we can light in object space or not. If we * can, find the current positions of the lights in object space */ diff --git a/xc/extras/Mesa/src/stencil.c b/xc/extras/Mesa/src/stencil.c index a0703339d..5e0494328 100644 --- a/xc/extras/Mesa/src/stencil.c +++ b/xc/extras/Mesa/src/stencil.c @@ -541,9 +541,9 @@ do_stencil_test( GLcontext *ctx, GLuint n, GLstencil stencil[], * */ static GLboolean -stencil_and_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLdepth z[], GLstencil stencil[], - GLubyte mask[] ) +stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLstencil stencil[], + GLubyte mask[] ) { ASSERT(ctx->Stencil.Enabled); ASSERT(n <= PB_SIZE); @@ -624,8 +624,8 @@ stencil_and_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, * */ GLboolean -gl_stencil_and_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLdepth z[], GLubyte mask[] ) +_mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLubyte mask[] ) { GLstencil stencilRow[MAX_WIDTH]; GLstencil *stencil; @@ -647,7 +647,7 @@ gl_stencil_and_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, } /* do all the stencil/depth testing/updating */ - result = stencil_and_depth_test_span( ctx, n, x, y, z, stencil, mask ); + result = stencil_and_ztest_span( ctx, n, x, y, z, stencil, mask ); if (ctx->Driver.WriteStencilSpan) { /* Write updated stencil values into hardware stencil buffer */ @@ -1016,7 +1016,7 @@ stencil_test_pixels( GLcontext *ctx, GLuint n, * This is used both for software and hardware stencil buffers. * * The comments in this function are a bit sparse but the code is - * almost identical to stencil_and_depth_test_span(), which is well + * almost identical to stencil_and_ztest_span(), which is well * commented. * * Input: n - number of pixels in the array @@ -1028,9 +1028,9 @@ stencil_test_pixels( GLcontext *ctx, GLuint n, * GL_FALSE - one or more fragments passed the testing */ GLboolean -gl_stencil_and_depth_test_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLdepth z[], GLubyte mask[] ) +_mesa_stencil_and_ztest_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ) { ASSERT(ctx->Stencil.Enabled); ASSERT(n <= PB_SIZE); @@ -1129,24 +1129,44 @@ gl_stencil_and_depth_test_pixels( GLcontext *ctx, * x,y - location of first pixel * Output: stencil - the array of stencil values */ -void gl_read_stencil_span( GLcontext *ctx, - GLint n, GLint x, GLint y, GLstencil stencil[] ) +void +_mesa_read_stencil_span( GLcontext *ctx, + GLint n, GLint x, GLint y, GLstencil stencil[] ) { + if (y < 0 || y >= ctx->DrawBuffer->Height || + x + n <= 0 || x >= ctx->DrawBuffer->Width) { + /* span is completely outside framebuffer */ + return; /* undefined values OK */ + } + + if (x < 0) { + GLint dx = -x; + x = 0; + n -= dx; + stencil += dx; + } + if (x + n > ctx->DrawBuffer->Width) { + GLint dx = x + n - ctx->DrawBuffer->Width; + n -= dx; + } + if (n <= 0) { + return; + } + + ASSERT(n >= 0); - if (ctx->DrawBuffer->Stencil) { - if (ctx->Driver.ReadStencilSpan) { - (*ctx->Driver.ReadStencilSpan)( ctx, (GLuint) n, x, y, stencil ); - } - else { - const GLstencil *s = STENCIL_ADDRESS( x, y ); + if (ctx->Driver.ReadStencilSpan) { + (*ctx->Driver.ReadStencilSpan)( ctx, (GLuint) n, x, y, stencil ); + } + else if (ctx->DrawBuffer->Stencil) { + const GLstencil *s = STENCIL_ADDRESS( x, y ); #if STENCIL_BITS == 8 - MEMCPY( stencil, s, n * sizeof(GLstencil) ); + MEMCPY( stencil, s, n * sizeof(GLstencil) ); #else - GLuint i; - for (i=0;i<n;i++) - stencil[i] = s[i]; + GLuint i; + for (i=0;i<n;i++) + stencil[i] = s[i]; #endif - } } } @@ -1159,41 +1179,42 @@ void gl_read_stencil_span( GLcontext *ctx, * x, y - location of first pixel * stencil - the array of stencil values */ -void gl_write_stencil_span( GLcontext *ctx, - GLint n, GLint x, GLint y, - const GLstencil stencil[] ) +void +_mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y, + const GLstencil stencil[] ) { - ASSERT(n >= 0); - if (ctx->DrawBuffer->Stencil) { - /* do clipping */ - if (y < ctx->DrawBuffer->Ymin || y > ctx->DrawBuffer->Ymax) - return; - if (x < ctx->DrawBuffer->Xmin) { - GLint diff = ctx->DrawBuffer->Xmin - x; - n -= diff; - stencil += diff; - x = ctx->DrawBuffer->Xmin; - } - if (x + n > ctx->DrawBuffer->Xmax) { - GLint diff = x + n - ctx->DrawBuffer->Xmax; - n -= diff; - } + if (y < 0 || y >= ctx->DrawBuffer->Height || + x + n <= 0 || x >= ctx->DrawBuffer->Width) { + /* span is completely outside framebuffer */ + return; /* undefined values OK */ + } - ASSERT( n >= 0); + if (x < 0) { + GLint dx = -x; + x = 0; + n -= dx; + stencil += dx; + } + if (x + n > ctx->DrawBuffer->Width) { + GLint dx = x + n - ctx->DrawBuffer->Width; + n -= dx; + } + if (n <= 0) { + return; + } - if (ctx->Driver.WriteStencilSpan) { - (*ctx->Driver.WriteStencilSpan)( ctx, n, x, y, stencil, NULL ); - } - else { - GLstencil *s = STENCIL_ADDRESS( x, y ); + if (ctx->Driver.WriteStencilSpan) { + (*ctx->Driver.WriteStencilSpan)( ctx, n, x, y, stencil, NULL ); + } + else if (ctx->DrawBuffer->Stencil) { + GLstencil *s = STENCIL_ADDRESS( x, y ); #if STENCIL_BITS == 8 - MEMCPY( s, stencil, n * sizeof(GLstencil) ); + MEMCPY( s, stencil, n * sizeof(GLstencil) ); #else - GLuint i; - for (i=0;i<n;i++) - s[i] = stencil[i]; + GLuint i; + for (i=0;i<n;i++) + s[i] = stencil[i]; #endif - } } } @@ -1203,7 +1224,8 @@ void gl_write_stencil_span( GLcontext *ctx, * Allocate a new stencil buffer. If there's an old one it will be * deallocated first. The new stencil buffer will be uninitialized. */ -void gl_alloc_stencil_buffer( GLcontext *ctx ) +void +_mesa_alloc_stencil_buffer( GLcontext *ctx ) { GLuint buffersize = ctx->DrawBuffer->Width * ctx->DrawBuffer->Height; @@ -1218,7 +1240,7 @@ void gl_alloc_stencil_buffer( GLcontext *ctx ) if (!ctx->DrawBuffer->Stencil) { /* out of memory */ _mesa_set_enable( ctx, GL_STENCIL_TEST, GL_FALSE ); - gl_error( ctx, GL_OUT_OF_MEMORY, "gl_alloc_stencil_buffer" ); + gl_error( ctx, GL_OUT_OF_MEMORY, "_mesa_alloc_stencil_buffer" ); } } @@ -1390,7 +1412,8 @@ clear_hardware_stencil_buffer( GLcontext *ctx ) /* * Clear the stencil buffer. */ -void gl_clear_stencil_buffer( GLcontext *ctx ) +void +_mesa_clear_stencil_buffer( GLcontext *ctx ) { if (ctx->Driver.WriteStencilSpan) { ASSERT(ctx->Driver.ReadStencilSpan); diff --git a/xc/extras/Mesa/src/stencil.h b/xc/extras/Mesa/src/stencil.h index 259b5bf04..38a1ac1a0 100644 --- a/xc/extras/Mesa/src/stencil.h +++ b/xc/extras/Mesa/src/stencil.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -49,33 +49,31 @@ _mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass ); extern GLboolean -gl_stencil_and_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - const GLdepth z[], GLubyte mask[] ); +_mesa_stencil_and_ztest_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLdepth z[], GLubyte mask[] ); -#ifdef VMS /* VMS allows externals of 31 characters maximum */ -#define gl_stencil_and_depth_test_pixels gl_stencil_and_depth_test_pixel -#endif extern GLboolean -gl_stencil_and_depth_test_pixels( GLcontext *ctx, GLuint n, - const GLint x[], const GLint y[], - const GLdepth z[], GLubyte mask[] ); - +_mesa_stencil_and_ztest_pixels( GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], + const GLdepth z[], GLubyte mask[] ); extern void -gl_read_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y, - GLstencil stencil[] ); +_mesa_read_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y, + GLstencil stencil[] ); extern void -gl_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y, - const GLstencil stencil[] ); +_mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y, + const GLstencil stencil[] ); -extern void gl_alloc_stencil_buffer( GLcontext *ctx ); +extern void +_mesa_alloc_stencil_buffer( GLcontext *ctx ); -extern void gl_clear_stencil_buffer( GLcontext *ctx ); +extern void +_mesa_clear_stencil_buffer( GLcontext *ctx ); #endif diff --git a/xc/extras/Mesa/src/texobj.c b/xc/extras/Mesa/src/texobj.c index bafac922a..330943b57 100644 --- a/xc/extras/Mesa/src/texobj.c +++ b/xc/extras/Mesa/src/texobj.c @@ -28,6 +28,7 @@ #include "all.h" #else #include "glheader.h" +#include "colortab.h" #include "context.h" #include "enums.h" #include "hash.h" @@ -73,13 +74,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, obj->BaseLevel = 0; obj->MaxLevel = 1000; obj->MinMagThresh = 0.0F; - obj->Palette.Table[0] = 255; - obj->Palette.Table[1] = 255; - obj->Palette.Table[2] = 255; - obj->Palette.Table[3] = 255; - obj->Palette.Size = 1; - obj->Palette.IntFormat = GL_RGBA; - obj->Palette.Format = GL_RGBA; + _mesa_init_colortable(&obj->Palette); /* insert into linked list */ if (shared) { @@ -143,7 +138,9 @@ void gl_free_texture_object( struct gl_shared_state *shared, _mesa_HashRemove(shared->TexObjects, t->Name); } - /* free texture image */ + _mesa_free_colortable_data(&t->Palette); + + /* free texture images */ { GLuint i; for (i=0;i<MAX_TEXTURE_LEVELS;i++) { diff --git a/xc/extras/Mesa/src/texture.c b/xc/extras/Mesa/src/texture.c index db20c8c36..d101e2518 100644 --- a/xc/extras/Mesa/src/texture.c +++ b/xc/extras/Mesa/src/texture.c @@ -246,11 +246,13 @@ static void palette_sample(const struct gl_texture_object *tObj, GLenum format; if (ctx->Texture.SharedPalette) { - palette = ctx->Texture.Palette.Table; + ASSERT(ctx->Texture.Palette.TableType == GL_UNSIGNED_BYTE); + palette = (const GLubyte *) ctx->Texture.Palette.Table; format = ctx->Texture.Palette.Format; } else { - palette = tObj->Palette.Table; + ASSERT(tObj->Palette.TableType == GL_UNSIGNED_BYTE); + palette = (const GLubyte *) tObj->Palette.Table; format = tObj->Palette.Format; } diff --git a/xc/extras/Mesa/src/triangle.c b/xc/extras/Mesa/src/triangle.c index 4c89ae9f5..29f85a4ef 100644 --- a/xc/extras/Mesa/src/triangle.c +++ b/xc/extras/Mesa/src/triangle.c @@ -615,14 +615,16 @@ static void affine_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1, * Render an perspective corrected RGB/RGBA textured triangle. * The Q (aka V in Mesa) coordinate must be zero such that the divide * by interpolated Q/W comes out right. - * - * XXX (May 15, 1999) this function not used for now because repeating - * of negative texture coords not handled correctly!!! */ -#if 000 static void persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv ) { +/* The BIAS value is used to shift negative values into positive values. + * Without this, negative texture values don't GL_REPEAT correctly at just + * below zero. We're not going to worry about texture coords less than -BIAS. + * Only seems to be a problem with GL_NEAREST filtering. + */ +#define BIAS 4096.0F #define INTERP_Z 1 #define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE @@ -686,8 +688,8 @@ static void persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1, #define SPAN1(DO_TEX,COMP) \ for (i=0;i<n;i++) { \ GLfloat invQ = 1.0f / vv; \ - GLint s = (int)(SS * invQ) & smask; \ - GLint t = (int)(TT * invQ) & tmask; \ + GLint s = (int)(SS * invQ + BIAS) & smask; \ + GLint t = (int)(TT * invQ + BIAS) & tmask; \ GLint pos = COMP * ((t << twidth_log2) + s); \ GLubyte *tex00 = texture + pos; \ zspan[i] = FixedToDepth(ffz); \ @@ -842,8 +844,8 @@ static void persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1, #include "tritemp.h" #undef SPAN1 #undef SPAN2 +#undef BIAS } -#endif @@ -1028,7 +1030,7 @@ static void general_textured_spec_triangle1( GLcontext *ctx, GLuint v0, /* * Compute the lambda value for a fragment. (texture level of detail) */ -static GLfloat +static INLINE GLfloat compute_lambda( GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, GLfloat invQ, GLfloat width, GLfloat height ) { @@ -1426,6 +1428,35 @@ static void lambda_multitextured_triangle( GLcontext *ctx, GLuint v0, } + +static void occlusion_zless_triangle( GLcontext *ctx, GLuint v0, GLuint v1, + GLuint v2, GLuint pv ) +{ + (void)pv; + if (ctx->OcclusionResult) { + return; + } + +#define DO_OCCLUSION_TEST +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define INNER_LOOP( LEFT, RIGHT, Y ) \ + { \ + GLint i, len = RIGHT-LEFT; \ + for (i=0;i<len;i++) { \ + GLdepth z = FixedToDepth(ffz); \ + if (z < zRow[i]) { \ + ctx->OcclusionResult = GL_TRUE; \ + return; \ + } \ + ffz += fdzdx; \ + } \ + } +#include "tritemp.h" +} + + + /* * Null rasterizer for measuring transformation speed. */ @@ -1473,6 +1504,23 @@ void gl_set_triangle_function( GLcontext *ctx ) return; } + if (ctx->Depth.OcclusionTest && + ctx->Depth.Mask == GL_FALSE && + ctx->Depth.Func == GL_LESS && + !ctx->Stencil.Enabled) { + if ((ctx->Visual->RGBAflag && + ctx->Color.ColorMask[0] == 0 && + ctx->Color.ColorMask[1] == 0 && + ctx->Color.ColorMask[2] == 0 && + ctx->Color.ColorMask[3] == 0) + || + (!ctx->Visual->RGBAflag && ctx->Color.IndexMask == 0)) { + dputs("occlusion_test_triangle"); + ctx->Driver.TriangleFunc = occlusion_zless_triangle; + return; + } + } + if (ctx->Texture.ReallyEnabled) { /* Ugh, we do a _lot_ of tests to pick the best textured tri func */ GLint format, filter; @@ -1521,8 +1569,7 @@ void gl_set_triangle_function( GLcontext *ctx ) } } else { - /*ctx->Driver.TriangleFunc = persp_textured_triangle;*/ - ctx->Driver.TriangleFunc = general_textured_triangle; + ctx->Driver.TriangleFunc = persp_textured_triangle; dputs("persp_textured_triangle"); } } diff --git a/xc/extras/Mesa/src/tritemp.h b/xc/extras/Mesa/src/tritemp.h index dd87a2994..684f4656b 100644 --- a/xc/extras/Mesa/src/tritemp.h +++ b/xc/extras/Mesa/src/tritemp.h @@ -152,6 +152,10 @@ oneOverArea = 1.0F / area; } +#ifndef DO_OCCLUSION_TEST + ctx->OcclusionResult = GL_TRUE; +#endif + /* Edge setup. For a triangle strip these could be reused... */ { /* fixed point Y coordinates */ @@ -1078,3 +1082,5 @@ #undef T_SCALE #undef FixedToDepth + +#undef DO_OCCLUSION_TEST diff --git a/xc/extras/Mesa/src/types.h b/xc/extras/Mesa/src/types.h index e96740e78..78a40ace1 100644 --- a/xc/extras/Mesa/src/types.h +++ b/xc/extras/Mesa/src/types.h @@ -208,10 +208,17 @@ struct gl_texture_image { /* Data structure for color tables */ struct gl_color_table { - GLubyte Table[4 * MAX_TEXTURE_PALETTE_SIZE]; + GLvoid *Table; + GLenum TableType; /* GL_UNSIGNED_BYTE or GL_FLOAT */ GLuint Size; /* number of entries (rows) in table */ GLenum Format; GLenum IntFormat; + GLint RedSize; + GLint GreenSize; + GLint BlueSize; + GLint AlphaSize; + GLint LuminanceSize; + GLint IntensitySize; }; @@ -400,6 +407,7 @@ struct gl_enable_attrib { GLboolean DepthTest; GLboolean Dither; GLboolean Fog; + GLboolean Histogram; GLboolean Light[MAX_LIGHTS]; GLboolean Lighting; GLboolean LineSmooth; @@ -424,7 +432,9 @@ struct gl_enable_attrib { GLboolean Map2TextureCoord4; GLboolean Map2Vertex3; GLboolean Map2Vertex4; + GLboolean MinMax; GLboolean Normalize; + GLboolean PixelTexture; GLboolean PointSmooth; GLboolean PolygonOffsetPoint; GLboolean PolygonOffsetLine; @@ -490,7 +500,7 @@ struct gl_hint_attrib { /* GL_PGI_misc_hints */ GLenum AllowDrawWin; - GLenum AllowDrawSpn; + GLenum AllowDrawFrg; GLenum AllowDrawMem; GLenum StrictLighting; @@ -499,6 +509,26 @@ struct gl_hint_attrib { }; +struct gl_histogram_attrib { + GLuint Width; + GLint Format; + GLboolean Sink; + GLuint RedSize; + GLuint GreenSize; + GLuint BlueSize; + GLuint AlphaSize; + GLuint LuminanceSize; + GLuint Count[HISTOGRAM_TABLE_SIZE][4]; +}; + + +struct gl_minmax_attrib { + GLenum Format; + GLboolean Sink; + GLfloat Min[4], Max[4]; /* RGBA */ +}; + + struct gl_light_attrib { struct gl_light Light[MAX_LIGHTS]; /* Array of lights */ struct gl_lightmodel Model; /* Lighting model */ @@ -554,8 +584,7 @@ struct gl_pixel_attrib { GLint IndexShift, IndexOffset; GLboolean MapColorFlag; GLboolean MapStencilFlag; - GLfloat ZoomX; /* Pixel zoom X factor */ - GLfloat ZoomY; /* Pixel zoom Y factor */ + GLfloat ZoomX, ZoomY; GLint MapStoSsize; /* Size of each pixel map */ GLint MapItoIsize; GLint MapItoRsize; @@ -580,6 +609,33 @@ struct gl_pixel_attrib { GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE]; GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE]; GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE]; + /* GL_EXT_histogram */ + GLboolean HistogramEnabled; + GLboolean MinMaxEnabled; + /* GL_SGIS_pixel_texture */ + GLboolean PixelTextureEnabled; + GLenum FragmentRgbSource; + GLenum FragmentAlphaSource; + /* GL_SGI_color_matrix */ + GLfloat PostColorMatrixRedScale; + GLfloat PostColorMatrixRedBias; + GLfloat PostColorMatrixGreenScale; + GLfloat PostColorMatrixGreenBias; + GLfloat PostColorMatrixBlueScale; + GLfloat PostColorMatrixBlueBias; + GLfloat PostColorMatrixAlphaScale; + GLfloat PostColorMatrixAlphaBias; + GLboolean ScaleOrBiasRGBApcm; + /* GL_SGI_color_table */ + GLfloat ColorTableScale[4]; + GLfloat ColorTableBias[4]; + GLboolean ColorTableEnabled; + GLfloat PCCTscale[4]; + GLfloat PCCTbias[4]; + GLboolean PostConvolutionColorTableEnabled; + GLfloat PCMCTscale[4]; + GLfloat PCMCTbias[4]; + GLboolean PostColorMatrixColorTableEnabled; }; @@ -1180,6 +1236,7 @@ struct gl_visual { GLboolean RGBAflag; /* Is frame buffer in RGBA mode, not CI? */ GLboolean DBflag; /* Is color buffer double buffered? */ GLboolean StereoFlag; /* stereo buffer? */ + GLboolean SoftwareAlpha; /* Implement software alpha buffer? */ GLint RedBits; /* Bits per color component */ GLint GreenBits; @@ -1188,11 +1245,13 @@ struct gl_visual { GLint IndexBits; /* Bits/pixel if in color index mode */ - GLint AccumBits; /* Number of bits per color channel, or 0 */ + GLint AccumRedBits; /* Number of bits in red accum channel */ + GLint AccumGreenBits; /* Number of bits in green accum channel */ + GLint AccumBlueBits; /* Number of bits in blue accum channel */ + GLint AccumAlphaBits; /* Number of bits in alpha accum channel */ GLint DepthBits; /* Number of bits in depth buffer, or 0 */ GLint StencilBits; /* Number of bits in stencil buffer, or 0 */ - - GLboolean SoftwareAlpha; /* Implement software alpha buffer? */ + GLint NumSamples; /* Samples/pixel for multisampling */ GLuint DepthMax; /* Max depth buffer value */ GLfloat DepthMaxF; /* Float max depth buffer value */ @@ -1253,6 +1312,7 @@ struct gl_constants { GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */ GLfloat LineWidthGranularity; GLuint NumAuxBuffers; + GLuint MaxColorTableSize; }; @@ -1309,6 +1369,7 @@ struct gl_extensions { #define NEW_NORMAL_TRANSFORM 0x8000 #define NEW_VIEWPORT 0x10000 #define NEW_TEXTURE_ENABLE 0x20000 +#define NEW_COLOR_MATRIX 0x40000 #define NEW_ALL ~0 @@ -1345,6 +1406,8 @@ struct gl_extensions { #define DD_STENCIL 0x1000000 #define DD_CLIP_FOG_COORD 0x2000000 + + #define DD_SW_SETUP (DD_TRI_CULL| \ DD_TRI_CULL_FRONT_BACK| \ DD_TRI_OFFSET| \ @@ -1683,6 +1746,11 @@ struct gl_context { GLuint TextureStackDepth[MAX_TEXTURE_UNITS]; GLmatrix TextureStack[MAX_TEXTURE_UNITS][MAX_TEXTURE_STACK_DEPTH - 1]; + /* Color matrix and stack */ + GLmatrix ColorMatrix; + GLuint ColorStackDepth; + GLmatrix ColorStack[MAX_COLOR_STACK_DEPTH - 1]; + /* Display lists */ GLuint CallDepth; /* Current recursion calling depth */ GLboolean ExecuteFlag; /* Execute GL commands? */ @@ -1718,9 +1786,11 @@ struct gl_context { struct gl_eval_attrib Eval; struct gl_fog_attrib Fog; struct gl_hint_attrib Hint; + struct gl_histogram_attrib Histogram; struct gl_light_attrib Light; struct gl_line_attrib Line; struct gl_list_attrib List; + struct gl_minmax_attrib MinMax; struct gl_pixel_attrib Pixel; struct gl_point_attrib Point; struct gl_polygon_attrib Polygon; @@ -1744,6 +1814,13 @@ struct gl_context { struct gl_feedback Feedback; /* Feedback */ struct gl_selection Select; /* Selection */ + struct gl_color_table ColorTable; /* Pre-convolution */ + struct gl_color_table ProxyColorTable; /* Pre-convolution */ + struct gl_color_table PostConvolutionColorTable; + struct gl_color_table ProxyPostConvolutionColorTable; + struct gl_color_table PostColorMatrixColorTable; + struct gl_color_table ProxyPostColorMatrixColorTable; + /* Optimized Accumulation buffer info */ GLboolean IntegerAccumMode; /* Storing unscaled integers? */ GLfloat IntegerAccumScaler; /* Implicit scale factor */ @@ -1798,6 +1875,7 @@ struct gl_context { GLfloat backface_sign; GLboolean OcclusionResult; /* GL_HP_occlusion_test */ + GLboolean OcclusionResultSaved; /* GL_HP_occlusion_test */ /* Destination of immediate mode commands */ struct immediate *input; diff --git a/xc/extras/Mesa/src/varray.c b/xc/extras/Mesa/src/varray.c index 786793da7..dc758594a 100644 --- a/xc/extras/Mesa/src/varray.c +++ b/xc/extras/Mesa/src/varray.c @@ -682,7 +682,6 @@ _mesa_DrawArrays(GLenum mode, GLint start, GLsizei count) VB->Primitive[VB->CopyStart] = mode; ctx->Array.Flag[count] |= VERT_END_VB; - ctx->Array.Flag[count] |= VERT_END_VB; /* Transform and render. */ gl_run_pipeline( VB ); diff --git a/xc/extras/Mesa/src/vbcull.c b/xc/extras/Mesa/src/vbcull.c index bbb0ad662..927e485c6 100644 --- a/xc/extras/Mesa/src/vbcull.c +++ b/xc/extras/Mesa/src/vbcull.c @@ -546,11 +546,6 @@ static GLuint gl_copy_overflow( struct vertex_buffer *VB, return 0; } - - - - - static void gl_fast_copy_noop( struct vertex_buffer *VB, GLuint start, GLuint count, GLuint ovf) @@ -802,7 +797,7 @@ static void build_clip_vert_bits( GLubyte *clipmask, const GLubyte *cullmask, GLuint gl_cull_vb( struct vertex_buffer *VB ) { const GLcontext *ctx = VB->ctx; - GLuint i, next, prim, n; + GLuint i, next, prim = 0xffffffff, n; GLfloat (*proj)[4] = VB->Projected->data; GLuint *in_prim = VB->Primitive; GLuint *out_prim = VB->IM->Primitive; diff --git a/xc/extras/Mesa/src/vbcull.h b/xc/extras/Mesa/src/vbcull.h index 2742634dc..6953092d3 100644 --- a/xc/extras/Mesa/src/vbcull.h +++ b/xc/extras/Mesa/src/vbcull.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,8 +24,6 @@ */ - - #ifndef VCULL_H #define VCULL_H @@ -38,6 +36,7 @@ extern const char *gl_prim_name[GL_POLYGON+2]; extern GLuint gl_cull_vb( struct vertex_buffer *VB ); extern void gl_dont_cull_vb( struct vertex_buffer *VB ); + extern void gl_fast_copy_vb( struct vertex_buffer *VB ); extern void gl_make_normal_cullmask( struct vertex_buffer *VB ); diff --git a/xc/extras/Mesa/src/vbfill.c b/xc/extras/Mesa/src/vbfill.c index 75a576467..4ee9d52a3 100644 --- a/xc/extras/Mesa/src/vbfill.c +++ b/xc/extras/Mesa/src/vbfill.c @@ -57,7 +57,7 @@ void -_mesa_Begin(GLenum mode ) +_mesa_Begin( GLenum mode ) { GET_CURRENT_CONTEXT(ctx); @@ -70,7 +70,8 @@ _mesa_Begin(GLenum mode ) } -void gl_Begin( GLcontext *ctx, GLenum p ) +void +gl_Begin( GLcontext *ctx, GLenum p ) { struct immediate *IM = ctx->input; GLuint inflags, state; @@ -172,7 +173,8 @@ _mesa_End(void) } -void gl_End( GLcontext *ctx ) +void +gl_End( GLcontext *ctx ) { struct immediate *IM = ctx->input; GLuint state = IM->BeginState; @@ -221,7 +223,7 @@ void gl_End( GLcontext *ctx ) * to implement that mechanism to get good performance from * color-material and vertex arrays. */ -#define COLOR( IM, r,g,b,a ) \ +#define COLOR( IM, r, g, b, a ) \ { \ GLuint count = IM->Count; \ IM->Flag[count] |= VERT_RGBA; \ @@ -240,19 +242,16 @@ void gl_End( GLcontext *ctx ) void -_mesa_Color3b(GLbyte red, GLbyte green, GLbyte blue ) +_mesa_Color3b( GLbyte red, GLbyte green, GLbyte blue ) { GET_IMMEDIATE; - COLOR( IM, - BYTE_TO_UBYTE(red), - BYTE_TO_UBYTE(green), - BYTE_TO_UBYTE(blue), - 255 ); + COLOR( IM, BYTE_TO_UBYTE(red), BYTE_TO_UBYTE(green), + BYTE_TO_UBYTE(blue), 255 ); } void -_mesa_Color3d(GLdouble red, GLdouble green, GLdouble blue ) +_mesa_Color3d( GLdouble red, GLdouble green, GLdouble blue ) { GLubyte col[4]; GLfloat r = red; @@ -268,7 +267,7 @@ _mesa_Color3d(GLdouble red, GLdouble green, GLdouble blue ) void -_mesa_Color3f(GLfloat red, GLfloat green, GLfloat blue ) +_mesa_Color3f( GLfloat red, GLfloat green, GLfloat blue ) { GLubyte col[4]; GET_IMMEDIATE; @@ -281,29 +280,25 @@ _mesa_Color3f(GLfloat red, GLfloat green, GLfloat blue ) void -_mesa_Color3i(GLint red, GLint green, GLint blue ) +_mesa_Color3i( GLint red, GLint green, GLint blue ) { GET_IMMEDIATE; - COLOR( IM, INT_TO_UBYTE(red), - INT_TO_UBYTE(green), - INT_TO_UBYTE(blue), - 255); + COLOR( IM, INT_TO_UBYTE(red), INT_TO_UBYTE(green), + INT_TO_UBYTE(blue), 255); } void -_mesa_Color3s(GLshort red, GLshort green, GLshort blue ) +_mesa_Color3s( GLshort red, GLshort green, GLshort blue ) { GET_IMMEDIATE; - COLOR( IM, SHORT_TO_UBYTE(red), - SHORT_TO_UBYTE(green), - SHORT_TO_UBYTE(blue), - 255); + COLOR( IM, SHORT_TO_UBYTE(red), SHORT_TO_UBYTE(green), + SHORT_TO_UBYTE(blue), 255); } void -_mesa_Color3ub(GLubyte red, GLubyte green, GLubyte blue ) +_mesa_Color3ub( GLubyte red, GLubyte green, GLubyte blue ) { GET_IMMEDIATE; COLOR( IM, red, green, blue, 255 ); @@ -311,28 +306,25 @@ _mesa_Color3ub(GLubyte red, GLubyte green, GLubyte blue ) void -_mesa_Color3ui(GLuint red, GLuint green, GLuint blue ) +_mesa_Color3ui( GLuint red, GLuint green, GLuint blue ) { GET_IMMEDIATE; - COLOR( IM, UINT_TO_UBYTE(red), - UINT_TO_UBYTE(green), - UINT_TO_UBYTE(blue), - 255 ); + COLOR( IM, UINT_TO_UBYTE(red), UINT_TO_UBYTE(green), + UINT_TO_UBYTE(blue), 255 ); } void -_mesa_Color3us(GLushort red, GLushort green, GLushort blue ) +_mesa_Color3us( GLushort red, GLushort green, GLushort blue ) { GET_IMMEDIATE; COLOR( IM, USHORT_TO_UBYTE(red), USHORT_TO_UBYTE(green), - USHORT_TO_UBYTE(blue), - 255 ); + USHORT_TO_UBYTE(blue), 255 ); } void -_mesa_Color4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) +_mesa_Color4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) { GET_IMMEDIATE; COLOR( IM, BYTE_TO_UBYTE(red), BYTE_TO_UBYTE(green), @@ -341,7 +333,7 @@ _mesa_Color4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) void -_mesa_Color4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) +_mesa_Color4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) { GLubyte col[4]; GLfloat r = red; @@ -358,7 +350,7 @@ _mesa_Color4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) void -_mesa_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +_mesa_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { GLubyte col[4]; GET_IMMEDIATE; @@ -371,7 +363,7 @@ _mesa_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) void -_mesa_Color4i(GLint red, GLint green, GLint blue, GLint alpha ) +_mesa_Color4i( GLint red, GLint green, GLint blue, GLint alpha ) { GET_IMMEDIATE; COLOR( IM, INT_TO_UBYTE(red), INT_TO_UBYTE(green), @@ -380,7 +372,7 @@ _mesa_Color4i(GLint red, GLint green, GLint blue, GLint alpha ) void -_mesa_Color4s(GLshort red, GLshort green, GLshort blue, GLshort alpha ) +_mesa_Color4s( GLshort red, GLshort green, GLshort blue, GLshort alpha ) { GET_IMMEDIATE; COLOR( IM, SHORT_TO_UBYTE(red), SHORT_TO_UBYTE(green), @@ -388,14 +380,14 @@ _mesa_Color4s(GLshort red, GLshort green, GLshort blue, GLshort alpha ) } void -_mesa_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +_mesa_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { GET_IMMEDIATE; COLOR( IM, red, green, blue, alpha ); } void -_mesa_Color4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha ) +_mesa_Color4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ) { GET_IMMEDIATE; COLOR( IM, UINT_TO_UBYTE(red), UINT_TO_UBYTE(green), @@ -403,7 +395,7 @@ _mesa_Color4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha ) } void -_mesa_Color4us(GLushort red, GLushort green, GLushort blue, GLushort alpha ) +_mesa_Color4us( GLushort red, GLushort green, GLushort blue, GLushort alpha ) { GET_IMMEDIATE; COLOR( IM, USHORT_TO_UBYTE(red), USHORT_TO_UBYTE(green), @@ -412,7 +404,7 @@ _mesa_Color4us(GLushort red, GLushort green, GLushort blue, GLushort alpha ) void -_mesa_Color3bv(const GLbyte *v ) +_mesa_Color3bv( const GLbyte *v ) { GET_IMMEDIATE; COLOR( IM, BYTE_TO_UBYTE(v[0]), BYTE_TO_UBYTE(v[1]), @@ -421,7 +413,7 @@ _mesa_Color3bv(const GLbyte *v ) void -_mesa_Color3dv(const GLdouble *v ) +_mesa_Color3dv( const GLdouble *v ) { GLubyte col[4]; GLfloat r = v[0]; @@ -437,7 +429,7 @@ _mesa_Color3dv(const GLdouble *v ) void -_mesa_Color3fv(const GLfloat *v ) +_mesa_Color3fv( const GLfloat *v ) { GLubyte col[4]; GET_IMMEDIATE; @@ -450,7 +442,7 @@ _mesa_Color3fv(const GLfloat *v ) void -_mesa_Color3iv(const GLint *v ) +_mesa_Color3iv( const GLint *v ) { GET_IMMEDIATE; COLOR( IM, INT_TO_UBYTE(v[0]), INT_TO_UBYTE(v[1]), @@ -459,7 +451,7 @@ _mesa_Color3iv(const GLint *v ) void -_mesa_Color3sv(const GLshort *v ) +_mesa_Color3sv( const GLshort *v ) { GET_IMMEDIATE; COLOR( IM, SHORT_TO_UBYTE(v[0]), SHORT_TO_UBYTE(v[1]), @@ -468,7 +460,7 @@ _mesa_Color3sv(const GLshort *v ) void -_mesa_Color3ubv(const GLubyte *v ) +_mesa_Color3ubv( const GLubyte *v ) { GET_IMMEDIATE; COLOR( IM, v[0], v[1], v[2], 255 ); @@ -476,7 +468,7 @@ _mesa_Color3ubv(const GLubyte *v ) void -_mesa_Color3uiv(const GLuint *v ) +_mesa_Color3uiv( const GLuint *v ) { GET_IMMEDIATE; COLOR( IM, UINT_TO_UBYTE(v[0]), UINT_TO_UBYTE(v[1]), @@ -485,7 +477,7 @@ _mesa_Color3uiv(const GLuint *v ) void -_mesa_Color3usv(const GLushort *v ) +_mesa_Color3usv( const GLushort *v ) { GET_IMMEDIATE; COLOR( IM, USHORT_TO_UBYTE(v[0]), USHORT_TO_UBYTE(v[1]), @@ -495,7 +487,7 @@ _mesa_Color3usv(const GLushort *v ) void -_mesa_Color4bv(const GLbyte *v ) +_mesa_Color4bv( const GLbyte *v ) { GET_IMMEDIATE; COLOR( IM, BYTE_TO_UBYTE(v[0]), BYTE_TO_UBYTE(v[1]), @@ -504,7 +496,7 @@ _mesa_Color4bv(const GLbyte *v ) void -_mesa_Color4dv(const GLdouble *v ) +_mesa_Color4dv( const GLdouble *v ) { GLubyte col[4]; GLfloat r = v[0]; @@ -521,7 +513,7 @@ _mesa_Color4dv(const GLdouble *v ) void -_mesa_Color4fv(const GLfloat *v ) +_mesa_Color4fv( const GLfloat *v ) { GLubyte col[4]; GET_IMMEDIATE; @@ -534,7 +526,7 @@ _mesa_Color4fv(const GLfloat *v ) void -_mesa_Color4iv(const GLint *v ) +_mesa_Color4iv( const GLint *v ) { GET_IMMEDIATE; COLOR( IM, INT_TO_UBYTE(v[0]), INT_TO_UBYTE(v[1]), @@ -543,7 +535,7 @@ _mesa_Color4iv(const GLint *v ) void -_mesa_Color4sv(const GLshort *v) +_mesa_Color4sv( const GLshort *v) { GET_IMMEDIATE; COLOR( IM, SHORT_TO_UBYTE(v[0]), SHORT_TO_UBYTE(v[1]), @@ -552,7 +544,7 @@ _mesa_Color4sv(const GLshort *v) void -_mesa_Color4ubv(const GLubyte *v) +_mesa_Color4ubv( const GLubyte *v) { GET_IMMEDIATE; COLORV( IM, v ); @@ -560,7 +552,7 @@ _mesa_Color4ubv(const GLubyte *v) void -_mesa_Color4uiv(const GLuint *v) +_mesa_Color4uiv( const GLuint *v) { GET_IMMEDIATE; COLOR( IM, UINT_TO_UBYTE(v[0]), UINT_TO_UBYTE(v[1]), @@ -569,7 +561,7 @@ _mesa_Color4uiv(const GLuint *v) void -_mesa_Color4usv(const GLushort *v) +_mesa_Color4usv( const GLushort *v) { GET_IMMEDIATE; COLOR( IM, USHORT_TO_UBYTE(v[0]), USHORT_TO_UBYTE(v[1]), @@ -615,7 +607,7 @@ _mesa_EdgeFlagv( const GLboolean *flag ) void _mesa_Indexd( GLdouble c ) { - INDEX( (GLuint) (GLint) c ); + INDEX( ( GLuint) (GLint) c ); } @@ -690,7 +682,7 @@ _mesa_Indexubv( const GLubyte *c ) * call. The Flag member allows the identification of missing * (ie shared) normals. */ -#define NORMAL( x,y,z ) \ +#define NORMAL( x, y, z ) \ { \ GLuint count; \ GLfloat *normal; \ @@ -1099,7 +1091,8 @@ _mesa_Vertex2f( GLfloat x, GLfloat y ) /* Internal use: */ -void gl_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) +void +gl_Vertex2f( GLcontext *ctx, GLfloat x, GLfloat y ) { struct immediate *im = ctx->input; VERTEX2( im, x, y ); diff --git a/xc/extras/Mesa/src/vbfill.h b/xc/extras/Mesa/src/vbfill.h index 3b7cf94ae..969e6724a 100644 --- a/xc/extras/Mesa/src/vbfill.h +++ b/xc/extras/Mesa/src/vbfill.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), diff --git a/xc/extras/Mesa/src/zoom.c b/xc/extras/Mesa/src/zoom.c index 54a751515..86a87eff8 100644 --- a/xc/extras/Mesa/src/zoom.c +++ b/xc/extras/Mesa/src/zoom.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -402,6 +402,6 @@ gl_write_zoomed_stencil_span( GLcontext *ctx, /* write the span */ for (r=r0; r<r1; r++) { - gl_write_stencil_span( ctx, m, x+skipcol, r, zstencil ); + _mesa_write_stencil_span( ctx, m, x+skipcol, r, zstencil ); } } diff --git a/xc/extras/Mesa/src/zoom.h b/xc/extras/Mesa/src/zoom.h index eb98164c5..83cb5e78e 100644 --- a/xc/extras/Mesa/src/zoom.h +++ b/xc/extras/Mesa/src/zoom.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), |