summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorbrianp <brianp>2000-03-23 19:09:33 +0000
committerbrianp <brianp>2000-03-23 19:09:33 +0000
commit5d5675f9be9673ef87677d76dda4177a3409b9fb (patch)
tree1557d13612f15bae26f283698fbf2e2806f0f7df /xc
parentbc33e81510fdc10118c1224db95a980a30b7b057 (diff)
Mesa 3.3 update
Variable size depth buffers New device driver texture image interface GL_EXT_texture_lod_bias extension
Diffstat (limited to 'xc')
-rw-r--r--xc/extras/Mesa/src/FX/fxapi.c32
-rw-r--r--xc/extras/Mesa/src/FX/fxdd.c6
-rw-r--r--xc/extras/Mesa/src/FX/fxddspan.c65
-rw-r--r--xc/extras/Mesa/src/FX/fxddtex.c29
-rw-r--r--xc/extras/Mesa/src/FX/fxdrv.h6
-rw-r--r--xc/extras/Mesa/src/FX/fxglidew.c14
-rw-r--r--xc/extras/Mesa/src/FX/fxpipeline.c3
-rw-r--r--xc/extras/Mesa/src/FX/fxsetup.c18
-rw-r--r--xc/extras/Mesa/src/FX/fxtrifuncs.c1
-rw-r--r--xc/extras/Mesa/src/X/xmesa1.c4
-rw-r--r--xc/extras/Mesa/src/X/xmesa3.c10
-rw-r--r--xc/extras/Mesa/src/X/xmesa4.c30
-rw-r--r--xc/extras/Mesa/src/accum.c2
-rw-r--r--xc/extras/Mesa/src/all.h1
-rw-r--r--xc/extras/Mesa/src/attrib.c43
-rw-r--r--xc/extras/Mesa/src/bitmap.c10
-rw-r--r--xc/extras/Mesa/src/clip.c81
-rw-r--r--xc/extras/Mesa/src/clip_funcs.h88
-rw-r--r--xc/extras/Mesa/src/colortab.c19
-rw-r--r--xc/extras/Mesa/src/config.h26
-rw-r--r--xc/extras/Mesa/src/context.c82
-rw-r--r--xc/extras/Mesa/src/context.h2
-rw-r--r--xc/extras/Mesa/src/copypix.c14
-rw-r--r--xc/extras/Mesa/src/dd.h346
-rw-r--r--xc/extras/Mesa/src/ddsample.c37
-rw-r--r--xc/extras/Mesa/src/depth.c726
-rw-r--r--xc/extras/Mesa/src/depth.h10
-rw-r--r--xc/extras/Mesa/src/dlist.c24
-rw-r--r--xc/extras/Mesa/src/drawpix.c56
-rw-r--r--xc/extras/Mesa/src/enable.c25
-rw-r--r--xc/extras/Mesa/src/enums.c3
-rw-r--r--xc/extras/Mesa/src/extensions.c39
-rw-r--r--xc/extras/Mesa/src/extensions.h14
-rw-r--r--xc/extras/Mesa/src/feedback.c23
-rw-r--r--xc/extras/Mesa/src/fixed.h16
-rw-r--r--xc/extras/Mesa/src/fog.c84
-rw-r--r--xc/extras/Mesa/src/fog_tmp.h173
-rw-r--r--xc/extras/Mesa/src/get.c80
-rw-r--r--xc/extras/Mesa/src/glapi.c696
-rw-r--r--xc/extras/Mesa/src/glapinoop.c2
-rw-r--r--xc/extras/Mesa/src/hash.c14
-rw-r--r--xc/extras/Mesa/src/hint.c151
-rw-r--r--xc/extras/Mesa/src/image.c300
-rw-r--r--xc/extras/Mesa/src/image.h66
-rw-r--r--xc/extras/Mesa/src/interp_tmp.h77
-rw-r--r--xc/extras/Mesa/src/lines.c11
-rw-r--r--xc/extras/Mesa/src/linetemp.h75
-rw-r--r--xc/extras/Mesa/src/lnaatemp.h158
-rw-r--r--xc/extras/Mesa/src/logic.c3
-rw-r--r--xc/extras/Mesa/src/matrix.c8
-rw-r--r--xc/extras/Mesa/src/mmath.h7
-rw-r--r--xc/extras/Mesa/src/pb.h14
-rw-r--r--xc/extras/Mesa/src/points.c24
-rw-r--r--xc/extras/Mesa/src/polygon.c21
-rw-r--r--xc/extras/Mesa/src/rastpos.c4
-rw-r--r--xc/extras/Mesa/src/readpix.c88
-rw-r--r--xc/extras/Mesa/src/render_tmp.h39
-rw-r--r--xc/extras/Mesa/src/shade_tmp.h3
-rw-r--r--xc/extras/Mesa/src/span.c21
-rw-r--r--xc/extras/Mesa/src/stages.c28
-rw-r--r--xc/extras/Mesa/src/state.c12
-rw-r--r--xc/extras/Mesa/src/teximage.c1074
-rw-r--r--xc/extras/Mesa/src/teximage.h4
-rw-r--r--xc/extras/Mesa/src/texobj.c10
-rw-r--r--xc/extras/Mesa/src/texstate.c87
-rw-r--r--xc/extras/Mesa/src/texture.c9
-rw-r--r--xc/extras/Mesa/src/triangle.c37
-rw-r--r--xc/extras/Mesa/src/tritemp.h83
-rw-r--r--xc/extras/Mesa/src/types.h37
-rw-r--r--xc/extras/Mesa/src/varray.c3
-rw-r--r--xc/extras/Mesa/src/vbfill.c48
-rw-r--r--xc/extras/Mesa/src/vbrender.c123
-rw-r--r--xc/extras/Mesa/src/vbxform.c25
73 files changed, 3773 insertions, 1831 deletions
diff --git a/xc/extras/Mesa/src/FX/fxapi.c b/xc/extras/Mesa/src/FX/fxapi.c
index 0b96cf439..6aea93fbf 100644
--- a/xc/extras/Mesa/src/FX/fxapi.c
+++ b/xc/extras/Mesa/src/FX/fxapi.c
@@ -694,22 +694,11 @@ void GLAPIENTRY fxMesaSetNearFar(GLfloat n, GLfloat f)
/*
- * The extension GL_FXMESA_global_texture_lod_bias
- */
-void GLAPIENTRY glGlobalTextureLODBiasFXMESA(GLfloat biasVal)
-{
- grTexLodBiasValue(GR_TMU0,biasVal);
-
- if(fxMesaCurrentCtx->haveTwoTMUs)
- grTexLodBiasValue(GR_TMU1,biasVal);
-}
-
-
-/*
* The 3Dfx Global Palette extension for GLQuake.
* More a trick than a real extesion, use the shared global
* palette extension.
*/
+extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */
void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal)
{
fxMesaContext fxMesa =fxMesaCurrentCtx;
@@ -890,8 +879,10 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
case FXMESA_DEPTH_SIZE:
i++;
depthSize=attribList[i];
- if(depthSize)
+ if(depthSize) {
aux=1;
+ depthSize = 16;
+ }
break;
case FXMESA_STENCIL_SIZE:
i++;
@@ -982,11 +973,20 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win,
* as Voodoo3s have 2 TMUs on board, Banshee has only 1
* Thanks to Joseph Kain for that one
*/
- if (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx == 2) {
- fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order (Voodoo3) */
+ GrVoodooConfig_t *voodoo;
+ voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig;
+
+ 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);
}
else {
- fxInitPixelTables(fxMesa, GL_TRUE); /* use BGR pixel order on Voodoo1/2 */
+ /* BGR pixel order on Voodoo1/2, or certain Quantum3D models */
+ fxInitPixelTables(fxMesa, GL_TRUE);
}
}
else {
diff --git a/xc/extras/Mesa/src/FX/fxdd.c b/xc/extras/Mesa/src/FX/fxdd.c
index b44ec4dbe..cb8ae0933 100644
--- a/xc/extras/Mesa/src/FX/fxdd.c
+++ b/xc/extras/Mesa/src/FX/fxdd.c
@@ -463,7 +463,7 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py,
+ (winX + px);
for (row = 0; row < height; row++) {
- const GLubyte *src = (const GLubyte *) gl_pixel_addr_in_image( finalUnpack,
+ const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack,
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
if (finalUnpack->LsbFirst) {
/* least significan bit first */
@@ -568,7 +568,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name)
}
}
/* now make the GL_RENDERER string */
- sprintf(buffer, "Mesa DRI %s 20000224", hardware);
+ sprintf(buffer, "Mesa DRI %s 20000322", hardware);
return buffer;
}
case GL_VENDOR:
@@ -771,7 +771,6 @@ void fxDDInitExtensions( GLcontext *ctx )
gl_extensions_disable(ctx, "GL_EXT_paletted_texture");
gl_extensions_add(ctx, DEFAULT_ON, "3DFX_set_global_palette", 0);
- gl_extensions_add(ctx, DEFAULT_ON, "GL_FXMESA_global_texture_lod_bias", 0);
if (!fxMesa->haveTwoTMUs)
gl_extensions_disable(ctx, "GL_EXT_texture_env_add");
@@ -991,7 +990,6 @@ void fxSetupDDPointers(GLcontext *ctx)
ctx->Driver.BindTexture=fxDDTexBind;
ctx->Driver.DeleteTexture=fxDDTexDel;
ctx->Driver.UpdateTexturePalette=fxDDTexPalette;
- ctx->Driver.UseGlobalTexturePalette=fxDDTexUseGlbPalette;
ctx->Driver.RectFunc=NULL;
diff --git a/xc/extras/Mesa/src/FX/fxddspan.c b/xc/extras/Mesa/src/FX/fxddspan.c
index ec5513480..89abdda95 100644
--- a/xc/extras/Mesa/src/FX/fxddspan.c
+++ b/xc/extras/Mesa/src/FX/fxddspan.c
@@ -396,7 +396,7 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx,
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
GLuint i;
- GLint bottom=fxMesa->y_delta-1;
+ GLint bottom=fxMesa->height+fxMesa->y_offset-1;
if (MESA_VERBOSE&VERBOSE_DRIVER) {
fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n");
@@ -423,11 +423,11 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
GLuint n, GLint x, GLint y, const GLdepth depth[],
const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n");
}
x += fxMesa->x_offset;
@@ -436,14 +436,20 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
GLint i;
for (i = 0; i < n; i++) {
if (mask[i]) {
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom-y,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]);
+ GLshort d = depth[i];
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
}
}
}
else {
- writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom-y,
- GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth);
+ GLushort depth16[MAX_WIDTH];
+ GLint i;
+ for (i = 0; i < n; i++) {
+ depth16[i] = depth[i];
+ }
+ writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y,
+ GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16);
}
}
@@ -451,15 +457,20 @@ void fxDDWriteDepthSpan(GLcontext *ctx,
void fxDDReadDepthSpan(GLcontext *ctx,
GLuint n, GLint x, GLint y, GLdepth depth[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLushort depth16[MAX_WIDTH];
+ GLuint i;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n");
}
- x+=fxMesa->x_offset;
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth);
+ x += fxMesa->x_offset;
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
+ for (i = 0; i < n; i++) {
+ depth[i] = depth16[i];
+ }
}
@@ -468,20 +479,21 @@ void fxDDWriteDepthPixels(GLcontext *ctx,
GLuint n, const GLint x[], const GLint y[],
const GLdepth depth[], const GLubyte mask[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n");
}
for (i = 0; i < n; i++) {
if (mask[i]) {
int xpos = x[i] + fxMesa->x_offset;
int ypos = bottom - y[i];
+ GLushort d = depth[i];
writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos,
- GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]);
+ GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d);
}
}
}
@@ -490,19 +502,20 @@ void fxDDWriteDepthPixels(GLcontext *ctx,
void fxDDReadDepthPixels(GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[], GLdepth depth[])
{
- fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
- GLint bottom=fxMesa->height+fxMesa->y_offset-1;
+ fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
GLuint i;
- if (MESA_VERBOSE&VERBOSE_DRIVER) {
- fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n");
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n");
}
-
for (i = 0; i < n; i++) {
int xpos = x[i] + fxMesa->x_offset;
int ypos = bottom - y[i];
- FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,xpos,ypos,1,1,0,&depth[i]);
+ GLushort d;
+ FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d);
+ depth[i] = d;
}
}
diff --git a/xc/extras/Mesa/src/FX/fxddtex.c b/xc/extras/Mesa/src/FX/fxddtex.c
index 71d1e97ad..f1ba481e6 100644
--- a/xc/extras/Mesa/src/FX/fxddtex.c
+++ b/xc/extras/Mesa/src/FX/fxddtex.c
@@ -63,17 +63,18 @@ void fxPrintTextureData(tfxTexInfo *ti)
} else
fprintf(stderr, "\tName: UNNAMED\n");
fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
- fprintf(stderr, "\tTMU: %d\n", ti->whichTMU);
+ fprintf(stderr, "\tTMU: %ld\n", ti->whichTMU);
fprintf(stderr, "\t%s\n", (ti->isInTM)?"In TMU":"Not in TMU");
if (ti->tm[0])
- fprintf(stderr, "\tMem0: %x-%x\n", ti->tm[0]->startAddr,
- ti->tm[0]->endAddr);
+ fprintf(stderr, "\tMem0: %x-%x\n", (unsigned) ti->tm[0]->startAddr,
+ (unsigned) ti->tm[0]->endAddr);
if (ti->tm[1])
- fprintf(stderr, "\tMem1: %x-%x\n", ti->tm[1]->startAddr,
- ti->tm[1]->endAddr);
+ fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr,
+ (unsigned) ti->tm[1]->endAddr);
fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel);
- fprintf(stderr, "\tFilters: min %d min %d\n", ti->minFilt, ti->maxFilt);
- fprintf(stderr, "\tClamps: s %d t %d\n", ti->sClamp, ti->tClamp);
+ fprintf(stderr, "\tFilters: min %d min %d\n",
+ (int) ti->minFilt, (int) ti->maxFilt);
+ fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp, (int) ti->tClamp);
fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale);
fprintf(stderr, "\tInt Scales: s %d t %d\n",
ti->int_sScale/0x800000, ti->int_tScale/0x800000);
@@ -86,7 +87,7 @@ void fxPrintTextureData(tfxTexInfo *ti)
/*************************** Texture Mapping ****************************/
/************************************************************************/
-void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
+static void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
tfxTexInfo *ti;
@@ -160,7 +161,7 @@ void fxDDTexBind(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj)
ctx->Driver.RenderStart = fxSetupFXUnits;
}
-void fxDDTexEnv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+void fxDDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param)
{
fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
@@ -171,6 +172,16 @@ void fxDDTexEnv(GLcontext *ctx, GLenum pname, const GLfloat *param)
fprintf(stderr,"fxmesa: texenv(%x)\n",pname);
}
+ /* apply any lod biasing right now */
+ if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
+ grTexLodBiasValue(GR_TMU0,*param);
+
+ if(fxMesa->haveTwoTMUs) {
+ grTexLodBiasValue(GR_TMU1,*param);
+ }
+
+ }
+
fxMesa->new_state|=FX_NEW_TEXTURING;
ctx->Driver.RenderStart = fxSetupFXUnits;
}
diff --git a/xc/extras/Mesa/src/FX/fxdrv.h b/xc/extras/Mesa/src/FX/fxdrv.h
index e12a3244f..fb009535a 100644
--- a/xc/extras/Mesa/src/FX/fxdrv.h
+++ b/xc/extras/Mesa/src/FX/fxdrv.h
@@ -87,8 +87,8 @@ typedef struct tfxMesaContext *fxMesaContext;
-#if defined(MESA_DEBUG) && 0
extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * );
+#if defined(MESA_DEBUG) && 0
#define grDrawTriangle fx_sanity_triangle
#endif
@@ -534,6 +534,7 @@ typedef void (*tfxSetupFunc)(struct vertex_buffer *, GLuint, GLuint);
extern GrHwConfiguration glbHWConfig;
extern int glbCurrentBoard;
+extern void fxPrintSetupFlags( const char *msg, GLuint flags );
extern void fxSetupFXUnits(GLcontext *);
extern void fxSetupDDPointers(GLcontext *);
extern void fxDDSetNearFar(GLcontext *, GLfloat, GLfloat);
@@ -567,7 +568,7 @@ extern void fxUpdateDDSpanPointers(GLcontext *);
extern void fxSetupDDSpanPointers(GLcontext *);
extern void fxPrintTextureData(tfxTexInfo *ti);
-extern void fxDDTexEnv(GLcontext *, GLenum, const GLfloat *);
+extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
extern void fxDDTexImg(GLcontext *, GLenum, struct gl_texture_object *,
GLint, GLint, const struct gl_texture_image *);
extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
@@ -619,6 +620,7 @@ extern void fxDDInitExtensions( GLcontext *ctx );
#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
extern void fxTMInit(fxMesaContext ctx);
extern void fxTMClose(fxMesaContext ctx);
+extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
#define fxTMMoveOutTM_NoLock fxTMMoveOutTM
diff --git a/xc/extras/Mesa/src/FX/fxglidew.c b/xc/extras/Mesa/src/FX/fxglidew.c
index 790e5c923..5d24e14ea 100644
--- a/xc/extras/Mesa/src/FX/fxglidew.c
+++ b/xc/extras/Mesa/src/FX/fxglidew.c
@@ -225,12 +225,12 @@ void FX_grGlideGetVersion(char *buf)
void FX_grSstPerfStats(GrSstPerfStats_t *st)
{
- /* ToDo */
- st->pixelsIn = 0;
- st->chromaFail = 0;
- st->zFuncFail = 0;
- st->aFuncFail = 0;
- st->pixelsOut = 0;
+ int 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;
+ grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n); st->aFuncFail = n;
+ grGet(GR_STATS_PIXELS_OUT, 4, &n); st->pixelsOut = n;
}
void FX_grAADrawLine(GrVertex *a,GrVertex *b)
@@ -403,6 +403,7 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
nColBuffers,
nAuxBuffers );
+ /*
fprintf(stderr,
"grSstWinOpen( win %d res %d ref %d fmt %d\n"
" org %d ncol %d naux %d )\n"
@@ -415,6 +416,7 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd,
nColBuffers,
nAuxBuffers,
i);
+ */
END_BOARD_LOCK();
return i;
}
diff --git a/xc/extras/Mesa/src/FX/fxpipeline.c b/xc/extras/Mesa/src/FX/fxpipeline.c
index fe4b76c68..c77e21ffa 100644
--- a/xc/extras/Mesa/src/FX/fxpipeline.c
+++ b/xc/extras/Mesa/src/FX/fxpipeline.c
@@ -281,12 +281,13 @@ void fxDDOptimizePrecalcPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
+/* unused?
void fxDDOptimizeEltPipeline( GLcontext *ctx, struct gl_pipeline *pipe )
{
(void) ctx;
(void) pipe;
}
-
+*/
#else
diff --git a/xc/extras/Mesa/src/FX/fxsetup.c b/xc/extras/Mesa/src/FX/fxsetup.c
index 8707aed1d..7d4340d4f 100644
--- a/xc/extras/Mesa/src/FX/fxsetup.c
+++ b/xc/extras/Mesa/src/FX/fxsetup.c
@@ -69,7 +69,7 @@ static void fxSetupDepthTest(GLcontext *ctx);
static void fxSetupScissor(GLcontext *ctx);
static void fxSetupCull(GLcontext *ctx);
static void gl_print_fx_state_flags( const char *msg, GLuint flags);
-static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);
+/*static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint);*/
static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint );
static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj)
@@ -1615,6 +1615,9 @@ void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
fxMesa->new_state |= FX_NEW_SCISSOR;
ctx->Driver.RenderStart = fxSetupFXUnits;
break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ fxDDTexUseGlbPalette(ctx, state);
+ break;
case GL_FOG:
fxMesa->new_state |= FX_NEW_FOG;
ctx->Driver.RenderStart = fxSetupFXUnits;
@@ -1624,6 +1627,7 @@ void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
ctx->Driver.RenderStart = fxSetupFXUnits;
break;
case GL_LINE_SMOOTH:
+ case GL_LINE_STIPPLE:
case GL_POINT_SMOOTH:
case GL_POLYGON_SMOOTH:
case GL_TEXTURE_2D:
@@ -1631,7 +1635,7 @@ void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
ctx->Driver.RenderStart = fxSetupFXUnits;
break;
default:
- ; /* XXX no-op??? */
+ ; /* XXX no-op? */
}
}
@@ -1664,10 +1668,10 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
fxDDDepthMask(ctx, FALSE);
}
/* Enable Cc*Ct mode */
- /* ??? Set the Constant Color ??? */
+ /* XXX Set the Constant Color ? */
fxDDEnable(ctx, GL_BLEND, GL_TRUE);
- fxDDBlendFunc(ctx, ???, ???);
- fxSetupTextureSingleTMU(ctx, ???);
+ fxDDBlendFunc(ctx, XXX, XXX);
+ fxSetupTextureSingleTMU(ctx, XXX);
fxSetupBlend(ctx);
fxSetupDepthTest(ctx);
break;
@@ -1675,8 +1679,8 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
case 2:
/* Reset everything back to normal */
fxMesa->unitsState = fxMesa->restoreUnitsState;
- fxMesa->setupdone &= ???;
- fxSetupTextureSingleTMU(ctx, ???);
+ fxMesa->setupdone &= XXX;
+ fxSetupTextureSingleTMU(ctx, XXX);
fxSetupBlend(ctx);
fxSetupDepthTest(ctx);
break;
diff --git a/xc/extras/Mesa/src/FX/fxtrifuncs.c b/xc/extras/Mesa/src/FX/fxtrifuncs.c
index 76cede5a7..4b349b31b 100644
--- a/xc/extras/Mesa/src/FX/fxtrifuncs.c
+++ b/xc/extras/Mesa/src/FX/fxtrifuncs.c
@@ -363,6 +363,7 @@ void fxDDChooseRenderState( GLcontext *ctx )
* Need this to provide at least one external definition.
*/
+extern int gl_fx_dummy_function_tris(void);
int gl_fx_dummy_function_tris(void)
{
return 0;
diff --git a/xc/extras/Mesa/src/X/xmesa1.c b/xc/extras/Mesa/src/X/xmesa1.c
index 56e6fcad7..4eb5cc82b 100644
--- a/xc/extras/Mesa/src/X/xmesa1.c
+++ b/xc/extras/Mesa/src/X/xmesa1.c
@@ -2435,7 +2435,7 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b,
GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
GLint *bytesPerValue, void **buffer )
{
- if ((!b->gl_buffer) || (!b->gl_buffer->Depth)) {
+ if ((!b->gl_buffer) || (!b->gl_buffer->DepthBuffer)) {
*width = 0;
*height = 0;
*bytesPerValue = 0;
@@ -2446,7 +2446,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
*width = b->gl_buffer->Width;
*height = b->gl_buffer->Height;
*bytesPerValue = sizeof(GLdepth);
- *buffer = b->gl_buffer->Depth;
+ *buffer = b->gl_buffer->DepthBuffer;
return GL_TRUE;
}
}
diff --git a/xc/extras/Mesa/src/X/xmesa3.c b/xc/extras/Mesa/src/X/xmesa3.c
index ba98c5e1d..7fb3c5ebd 100644
--- a/xc/extras/Mesa/src/X/xmesa3.c
+++ b/xc/extras/Mesa/src/X/xmesa3.c
@@ -353,6 +353,7 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define CLIP_HACK 1
#define PLOT(X,Y) \
if (Z < *zPtr) { \
@@ -375,6 +376,7 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx,
GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
@@ -400,6 +402,7 @@ static void flat_8R8G8B_z_line( GLcontext *ctx,
GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
@@ -424,6 +427,7 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx,
const GLubyte *color = ctx->VB->ColorPtr->data[pv];
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
@@ -451,6 +455,7 @@ static void flat_5R6G5B_z_line( GLcontext *ctx,
GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
@@ -474,6 +479,7 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx,
const GLubyte *color = ctx->VB->ColorPtr->data[pv];
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
@@ -500,6 +506,7 @@ static void flat_DITHER8_z_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
@@ -526,6 +533,7 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx,
pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
@@ -552,6 +560,7 @@ static void flat_HPCR_z_line( GLcontext *ctx,
#define INTERP_XY 1
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
@@ -670,6 +679,7 @@ line_func xmesa_get_line_func( GLcontext *ctx )
&& ctx->RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Line.Width==1.0F) {
switch (xmesa->pixelformat) {
case PF_TRUECOLOR:
diff --git a/xc/extras/Mesa/src/X/xmesa4.c b/xc/extras/Mesa/src/X/xmesa4.c
index 844447595..a0ffafae0 100644
--- a/xc/extras/Mesa/src/X/xmesa4.c
+++ b/xc/extras/Mesa/src/X/xmesa4.c
@@ -97,6 +97,7 @@ static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx,
XMesaImage *img = xmesa->xm_buffer->backimage;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -129,6 +130,7 @@ static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLuint
@@ -161,6 +163,7 @@ static void smooth_8R8G8B_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLuint
@@ -193,6 +196,7 @@ static void smooth_8R8G8B24_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE bgr_t
@@ -228,6 +232,7 @@ static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx,
XMesaImage *img = xmesa->xm_buffer->backimage;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
@@ -259,6 +264,7 @@ static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLushort
@@ -267,7 +273,7 @@ static void smooth_5R6G5B_z_triangle( GLcontext *ctx,
{ \
GLint i, len = RIGHT-LEFT; \
for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
+ DEPTH_TYPE z = FixedToDepth(ffz); \
if (z < zRow[i]) { \
pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \
FixedToInt(ffb) ); \
@@ -291,6 +297,7 @@ static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLushort
@@ -323,6 +330,7 @@ static void smooth_DITHER8_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
@@ -357,6 +365,7 @@ static void smooth_DITHER_z_triangle( GLcontext *ctx,
XMesaImage *img = xmesa->xm_buffer->backimage;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
@@ -390,6 +399,7 @@ static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
@@ -423,6 +433,7 @@ static void smooth_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
@@ -455,6 +466,7 @@ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
unsigned long pixel; \
PACK_TRUECOLOR(pixel, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2]);
@@ -483,6 +495,7 @@ static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, GLuint v0,
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -513,6 +526,7 @@ static void flat_8R8G8B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLuint
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -544,6 +558,7 @@ static void flat_8R8G8B24_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
const GLubyte *color = ctx->VB->ColorPtr->data[pv];
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE bgr_t
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -575,6 +590,7 @@ static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INNER_LOOP( LEFT, RIGHT, Y ) \
{ \
GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \
@@ -602,6 +618,7 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -612,7 +629,7 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{ \
GLint i, len = RIGHT-LEFT; \
for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
+ DEPTH_TYPE z = FixedToDepth(ffz); \
if (z < zRow[i]) { \
pRow[i] = (PIXEL_TYPE) p; \
zRow[i] = z; \
@@ -633,6 +650,7 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
const GLubyte *color = ctx->VB->ColorPtr->data[pv];
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLushort
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -640,7 +658,7 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0,
{ \
GLint i, len = RIGHT-LEFT; \
for (i=0;i<len;i++) { \
- GLdepth z = FixedToDepth(ffz); \
+ DEPTH_TYPE z = FixedToDepth(ffz); \
if (z < zRow[i]) { \
PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \
color[GCOMP], color[BCOMP]); \
@@ -661,6 +679,7 @@ static void flat_DITHER8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -693,6 +712,7 @@ static void flat_DITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
XMesaImage *img = xmesa->xm_buffer->backimage;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
FLAT_DITHER_SETUP( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] );
@@ -722,6 +742,7 @@ static void flat_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -753,6 +774,7 @@ static void flat_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y)
#define PIXEL_TYPE GLubyte
#define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line)
@@ -1432,6 +1454,7 @@ triangle_func xmesa_get_triangle_func( GLcontext *ctx )
&& ctx->RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Polygon.StippleFlag==GL_FALSE) {
switch (xmesa->pixelformat) {
case PF_TRUECOLOR:
@@ -1463,6 +1486,7 @@ triangle_func xmesa_get_triangle_func( GLcontext *ctx )
&& ctx->RasterMask==DEPTH_BIT
&& ctx->Depth.Func==GL_LESS
&& ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS
&& ctx->Polygon.StippleFlag==GL_FALSE) {
switch (xmesa->pixelformat) {
case PF_TRUECOLOR:
diff --git a/xc/extras/Mesa/src/accum.c b/xc/extras/Mesa/src/accum.c
index 2f1996eb8..e4e7cfec8 100644
--- a/xc/extras/Mesa/src/accum.c
+++ b/xc/extras/Mesa/src/accum.c
@@ -350,7 +350,7 @@ _mesa_Accum( GLenum op, GLfloat value )
static GLchan multTable[32768];
static GLfloat prevMult = 0.0;
GLuint j;
- const GLint max = 256 / mult;
+ const GLint max = (GLint) (256 / mult);
if (mult != prevMult) {
assert(max <= 32768);
for (j = 0; j < max; j++)
diff --git a/xc/extras/Mesa/src/all.h b/xc/extras/Mesa/src/all.h
index 5e291f0a9..b1ced0aa4 100644
--- a/xc/extras/Mesa/src/all.h
+++ b/xc/extras/Mesa/src/all.h
@@ -45,6 +45,7 @@
#endif
#include "glheader.h"
+#include "aatriangle.h"
#include "accum.h"
#include "alpha.h"
#include "alphabuf.h"
diff --git a/xc/extras/Mesa/src/attrib.c b/xc/extras/Mesa/src/attrib.c
index 53f59765d..8ff30b023 100644
--- a/xc/extras/Mesa/src/attrib.c
+++ b/xc/extras/Mesa/src/attrib.c
@@ -103,7 +103,7 @@ _mesa_PushAttrib(GLbitfield mask)
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushAttrib");
if (MESA_VERBOSE&VERBOSE_API)
- fprintf(stderr, "glPushAttrib %x\n", mask);
+ fprintf(stderr, "glPushAttrib %x\n", (int)mask);
if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) {
gl_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" );
@@ -422,21 +422,43 @@ _mesa_PopAttrib(void)
GLubyte oldAlphaRef = ctx->Color.AlphaRef;
GLenum oldBlendSrc = ctx->Color.BlendSrcRGB;
GLenum oldBlendDst = ctx->Color.BlendDstRGB;
+ GLenum oldLogicOp = ctx->Color.LogicOp;
MEMCPY( &ctx->Color, attr->data,
sizeof(struct gl_colorbuffer_attrib) );
if (ctx->Color.DrawBuffer != oldDrawBuffer) {
_mesa_DrawBuffer( ctx->Color.DrawBuffer);
}
- if ((ctx->Color.AlphaFunc != oldAlphaFunc ||
- ctx->Color.AlphaRef != oldAlphaRef) &&
- ctx->Driver.AlphaFunc)
- (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc,
- ctx->Color.AlphaRef / 255.0F);
if ((ctx->Color.BlendSrcRGB != oldBlendSrc ||
- ctx->Color.BlendSrcRGB != oldBlendDst) &&
+ ctx->Color.BlendDstRGB != oldBlendDst) &&
ctx->Driver.BlendFunc)
(*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB,
ctx->Color.BlendDstRGB);
+ if (ctx->Color.LogicOp != oldLogicOp &&
+ ctx->Driver.LogicOpcode) {
+ ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
+ }
+ if (ctx->Visual->RGBAflag) {
+ GLubyte r = (GLint) (ctx->Color.ClearColor[0] * 255.0F);
+ GLubyte g = (GLint) (ctx->Color.ClearColor[1] * 255.0F);
+ GLubyte b = (GLint) (ctx->Color.ClearColor[2] * 255.0F);
+ GLubyte a = (GLint) (ctx->Color.ClearColor[3] * 255.0F);
+ (*ctx->Driver.ClearColor)( ctx, r, g, b, a );
+ if ((ctx->Color.AlphaFunc != oldAlphaFunc ||
+ ctx->Color.AlphaRef != oldAlphaRef) &&
+ ctx->Driver.AlphaFunc)
+ (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc,
+ ctx->Color.AlphaRef / 255.0F);
+ if (ctx->Driver.ColorMask) {
+ (*ctx->Driver.ColorMask)(ctx,
+ ctx->Color.ColorMask[0],
+ ctx->Color.ColorMask[1],
+ ctx->Color.ColorMask[2],
+ ctx->Color.ColorMask[3]);
+ }
+ }
+ else {
+ (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex);
+ }
}
break;
case GL_CURRENT_BIT:
@@ -634,6 +656,11 @@ _mesa_PopAttrib(void)
(*ctx->Driver.Enable)( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
(*ctx->Driver.Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag );
}
+ if (ctx->Driver.LineStipple)
+ (*ctx->Driver.LineStipple)(ctx, ctx->Line.StippleFactor,
+ ctx->Line.StipplePattern);
+ if (ctx->Driver.LineWidth)
+ (*ctx->Driver.LineWidth)(ctx, ctx->Line.Width);
break;
case GL_LIST_BIT:
MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
@@ -670,6 +697,8 @@ _mesa_PopAttrib(void)
break;
case GL_POLYGON_STIPPLE_BIT:
MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
+ if (ctx->Driver.PolygonStipple)
+ ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data );
break;
case GL_SCISSOR_BIT:
MEMCPY( &ctx->Scissor, attr->data,
diff --git a/xc/extras/Mesa/src/bitmap.c b/xc/extras/Mesa/src/bitmap.c
index 563dff9af..d729b5436 100644
--- a/xc/extras/Mesa/src/bitmap.c
+++ b/xc/extras/Mesa/src/bitmap.c
@@ -53,7 +53,7 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py,
{
struct pixel_buffer *PB = ctx->PB;
GLint row, col;
- GLint pz;
+ GLdepth fragZ;
ASSERT(ctx->RenderMode == GL_RENDER);
@@ -74,10 +74,10 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py,
PB_SET_INDEX( ctx, PB, ctx->Current.RasterIndex );
}
- pz = (GLint) ( ctx->Current.RasterPos[2] * DEPTH_SCALE );
+ fragZ = (GLdepth) ( ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
for (row=0; row<height; row++) {
- const GLubyte *src = (const GLubyte *) gl_pixel_addr_in_image( unpack,
+ const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack,
bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 );
if (unpack->LsbFirst) {
@@ -85,7 +85,7 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py,
GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
for (col=0; col<width; col++) {
if (*src & mask) {
- PB_WRITE_PIXEL( PB, px+col, py+row, pz );
+ PB_WRITE_PIXEL( PB, px+col, py+row, fragZ );
}
if (mask == 128U) {
src++;
@@ -107,7 +107,7 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py,
GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
for (col=0; col<width; col++) {
if (*src & mask) {
- PB_WRITE_PIXEL( PB, px+col, py+row, pz );
+ PB_WRITE_PIXEL( PB, px+col, py+row, fragZ );
}
if (mask == 1U) {
src++;
diff --git a/xc/extras/Mesa/src/clip.c b/xc/extras/Mesa/src/clip.c
index 84a9fad29..ed986ad6b 100644
--- a/xc/extras/Mesa/src/clip.c
+++ b/xc/extras/Mesa/src/clip.c
@@ -41,6 +41,15 @@
+#define CLIP_RGBA0 0x1
+#define CLIP_RGBA1 0x2
+#define CLIP_TEX0 0x4
+#define CLIP_TEX1 0x8
+#define CLIP_INDEX0 0x10
+#define CLIP_INDEX1 0x20
+#define CLIP_FOG_COORD 0x40
+
+
/* Linear interpolation between A and B: */
#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
@@ -57,16 +66,7 @@ do { \
} while(0)
-
-
-#define CLIP_RGBA0 0x1
-#define CLIP_RGBA1 0x2
-#define CLIP_TEX0 0x4
-#define CLIP_TEX1 0x8
-#define CLIP_INDEX0 0x10
-#define CLIP_INDEX1 0x20
-
-static clip_interp_func clip_interp_tab[0x40];
+static clip_interp_func clip_interp_tab[0x80];
#define IND 0
#define NAME clip_nil
@@ -112,6 +112,50 @@ static clip_interp_func clip_interp_tab[0x40];
#define NAME clipINDEX0_INDEX1
#include "interp_tmp.h"
+#define IND (CLIP_FOG_COORD)
+#define NAME clip_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_RGBA0|CLIP_FOG_COORD)
+#define NAME clipRGBA0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
+#define NAME clipRGBA0_RGBA1_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
+#define NAME clipTEX0_RGBA0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
+#define NAME clipTEX0_RGBA0_RGBA1_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
+#define NAME clipTEX1_TEX0_RGBA0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX0|CLIP_FOG_COORD)
+#define NAME clipTEX0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD)
+#define NAME clipTEX1_TEX0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
+#define NAME clipTEX1_TEX0_RGBA0_RGBA1_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_INDEX0|CLIP_FOG_COORD)
+#define NAME clipINDEX0_FOG
+#include "interp_tmp.h"
+
+#define IND (CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD)
+#define NAME clipINDEX0_INDEX1_FOG
+#include "interp_tmp.h"
+
@@ -352,6 +396,8 @@ void gl_update_clipmask( GLcontext *ctx )
mask |= CLIP_INDEX1;
}
+ if (ctx->FogMode == FOG_FRAGMENT && (ctx->TriangleCaps & DD_CLIP_FOG_COORD))
+ mask |= CLIP_FOG_COORD;
ctx->ClipInterpFunc = clip_interp_tab[mask];
ctx->poly_clip_tab = gl_poly_clip_tab[0];
@@ -447,11 +493,22 @@ void gl_init_clip(void)
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0] = clipTEX1_TEX0_RGBA0;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1] =
clipTEX1_TEX0_RGBA0_RGBA1;
-
clip_interp_tab[CLIP_TEX0] = clipTEX0;
clip_interp_tab[CLIP_TEX1|CLIP_TEX0] = clipTEX1_TEX0;
-
clip_interp_tab[CLIP_INDEX0] = clipINDEX0;
clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1] = clipINDEX0_INDEX1;
+
+ clip_interp_tab[CLIP_FOG_COORD] = clip_FOG;
+ clip_interp_tab[CLIP_RGBA0|CLIP_FOG_COORD] = clipRGBA0_FOG;
+ clip_interp_tab[CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipRGBA0_RGBA1_FOG;
+ clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX0_RGBA0_FOG;
+ clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipTEX0_RGBA0_RGBA1_FOG;
+ clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX1_TEX0_RGBA0_FOG;
+ clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] =
+ clipTEX1_TEX0_RGBA0_RGBA1_FOG;
+ clip_interp_tab[CLIP_TEX0|CLIP_FOG_COORD] = clipTEX0_FOG;
+ clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD] = clipTEX1_TEX0_FOG;
+ clip_interp_tab[CLIP_INDEX0|CLIP_FOG_COORD] = clipINDEX0_FOG;
+ clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD] = clipINDEX0_INDEX1_FOG;
}
diff --git a/xc/extras/Mesa/src/clip_funcs.h b/xc/extras/Mesa/src/clip_funcs.h
index c348c0724..8c51fe070 100644
--- a/xc/extras/Mesa/src/clip_funcs.h
+++ b/xc/extras/Mesa/src/clip_funcs.h
@@ -151,17 +151,23 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
#define GENERAL_CLIP \
if (mask & PLANE) { \
- GLuint prevj = inlist[n-1]; \
+ GLuint prevj = inlist[0]; \
GLuint prevflag = INSIDE(prevj); \
GLuint outcount = 0; \
- GLuint ef_state = 3; \
GLuint i; \
- \
- \
- for (i = 0; i < n; 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); \
+ } \
+ \
if (flag ^ prevflag) { \
if (flag) { \
/* Coming back in \
@@ -171,7 +177,7 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
\
if (IND&CLIP_TAB_EDGEFLAG) \
VB->EdgeFlagPtr->data[vb_free] = \
- VB->EdgeFlagPtr->data[prevj] & ef_state; \
+ VB->EdgeFlagPtr->data[prevj]; \
\
\
} else { \
@@ -180,22 +186,25 @@ static GLuint TAG(viewclip_polygon)( struct vertex_buffer *VB,
COMPUTE_INTERSECTION( prevj, j, vb_free ); \
interp( VB, vb_free, t, prevj, j ); \
\
- if (IND&CLIP_TAB_EDGEFLAG) \
- VB->EdgeFlagPtr->data[vb_free] = 1; \
+ if (IND&CLIP_TAB_EDGEFLAG) { \
+ VB->EdgeFlagPtr->data[vb_free] = 3; \
+ } \
+ } \
+ \
+ if (IND&CLIP_TAB_EDGEFLAG) { \
+ /* Demote trailing edge to internal edge. \
+ */ \
+ 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; \
+ VB->ClipMask[vb_free++] = 0; \
} \
\
- if (flag) { \
- outlist[outcount++] = j; \
- } else { \
- VB->ClipMask[j] |= (PLANE&CLIP_ALL_BITS); /* don't setup */ \
- } \
prevj = j; \
prevflag = flag; \
- ef_state = 1; \
} \
\
if (outcount < 3) \
@@ -340,49 +349,60 @@ static GLuint TAG(userclip_polygon)( struct vertex_buffer *VB,
register float d = ctx->Transform.ClipUserPlane[p][3];
/* initialize prev to be last in the input list */
- GLuint prevj = inlist[n - 1];
+ GLuint prevj = inlist[0];
GLfloat dpJ = d*W(prevj) + c*Z(prevj) + b*Y(prevj) + a*X(prevj);
GLuint flagJ = INSIDE(dpJ);
GLuint outcount = 0;
GLuint curri;
- for (curri=0;curri<n;curri++) {
+ inlist[n] = inlist[0];
+
+
+ for (curri=1;curri<n+1;curri++) {
GLuint currj = inlist[curri];
GLfloat dpI = d*W(currj) + c*Z(currj) + b*Y(currj) + a*X(currj);
GLuint flagI = INSIDE(dpI);
+ if (flagJ) {
+ outlist[outcount++] = prevj;
+ } else {
+ VB->ClipMask[prevj] |= CLIP_USER_BIT;
+ }
+
if (flagI ^ flagJ) {
GLfloat t;
GLuint in;
GLuint out;
-
+
if (flagI) {
out = prevj;
- in = currj;
- t = dpI/(dpI-dpJ);
+ in = currj;
+ t = dpI/(dpI-dpJ);
- if (IND&CLIP_TAB_EDGEFLAG)
- VB->EdgeFlagPtr->data[vb_free] =
- VB->EdgeFlagPtr->data[prevj];
+ if (IND&CLIP_TAB_EDGEFLAG)
+ VB->EdgeFlagPtr->data[vb_free] =
+ VB->EdgeFlagPtr->data[prevj];
} else {
in = prevj;
- out = currj;
- t = dpJ/(dpJ-dpI);
+ out = currj;
+ t = dpJ/(dpJ-dpI);
- if (IND&CLIP_TAB_EDGEFLAG)
- VB->EdgeFlagPtr->data[vb_free] = 1;
+ if (IND&CLIP_TAB_EDGEFLAG)
+ VB->EdgeFlagPtr->data[vb_free] = 3;
}
+
+ if (IND&CLIP_TAB_EDGEFLAG) {
+ /* Demote trailing edge to internal edge.
+ */
+ if (outcount &&
+ (VB->EdgeFlagPtr->data[outlist[outcount-1]] & 0x2))
+ VB->EdgeFlagPtr->data[outlist[outcount-1]] = 1;
+ }
INTERP_SZ( t, coord, vb_free, in, out, SIZE );
interp( VB, vb_free, t, in, out);
outlist[outcount++] = vb_free;
VB->ClipMask[vb_free++] = 0;
- }
-
- if (flagI) {
- outlist[outcount++] = currj;
- } else {
- VB->ClipMask[currj] |= CLIP_USER_BIT;
}
prevj = currj;
diff --git a/xc/extras/Mesa/src/colortab.c b/xc/extras/Mesa/src/colortab.c
index 63b93435a..95c2a7d84 100644
--- a/xc/extras/Mesa/src/colortab.c
+++ b/xc/extras/Mesa/src/colortab.c
@@ -162,7 +162,7 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat,
assert(palette);
- if (!gl_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type)) {
gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)");
return;
}
@@ -245,7 +245,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
assert(palette);
- if (!gl_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type)) {
gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)");
return;
}
@@ -255,7 +255,7 @@ _mesa_ColorSubTable( GLenum target, GLsizei start,
return;
}
- comps = gl_components_in_format(format);
+ comps = _mesa_components_in_format(format);
assert(comps > 0); /* error should be caught sooner */
if (start + count > palette->Size) {
@@ -369,8 +369,8 @@ _mesa_GetColorTable( GLenum target, GLenum format,
return;
}
- gl_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba,
- format, type, table, &ctx->Pack, GL_FALSE);
+ _mesa_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba,
+ format, type, table, &ctx->Pack, GL_FALSE);
(void) format;
(void) type;
@@ -408,6 +408,15 @@ _mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params )
case GL_TEXTURE_3D:
palette = &texUnit->CurrentD[3]->Palette;
break;
+ case GL_PROXY_TEXTURE_1D:
+ palette = &ctx->Texture.Proxy1D->Palette;
+ break;
+ case GL_PROXY_TEXTURE_2D:
+ palette = &ctx->Texture.Proxy2D->Palette;
+ break;
+ case GL_PROXY_TEXTURE_3D:
+ palette = &ctx->Texture.Proxy3D->Palette;
+ break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
palette = &ctx->Texture.Palette;
break;
diff --git a/xc/extras/Mesa/src/config.h b/xc/extras/Mesa/src/config.h
index 595f02830..22ad65ca2 100644
--- a/xc/extras/Mesa/src/config.h
+++ b/xc/extras/Mesa/src/config.h
@@ -125,26 +125,12 @@
/*
- * Bits per depth buffer value: 16 or 32
+ * Bits per depth buffer value: 16 or 32 (GLushort or GLuint)
+ * gl_create_visual() can select any depth in [0, 32].
*/
-#ifdef MESAD3D
- /* Mesa / Direct3D driver only */
- extern float g_DepthScale, g_MaxDepth;
-# define DEPTH_BITS 32
-# define DEPTH_SCALE g_DepthScale
-# define MAX_DEPTH g_MaxDepth
-#else
-# define DEPTH_BITS 16
-# if DEPTH_BITS==16
-# define MAX_DEPTH 0xffff
-# define DEPTH_SCALE 65535.0F
-# elif DEPTH_BITS==32
-# define MAX_DEPTH 0x3fffffff
-# define DEPTH_SCALE ((GLfloat) MAX_DEPTH)
-# else
-# error "illegal number of depth bits"
-# endif
-#endif
+#define DEFAULT_SOFTWARE_DEPTH_BITS 16
+#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort
+
/*
@@ -190,7 +176,7 @@
* VB_MAX vertices. (This only happens when mixed primitives are
* sharing the vb).
*/
-#define VB_MAX_CLIPPED_VERTS (2 * (6 + MAX_CLIP_PLANES))
+#define VB_MAX_CLIPPED_VERTS ((2 * (6 + MAX_CLIP_PLANES))+1)
#define VB_SIZE (VB_MAX + VB_MAX_CLIPPED_VERTS)
diff --git a/xc/extras/Mesa/src/context.c b/xc/extras/Mesa/src/context.c
index 48e92df60..9daf404c8 100644
--- a/xc/extras/Mesa/src/context.c
+++ b/xc/extras/Mesa/src/context.c
@@ -254,12 +254,15 @@ static void print_timings( GLcontext *ctx )
* alphaFlag - alloc software alpha buffers?
* dbFlag - double buffering?
* stereoFlag - stereo buffer?
- * depthFits - requested minimum bits per depth buffer value
- * stencilFits - requested minimum bits per stencil buffer value
- * accumFits - requested minimum bits per accum buffer component
- * indexFits - number of bits per pixel if rgbFlag==GL_FALSE
- * red/green/blue/alphaFits - number of bits per color component
- * in frame buffer for RGB(A) mode.
+ * depthBits - requested bits per depth buffer value
+ * Any value in [0, 32] is acceptable but the actual
+ * depth type will be GLushort or GLuint as needed.
+ * stencilBits - requested minimum bits per stencil buffer value
+ * accumBits - requested minimum bits per accum buffer component
+ * indexBits - number of bits per pixel if rgbFlag==GL_FALSE
+ * red/green/blue/alphaBits - number of bits per color component
+ * in frame buffer for RGB(A) mode.
+ * We always use 8 in core Mesa though.
* Return: pointer to new GLvisual or NULL if requested parameters can't
* be met.
*/
@@ -278,16 +281,19 @@ GLvisual *gl_create_visual( GLboolean rgbFlag,
{
GLvisual *vis;
- if (depthBits > (GLint) (8*sizeof(GLdepth))) {
- /* can't meet depth buffer requirements */
+ /* This is to catch bad values from device drivers not updated for
+ * Mesa 3.3. Some device drivers just passed 1. That's a REALLY
+ * bad value now (a 1-bit depth buffer!?!).
+ */
+ assert(depthBits == 0 || depthBits > 1);
+
+ if (depthBits < 0 || depthBits > 32) {
return NULL;
}
- if (stencilBits > (GLint) (8*sizeof(GLstencil))) {
- /* can't meet stencil buffer requirements */
+ if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) {
return NULL;
}
- if (accumBits > (GLint) (8*sizeof(GLaccum))) {
- /* can't meet accum buffer requirements */
+ if (accumBits < 0 || accumBits > (GLint) (8 * sizeof(GLaccum))) {
return NULL;
}
@@ -302,15 +308,27 @@ GLvisual *gl_create_visual( GLboolean rgbFlag,
vis->RedBits = redBits;
vis->GreenBits = greenBits;
vis->BlueBits = blueBits;
- vis->AlphaBits = alphaFlag ? 8*sizeof(GLubyte) : alphaBits;
+ vis->AlphaBits = alphaFlag ? (8 * sizeof(GLubyte)) : alphaBits;
vis->IndexBits = indexBits;
- vis->DepthBits = (depthBits>0) ? 8*sizeof(GLdepth) : 0;
- vis->AccumBits = (accumBits>0) ? 8*sizeof(GLaccum) : 0;
- vis->StencilBits = (stencilBits>0) ? 8*sizeof(GLstencil) : 0;
+ vis->DepthBits = depthBits;
+ vis->AccumBits = (accumBits > 0) ? (8 * sizeof(GLaccum)) : 0;
+ vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0;
vis->SoftwareAlpha = alphaFlag;
+ if (depthBits == 0) {
+ /* Special case. Even if we don't have a depth buffer we need
+ * good values for DepthMax for Z vertex transformation purposes.
+ */
+ vis->DepthMax = 1;
+ vis->DepthMaxF = 1.0F;
+ }
+ else {
+ vis->DepthMax = (1 << depthBits) - 1;
+ vis->DepthMaxF = (GLfloat) vis->DepthMax;
+ }
+
return vis;
}
@@ -386,8 +404,8 @@ GLframebuffer *gl_create_framebuffer( GLvisual *visual,
void gl_destroy_framebuffer( GLframebuffer *buffer )
{
if (buffer) {
- if (buffer->Depth) {
- FREE( buffer->Depth );
+ if (buffer->DepthBuffer) {
+ FREE( buffer->DepthBuffer );
}
if (buffer->Accum) {
FREE( buffer->Accum );
@@ -756,7 +774,7 @@ static void init_attrib_groups( GLcontext *ctx )
gl_matrix_alloc_inv( &ctx->ModelView );
ctx->ModelViewStackDepth = 0;
- for (i = 0 ; i < MAX_MODELVIEW_STACK_DEPTH ; i++) {
+ for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
gl_matrix_ctr( &ctx->ModelViewStack[i] );
gl_matrix_alloc_inv( &ctx->ModelViewStack[i] );
}
@@ -773,7 +791,7 @@ static void init_attrib_groups( GLcontext *ctx )
ctx->NearFarStack[0][0] = 1.0; /* These values seem weird by make */
ctx->NearFarStack[0][1] = 0.0; /* sense mathematically. */
- for (i = 0 ; i < MAX_PROJECTION_STACK_DEPTH ; i++) {
+ for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
gl_matrix_ctr( &ctx->ProjectionStack[i] );
gl_matrix_alloc_inv( &ctx->ProjectionStack[i] );
}
@@ -782,7 +800,7 @@ static void init_attrib_groups( GLcontext *ctx )
for (i=0; i<MAX_TEXTURE_UNITS; i++) {
gl_matrix_ctr( &ctx->TextureMatrix[i] );
ctx->TextureStackDepth[i] = 0;
- for (j = 0 ; j < MAX_TEXTURE_STACK_DEPTH ; j++) {
+ for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
ctx->TextureStack[i][j].inv = 0;
}
}
@@ -845,6 +863,7 @@ static void init_attrib_groups( GLcontext *ctx )
ctx->Depth.Clear = 1.0;
ctx->Depth.Func = GL_LESS;
ctx->Depth.Mask = GL_TRUE;
+ ctx->Depth.OcclusionTest = GL_FALSE;
/* Evaluators group */
ctx->Eval.Map1Color4 = GL_FALSE;
@@ -1100,8 +1119,8 @@ static void init_attrib_groups( GLcontext *ctx )
#define Sz 10
#define Tz 14
- ctx->Viewport.WindowMap.m[Sz] = 0.5 * DEPTH_SCALE;
- ctx->Viewport.WindowMap.m[Tz] = 0.5 * DEPTH_SCALE;
+ ctx->Viewport.WindowMap.m[Sz] = 0.5 * ctx->Visual->DepthMaxF;
+ ctx->Viewport.WindowMap.m[Tz] = 0.5 * ctx->Visual->DepthMaxF;
#undef Sz
#undef Tz
@@ -1208,6 +1227,7 @@ static void init_attrib_groups( GLcontext *ctx )
ctx->ErrorValue = (GLenum) GL_NO_ERROR;
ctx->CatchSignals = GL_TRUE;
+ ctx->OcclusionResult = GL_FALSE;
/* For debug/development only */
ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE;
@@ -1373,8 +1393,8 @@ GLboolean gl_initialize_context_data( GLcontext *ctx,
}
/* setup API dispatch tables */
- ctx->Exec = CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
- ctx->Save = CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
+ ctx->Exec = (struct _glapi_table *) CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
+ ctx->Save = (struct _glapi_table *) CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *));
if (!ctx->Exec || !ctx->Save) {
free_shared_state(ctx, ctx->Shared);
FREE(ctx->VB);
@@ -1427,8 +1447,8 @@ GLcontext *gl_create_context( GLvisual *visual,
*/
void gl_free_context_data( GLcontext *ctx )
{
- GLuint i;
struct gl_shine_tab *s, *tmps;
+ GLuint i, j;
/* if we're destroying the current context, unbind it first */
if (ctx == gl_get_current_context()) {
@@ -1442,13 +1462,19 @@ void gl_free_context_data( GLcontext *ctx )
#endif
gl_matrix_dtr( &ctx->ModelView );
- for (i = 0 ; i < MAX_MODELVIEW_STACK_DEPTH ; i++) {
+ for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
gl_matrix_dtr( &ctx->ModelViewStack[i] );
}
gl_matrix_dtr( &ctx->ProjectionMatrix );
- for (i = 0 ; i < MAX_PROJECTION_STACK_DEPTH ; i++) {
+ for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
gl_matrix_dtr( &ctx->ProjectionStack[i] );
}
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ gl_matrix_dtr( &ctx->TextureMatrix[i] );
+ for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
+ gl_matrix_dtr( &ctx->TextureStack[i][j] );
+ }
+ }
FREE( ctx->PB );
diff --git a/xc/extras/Mesa/src/context.h b/xc/extras/Mesa/src/context.h
index 535ac238e..1f0b0d063 100644
--- a/xc/extras/Mesa/src/context.h
+++ b/xc/extras/Mesa/src/context.h
@@ -141,7 +141,7 @@ do { \
extern struct immediate *_mesa_CurrentInput;
-#define GET_CURRENT_CONTEXT(C) GLcontext *C = _glapi_Context
+#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
#define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
diff --git a/xc/extras/Mesa/src/copypix.c b/xc/extras/Mesa/src/copypix.c
index a77086ccf..0ca25b9f7 100644
--- a/xc/extras/Mesa/src/copypix.c
+++ b/xc/extras/Mesa/src/copypix.c
@@ -103,7 +103,7 @@ static void copy_rgba_pixels( GLcontext *ctx,
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
- GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMax);
for (i=0;i<width;i++) {
zspan[i] = z;
}
@@ -244,7 +244,7 @@ static void copy_ci_pixels( GLcontext *ctx,
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
- GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMax);
for (i=0;i<width;i++) {
zspan[i] = z;
}
@@ -335,7 +335,7 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
GLint overlapping;
- if (!ctx->ReadBuffer->Depth || !ctx->DrawBuffer->Depth) {
+ if (!ctx->ReadBuffer->DepthBuffer || !ctx->DrawBuffer->DepthBuffer) {
gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
return;
}
@@ -401,7 +401,7 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
for (i = 0; i < width; i++) {
GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
- zspan[i] = (GLint) (CLAMP( d, 0.0F, 1.0F ) * DEPTH_SCALE);
+ zspan[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->Visual->DepthMax);
}
if (ctx->Visual->RGBAflag) {
@@ -542,6 +542,12 @@ _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);
+ if (ctx->Driver.CopyPixels &&
+ (*ctx->Driver.CopyPixels)( ctx, srcx, srcy, width, height,
+ destx, desty, type )) {
+ return;
+ }
+
if (type == GL_COLOR && ctx->Visual->RGBAflag) {
copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
}
diff --git a/xc/extras/Mesa/src/dd.h b/xc/extras/Mesa/src/dd.h
index 25a82a546..739905f6d 100644
--- a/xc/extras/Mesa/src/dd.h
+++ b/xc/extras/Mesa/src/dd.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"),
@@ -390,6 +390,8 @@ struct dd_function_table {
/***
*** For supporting hardware Z buffers:
*** Either ALL or NONE of these functions must be implemented!
+ *** NOTE that Each depth value is a 32-bit GLuint. If the depth
+ *** buffer is less than 32 bits deep then the extra upperbits are zero.
***/
void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
@@ -431,13 +433,11 @@ struct dd_function_table {
* Else, only write stencil[i] if mask[i] is non-zero.
*/
-
void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y,
GLstencil stencil[] );
/* Read a horizontal span of stencil values from the stencil buffer.
*/
-
void (*WriteStencilPixels)( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
const GLstencil stencil[],
@@ -454,18 +454,10 @@ struct dd_function_table {
*/
-
/***
- *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
+ *** glDraw/Read/CopyPixels and glBitmap functions:
***/
- points_func PointsFunc;
- line_func LineFunc;
- triangle_func TriangleFunc;
- quad_func QuadFunc;
- rect_func RectFunc;
-
-
GLboolean (*DrawPixels)( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
@@ -477,6 +469,25 @@ struct dd_function_table {
* must do the job.
*/
+ GLboolean (*ReadPixels)( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ GLvoid *dest );
+ /* Called by glReadPixels.
+ * Return GL_TRUE if operation completed, else return GL_FALSE.
+ * This function must respect all glPixelTransfer settings.
+ */
+
+ GLboolean (*CopyPixels)( GLcontext *ctx,
+ GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint dstx, GLint dsty, GLenum type );
+ /* Do a glCopyPixels. Return GL_TRUE if operation completed, else
+ * return GL_FALSE. This function must respect all rasterization
+ * state, glPixelTransfer, glPixelZoom, etc.
+ */
+
GLboolean (*Bitmap)( GLcontext *ctx,
GLint x, GLint y, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
@@ -484,78 +495,17 @@ struct dd_function_table {
/* This is called by glBitmap. Works the same as DrawPixels, above.
*/
- void (*RenderStart)( GLcontext *ctx );
- void (*RenderFinish)( GLcontext *ctx );
- /* KW: These replace Begin and End, and have more relaxed semantics.
- * They are called prior-to and after one or more vb flush, and are
- * thus decoupled from the gl_begin/gl_end pairs, which are possibly
- * more frequent. If a begin/end pair covers >1 vertex buffer, these
- * are called at most once for the pair. (a bit broken at present)
- */
-
- void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end );
- /* This function, if not NULL, is called whenever new window coordinates
- * are put in the vertex buffer. The vertices in question are those n
- * such that start <= n < end.
- * The device driver can convert the window coords to its own specialized
- * format. The 3Dfx driver uses this.
- *
- * Note: Deprecated in favour of RegisterPipelineStages, below.
- */
-
-
- render_func *RenderVBClippedTab;
- render_func *RenderVBCulledTab;
- render_func *RenderVBRawTab;
- /* These function tables allow the device driver to rasterize an
- * entire begin/end group of primitives at once. See the
- * gl_render_vb() function in vbrender.c for more details.
- */
-
-
- void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive );
- /* If registered, this will be called when rendering transitions between
- * points, lines and triangles. It is not called on transitions between
- * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
- * triangles and quads or triangles and polygons.
- */
-
- GLuint TriangleCaps;
- /* Holds a list of the reasons why we might normally want to call
- * render_triangle, but which are in fact implemented by the
- * driver. The FX driver sets this to DD_TRI_CULL, and will soon
- * implement DD_TRI_OFFSET.
- */
-
-
- GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno );
- /* Driver may request additional render passes by returning GL_TRUE
- * when this function is called. This function will be called
- * after the first pass, and passes will be made until the function
- * returns GL_FALSE. If no function is registered, only one pass
- * is made.
- *
- * This function will be first invoked with passno == 1.
- */
/***
*** Texture mapping functions:
***/
- void (*TexEnv)( GLcontext *ctx, GLenum pname, const GLfloat *param );
- /*
- * Called whenever glTexEnv*() is called.
- * Pname will be one of GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR.
- * If pname is GL_TEXTURE_ENV_MODE then param will be one
- * of GL_MODULATE, GL_BLEND, GL_DECAL, or GL_REPLACE.
- */
-
void (*TexImage)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj, GLint level,
GLint internalFormat,
const struct gl_texture_image *image );
- /*
- * Called whenever a texture object's image is changed.
+ /* XXX this function is obsolete */
+ /* Called whenever a texture object's image is changed.
* texObject is the number of the texture object being changed.
* level indicates the mipmap level.
* internalFormat is the format in which the texture is to be stored.
@@ -569,70 +519,240 @@ struct dd_function_table {
GLsizei width, GLsizei height,
GLint internalFormat,
const struct gl_texture_image *image );
- /*
- * Called from glTexSubImage() to define a sub-region of a texture.
+ /* XXX this function is obsolete */
+ /* Called from glTexSubImage() to define a sub-region of a texture.
+ */
+
+
+ GLboolean (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLboolean *retainInternalCopy );
+ GLboolean (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLboolean *retainInternalCopy );
+ GLboolean (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLboolean *retainInternalCopy );
+ /* Called by glTexImage1/2/3D.
+ * Will not be called if any glPixelTransfer operations are enabled.
+ * Arguments:
+ * <target>, <level>, <format>, <type> and <pixels> are user specified.
+ * <packing> indicates the image packing of pixels.
+ * <texObj> is the target texture object.
+ * <texImage> is the target texture image. It will have the texture
+ * width, height, depth, border and internalFormat information.
+ * <retainInternalCopy> is returned by this function and indicates whether
+ * core Mesa should keep an internal copy of the texture image.
+ * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
+ * should do the job. If GL_FALSE is returned, this function will be
+ * called a second time after the texture image has been unpacked into
+ * GLubytes. It may be easier for the driver to handle then.
+ */
+
+ GLboolean (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+ GLboolean (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+ GLboolean (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLint depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+ /* Called by glTexSubImage1/2/3D.
+ * Will not be called if any glPixelTransfer operations are enabled.
+ * Arguments:
+ * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>,
+ * <depth>, <format>, <type> and <pixels> are user specified.
+ * <packing> indicates the image packing of pixels.
+ * <texObj> is the target texture object.
+ * <texImage> is the target texture image. It will have the texture
+ * width, height, border and internalFormat information.
+ * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
+ * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will
+ * be called with the complete texture image.
+ */
+
+ GLboolean (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat, GLint x, GLint y,
+ GLsizei width, GLint border );
+ GLboolean (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat, GLint x, GLint y,
+ GLsizei width, GLsizei height, GLint border );
+ /* Called by glCopyTexImage1D and glCopyTexImage2D.
+ * Will not be called if any glPixelTransfer operations are enabled.
+ * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
+ * should do the job.
+ */
+
+ GLboolean (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset,
+ GLint x, GLint y, GLsizei width );
+ GLboolean (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+ GLboolean (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+ /* Called by glCopyTexSubImage1/2/3D.
+ * Will not be called if any glPixelTransfer operations are enabled.
+ * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa
+ * should do the job.
+ */
+
+ GLvoid *(*GetTexImage)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum *formatOut, GLenum *typeOut,
+ GLboolean *freeImageOut );
+ /* Called by glGetTexImage or by core Mesa when a texture image
+ * is needed for software fallback rendering.
+ * Return the address of the texture image or NULL if failure.
+ * The image must be tightly packed (i.e. row stride = image width)
+ * Return the image's format and type in formatOut and typeOut.
+ * The format and type must be values which are accepted by glTexImage.
+ * Set the freeImageOut flag if the returned image should be deallocated
+ * with FREE() when finished.
+ * The size of the image can be deduced from the target and level.
+ * Core Mesa will perform any image format/type conversions that are needed.
+ */
+
+ void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname,
+ const GLfloat *param );
+ /* Called by glTexEnv*().
*/
void (*TexParameter)( GLcontext *ctx, GLenum target,
- struct gl_texture_object *tObj,
+ struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params );
- /*
- * Called whenever glTexParameter*() is called.
- * target is GL_TEXTURE_1D or GL_TEXTURE_2D
- * texObject is the texture object to modify
- * pname is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
- * GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, or GL_TEXTURE_BORDER_COLOR.
- * params is dependant on pname. See man glTexParameter.
+ /* Called by glTexParameter*().
+ * <target> is user specified
+ * <texObj> the texture object to modify
+ * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER,
+ * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR.
+ * <params> is user specified.
*/
void (*BindTexture)( GLcontext *ctx, GLenum target,
struct gl_texture_object *tObj );
- /*
- * Called whenever glBindTexture() is called. This specifies which
- * texture is to be the current one. No dirty flags will be set.
+ /* Called by glBindTexture().
*/
void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
- /*
- * Called when a texture object is about to be deallocated. Driver
+ /* Called when a texture object is about to be deallocated. Driver
* should free anything attached to the DriverData pointers.
*/
- void (*UpdateTexturePalette)( GLcontext *ctx,
- struct gl_texture_object *tObj );
- /*
- * Called when the texture's color lookup table is changed.
- * If tObj is NULL then the shared texture palette ctx->Texture.Palette
- * was changed.
+ GLboolean (*IsTextureResident)( GLcontext *ctx,
+ struct gl_texture_object *t );
+ /* Called by glAreTextureResident().
*/
- void (*UseGlobalTexturePalette)( GLcontext *ctx, GLboolean state );
- /*
- * Called via glEnable/Disable(GL_SHARED_TEXTURE_PALETTE_EXT)
+ void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t,
+ GLclampf priority );
+ /* Called by glPrioritizeTextures().
*/
void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
- /*
- * Called by glActiveTextureARB to set current texture unit.
+ /* Called by glActiveTextureARB to set current texture unit.
*/
+ void (*UpdateTexturePalette)( GLcontext *ctx,
+ struct gl_texture_object *tObj );
+ /* Called when the texture's color lookup table is changed.
+ * If tObj is NULL then the shared texture palette ctx->Texture.Palette
+ * is to be updated.
+ */
- GLboolean (*IsTextureResident)( GLcontext *ctx,
- struct gl_texture_object *t );
- /*
- * Allows the driver to implement the AreTexturesResident tests without
- * knowing about Mesa's internal hash tables for textures.
+
+
+ /***
+ *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions:
+ ***/
+
+ points_func PointsFunc;
+ line_func LineFunc;
+ triangle_func TriangleFunc;
+ quad_func QuadFunc;
+ rect_func RectFunc;
+
+
+ /***
+ *** Transformation/Rendering functions
+ ***/
+
+ void (*RenderStart)( GLcontext *ctx );
+ void (*RenderFinish)( GLcontext *ctx );
+ /* KW: These replace Begin and End, and have more relaxed semantics.
+ * They are called prior-to and after one or more vb flush, and are
+ * thus decoupled from the gl_begin/gl_end pairs, which are possibly
+ * more frequent. If a begin/end pair covers >1 vertex buffer, these
+ * are called at most once for the pair. (a bit broken at present)
+ */
+
+ void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end );
+ /* This function, if not NULL, is called whenever new window coordinates
+ * are put in the vertex buffer. The vertices in question are those n
+ * such that start <= n < end.
+ * The device driver can convert the window coords to its own specialized
+ * format. The 3Dfx driver uses this.
+ *
+ * Note: Deprecated in favour of RegisterPipelineStages, below.
*/
- void (*PrioritizeTexture)( GLcontext *ctx,
- struct gl_texture_object *t,
- GLclampf priority );
- /*
- * Notify driver of priority change for a texture.
+ render_func *RenderVBClippedTab;
+ render_func *RenderVBCulledTab;
+ render_func *RenderVBRawTab;
+ /* These function tables allow the device driver to rasterize an
+ * entire begin/end group of primitives at once. See the
+ * gl_render_vb() function in vbrender.c for more details.
*/
+ void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive );
+ /* If registered, this will be called when rendering transitions between
+ * points, lines and triangles. It is not called on transitions between
+ * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between
+ * triangles and quads or triangles and polygons.
+ */
+ GLuint TriangleCaps;
+ /* Holds a list of the reasons why we might normally want to call
+ * render_triangle, but which are in fact implemented by the
+ * driver. The FX driver sets this to DD_TRI_CULL, and will soon
+ * implement DD_TRI_OFFSET.
+ */
+ GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno );
+ /* Driver may request additional render passes by returning GL_TRUE
+ * when this function is called. This function will be called
+ * after the first pass, and passes will be made until the function
+ * returns GL_FALSE. If no function is registered, only one pass
+ * is made.
+ *
+ * This function will be first invoked with passno == 1.
+ */
/***
*** NEW in Mesa 3.x
@@ -704,7 +824,11 @@ struct dd_function_table {
void (*Lightfv)(GLcontext *ctx, GLenum light,
GLenum pname, const GLfloat *params, GLint nparams );
void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
+ void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
+ void (*LineWidth)(GLcontext *ctx, GLfloat width);
+ void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
+ void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
void (*ShadeModel)(GLcontext *ctx, GLenum mode);
void (*ClearStencil)(GLcontext *ctx, GLint s);
diff --git a/xc/extras/Mesa/src/ddsample.c b/xc/extras/Mesa/src/ddsample.c
index 364b091eb..16894d403 100644
--- a/xc/extras/Mesa/src/ddsample.c
+++ b/xc/extras/Mesa/src/ddsample.c
@@ -240,10 +240,20 @@ static void dither( GLcontext *ctx, GLboolean enable )
/*
- * Set the current drawing/reading buffer, return GL_TRUE or GL_FALSE
- * for success/failure.
+ * Set the current reading buffer.
*/
-static GLboolean set_buffer( GLcontext *ctx, GLenum mode )
+static void set_read_buffer( GLcontext *ctx, GLframebuffer *bufer,
+ GLenum mode )
+{
+ struct foo_mesa_context *foo = (struct foo_mesa_context *) ctx->DriverCtx;
+ setup_DD_pointers( ctx );
+}
+
+
+/*
+ * Set the destination/draw buffer.
+ */
+static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode )
{
struct foo_mesa_context *foo = (struct foo_mesa_context *) ctx->DriverCtx;
setup_DD_pointers( ctx );
@@ -311,8 +321,8 @@ static void fast_points_function( GLcontext *ctx, GLuint first, GLuint last )
for (i=first;i<=last;i++) {
if (VB->ClipMask[i]==0) {
int x, y;
- x = (GLint) VB->Win[i][0];
- y = FLIP( (GLint) VB->Win[i][1] );
+ x = (GLint) VB->Win.data[i][0];
+ y = FLIP( (GLint) VB->Win.data[i][1] );
WriteRGBAPixel( x, y, VB->ColorPtr->data[i] );
}
}
@@ -332,10 +342,10 @@ static void fast_line_function( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv
pixel = VB->ColorPtr->data[pv];
- x0 = (int) VB->Win[v0][0];
- y0 = FLIP( (int) VB->Win[v0][1] );
- x1 = (int) VB->Win[v1][0];
- y1 = FLIP( (int) VB->Win[v1][1] );
+ x0 = (int) VB->Win.data[v0][0];
+ y0 = FLIP( (int) VB->Win.data[v0][1] );
+ x1 = (int) VB->Win.data[v1][0];
+ y1 = FLIP( (int) VB->Win.data[v1][1] );
/* Draw line from (x0,y0) to (x1,y1) with current pixel color/index */
}
@@ -615,7 +625,8 @@ static void setup_DD_pointers( GLcontext *ctx )
ctx->Driver.Index = set_index;
ctx->Driver.Color = set_color;
- ctx->Driver.SetBuffer = set_buffer;
+ ctx->Driver.SetDrawBuffer = set_draw_buffer;
+ ctx->Driver.SetReadBuffer = set_read_buffer;
ctx->Driver.GetBufferSize = get_buffer_size;
ctx->Driver.PointsFunc = fast_points_function;
@@ -730,7 +741,11 @@ FooMesaBuffer FooMesaCreateBuffer( FooMesaVisual visual,
return NULL;
}
- b->gl_buffer = gl_create_framebuffer( visual->gl_visual );
+ b->gl_buffer = gl_create_framebuffer( visual->gl_visual,
+ visual->gl_visual->DepthBits > 0,
+ visual->gl_visual->StencilBits > 0,
+ visual->gl_visual->AccumBits > 0,
+ visual->gl_visual->AlphaBits > 0 );
b->the_window = your_window_id;
/* other stuff */
diff --git a/xc/extras/Mesa/src/depth.c b/xc/extras/Mesa/src/depth.c
index cb90fb21a..73fd68fb8 100644
--- a/xc/extras/Mesa/src/depth.c
+++ b/xc/extras/Mesa/src/depth.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"),
@@ -124,6 +124,33 @@ _mesa_DepthMask( GLboolean flag )
/**********************************************************************/
+/***** Misc *****/
+/**********************************************************************/
+
+/*
+ * Return address of depth buffer value for given window coord.
+ */
+GLvoid *
+_mesa_zbuffer_address(GLcontext *ctx, GLint x, GLint y)
+{
+ if (ctx->Visual->DepthBits <= 16)
+ return (GLushort *) ctx->DrawBuffer->DepthBuffer + ctx->DrawBuffer->Width * y + x;
+ else
+ return (GLuint *) ctx->DrawBuffer->DepthBuffer + ctx->DrawBuffer->Width * y + x;
+}
+
+
+#define Z_ADDRESS16( CTX, X, Y ) \
+ ( ((GLushort *) (CTX)->DrawBuffer->DepthBuffer) \
+ + (CTX)->DrawBuffer->Width * (Y) + (X) )
+
+#define Z_ADDRESS32( CTX, X, Y ) \
+ ( ((GLuint *) (CTX)->DrawBuffer->DepthBuffer) \
+ + (CTX)->DrawBuffer->Width * (Y) + (X) )
+
+
+
+/**********************************************************************/
/***** Depth Testing Functions *****/
/**********************************************************************/
@@ -136,8 +163,8 @@ _mesa_DepthMask( GLboolean flag )
* Return: number of fragments which pass the test.
*/
static GLuint
-depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
- GLdepth zbuffer[], const GLdepth z[], GLubyte mask[] )
+depth_test_span16( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLushort zbuffer[], const GLdepth z[], GLubyte mask[] )
{
GLuint passed = 0;
@@ -357,7 +384,236 @@ depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
MEMSET(mask, 0, n * sizeof(GLubyte));
break;
default:
- gl_problem(ctx, "Bad depth func in depth_test_span");
+ gl_problem(ctx, "Bad depth func in depth_test_span16");
+ }
+
+ return passed;
+}
+
+
+static GLuint
+depth_test_span32( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ GLuint zbuffer[], const GLdepth z[], GLubyte mask[] )
+{
+ GLuint passed = 0;
+
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
+ case GL_LESS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ if (z[i] < zbuffer[i]) {
+ /* pass */
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ if (z[i] < zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] <= zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] <= zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] >= zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] >= zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GREATER:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] > zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] > zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] != zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] != zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_EQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] == zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] == zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer or mask */
+ passed = n;
+ }
+ break;
+ case GL_NEVER:
+ MEMSET(mask, 0, n * sizeof(GLubyte));
+ break;
+ default:
+ gl_problem(ctx, "Bad depth func in depth_test_span32");
}
return passed;
@@ -372,31 +628,277 @@ GLuint
_mesa_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
const GLdepth z[], GLubyte mask[] )
{
- GLdepth zbuffer[MAX_WIDTH];
- GLdepth *zptr;
- GLuint passed;
-
if (ctx->Driver.ReadDepthSpan) {
- /* read depth values out of hardware Z buffer */
+ /* hardware-based depth buffer */
+ GLdepth zbuffer[MAX_WIDTH];
+ GLuint passed;
(*ctx->Driver.ReadDepthSpan)(ctx, n, x, y, zbuffer);
- zptr = zbuffer;
+ passed = depth_test_span32(ctx, n, x, y, zbuffer, z, mask);
+ assert(ctx->Driver.WriteDepthSpan);
+ (*ctx->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer, mask);
+ return passed;
}
else {
- /* test against software depth buffer values */
- zptr = Z_ADDRESS( ctx, x, y );
+ /* software depth buffer */
+ if (ctx->Visual->DepthBits <= 16) {
+ GLushort *zptr = (GLushort *) Z_ADDRESS16(ctx, x, y);
+ GLuint passed = depth_test_span16(ctx, n, x, y, zptr, z, mask);
+ return passed;
+ }
+ else {
+ GLuint *zptr = (GLuint *) Z_ADDRESS32(ctx, x, y);
+ GLuint passed = depth_test_span32(ctx, n, x, y, zptr, z, mask);
+ return passed;
+ }
}
+}
- passed = depth_test_span( ctx, n, x, y, zptr, z, mask );
- if (ctx->Driver.WriteDepthSpan) {
- /* write updated depth values into hardware Z buffer */
- assert(zptr == zbuffer);
- (*ctx->Driver.WriteDepthSpan)(ctx, n, x, y, zbuffer, mask);
- }
- return passed;
-}
+/*
+ * Do depth testing for an array of fragments using software Z buffer.
+ */
+static void
+software_depth_test_pixels16( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth z[], GLubyte mask[] )
+{
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
+ case GL_LESS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] < *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] < *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] <= *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] <= *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] >= *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] >= *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GREATER:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] > *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] > *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] != *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] != *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_EQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] == *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ if (z[i] == *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS16(ctx,x[i],y[i]);
+ *zptr = z[i];
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer or mask */
+ }
+ break;
+ case GL_NEVER:
+ /* depth test never passes */
+ MEMSET(mask, 0, n * sizeof(GLubyte));
+ break;
+ default:
+ gl_problem(ctx, "Bad depth func in software_depth_test_pixels");
+ }
+}
@@ -404,9 +906,9 @@ _mesa_depth_test_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
* Do depth testing for an array of fragments using software Z buffer.
*/
static void
-software_depth_test_pixels( GLcontext *ctx, GLuint n,
- const GLint x[], const GLint y[],
- const GLdepth z[], GLubyte mask[] )
+software_depth_test_pixels32( GLcontext *ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth z[], GLubyte mask[] )
{
/* switch cases ordered from most frequent to less frequent */
switch (ctx->Depth.Func) {
@@ -416,7 +918,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] < *zptr) {
/* pass */
*zptr = z[i];
@@ -433,7 +935,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] < *zptr) {
/* pass */
}
@@ -451,7 +953,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] <= *zptr) {
/* pass */
*zptr = z[i];
@@ -468,7 +970,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] <= *zptr) {
/* pass */
}
@@ -486,7 +988,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] >= *zptr) {
/* pass */
*zptr = z[i];
@@ -503,7 +1005,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] >= *zptr) {
/* pass */
}
@@ -521,7 +1023,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] > *zptr) {
/* pass */
*zptr = z[i];
@@ -538,7 +1040,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] > *zptr) {
/* pass */
}
@@ -556,7 +1058,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] != *zptr) {
/* pass */
*zptr = z[i];
@@ -573,7 +1075,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] != *zptr) {
/* pass */
}
@@ -591,7 +1093,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] == *zptr) {
/* pass */
*zptr = z[i];
@@ -608,7 +1110,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
if (z[i] == *zptr) {
/* pass */
}
@@ -626,7 +1128,7 @@ software_depth_test_pixels( GLcontext *ctx, GLuint n,
GLuint i;
for (i=0; i<n; i++) {
if (mask[i]) {
- GLdepth *zptr = Z_ADDRESS(ctx,x[i],y[i]);
+ GLuint *zptr = Z_ADDRESS32(ctx,x[i],y[i]);
*zptr = z[i];
}
}
@@ -894,11 +1396,14 @@ _mesa_depth_test_pixels( GLcontext *ctx,
/* update hardware Z buffer with new values */
assert(ctx->Driver.WriteDepthPixels);
- (*ctx->Driver.WriteDepthPixels)(ctx, n, x, y, z, mask );
+ (*ctx->Driver.WriteDepthPixels)(ctx, n, x, y, zbuffer, mask );
}
else {
/* software depth testing */
- software_depth_test_pixels(ctx, n, x, y, z, mask);
+ if (ctx->Visual->DepthBits <= 16)
+ software_depth_test_pixels16(ctx, n, x, y, z, mask);
+ else
+ software_depth_test_pixels32(ctx, n, x, y, z, mask);
}
}
@@ -922,14 +1427,23 @@ void
_mesa_read_depth_span_float( GLcontext* ctx,
GLuint n, GLint x, GLint y, GLfloat depth[] )
{
- const GLfloat scale = 1.0F / DEPTH_SCALE;
+ const GLfloat scale = 1.0F / ctx->Visual->DepthMaxF;
- if (ctx->DrawBuffer->Depth) {
+ if (ctx->DrawBuffer->DepthBuffer) {
/* read from software depth buffer */
- const GLdepth *zptr = Z_ADDRESS( ctx, x, y );
- GLuint i;
- for (i = 0; i < n; i++) {
- depth[i] = (GLfloat) zptr[i] * scale;
+ if (ctx->Visual->DepthBits <= 16) {
+ const GLushort *zptr = Z_ADDRESS16( ctx, x, y );
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ depth[i] = (GLfloat) zptr[i] * scale;
+ }
+ }
+ else {
+ const GLuint *zptr = Z_ADDRESS32( ctx, x, y );
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ depth[i] = (GLfloat) zptr[i] * scale;
+ }
}
}
else if (ctx->Driver.ReadDepthSpan) {
@@ -962,20 +1476,28 @@ _mesa_read_depth_span_float( GLcontext* ctx,
* This function is only called through Driver.alloc_depth_buffer.
*/
void
-_mesa_alloc_depth_buffer( GLcontext* ctx )
+_mesa_alloc_depth_buffer( GLcontext *ctx )
{
/* deallocate current depth buffer if present */
if (ctx->DrawBuffer->UseSoftwareDepthBuffer) {
- if (ctx->DrawBuffer->Depth) {
- FREE(ctx->DrawBuffer->Depth);
- ctx->DrawBuffer->Depth = NULL;
+ GLint bytesPerValue;
+
+ if (ctx->DrawBuffer->DepthBuffer) {
+ FREE(ctx->DrawBuffer->DepthBuffer);
+ ctx->DrawBuffer->DepthBuffer = NULL;
}
/* allocate new depth buffer, but don't initialize it */
- ctx->DrawBuffer->Depth = (GLdepth *) MALLOC( ctx->DrawBuffer->Width
- * ctx->DrawBuffer->Height
- * sizeof(GLdepth) );
- if (!ctx->DrawBuffer->Depth) {
+ if (ctx->Visual->DepthBits <= 16)
+ bytesPerValue = sizeof(GLushort);
+ else
+ bytesPerValue = sizeof(GLuint);
+
+ ctx->DrawBuffer->DepthBuffer = MALLOC( ctx->DrawBuffer->Width
+ * ctx->DrawBuffer->Height
+ * bytesPerValue );
+
+ if (!ctx->DrawBuffer->DepthBuffer) {
/* out of memory */
ctx->Depth.Test = GL_FALSE;
ctx->NewState |= NEW_RASTER_OPS;
@@ -993,11 +1515,11 @@ _mesa_alloc_depth_buffer( GLcontext* ctx )
* This function is only called through Driver.clear_depth_buffer.
*/
void
-_mesa_clear_depth_buffer( GLcontext* ctx )
+_mesa_clear_depth_buffer( GLcontext *ctx )
{
- GLdepth clear_value = (GLdepth) (ctx->Depth.Clear * DEPTH_SCALE);
-
- if (ctx->Visual->DepthBits==0 || !ctx->DrawBuffer->Depth || !ctx->Depth.Mask) {
+ if (ctx->Visual->DepthBits == 0
+ || !ctx->DrawBuffer->DepthBuffer
+ || !ctx->Depth.Mask) {
/* no depth buffer, or writing to it is disabled */
return;
}
@@ -1008,40 +1530,84 @@ _mesa_clear_depth_buffer( GLcontext* ctx )
if (ctx->Scissor.Enabled) {
/* only clear scissor region */
- GLint y;
- for (y=ctx->DrawBuffer->Ymin; y<=ctx->DrawBuffer->Ymax; y++) {
- GLdepth *d = Z_ADDRESS( ctx, ctx->DrawBuffer->Xmin, y );
- GLint n = ctx->DrawBuffer->Xmax - ctx->DrawBuffer->Xmin + 1;
- do {
- *d++ = clear_value;
- n--;
- } while (n);
+ if (ctx->Visual->DepthBits <= 16) {
+ const GLushort clearValue = (GLushort) (ctx->Depth.Clear * ctx->Visual->DepthMax);
+ const GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1;
+ const GLint width = ctx->DrawBuffer->Width;
+ GLushort *dRow = (GLushort *) ctx->DrawBuffer->DepthBuffer
+ + ctx->DrawBuffer->Ymin * width + ctx->DrawBuffer->Xmin;
+ GLint i, j;
+ for (i = 0; i < rows; i++) {
+ for (j = 0; j < width; j++) {
+ dRow[j] = clearValue;
+ }
+ dRow += width;
+ }
+ }
+ else {
+ const GLuint clearValue = (GLuint) (ctx->Depth.Clear * ctx->Visual->DepthMax);
+ const GLint rows = ctx->DrawBuffer->Ymax - ctx->DrawBuffer->Ymin + 1;
+ const GLint width = ctx->DrawBuffer->Width;
+ GLuint *dRow = (GLuint *) ctx->DrawBuffer->DepthBuffer
+ + ctx->DrawBuffer->Ymin * width + ctx->DrawBuffer->Xmin;
+ GLint i, j;
+ for (i = 0; i < rows; i++) {
+ for (j = 0; j < width; j++) {
+ dRow[j] = clearValue;
+ }
+ dRow += width;
+ }
}
}
else {
/* clear whole buffer */
- if (sizeof(GLdepth)==2 && (clear_value&0xff)==(clear_value>>8)) {
- /* lower and upper bytes of clear_value are same, use MEMSET */
- MEMSET( ctx->DrawBuffer->Depth, clear_value & 0xff,
- 2*ctx->DrawBuffer->Width * ctx->DrawBuffer->Height);
+ 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);
+ }
+ else {
+ GLushort *d = (GLushort *) ctx->DrawBuffer->DepthBuffer;
+ 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;
+ }
+ while (n > 0) {
+ *d++ = clearValue;
+ n--;
+ }
+ }
}
else {
- GLdepth *d = ctx->DrawBuffer->Depth;
+ /* >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] = clear_value; d[1] = clear_value;
- d[2] = clear_value; d[3] = clear_value;
- d[4] = clear_value; d[5] = clear_value;
- d[6] = clear_value; d[7] = clear_value;
- d[8] = clear_value; d[9] = clear_value;
- d[10] = clear_value; d[11] = clear_value;
- d[12] = clear_value; d[13] = clear_value;
- d[14] = clear_value; d[15] = clear_value;
+ 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++ = clear_value;
+ while (n > 0) {
+ *d++ = clearValue;
n--;
}
}
diff --git a/xc/extras/Mesa/src/depth.h b/xc/extras/Mesa/src/depth.h
index 34ce8a392..041318235 100644
--- a/xc/extras/Mesa/src/depth.h
+++ b/xc/extras/Mesa/src/depth.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"),
@@ -48,14 +48,12 @@ _mesa_DepthMask( GLboolean flag );
-
/*
- * Return the address of the Z-buffer value for window coordinate (x,y):
+ * Internal functions
*/
-#define Z_ADDRESS( CTX, X, Y ) \
- ((CTX)->DrawBuffer->Depth + (CTX)->DrawBuffer->Width * (Y) + (X))
-
+extern GLvoid *
+_mesa_zbuffer_address(GLcontext *ctx, GLint x, GLint y);
extern GLuint
diff --git a/xc/extras/Mesa/src/dlist.c b/xc/extras/Mesa/src/dlist.c
index d491db47c..cdb1a5ac3 100644
--- a/xc/extras/Mesa/src/dlist.c
+++ b/xc/extras/Mesa/src/dlist.c
@@ -2176,7 +2176,8 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units )
static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
{
- save_PolygonOffset(factor, DEPTH_SCALE * bias);
+ GET_CURRENT_CONTEXT(ctx);
+ save_PolygonOffset(factor, ctx->Visual->DepthMaxF * bias);
}
@@ -3364,10 +3365,12 @@ static void execute_list( GLcontext *ctx, GLuint list )
(MESA_VERBOSE & VERBOSE_IMMEDIATE))
gl_print_cassette( (struct immediate *) n[1].data );
- if (0)
- fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x\n",
+ if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) {
+ fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ",
IM->id,
IM->Start, IM->Count, IM->BeginState);
+ gl_print_vert_flags("orflag", IM->OrFlag);
+ }
gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
gl_execute_cassette( ctx, (struct immediate *) n[1].data );
@@ -3387,7 +3390,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
struct gl_pixelstore_attrib save = ctx->Unpack;
ctx->Unpack = _mesa_native_packing;
(*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i,
- n[3].f, n[4].f, n[5].f, n[6].f, n[7].data );
+ n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data );
ctx->Unpack = save; /* restore */
}
break;
@@ -3953,6 +3956,11 @@ _mesa_GenLists(GLsizei range )
return 0;
}
+ /*
+ * Make this an atomic operation
+ */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+
base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range);
if (base) {
/* reserve the list IDs by with empty/dummy lists */
@@ -3961,6 +3969,9 @@ _mesa_GenLists(GLsizei range )
_mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list());
}
}
+
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
return base;
}
@@ -4507,8 +4518,8 @@ _mesa_init_dlist_table( struct _glapi_table *table )
/* Not all are supported */
table->BlendColor = save_BlendColor;
table->BlendEquation = save_BlendEquation;
- table->ColorSubTable = _mesa_ColorSubTable;
- table->ColorTable = _mesa_ColorTable;
+ table->ColorSubTable = save_ColorSubTable;
+ table->ColorTable = save_ColorTable;
table->ColorTableParameterfv = _mesa_ColorTableParameterfv;
table->ColorTableParameteriv = _mesa_ColorTableParameteriv;
table->ConvolutionFilter1D = _mesa_ConvolutionFilter1D;
@@ -4788,6 +4799,7 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
((struct immediate *) n[1].data)->id,
n[2].ui,
n[3].ui);
+ gl_print_cassette( (struct immediate *) n[1].data );
break;
case OPCODE_CONTINUE:
fprintf(f,"DISPLAY-LIST-CONTINUE\n");
diff --git a/xc/extras/Mesa/src/drawpix.c b/xc/extras/Mesa/src/drawpix.c
index f89d80a70..283ca63e5 100644
--- a/xc/extras/Mesa/src/drawpix.c
+++ b/xc/extras/Mesa/src/drawpix.c
@@ -33,6 +33,7 @@
#include "feedback.h"
#include "image.h"
#include "macros.h"
+#include "mem.h"
#include "mmath.h"
#include "pixel.h"
#include "span.h"
@@ -116,13 +117,6 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
gl_update_state(ctx);
}
- /* see if device driver can do the drawpix */
- if (ctx->Driver.DrawPixels
- && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type,
- unpack, pixels)) {
- return GL_TRUE;
- }
-
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
@@ -180,7 +174,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y,
}
else {
/* setup array of fragment Z value to pass to zoom function */
- GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
assert(drawWidth < MAX_WIDTH);
for (i=0; i<drawWidth; i++)
@@ -418,7 +412,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
/* Fragment depth values */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
- GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
for (i = 0; i < drawWidth; i++) {
zspan[i] = zval;
@@ -430,7 +424,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
*/
for (row = 0; row < height; row++, y++) {
GLuint indexes[MAX_WIDTH];
- const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLvoid *source = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0);
_mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes,
type, source, &ctx->Unpack, GL_TRUE);
@@ -476,7 +470,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
GLstencil values[MAX_WIDTH];
GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
- const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack,
+ 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);
@@ -545,30 +539,23 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
/* Special case: directly write 16-bit depth values */
GLint row;
for (row = 0; row < height; row++, y++) {
- const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack,
+ GLdepth zspan[MAX_WIDTH];
+ const GLushort *zptr = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
- gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP );
+ GLint i;
+ for (i = 0; i < width; i++)
+ zspan[i] = zptr[i];
+ gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP );
}
}
- else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint)
+ else if (type==GL_UNSIGNED_INT && ctx->Visual->DepthBits == 32
&& !bias_or_scale && !zoom && ctx->Visual->RGBAflag) {
/* Special case: directly write 32-bit depth values */
- GLint i, row;
- /* Compute shift value to scale 32-bit uints down to depth values. */
- GLuint shift = 0;
- GLuint max = MAX_DEPTH;
- while ((max & 0x80000000) == 0) {
- max = max << 1;
- shift++;
- }
+ GLint row;
for (row = 0; row < height; row++, y++) {
- GLdepth zspan[MAX_WIDTH];
- const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLuint *zptr = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
- for (i=0;i<width;i++) {
- zspan[i] = zptr[i] >> shift;
- }
- gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP );
+ gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP );
}
}
else {
@@ -576,7 +563,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
GLint row;
for (row = 0; row < height; row++, y++) {
GLdepth zspan[MAX_WIDTH];
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack,
+ const GLvoid *src = _mesa_image_address(&ctx->Unpack,
pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0);
_mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src,
&ctx->Unpack, GL_TRUE );
@@ -625,7 +612,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
/* Fragment depth values */
if (ctx->Depth.Test || ctx->Fog.Enabled) {
/* fill in array of z values */
- GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE);
+ GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF);
GLint i;
for (i=0;i<width;i++) {
zspan[i] = z;
@@ -652,7 +639,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
if (width > MAX_WIDTH)
width = MAX_WIDTH;
for (row = 0; row < height; row++, y++) {
- const GLvoid *source = gl_pixel_addr_in_image(unpack,
+ const GLvoid *source = _mesa_image_address(unpack,
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);
@@ -693,6 +680,13 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
x = (GLint) (ctx->Current.RasterPos[0] + 0.5F);
y = (GLint) (ctx->Current.RasterPos[1] + 0.5F);
+ /* see if device driver can do the drawpix */
+ if (ctx->Driver.DrawPixels
+ && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type,
+ &ctx->Unpack, pixels)) {
+ return;
+ }
+
switch (format) {
case GL_STENCIL_INDEX:
draw_stencil_pixels( ctx, x, y, width, height, type, pixels );
diff --git a/xc/extras/Mesa/src/enable.c b/xc/extras/Mesa/src/enable.c
index aff6cbb50..cc81c8557 100644
--- a/xc/extras/Mesa/src/enable.c
+++ b/xc/extras/Mesa/src/enable.c
@@ -327,8 +327,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
case GL_SHARED_TEXTURE_PALETTE_EXT:
ctx->Texture.SharedPalette = state;
- if (ctx->Driver.UseGlobalTexturePalette)
- (*ctx->Driver.UseGlobalTexturePalette)( ctx, state );
break;
case GL_STENCIL_TEST:
if (state && ctx->Visual->StencilBits==0) {
@@ -452,6 +450,18 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->Array.EdgeFlag.Enabled = state;
break;
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ ctx->Depth.OcclusionTest = state;
+ ctx->NewState |= NEW_RASTER_OPS;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" );
+ return;
+ }
+ break;
+
default:
if (state) {
gl_error( ctx, GL_INVALID_ENUM, "glEnable" );
@@ -645,6 +655,17 @@ _mesa_IsEnabled( GLenum cap )
return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
case GL_EDGE_FLAG_ARRAY:
return ctx->Array.EdgeFlag.Enabled;
+
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ return ctx->Depth.OcclusionTest;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
+ return GL_FALSE;
+ }
+
default:
gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" );
return GL_FALSE;
diff --git a/xc/extras/Mesa/src/enums.c b/xc/extras/Mesa/src/enums.c
index a5b482338..946318442 100644
--- a/xc/extras/Mesa/src/enums.c
+++ b/xc/extras/Mesa/src/enums.c
@@ -768,6 +768,9 @@ enum_elt all_enums[] =
{ "GL_CLIENT_ACTIVE_TEXTURE_ARB", 0x84E1 },
{ "GL_MAX_TEXTURE_UNITS_ARB", 0x84E2 },
+ { "GL_TEXTURE_FILTER_CONTROL_EXT", 0x8500 },
+ { "GL_TEXTUER_LOD_BIAS_EXT", 0x8501 },
+
{ "GL_NORMAL_MAP_NV", 0x8511 },
{ "GL_REFLECTION_MAP_NV", 0x8512 },
diff --git a/xc/extras/Mesa/src/extensions.c b/xc/extras/Mesa/src/extensions.c
index 82ad25208..c63607676 100644
--- a/xc/extras/Mesa/src/extensions.c
+++ b/xc/extras/Mesa/src/extensions.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"),
@@ -40,7 +40,7 @@
struct extension {
struct extension *next, *prev;
- int enabled;
+ GLint enabled;
char name[MAX_EXT_NAMELEN+1];
void (*notify)( GLcontext *, GLboolean );
};
@@ -61,7 +61,7 @@ static struct { int enabled; const char *name; } default_extensions[] = {
{ DEFAULT_ON, "GL_EXT_texture3D" },
{ ALWAYS_ENABLED, "GL_MESA_window_pos" },
{ ALWAYS_ENABLED, "GL_MESA_resize_buffers" },
- { ALWAYS_ENABLED, "GL_EXT_shared_texture_palette" },
+ { 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" },
@@ -71,13 +71,30 @@ static struct { int enabled; const char *name; } default_extensions[] = {
{ ALWAYS_ENABLED, "GL_NV_texgen_reflection" },
{ DEFAULT_ON, "GL_PGI_misc_hints" },
{ DEFAULT_ON, "GL_EXT_compiled_vertex_array" },
- { DEFAULT_OFF, "GL_EXT_vertex_array_set" },
{ 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" }
};
+/*
+ * Update the boolean convenience flags in the Extensions struct.
+ */
+static void
+update_extension_flags( GLcontext *ctx )
+{
+ /* Update flags */
+ ctx->Extensions.HaveTextureEnvAdd = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add");
+ ctx->Extensions.HaveTextureLodBias = gl_extension_is_enabled(ctx, "GL_EXT_texture_lod_bias");
+ ctx->Extensions.HaveHpOcclusionTest = gl_extension_is_enabled(ctx, "GL_HP_occlusion_test");
+}
+
+
+
int gl_extensions_add( GLcontext *ctx,
int state,
const char *name,
@@ -99,21 +116,26 @@ int gl_extensions_add( GLcontext *ctx,
}
-static int set_extension( GLcontext *ctx, const char *name, GLuint state )
+/*
+ * Either enable or disable the named extension.
+ */
+static int set_extension( GLcontext *ctx, const char *name, GLint state )
{
struct extension *i;
foreach( i, ctx->Extensions.ext_list )
if (strncmp(i->name, name, MAX_EXT_NAMELEN) == 0)
break;
- if (i == ctx->Extensions.ext_list) return 1;
+ if (i == ctx->Extensions.ext_list)
+ return 1;
- if (i->enabled && !(i->enabled & ALWAYS_ENABLED))
- {
+ if (i->enabled && !(i->enabled & ALWAYS_ENABLED)) {
if (i->notify) i->notify( ctx, state );
i->enabled = state;
}
+ update_extension_flags(ctx);
+
return 0;
}
@@ -187,6 +209,7 @@ void gl_extensions_ctr( GLcontext *ctx )
default_extensions[i].name,
0 );
}
+ update_extension_flags(ctx);
}
diff --git a/xc/extras/Mesa/src/extensions.h b/xc/extras/Mesa/src/extensions.h
index 960fa0ead..644431ad8 100644
--- a/xc/extras/Mesa/src/extensions.h
+++ b/xc/extras/Mesa/src/extensions.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"),
@@ -36,15 +36,15 @@
/* Return 0 on success.
*/
-extern int gl_extensions_add( struct gl_context *ctx, int state,
+extern int gl_extensions_add( GLcontext *ctx, int state,
const char *name, void (*notify)( void ) );
-extern int gl_extensions_enable( struct gl_context *ctx, const char *name );
-extern int gl_extensions_disable( struct gl_context *ctx, const char *name );
+extern int gl_extensions_enable( GLcontext *ctx, const char *name );
+extern int gl_extensions_disable( GLcontext *ctx, const char *name );
extern GLboolean gl_extension_is_enabled( GLcontext *ctx, const char *name);
-extern void gl_extensions_dtr( struct gl_context *ctx );
-extern void gl_extensions_ctr( struct gl_context *ctx );
-extern const char *gl_extensions_get_string( struct gl_context *ctx );
+extern void gl_extensions_dtr( GLcontext *ctx );
+extern void gl_extensions_ctr( GLcontext *ctx );
+extern const char *gl_extensions_get_string( GLcontext *ctx );
#endif
diff --git a/xc/extras/Mesa/src/feedback.c b/xc/extras/Mesa/src/feedback.c
index 12565b105..ed018576a 100644
--- a/xc/extras/Mesa/src/feedback.c
+++ b/xc/extras/Mesa/src/feedback.c
@@ -132,6 +132,7 @@ void gl_feedback_vertex( GLcontext *ctx,
FEEDBACK_TOKEN( ctx, win[0] );
FEEDBACK_TOKEN( ctx, win[1] );
if (ctx->Feedback.Mask & FB_3D) {
+ printf("FB %g\n", win[2]);
FEEDBACK_TOKEN( ctx, win[2] );
}
if (ctx->Feedback.Mask & FB_4D) {
@@ -167,7 +168,7 @@ static void feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv )
win[0] = VB->Win.data[v][0];
win[1] = VB->Win.data[v][1];
- win[2] = VB->Win.data[v][2] / DEPTH_SCALE;
+ win[2] = VB->Win.data[v][2] / ctx->Visual->DepthMaxF;
win[3] = 1.0 / VB->Win.data[v][3];
if (ctx->Light.ShadeModel == GL_SMOOTH)
@@ -298,12 +299,13 @@ void gl_update_hitflag( GLcontext *ctx, GLfloat z )
void gl_select_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
{
- struct vertex_buffer *VB = ctx->VB;
+ const struct vertex_buffer *VB = ctx->VB;
if (gl_cull_triangle( ctx, v0, v1, v2, 0 )) {
- gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE );
- gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE );
- gl_update_hitflag( ctx, VB->Win.data[v2][2] / DEPTH_SCALE );
+ const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF;
+ gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs );
+ gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs );
+ gl_update_hitflag( ctx, VB->Win.data[v2][2] * zs );
}
}
@@ -311,21 +313,22 @@ void gl_select_triangle( GLcontext *ctx,
void gl_select_line( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint pv )
{
- struct vertex_buffer *VB = ctx->VB;
-
- gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE );
- gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE );
+ const struct vertex_buffer *VB = ctx->VB;
+ const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF;
+ gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs );
+ gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs );
}
void gl_select_points( GLcontext *ctx, GLuint first, GLuint last )
{
struct vertex_buffer *VB = ctx->VB;
+ const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF;
GLuint i;
for (i=first;i<=last;i++) {
if (VB->ClipMask[i]==0) {
- gl_update_hitflag( ctx, VB->Win.data[i][2] / DEPTH_SCALE);
+ gl_update_hitflag( ctx, VB->Win.data[i][2] * zs );
}
}
}
diff --git a/xc/extras/Mesa/src/fixed.h b/xc/extras/Mesa/src/fixed.h
index 3c63b9ad1..608117bd1 100644
--- a/xc/extras/Mesa/src/fixed.h
+++ b/xc/extras/Mesa/src/fixed.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,9 +24,6 @@
*/
-
-
-
#ifndef FIXED_H
#define FIXED_H
@@ -52,13 +49,4 @@ typedef int GLfixed;
#define SignedFloatToFixed(X) FloatToFixed(X)
-#if DEPTH_BITS==16
-/* use fixed-point interpolation */
-#define FixedToDepth(I) ((I) >> FIXED_SHIFT)
-#else
-/* don't really use fixed-point */
-#define FixedToDepth(I) (I)
-#endif
-
-
#endif
diff --git a/xc/extras/Mesa/src/fog.c b/xc/extras/Mesa/src/fog.c
index 1aff751c4..bac41cb1d 100644
--- a/xc/extras/Mesa/src/fog.c
+++ b/xc/extras/Mesa/src/fog.c
@@ -33,6 +33,7 @@
#include "macros.h"
#include "mmath.h"
#include "types.h"
+#include "xform.h"
#endif
@@ -105,23 +106,9 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
}
break;
case GL_FOG_START:
-#if 0
- /* Prior to OpenGL 1.1, this was an error */
- if (*params<0.0F) {
- gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_START)" );
- return;
- }
-#endif
ctx->Fog.Start = *params;
break;
case GL_FOG_END:
-#if 0
- /* Prior to OpenGL 1.1, this was an error */
- if (*params<0.0F) {
- gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_END)" );
- return;
- }
-#endif
ctx->Fog.End = *params;
break;
case GL_FOG_INDEX:
@@ -149,9 +136,13 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
typedef void (*fog_func)( struct vertex_buffer *VB, GLuint side,
GLubyte flag );
+typedef void (*fog_coord_func)( struct vertex_buffer *VB,
+ const GLvector4f *from,
+ GLubyte flag );
static fog_func fog_ci_tab[2];
static fog_func fog_rgba_tab[2];
+static fog_coord_func make_fog_coord_tab[2];
/*
* Compute the fogged color for an array of vertices.
@@ -209,6 +200,71 @@ _mesa_fog_vertices( struct vertex_buffer *VB )
}
}
+
+static void check_fog_coords( GLcontext *ctx, struct gl_pipeline_stage *d )
+{
+ d->type = 0;
+
+ if (ctx->FogMode==FOG_FRAGMENT)
+ {
+ d->type = PIPE_IMMEDIATE|PIPE_PRECALC;
+ d->inputs = VERT_OBJ_ANY;
+ d->outputs = VERT_FOG_COORD;
+ }
+}
+
+
+static void gl_make_fog_coords( struct vertex_buffer *VB )
+{
+ GLcontext *ctx = VB->ctx;
+
+ /* If full eye coords weren't required, just calculate the eye Z
+ * values.
+ */
+ if (!ctx->NeedEyeCoords) {
+ GLfloat *m = ctx->ModelView.m;
+ GLfloat plane[4];
+
+ plane[0] = m[2];
+ plane[1] = m[6];
+ plane[2] = m[10];
+ plane[3] = m[14];
+
+ gl_dotprod_tab[0][VB->ObjPtr->size](&VB->Eye,
+ 2, /* fill z coordinates */
+ VB->ObjPtr,
+ plane,
+ 0 );
+
+ make_fog_coord_tab[0]( VB, &VB->Eye, 0 );
+ }
+ else
+ {
+ make_fog_coord_tab[0]( VB, VB->EyePtr, 0 );
+ }
+}
+
+
+/* Drivers that want fog coordinates in VB->Spec[0] alpha, can substitute this
+ * stage for the default PIPE_OP_FOG pipeline stage.
+ */
+struct gl_pipeline_stage gl_fog_coord_stage = {
+ "build fog coordinates",
+ PIPE_OP_FOG,
+ PIPE_PRECALC|PIPE_IMMEDIATE,
+ 0,
+ NEW_FOG,
+ NEW_LIGHTING|NEW_RASTER_OPS|NEW_FOG|NEW_MODELVIEW,
+ 0, 0,
+ 0, 0, 0,
+ check_fog_coords,
+ gl_make_fog_coords
+};
+
+
+
+
+
/*
* Apply fog to an array of RGBA pixels.
* Input: n - number of pixels
diff --git a/xc/extras/Mesa/src/fog_tmp.h b/xc/extras/Mesa/src/fog_tmp.h
index e288a6efa..a0fa87229 100644
--- a/xc/extras/Mesa/src/fog_tmp.h
+++ b/xc/extras/Mesa/src/fog_tmp.h
@@ -23,6 +23,178 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+/* For 3.2: Add a helper function for drivers to do fog coordinate
+ * calculation. Not called from standard pipelines.
+ */
+static void TAG(make_fog_coord)( struct vertex_buffer *VB,
+ const GLvector4f *eye,
+ GLubyte flag)
+{
+ const GLcontext *ctx = VB->ctx;
+ GLfloat end = ctx->Fog.End;
+ GLubyte *cullmask = VB->CullMask + VB->Start;
+ GLfloat *v = eye->start;
+ GLuint stride = eye->stride;
+ GLuint n = VB->Count - VB->Start;
+ GLubyte (*out)[4];
+ GLfloat d;
+ GLuint i;
+
+ (void) cullmask;
+ (void) flag;
+
+ /* Use specular alpha (front side) as fog coordinate.
+ */
+ out = VB->Spec[0] + VB->Start;
+
+ if (VB->EyePtr->size > 2) {
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
+ CULLCHECK {
+ GLfloat f = (end - ABSF(v[2])) * d;
+ FLOAT_COLOR_TO_UBYTE_COLOR(out[i][3], f);
+ }
+ }
+ break;
+ case GL_EXP:
+ d = -ctx->Fog.Density;
+ for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
+ CULLCHECK {
+ GLfloat f = exp( d*ABSF(v[2]) ); /* already clamped */
+ FLOAT_COLOR_TO_UBYTE_COLOR(out[i][3], f);
+ }
+ }
+ break;
+ case GL_EXP2:
+ d = -(ctx->Fog.Density*ctx->Fog.Density);
+ for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
+ CULLCHECK {
+ GLfloat z = v[2];
+ GLfloat f = exp( d*z*z ); /* already clamped */
+ FLOAT_COLOR_TO_UBYTE_COLOR(out[i][3], f);
+ }
+ }
+ break;
+ default:
+ gl_problem(ctx, "Bad fog mode in make_fog_coord");
+ return;
+ }
+ }
+ else
+ {
+ GLubyte r = 0;
+
+ if (ctx->Fog.Mode == GL_LINEAR) {
+ GLfloat f = ctx->Fog.End * (ctx->Fog.End - ctx->Fog.Start);
+ CLAMP_FLOAT_COLOR( f );
+ f = 1.0 - f;
+ FLOAT_COLOR_TO_UBYTE_COLOR(r, f);
+ }
+
+ for (i = 0 ; i < n ; i++)
+ out[i][3] = r;
+ }
+}
+
+
+
+
+
+#if 0
+/* TODO : use fog coordinates as intermediate step in all fog
+ * calculations.
+ */
+
+static void TAG(fog_rgba_vertices)( struct vertex_buffer *VB,
+ GLuint side,
+ GLubyte flag)
+{
+ const GLcontext *ctx = VB->ctx;
+ const GLubyte rFog = ctx->Fog.ByteColor[0];
+ const GLubyte gFog = ctx->Fog.ByteColor[1];
+ const GLubyte bFog = ctx->Fog.ByteColor[2];
+ GLfloat end = ctx->Fog.End;
+ GLubyte *cullmask = VB->CullMask + VB->Start;
+ GLubyte (*fcoord)[4] = VB->SpecPtr[0]->start;
+ GLuint stride = VB->SpecPtr[0]->stride;
+ GLuint n = VB->Count - VB->Start;
+ GLubyte *in;
+ GLuint in_stride;
+ GLubyte (*out)[4];
+ GLfloat d,t;
+ GLuint i;
+
+ (void) cullmask;
+ (void) flag;
+
+ /* Get correct source and destination for fogged colors.
+ */
+ in_stride = VB->Color[side]->stride;
+ in = VB->Color[side]->start;
+ VB->Color[side] = VB->FoggedColor[side];
+ VB->ColorPtr = VB->Color[0];
+ out = (GLubyte (*)[4])VB->Color[side]->start;
+
+ FLOAT_COLOR_TO_UBYTE_COLOR( rFog, ctx->Fog.Color[0] );
+
+ for ( i = 0 ; i < n ; i++, STRIDE_F(spec, sp_stride), in += in_stride) {
+ CULLCHECK {
+ GLint fc = (GLint) spec[3], ifc = 255 - fc;
+
+ out[i][0] = (fc * in[0] + ifc * rFog) >> 8;
+ out[i][1] = (fc * in[1] + ifc * gFog) >> 8;
+ out[i][2] = (fc * in[2] + ifc * bFog) >> 8;
+ }
+ }
+}
+
+
+
+static void TAG(fog_ci_vertices)( struct vertex_buffer *VB,
+ GLuint side,
+ GLubyte flag )
+{
+ GLcontext *ctx = VB->ctx;
+
+ GLubyte *cullmask = VB->CullMask + VB->Start;
+
+ GLfloat *v = VB->EyePtr->start;
+ GLuint stride = VB->EyePtr->stride;
+ GLuint vertex_size = VB->EyePtr->size;
+ GLuint n = VB->EyePtr->count;
+
+ GLuint *in;
+ GLuint in_stride;
+ GLuint *out;
+ GLuint i;
+
+ (void) flag;
+ (void) cullmask;
+
+
+ in = VB->Index[side]->start;
+ in_stride = VB->Index[side]->stride;
+ VB->IndexPtr = VB->FoggedIndex[side];
+ out = VB->IndexPtr->start;
+
+
+ /* NOTE: the use of casts generates better/faster code for MIPS */
+ for ( i = 0; i < n ; i++, STRIDE_F(v,stride), STRIDE_UI(in,in_stride))
+ CULLCHECK {
+ GLfloat f = (fogend - ABSF(v[2])) * d;
+ f = CLAMP( f, 0.0, 1.0 );
+ *out = (GLint) ((GLfloat)(GLint) *in + (1.0F-f) * fogindex);
+ }
+}
+
+#endif
+
+
+
+
+
static void TAG(fog_rgba_vertices)( struct vertex_buffer *VB,
@@ -254,6 +426,7 @@ static void TAG(init_fog_tab)(void)
{
fog_ci_tab[IDX] = TAG(fog_ci_vertices);
fog_rgba_tab[IDX] = TAG(fog_rgba_vertices);
+ make_fog_coord_tab[IDX] = TAG(make_fog_coord);
}
#undef TAG
diff --git a/xc/extras/Mesa/src/get.c b/xc/extras/Mesa/src/get.c
index 6c5f3ef9f..f43e305e5 100644
--- a/xc/extras/Mesa/src/get.c
+++ b/xc/extras/Mesa/src/get.c
@@ -1011,8 +1011,26 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
}
break;
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = ctx->Depth.OcclusionTest;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" );
+ }
+ return;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = ctx->OcclusionResult;
+ ctx->OcclusionResult = GL_FALSE; /* reset now */
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" );
+ }
+ return;
+
default:
- printf("invalid enum: %x\n", pname);
gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" );
}
}
@@ -1974,8 +1992,26 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
}
break;
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = (GLdouble) ctx->Depth.OcclusionTest;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" );
+ }
+ return;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = (GLdouble) ctx->OcclusionResult;
+ ctx->OcclusionResult = GL_FALSE; /* reset now */
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" );
+ }
+ return;
+
default:
- printf("invalid enum: %x\n", pname);
gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" );
}
}
@@ -2914,8 +2950,26 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
gl_matrix_transposef(params, ctx->TextureMatrix[texTransformUnit].m);
break;
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = (GLfloat) ctx->Depth.OcclusionTest;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" );
+ }
+ return;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = (GLfloat) ctx->OcclusionResult;
+ ctx->OcclusionResult = GL_FALSE; /* reset now */
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" );
+ }
+ return;
+
default:
- printf("invalid enum: %x\n", pname);
gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" );
}
}
@@ -3877,8 +3931,26 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
}
break;
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = (GLint) ctx->Depth.OcclusionTest;
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" );
+ }
+ return;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ if (ctx->Extensions.HaveHpOcclusionTest) {
+ *params = (GLint) ctx->OcclusionResult;
+ ctx->OcclusionResult = GL_FALSE; /* reset now */
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" );
+ }
+ return;
+
default:
- printf("invalid enum: %x\n", pname);
gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" );
}
}
diff --git a/xc/extras/Mesa/src/glapi.c b/xc/extras/Mesa/src/glapi.c
index 5f5fc6de1..c5eea74be 100644
--- a/xc/extras/Mesa/src/glapi.c
+++ b/xc/extras/Mesa/src/glapi.c
@@ -222,354 +222,6 @@ _glapi_get_version(void)
}
-struct name_address_offset {
- const char *Name;
- GLvoid *Address;
- GLuint Offset;
-};
-
-static struct name_address_offset static_functions[1000];
-
-
-
-/*
- * Return dispatch table offset of the named static (built-in) function.
- * Return -1 if function not found.
- */
-static GLint
-get_static_proc_offset(const char *funcName)
-{
- GLuint i;
- for (i = 0; static_functions[i].Name; i++) {
- if (strcmp(static_functions[i].Name, funcName) == 0) {
- return static_functions[i].Offset;
- }
- }
- return -1;
-}
-
-
-/*
- * Return dispatch function address the named static (built-in) function.
- * Return NULL if function not found.
- */
-static GLvoid *
-get_static_proc_address(const char *funcName)
-{
- GLint i = get_static_proc_offset(funcName);
- if (i >= 0)
- return static_functions[i].Address;
- else
- return NULL;
-}
-
-
-
-/**********************************************************************
- * Extension function management.
- */
-
-
-#define MAX_EXTENSION_FUNCS 1000
-
-static struct name_address_offset ExtEntryTable[MAX_EXTENSION_FUNCS];
-static GLuint NumExtEntryPoints = 0;
-
-
-
-/*
- * Generate a dispatch function (entrypoint) which jumps through
- * the given slot number (offset) in the current dispatch table.
- * We need assembly language in order to accomplish this.
- */
-static void *
-generate_entrypoint(GLuint functionOffset)
-{
-#if defined(USE_X86_ASM)
- /*
- * This x86 code contributed by Josh Vanderhoof.
- *
- * 0: a1 10 32 54 76 movl __glapi_Dispatch,%eax
- * 00 01 02 03 04
- * 5: 85 c0 testl %eax,%eax
- * 05 06
- * 7: 74 06 je f <entrypoint+0xf>
- * 07 08
- * 9: ff a0 10 32 54 76 jmp *0x76543210(%eax)
- * 09 0a 0b 0c 0d 0e
- * f: e8 fc ff ff ff call __glapi_get_dispatch
- * 0f 10 11 12 13
- * 14: ff a0 10 32 54 76 jmp *0x76543210(%eax)
- * 14 15 16 17 18 19
- */
- static const unsigned char temp[] = {
- 0xa1, 0x00, 0x00, 0x00, 0x00,
- 0x85, 0xc0,
- 0x74, 0x06,
- 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00,
- 0xe8, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00
- };
- unsigned char *code = malloc(sizeof(temp));
- unsigned int next_insn;
- if (code) {
- memcpy(code, temp, sizeof(temp));
-
- *(unsigned int *)(code + 0x01) = (unsigned int)&_glapi_Dispatch;
- *(unsigned int *)(code + 0x0b) = (unsigned int)functionOffset * 4;
- next_insn = (unsigned int)(code + 0x14);
- *(unsigned int *)(code + 0x10) = (unsigned int)_glapi_get_dispatch - next_insn;
- *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4;
- }
- return code;
-#else
- return NULL;
-#endif
-}
-
-
-
-/*
- * Add a new extension function entrypoint.
- * Return: GL_TRUE = success or GL_FALSE = failure
- */
-GLboolean
-_glapi_add_entrypoint(const char *funcName, GLuint offset)
-{
- /* Make sure we don't try to add a new entrypoint after someone
- * has already called _glapi_get_dispatch_table_size()! If that's
- * happened the caller's information will now be out of date.
- */
- assert(!GetSizeCalled);
-
- /* first check if the named function is already statically present */
- {
- GLint index = get_static_proc_offset(funcName);
- if (index >= 0) {
- return (GLboolean) (index == offset); /* bad offset! */
- }
- }
-
- {
- /* make sure this offset/name pair is legal */
- const char *name = _glapi_get_proc_name(offset);
- if (name && strcmp(name, funcName) != 0)
- return GL_FALSE; /* bad name! */
- }
-
- {
- /* be sure index and name match known data */
- GLuint i;
- for (i = 0; i < NumExtEntryPoints; i++) {
- if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
- /* function already registered with api */
- if (ExtEntryTable[i].Offset == offset) {
- return GL_TRUE; /* offsets match */
- }
- else {
- return GL_FALSE; /* bad offset! */
- }
- }
- }
-
- /* make sure we have space */
- if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS) {
- return GL_FALSE;
- }
- else {
- void *entrypoint = generate_entrypoint(offset);
- if (!entrypoint)
- return GL_FALSE;
-
- ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName);
- ExtEntryTable[NumExtEntryPoints].Offset = offset;
- ExtEntryTable[NumExtEntryPoints].Address = entrypoint;
- NumExtEntryPoints++;
-
- if (offset > MaxDispatchOffset)
- MaxDispatchOffset = offset;
-
- return GL_TRUE; /* success */
- }
- }
-
- /* should never get here, but play it safe */
- return GL_FALSE;
-}
-
-
-
-#if 0000 /* prototype code for dynamic extension slot allocation */
-
-static int NextFreeOffset = 409; /*XXX*/
-#define MAX_DISPATCH_TABLE_SIZE 1000
-
-/*
- * Dynamically allocate a dispatch slot for an extension entrypoint
- * and generate the assembly language dispatch stub.
- * Return the dispatch offset for the function or -1 if no room or error.
- */
-GLint
-_glapi_add_entrypoint2(const char *funcName)
-{
- int offset;
-
- /* first see if extension func is already known */
- offset = _glapi_get_proc_offset(funcName);
- if (offset >= 0)
- return offset;
-
- if (NumExtEntryPoints < MAX_EXTENSION_FUNCS
- && NextFreeOffset < MAX_DISPATCH_TABLE_SIZE) {
- void *entryPoint;
- offset = NextFreeOffset;
- entryPoint = generate_entrypoint(offset);
- if (entryPoint) {
- NextFreeOffset++;
- ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName);
- ExtEntryTable[NumExtEntryPoints].Offset = offset;
- ExtEntryTable[NumExtEntryPoints].Address = entryPoint;
- NumExtEntryPoints++;
- return offset;
- }
- }
- return -1;
-}
-
-#endif
-
-
-
-/*
- * Return offset of entrypoint for named function within dispatch table.
- */
-GLint
-_glapi_get_proc_offset(const char *funcName)
-{
- /* search extension functions first */
- GLint i;
- for (i = 0; i < NumExtEntryPoints; i++) {
- if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
- return ExtEntryTable[i].Offset;
- }
- }
-
- /* search static functions */
- return get_static_proc_offset(funcName);
-}
-
-
-
-/*
- * Return entrypoint for named function.
- */
-const GLvoid *
-_glapi_get_proc_address(const char *funcName)
-{
- /* search extension functions first */
- GLint i;
- for (i = 0; i < NumExtEntryPoints; i++) {
- if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
- return ExtEntryTable[i].Address;
- }
- }
-
- /* search static functions */
- return get_static_proc_address(funcName);
-}
-
-
-
-
-/*
- * Return the name of the function at the given dispatch offset.
- * This is only intended for debugging.
- */
-const char *
-_glapi_get_proc_name(GLuint offset)
-{
- const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset);
- GLuint i;
- for (i = 0; i < n; i++) {
- if (static_functions[i].Offset == offset)
- return static_functions[i].Name;
- }
-
- /* search added extension functions */
- for (i = 0; i < NumExtEntryPoints; i++) {
- if (ExtEntryTable[i].Offset == offset) {
- return ExtEntryTable[i].Name;
- }
- }
- return NULL;
-}
-
-
-
-/*
- * Make sure there are no NULL pointers in the given dispatch table.
- * Intented for debugging purposes.
- */
-void
-_glapi_check_table(const struct _glapi_table *table)
-{
- const GLuint entries = _glapi_get_dispatch_table_size();
- const void **tab = (const void **) table;
- GLuint i;
- for (i = 1; i < entries; i++) {
- assert(tab[i]);
- }
-
-#ifdef DEBUG
- /* Do some spot checks to be sure that the dispatch table
- * slots are assigned correctly.
- */
- {
- GLuint BeginOffset = _glapi_get_proc_offset("glBegin");
- char *BeginFunc = (char*) &table->Begin;
- GLuint offset = (BeginFunc - (char *) table) / sizeof(void *);
- assert(BeginOffset == _gloffset_Begin);
- assert(BeginOffset == offset);
- }
- {
- GLuint viewportOffset = _glapi_get_proc_offset("glViewport");
- char *viewportFunc = (char*) &table->Viewport;
- GLuint offset = (viewportFunc - (char *) table) / sizeof(void *);
- assert(viewportOffset == _gloffset_Viewport);
- assert(viewportOffset == offset);
- }
- {
- GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer");
- char *VertexPointerFunc = (char*) &table->VertexPointer;
- GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *);
- assert(VertexPointerOffset == _gloffset_VertexPointer);
- assert(VertexPointerOffset == offset);
- }
- {
- GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax");
- char *ResetMinMaxFunc = (char*) &table->ResetMinmax;
- GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *);
- assert(ResetMinMaxOffset == _gloffset_ResetMinmax);
- assert(ResetMinMaxOffset == offset);
- }
- {
- GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor");
- char *blendColorFunc = (char*) &table->BlendColor;
- GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *);
- assert(blendColorOffset == _gloffset_BlendColor);
- assert(blendColorOffset == offset);
- }
- {
- GLuint istextureOffset = _glapi_get_proc_offset("glIsTextureEXT");
- char *istextureFunc = (char*) &table->IsTextureEXT;
- GLuint offset = (istextureFunc - (char *) table) / sizeof(void *);
- assert(istextureOffset == _gloffset_IsTextureEXT);
- assert(istextureOffset == offset);
- }
-#endif
-}
-
-
/*
* For each entry in static_functions[] which use this function
* we should implement a dispatch function in glapitemp.h and
@@ -581,6 +233,12 @@ static int NotImplemented(void)
}
+struct name_address_offset {
+ const char *Name;
+ GLvoid *Address;
+ GLuint Offset;
+};
+
static struct name_address_offset static_functions[] = {
/* GL 1.1 */
@@ -1522,3 +1180,345 @@ static struct name_address_offset static_functions[] = {
{ NULL, NULL } /* end of list marker */
};
+
+
+/*
+ * Return dispatch table offset of the named static (built-in) function.
+ * Return -1 if function not found.
+ */
+static GLint
+get_static_proc_offset(const char *funcName)
+{
+ GLuint i;
+ for (i = 0; static_functions[i].Name; i++) {
+ if (strcmp(static_functions[i].Name, funcName) == 0) {
+ return static_functions[i].Offset;
+ }
+ }
+ return -1;
+}
+
+
+/*
+ * Return dispatch function address the named static (built-in) function.
+ * Return NULL if function not found.
+ */
+static GLvoid *
+get_static_proc_address(const char *funcName)
+{
+ GLint i = get_static_proc_offset(funcName);
+ if (i >= 0)
+ return static_functions[i].Address;
+ else
+ return NULL;
+}
+
+
+
+/**********************************************************************
+ * Extension function management.
+ */
+
+
+#define MAX_EXTENSION_FUNCS 1000
+
+static struct name_address_offset ExtEntryTable[MAX_EXTENSION_FUNCS];
+static GLuint NumExtEntryPoints = 0;
+
+
+
+/*
+ * Generate a dispatch function (entrypoint) which jumps through
+ * the given slot number (offset) in the current dispatch table.
+ * We need assembly language in order to accomplish this.
+ */
+static void *
+generate_entrypoint(GLuint functionOffset)
+{
+#if defined(USE_X86_ASM)
+ /*
+ * This x86 code contributed by Josh Vanderhoof.
+ *
+ * 0: a1 10 32 54 76 movl __glapi_Dispatch,%eax
+ * 00 01 02 03 04
+ * 5: 85 c0 testl %eax,%eax
+ * 05 06
+ * 7: 74 06 je f <entrypoint+0xf>
+ * 07 08
+ * 9: ff a0 10 32 54 76 jmp *0x76543210(%eax)
+ * 09 0a 0b 0c 0d 0e
+ * f: e8 fc ff ff ff call __glapi_get_dispatch
+ * 0f 10 11 12 13
+ * 14: ff a0 10 32 54 76 jmp *0x76543210(%eax)
+ * 14 15 16 17 18 19
+ */
+ static const unsigned char temp[] = {
+ 0xa1, 0x00, 0x00, 0x00, 0x00,
+ 0x85, 0xc0,
+ 0x74, 0x06,
+ 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00,
+ 0xe8, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00
+ };
+ unsigned char *code = malloc(sizeof(temp));
+ unsigned int next_insn;
+ if (code) {
+ memcpy(code, temp, sizeof(temp));
+
+ *(unsigned int *)(code + 0x01) = (unsigned int)&_glapi_Dispatch;
+ *(unsigned int *)(code + 0x0b) = (unsigned int)functionOffset * 4;
+ next_insn = (unsigned int)(code + 0x14);
+ *(unsigned int *)(code + 0x10) = (unsigned int)_glapi_get_dispatch - next_insn;
+ *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4;
+ }
+ return code;
+#else
+ return NULL;
+#endif
+}
+
+
+
+/*
+ * Add a new extension function entrypoint.
+ * Return: GL_TRUE = success or GL_FALSE = failure
+ */
+GLboolean
+_glapi_add_entrypoint(const char *funcName, GLuint offset)
+{
+ /* Make sure we don't try to add a new entrypoint after someone
+ * has already called _glapi_get_dispatch_table_size()! If that's
+ * happened the caller's information will now be out of date.
+ */
+ assert(!GetSizeCalled);
+
+ /* first check if the named function is already statically present */
+ {
+ GLint index = get_static_proc_offset(funcName);
+ if (index >= 0) {
+ return (GLboolean) (index == offset); /* bad offset! */
+ }
+ }
+
+ {
+ /* make sure this offset/name pair is legal */
+ const char *name = _glapi_get_proc_name(offset);
+ if (name && strcmp(name, funcName) != 0)
+ return GL_FALSE; /* bad name! */
+ }
+
+ {
+ /* be sure index and name match known data */
+ GLuint i;
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
+ /* function already registered with api */
+ if (ExtEntryTable[i].Offset == offset) {
+ return GL_TRUE; /* offsets match */
+ }
+ else {
+ return GL_FALSE; /* bad offset! */
+ }
+ }
+ }
+
+ /* make sure we have space */
+ if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS) {
+ return GL_FALSE;
+ }
+ else {
+ void *entrypoint = generate_entrypoint(offset);
+ if (!entrypoint)
+ return GL_FALSE;
+
+ ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName);
+ ExtEntryTable[NumExtEntryPoints].Offset = offset;
+ ExtEntryTable[NumExtEntryPoints].Address = entrypoint;
+ NumExtEntryPoints++;
+
+ if (offset > MaxDispatchOffset)
+ MaxDispatchOffset = offset;
+
+ return GL_TRUE; /* success */
+ }
+ }
+
+ /* should never get here, but play it safe */
+ return GL_FALSE;
+}
+
+
+
+#if 0000 /* prototype code for dynamic extension slot allocation */
+
+static int NextFreeOffset = 409; /*XXX*/
+#define MAX_DISPATCH_TABLE_SIZE 1000
+
+/*
+ * Dynamically allocate a dispatch slot for an extension entrypoint
+ * and generate the assembly language dispatch stub.
+ * Return the dispatch offset for the function or -1 if no room or error.
+ */
+GLint
+_glapi_add_entrypoint2(const char *funcName)
+{
+ int offset;
+
+ /* first see if extension func is already known */
+ offset = _glapi_get_proc_offset(funcName);
+ if (offset >= 0)
+ return offset;
+
+ if (NumExtEntryPoints < MAX_EXTENSION_FUNCS
+ && NextFreeOffset < MAX_DISPATCH_TABLE_SIZE) {
+ void *entryPoint;
+ offset = NextFreeOffset;
+ entryPoint = generate_entrypoint(offset);
+ if (entryPoint) {
+ NextFreeOffset++;
+ ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName);
+ ExtEntryTable[NumExtEntryPoints].Offset = offset;
+ ExtEntryTable[NumExtEntryPoints].Address = entryPoint;
+ NumExtEntryPoints++;
+ return offset;
+ }
+ }
+ return -1;
+}
+
+#endif
+
+
+
+/*
+ * Return offset of entrypoint for named function within dispatch table.
+ */
+GLint
+_glapi_get_proc_offset(const char *funcName)
+{
+ /* search extension functions first */
+ GLint i;
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
+ return ExtEntryTable[i].Offset;
+ }
+ }
+
+ /* search static functions */
+ return get_static_proc_offset(funcName);
+}
+
+
+
+/*
+ * Return entrypoint for named function.
+ */
+const GLvoid *
+_glapi_get_proc_address(const char *funcName)
+{
+ /* search extension functions first */
+ GLint i;
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (strcmp(ExtEntryTable[i].Name, funcName) == 0) {
+ return ExtEntryTable[i].Address;
+ }
+ }
+
+ /* search static functions */
+ return get_static_proc_address(funcName);
+}
+
+
+
+
+/*
+ * Return the name of the function at the given dispatch offset.
+ * This is only intended for debugging.
+ */
+const char *
+_glapi_get_proc_name(GLuint offset)
+{
+ const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (static_functions[i].Offset == offset)
+ return static_functions[i].Name;
+ }
+
+ /* search added extension functions */
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (ExtEntryTable[i].Offset == offset) {
+ return ExtEntryTable[i].Name;
+ }
+ }
+ return NULL;
+}
+
+
+
+/*
+ * Make sure there are no NULL pointers in the given dispatch table.
+ * Intented for debugging purposes.
+ */
+void
+_glapi_check_table(const struct _glapi_table *table)
+{
+ const GLuint entries = _glapi_get_dispatch_table_size();
+ const void **tab = (const void **) table;
+ GLuint i;
+ for (i = 1; i < entries; i++) {
+ assert(tab[i]);
+ }
+
+#ifdef DEBUG
+ /* Do some spot checks to be sure that the dispatch table
+ * slots are assigned correctly.
+ */
+ {
+ GLuint BeginOffset = _glapi_get_proc_offset("glBegin");
+ char *BeginFunc = (char*) &table->Begin;
+ GLuint offset = (BeginFunc - (char *) table) / sizeof(void *);
+ assert(BeginOffset == _gloffset_Begin);
+ assert(BeginOffset == offset);
+ }
+ {
+ GLuint viewportOffset = _glapi_get_proc_offset("glViewport");
+ char *viewportFunc = (char*) &table->Viewport;
+ GLuint offset = (viewportFunc - (char *) table) / sizeof(void *);
+ assert(viewportOffset == _gloffset_Viewport);
+ assert(viewportOffset == offset);
+ }
+ {
+ GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer");
+ char *VertexPointerFunc = (char*) &table->VertexPointer;
+ GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *);
+ assert(VertexPointerOffset == _gloffset_VertexPointer);
+ assert(VertexPointerOffset == offset);
+ }
+ {
+ GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax");
+ char *ResetMinMaxFunc = (char*) &table->ResetMinmax;
+ GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *);
+ assert(ResetMinMaxOffset == _gloffset_ResetMinmax);
+ assert(ResetMinMaxOffset == offset);
+ }
+ {
+ GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor");
+ char *blendColorFunc = (char*) &table->BlendColor;
+ GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *);
+ assert(blendColorOffset == _gloffset_BlendColor);
+ assert(blendColorOffset == offset);
+ }
+ {
+ GLuint istextureOffset = _glapi_get_proc_offset("glIsTextureEXT");
+ char *istextureFunc = (char*) &table->IsTextureEXT;
+ GLuint offset = (istextureFunc - (char *) table) / sizeof(void *);
+ assert(istextureOffset == _gloffset_IsTextureEXT);
+ assert(istextureOffset == offset);
+ }
+#endif
+}
+
+
+
+
diff --git a/xc/extras/Mesa/src/glapinoop.c b/xc/extras/Mesa/src/glapinoop.c
index a522e193e..94d4a11f1 100644
--- a/xc/extras/Mesa/src/glapinoop.c
+++ b/xc/extras/Mesa/src/glapinoop.c
@@ -684,7 +684,7 @@ void *__glapi_noop_table[] = {
(void *) NoOpFogCoordfEXT,
(void *) NoOpFogCoordfvEXT,
(void *) NoOpFogCoorddEXT,
- (void *) NoOpFogCoorddEXT,
+ (void *) NoOpFogCoorddvEXT,
(void *) NoOpFogCoordPointerEXT,
/* GL_EXT_color_table */
(void *) NoOpGetColorTableEXT,
diff --git a/xc/extras/Mesa/src/hash.c b/xc/extras/Mesa/src/hash.c
index 7990bc528..456b7f3d2 100644
--- a/xc/extras/Mesa/src/hash.c
+++ b/xc/extras/Mesa/src/hash.c
@@ -202,17 +202,21 @@ void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
/*
* Return the key of the "first" entry in the hash table.
- * By calling this function until zero is returned we can get
- * the keys of all entries in the table.
+ * This is used in the course of deleting all display lists when
+ * a context is destroyed.
*/
GLuint _mesa_HashFirstEntry(const struct _mesa_HashTable *table)
{
GLuint pos;
assert(table);
+ _glthread_LOCK_MUTEX(table->Mutex);
for (pos=0; pos < TABLE_SIZE; pos++) {
- if (table->Table[pos])
+ if (table->Table[pos]) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return table->Table[pos]->Key;
+ }
}
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return 0;
}
@@ -245,8 +249,10 @@ void _mesa_HashPrint(const struct _mesa_HashTable *table)
GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint numKeys)
{
GLuint maxKey = ~((GLuint) 0);
+ _glthread_LOCK_MUTEX(table->Mutex);
if (maxKey - numKeys > table->MaxKey) {
/* the quick solution */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return table->MaxKey + 1;
}
else {
@@ -264,11 +270,13 @@ GLuint _mesa_HashFindFreeKeyBlock(const struct _mesa_HashTable *table, GLuint nu
/* this key not in use, check if we've found enough */
freeCount++;
if (freeCount == numKeys) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return freeStart;
}
}
}
/* cannot allocate a block of numKeys consecutive keys */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
return 0;
}
}
diff --git a/xc/extras/Mesa/src/hint.c b/xc/extras/Mesa/src/hint.c
index 210138d2b..2d7427f01 100644
--- a/xc/extras/Mesa/src/hint.c
+++ b/xc/extras/Mesa/src/hint.c
@@ -52,78 +52,84 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode )
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glHint %s %d\n", gl_lookup_enum_by_nr(target), mode);
- switch (target) {
- case GL_FOG_HINT:
- ctx->Hint.Fog = mode;
- break;
- case GL_LINE_SMOOTH_HINT:
- ctx->Hint.LineSmooth = mode;
- break;
- case GL_PERSPECTIVE_CORRECTION_HINT:
- ctx->Hint.PerspectiveCorrection = mode;
- break;
- case GL_POINT_SMOOTH_HINT:
- ctx->Hint.PointSmooth = mode;
- break;
- case GL_POLYGON_SMOOTH_HINT:
- ctx->Hint.PolygonSmooth = mode;
- break;
- case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
- case GL_STRICT_DEPTHFUNC_HINT_PGI:
- break;
- case GL_STRICT_LIGHTING_HINT_PGI:
- ctx->Hint.StrictLighting = mode;
- break;
- case GL_STRICT_SCISSOR_HINT_PGI:
- case GL_FULL_STIPPLE_HINT_PGI:
- case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI:
- case GL_NATIVE_GRAPHICS_END_HINT_PGI:
- case GL_CONSERVE_MEMORY_HINT_PGI:
- case GL_RECLAIM_MEMORY_HINT_PGI:
- break;
- case GL_ALWAYS_FAST_HINT_PGI:
- if (mode) {
- ctx->Hint.AllowDrawWin = GL_TRUE;
- ctx->Hint.AllowDrawSpn = GL_FALSE;
- ctx->Hint.AllowDrawMem = GL_FALSE;
- } else {
- ctx->Hint.AllowDrawWin = GL_TRUE;
- ctx->Hint.AllowDrawSpn = 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.AllowDrawMem = GL_TRUE;
- break;
- case GL_ALLOW_DRAW_OBJ_HINT_PGI:
- break;
- case GL_ALLOW_DRAW_WIN_HINT_PGI:
- ctx->Hint.AllowDrawWin = mode;
- break;
- case GL_ALLOW_DRAW_SPN_HINT_PGI:
- ctx->Hint.AllowDrawSpn = mode;
- break;
- case GL_ALLOW_DRAW_MEM_HINT_PGI:
- ctx->Hint.AllowDrawMem = mode;
- break;
- case GL_CLIP_NEAR_HINT_PGI:
- case GL_CLIP_FAR_HINT_PGI:
- case GL_WIDE_LINE_HINT_PGI:
- case GL_BACK_NORMALS_HINT_PGI:
- case GL_NATIVE_GRAPHICS_HANDLE_PGI:
- break;
-
- /* GL_EXT_clip_volume_hint */
- case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
- ctx->Hint.ClipVolumeClipping = mode;
- break;
-
- default:
- gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" );
+ if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
+ gl_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
return GL_FALSE;
}
+
+ switch (target) {
+ case GL_FOG_HINT:
+ ctx->Hint.Fog = mode;
+ break;
+ case GL_LINE_SMOOTH_HINT:
+ ctx->Hint.LineSmooth = mode;
+ break;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+ ctx->Hint.PerspectiveCorrection = mode;
+ break;
+ case GL_POINT_SMOOTH_HINT:
+ ctx->Hint.PointSmooth = mode;
+ break;
+ case GL_POLYGON_SMOOTH_HINT:
+ ctx->Hint.PolygonSmooth = mode;
+ break;
+ case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
+ case GL_STRICT_DEPTHFUNC_HINT_PGI:
+ break;
+ case GL_STRICT_LIGHTING_HINT_PGI:
+ ctx->Hint.StrictLighting = mode;
+ break;
+ case GL_STRICT_SCISSOR_HINT_PGI:
+ case GL_FULL_STIPPLE_HINT_PGI:
+ case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI:
+ case GL_NATIVE_GRAPHICS_END_HINT_PGI:
+ case GL_CONSERVE_MEMORY_HINT_PGI:
+ case GL_RECLAIM_MEMORY_HINT_PGI:
+ break;
+ case GL_ALWAYS_FAST_HINT_PGI:
+ if (mode) {
+ ctx->Hint.AllowDrawWin = GL_TRUE;
+ ctx->Hint.AllowDrawSpn = GL_FALSE;
+ ctx->Hint.AllowDrawMem = GL_FALSE;
+ } else {
+ ctx->Hint.AllowDrawWin = GL_TRUE;
+ ctx->Hint.AllowDrawSpn = 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.AllowDrawMem = GL_TRUE;
+ break;
+ case GL_ALLOW_DRAW_OBJ_HINT_PGI:
+ break;
+ case GL_ALLOW_DRAW_WIN_HINT_PGI:
+ ctx->Hint.AllowDrawWin = mode;
+ break;
+ case GL_ALLOW_DRAW_SPN_HINT_PGI:
+ ctx->Hint.AllowDrawSpn = mode;
+ break;
+ case GL_ALLOW_DRAW_MEM_HINT_PGI:
+ ctx->Hint.AllowDrawMem = mode;
+ break;
+ case GL_CLIP_NEAR_HINT_PGI:
+ case GL_CLIP_FAR_HINT_PGI:
+ case GL_WIDE_LINE_HINT_PGI:
+ case GL_BACK_NORMALS_HINT_PGI:
+ case GL_NATIVE_GRAPHICS_HANDLE_PGI:
+ break;
+
+ /* GL_EXT_clip_volume_hint */
+ case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
+ ctx->Hint.ClipVolumeClipping = mode;
+ break;
+
+ default:
+ gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" );
+ return GL_FALSE;
+ }
+
ctx->NewState |= NEW_ALL; /* just to be safe */
if (ctx->Driver.Hint) {
@@ -143,6 +149,11 @@ _mesa_HintPGI( GLenum target, GLint mode )
if (MESA_VERBOSE & VERBOSE_API)
fprintf(stderr, "glHintPGI %s %d\n", gl_lookup_enum_by_nr(target), mode);
+ if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
+ gl_error(ctx, GL_INVALID_ENUM, "glHintPGI(mode)");
+ return;
+ }
+
switch (target) {
case GL_PREFER_DOUBLEBUFFER_HINT_PGI:
case GL_STRICT_DEPTHFUNC_HINT_PGI:
diff --git a/xc/extras/Mesa/src/image.c b/xc/extras/Mesa/src/image.c
index 16c8d4921..3cd4a8312 100644
--- a/xc/extras/Mesa/src/image.c
+++ b/xc/extras/Mesa/src/image.c
@@ -46,7 +46,7 @@
* from within display lists we have to be sure to set the current
* unpacking params to these values!
*/
-struct gl_pixelstore_attrib _mesa_native_packing = {
+const struct gl_pixelstore_attrib _mesa_native_packing = {
1, /* Alignment */
0, /* RowLength */
0, /* SkipPixels */
@@ -62,7 +62,8 @@ struct gl_pixelstore_attrib _mesa_native_packing = {
/*
* Flip the 8 bits in each byte of the given array.
*/
-void gl_flip_bytes( GLubyte *p, GLuint n )
+static void
+flip_bytes( GLubyte *p, GLuint n )
{
register GLuint i, a, b;
@@ -84,7 +85,8 @@ void gl_flip_bytes( GLubyte *p, GLuint n )
/*
* Flip the order of the 2 bytes in each word in the given array.
*/
-void gl_swap2( GLushort *p, GLuint n )
+void
+_mesa_swap2( GLushort *p, GLuint n )
{
register GLuint i;
@@ -98,7 +100,8 @@ void gl_swap2( GLushort *p, GLuint n )
/*
* Flip the order of the 4 bytes in each word in the given array.
*/
-void gl_swap4( GLuint *p, GLuint n )
+void
+_mesa_swap4( GLuint *p, GLuint n )
{
register GLuint i, a, b;
@@ -120,7 +123,7 @@ void gl_swap4( GLuint *p, GLuint n )
* Return 0 if GL_BITMAP.
* Return -1 if invalid type enum.
*/
-GLint gl_sizeof_type( GLenum type )
+GLint _mesa_sizeof_type( GLenum type )
{
switch (type) {
case GL_BITMAP:
@@ -146,10 +149,10 @@ GLint gl_sizeof_type( GLenum type )
/*
- * Same as gl_sizeof_packed_type() but we also accept the
+ * Same as _mesa_sizeof_packed_type() but we also accept the
* packed pixel format datatypes.
*/
-GLint gl_sizeof_packed_type( GLenum type )
+GLint _mesa_sizeof_packed_type( GLenum type )
{
switch (type) {
case GL_BITMAP:
@@ -203,7 +206,7 @@ GLint gl_sizeof_packed_type( GLenum type )
* Return the number of components in a GL enum pixel type.
* Return -1 if bad format.
*/
-GLint gl_components_in_format( GLenum format )
+GLint _mesa_components_in_format( GLenum format )
{
switch (format) {
case GL_COLOR_INDEX:
@@ -243,9 +246,9 @@ GLint gl_components_in_format( GLenum format )
* Return bytes per pixel for given format and type
* Return -1 if bad format or type.
*/
-GLint gl_bytes_per_pixel( GLenum format, GLenum type )
+GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
{
- GLint comps = gl_components_in_format( format );
+ GLint comps = _mesa_components_in_format( format );
if (comps < 0)
return -1;
@@ -301,7 +304,8 @@ GLint gl_bytes_per_pixel( GLenum format, GLenum type )
* Test if the given pixel format and type are legal.
* Return GL_TRUE for legal, GL_FALSE for illegal.
*/
-GLboolean gl_is_legal_format_and_type( GLenum format, GLenum type )
+GLboolean
+_mesa_is_legal_format_and_type( GLenum format, GLenum type )
{
switch (format) {
case GL_COLOR_INDEX:
@@ -399,10 +403,11 @@ GLboolean gl_is_legal_format_and_type( GLenum format, GLenum type )
* row, column - location of pixel in the image
* Return: address of pixel at (image,row,column) in image or NULL if error.
*/
-GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image, GLsizei width,
- GLsizei height, GLenum format, GLenum type,
- GLint img, GLint row, GLint column )
+GLvoid *
+_mesa_image_address( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image, GLsizei width,
+ GLsizei height, GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
{
GLint alignment; /* 1, 2 or 4 */
GLint pixels_per_row;
@@ -437,13 +442,13 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing,
GLint bytes_per_image;
/* Compute bytes per component */
- bytes_per_comp = gl_sizeof_packed_type( type );
+ bytes_per_comp = _mesa_sizeof_packed_type( type );
if (bytes_per_comp<0) {
return NULL;
}
/* Compute number of components per pixel */
- comp_per_pixel = gl_components_in_format( format );
+ comp_per_pixel = _mesa_components_in_format( format );
if (comp_per_pixel<0 && type != GL_BITMAP) {
return NULL;
}
@@ -462,7 +467,7 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing,
/* Non-BITMAP data */
GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image;
- bytes_per_pixel = gl_bytes_per_pixel( format, type );
+ bytes_per_pixel = _mesa_bytes_per_pixel( format, type );
/* The pixel type and format should have been error checked earlier */
assert(bytes_per_pixel > 0);
@@ -489,25 +494,66 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing,
/*
- * Unpack a 32x32 pixel polygon stipple from user memory using the
- * current pixel unpack settings.
+ * Compute the stride between image rows (in bytes) for the given
+ * pixel packing parameters and image width, format and type.
*/
-void gl_unpack_polygon_stipple( const GLcontext *ctx,
- const GLubyte *pattern, GLuint dest[32] )
+GLint
+_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLenum format, GLenum type )
{
- GLint i;
- for (i = 0; i < 32; i++) {
- GLubyte *src = (GLubyte *) gl_pixel_addr_in_image( &ctx->Unpack, pattern,
- 32, 32, GL_COLOR_INDEX, GL_BITMAP, 0, i, 0 );
- dest[i] = (src[0] << 24)
- | (src[1] << 16)
- | (src[2] << 8)
- | (src[3] );
+ ASSERT(packing);
+ if (type == GL_BITMAP) {
+ /* BITMAP data */
+ if (packing->RowLength == 0) {
+ GLint bytes = (width + 7) / 8;
+ return bytes;
+ }
+ else {
+ GLint bytes = (packing->RowLength + 7) / 8;
+ return bytes;
+ }
}
+ else {
+ /* Non-BITMAP data */
+ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
+ if (bytesPerPixel <= 0)
+ return -1; /* error */
+ if (packing->RowLength == 0) {
+ GLint bytes = bytesPerPixel * width;
+ return bytes;
+ }
+ else {
+ GLint bytes = bytesPerPixel * packing->RowLength;
+ return bytes;
+ }
+ }
+}
- /* Bit flipping within each byte */
- if (ctx->Unpack.LsbFirst) {
- gl_flip_bytes( (GLubyte *) dest, 32 * 4 );
+
+
+/*
+ * Unpack a 32x32 pixel polygon stipple from user memory using the
+ * current pixel unpack settings.
+ */
+void
+_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
+ const struct gl_pixelstore_attrib *unpacking )
+{
+ GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap( 32, 32, pattern, unpacking );
+ if (ptrn) {
+ /* Convert pattern from GLubytes to GLuints and handle big/little
+ * endian differences
+ */
+ GLubyte *p = ptrn;
+ GLint i;
+ for (i = 0; i < 32; i++) {
+ dest[i] = (p[0] << 24)
+ | (p[1] << 16)
+ | (p[2] << 8)
+ | (p[3] );
+ p += 4;
+ }
+ FREE(ptrn);
}
}
@@ -517,24 +563,23 @@ void gl_unpack_polygon_stipple( const GLcontext *ctx,
* Pack polygon stipple into user memory given current pixel packing
* settings.
*/
-void gl_pack_polygon_stipple( const GLcontext *ctx,
- const GLuint pattern[32],
- GLubyte *dest )
+void
+_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
+ const struct gl_pixelstore_attrib *packing )
{
+ /* Convert pattern from GLuints to GLubytes to handle big/little
+ * endian differences.
+ */
+ GLubyte ptrn[32*4];
GLint i;
for (i = 0; i < 32; i++) {
- GLubyte *dst = (GLubyte *) gl_pixel_addr_in_image( &ctx->Pack, dest,
- 32, 32, GL_COLOR_INDEX, GL_BITMAP, 0, i, 0 );
- dst[0] = (pattern[i] >> 24) & 0xff;
- dst[1] = (pattern[i] >> 16) & 0xff;
- dst[2] = (pattern[i] >> 8) & 0xff;
- dst[3] = (pattern[i] ) & 0xff;
-
- /* Bit flipping within each byte */
- if (ctx->Pack.LsbFirst) {
- gl_flip_bytes( (GLubyte *) dst, 4 );
- }
+ ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff);
+ ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff);
+ ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff);
+ ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff);
}
+
+ _mesa_pack_bitmap(32, 32, ptrn, dest, packing);
}
@@ -554,11 +599,12 @@ void gl_pack_polygon_stipple( const GLcontext *ctx,
* packing - pixel packing parameters
* applyTransferOps - apply scale/bias/lookup-table ops?
*/
-void gl_pack_rgba_span( const GLcontext *ctx,
- GLuint n, CONST GLubyte rgba[][4],
- GLenum format, GLenum type, GLvoid *destination,
- const struct gl_pixelstore_attrib *packing,
- GLboolean applyTransferOps )
+void
+_mesa_pack_rgba_span( const GLcontext *ctx,
+ GLuint n, CONST GLubyte rgba[][4],
+ GLenum format, GLenum type, GLvoid *destination,
+ const struct gl_pixelstore_attrib *packing,
+ GLboolean applyTransferOps )
{
applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag);
@@ -586,7 +632,7 @@ void gl_pack_rgba_span( const GLcontext *ctx,
const GLfloat gscale = 1.0F / 255.0F;
const GLfloat bscale = 1.0F / 255.0F;
const GLfloat ascale = 1.0F / 255.0F;
- const GLint comps = gl_components_in_format(format);
+ const GLint comps = _mesa_components_in_format(format);
GLuint i;
assert(n <= MAX_WIDTH);
@@ -691,7 +737,7 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
}
break;
@@ -763,7 +809,7 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
}
break;
@@ -836,10 +882,10 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, n * comps);
+ _mesa_swap2( (GLushort *) dst, n * comps);
}
}
break;
@@ -911,10 +957,10 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, n * comps );
+ _mesa_swap2( (GLushort *) dst, n * comps );
}
}
break;
@@ -987,10 +1033,10 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, n * comps );
+ _mesa_swap4( (GLuint *) dst, n * comps );
}
}
break;
@@ -1063,10 +1109,10 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, n * comps );
+ _mesa_swap4( (GLuint *) dst, n * comps );
}
}
break;
@@ -1139,10 +1185,10 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem(ctx, "bad format in gl_pack_rgba_span\n");
+ gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, n * comps );
+ _mesa_swap4( (GLuint *) dst, n * comps );
}
}
break;
@@ -1347,7 +1393,7 @@ void gl_pack_rgba_span( const GLcontext *ctx,
}
break;
default:
- gl_problem( ctx, "bad type in gl_pack_rgba_span" );
+ gl_problem( ctx, "bad type in _mesa_pack_rgba_span" );
}
}
}
@@ -1515,12 +1561,12 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
for (i = 0; i < n; i++) {
GLfloat value = s[i];
SWAP4BYTE(value);
- indexes[i] = value;
+ indexes[i] = (GLuint) value;
}
}
else {
for (i = 0; i < n; i++)
- indexes[i] = s[i];
+ indexes[i] = (GLuint) s[i];
}
}
break;
@@ -2155,7 +2201,7 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
}
}
else if (dstFormat == srcFormat) {
- GLint comps = gl_components_in_format(srcFormat);
+ GLint comps = _mesa_components_in_format(srcFormat);
assert(comps > 0);
MEMCPY( dest, source, n * comps * sizeof(GLubyte) );
return;
@@ -2170,7 +2216,7 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx,
GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex;
GLint dstLuminanceIndex, dstIntensityIndex;
- dstComponents = gl_components_in_format( dstFormat );
+ dstComponents = _mesa_components_in_format( dstFormat );
/* source & dest image formats should have been error checked by now */
assert(dstComponents > 0);
@@ -2643,9 +2689,10 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest,
/* clamp depth values to [0,1] and convert from floats to integers */
{
+ const GLfloat zs = ctx->Visual->DepthMaxF;
GLuint i;
for (i = 0; i < n; i++) {
- dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * DEPTH_SCALE);
+ dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * zs);
}
}
@@ -2679,8 +2726,8 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
compsPerRow = 0;
}
else {
- const GLint bytesPerPixel = gl_bytes_per_pixel(format, type);
- const GLint components = gl_components_in_format(format);
+ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
+ const GLint components = _mesa_components_in_format(format);
GLint bytesPerComp;
if (bytesPerPixel <= 0 || components <= 0)
return NULL; /* bad format or type. generate error later */
@@ -2703,18 +2750,18 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth,
dst = destBuffer;
for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) {
- const GLvoid *src = gl_pixel_addr_in_image(unpack, pixels,
+ const GLvoid *src = _mesa_image_address(unpack, pixels,
width, height, format, type, img, row, 0);
MEMCPY(dst, src, bytesPerRow);
/* byte flipping/swapping */
if (flipBytes) {
- gl_flip_bytes((GLubyte *) dst, bytesPerRow);
+ flip_bytes((GLubyte *) dst, bytesPerRow);
}
else if (swap2) {
- gl_swap2((GLushort*) dst, compsPerRow);
+ _mesa_swap2((GLushort*) dst, compsPerRow);
}
else if (swap4) {
- gl_swap4((GLuint*) dst, compsPerRow);
+ _mesa_swap4((GLuint*) dst, compsPerRow);
}
dst += bytesPerRow;
}
@@ -2748,9 +2795,9 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
width_in_bytes = CEILING( width, 8 );
dst = buffer;
for (row = 0; row < height; row++) {
- GLubyte *src = gl_pixel_addr_in_image( packing, pixels, width, height,
- GL_COLOR_INDEX, GL_BITMAP,
- 0, row, 0 );
+ GLubyte *src = _mesa_image_address( packing, pixels, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 0, row, 0 );
if (!src) {
FREE(buffer);
return NULL;
@@ -2759,7 +2806,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
if (packing->SkipPixels == 0) {
MEMCPY( dst, src, width_in_bytes );
if (packing->LsbFirst) {
- gl_flip_bytes( dst, width_in_bytes );
+ flip_bytes( dst, width_in_bytes );
}
}
else {
@@ -2825,3 +2872,94 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
return buffer;
}
+
+
+/*
+ * Pack bitmap data.
+ */
+void
+_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
+ GLubyte *dest, const struct gl_pixelstore_attrib *packing )
+{
+ GLint row, width_in_bytes;
+ const GLubyte *src;
+
+ if (!source)
+ return;
+
+ width_in_bytes = CEILING( width, 8 );
+ src = source;
+ for (row = 0; row < height; row++) {
+ GLubyte *dst = _mesa_image_address( packing, dest, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 0, row, 0 );
+ if (!dst)
+ return;
+
+ if (packing->SkipPixels == 0) {
+ MEMCPY( dst, src, width_in_bytes );
+ if (packing->LsbFirst) {
+ flip_bytes( dst, width_in_bytes );
+ }
+ }
+ else {
+ /* handling SkipPixels is a bit tricky (no pun intended!) */
+ GLint i;
+ if (packing->LsbFirst) {
+ GLubyte srcMask = 1 << (packing->SkipPixels & 0x7);
+ GLubyte dstMask = 128;
+ const GLubyte *s = src;
+ GLubyte *d = dst;
+ *d = 0;
+ for (i = 0; i < width; i++) {
+ if (*s & srcMask) {
+ *d |= dstMask;
+ }
+ if (srcMask == 128) {
+ srcMask = 1;
+ s++;
+ }
+ else {
+ srcMask = srcMask << 1;
+ }
+ if (dstMask == 1) {
+ dstMask = 128;
+ d++;
+ *d = 0;
+ }
+ else {
+ dstMask = dstMask >> 1;
+ }
+ }
+ }
+ else {
+ GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7);
+ GLubyte dstMask = 128;
+ const GLubyte *s = src;
+ GLubyte *d = dst;
+ *d = 0;
+ for (i = 0; i < width; i++) {
+ if (*s & srcMask) {
+ *d |= dstMask;
+ }
+ if (srcMask == 1) {
+ srcMask = 128;
+ s++;
+ }
+ else {
+ srcMask = srcMask >> 1;
+ }
+ if (dstMask == 1) {
+ dstMask = 128;
+ d++;
+ *d = 0;
+ }
+ else {
+ dstMask = dstMask >> 1;
+ }
+ }
+ }
+ }
+ src += width_in_bytes;
+ }
+}
diff --git a/xc/extras/Mesa/src/image.h b/xc/extras/Mesa/src/image.h
index 84f104422..cbe0926da 100644
--- a/xc/extras/Mesa/src/image.h
+++ b/xc/extras/Mesa/src/image.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"),
@@ -31,53 +31,59 @@
#include "types.h"
-extern struct gl_pixelstore_attrib _mesa_native_packing;
+extern const struct gl_pixelstore_attrib _mesa_native_packing;
-extern void gl_flip_bytes( GLubyte *p, GLuint n );
+extern void
+_mesa_swap2( GLushort *p, GLuint n );
+extern void
+_mesa_swap4( GLuint *p, GLuint n );
-extern void gl_swap2( GLushort *p, GLuint n );
+extern GLint
+_mesa_sizeof_type( GLenum type );
-extern void gl_swap4( GLuint *p, GLuint n );
+extern GLint
+_mesa_sizeof_packed_type( GLenum type );
+extern GLint
+_mesa_components_in_format( GLenum format );
-extern GLint gl_sizeof_type( GLenum type );
+extern GLint
+_mesa_bytes_per_pixel( GLenum format, GLenum type );
-extern GLint gl_sizeof_packed_type( GLenum type );
+extern GLboolean
+_mesa_is_legal_format_and_type( GLenum format, GLenum type );
-extern GLint gl_components_in_format( GLenum format );
-extern GLint gl_bytes_per_pixel( GLenum format, GLenum type );
+extern GLvoid *
+_mesa_image_address( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image, GLsizei width,
+ GLsizei height, GLenum format, GLenum type,
+ GLint img, GLint row, GLint column );
-extern GLboolean gl_is_legal_format_and_type( GLenum format, GLenum type );
-
-extern GLvoid *
-gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing,
- const GLvoid *image, GLsizei width,
- GLsizei height, GLenum format, GLenum type,
- GLint img, GLint row, GLint column );
+extern GLint
+_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLenum format, GLenum type );
extern void
-gl_unpack_polygon_stipple( const GLcontext *ctx,
- const GLubyte *pattern,
- GLuint dest[32] );
+_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
+ const struct gl_pixelstore_attrib *unpacking );
extern void
-gl_pack_polygon_stipple( const GLcontext *ctx,
- const GLuint pattern[32],
- GLubyte *dest );
+_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
+ const struct gl_pixelstore_attrib *packing );
extern void
-gl_pack_rgba_span( const GLcontext *ctx,
- GLuint n, CONST GLubyte rgba[][4],
- GLenum format, GLenum type, GLvoid *dest,
- const struct gl_pixelstore_attrib *packing,
- GLboolean applyTransferOps );
+_mesa_pack_rgba_span( const GLcontext *ctx,
+ GLuint n, CONST GLubyte rgba[][4],
+ GLenum format, GLenum type, GLvoid *dest,
+ const struct gl_pixelstore_attrib *packing,
+ GLboolean applyTransferOps );
extern void
@@ -122,5 +128,9 @@ extern GLvoid *
_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
const struct gl_pixelstore_attrib *packing );
+extern void
+_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source,
+ GLubyte *dest, const struct gl_pixelstore_attrib *packing );
+
#endif
diff --git a/xc/extras/Mesa/src/interp_tmp.h b/xc/extras/Mesa/src/interp_tmp.h
index 2678ed609..2133629bc 100644
--- a/xc/extras/Mesa/src/interp_tmp.h
+++ b/xc/extras/Mesa/src/interp_tmp.h
@@ -23,14 +23,43 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#define INTERP_UBYTE( out, t, a, b ) { \
+ GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a); \
+ GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b); \
+ GLfloat fo = LINTERP(t, fa, fb); \
+ FLOAT_COLOR_TO_UBYTE_COLOR(out, fo); \
+}
+
+#if 1
+
+#define INTERP_RGBA(nr, t, out, a, b) { \
+ int i; \
+ for (i = 0; i < nr; i++) { \
+ GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \
+ GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \
+ GLfloat fo = LINTERP(t, fa, fb); \
+ FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \
+ } \
+}
+#else
+
+#define INTERP_RGBA(nr, t, out, a, b) { \
+ int n; \
+ const GLuint ti = FloatToInt(t*256.0F); \
+ const GLubyte *Ib = (const GLubyte *)&a[0]; \
+ const GLubyte *Jb = (const GLubyte *)&b[0]; \
+ GLubyte *Ob = (GLubyte *)&out[0]; \
+ \
+ for (n = 0 ; n < nr ; n++) \
+ Ob[n] = (GLubyte) (Ib[n] + ((ti * (Jb[n] - Ib[n]))/256)); \
+}
+#endif
+
+
static void NAME( struct vertex_buffer *VB,
GLuint dst, GLfloat t, GLuint in, GLuint out )
{
-#if (IND & CLIP_RGBA0)
- GLfloat col[3][4];
-#endif
-
(void) VB;
(void) dst;
(void) t;
@@ -38,36 +67,44 @@ static void NAME( struct vertex_buffer *VB,
(void) out;
#if (IND & CLIP_RGBA0)
- UBYTE_RGBA_TO_FLOAT_RGBA(col[1], VB->Color[0]->data[in]);
- UBYTE_RGBA_TO_FLOAT_RGBA(col[2], VB->Color[0]->data[out]);
- INTERP_SZ( t, col, 0, 1, 2, 4 );
- FLOAT_RGBA_TO_UBYTE_RGBA(VB->Color[0]->data[dst], col[0]);
+ INTERP_RGBA( 4, t,
+ VB->Color[0]->data[dst],
+ VB->Color[0]->data[in],
+ VB->Color[0]->data[out] );
#endif
#if (IND & CLIP_RGBA1)
if (VB->ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
- UBYTE_RGBA_TO_FLOAT_RGBA(col[1], VB->Color[1]->data[in]);
- UBYTE_RGBA_TO_FLOAT_RGBA(col[2], VB->Color[1]->data[out]);
- INTERP_SZ( t, col, 0, 1, 2, 4 );
- FLOAT_RGBA_TO_UBYTE_RGBA(VB->Color[1]->data[dst], col[0]);
+ INTERP_RGBA( 4, t,
+ VB->Color[1]->data[dst],
+ VB->Color[1]->data[in],
+ VB->Color[1]->data[out] );
}
if (VB->ctx->TriangleCaps & DD_SEPERATE_SPECULAR)
{
- UBYTE_RGBA_TO_FLOAT_RGBA(col[1], VB->Spec[0][in]);
- UBYTE_RGBA_TO_FLOAT_RGBA(col[2], VB->Spec[0][out]);
- INTERP_SZ( t, col, 0, 1, 2, 4 );
- FLOAT_RGBA_TO_UBYTE_RGBA(VB->Spec[0][dst], col[0]);
+ INTERP_RGBA( 3, t,
+ VB->Spec[0][dst],
+ VB->Spec[0][in],
+ VB->Spec[0][out] );
if (VB->ctx->TriangleCaps & DD_TRI_LIGHT_TWOSIDE) {
- UBYTE_RGBA_TO_FLOAT_RGBA(col[1], VB->Spec[1][in]);
- UBYTE_RGBA_TO_FLOAT_RGBA(col[2], VB->Spec[1][out]);
- INTERP_SZ( t, col, 0, 1, 2, 4 );
- FLOAT_RGBA_TO_UBYTE_RGBA(VB->Spec[1][dst], col[0]);
+ INTERP_RGBA( 3, t,
+ VB->Spec[1][dst],
+ VB->Spec[1][in],
+ VB->Spec[1][out] );
}
}
#endif
+#if (IND & CLIP_FOG_COORD)
+ {
+ GLubyte a = VB->Spec[0][in][3], b = VB->Spec[0][out][3];
+ INTERP_UBYTE( VB->Spec[0][dst][3], t, a, b );
+ }
+#endif
+
+
#if (IND & CLIP_INDEX0)
VB->IndexPtr->data[dst] = (GLuint) (GLint)
LINTERP( t,
diff --git a/xc/extras/Mesa/src/lines.c b/xc/extras/Mesa/src/lines.c
index 1b075e25f..c97e8ee92 100644
--- a/xc/extras/Mesa/src/lines.c
+++ b/xc/extras/Mesa/src/lines.c
@@ -57,6 +57,8 @@ _mesa_LineWidth( GLfloat width )
ctx->TriangleCaps &= ~DD_LINE_WIDTH;
if (width != 1.0) ctx->TriangleCaps |= DD_LINE_WIDTH;
ctx->NewState |= NEW_RASTER_OPS;
+ if (ctx->Driver.LineWidth)
+ (*ctx->Driver.LineWidth)(ctx, width);
}
}
@@ -70,6 +72,9 @@ _mesa_LineStipple( GLint factor, GLushort pattern )
ctx->Line.StippleFactor = CLAMP( factor, 1, 256 );
ctx->Line.StipplePattern = pattern;
ctx->NewState |= NEW_RASTER_OPS;
+
+ if (ctx->Driver.LineStipple)
+ ctx->Driver.LineStipple( ctx, factor, pattern );
}
@@ -1023,8 +1028,7 @@ void gl_set_line_function( GLcontext *ctx )
else {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* Width==1, non-stippled, smooth-shaded */
- if (ctx->Depth.Test
- || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
+ if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
if (rgbmode)
ctx->Driver.LineFunc = smooth_rgba_z_line;
else
@@ -1039,8 +1043,7 @@ void gl_set_line_function( GLcontext *ctx )
}
else {
/* Width==1, non-stippled, flat-shaded */
- if (ctx->Depth.Test
- || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) {
+ if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) {
if (rgbmode)
ctx->Driver.LineFunc = flat_rgba_z_line;
else
diff --git a/xc/extras/Mesa/src/linetemp.h b/xc/extras/Mesa/src/linetemp.h
index 9d74f33c5..898107266 100644
--- a/xc/extras/Mesa/src/linetemp.h
+++ b/xc/extras/Mesa/src/linetemp.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/linetemp.h,v 1.7 2000/02/18 12:18:44 tsi Exp $ */
+
/*
* Line Rasterizer Template
@@ -51,6 +51,10 @@
* PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
* Y==0 at bottom of screen and increases upward.
*
+ * Similarly, for direct depth buffer access, this type is used for depth
+ * buffer addressing:
+ * DEPTH_TYPE - either GLushort or GLuint
+ *
* Optionally, one may provide one-time setup code
* SETUP_CODE - code which is to be executed once per line
*
@@ -84,8 +88,14 @@
GLint xstep, ystep;
#endif
#ifdef INTERP_Z
- GLint z0, z1, dz, zPtrXstep, zPtrYstep;
- GLdepth *zPtr;
+ GLint z0, z1, dz;
+ const GLint depthBits = ctx->Visual->DepthBits;
+ const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+# define FixedToDepth(F) ((F) >> fixedToDepthShift)
+# ifdef DEPTH_TYPE
+ GLint zPtrXstep, zPtrYstep;
+ DEPTH_TYPE *zPtr;
+# endif
#endif
#ifdef INTERP_RGB
GLfixed r0 = IntToFixed(VB->ColorPtr->data[vert0][0]);
@@ -109,7 +119,7 @@
#endif
#ifdef INTERP_INDEX
GLint i0 = VB->IndexPtr->data[vert0] << 8;
- GLint di = (GLint) (VB->IndexPtr->data[vert1] << 8)-i0;
+ GLint di = (GLint) (VB->IndexPtr->data[vert1] << 8) - i0;
#endif
#ifdef INTERP_ST
GLfixed s0 = FloatToFixed(VB->TexCoord[vert0][0] * S_SCALE);
@@ -209,14 +219,17 @@
#endif
#ifdef INTERP_Z
- zPtr = Z_ADDRESS(ctx,x0,y0);
-# if DEPTH_BITS==16
+# ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, x0, y0);
+# endif
+ if (depthBits <= 16) {
z0 = FloatToFixed(VB->Win.data[vert0][2]);
z1 = FloatToFixed(VB->Win.data[vert1][2]);
-# else
+ }
+ else {
z0 = (int) VB->Win.data[vert0][2];
z1 = (int) VB->Win.data[vert1][2];
-# endif
+ }
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0);
@@ -227,8 +240,8 @@
#ifdef INTERP_XY
xstep = -1;
#endif
-#ifdef INTERP_Z
- zPtrXstep = -((GLint)sizeof(GLdepth));
+#if defined(INTERP_Z) && defined(DEPTH_TYPE)
+ zPtrXstep = -((GLint)sizeof(DEPTH_TYPE));
#endif
#ifdef PIXEL_ADDRESS
pixelXstep = -((GLint)sizeof(PIXEL_TYPE));
@@ -238,8 +251,8 @@
#ifdef INTERP_XY
xstep = 1;
#endif
-#ifdef INTERP_Z
- zPtrXstep = ((GLint)sizeof(GLdepth));
+#if defined(INTERP_Z) && defined(DEPTH_TYPE)
+ zPtrXstep = ((GLint)sizeof(DEPTH_TYPE));
#endif
#ifdef PIXEL_ADDRESS
pixelXstep = ((GLint)sizeof(PIXEL_TYPE));
@@ -251,8 +264,8 @@
#ifdef INTERP_XY
ystep = -1;
#endif
-#ifdef INTERP_Z
- zPtrYstep = -ctx->DrawBuffer->Width * ((GLint)sizeof(GLdepth));
+#if defined(INTERP_Z) && defined(DEPTH_TYPE)
+ zPtrYstep = -ctx->DrawBuffer->Width * ((GLint)sizeof(DEPTH_TYPE));
#endif
#ifdef PIXEL_ADDRESS
pixelYstep = BYTES_PER_ROW;
@@ -262,8 +275,8 @@
#ifdef INTERP_XY
ystep = 1;
#endif
-#ifdef INTERP_Z
- zPtrYstep = ctx->DrawBuffer->Width * ((GLint)sizeof(GLdepth));
+#if defined(INTERP_Z) && defined(DEPTH_TYPE)
+ zPtrYstep = ctx->DrawBuffer->Width * ((GLint)sizeof(DEPTH_TYPE));
#endif
#ifdef PIXEL_ADDRESS
pixelYstep = -(BYTES_PER_ROW);
@@ -328,11 +341,7 @@
if (ctx->Line.StipplePattern & m) {
#endif
#ifdef INTERP_Z
-# if DEPTH_BITS==16
- GLdepth Z = FixedToInt(z0);
-# else
- GLdepth Z = z0;
-# endif
+ GLdepth Z = FixedToDepth(z0);
#endif
#ifdef INTERP_INDEX
GLint I = i0 >> 8;
@@ -371,7 +380,9 @@
x0 += xstep;
#endif
#ifdef INTERP_Z
- zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep);
+# ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep);
+# endif
z0 += dz;
#endif
#ifdef INTERP_RGB
@@ -417,8 +428,8 @@
#ifdef INTERP_XY
y0 += ystep;
#endif
-#ifdef INTERP_Z
- zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep);
+#if defined(INTERP_Z) && defined(DEPTH_TYPE)
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep);
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep);
@@ -480,11 +491,7 @@
if (ctx->Line.StipplePattern & m) {
#endif
#ifdef INTERP_Z
-# if DEPTH_BITS==16
- GLdepth Z = FixedToInt(z0);
-# else
- GLdepth Z = z0;
-# endif
+ GLdepth Z = FixedToDepth(z0);
#endif
#ifdef INTERP_INDEX
GLint I = i0 >> 8;
@@ -523,7 +530,9 @@
y0 += ystep;
#endif
#ifdef INTERP_Z
- zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrYstep);
+# ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep);
+# endif
z0 += dz;
#endif
#ifdef INTERP_RGB
@@ -569,8 +578,8 @@
#ifdef INTERP_XY
x0 += xstep;
#endif
-#ifdef INTERP_Z
- zPtr = (GLdepth *) ((GLubyte*) zPtr + zPtrXstep);
+#if defined(INTERP_Z) && defined(DEPTH_TYPE)
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep);
#endif
#ifdef PIXEL_ADDRESS
pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
@@ -592,6 +601,7 @@
#undef INTERP_INDEX
#undef PIXEL_ADDRESS
#undef PIXEL_TYPE
+#undef DEPTH_TYPE
#undef BYTES_PER_ROW
#undef SETUP_CODE
#undef PLOT
@@ -600,3 +610,4 @@
#undef CLIP_HACK
#undef STIPPLE
#undef WIDE
+#undef FixedToDepth
diff --git a/xc/extras/Mesa/src/lnaatemp.h b/xc/extras/Mesa/src/lnaatemp.h
index 43923e851..f09c74ef1 100644
--- a/xc/extras/Mesa/src/lnaatemp.h
+++ b/xc/extras/Mesa/src/lnaatemp.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/lnaatemp.h,v 1.7 2000/02/18 12:18:45 tsi Exp $ */
+
/*
* Antialiased Line Rasterizer Template
@@ -61,22 +61,25 @@
GLint dy = y1 - y0;
GLint xStep, yStep;
GLint z0, z1;
-#ifdef INTERP_RGBA
+ const GLint depthBits = ctx->Visual->DepthBits;
+ const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+#define FixedToDepth(F) ((F) >> fixedToDepthShift)
+#if INTERP_RGBA
GLfixed fr, fg, fb, fa; /* fixed-pt RGBA */
GLfixed dfr, dfg, dfb, dfa; /* fixed-pt RGBA deltas */
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
GLfixed fsr, fsg, fsb; /* fixed-pt specular RGBA */
GLfixed dfsr, dfsg, dfsb; /* fixed-pt specular RGBA deltas */
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
GLfixed fi, dfi;
#endif
-#if defined(INTERP_STUV0) || defined(INTERP_STUV1)
+#if INTERP_STUV0 || INTERP_STUV1
GLfloat invw0 = VB->Win.data[vert0][3];
GLfloat invw1 = VB->Win.data[vert1][3];
#endif
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
/* h denotes hyperbolic */
GLfloat hs0 = invw0 * VB->TexCoordPtr[0]->data[vert0][0];
GLfloat dhs = invw1 * VB->TexCoordPtr[0]->data[vert1][0] - hs0;
@@ -85,7 +88,7 @@
GLfloat hu0 = 0, dhu = 0;
GLfloat hv0 = invw0, dhv = invw1 - invw0;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
GLfloat hs01 = invw0 * VB->TexCoordPtr[1]->data[vert0][0];
GLfloat dhs1 = invw1 * VB->TexCoordPtr[1]->data[vert1][0] - hs01;
GLfloat ht01 = invw0 * VB->TexCoordPtr[1]->data[vert0][1];
@@ -97,15 +100,16 @@
if (dx == 0 && dy == 0)
return;
-#if DEPTH_BITS==16
- z0 = FloatToFixed(VB->Win.data[vert0][2]);
- z1 = FloatToFixed(VB->Win.data[vert1][2]);
-#else
- z0 = (int) VB->Win.data[vert0][2];
- z1 = (int) VB->Win.data[vert1][2];
-#endif
+ if (depthBits <= 16) {
+ z0 = FloatToFixed(VB->Win.data[vert0][2]);
+ z1 = FloatToFixed(VB->Win.data[vert1][2]);
+ }
+ else {
+ z0 = (int) VB->Win.data[vert0][2];
+ z1 = (int) VB->Win.data[vert1][2];
+ }
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
if (VB->TexCoordPtr[0]->size > 2) {
hu0 = invw0 * VB->TexCoordPtr[0]->data[vert0][2];
dhu = invw1 * VB->TexCoordPtr[0]->data[vert1][2] - hu0;
@@ -116,7 +120,7 @@
}
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
if (VB->TexCoordPtr[1]->size > 2) {
hu01 = invw0 * VB->TexCoordPtr[1]->data[vert0][2];
dhu1 = invw1 * VB->TexCoordPtr[1]->data[vert1][2] - hu01;
@@ -127,7 +131,7 @@
}
#endif
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
fr = IntToFixed(VB->ColorPtr->data[vert0][0]);
fg = IntToFixed(VB->ColorPtr->data[vert0][1]);
@@ -142,7 +146,7 @@
dfr = dfg = dfb = dfa = 0;
}
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
fsr = IntToFixed(VB->Specular[vert0][0]);
fsg = IntToFixed(VB->Specular[vert0][1]);
@@ -155,7 +159,7 @@
dfsr = dfsg = dfsb = 0;
}
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
if (ctx->Light.ShadeModel == GL_SMOOTH) {
fi = IntToFixed(VB->IndexPtr->data[vert0]);
}
@@ -193,11 +197,10 @@
GLint i;
GLint x = x0;
GLfloat y = VB->Win.data[vert0][1];
- GLfloat yStep = (VB->Win.data[vert1][1] - y) / (GLfloat) dx;
- GLint dz = (z1 - z0) / dx;
- GLfloat invDx = 1.0F / dx;
- (void) invDx;
-#ifdef INTERP_RGBA
+ const GLfloat invDx = 1.0F / dx;
+ GLfloat yStep = (VB->Win.data[vert1][1] - y) * invDx;
+ GLint dz = (GLint) ((z1 - z0) * invDx);
+#if INTERP_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
dfr = (IntToFixed(VB->ColorPtr->data[vert1][0]) - fr) * invDx;
dfg = (IntToFixed(VB->ColorPtr->data[vert1][1]) - fg) * invDx;
@@ -205,25 +208,31 @@
dfa = (IntToFixed(VB->ColorPtr->data[vert1][3]) - fa) * invDx;
}
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
dfsr = (IntToFixed(VB->Specular[vert1][0]) - fsr) * invDx;
dfsg = (IntToFixed(VB->Specular[vert1][1]) - fsg) * invDx;
dfsb = (IntToFixed(VB->Specular[vert1][2]) - fsb) * invDx;
}
#endif
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
dhs *= invDx;
dht *= invDx;
dhu *= invDx;
dhv *= invDx;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
dhs1 *= invDx;
dht1 *= invDx;
dhu1 *= invDx;
dhv1 *= invDx;
#endif
+#if INTERP_INDEX
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) * invDx;
+ }
+#endif
+
for (i = 0; i < dx; i++) {
if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) {
@@ -232,37 +241,33 @@
GLint yTopi = (GLint) yTop;
GLint yBoti = (GLint) yBot;
GLint iy;
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
GLubyte red = FixedToInt(fr);
GLubyte green = FixedToInt(fg);
GLubyte blue = FixedToInt(fb);
GLubyte alpha = FixedToInt(fa);
GLint coverage;
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
GLubyte specRed = FixedToInt(fsr);
GLubyte specGreen = FixedToInt(fsg);
GLubyte specBlue = FixedToInt(fsb);
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
GLuint index = FixedToInt(fi) & 0xfffffff0;
GLuint coverage;
#endif
-#if DEPTH_BITS==16
- GLdepth z = FixedToInt(z0);
-#else
- GLdepth z = z0;
-#endif
+ GLdepth z = FixedToDepth(z0);
ASSERT(yBoti <= yTopi);
{
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
GLfloat invQ = 1.0F / hv0;
GLfloat s = hs0 * invQ;
GLfloat t = ht0 * invQ;
GLfloat u = hu0 * invQ;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
GLfloat invQ1 = 1.0F / hv01;
GLfloat s1 = hs01 * invQ1;
GLfloat t1 = ht01 * invQ1;
@@ -270,30 +275,30 @@
#endif
/* bottom pixel of swipe */
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
coverage = (GLint) (alpha * (1.0F - (yBot - yBoti)));
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
coverage = (GLuint) (15.0F * (1.0F - (yBot - yBoti)));
#endif
PLOT(x, yBoti);
yBoti++;
/* top pixel of swipe */
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
coverage = (GLint) (alpha * (yTop - yTopi));
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
coverage = (GLuint) (15.0F * (yTop - yTopi));
#endif
PLOT(x, yTopi);
yTopi--;
/* pixels between top and bottom with 100% coverage */
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
coverage = alpha;
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
coverage = 15;
#endif
for (iy = yBoti; iy <= yTopi; iy++) {
@@ -307,30 +312,30 @@
x += xStep;
y += yStep;
z0 += dz;
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
fr += dfr;
fg += dfg;
fb += dfb;
fa += dfa;
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
fsr += dfsr;
fsg += dfsg;
fsb += dfsb;
#endif
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
hs0 += dhs;
ht0 += dht;
hu0 += dhu;
hv0 += dhv;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
hs01 += dhs1;
ht01 += dht1;
hu01 += dhu1;
hv01 += dhv1;
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
fi += dfi;
#endif
@@ -343,11 +348,10 @@
GLint i;
GLint y = y0;
GLfloat x = VB->Win.data[vert0][0];
- GLfloat xStep = (VB->Win.data[vert1][0] - x) / (GLfloat) dy;
- GLint dz = (z1 - z0) / dy;
- GLfloat invDy = 1.0F / dy;
- (void) invDy;
-#ifdef INTERP_RGBA
+ const GLfloat invDy = 1.0F / dy;
+ GLfloat xStep = (VB->Win.data[vert1][0] - x) * invDy;
+ GLint dz = (GLint) ((z1 - z0) * invDy);
+#if INTERP_RGBA
if (ctx->Light.ShadeModel == GL_SMOOTH) {
dfr = (IntToFixed(VB->ColorPtr->data[vert1][0]) - fr) * invDy;
dfg = (IntToFixed(VB->ColorPtr->data[vert1][1]) - fg) * invDy;
@@ -355,28 +359,28 @@
dfa = (IntToFixed(VB->ColorPtr->data[vert1][3]) - fa) * invDy;
}
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
if (ctx->Light.ShadeModel == GL_SMOOTH) {
dfsr = (IntToFixed(VB->Specular[vert1][0]) - fsr) * invDy;
dfsg = (IntToFixed(VB->Specular[vert1][1]) - fsg) * invDy;
dfsb = (IntToFixed(VB->Specular[vert1][2]) - fsb) * invDy;
}
#endif
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
dhs *= invDy;
dht *= invDy;
dhu *= invDy;
dhv *= invDy;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
dhs1 *= invDy;
dht1 *= invDy;
dhu1 *= invDy;
dhv1 *= invDy;
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
if (ctx->Light.ShadeModel == GL_SMOOTH) {
- dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) / dy;
+ dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) * invDy;
}
#endif
for (i = 0; i < dy; i++) {
@@ -386,38 +390,34 @@
GLint xRighti = (GLint) xRight;
GLint xLefti = (GLint) xLeft;
GLint ix;
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
GLubyte red = FixedToInt(fr);
GLubyte green = FixedToInt(fg);
GLubyte blue = FixedToInt(fb);
GLubyte alpha = FixedToInt(fa);
GLint coverage;
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
GLubyte specRed = FixedToInt(fsr);
GLubyte specGreen = FixedToInt(fsg);
GLubyte specBlue = FixedToInt(fsb);
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
GLuint index = FixedToInt(fi) & 0xfffffff0;
GLuint coverage;
#endif
-#if DEPTH_BITS==16
- GLdepth z = FixedToInt(z0);
-#else
- GLdepth z = z0;
-#endif
+ GLdepth z = FixedToDepth(z0);
ASSERT(xLefti < xRight);
{
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
GLfloat invQ = 1.0F / hv0;
GLfloat s = hs0 * invQ;
GLfloat t = ht0 * invQ;
GLfloat u = hu0 * invQ;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
GLfloat invQ1 = 1.0F / hv01;
GLfloat s1 = hs01 * invQ1;
GLfloat t1 = ht01 * invQ1;
@@ -425,30 +425,30 @@
#endif
/* left pixel of swipe */
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
coverage = (GLint) (alpha * (1.0F - (xLeft - xLefti)));
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
coverage = (GLuint) (15.0F * (1.0F - (xLeft - xLefti)));
#endif
PLOT(xLefti, y);
xLefti++;
/* right pixel of swipe */
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
coverage = (GLint) (alpha * (xRight - xRighti));
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
coverage = (GLuint) (15.0F * (xRight - xRighti));
#endif
PLOT(xRighti, y)
xRighti--;
/* pixels between top and bottom with 100% coverage */
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
coverage = alpha;
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
coverage = 15;
#endif
for (ix = xLefti; ix <= xRighti; ix++) {
@@ -461,30 +461,30 @@
x += xStep;
y += yStep;
z0 += dz;
-#ifdef INTERP_RGBA
+#if INTERP_RGBA
fr += dfr;
fg += dfg;
fb += dfb;
fa += dfa;
#endif
-#ifdef INTERP_SPEC
+#if INTERP_SPEC
fsr += dfsr;
fsg += dfsg;
fsb += dfsb;
#endif
-#ifdef INTERP_STUV0
+#if INTERP_STUV0
hs0 += dhs;
ht0 += dht;
hu0 += dhu;
hv0 += dhv;
#endif
-#ifdef INTERP_STUV1
+#if INTERP_STUV1
hs01 += dhs1;
ht01 += dht1;
hu01 += dhu1;
hv01 += dhv1;
#endif
-#ifdef INTERP_INDEX
+#if INTERP_INDEX
fi += dfi;
#endif
if (!solid)
diff --git a/xc/extras/Mesa/src/logic.c b/xc/extras/Mesa/src/logic.c
index d6db7e84b..715eb9ccd 100644
--- a/xc/extras/Mesa/src/logic.c
+++ b/xc/extras/Mesa/src/logic.c
@@ -68,6 +68,9 @@ _mesa_LogicOp( GLenum opcode )
gl_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
return;
}
+
+ if (ctx->Driver.LogicOpcode)
+ ctx->Driver.LogicOpcode( ctx, opcode );
}
diff --git a/xc/extras/Mesa/src/matrix.c b/xc/extras/Mesa/src/matrix.c
index ef1abacd4..f9270f75c 100644
--- a/xc/extras/Mesa/src/matrix.c
+++ b/xc/extras/Mesa/src/matrix.c
@@ -1459,8 +1459,8 @@ gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height )
ctx->Viewport.WindowMap.m[MAT_TX] = ctx->Viewport.WindowMap.m[MAT_SX] + x;
ctx->Viewport.WindowMap.m[MAT_SY] = (GLfloat) height / 2.0F;
ctx->Viewport.WindowMap.m[MAT_TY] = ctx->Viewport.WindowMap.m[MAT_SY] + y;
- ctx->Viewport.WindowMap.m[MAT_SZ] = 0.5 * DEPTH_SCALE;
- ctx->Viewport.WindowMap.m[MAT_TZ] = 0.5 * DEPTH_SCALE;
+ ctx->Viewport.WindowMap.m[MAT_SZ] = 0.5 * ctx->Visual->DepthMaxF;
+ ctx->Viewport.WindowMap.m[MAT_TZ] = 0.5 * ctx->Visual->DepthMaxF;
ctx->Viewport.WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
ctx->Viewport.WindowMap.type = MATRIX_3D_NO_ROT;
@@ -1517,8 +1517,8 @@ _mesa_DepthRange( GLclampd nearval, GLclampd farval )
ctx->Viewport.Near = n;
ctx->Viewport.Far = f;
- ctx->Viewport.WindowMap.m[MAT_SZ] = DEPTH_SCALE * ((f - n) / 2.0);
- ctx->Viewport.WindowMap.m[MAT_TZ] = DEPTH_SCALE * ((f - n) / 2.0 + n);
+ ctx->Viewport.WindowMap.m[MAT_SZ] = ctx->Visual->DepthMaxF * ((f - n) / 2.0);
+ ctx->Viewport.WindowMap.m[MAT_TZ] = ctx->Visual->DepthMaxF * ((f - n) / 2.0 + n);
ctx->ModelProjectWinMatrixUptodate = GL_FALSE;
diff --git a/xc/extras/Mesa/src/mmath.h b/xc/extras/Mesa/src/mmath.h
index fe5dab7b0..2d9a558fc 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)
diff --git a/xc/extras/Mesa/src/pb.h b/xc/extras/Mesa/src/pb.h
index 54fad8388..474aecb53 100644
--- a/xc/extras/Mesa/src/pb.h
+++ b/xc/extras/Mesa/src/pb.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,9 +24,6 @@
*/
-
-
-
#ifndef PB_H
#define PB_H
@@ -34,7 +31,6 @@
#include "types.h"
-
/*
* Pixel buffer size, must be larger than MAX_WIDTH.
*/
@@ -44,7 +40,7 @@
struct pixel_buffer {
GLint x[PB_SIZE]; /* X window coord in [0,MAX_WIDTH) */
GLint y[PB_SIZE]; /* Y window coord in [0,MAX_HEIGHT) */
- GLdepth z[PB_SIZE]; /* Z window coord in [0,MAX_DEPTH] */
+ GLdepth z[PB_SIZE]; /* Z window coord in [0,Visual.MaxDepth] */
GLubyte rgba[PB_SIZE][4]; /* Colors */
GLubyte spec[PB_SIZE][3]; /* Separate specular colors */
GLuint i[PB_SIZE]; /* Index */
@@ -61,8 +57,6 @@ struct pixel_buffer {
-
-
/*
* Set the color used for all subsequent pixels in the buffer.
*/
@@ -71,7 +65,7 @@ struct pixel_buffer {
|| (PB)->color[BCOMP]!=(B) || (PB)->color[ACOMP]!=(A) \
|| !(PB)->mono) { \
gl_flush_pb( ctx ); \
- } \
+ } \
(PB)->color[RCOMP] = R; \
(PB)->color[GCOMP] = G; \
(PB)->color[BCOMP] = B; \
diff --git a/xc/extras/Mesa/src/points.c b/xc/extras/Mesa/src/points.c
index 48866230f..9c77ac3a6 100644
--- a/xc/extras/Mesa/src/points.c
+++ b/xc/extras/Mesa/src/points.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"),
@@ -708,15 +708,14 @@ static void dist3(GLfloat *out, GLuint first, GLuint last,
const GLcontext *ctx, const GLvector4f *v)
{
GLuint stride = v->stride;
- GLfloat *p = VEC_ELT(v, GLfloat, first);
+ const GLfloat *p = VEC_ELT(v, GLfloat, first);
GLuint i;
- for (i = first ; i <= last ; i++, STRIDE_F(p, stride) )
- {
+ for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]);
- out[i] = 1/(ctx->Point.Params[0]+
- dist * (ctx->Point.Params[1] +
- dist * ctx->Point.Params[2]));
+ out[i] = 1.0F / (ctx->Point.Params[0] +
+ dist * (ctx->Point.Params[1] +
+ dist * ctx->Point.Params[2]));
}
}
@@ -724,15 +723,14 @@ static void dist2(GLfloat *out, GLuint first, GLuint last,
const GLcontext *ctx, const GLvector4f *v)
{
GLuint stride = v->stride;
- GLfloat *p = VEC_ELT(v, GLfloat, first);
+ const GLfloat *p = VEC_ELT(v, GLfloat, first);
GLuint i;
- for (i = first ; i <= last ; i++, STRIDE_F(p, stride) )
- {
+ for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) {
GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]);
- out[i] = 1/(ctx->Point.Params[0]+
- dist * (ctx->Point.Params[1] +
- dist * ctx->Point.Params[2]));
+ out[i] = 1.0F / (ctx->Point.Params[0] +
+ dist * (ctx->Point.Params[1] +
+ dist * ctx->Point.Params[2]));
}
}
diff --git a/xc/extras/Mesa/src/polygon.c b/xc/extras/Mesa/src/polygon.c
index 50ce47b90..4a4f85064 100644
--- a/xc/extras/Mesa/src/polygon.c
+++ b/xc/extras/Mesa/src/polygon.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"),
@@ -131,24 +131,23 @@ _mesa_PolygonMode( GLenum face, GLenum mode )
-/*
- * NOTE: stipple pattern has already been unpacked.
- */
void
-_mesa_PolygonStipple( const GLubyte *mask )
+_mesa_PolygonStipple( const GLubyte *pattern )
{
GET_CURRENT_CONTEXT(ctx);
- GLuint *pattern = (GLuint *) mask; /* XXX verify */
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonStipple");
if (MESA_VERBOSE&VERBOSE_API)
fprintf(stderr, "glPolygonStipple\n");
- MEMCPY( ctx->PolygonStipple, pattern, 32 * 4 );
+ _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack);
if (ctx->Polygon.StippleFlag) {
ctx->NewState |= NEW_RASTER_OPS;
}
+
+ if (ctx->Driver.PolygonStipple)
+ ctx->Driver.PolygonStipple( ctx, (const GLubyte *) ctx->PolygonStipple );
}
@@ -162,7 +161,7 @@ _mesa_GetPolygonStipple( GLubyte *dest )
if (MESA_VERBOSE&VERBOSE_API)
fprintf(stderr, "glGetPolygonStipple\n");
- gl_pack_polygon_stipple( ctx, ctx->PolygonStipple, dest );
+ _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack);
}
@@ -181,9 +180,11 @@ _mesa_PolygonOffset( GLfloat factor, GLfloat units )
}
+
void
_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
{
- _mesa_PolygonOffset(factor, bias * DEPTH_SCALE );
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPolygonOffsetEXT");
+ _mesa_PolygonOffset(factor, bias * ctx->Visual->DepthMaxF );
}
-
diff --git a/xc/extras/Mesa/src/rastpos.c b/xc/extras/Mesa/src/rastpos.c
index f4508cba9..8bd67751f 100644
--- a/xc/extras/Mesa/src/rastpos.c
+++ b/xc/extras/Mesa/src/rastpos.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"),
@@ -131,7 +131,7 @@ static void raster_pos4f( GLcontext *ctx,
ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport.WindowMap.m[MAT_SY] +
ctx->Viewport.WindowMap.m[MAT_TY]);
ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport.WindowMap.m[MAT_SZ] +
- ctx->Viewport.WindowMap.m[MAT_TZ]) / DEPTH_SCALE;
+ ctx->Viewport.WindowMap.m[MAT_TZ]) / ctx->Visual->DepthMaxF;
ctx->Current.RasterPos[3] = clip[3];
ctx->Current.RasterPosValid = GL_TRUE;
diff --git a/xc/extras/Mesa/src/readpix.c b/xc/extras/Mesa/src/readpix.c
index a1e01f0fd..235444e03 100644
--- a/xc/extras/Mesa/src/readpix.c
+++ b/xc/extras/Mesa/src/readpix.c
@@ -82,7 +82,7 @@ static void read_index_pixels( GLcontext *ctx,
gl_map_ci(ctx, readWidth, index);
}
- dest = gl_pixel_addr_in_image(packing, pixels,
+ dest = _mesa_image_address(packing, pixels,
width, height, GL_COLOR_INDEX, type, 0, j, 0);
switch (type) {
@@ -109,7 +109,7 @@ static void read_index_pixels( GLcontext *ctx,
dst[i] = (GLushort) index[i];
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, readWidth );
+ _mesa_swap2( (GLushort *) dst, readWidth );
}
}
break;
@@ -120,7 +120,7 @@ static void read_index_pixels( GLcontext *ctx,
dst[i] = (GLshort) index[i];
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, readWidth );
+ _mesa_swap2( (GLushort *) dst, readWidth );
}
}
break;
@@ -131,7 +131,7 @@ static void read_index_pixels( GLcontext *ctx,
dst[i] = (GLuint) index[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -142,7 +142,7 @@ static void read_index_pixels( GLcontext *ctx,
dst[i] = (GLint) index[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -153,7 +153,7 @@ static void read_index_pixels( GLcontext *ctx,
dst[i] = (GLfloat) index[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -203,28 +203,22 @@ static void read_depth_pixels( GLcontext *ctx,
&& !bias_or_scale && !packing->SwapBytes) {
/* Special case: directly read 16-bit unsigned depth values. */
for (j=0;j<height;j++,y++) {
- GLushort *dst = (GLushort*) gl_pixel_addr_in_image( packing, pixels,
+ GLdepth depth[MAX_WIDTH];
+ GLushort *dst = (GLushort*) _mesa_image_address( packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 );
- (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, (GLdepth*) dst);
+ GLint i;
+ (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, depth);
+ for (i = 0; i < width; i++)
+ dst[i] = depth[i];
}
}
- else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint)
+ else if (type==GL_UNSIGNED_INT && ctx->Visual->DepthBits == 32
&& !bias_or_scale && !packing->SwapBytes) {
/* Special case: directly read 32-bit unsigned depth values. */
- /* Compute shift value to scale depth values up to 32-bit uints. */
- GLuint shift = 0;
- GLuint max = MAX_DEPTH;
- while ((max&0x80000000)==0) {
- max = max << 1;
- shift++;
- }
for (j=0;j<height;j++,y++) {
- GLuint *dst = (GLuint *) gl_pixel_addr_in_image( packing, pixels,
+ GLdepth *dst = (GLdepth *) _mesa_image_address( packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 );
- (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, (GLdepth*) dst);
- for (i=0;i<width;i++) {
- dst[i] = dst[i] << shift;
- }
+ (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, dst);
}
}
else {
@@ -243,7 +237,7 @@ static void read_depth_pixels( GLcontext *ctx,
}
}
- dest = gl_pixel_addr_in_image(packing, pixels,
+ dest = _mesa_image_address(packing, pixels,
width, height, GL_DEPTH_COMPONENT, type, 0, j, 0);
switch (type) {
@@ -270,7 +264,7 @@ static void read_depth_pixels( GLcontext *ctx,
dst[i] = FLOAT_TO_USHORT( depth[i] );
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, readWidth );
+ _mesa_swap2( (GLushort *) dst, readWidth );
}
}
break;
@@ -281,7 +275,7 @@ static void read_depth_pixels( GLcontext *ctx,
dst[i] = FLOAT_TO_SHORT( depth[i] );
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, readWidth );
+ _mesa_swap2( (GLushort *) dst, readWidth );
}
}
break;
@@ -292,7 +286,7 @@ static void read_depth_pixels( GLcontext *ctx,
dst[i] = FLOAT_TO_UINT( depth[i] );
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -303,7 +297,7 @@ static void read_depth_pixels( GLcontext *ctx,
dst[i] = FLOAT_TO_INT( depth[i] );
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -314,7 +308,7 @@ static void read_depth_pixels( GLcontext *ctx,
dst[i] = depth[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -374,7 +368,7 @@ static void read_stencil_pixels( GLcontext *ctx,
gl_map_stencil( ctx, readWidth, stencil );
}
- dest = gl_pixel_addr_in_image( packing, pixels,
+ dest = _mesa_image_address( packing, pixels,
width, height, GL_STENCIL_INDEX, type, 0, j, 0 );
switch (type) {
@@ -407,7 +401,7 @@ static void read_stencil_pixels( GLcontext *ctx,
dst[i] = (GLushort) stencil[i];
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, readWidth );
+ _mesa_swap2( (GLushort *) dst, readWidth );
}
}
break;
@@ -418,7 +412,7 @@ static void read_stencil_pixels( GLcontext *ctx,
dst[i] = (GLshort) stencil[i];
}
if (packing->SwapBytes) {
- gl_swap2( (GLushort *) dst, readWidth );
+ _mesa_swap2( (GLushort *) dst, readWidth );
}
}
break;
@@ -429,7 +423,7 @@ static void read_stencil_pixels( GLcontext *ctx,
dst[i] = (GLuint) stencil[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -440,7 +434,7 @@ static void read_stencil_pixels( GLcontext *ctx,
*dst++ = (GLint) stencil[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -451,7 +445,7 @@ static void read_stencil_pixels( GLcontext *ctx,
dst[i] = (GLfloat) stencil[i];
}
if (packing->SwapBytes) {
- gl_swap4( (GLuint *) dst, readWidth );
+ _mesa_swap4( (GLuint *) dst, readWidth );
}
}
break;
@@ -633,7 +627,7 @@ static void read_rgba_pixels( GLcontext *ctx,
return;
}
- if (!gl_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type)) {
gl_error(ctx, GL_INVALID_OPERATION, "glReadPixels(format or type)");
return;
}
@@ -646,11 +640,11 @@ static void read_rgba_pixels( GLcontext *ctx,
gl_read_rgba_span( ctx, ctx->ReadBuffer, readWidth, x, y, rgba );
- dest = gl_pixel_addr_in_image( packing, pixels, width, height,
+ dest = _mesa_image_address( packing, pixels, width, height,
format, type, 0, j, 0);
- gl_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba,
- format, type, dest, packing, GL_TRUE );
+ _mesa_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba,
+ format, type, dest, packing, GL_TRUE );
}
}
else {
@@ -668,11 +662,11 @@ static void read_rgba_pixels( GLcontext *ctx,
gl_map_ci_to_rgba(ctx, readWidth, index, rgba );
- dest = gl_pixel_addr_in_image( packing, pixels, width, height,
+ dest = _mesa_image_address( packing, pixels, width, height,
format, type, 0, j, 0);
- gl_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba,
- format, type, dest, packing, GL_TRUE );
+ _mesa_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba,
+ format, type, dest, packing, GL_TRUE );
}
}
@@ -693,15 +687,20 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
return;
}
+ if (ctx->Driver.ReadPixels &&
+ (*ctx->Driver.ReadPixels)(ctx, x, y, width, height,
+ format, type, &ctx->Pack, pixels))
+ return;
+
switch (format) {
case GL_COLOR_INDEX:
- read_index_pixels( ctx, x, y, width, height, type, pixels, &ctx->Pack );
+ read_index_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack);
break;
case GL_STENCIL_INDEX:
- read_stencil_pixels( ctx, x, y, width, height, type, pixels, &ctx->Pack );
+ read_stencil_pixels(ctx, x,y, width,height, type, pixels, &ctx->Pack);
break;
case GL_DEPTH_COMPONENT:
- read_depth_pixels( ctx, x, y, width, height, type, pixels, &ctx->Pack );
+ read_depth_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack);
break;
case GL_RED:
case GL_GREEN:
@@ -714,7 +713,8 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
case GL_BGR:
case GL_BGRA:
case GL_ABGR_EXT:
- read_rgba_pixels( ctx, x, y, width, height, format, type, pixels, &ctx->Pack );
+ read_rgba_pixels(ctx, x, y, width, height,
+ format, type, pixels, &ctx->Pack);
break;
default:
gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(format)" );
diff --git a/xc/extras/Mesa/src/render_tmp.h b/xc/extras/Mesa/src/render_tmp.h
index f9447003e..3907ee86f 100644
--- a/xc/extras/Mesa/src/render_tmp.h
+++ b/xc/extras/Mesa/src/render_tmp.h
@@ -38,9 +38,15 @@
#ifndef NEED_EDGEFLAG_SETUP
#define NEED_EDGEFLAG_SETUP 0
#define EDGEFLAG_TRI(a,b,c,d,e)
+#define EDGEFLAG_POLY_TRI_PRE(a,b,c,d)
+#define EDGEFLAG_POLY_TRI_POST(a,b,c,d)
#define EDGEFLAG_QUAD(a,b,c,d,e)
#endif
+#ifndef RESET_STIPPLE
+#define RESET_STIPPLE
+#endif
+
static void TAG(render_vb_points)( struct vertex_buffer *VB,
GLuint start,
@@ -60,14 +66,13 @@ static void TAG(render_vb_lines)( struct vertex_buffer *VB,
GLuint parity )
{
GLuint j;
- GLuint *stipplecounter = &VB->ctx->StippleCounter;
LOCAL_VARS;
(void) parity;
INIT(GL_LINES);
for (j=start+1; j<count; j+=2 ) {
RENDER_LINE( j-1, j );
- *stipplecounter = 0;
+ RESET_STIPPLE;
}
POSTFIX;
}
@@ -85,9 +90,11 @@ static void TAG(render_vb_line_strip)( struct vertex_buffer *VB,
INIT(GL_LINES);
for (j=start+1; j<count; j++ ) {
RENDER_LINE( j-1, j );
+ }
+
+ if (VB->Flag[count] & VERT_END) {
+ RESET_STIPPLE;
}
-
- VB->ctx->StippleCounter = 0;
POSTFIX;
}
@@ -108,9 +115,9 @@ static void TAG(render_vb_line_loop)( struct vertex_buffer *VB,
if (VB->Flag[count] & VERT_END) {
RENDER_LINE( i-1, start );
- }
+ RESET_STIPPLE;
+ }
- VB->ctx->StippleCounter = 0;
POSTFIX;
}
@@ -127,6 +134,7 @@ static void TAG(render_vb_triangles)( struct vertex_buffer *VB,
INIT(GL_POLYGON);
for (j=start+2; j<count; j+=3) {
RENDER_TRI( j-2, j-1, j, j, 0 );
+ RESET_STIPPLE;
}
POSTFIX;
}
@@ -146,6 +154,7 @@ static void TAG(render_vb_tri_strip)( struct vertex_buffer *VB,
for (j=start+2;j<count;j++,parity^=1) {
EDGEFLAG_TRI( j-2, j-1, j, j, parity );
RENDER_TRI( j-2, j-1, j, j, parity );
+ RESET_STIPPLE;
}
} else {
for (j=start+2;j<count;j++,parity^=1) {
@@ -169,6 +178,7 @@ static void TAG(render_vb_tri_fan)( struct vertex_buffer *VB,
for (j=start+2;j<count;j++) {
EDGEFLAG_TRI( start, j-1, j, j, 0 );
RENDER_TRI( start, j-1, j, j, 0 );
+ RESET_STIPPLE;
}
} else {
for (j=start+2;j<count;j++) {
@@ -189,9 +199,19 @@ static void TAG(render_vb_poly)( struct vertex_buffer *VB,
LOCAL_VARS;
(void) parity;
INIT(GL_POLYGON);
- for (j=start+2;j<count;j++) {
- RENDER_TRI( start, j-1, j, start, 0 );
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++) {
+ EDGEFLAG_POLY_TRI_PRE( start, j-1, j, start );
+ RENDER_TRI( start, j-1, j, start, 0 );
+ EDGEFLAG_POLY_TRI_POST( start, j-1, j, start );
+ }
+ }
+ else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( start, j-1, j, start, 0 );
+ }
}
+ RESET_STIPPLE;
POSTFIX;
}
@@ -207,6 +227,7 @@ static void TAG(render_vb_quads)( struct vertex_buffer *VB,
INIT(GL_POLYGON);
for (j=start+3; j<count; j+=4) {
RENDER_QUAD( j-3, j-2, j-1, j, j );
+ RESET_STIPPLE;
}
POSTFIX;
}
@@ -224,6 +245,7 @@ static void TAG(render_vb_quad_strip)( struct vertex_buffer *VB,
for (j=start+3;j<count;j+=2) {
EDGEFLAG_QUAD( j-3, j-2, j, j-1, j );
RENDER_QUAD( j-3, j-2, j, j-1, j );
+ RESET_STIPPLE;
}
} else {
for (j=start+3;j<count;j+=2) {
@@ -273,6 +295,7 @@ static void TAG(render_init)( void )
#undef LOCAL_VARS
#undef INIT
#undef POSTFIX
+#undef RESET_STIPPLE
#endif
#ifndef PRESERVE_TAG
diff --git a/xc/extras/Mesa/src/shade_tmp.h b/xc/extras/Mesa/src/shade_tmp.h
index 158ace90d..189a91d4f 100644
--- a/xc/extras/Mesa/src/shade_tmp.h
+++ b/xc/extras/Mesa/src/shade_tmp.h
@@ -553,8 +553,7 @@ static void TAG(shade_fast_rgba)( struct vertex_buffer *VB )
COPY_3V(sum[0], base[0]);
if (NR_SIDES == 2) COPY_3V(sum[1], base[1]);
- if (0)
-/* if (ctx->Light.ShadeModel == GL_SMOOTH) */
+ if (MESA_VERBOSE&VERBOSE_LIGHTING)
fprintf(stderr, "light normal %d/%d, %f %f %f\n",
j, VB->Start, normal[0], normal[1], normal[2]);
diff --git a/xc/extras/Mesa/src/span.c b/xc/extras/Mesa/src/span.c
index 38f4449f1..fd07810f2 100644
--- a/xc/extras/Mesa/src/span.c
+++ b/xc/extras/Mesa/src/span.c
@@ -227,6 +227,9 @@ void gl_write_index_span( GLcontext *ctx,
if (_mesa_depth_test_span( ctx, n, x, y, z, mask )==0) return;
}
+ /* if we get here, something passed the depth test */
+ ctx->OcclusionResult = GL_TRUE;
+
if (ctx->RasterMask & MULTI_DRAW_BIT) {
/* draw to zero or two or more buffers */
multi_write_index_span( ctx, n, x, y, index, mask );
@@ -287,6 +290,9 @@ void gl_write_monoindex_span( GLcontext *ctx,
if (_mesa_depth_test_span( ctx, n, x, y, z, mask )==0) return;
}
+ /* if we get here, something passed the depth test */
+ ctx->OcclusionResult = GL_TRUE;
+
if (ctx->Color.DrawBuffer == GL_NONE) {
/* write no pixels */
return;
@@ -486,6 +492,9 @@ void gl_write_rgba_span( GLcontext *ctx,
}
}
+ /* if we get here, something passed the depth test */
+ ctx->OcclusionResult = GL_TRUE;
+
if (ctx->RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, n, x, y,
(const GLubyte (*)[4]) rgba,
@@ -596,6 +605,9 @@ void gl_write_monocolor_span( GLcontext *ctx,
}
}
+ /* if we get here, something passed the depth test */
+ ctx->OcclusionResult = GL_TRUE;
+
if (ctx->Color.DrawBuffer == GL_NONE) {
/* write no pixels */
return;
@@ -785,6 +797,9 @@ void gl_write_texture_span( GLcontext *ctx,
}
}
+ /* if we get here, something passed the depth test */
+ ctx->OcclusionResult = GL_TRUE;
+
if (ctx->RasterMask & MULTI_DRAW_BIT) {
multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4])rgba,
write_all ? Null : mask );
@@ -912,8 +927,12 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits,
}
}
+ /* if we get here, something passed the depth test */
+ ctx->OcclusionResult = GL_TRUE;
+
if (ctx->RasterMask & MULTI_DRAW_BIT) {
- multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, write_all ? Null : mask );
+ multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba,
+ write_all ? Null : mask );
}
else {
/* normal: write to exactly one buffer */
diff --git a/xc/extras/Mesa/src/stages.c b/xc/extras/Mesa/src/stages.c
index 69e6831db..43aff42c2 100644
--- a/xc/extras/Mesa/src/stages.c
+++ b/xc/extras/Mesa/src/stages.c
@@ -419,15 +419,17 @@ static void do_normal_transform( struct vertex_buffer *VB )
gl_make_normal_cullmask( VB );
}
- (ctx->NormalTransform[tmp])(&ctx->ModelView,
- ctx->vb_rescale_factor,
- VB->NormalPtr,
- (VB->NormalLengthPtr ?
- VB->NormalLengthPtr + VB->Start : 0),
- VB->NormCullStart,
- VB->store.Normal);
-
- VB->NormalPtr = VB->store.Normal;
+ if (ctx->NormalTransform) {
+ (ctx->NormalTransform[tmp])(&ctx->ModelView,
+ ctx->vb_rescale_factor,
+ VB->NormalPtr,
+ (VB->NormalLengthPtr ?
+ VB->NormalLengthPtr + VB->Start : 0),
+ VB->NormCullStart,
+ VB->store.Normal);
+
+ VB->NormalPtr = VB->store.Normal;
+ }
}
@@ -511,7 +513,7 @@ static void check_fog( GLcontext *ctx, struct gl_pipeline_stage *d )
{
d->type = 0;
- if (ctx->Fog.Enabled && ctx->FogMode==FOG_VERTEX)
+ if (ctx->FogMode==FOG_VERTEX)
{
GLuint flags;
@@ -705,7 +707,7 @@ CONST struct gl_pipeline_stage gl_default_pipeline[] = {
PIPE_OP_NORM_XFORM,
PIPE_PRECALC|PIPE_IMMEDIATE,
0,
- NEW_LIGHTING|NEW_FOG|NEW_TEXTURING, /* state change (recheck) */
+ NEW_LIGHTING|NEW_FOG|NEW_TEXTURING|NEW_NORMAL_TRANSFORM, /* state change (recheck) */
NEW_NORMAL_TRANSFORM, /* cva state change (recalc) */
0, 0,
DYN_STATE,
@@ -784,8 +786,8 @@ CONST struct gl_pipeline_stage gl_default_pipeline[] = {
PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1,
PIPE_PRECALC|PIPE_IMMEDIATE,
0,
- NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS|NEW_POLYGON,
- NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS|NEW_POLYGON,
+ NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS|NEW_POLYGON|NEW_TEXTURE_ENV,
+ NEW_LIGHTING|NEW_TEXTURING|NEW_RASTER_OPS|NEW_POLYGON|NEW_TEXTURE_ENV,
0, 0,
DYN_STATE,
check_full_setup,
diff --git a/xc/extras/Mesa/src/state.c b/xc/extras/Mesa/src/state.c
index b135a3df0..fda6210ba 100644
--- a/xc/extras/Mesa/src/state.c
+++ b/xc/extras/Mesa/src/state.c
@@ -790,11 +790,21 @@ 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 we're not drawing to exactly one color buffer set the
* MULTI_DRAW_BIT flag. Also set it if we're drawing to no
* buffers or the RGBA or CI mask disables all writes.
*/
-
ctx->TriangleCaps &= ~DD_MULTIDRAW;
if (ctx->Color.MultiDrawBuffer) {
diff --git a/xc/extras/Mesa/src/teximage.c b/xc/extras/Mesa/src/teximage.c
index 7248cbad9..327c4bf92 100644
--- a/xc/extras/Mesa/src/teximage.c
+++ b/xc/extras/Mesa/src/teximage.c
@@ -49,7 +49,6 @@
*/
-
/*
* Compute log base 2 of n.
* If n isn't an exact power of two return -1.
@@ -85,8 +84,8 @@ logbase2( int n )
* GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA.
* Return -1 if invalid enum.
*/
-static GLint
-decode_internal_format( GLint format )
+GLint
+_mesa_base_tex_format( GLint format )
{
switch (format) {
case GL_ALPHA:
@@ -225,26 +224,6 @@ components_in_intformat( GLint format )
-struct gl_texture_image *
-gl_alloc_texture_image( void )
-{
- return CALLOC_STRUCT(gl_texture_image);
-}
-
-
-
-void
-gl_free_texture_image( struct gl_texture_image *teximage )
-{
- if (teximage->Data) {
- FREE( teximage->Data );
- teximage->Data = NULL;
- }
- FREE( teximage );
-}
-
-
-
/*
* Examine the texImage->Format field and set the Red, Green, Blue, etc
* texel component sizes to default values.
@@ -354,6 +333,64 @@ set_teximage_component_sizes( struct gl_texture_image *texImage )
}
+
+/*
+ * Return new gl_texture_image struct with all fields initialized to zero.
+ */
+struct gl_texture_image *
+gl_alloc_texture_image( void )
+{
+ return CALLOC_STRUCT(gl_texture_image);
+}
+
+
+
+/*
+ * Initialize most fields of a gl_texture_image struct.
+ */
+static void
+init_texture_image( struct gl_texture_image *img,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLenum internalFormat )
+{
+ ASSERT(img);
+ ASSERT(!img->Data);
+ img->Format = (GLenum) _mesa_base_tex_format(internalFormat);
+ set_teximage_component_sizes( img );
+ img->IntFormat = (GLenum) internalFormat;
+ img->Border = border;
+ img->Width = width;
+ img->Height = height;
+ img->Depth = depth;
+ img->WidthLog2 = logbase2(width - 2 * border);
+ if (height == 1) /* 1-D texture */
+ img->HeightLog2 = 0;
+ else
+ img->HeightLog2 = logbase2(height - 2 * border);
+ if (depth == 1) /* 2-D texture */
+ img->DepthLog2 = 0;
+ else
+ img->DepthLog2 = logbase2(depth - 2 * border);
+ img->Width2 = 1 << img->WidthLog2;
+ img->Height2 = 1 << img->HeightLog2;
+ img->Depth2 = 1 << img->DepthLog2;
+ img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
+}
+
+
+
+void
+gl_free_texture_image( struct gl_texture_image *teximage )
+{
+ if (teximage->Data) {
+ FREE( teximage->Data );
+ teximage->Data = NULL;
+ }
+ FREE( teximage );
+}
+
+
+
/* Need this to prevent an out-of-bounds memory access when using
* X86 optimized code.
*/
@@ -366,68 +403,45 @@ set_teximage_component_sizes( struct gl_texture_image *texImage )
/*
- * This is called by glTexImage[123]D in order to build a gl_texture_image
- * object given the client's parameters and image data.
- *
- * NOTES: Width, height and depth should include the border.
- * All texture image parameters should have already been error checked.
+ * Called by glTexImage[123]D. Fill in a texture image with data given
+ * by the client. All pixel transfer and unpack modes are handled here.
+ * NOTE: All texture image parameters should have already been error checked.
*/
-static struct gl_texture_image *
-make_texture_image( GLcontext *ctx, GLint internalFormat,
- GLint width, GLint height, GLint depth, GLint border,
+static void
+make_texture_image( GLcontext *ctx,
+ struct gl_texture_image *texImage,
GLenum srcFormat, GLenum srcType, const GLvoid *pixels,
const struct gl_pixelstore_attrib *unpacking)
{
GLint components, numPixels;
- struct gl_texture_image *texImage;
-
- assert(width > 0);
- assert(height > 0);
- assert(depth > 0);
- assert(border == 0 || border == 1);
- assert(pixels);
- assert(unpacking);
-
-
- /*
- * Allocate and initialize the texture_image struct
- */
- texImage = gl_alloc_texture_image();
- if (!texImage)
- return NULL;
-
- texImage->Format = (GLenum) decode_internal_format(internalFormat);
- set_teximage_component_sizes( texImage );
- texImage->IntFormat = (GLenum) internalFormat;
- texImage->Border = border;
- texImage->Width = width;
- texImage->Height = height;
- texImage->Depth = depth;
- texImage->WidthLog2 = logbase2(width - 2 * border);
- if (height == 1) /* 1-D texture */
- texImage->HeightLog2 = 0;
- else
- texImage->HeightLog2 = logbase2(height - 2 * border);
- if (depth == 1) /* 2-D texture */
- texImage->DepthLog2 = 0;
- else
- texImage->DepthLog2 = logbase2(depth - 2 * border);
- texImage->Width2 = 1 << texImage->WidthLog2;
- texImage->Height2 = 1 << texImage->HeightLog2;
- texImage->Depth2 = 1 << texImage->DepthLog2;
- texImage->MaxLog2 = MAX2(texImage->WidthLog2, texImage->HeightLog2);
-
+ GLint internalFormat, width, height, depth, border;
+
+ ASSERT(ctx);
+ ASSERT(texImage);
+ ASSERT(!texImage->Data);
+ ASSERT(pixels);
+ ASSERT(unpacking);
+
+ internalFormat = texImage->IntFormat;
+ width = texImage->Width;
+ height = texImage->Height;
+ depth = texImage->Depth;
+ border = texImage->Border;
components = components_in_intformat(internalFormat);
- numPixels = texImage->Width * texImage->Height * texImage->Depth;
- texImage->Data = (GLubyte *) MALLOC(numPixels * components + EXTRA_BYTE);
+ ASSERT(width > 0);
+ ASSERT(height > 0);
+ ASSERT(depth > 0);
+ ASSERT(border == 0 || border == 1);
+ ASSERT(pixels);
+ ASSERT(unpacking);
+ ASSERT(components);
- if (!texImage->Data) {
- /* out of memory */
- gl_free_texture_image(texImage);
- return NULL;
- }
+ numPixels = width * height * depth;
+ texImage->Data = (GLubyte *) MALLOC(numPixels * components + EXTRA_BYTE);
+ if (!texImage->Data)
+ return; /* out of memory */
/*
* OK, the texture image struct has been initialized and the texture
@@ -441,15 +455,18 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
&& !ctx->Pixel.IndexOffset && !ctx->Pixel.IndexShift
&& srcType == GL_UNSIGNED_BYTE && depth == 1) {
- if (srcFormat == internalFormat) {
+ if (srcFormat == internalFormat ||
+ (srcFormat == GL_LUMINANCE && internalFormat == 1) ||
+ (srcFormat == GL_LUMINANCE_ALPHA && internalFormat == 2) ||
+ (srcFormat == GL_RGB && internalFormat == 3) ||
+ (srcFormat == GL_RGBA && internalFormat == 4)) {
/* This will cover the common GL_RGB, GL_RGBA, GL_ALPHA,
* GL_LUMINANCE_ALPHA, etc. texture formats.
*/
- const GLubyte *src = gl_pixel_addr_in_image(unpacking,
- pixels, width, height, srcFormat, srcType, 0, 0, 0);
- const GLubyte *src1 = gl_pixel_addr_in_image(unpacking,
- pixels, width, height, srcFormat, srcType, 0, 1, 0);
- const GLint srcStride = src1 - src;
+ const GLubyte *src = (const GLubyte *) _mesa_image_address(
+ unpacking, pixels, width, height, srcFormat, srcType, 0, 0, 0);
+ const GLint srcStride = _mesa_image_row_stride(unpacking, width,
+ srcFormat, srcType);
GLubyte *dst = texImage->Data;
GLint dstBytesPerRow = width * components * sizeof(GLubyte);
if (srcStride == dstBytesPerRow) {
@@ -463,15 +480,14 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
dst += dstBytesPerRow;
}
}
- return texImage; /* all done */
+ return; /* all done */
}
else if (srcFormat == GL_RGBA && internalFormat == GL_RGB) {
/* commonly used by Quake */
- const GLubyte *src = gl_pixel_addr_in_image(unpacking,
- pixels, width, height, srcFormat, srcType, 0, 0, 0);
- const GLubyte *src1 = gl_pixel_addr_in_image(unpacking,
- pixels, width, height, srcFormat, srcType, 0, 1, 0);
- const GLint srcStride = src1 - src;
+ const GLubyte *src = (const GLubyte *) _mesa_image_address(
+ unpacking, pixels, width, height, srcFormat, srcType, 0, 0, 0);
+ const GLint srcStride = _mesa_image_row_stride(unpacking, width,
+ srcFormat, srcType);
GLubyte *dst = texImage->Data;
GLint i, j;
for (i = 0; i < height; i++) {
@@ -484,7 +500,7 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
}
src += srcStride;
}
- return texImage; /* all done */
+ return; /* all done */
}
}
@@ -500,7 +516,7 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
GLint img, row;
for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) {
- const GLvoid *source = gl_pixel_addr_in_image(unpacking,
+ const GLvoid *source = _mesa_image_address(unpacking,
pixels, width, height, srcFormat, srcType, img, row, 0);
_mesa_unpack_index_span(ctx, width, dstType, dest,
srcType, source, unpacking, GL_TRUE);
@@ -516,7 +532,7 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
GLint img, row;
for (img = 0; img < depth; img++) {
for (row = 0; row < height; row++) {
- const GLvoid *source = gl_pixel_addr_in_image(unpacking,
+ const GLvoid *source = _mesa_image_address(unpacking,
pixels, width, height, srcFormat, srcType, img, row, 0);
_mesa_unpack_ubyte_color_span(ctx, width, dstFormat, dest,
srcFormat, srcType, source, unpacking, GL_TRUE);
@@ -524,8 +540,6 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
}
}
}
-
- return texImage; /* All done! */
}
@@ -533,48 +547,19 @@ make_texture_image( GLcontext *ctx, GLint internalFormat,
/*
* glTexImage[123]D can accept a NULL image pointer. In this case we
* create a texture image with unspecified image contents per the OpenGL
- * spec.
+ * spec. This function creates an empty image for the given texture image.
*/
-static struct gl_texture_image *
-make_null_texture( GLcontext *ctx, GLenum internalFormat,
- GLsizei width, GLsizei height, GLsizei depth, GLint border )
+static void
+make_null_texture( struct gl_texture_image *texImage )
{
GLint components;
- struct gl_texture_image *texImage;
GLint numPixels;
- (void) ctx;
- /*internalFormat = decode_internal_format(internalFormat);*/
- components = components_in_intformat(internalFormat);
- numPixels = width * height * depth;
+ ASSERT(texImage);
+ ASSERT(!texImage->Data);
- texImage = gl_alloc_texture_image();
- if (!texImage)
- return NULL;
-
- texImage->Format = (GLenum) decode_internal_format(internalFormat);
- set_teximage_component_sizes( texImage );
- texImage->IntFormat = internalFormat;
- texImage->Border = border;
- texImage->Width = width;
- texImage->Height = height;
- texImage->Depth = depth;
- texImage->WidthLog2 = logbase2(width - 2*border);
- if (height==1) /* 1-D texture */
- texImage->HeightLog2 = 0;
- else
- texImage->HeightLog2 = logbase2(height - 2*border);
- if (depth==1) /* 2-D texture */
- texImage->DepthLog2 = 0;
- else
- texImage->DepthLog2 = logbase2(depth - 2*border);
- texImage->Width2 = 1 << texImage->WidthLog2;
- texImage->Height2 = 1 << texImage->HeightLog2;
- texImage->Depth2 = 1 << texImage->DepthLog2;
- texImage->MaxLog2 = MAX2( texImage->WidthLog2, texImage->HeightLog2 );
-
- /* XXX should we really allocate memory for the image or let it be NULL? */
- /*texImage->Data = NULL;*/
+ components = components_in_intformat(texImage->IntFormat);
+ numPixels = texImage->Width * texImage->Height * texImage->Depth;
texImage->Data = (GLubyte *) MALLOC( numPixels * components + EXTRA_BYTE );
@@ -597,9 +582,9 @@ make_null_texture( GLcontext *ctx, GLenum internalFormat,
GLubyte *imgPtr = texImage->Data;
GLint i, j, k;
- for (i=0;i<height;i++) {
+ for (i = 0; i < texImage->Height; i++) {
GLint srcRow = 7 - i % 8;
- for (j=0;j<width;j++) {
+ for (j = 0; j < texImage->Width; j++) {
GLint srcCol = j % 32;
GLint texel = (message[srcRow][srcCol]=='X') ? 255 : 70;
for (k=0;k<components;k++) {
@@ -608,8 +593,6 @@ make_null_texture( GLcontext *ctx, GLenum internalFormat,
}
}
}
-
- return texImage;
}
@@ -712,7 +695,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
return GL_TRUE;
}
- iformat = decode_internal_format( internalFormat );
+ iformat = _mesa_base_tex_format( internalFormat );
if (iformat < 0) {
if (!isProxy) {
char message[100];
@@ -722,7 +705,7 @@ texture_error_check( GLcontext *ctx, GLenum target,
return GL_TRUE;
}
- if (!gl_is_legal_format_and_type( format, type )) {
+ if (!_mesa_is_legal_format_and_type( format, type )) {
/* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
* is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4.
*/
@@ -838,7 +821,7 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions,
}
}
- if (!gl_is_legal_format_and_type(format, type)) {
+ if (!_mesa_is_legal_format_and_type(format, type)) {
char message[100];
sprintf(message, "glTexSubImage%dD(format or type)", dimensions);
gl_error(ctx, GL_INVALID_ENUM, message);
@@ -911,7 +894,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions,
return GL_TRUE;
}
- iformat = decode_internal_format( internalFormat );
+ iformat = _mesa_base_tex_format( internalFormat );
if (iformat < 0) {
char message[100];
sprintf(message, "glCopyTexImage%dD(internalFormat)", dimensions);
@@ -1028,52 +1011,89 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
* Called from the API. Note that width includes the border.
*/
void
-_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
+_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLint border, GLenum format,
GLenum type, const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage1D");
if (target==GL_TEXTURE_1D) {
- struct gl_texture_image *teximage;
- if (texture_error_check( ctx, target, level, internalformat,
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ if (texture_error_check( ctx, target, level, internalFormat,
format, type, 1, width, 1, 1, border )) {
- /* error in texture image was detected */
- return;
+ return; /* error in texture image was detected */
}
- /* free current texture image, if any */
- if (texUnit->CurrentD[1]->Image[level]) {
- gl_free_texture_image( texUnit->CurrentD[1]->Image[level] );
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = texUnit->CurrentD[1];
+ texImage = texObj->Image[level];
+
+ if (!texImage) {
+ texImage = gl_alloc_texture_image();
+ texObj->Image[level] = texImage;
+ if (!texImage) {
+ gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
}
+ else if (texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
+
+ /* setup the teximage struct's fields */
+ init_texture_image(texImage, width, 1, 1, border, internalFormat);
- /* make new texture from source image */
+ /* process the texture image */
if (pixels) {
- teximage = make_texture_image(ctx, internalformat, width, 1, 1,
- border, format, type, pixels, &ctx->Unpack);
+ GLboolean retain = GL_TRUE;
+ GLboolean success = GL_FALSE;
+ if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA
+ && ctx->Driver.TexImage1D) {
+ /* let device driver try to use raw image */
+ success = (*ctx->Driver.TexImage1D)( ctx, target, level, format,
+ type, pixels, &ctx->Unpack,
+ texObj, texImage, &retain);
+ }
+ if (retain || !success) {
+ /* make internal copy of the texture image */
+ make_texture_image(ctx, texImage, format, type,
+ pixels, &ctx->Unpack);
+ if (!success && ctx->Driver.TexImage1D) {
+ /* let device driver try to use unpacked image */
+ (*ctx->Driver.TexImage1D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing,
+ texObj, texImage, &retain);
+ }
+ }
+ if (!retain && texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
}
else {
- teximage = make_null_texture(ctx, (GLenum) internalformat,
- width, 1, 1, border);
+ make_null_texture(texImage);
+ if (ctx->Driver.TexImage1D) {
+ GLboolean retain;
+ (*ctx->Driver.TexImage1D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing,
+ texObj, texImage, &retain);
+ }
}
- /* install new texture image */
- texUnit->CurrentD[1]->Image[level] = teximage;
- gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] );
+ /* state update */
+ gl_put_texobj_on_dirty_list( ctx, texObj );
ctx->NewState |= NEW_TEXTURING;
-
- /* tell driver about change */
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D,
- texUnit->CurrentD[1],
- level, internalformat, teximage );
- }
}
else if (target==GL_PROXY_TEXTURE_1D) {
/* Proxy texture: check for errors and update proxy state */
- if (texture_error_check( ctx, target, level, internalformat,
+ if (texture_error_check( ctx, target, level, internalFormat,
format, type, 1, width, 1, 1, border )) {
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
MEMSET( ctx->Texture.Proxy1D->Image[level], 0,
@@ -1083,7 +1103,7 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
else {
ctx->Texture.Proxy1D->Image[level]->Format = (GLenum) format;
set_teximage_component_sizes( ctx->Texture.Proxy1D->Image[level] );
- ctx->Texture.Proxy1D->Image[level]->IntFormat = (GLenum) internalformat;
+ ctx->Texture.Proxy1D->Image[level]->IntFormat = (GLenum) internalFormat;
ctx->Texture.Proxy1D->Image[level]->Border = border;
ctx->Texture.Proxy1D->Image[level]->Width = width;
ctx->Texture.Proxy1D->Image[level]->Height = 1;
@@ -1098,53 +1118,99 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
void
-_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
+_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLint border,
GLenum format, GLenum type,
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage2D");
if (target==GL_TEXTURE_2D) {
- struct gl_texture_image *teximage;
- if (texture_error_check( ctx, target, level, internalformat,
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ if (texture_error_check( ctx, target, level, internalFormat,
format, type, 2, width, height, 1, border )) {
- /* error in texture image was detected */
- return;
+ return; /* error in texture image was detected */
}
- /* free current texture image, if any */
- if (texUnit->CurrentD[2]->Image[level]) {
- gl_free_texture_image( texUnit->CurrentD[2]->Image[level] );
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = texUnit->CurrentD[2];
+ texImage = texObj->Image[level];
+
+ if (!texImage) {
+ texImage = gl_alloc_texture_image();
+ texObj->Image[level] = texImage;
+ if (!texImage) {
+ gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ else if (texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
}
- /* make new texture from source image */
+ /* setup the teximage struct's fields */
+ init_texture_image(texImage, width, height, 1, border, internalFormat);
+
+ /* process the texture image */
if (pixels) {
- teximage = make_texture_image(ctx, internalformat, width, height, 1,
- border, format, type, pixels, &ctx->Unpack);
+ GLboolean retain = GL_TRUE;
+ GLboolean success = GL_FALSE;
+ if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA
+ && ctx->Driver.TexImage2D) {
+ /* let device driver try to use raw image */
+ success = (*ctx->Driver.TexImage2D)( ctx, target, level, format,
+ type, pixels, &ctx->Unpack,
+ texObj, texImage, &retain);
+ }
+ if (retain || !success) {
+ /* make internal copy of the texture image */
+ make_texture_image(ctx, texImage, format, type,
+ pixels, &ctx->Unpack);
+ if (!success && ctx->Driver.TexImage2D) {
+ /* let device driver try to use unpacked image */
+ (*ctx->Driver.TexImage2D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing,
+ texObj, texImage, &retain);
+ }
+ }
+ if (!retain && texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
}
else {
- teximage = make_null_texture(ctx, (GLenum) internalformat,
- width, height, 1, border);
+ make_null_texture(texImage);
+ if (ctx->Driver.TexImage2D) {
+ GLboolean retain;
+ (*ctx->Driver.TexImage2D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing,
+ texObj, texImage, &retain);
+ }
}
- /* install new texture image */
- texUnit->CurrentD[2]->Image[level] = teximage;
- gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[2] );
- ctx->NewState |= NEW_TEXTURING;
-
- /* tell driver about change */
+#define OLD_DD_TEXTURE
+#ifdef OLD_DD_TEXTURE
+ /* XXX this will be removed in the future */
if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D,
- texUnit->CurrentD[2],
- level, internalformat, teximage );
+ (*ctx->Driver.TexImage)( ctx, target, texObj, level, internalFormat,
+ texImage );
}
+#endif
+
+ /* state update */
+ gl_put_texobj_on_dirty_list( ctx, texObj );
+ ctx->NewState |= NEW_TEXTURING;
}
else if (target==GL_PROXY_TEXTURE_2D) {
/* Proxy texture: check for errors and update proxy state */
- if (texture_error_check( ctx, target, level, internalformat,
+ if (texture_error_check( ctx, target, level, internalFormat,
format, type, 2, width, height, 1, border )) {
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
MEMSET( ctx->Texture.Proxy2D->Image[level], 0,
@@ -1154,7 +1220,7 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
else {
ctx->Texture.Proxy2D->Image[level]->Format = (GLenum) format;
set_teximage_component_sizes( ctx->Texture.Proxy2D->Image[level] );
- ctx->Texture.Proxy2D->Image[level]->IntFormat = (GLenum) internalformat;
+ ctx->Texture.Proxy2D->Image[level]->IntFormat = (GLenum) internalFormat;
ctx->Texture.Proxy2D->Image[level]->Border = border;
ctx->Texture.Proxy2D->Image[level]->Width = width;
ctx->Texture.Proxy2D->Image[level]->Height = height;
@@ -1174,54 +1240,91 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
* Note that width and height include the border.
*/
void
-_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
+_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type,
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage3DEXT");
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage3D");
if (target==GL_TEXTURE_3D_EXT) {
- struct gl_texture_image *teximage;
- if (texture_error_check( ctx, target, level, internalformat,
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ if (texture_error_check( ctx, target, level, internalFormat,
format, type, 3, width, height, depth,
border )) {
- /* error in texture image was detected */
- return;
+ return; /* error in texture image was detected */
}
- /* free current texture image, if any */
- if (texUnit->CurrentD[3]->Image[level]) {
- gl_free_texture_image( texUnit->CurrentD[3]->Image[level] );
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = texUnit->CurrentD[3];
+ texImage = texObj->Image[level];
+
+ if (!texImage) {
+ texImage = gl_alloc_texture_image();
+ texObj->Image[level] = texImage;
+ if (!texImage) {
+ gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
}
+ else if (texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
+
+ /* setup the teximage struct's fields */
+ init_texture_image(texImage, width, height, depth,
+ border, internalFormat);
- /* make new texture from source image */
+ /* process the texture image */
if (pixels) {
- teximage = make_texture_image(ctx, internalformat, width, height,
- depth, border, format, type, pixels, &ctx->Unpack);
+ GLboolean retain = GL_TRUE;
+ GLboolean success = GL_FALSE;
+ if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA
+ && ctx->Driver.TexImage3D) {
+ /* let device driver try to use raw image */
+ success = (*ctx->Driver.TexImage3D)( ctx, target, level, format,
+ type, pixels, &ctx->Unpack,
+ texObj, texImage, &retain);
+ }
+ if (retain || !success) {
+ /* make internal copy of the texture image */
+ make_texture_image(ctx, texImage, format, type,
+ pixels, &ctx->Unpack);
+ if (!success && ctx->Driver.TexImage3D) {
+ /* let device driver try to use unpacked image */
+ (*ctx->Driver.TexImage3D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing,
+ texObj, texImage, &retain);
+ }
+ }
+ if (!retain && texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
}
else {
- teximage = make_null_texture(ctx, (GLenum) internalformat,
- width, height, depth, border);
+ make_null_texture(texImage);
+ if (ctx->Driver.TexImage3D) {
+ GLboolean retain;
+ (*ctx->Driver.TexImage3D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing,
+ texObj, texImage, &retain);
+ }
}
- /* install new texture image */
- texUnit->CurrentD[3]->Image[level] = teximage;
- gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[3] );
+ /* state update */
+ gl_put_texobj_on_dirty_list( ctx, texObj );
ctx->NewState |= NEW_TEXTURING;
-
- /* tell driver about change */
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D_EXT,
- texUnit->CurrentD[3],
- level, internalformat, teximage );
- }
}
else if (target==GL_PROXY_TEXTURE_3D_EXT) {
/* Proxy texture: check for errors and update proxy state */
- if (texture_error_check( ctx, target, level, internalformat,
+ if (texture_error_check( ctx, target, level, internalFormat,
format, type, 3, width, height, depth,
border )) {
if (level>=0 && level<ctx->Const.MaxTextureLevels) {
@@ -1232,7 +1335,7 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
else {
ctx->Texture.Proxy3D->Image[level]->Format = (GLenum) format;
set_teximage_component_sizes( ctx->Texture.Proxy3D->Image[level] );
- ctx->Texture.Proxy3D->Image[level]->IntFormat = (GLenum) internalformat;
+ ctx->Texture.Proxy3D->Image[level]->IntFormat = (GLenum) internalFormat;
ctx->Texture.Proxy3D->Image[level]->Border = border;
ctx->Texture.Proxy3D->Image[level]->Width = width;
ctx->Texture.Proxy3D->Image[level]->Height = height;
@@ -1247,16 +1350,106 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
void
-_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
+_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type,
const GLvoid *pixels )
{
- _mesa_TexImage3D(target, level, (GLint) internalformat, width, height,
+ _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height,
depth, border, format, type, pixels);
}
+/*
+ * Fetch a texture image from the device driver.
+ * Store the results in the given texture object at the given mipmap level.
+ */
+static void
+get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level,
+ const struct gl_texture_object *texObj )
+{
+ GLvoid *image;
+ GLenum imgFormat, imgType;
+ GLboolean freeImage;
+ struct gl_texture_image *texImage;
+ GLint destComponents, numPixels, srcBytesPerTexel;
+
+ if (!ctx->Driver.GetTexImage)
+ return;
+
+ image = (*ctx->Driver.GetTexImage)( ctx, target, level,
+ &imgFormat, &imgType, &freeImage);
+ if (!image)
+ return;
+
+ texImage = texObj->Image[level];
+ ASSERT(texImage);
+ if (!texImage)
+ return;
+
+ destComponents = components_in_intformat(texImage->Format);
+ assert(destComponents > 0);
+ numPixels = texImage->Width * texImage->Height * texImage->Depth;
+ assert(numPixels > 0);
+ srcBytesPerTexel = _mesa_bytes_per_pixel(imgFormat, imgType);
+ assert(srcBytesPerTexel > 0);
+
+ if (!texImage->Data) {
+ /* Allocate memory for the texture image data */
+ texImage->Data = (GLubyte *) MALLOC(numPixels * destComponents + EXTRA_BYTE);
+ }
+
+ if (imgFormat == texImage->Format && imgType == GL_UNSIGNED_BYTE) {
+ /* We got lucky! The driver's format and type match Mesa's format. */
+ if (texImage->Data) {
+ MEMCPY(texImage->Data, image, numPixels * destComponents);
+ }
+ }
+ else {
+ /* Convert the texture image from the driver's format to Mesa's
+ * internal format.
+ */
+ const GLint width = texImage->Width;
+ const GLint height = texImage->Height;
+ const GLint depth = texImage->Depth;
+ const GLint destBytesPerRow = width * destComponents * sizeof(GLchan);
+ const GLint srcBytesPerRow = width * srcBytesPerTexel;
+ const GLenum dstType = GL_UNSIGNED_BYTE;
+ const GLenum dstFormat = texImage->Format;
+ const GLubyte *srcPtr = (const GLubyte *) image;
+ GLubyte *destPtr = texImage->Data;
+
+ if (texImage->Format == GL_COLOR_INDEX) {
+ /* color index texture */
+ GLint img, row;
+ assert(imgFormat == GL_COLOR_INDEX);
+ for (img = 0; img < depth; img++) {
+ for (row = 0; row < height; row++) {
+ _mesa_unpack_index_span(ctx, width, dstType, destPtr,
+ imgType, srcPtr, &_mesa_native_packing, GL_FALSE);
+ destPtr += destBytesPerRow;
+ srcPtr += srcBytesPerRow;
+ }
+ }
+ }
+ else {
+ /* color texture */
+ GLint img, row;
+ for (img = 0; img < depth; img++) {
+ for (row = 0; row < height; row++) {
+ _mesa_unpack_ubyte_color_span(ctx, width, dstFormat, destPtr,
+ imgFormat, imgType, srcPtr, &_mesa_native_packing, GL_FALSE);
+ destPtr += destBytesPerRow;
+ srcPtr += srcBytesPerRow;
+ }
+ }
+ }
+ }
+
+ if (freeImage)
+ FREE(image);
+}
+
void
_mesa_GetTexImage( GLenum target, GLint level, GLenum format,
@@ -1264,6 +1457,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
{
GET_CURRENT_CONTEXT(ctx);
const struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLboolean discardImage;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexImage");
@@ -1272,18 +1467,18 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
return;
}
- if (gl_sizeof_type(type) <= 0) {
+ if (_mesa_sizeof_type(type) <= 0) {
gl_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" );
return;
}
- if (gl_components_in_format(format) <= 0) {
+ if (_mesa_components_in_format(format) <= 0) {
gl_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" );
return;
}
if (!pixels)
- return; /* XXX generate an error??? */
+ return;
switch (target) {
case GL_TEXTURE_1D:
@@ -1300,23 +1495,37 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
return;
}
- if (texObj->Image[level] && texObj->Image[level]->Data) {
- const struct gl_texture_image *texImage = texObj->Image[level];
+ texImage = texObj->Image[level];
+ if (!texImage) {
+ /* invalid mipmap level */
+ return;
+ }
+
+ if (!texImage->Data) {
+ /* try to get the texture image from the device driver */
+ get_teximage_from_driver(ctx, target, level, texObj);
+ discardImage = GL_TRUE;
+ }
+ else {
+ discardImage = GL_FALSE;
+ }
+
+ if (texImage->Data) {
GLint width = texImage->Width;
GLint height = texImage->Height;
GLint row;
for (row = 0; row < height; row++) {
/* compute destination address in client memory */
- GLvoid *dest = gl_pixel_addr_in_image( &ctx->Unpack, pixels,
+ GLvoid *dest = _mesa_image_address( &ctx->Unpack, pixels,
width, height,
format, type, 0, row, 0);
assert(dest);
if (texImage->Format == GL_RGBA) {
const GLubyte *src = texImage->Data + row * width * 4 * sizeof(GLubyte);
- gl_pack_rgba_span( ctx, width, (void *) src, format, type, dest,
- &ctx->Pack, GL_TRUE );
+ _mesa_pack_rgba_span( ctx, width, (CONST GLubyte (*)[4]) src,
+ format, type, dest, &ctx->Pack, GL_TRUE );
}
else {
/* fetch RGBA row from texture image then pack it in client mem */
@@ -1379,10 +1588,16 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format,
default:
gl_problem( ctx, "bad format in gl_GetTexImage" );
}
- gl_pack_rgba_span( ctx, width, (const GLubyte (*)[4])rgba,
- format, type, dest, &ctx->Pack, GL_TRUE );
+ _mesa_pack_rgba_span( ctx, width, (const GLubyte (*)[4])rgba,
+ format, type, dest, &ctx->Pack, GL_TRUE );
}
}
+
+ /* if we got the teximage from the device driver we'll discard it now */
+ if (discardImage) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
}
}
@@ -1395,65 +1610,78 @@ _mesa_TexSubImage1D( GLenum target, GLint level,
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- struct gl_texture_image *destTex;
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLboolean success = GL_FALSE;
if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0,
width, 1, 1, format, type)) {
- /* error was detected */
- return;
+ return; /* error was detected */
}
- destTex = texUnit->CurrentD[1]->Image[level];
- assert(destTex);
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = texUnit->CurrentD[1];
+ texImage = texObj->Image[level];
+ assert(texImage);
if (width == 0 || !pixels)
return; /* no-op, not an error */
- /*
- * Replace the texture subimage
- */
- {
- const GLint texComponents = components_in_intformat(destTex->Format);
- const GLenum texFormat = destTex->Format;
- const GLint xoffsetb = xoffset + destTex->Border;
- GLubyte *dst = destTex->Data + xoffsetb * texComponents;
+ if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA
+ && ctx->Driver.TexSubImage1D) {
+ success = (*ctx->Driver.TexSubImage1D)( ctx, target, level, xoffset,
+ width, format, type, pixels,
+ &ctx->Unpack, texObj, texImage );
+ }
+ if (!success) {
+ /* XXX if Driver.TexSubImage1D, unpack image and try again? */
+
+ const GLint texComponents = components_in_intformat(texImage->Format);
+ const GLenum texFormat = texImage->Format;
+ const GLint xoffsetb = xoffset + texImage->Border;
+ GLboolean retain = GL_TRUE;
+ if (!texImage->Data) {
+ get_teximage_from_driver( ctx, target, level, texObj );
+ if (!texImage->Data) {
+ make_null_texture(texImage);
+ }
+ if (!texImage->Data)
+ return; /* we're really out of luck! */
+ }
+
if (texFormat == GL_COLOR_INDEX) {
/* color index texture */
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels,
- width, 1, format, type, 0, 0, 0);
+ GLubyte *dst = texImage->Data + xoffsetb * texComponents;
+ const GLvoid *src = _mesa_image_address(&ctx->Unpack, pixels, width,
+ 1, format, type, 0, 0, 0);
_mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst,
- type, src, &ctx->Unpack, GL_TRUE);
+ type, src, &ctx->Unpack, GL_TRUE);
}
else {
/* color texture */
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels,
- width, 1, format, type, 0, 0, 0);
- _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst,
- format, type, src, &ctx->Unpack, GL_TRUE);
+ GLubyte *dst = texImage->Data + xoffsetb * texComponents;
+ const GLvoid *src = _mesa_image_address(&ctx->Unpack, pixels, width,
+ 1, format, type, 0, 0, 0);
+ _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, format,
+ type, src, &ctx->Unpack, GL_TRUE);
}
- }
- gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] );
+ if (ctx->Driver.TexImage1D) {
+ (*ctx->Driver.TexImage1D)( ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing, texObj, texImage,
+ &retain );
+ }
- /*
- * Inform device driver of texture image change.
- */
- if (ctx->Driver.TexSubImage) {
- (*ctx->Driver.TexSubImage)(ctx, GL_TEXTURE_1D, texUnit->CurrentD[1],
- level, xoffset, 0, width, 1,
- texUnit->CurrentD[1]->Image[level]->IntFormat,
- destTex );
- }
- else {
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_1D, texUnit->CurrentD[1],
- level,
- texUnit->CurrentD[1]->Image[level]->IntFormat,
- destTex );
+ if (!retain && texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
}
}
+
+ /*gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] );*/
}
@@ -1465,76 +1693,104 @@ _mesa_TexSubImage2D( GLenum target, GLint level,
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- struct gl_texture_image *destTex;
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLboolean success = GL_FALSE;
if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
width, height, 1, format, type)) {
- /* error was detected */
- return;
+ return; /* error was detected */
}
- destTex = texUnit->CurrentD[2]->Image[level];
- assert(destTex);
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = texUnit->CurrentD[2];
+ texImage = texObj->Image[level];
+ assert(texImage);
if (width == 0 || height == 0 || !pixels)
return; /* no-op, not an error */
+ if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA
+ && ctx->Driver.TexSubImage2D) {
+ success = (*ctx->Driver.TexSubImage2D)( ctx, target, level, xoffset,
+ yoffset, width, height, format, type,
+ pixels, &ctx->Unpack, texObj, texImage );
+ }
+ if (!success) {
+ /* XXX if Driver.TexSubImage2D, unpack image and try again? */
+
+ const GLint texComponents = components_in_intformat(texImage->Format);
+ const GLenum texFormat = texImage->Format;
+ const GLint xoffsetb = xoffset + texImage->Border;
+ const GLint yoffsetb = yoffset + texImage->Border;
+ const GLint srcStride = _mesa_image_row_stride(&ctx->Unpack, width,
+ format, type);
+ const GLint dstStride = texImage->Width * texComponents *sizeof(GLubyte);
+ GLboolean retain = GL_TRUE;
+
+ if (!texImage->Data) {
+ get_teximage_from_driver( ctx, target, level, texObj );
+ if (!texImage->Data) {
+ make_null_texture(texImage);
+ }
+ if (!texImage->Data)
+ return; /* we're really out of luck! */
+ }
- /*
- * Replace the texture subimage
- */
- {
- const GLint texComponents = components_in_intformat(destTex->Format);
- const GLenum texFormat = destTex->Format;
- const GLint xoffsetb = xoffset + destTex->Border;
- const GLint yoffsetb = yoffset + destTex->Border;
- GLubyte *dst = destTex->Data
- + (yoffsetb * destTex->Width + xoffsetb) * texComponents;
if (texFormat == GL_COLOR_INDEX) {
/* color index texture */
- const GLint stride = destTex->Width * sizeof(GLubyte);
+ GLubyte *dst = texImage->Data
+ + (yoffsetb * texImage->Width + xoffsetb) * texComponents;
+ const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels,
+ width, height, format, type, 0, 0, 0);
GLint row;
for (row = 0; row < height; row++) {
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels,
- width, height, format, type, 0, row, 0);
- _mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst,
- type, src, &ctx->Unpack, GL_TRUE);
- dst += stride;
+ _mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst, type,
+ (const GLvoid *) src, &ctx->Unpack, GL_TRUE);
+ src += srcStride;
+ dst += dstStride;
}
}
else {
/* color texture */
- const GLint stride = destTex->Width * texComponents * sizeof(GLubyte);
+ GLubyte *dst = texImage->Data
+ + (yoffsetb * texImage->Width + xoffsetb) * texComponents;
+ const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels,
+ width, height, format, type, 0, 0, 0);
GLint row;
for (row = 0; row < height; row++) {
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels,
- width, height, format, type, 0, row, 0);
- _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst,
- format, type, src, &ctx->Unpack, GL_TRUE);
- dst += stride;
+ _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, format,
+ type, (const GLvoid *) src, &ctx->Unpack, GL_TRUE);
+ src += srcStride;
+ dst += dstStride;
}
}
- }
- gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[2] );
+ if (ctx->Driver.TexImage2D) {
+ (*ctx->Driver.TexImage2D)(ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing, texObj, texImage,
+ &retain);
+ }
- /*
- * Inform device driver of texture image change.
- */
- if (ctx->Driver.TexSubImage) {
- (*ctx->Driver.TexSubImage)(ctx, GL_TEXTURE_2D, texUnit->CurrentD[2],
- level, xoffset, yoffset, width, height,
- texUnit->CurrentD[2]->Image[level]->IntFormat,
- destTex );
- }
- else {
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_2D, texUnit->CurrentD[2],
- level,
- texUnit->CurrentD[2]->Image[level]->IntFormat,
- destTex );
+ if (!retain && texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
+
+#ifdef OLD_DD_TEXTURE
+ /* XXX this will be removed in the future */
+ if (ctx->Driver.TexSubImage) {
+ (*ctx->Driver.TexSubImage)(ctx, target, texObj, level,
+ xoffset, yoffset, width, height,
+ texImage->IntFormat, texImage);
+ }
+ else if (ctx->Driver.TexImage) {
+ (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_1D, texObj,
+ level, texImage->IntFormat, texImage );
}
+#endif
}
}
@@ -1548,71 +1804,90 @@ _mesa_TexSubImage3D( GLenum target, GLint level,
const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
- struct gl_texture_image *destTex;
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLboolean success = GL_FALSE;
if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
width, height, depth, format, type)) {
- /* error was detected */
- return;
+ return; /* error was detected */
}
- destTex = texUnit->CurrentD[3]->Image[level];
- assert(destTex);
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = texUnit->CurrentD[3];
+ texImage = texObj->Image[level];
+ assert(texImage);
if (width == 0 || height == 0 || height == 0 || !pixels)
return; /* no-op, not an error */
- /*
- * Replace the texture subimage
- */
- {
- const GLint texComponents = components_in_intformat(destTex->Format);
- const GLenum texFormat = destTex->Format;
- const GLint xoffsetb = xoffset + destTex->Border;
- const GLint yoffsetb = yoffset + destTex->Border;
- const GLint zoffsetb = zoffset + destTex->Border;
- GLint dstRectArea = destTex->Width * destTex->Height;
- GLubyte *dst = destTex->Data
- + (zoffsetb * dstRectArea + yoffsetb * destTex->Width + xoffsetb)
- * texComponents;
+ if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA
+ && ctx->Driver.TexSubImage3D) {
+ success = (*ctx->Driver.TexSubImage3D)( ctx, target, level, xoffset,
+ yoffset, zoffset, width, height, depth, format,
+ type, pixels, &ctx->Unpack, texObj, texImage );
+ }
+ if (!success) {
+ /* XXX if Driver.TexSubImage3D, unpack image and try again? */
+
+ const GLint texComponents = components_in_intformat(texImage->Format);
+ const GLenum texFormat = texImage->Format;
+ const GLint xoffsetb = xoffset + texImage->Border;
+ const GLint yoffsetb = yoffset + texImage->Border;
+ const GLint zoffsetb = zoffset + texImage->Border;
+ const GLint texWidth = texImage->Width;
+ const GLint dstRectArea = texWidth * texImage->Height;
+ const GLint srcStride = _mesa_image_row_stride(&ctx->Unpack,
+ width, format, type);
+ const GLint dstStride = texWidth * texComponents * sizeof(GLubyte);
+ GLboolean retain = GL_TRUE;
if (texFormat == GL_COLOR_INDEX) {
/* color index texture */
- const GLint stride = destTex->Width * sizeof(GLubyte);
GLint img, row;
for (img = 0; img < depth; img++) {
+ const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels,
+ width, height, format, type, img, 0, 0);
+ GLubyte *dst = texImage->Data + ((zoffsetb + img) * dstRectArea
+ + yoffsetb * texWidth + xoffsetb) * texComponents;
for (row = 0; row < height; row++) {
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels,
- width, height, format, type, img, row, 0);
_mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst,
- type, src, &ctx->Unpack, GL_TRUE);
- dst += stride;
+ type, (const GLvoid *) src, &ctx->Unpack, GL_TRUE);
+ src += srcStride;
+ dst += dstStride;
}
}
}
else {
/* color texture */
- const GLint stride = destTex->Width * texComponents * sizeof(GLubyte);
GLint img, row;
for (img = 0; img < depth; img++) {
+ const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels,
+ width, height, format, type, img, 0, 0);
+ GLubyte *dst = texImage->Data + ((zoffsetb + img) * dstRectArea
+ + yoffsetb * texWidth + xoffsetb) * texComponents;
for (row = 0; row < height; row++) {
- const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels,
- width, height, format, type, img, row, 0);
_mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst,
- format, type, src, &ctx->Unpack, GL_TRUE);
- dst += stride;
+ format, type, (const GLvoid *) src, &ctx->Unpack, GL_TRUE);
+ src += srcStride;
+ dst += dstStride;
}
}
}
- }
- gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] );
+ if (ctx->Driver.TexImage3D) {
+ (*ctx->Driver.TexImage3D)(ctx, target, level, texImage->Format,
+ GL_UNSIGNED_BYTE, texImage->Data,
+ &_mesa_native_packing, texObj, texImage,
+ &retain);
+ }
- /*
- * Inform device driver of texture image change.
- */
- /* XXX todo */
+ if (!retain && texImage->Data) {
+ FREE(texImage->Data);
+ texImage->Data = NULL;
+ }
+ }
}
@@ -1632,7 +1907,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y,
GLint stride, i;
GLubyte *image, *dst;
- image = MALLOC(width * height * 4 * sizeof(GLubyte));
+ image = (GLubyte *) MALLOC(width * height * 4 * sizeof(GLubyte));
if (!image)
return NULL;
@@ -1666,15 +1941,22 @@ _mesa_CopyTexImage1D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexImage1D");
- if (!copytexture_error_check(ctx, 1, target, level, internalFormat,
- width, 1, border)) {
+ if (copytexture_error_check(ctx, 1, target, level, internalFormat,
+ width, 1, border))
+ return;
+
+ if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA
+ || !ctx->Driver.CopyTexImage1D
+ || !(*ctx->Driver.CopyTexImage1D)(ctx, target, level,
+ internalFormat, x, y, width, border))
+ {
GLubyte *image = read_color_image( ctx, x, y, width, 1 );
if (!image) {
gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D" );
return;
}
(*ctx->Exec->TexImage1D)( target, level, internalFormat, width,
- border, GL_RGBA, GL_UNSIGNED_BYTE, image );
+ border, GL_RGBA, GL_UNSIGNED_BYTE, image );
FREE(image);
}
}
@@ -1689,15 +1971,22 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexImage2D");
- if (!copytexture_error_check(ctx, 2, target, level, internalFormat,
- width, height, border)) {
+ if (copytexture_error_check(ctx, 2, target, level, internalFormat,
+ width, height, border))
+ return;
+
+ if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA
+ || !ctx->Driver.CopyTexImage2D
+ || !(*ctx->Driver.CopyTexImage2D)(ctx, target, level,
+ internalFormat, x, y, width, height, border))
+ {
GLubyte *image = read_color_image( ctx, x, y, width, height );
if (!image) {
gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D" );
return;
}
(ctx->Exec->TexImage2D)( target, level, internalFormat, width,
- height, border, GL_RGBA, GL_UNSIGNED_BYTE, image );
+ height, border, GL_RGBA, GL_UNSIGNED_BYTE, image );
FREE(image);
}
}
@@ -1713,17 +2002,6 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest,
GLint srcx, GLint srcy,
GLint dstx, GLint dsty, GLint dstz )
{
- static struct gl_pixelstore_attrib packing = {
- 1, /* Alignment */
- 0, /* RowLength */
- 0, /* SkipPixels */
- 0, /* SkipRows */
- 0, /* ImageHeight */
- 0, /* SkipImages */
- GL_FALSE, /* SwapBytes */
- GL_FALSE /* LsbFirst */
- };
-
GLint i;
GLint format, components, rectarea;
GLint texwidth, texheight, zoffset;
@@ -1750,7 +2028,7 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest,
dst = dest->Data + ( zoffset + (dsty+i) * texwidth + dstx) * components;
_mesa_unpack_ubyte_color_span(ctx, width, format, dst,
GL_RGBA, GL_UNSIGNED_BYTE, rgba,
- &packing, GL_TRUE);
+ &_mesa_native_packing, GL_TRUE);
}
/* Read from draw buffer (the default) */
@@ -1768,8 +2046,14 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage1D");
- if (!copytexsubimage_error_check(ctx, 1, target, level,
- xoffset, 0, 0, width, 1)) {
+ if (copytexsubimage_error_check(ctx, 1, target, level,
+ xoffset, 0, 0, width, 1))
+ return;
+
+ if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA
+ || !ctx->Driver.CopyTexSubImage1D
+ || !(*ctx->Driver.CopyTexSubImage1D)(ctx, target, level,
+ xoffset, x, y, width)) {
struct gl_texture_unit *texUnit;
struct gl_texture_image *teximage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@ -1777,12 +2061,13 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
assert(teximage);
if (teximage->Data) {
copy_tex_sub_image(ctx, teximage, width, 1, x, y, xoffset, 0, 0);
- /* tell driver about the change */
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D,
- texUnit->CurrentD[1],
- level, teximage->IntFormat, teximage );
- }
+ /* tell driver about the change */
+ /* XXX call Driver.TexSubImage instead? */
+ if (ctx->Driver.TexImage) {
+ (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D,
+ texUnit->CurrentD[1],
+ level, teximage->IntFormat, teximage );
+ }
}
}
}
@@ -1797,8 +2082,14 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage2D");
- if (!copytexsubimage_error_check(ctx, 2, target, level,
- xoffset, yoffset, 0, width, height)) {
+ if (copytexsubimage_error_check(ctx, 2, target, level,
+ xoffset, yoffset, 0, width, height))
+ return;
+
+ if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA
+ || !ctx->Driver.CopyTexSubImage2D
+ || !(*ctx->Driver.CopyTexSubImage2D)(ctx, target, level,
+ xoffset, yoffset, x, y, width, height )) {
struct gl_texture_unit *texUnit;
struct gl_texture_image *teximage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@ -1807,11 +2098,12 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
if (teximage->Data) {
copy_tex_sub_image(ctx, teximage, width, height,
x, y, xoffset, yoffset, 0);
- /* tell driver about the change */
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D,
- texUnit->CurrentD[2],
- level, teximage->IntFormat, teximage );
+ /* tell driver about the change */
+ /* XXX call Driver.TexSubImage instead? */
+ if (ctx->Driver.TexImage) {
+ (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D,
+ texUnit->CurrentD[2],
+ level, teximage->IntFormat, teximage );
}
}
}
@@ -1827,8 +2119,14 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage3D");
- if (!copytexsubimage_error_check(ctx, 3, target, level,
- xoffset, yoffset, zoffset, width, height)) {
+ if (copytexsubimage_error_check(ctx, 3, target, level,
+ xoffset, yoffset, zoffset, width, height))
+ return;
+
+ if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA
+ || !ctx->Driver.CopyTexSubImage3D
+ || !(*ctx->Driver.CopyTexSubImage3D)(ctx, target, level,
+ xoffset, yoffset, zoffset, x, y, width, height )) {
struct gl_texture_unit *texUnit;
struct gl_texture_image *teximage;
texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
@@ -1837,13 +2135,13 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
if (teximage->Data) {
copy_tex_sub_image(ctx, teximage, width, height,
x, y, xoffset, yoffset, zoffset);
- /* tell driver about the change */
- if (ctx->Driver.TexImage) {
- (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D,
- texUnit->CurrentD[3],
- level, teximage->IntFormat, teximage );
- }
+ /* tell driver about the change */
+ /* XXX call Driver.TexSubImage instead? */
+ if (ctx->Driver.TexImage) {
+ (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D,
+ texUnit->CurrentD[3],
+ level, teximage->IntFormat, teximage );
+ }
}
}
}
-
diff --git a/xc/extras/Mesa/src/teximage.h b/xc/extras/Mesa/src/teximage.h
index 167708d26..5f1bb8a27 100644
--- a/xc/extras/Mesa/src/teximage.h
+++ b/xc/extras/Mesa/src/teximage.h
@@ -34,6 +34,10 @@
/*** Internal functions ***/
+extern GLint
+_mesa_base_tex_format( GLint format );
+
+
extern struct gl_texture_image *
gl_alloc_texture_image( void );
diff --git a/xc/extras/Mesa/src/texobj.c b/xc/extras/Mesa/src/texobj.c
index e30032376..9d00bcd50 100644
--- a/xc/extras/Mesa/src/texobj.c
+++ b/xc/extras/Mesa/src/texobj.c
@@ -324,6 +324,8 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur
}
+_glthread_DECLARE_STATIC_MUTEX(GenTexturesLock);
+
/*
* Execute glGenTextures
@@ -341,6 +343,12 @@ _mesa_GenTextures( GLsizei n, GLuint *texName )
return;
}
+
+ /*
+ * This must be atomic (generation and allocation of texture IDs)
+ */
+ _glthread_LOCK_MUTEX(GenTexturesLock);
+
first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
/* Return the texture names */
@@ -354,6 +362,8 @@ _mesa_GenTextures( GLsizei n, GLuint *texName )
GLuint dims = 0;
(void) gl_alloc_texture_object(ctx->Shared, name, dims);
}
+
+ _glthread_UNLOCK_MUTEX(GenTexturesLock);
}
diff --git a/xc/extras/Mesa/src/texstate.c b/xc/extras/Mesa/src/texstate.c
index 3b0a7f539..41b2f0219 100644
--- a/xc/extras/Mesa/src/texstate.c
+++ b/xc/extras/Mesa/src/texstate.c
@@ -68,35 +68,24 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv");
- if (target!=GL_TEXTURE_ENV) {
- gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
- return;
- }
-
- if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
- fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",
- gl_lookup_enum_by_nr(target),
- gl_lookup_enum_by_nr(pname),
- *param,
- gl_lookup_enum_by_nr((GLenum) (GLint) *param));
-
-
- if (pname==GL_TEXTURE_ENV_MODE) {
- GLenum mode = (GLenum) (GLint) *param;
- switch (mode) {
- case GL_ADD:
- if (!gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add")) {
- gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
- return;
- }
- /* FALL-THROUGH */
- case GL_MODULATE:
- case GL_BLEND:
- case GL_DECAL:
- case GL_REPLACE:
+ if (target==GL_TEXTURE_ENV) {
+
+ if (pname==GL_TEXTURE_ENV_MODE) {
+ GLenum mode = (GLenum) (GLint) *param;
+ switch (mode) {
+ case GL_ADD:
+ if (!ctx->Extensions.HaveTextureEnvAdd) {
+ gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)");
+ return;
+ }
+ /* FALL-THROUGH */
+ case GL_MODULATE:
+ case GL_BLEND:
+ case GL_DECAL:
+ case GL_REPLACE:
/* A small optimization for drivers */
if (texUnit->EnvMode == mode)
- return;
+ return;
if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE))
fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n",
@@ -109,23 +98,53 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
default:
gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" );
return;
+ }
}
+ else if (pname==GL_TEXTURE_ENV_COLOR) {
+ texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
+ texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
+ texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
+ texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+ return;
+ }
+
}
- else if (pname==GL_TEXTURE_ENV_COLOR) {
- texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F );
- texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F );
- texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F );
- texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F );
+ else if (target==GL_TEXTURE_FILTER_CONTROL_EXT) {
+
+ if (!ctx->Extensions.HaveTextureLodBias) {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" );
+ return;
+ }
+
+ if (pname==GL_TEXTURE_LOD_BIAS_EXT) {
+ texUnit->LodBias = param[0];
+ }
+ else {
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+ return;
+ }
+
}
else {
- gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+ gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" );
return;
}
+ if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
+ fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n",
+ gl_lookup_enum_by_nr(target),
+ gl_lookup_enum_by_nr(pname),
+ *param,
+ gl_lookup_enum_by_nr((GLenum) (GLint) *param));
+
/* Tell device driver about the new texture environment */
if (ctx->Driver.TexEnv) {
- (*ctx->Driver.TexEnv)( ctx, pname, param );
+ (*ctx->Driver.TexEnv)( ctx, target, pname, param );
}
+
}
diff --git a/xc/extras/Mesa/src/texture.c b/xc/extras/Mesa/src/texture.c
index c73171bd2..f1e350ce4 100644
--- a/xc/extras/Mesa/src/texture.c
+++ b/xc/extras/Mesa/src/texture.c
@@ -2096,9 +2096,16 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n,
if (ctx->Texture.Enabled & mask) {
const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit[texUnit];
if (textureUnit->Current && textureUnit->Current->SampleFunc) {
-
GLubyte texel[PB_SIZE][4];
+ if (textureUnit->LodBias != 0.0F) {
+ /* apply LOD bias, but don't clamp yet */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ lambda[i] += textureUnit->LodBias;
+ }
+ }
+
if (textureUnit->Current->MinLod != -1000.0
|| textureUnit->Current->MaxLod != 1000.0) {
/* apply LOD clamping to lambda */
diff --git a/xc/extras/Mesa/src/triangle.c b/xc/extras/Mesa/src/triangle.c
index 818eda29d..4c89ae9f5 100644
--- a/xc/extras/Mesa/src/triangle.c
+++ b/xc/extras/Mesa/src/triangle.c
@@ -35,6 +35,7 @@
#include "all.h"
#else
#include "glheader.h"
+#include "aatriangle.h"
#include "context.h"
#include "depth.h"
#include "feedback.h"
@@ -77,7 +78,6 @@ static void flat_ci_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
{
#define INTERP_Z 1
-
#define SETUP_CODE \
GLuint index = VB->IndexPtr->data[pv]; \
if (1) { \
@@ -143,6 +143,7 @@ static void flat_rgba_triangle( GLcontext *ctx,
GLuint v0, GLuint v1, GLuint v2, GLuint pv )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define SETUP_CODE \
if (1) { \
@@ -185,6 +186,7 @@ static void smooth_rgba_triangle( GLcontext *ctx,
{
(void) pv;
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
@@ -276,6 +278,7 @@ static void simple_z_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_INT_ST 1
#define S_SCALE twidth
#define T_SCALE theight
@@ -335,6 +338,7 @@ static void affine_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_INT_ST 1
@@ -621,6 +625,7 @@ static void persp_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STUV 1
@@ -852,6 +857,7 @@ static void general_textured_triangle( GLcontext *ctx, GLuint v0, GLuint v1,
GLuint v2, GLuint pv )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STUV 1
@@ -936,6 +942,7 @@ static void general_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
GLubyte spec[MAX_WIDTH][4] )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_SPEC 1
#define INTERP_ALPHA 1
@@ -1051,6 +1058,7 @@ static void lambda_textured_triangle1( GLcontext *ctx, GLuint v0, GLuint v1,
GLfloat u[MAX_WIDTH] )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STUV 1
@@ -1146,6 +1154,7 @@ static void lambda_textured_spec_triangle1( GLcontext *ctx, GLuint v0,
GLfloat u[MAX_WIDTH] )
{
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_SPEC 1
#define INTERP_ALPHA 1
@@ -1255,6 +1264,7 @@ static void lambda_multitextured_triangle1( GLcontext *ctx, GLuint v0,
{
GLubyte rgba[MAX_WIDTH][4];
#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
#define INTERP_RGB 1
#define INTERP_ALPHA 1
#define INTERP_STUV 1
@@ -1453,12 +1463,19 @@ void gl_set_triangle_function( GLcontext *ctx )
}
if (ctx->Driver.TriangleFunc) {
/* Device driver will draw triangles. */
+ dputs("Driver triangle");
return;
}
+ if (ctx->Polygon.SmoothFlag) {
+ _mesa_set_aa_triangle_function(ctx);
+ ASSERT(ctx->Driver.TriangleFunc);
+ return;
+ }
+
if (ctx->Texture.ReallyEnabled) {
/* Ugh, we do a _lot_ of tests to pick the best textured tri func */
- int format, filter;
+ GLint format, filter;
const struct gl_texture_object *current2Dtex = ctx->Texture.Unit[0].CurrentD[2];
const struct gl_texture_image *image;
/* First see if we can used an optimized 2-D texture function */
@@ -1553,17 +1570,25 @@ void gl_set_triangle_function( GLcontext *ctx )
else {
if (ctx->Light.ShadeModel==GL_SMOOTH) {
/* smooth shaded, no texturing, stippled or some raster ops */
- if (rgbmode)
+ if (rgbmode) {
+ dputs("smooth_rgba_triangle");
ctx->Driver.TriangleFunc = smooth_rgba_triangle;
- else
+ }
+ else {
+ dputs("smooth_ci_triangle");
ctx->Driver.TriangleFunc = smooth_ci_triangle;
+ }
}
else {
/* flat shaded, no texturing, stippled or some raster ops */
- if (rgbmode)
+ if (rgbmode) {
+ dputs("flat_rgba_triangle");
ctx->Driver.TriangleFunc = flat_rgba_triangle;
- else
+ }
+ else {
+ dputs("flat_ci_triangle");
ctx->Driver.TriangleFunc = flat_ci_triangle;
+ }
}
}
}
diff --git a/xc/extras/Mesa/src/tritemp.h b/xc/extras/Mesa/src/tritemp.h
index ed2b8324f..dd87a2994 100644
--- a/xc/extras/Mesa/src/tritemp.h
+++ b/xc/extras/Mesa/src/tritemp.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/tritemp.h,v 1.7 2000/02/18 12:18:46 tsi Exp $ */
+
/*
* Triangle Rasterizer Template
@@ -50,6 +50,10 @@
* PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
* Y==0 at bottom of screen and increases upward.
*
+ * Similarly, for direct depth buffer access, this type is used for depth
+ * buffer addressing:
+ * DEPTH_TYPE - either GLushort or GLuint
+ *
* Optionally, one may provide one-time setup code per triangle:
* SETUP_CODE - code which is to be executed once per triangle
*
@@ -82,6 +86,12 @@
GLfixed fx0; /* fixed pt X of lower endpoint */
} EdgeT;
+#ifdef INTERP_Z
+ const GLint depthBits = ctx->Visual->DepthBits;
+ const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+ const GLfloat maxDepth = ctx->Visual->DepthMaxF;
+#define FixedToDepth(F) ((F) >> fixedToDepthShift)
+#endif
const struct vertex_buffer *VB = ctx->VB;
EdgeT eMaj, eTop, eBot;
GLfloat oneOverArea;
@@ -273,7 +283,7 @@
eMaj_dz = VB->Win.data[vMax][2] - VB->Win.data[vMin][2];
eBot_dz = VB->Win.data[vMid][2] - VB->Win.data[vMin][2];
dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
- if (dzdx>DEPTH_SCALE || dzdx<-DEPTH_SCALE) {
+ if (dzdx > maxDepth || dzdx < -maxDepth) {
/* probably a sliver triangle */
dzdx = 0.0;
dzdy = 0.0;
@@ -281,11 +291,10 @@
else {
dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx);
}
-#if DEPTH_BITS==16
- fdzdx = SignedFloatToFixed(dzdx);
-#else
- fdzdx = (GLint) dzdx;
-#endif
+ if (depthBits <= 16)
+ fdzdx = SignedFloatToFixed(dzdx);
+ else
+ fdzdx = (GLint) dzdx;
}
#endif
#ifdef INTERP_RGB
@@ -555,8 +564,10 @@
int dPRowOuter, dPRowInner; /* offset in bytes */
#endif
#ifdef INTERP_Z
- GLdepth *zRow;
+# ifdef DEPTH_TYPE
+ DEPTH_TYPE *zRow;
int dZRowOuter, dZRowInner; /* offset in bytes */
+# endif
GLfixed fz, fdzOuter, fdzInner;
#endif
#ifdef INTERP_RGB
@@ -676,24 +687,25 @@
#ifdef INTERP_Z
{
- GLfloat z0, tmp;
- z0 = VB->Win.data[vLower][2] + ctx->PolygonZoffset;
-#if DEPTH_BITS==16
- /* interpolate fixed-pt values */
- tmp = (z0 * FIXED_SCALE + dzdx * adjx + dzdy * adjy) + FIXED_HALF;
- if (tmp < MAX_GLUINT/2)
- fz = (GLfixed) tmp;
- else
- fz = MAX_GLUINT/2;
- fdzOuter = SignedFloatToFixed(dzdy + dxOuter * dzdx);
-#else
- (void) tmp;
- /* interpolate depth values exactly */
- fz = (GLint) (z0 + dzdx*FixedToFloat(adjx) + dzdy*FixedToFloat(adjy));
- fdzOuter = (GLint) (dzdy + dxOuter * dzdx);
-#endif
- zRow = Z_ADDRESS( ctx, FixedToInt(fxLeftEdge), iy );
- dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(GLdepth);
+ GLfloat z0 = VB->Win.data[vLower][2] + ctx->PolygonZoffset;
+ if (depthBits <= 16) {
+ /* interpolate fixed-pt values */
+ GLfloat tmp = (z0 * FIXED_SCALE + dzdx * adjx + dzdy * adjy) + FIXED_HALF;
+ if (tmp < MAX_GLUINT / 2)
+ fz = (GLfixed) tmp;
+ else
+ fz = MAX_GLUINT / 2;
+ fdzOuter = SignedFloatToFixed(dzdy + dxOuter * dzdx);
+ }
+ else {
+ /* interpolate depth values exactly */
+ fz = (GLint) (z0 + dzdx*FixedToFloat(adjx) + dzdy*FixedToFloat(adjy));
+ fdzOuter = (GLint) (dzdy + dxOuter * dzdx);
+ }
+# ifdef DEPTH_TYPE
+ zRow = (DEPTH_TYPE *) _mesa_zbuffer_address(ctx, FixedToInt(fxLeftEdge), iy);
+ dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
+# endif
}
#endif
#ifdef INTERP_RGB
@@ -838,7 +850,9 @@
dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE);
#endif
#ifdef INTERP_Z
- dZRowInner = dZRowOuter + sizeof(GLdepth);
+# ifdef DEPTH_TYPE
+ dZRowInner = dZRowOuter + sizeof(DEPTH_TYPE);
+# endif
fdzInner = fdzOuter + fdzdx;
#endif
#ifdef INTERP_RGB
@@ -879,7 +893,6 @@
/* ff = fixed-pt fragment */
#ifdef INTERP_Z
GLfixed ffz = fz;
- /*GLdepth *zp = zRow;*/
#endif
#ifdef INTERP_RGB
GLfixed ffr = fr, ffg = fg, ffb = fb;
@@ -963,10 +976,12 @@
if (fError >= 0) {
fError -= FIXED_ONE;
#ifdef PIXEL_ADDRESS
- pRow = (PIXEL_TYPE*) ((GLubyte*)pRow + dPRowOuter);
+ pRow = (PIXEL_TYPE *) ((GLubyte*)pRow + dPRowOuter);
#endif
#ifdef INTERP_Z
- zRow = (GLdepth*) ((GLubyte*)zRow + dZRowOuter);
+# ifdef DEPTH_TYPE
+ zRow = (DEPTH_TYPE *) ((GLubyte*)zRow + dZRowOuter);
+# endif
fz += fdzOuter;
#endif
#ifdef INTERP_RGB
@@ -999,10 +1014,12 @@
}
else {
#ifdef PIXEL_ADDRESS
- pRow = (PIXEL_TYPE*) ((GLubyte*)pRow + dPRowInner);
+ pRow = (PIXEL_TYPE *) ((GLubyte*)pRow + dPRowInner);
#endif
#ifdef INTERP_Z
- zRow = (GLdepth*) ((GLubyte*)zRow + dZRowInner);
+# ifdef DEPTH_TYPE
+ zRow = (DEPTH_TYPE *) ((GLubyte*)zRow + dZRowInner);
+# endif
fz += fdzInner;
#endif
#ifdef INTERP_RGB
@@ -1059,3 +1076,5 @@
#undef S_SCALE
#undef T_SCALE
+
+#undef FixedToDepth
diff --git a/xc/extras/Mesa/src/types.h b/xc/extras/Mesa/src/types.h
index b3af90a8c..dc1b5e103 100644
--- a/xc/extras/Mesa/src/types.h
+++ b/xc/extras/Mesa/src/types.h
@@ -82,13 +82,7 @@
/*
* Depth buffer data type:
*/
-#if DEPTH_BITS==16
- typedef GLushort GLdepth;
-#elif DEPTH_BITS==32
- typedef GLint GLdepth;
-#else
-# error "illegal number of depth bits"
-#endif
+typedef GLuint GLdepth; /* Must be 32-bits! */
@@ -392,6 +386,7 @@ struct gl_depthbuffer_attrib {
GLfloat Clear; /* Value to clear depth buffer to */
GLboolean Test; /* Depth buffering enabled flag */
GLboolean Mask; /* Depth buffer writable? */
+ GLboolean OcclusionTest;/* XXX GL_HP_occlusion_test */
};
@@ -774,6 +769,7 @@ struct gl_texture_unit {
GLubyte Holes; /* elements not generated by texgen */
GLuint TexgenSize; /* size of element generated */
GLboolean AnyTransform; /* texgen or non-identity matrix */
+ GLfloat LodBias; /* for biasing mipmap levels */
struct gl_texture_object *CurrentD[4];
struct gl_texture_object *Current;
@@ -1197,6 +1193,9 @@ struct gl_visual {
GLint StencilBits; /* Number of bits in stencil buffer, or 0 */
GLboolean SoftwareAlpha; /* Implement software alpha buffer? */
+
+ GLuint DepthMax; /* Max depth buffer value */
+ GLfloat DepthMaxF; /* Float max depth buffer value */
};
@@ -1218,7 +1217,7 @@ struct gl_frame_buffer {
GLboolean UseSoftwareAlphaBuffers;
/* Software depth (aka Z) buffer */
- GLdepth *Depth; /* array [Width*Height] of GLdepth values */
+ GLvoid *DepthBuffer; /* array [Width*Height] of GLushort or GLuint*/
/* Software stencil buffer */
GLstencil *Stencil; /* array [Width*Height] of GLstencil values */
@@ -1234,7 +1233,7 @@ struct gl_frame_buffer {
GLubyte *Alpha; /* Points to current alpha buffer */
/* Drawing bounds: intersection of window size and scissor box */
- GLint Xmin, Xmax, Ymin, Ymax;
+ GLint Xmin, Xmax, Ymin, Ymax; /* [Xmin,Xmax] X [Ymin,Ymax] */
};
@@ -1264,6 +1263,10 @@ struct extension;
struct gl_extensions {
char *ext_string;
struct extension *ext_list;
+ /* flags to quickly test if certain extensions are available */
+ GLboolean HaveTextureEnvAdd;
+ GLboolean HaveTextureLodBias;
+ GLboolean HaveHpOcclusionTest;
};
@@ -1282,6 +1285,8 @@ struct gl_extensions {
#define WINCLIP_BIT 0x200 /* Clip pixels/primitives to window */
#define MULTI_DRAW_BIT 0x400 /* Write to more than one color- */
/* buffer or no buffers. */
+#define OCCLUSION_BIT 0x800 /* GL_HP_occlusion_test enabled */
+
/*
* Bits to indicate what state has to be updated (NewState)
@@ -1338,6 +1343,9 @@ struct gl_extensions {
#define DD_TRI_CULL_FRONT_BACK 0x400000 /* not supported by most drivers */
#define DD_Z_NEVER 0x800000
#define DD_STENCIL 0x1000000
+#define DD_CLIP_FOG_COORD 0x2000000
+
+
#define DD_SW_SETUP (DD_TRI_CULL| \
DD_TRI_CULL_FRONT_BACK| \
@@ -1540,7 +1548,8 @@ typedef union node Node;
#define VERT_EVAL_C2 0x2000000 /* - or just use 3 bits */
#define VERT_EVAL_P1 0x4000000 /* */
#define VERT_EVAL_P2 0x8000000 /* */
-#define VERT_FLOAT_RGBA 0x10000000 /* allow partial support for this */
+#define VERT_SPEC_RGB 0x10000000
+#define VERT_FOG_COORD 0x20000000 /* internal use only, currently */
#define VERT_EYE VERT_BEGIN /* for pipeline management & cva */
#define VERT_WIN VERT_END /* some overlaps can be tolerated */
@@ -1591,7 +1600,7 @@ typedef union node Node;
#define VERT_DATA (VERT_TEX0_ANY|VERT_TEX1_ANY|VERT_RGBA| \
VERT_INDEX|VERT_EDGE|VERT_NORM| \
VERT_OBJ_ANY|VERT_MATERIAL|VERT_ELT| \
- VERT_EVAL_ANY)
+ VERT_EVAL_ANY|VERT_FOG_COORD)
#define VERT_TO_PIPE (~VERT_END_VB)
@@ -1764,7 +1773,6 @@ struct gl_context {
GLboolean DoViewportMapping;
-
GLuint RenderFlags; /* Active inputs to render stage */
GLuint RequireWriteableFlags; /* What can the driver/clipping tolerate? */
@@ -1791,6 +1799,8 @@ struct gl_context {
GLfloat backface_sign;
+ GLboolean OcclusionResult; /* GL_HP_occlusion_test */
+
/* Destination of immediate mode commands */
struct immediate *input;
@@ -1863,7 +1873,8 @@ enum _verbose {
VERBOSE_API = 0x40,
VERBOSE_TRIANGLE_CHECKS = 0x80,
VERBOSE_CULL = 0x100,
- VERBOSE_DISPLAY_LIST = 0x200
+ VERBOSE_DISPLAY_LIST = 0x200,
+ VERBOSE_LIGHTING = 0x400
};
diff --git a/xc/extras/Mesa/src/varray.c b/xc/extras/Mesa/src/varray.c
index f931a2105..dc758594a 100644
--- a/xc/extras/Mesa/src/varray.c
+++ b/xc/extras/Mesa/src/varray.c
@@ -680,6 +680,7 @@ _mesa_DrawArrays(GLenum mode, GLint start, GLsizei count)
VB->NextPrimitive[VB->CopyStart] = VB->Count;
VB->Primitive[VB->CopyStart] = mode;
+ ctx->Array.Flag[count] |= VERT_END_VB;
/* Transform and render.
*/
@@ -815,7 +816,7 @@ _mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indice
return;
}
- if (mode > GL_POLYGON) {
+ if (mode < 0 || mode > GL_POLYGON) {
gl_error( ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
return;
}
diff --git a/xc/extras/Mesa/src/vbfill.c b/xc/extras/Mesa/src/vbfill.c
index 09914e3bc..75a576467 100644
--- a/xc/extras/Mesa/src/vbfill.c
+++ b/xc/extras/Mesa/src/vbfill.c
@@ -231,28 +231,6 @@ void gl_End( GLcontext *ctx )
IM->Color[count][3] = a; \
}
-#if 0
-#define COLOR4F( IM, r,g,b,a ) \
-{ \
- GLuint count = IM->Count; \
- IM->Flag[count] |= VERT_RGBA | VERT_FLOAT_RGBA; \
- IM->FloatColor[count][0] = r; \
- IM->FloatColor[count][1] = g; \
- IM->FloatColor[count][2] = b; \
- IM->FloatColor[count][3] = a; \
-}
-#else
-#define COLOR4F(IM, r, g, b, a) \
-{ \
- GLubyte col[4]; \
- FLOAT_COLOR_TO_UBYTE_COLOR(col[0], r); \
- FLOAT_COLOR_TO_UBYTE_COLOR(col[1], g); \
- FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b); \
- FLOAT_COLOR_TO_UBYTE_COLOR(col[3], a); \
- COLORV( IM, col ); \
-}
-#endif
-
#define COLORV( IM, v ) \
{ \
GLuint count = IM->Count; \
@@ -286,8 +264,6 @@ _mesa_Color3d(GLdouble red, GLdouble green, GLdouble blue )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b);
col[3] = 255;
COLORV( IM, col );
-
-/* COLOR4F( IM, red, green, blue, 1.0 ); */
}
@@ -301,8 +277,6 @@ _mesa_Color3f(GLfloat red, GLfloat green, GLfloat blue )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], blue);
col[3] = 255;
COLORV( IM, col );
-
-/* COLOR4F( IM, red, green, blue, 1.0 ); */
}
@@ -380,8 +354,6 @@ _mesa_Color4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b);
FLOAT_COLOR_TO_UBYTE_COLOR(col[3], a);
COLORV( IM, col );
-
-/* COLOR4F( IM, red, green, blue, alpha ); */
}
@@ -395,8 +367,6 @@ _mesa_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], blue);
FLOAT_COLOR_TO_UBYTE_COLOR(col[3], alpha);
COLORV( IM, col );
-
-/* COLOR4F( IM, red, green, blue, alpha ); */
}
@@ -463,8 +433,6 @@ _mesa_Color3dv(const GLdouble *v )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b);
col[3]= 255;
COLORV( IM, col );
-
-/* COLOR4F( IM, v[0], v[1], v[2], v[3] ); */
}
@@ -478,8 +446,6 @@ _mesa_Color3fv(const GLfloat *v )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], v[2]);
col[3] = 255;
COLORV( IM, col );
-
-/* COLOR4F( IM, v[0], v[1], v[2], v[3] ); */
}
@@ -551,8 +517,6 @@ _mesa_Color4dv(const GLdouble *v )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], b);
FLOAT_COLOR_TO_UBYTE_COLOR(col[3], a);
COLORV( IM, col );
-
-/* COLOR4F( IM, v[0], v[1], v[2], v[3] ); */
}
@@ -566,8 +530,6 @@ _mesa_Color4fv(const GLfloat *v )
FLOAT_COLOR_TO_UBYTE_COLOR(col[2], v[2]);
FLOAT_COLOR_TO_UBYTE_COLOR(col[3], v[3]);
COLORV( IM, col );
-
-/* COLOR4F( IM, v[0], v[1], v[2], v[3] ); */
}
@@ -1329,9 +1291,10 @@ _mesa_Vertex4sv( const GLshort *v )
/* KW: Do the check here so that we only have to do a single range
- * test. The possible compliance problem with this is that
- * we will throw out error-producing calls when compiling
- * display lists. There are ways around this if need be.
+ * test. The possible compliance problem with this is that we
+ * will throw out error-producing calls when compiling display
+ * lists. The solution is to do dispatch on gl_error to call
+ * gl_save_error if compiling.
*/
@@ -1344,7 +1307,8 @@ _mesa_Vertex4sv( const GLshort *v )
texSet = target - GL_TEXTURE0_ARB; \
} \
else { \
- gl_error(IM->backref, GL_INVALID_ENUM, "glMultiTexCoord(target)"); \
+ gl_error(IM->backref, GL_INVALID_ENUM, \
+ "glMultiTexCoord(target)"); \
return; \
}
diff --git a/xc/extras/Mesa/src/vbrender.c b/xc/extras/Mesa/src/vbrender.c
index ff493f5fc..507bf195a 100644
--- a/xc/extras/Mesa/src/vbrender.c
+++ b/xc/extras/Mesa/src/vbrender.c
@@ -164,7 +164,7 @@ static void unfilled_polygon( GLcontext *ctx,
j1 = vlist[i+1];
if (edge_ptr[j0] & 0x1) {
- edge_ptr[j0] &= ~1;
+ edge_ptr[j0] &= ~0x1;
(*ctx->Driver.LineFunc)( ctx, j0, j1, pv );
}
}
@@ -174,7 +174,7 @@ static void unfilled_polygon( GLcontext *ctx,
j1 = vlist[0];
if (edge_ptr[j0] & 0x2) {
- edge_ptr[j0] &= ~2;
+ edge_ptr[j0] &= ~0x2;
(*ctx->Driver.LineFunc)( ctx, j0, j1, pv );
}
}
@@ -219,7 +219,9 @@ static INLINE void gl_render_clipped_triangle2( GLcontext *ctx,
GLuint pv )
{
struct vertex_buffer *VB = ctx->VB;
- GLubyte mask = (GLubyte) (VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3]);
+ GLubyte mask = (GLubyte) (VB->ClipMask[v1] |
+ VB->ClipMask[v2] |
+ VB->ClipMask[v3]);
GLuint vlist[VB_MAX_CLIPPED_VERTS];
GLuint i, n;
@@ -233,7 +235,38 @@ static INLINE void gl_render_clipped_triangle2( GLcontext *ctx,
ASSIGN_3V(vlist, v1, v2, v3 );
n = (ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 3, vlist, mask );
-
+
+ for (i=2;i<n;i++)
+ ctx->TriangleFunc( ctx, *vlist, vlist[i-1], vlist[i], pv );
+}
+
+
+static INLINE void gl_render_clipped_quad2( GLcontext *ctx,
+ GLuint v1, GLuint v2, GLuint v3,
+ GLuint v4,
+ GLuint pv )
+{
+ struct vertex_buffer *VB = ctx->VB;
+ GLubyte mask = (GLubyte) (VB->ClipMask[v1] |
+ VB->ClipMask[v2] |
+ VB->ClipMask[v3] |
+ VB->ClipMask[v4]);
+ GLuint vlist[VB_MAX_CLIPPED_VERTS];
+ GLuint i, n;
+
+ if (!mask) {
+ ctx->QuadFunc( ctx, v1, v2, v3, v4, pv );
+ return;
+ }
+
+ if (CLIP_ALL_BITS & VB->ClipMask[v1] &
+ VB->ClipMask[v2] & VB->ClipMask[v3] &
+ VB->ClipMask[v4])
+ return;
+
+ ASSIGN_4V(vlist, v1, v2, v3, v4 );
+ n = (ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 4, vlist, mask );
+
for (i=2;i<n;i++)
ctx->TriangleFunc( ctx, *vlist, vlist[i-1], vlist[i], pv );
}
@@ -309,16 +342,14 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1,
GLfloat fy = win[v3][1] - win[v1][1];
GLfloat c = ex*fy-ey*fx;
GLuint facing;
- GLuint tricaps;
+ GLuint tricaps = ctx->IndirectTriangles;
if (c * ctx->backface_sign > 0)
return;
facing = (c<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW);
- tricaps = ctx->IndirectTriangles;
- (void) tricaps; /* not needed? */
- if (ctx->IndirectTriangles & DD_TRI_OFFSET) {
+ if (tricaps & DD_TRI_OFFSET) {
GLfloat ez = win[v2][2] - win[v0][2];
GLfloat fz = win[v3][2] - win[v1][2];
GLfloat a = ey*fz-ez*fy;
@@ -327,7 +358,7 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1,
}
- if (ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE) {
+ if (tricaps & DD_TRI_LIGHT_TWOSIDE) {
VB->Specular = VB->Spec[facing];
VB->ColorPtr = VB->Color[facing];
VB->IndexPtr = VB->Index[facing];
@@ -335,7 +366,7 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1,
/* Render the quad! */
- if (ctx->IndirectTriangles & DD_TRI_UNFILLED) {
+ if (tricaps & DD_TRI_UNFILLED) {
GLuint vlist[4];
vlist[0] = v0;
vlist[1] = v1;
@@ -373,9 +404,7 @@ extern const char *gl_prim_name[];
#define EDGEFLAG_TRI( i2, i1, i, pv, parity) \
do { \
- GLuint e1=i1, e0=i; \
- if (parity) { GLuint t=e1; e1=e0; e0=t; } \
- eflag[i2] = eflag[e1] = 1; eflag[e0] = 2; \
+ eflag[i2] = eflag[i1] = 1; eflag[i] = 2; \
} while (0)
#define EDGEFLAG_QUAD( i3, i2, i1, i, pv) \
@@ -384,6 +413,21 @@ do { \
} while (0)
+#define EDGEFLAG_POLY_TRI_PRE( i2, i1, i, pv) \
+do { \
+ eflag[i1] |= (eflag[i1] >> 2) & 1; \
+ eflag[i] |= (eflag[i] >> 2) & 2; \
+} while (0)
+
+#define EDGEFLAG_POLY_TRI_POST( i2, i1, i, pv) \
+do { \
+ eflag[i2] = 0; \
+ eflag[i1] &= ~(4|1); \
+ eflag[i] &= ~(8|2); \
+} while (0)
+
+
+
/* Culled and possibly clipped primitives.
*/
#define RENDER_POINTS( start, count ) \
@@ -455,10 +499,12 @@ do { \
const GLubyte *cullmask = VB->CullMask; \
GLuint vlist[VB_SIZE]; \
GLubyte *eflag = VB->EdgeFlagPtr->data; \
- (void) vlist; (void) eflag;
+ GLuint *stipplecounter = &VB->ctx->StippleCounter; \
+ (void) vlist; (void) eflag; (void) stipplecounter;
#define TAG(x) x##_cull
#define INIT(x) FLUSH_PRIM(x)
+#define RESET_STIPPLE *stipplecounter = 0
#include "render_tmp.h"
@@ -492,9 +538,11 @@ do { \
#define LOCAL_VARS \
GLcontext *ctx = VB->ctx; \
GLubyte *eflag = VB->EdgeFlagPtr->data; \
- (void) eflag;
+ GLuint *stipplecounter = &VB->ctx->StippleCounter; \
+ (void) eflag; (void) stipplecounter;
#define INIT(x) FLUSH_PRIM(x);
+#define RESET_STIPPLE *stipplecounter = 0
#include "render_tmp.h"
@@ -510,24 +558,27 @@ do { \
#define RENDER_TRI( i2, i1, i, pv, parity) \
do { \
- GLuint e1=i1, e0=i; \
- if (parity) { GLuint t=e1; e1=e0; e0=t; } \
- gl_render_clipped_triangle2(ctx,i2,e1,e0,pv); \
+ GLuint e2=i2, e1=i1; \
+ if (parity) { GLuint t=e2; e2=e1; e1=t; } \
+ gl_render_clipped_triangle2(ctx,e2,e1,i,pv); \
} while (0)
#define RENDER_QUAD( i3, i2, i1, i, pv) \
do { \
- gl_render_clipped_triangle2(ctx,i3,i2,i1,pv); \
- gl_render_clipped_triangle2(ctx,i3,i1,i,pv); \
+ gl_render_clipped_quad2(ctx,i3,i2,i1,i,pv); \
} while (0)
#define LOCAL_VARS \
GLcontext *ctx = VB->ctx; \
GLubyte *eflag = VB->EdgeFlagPtr->data; \
- (void) eflag;
+ GLuint *stipplecounter = &VB->ctx->StippleCounter; \
+ (void) eflag; (void) stipplecounter;
+
#define INIT(x) FLUSH_PRIM(x);
#define TAG(x) x##_clipped
+#define RESET_STIPPLE *stipplecounter = 0
+
#include "render_tmp.h"
/* Bits:
@@ -566,24 +617,25 @@ setup_edgeflag( struct vertex_buffer *VB,
switch (prim) {
case GL_TRIANGLES:
for (i = 0 ; i < n-2 ; i+=3) {
- if (flag[i]) flag[i] = 0x5;
- if (flag[i+1]) flag[i+1] = 0x5;
- if (flag[i+2]) flag[i+2] = 0x6;
+ if (flag[i]) flag[i] = 0x1;
+ if (flag[i+1]) flag[i+1] = 0x1;
+ if (flag[i+2]) flag[i+2] = 0x3;
}
break;
case GL_QUADS:
for (i = 0 ; i < n-3 ; i+=4) {
- if (flag[i]) flag[i] = 0x5;
- if (flag[i+1]) flag[i+1] = 0x5;
- if (flag[i+2]) flag[i+2] = 0x5;
- if (flag[i+3]) flag[i+3] = 0x6;
+ if (flag[i]) flag[i] = 0x1;
+ if (flag[i+1]) flag[i+1] = 0x1;
+ if (flag[i+2]) flag[i+2] = 0x1;
+ if (flag[i+3]) flag[i+3] = 0x3;
}
break;
case GL_POLYGON:
- for (i = 0 ; i < n-1 ; i++) {
- if (flag[i]) flag[i] = 0x5;
+ if (flag[0]) flag[0] = 0x1;
+ for (i = 1 ; i < n-1 ; i++) {
+ if (flag[i]) flag[i] = 0x1<<2;
}
- if (flag[i]) flag[i] = 0x6;
+ if (flag[i]) flag[i] = 0x3<<2;
break;
default:
break;
@@ -669,10 +721,13 @@ void gl_reduced_prim_change( GLcontext *ctx, GLenum prim )
ctx->PB->count = 0;
ctx->PB->mono = GL_FALSE;
- ctx->PB->primitive = prim;
+
+ if (ctx->PB->primitive != prim) {
+ ctx->PB->primitive = prim;
- if (ctx->Driver.ReducedPrimitiveChange)
- ctx->Driver.ReducedPrimitiveChange( ctx, prim );
+ if (ctx->Driver.ReducedPrimitiveChange)
+ ctx->Driver.ReducedPrimitiveChange( ctx, prim );
+ }
}
diff --git a/xc/extras/Mesa/src/vbxform.c b/xc/extras/Mesa/src/vbxform.c
index 4dbaf86f6..eea0be897 100644
--- a/xc/extras/Mesa/src/vbxform.c
+++ b/xc/extras/Mesa/src/vbxform.c
@@ -359,13 +359,23 @@ fixup_4ub( GLubyte data[][4], GLuint flag[], GLuint start, GLuint match )
static void
find_last_3f( float data[][3], GLuint flag[], GLuint match, GLuint count )
{
- GLuint i = count;
+ int i = count;
- for (;;)
+ do {
if ((flag[--i] & match) != 0) {
COPY_3V(data[count], data[i]);
return;
}
+ } while (i >= 0);
+
+ /* To reach this point excercises a bug that seems only to exist on
+ * dec alpha installations. I want to leave this print statement
+ * enabled on the 3.3 branch so that we are reminded to track down
+ * the problem.
+ */
+ fprintf(stderr,
+ "didn't find VERT_NORM in find_last_3f"
+ "(Dec alpha problem?)\n");
}
static void
@@ -599,10 +609,17 @@ void gl_fixup_input( GLcontext *ctx, struct immediate *IM )
}
if (fixup & VERT_NORM) {
+ /* Only eval cannot use the Flag member to find valid normals:
+ */
if (IM->OrFlag & VERT_EVAL_ANY)
fixup_3f( IM->Normal, IM->Flag, start, VERT_NORM );
- else if (!(IM->Flag[IM->LastData] & VERT_NORM))
- find_last_3f( IM->Normal, IM->Flag, VERT_NORM, IM->LastData );
+ else {
+ /* Copy-to-current requires a valid normal in the last slot:
+ */
+ if ((IM->OrFlag & VERT_NORM) &&
+ !(IM->Flag[IM->LastData] & VERT_NORM))
+ find_last_3f( IM->Normal, IM->Flag, VERT_NORM, IM->LastData );
+ }
}
}