summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/glide
diff options
context:
space:
mode:
authorDaniel Borca <[email protected]>2004-09-24 07:03:53 +0000
committerDaniel Borca <[email protected]>2004-09-24 07:03:53 +0000
commitd9873c59ef4d14b5e3137cb2d7c765797f82ac56 (patch)
tree25b11356a6fbb6568ac3c7790538fb1db373547f /src/mesa/drivers/glide
parent303c342d5353e7fb1b480da97ce505357eafe0c0 (diff)
added (back!) option to use non-packedcolor
Diffstat (limited to 'src/mesa/drivers/glide')
-rw-r--r--src/mesa/drivers/glide/fxapi.c2
-rw-r--r--src/mesa/drivers/glide/fxdrv.h22
-rw-r--r--src/mesa/drivers/glide/fxglidew.c5
-rw-r--r--src/mesa/drivers/glide/fxglidew.h33
-rw-r--r--src/mesa/drivers/glide/fxtris.c96
-rw-r--r--src/mesa/drivers/glide/fxvb.c17
-rw-r--r--src/mesa/drivers/glide/fxvbtmp.h30
7 files changed, 201 insertions, 4 deletions
diff --git a/src/mesa/drivers/glide/fxapi.c b/src/mesa/drivers/glide/fxapi.c
index 5c77ed339ff..708dad51f41 100644
--- a/src/mesa/drivers/glide/fxapi.c
+++ b/src/mesa/drivers/glide/fxapi.c
@@ -638,7 +638,7 @@ fxMesaCreateContext(GLuint win,
fxMesa->snapVertices ? "" : "no ");
}
- sprintf(fxMesa->rendererString, "Mesa %s v0.61 %s%s",
+ sprintf(fxMesa->rendererString, "Mesa %s v0.62 %s%s",
grGetString(GR_RENDERER),
grGetString(GR_HARDWARE),
((fxMesa->type < GR_SSTTYPE_Voodoo4) && (voodoo->numChips > 1)) ? " SLI" : "");
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index c246444d1c3..9cc6d15e0bb 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -731,6 +731,28 @@ void fxSetupStencil (GLcontext *ctx);
extern GLuint fx_check_IsInHardware(GLcontext *ctx);
+/***
+ *** CNORM: clamp float to [0,1] and map to float in [0,255]
+ ***/
+#if defined(USE_IEEE) && !defined(DEBUG)
+#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
+#define CNORM(N, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F); \
+ if (__tmp.i < 0) \
+ N = 0; \
+ else if (__tmp.i >= IEEE_0996) \
+ N = 255.0f; \
+ else { \
+ N = (F) * 255.0f; \
+ } \
+ } while (0)
+#else
+#define CNORM(n, f) \
+ n = (CLAMP((f), 0.0F, 1.0F) * 255.0F)
+#endif
+
/* run-time debugging */
#ifndef FX_DEBUG
#define FX_DEBUG 0
diff --git a/src/mesa/drivers/glide/fxglidew.c b/src/mesa/drivers/glide/fxglidew.c
index dd1f7b6ac66..1fedf2ab969 100644
--- a/src/mesa/drivers/glide/fxglidew.c
+++ b/src/mesa/drivers/glide/fxglidew.c
@@ -126,7 +126,12 @@ FX_setupGrVertexLayout(void)
grCoordinateSpace(GR_WINDOW_COORDS);
grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
+#if FX_PACKEDCOLOR
grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
+#else /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
+#endif /* !FX_PACKEDCOLOR */
grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2,
diff --git a/src/mesa/drivers/glide/fxglidew.h b/src/mesa/drivers/glide/fxglidew.h
index 472cf9473cc..a19d0b58c73 100644
--- a/src/mesa/drivers/glide/fxglidew.h
+++ b/src/mesa/drivers/glide/fxglidew.h
@@ -38,7 +38,9 @@
#include "fxg.h"
-
+#ifndef FX_PACKEDCOLOR
+#define FX_PACKEDCOLOR 1
+#endif
#define MAX_NUM_SST 4
@@ -112,6 +114,7 @@ typedef struct {
float oow; /* 1/w (used mipmapping - really 0xfff/w) */
} GrTmuVertex;
+#if FX_PACKEDCOLOR
typedef struct {
float x, y; /* X and Y in screen space */
float ooz; /* 65535/Z (used for Z-buffering) */
@@ -137,6 +140,34 @@ typedef struct {
#define GR_VERTEX_OOW_TMU1_OFFSET 10
#define GR_VERTEX_FOG_OFFSET 11
#define GR_VERTEX_PSPEC_OFFSET 12
+#else /* !FX_PACKEDCOLOR */
+typedef struct {
+ float x, y; /* X and Y in screen space */
+ float ooz; /* 65535/Z (used for Z-buffering) */
+ float oow; /* 1/W (used for W-buffering, texturing) */
+ float r, g, b, a; /* R, G, B, A [0..255] */
+ GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
+ float fog; /* fog coordinate */
+ float r1, g1, b1; /* R, G, B [0..255] */
+ float psize; /* point size */
+ long pad[20 - 19]; /* ensure multiple of 16 */
+} GrVertex;
+
+#define GR_VERTEX_X_OFFSET 0
+#define GR_VERTEX_Y_OFFSET 1
+#define GR_VERTEX_OOZ_OFFSET 2
+#define GR_VERTEX_OOW_OFFSET 3
+#define GR_VERTEX_RGB_OFFSET 4
+#define GR_VERTEX_A_OFFSET 7
+#define GR_VERTEX_SOW_TMU0_OFFSET 8
+#define GR_VERTEX_TOW_TMU0_OFFSET 9
+#define GR_VERTEX_OOW_TMU0_OFFSET 10
+#define GR_VERTEX_SOW_TMU1_OFFSET 11
+#define GR_VERTEX_TOW_TMU1_OFFSET 12
+#define GR_VERTEX_OOW_TMU1_OFFSET 13
+#define GR_VERTEX_FOG_OFFSET 14
+#define GR_VERTEX_SPEC_OFFSET 15
+#endif /* !FX_PACKEDCOLOR */
diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c
index 4270ceb0afe..f53c2b31d0f 100644
--- a/src/mesa/drivers/glide/fxtris.c
+++ b/src/mesa/drivers/glide/fxtris.c
@@ -146,6 +146,7 @@ fx_translate_vertex( GLcontext *ctx, const GrVertex *src, SWvertex *dst)
dst->win[2] = src->ooz;
dst->win[3] = src->oow;
+#if FX_PACKEDCOLOR
dst->color[0] = src->pargb[2];
dst->color[1] = src->pargb[1];
dst->color[2] = src->pargb[0];
@@ -154,6 +155,16 @@ fx_translate_vertex( GLcontext *ctx, const GrVertex *src, SWvertex *dst)
dst->specular[0] = src->pspec[2];
dst->specular[1] = src->pspec[1];
dst->specular[2] = src->pspec[0];
+#else /* !FX_PACKEDCOLOR */
+ dst->color[0] = src->r;
+ dst->color[1] = src->g;
+ dst->color[2] = src->b;
+ dst->color[3] = src->a;
+
+ dst->specular[0] = src->r1;
+ dst->specular[1] = src->g1;
+ dst->specular[2] = src->g1;
+#endif /* !FX_PACKEDCOLOR */
dst->texcoord[ts0][0] = fxMesa->inv_s0scale * src->tmuvtx[0].sow * w;
dst->texcoord[ts0][1] = fxMesa->inv_t0scale * src->tmuvtx[0].tow * w;
@@ -227,7 +238,11 @@ static void fx_print_vertex( GLcontext *ctx, const GrVertex *v )
fprintf(stderr, "\tvertex at %p\n", (void *) v);
fprintf(stderr, "\tx %f y %f z %f oow %f\n", v->x, v->y, v->ooz, v->oow);
+#if FX_PACKEDCOLOR
fprintf(stderr, "\tr %d g %d b %d a %d\n", v->pargb[2], v->pargb[1], v->pargb[0], v->pargb[3]);
+#else /* !FX_PACKEDCOLOR */
+ fprintf(stderr, "\tr %f g %f b %f a %f\n", v->r, v->g, v->b, v->a);
+#endif /* !FX_PACKEDCOLOR */
fprintf(stderr, "\n");
}
@@ -353,7 +368,7 @@ static void fx_draw_point_wide ( fxMesaContext fxMesa,
const GLcontext *ctx = fxMesa->glCtx;
const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN)
? CLAMP(v0->psize, ctx->Point.MinSize, ctx->Point.MaxSize)
- : ctx->Point._Size; /* clamped */
+ : ctx->Point._Size; /* clamped */
if (ctx->Point.PointSprite) {
fx_draw_point_sprite(fxMesa, v0, psize);
@@ -430,7 +445,7 @@ static void fx_draw_point_wide_aa ( fxMesaContext fxMesa,
const GLcontext *ctx = fxMesa->glCtx;
const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN)
? CLAMP(v0->psize, ctx->Point.MinSize, ctx->Point.MaxSize)
- : ctx->Point._Size; /* clamped */
+ : ctx->Point._Size; /* clamped */
if (ctx->Point.PointSprite) {
fx_draw_point_sprite(fxMesa, v0, psize);
@@ -514,6 +529,7 @@ static struct {
#endif
+#if FX_PACKEDCOLOR
#define VERT_SET_RGBA( dst, f ) \
do { \
UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[2], f[0]);\
@@ -553,6 +569,74 @@ do { \
fxMesaContext fxMesa = FX_CONTEXT(ctx); \
GLubyte color[n][4], spec[n][4]; \
(void) color; (void) spec;
+#else /* !FX_PACKEDCOLOR */
+#define VERT_SET_RGBA( dst, f ) \
+do { \
+ CNORM(dst->r, f[0]); \
+ CNORM(dst->g, f[1]); \
+ CNORM(dst->b, f[2]); \
+ CNORM(dst->a, f[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) \
+do { \
+ *(GLuint *)&v0->r = *(GLuint *)&v1->r; \
+ *(GLuint *)&v0->g = *(GLuint *)&v1->g; \
+ *(GLuint *)&v0->b = *(GLuint *)&v1->b; \
+ *(GLuint *)&v0->a = *(GLuint *)&v1->a; \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) \
+do { \
+ *(GLuint *)&color[idx][0] = *(GLuint *)&v[idx]->r;\
+ *(GLuint *)&color[idx][1] = *(GLuint *)&v[idx]->g;\
+ *(GLuint *)&color[idx][2] = *(GLuint *)&v[idx]->b;\
+ *(GLuint *)&color[idx][3] = *(GLuint *)&v[idx]->a;\
+} while (0)
+
+#define VERT_RESTORE_RGBA( idx ) \
+do { \
+ *(GLuint *)&v[idx]->r = *(GLuint *)&color[idx][0];\
+ *(GLuint *)&v[idx]->g = *(GLuint *)&color[idx][1];\
+ *(GLuint *)&v[idx]->b = *(GLuint *)&color[idx][2];\
+ *(GLuint *)&v[idx]->a = *(GLuint *)&color[idx][3];\
+} while (0)
+
+
+#define VERT_SET_SPEC( dst, f ) \
+do { \
+ CNORM(dst->r1, f[0]); \
+ CNORM(dst->g1, f[1]); \
+ CNORM(dst->b1, f[2]); \
+} while (0)
+
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ *(GLuint *)&v0->r1 = *(GLuint *)&v1->r1; \
+ *(GLuint *)&v0->g1 = *(GLuint *)&v1->g1; \
+ *(GLuint *)&v0->b1 = *(GLuint *)&v1->b1; \
+} while (0)
+
+#define VERT_SAVE_SPEC( idx ) \
+do { \
+ *(GLuint *)&spec[idx][0] = *(GLuint *)&v[idx]->r1;\
+ *(GLuint *)&spec[idx][1] = *(GLuint *)&v[idx]->g1;\
+ *(GLuint *)&spec[idx][2] = *(GLuint *)&v[idx]->b1;\
+} while (0)
+
+#define VERT_RESTORE_SPEC( idx ) \
+do { \
+ *(GLuint *)&v[idx]->r1 = *(GLuint *)&spec[idx][0];\
+ *(GLuint *)&v[idx]->g1 = *(GLuint *)&spec[idx][1];\
+ *(GLuint *)&v[idx]->b1 = *(GLuint *)&spec[idx][2];\
+} while (0)
+
+
+#define LOCAL_VARS(n) \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GLuint color[n][4], spec[n][4]; \
+ (void) color; (void) spec;
+#endif /* !FX_PACKEDCOLOR */
@@ -1511,7 +1595,11 @@ GLboolean fxMultipass_ColorSum (GLcontext *ctx, GLuint pass)
fxDDDepthMask( ctx, GL_FALSE );
}
/* switch to secondary colors */
+#if FX_PACKEDCOLOR
grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PSPEC_OFFSET << 2, GR_PARAM_ENABLE);
+#else /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_SPEC_OFFSET << 2, GR_PARAM_ENABLE);
+#endif /* !FX_PACKEDCOLOR */
/* don't advertise new state */
fxMesa->new_state = 0;
break;
@@ -1522,7 +1610,11 @@ GLboolean fxMultipass_ColorSum (GLcontext *ctx, GLuint pass)
ctx->Texture.Unit[0]._ReallyEnabled = t0;
ctx->Texture.Unit[1]._ReallyEnabled = t1;
/* revert to primary colors */
+#if FX_PACKEDCOLOR
grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
+#else /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE);
+#endif /* !FX_PACKEDCOLOR */
break;
default:
assert(0); /* NOTREACHED */
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index 13bc1b3ecd8..27cb164a3c3 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -55,7 +55,14 @@ static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
GrVertex *dst = fxMesa->verts + edst;
GrVertex *src = fxMesa->verts + esrc;
+#if FX_PACKEDCOLOR
*(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
+#else /* !FX_PACKEDCOLOR */
+ *(GLuint *)&dst->r = *(GLuint *)&src->r;
+ *(GLuint *)&dst->g = *(GLuint *)&src->g;
+ *(GLuint *)&dst->b = *(GLuint *)&src->b;
+ *(GLuint *)&dst->a = *(GLuint *)&src->a;
+#endif /* !FX_PACKEDCOLOR */
}
static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
@@ -64,8 +71,18 @@ static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
GrVertex *dst = fxMesa->verts + edst;
GrVertex *src = fxMesa->verts + esrc;
+#if FX_PACKEDCOLOR
*(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
*(GLuint *)&dst->pspec = *(GLuint *)&src->pspec;
+#else /* !FX_PACKEDCOLOR */
+ *(GLuint *)&dst->r = *(GLuint *)&src->r;
+ *(GLuint *)&dst->g = *(GLuint *)&src->g;
+ *(GLuint *)&dst->b = *(GLuint *)&src->b;
+ *(GLuint *)&dst->a = *(GLuint *)&src->a;
+ *(GLuint *)&dst->r1 = *(GLuint *)&src->r1;
+ *(GLuint *)&dst->g1 = *(GLuint *)&src->g1;
+ *(GLuint *)&dst->b1 = *(GLuint *)&src->b1;
+#endif /* !FX_PACKEDCOLOR */
}
static struct {
diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h
index 255ddc9296d..8ca46dde8f1 100644
--- a/src/mesa/drivers/glide/fxvbtmp.h
+++ b/src/mesa/drivers/glide/fxvbtmp.h
@@ -145,6 +145,7 @@ static void TAG(emit)( GLcontext *ctx,
proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
}
if (IND & SETUP_RGBA) {
+#if FX_PACKEDCOLOR
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]);
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]);
UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]);
@@ -153,12 +154,28 @@ static void TAG(emit)( GLcontext *ctx,
} else {
v->pargb[3] = 255;
}
+#else /* !FX_PACKEDCOLOR */
+ CNORM(v->r, col[0][0]);
+ CNORM(v->g, col[0][1]);
+ CNORM(v->b, col[0][2]);
+ if (col_size == 4) {
+ CNORM(v->a, col[0][3]);
+ } else {
+ v->a = 255.0f;
+ }
+#endif /* !FX_PACKEDCOLOR */
STRIDE_4F(col, col_stride);
}
if (IND & SETUP_SPEC) {
+#if FX_PACKEDCOLOR
UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]);
UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]);
UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]);
+#else /* !FX_PACKEDCOLOR */
+ CNORM(v->r1, spec[0][0]);
+ CNORM(v->g1, spec[0][1]);
+ CNORM(v->b1, spec[0][2]);
+#endif /* !FX_PACKEDCOLOR */
STRIDE_4F(spec, spec_stride);
}
if (IND & SETUP_FOGC) {
@@ -253,15 +270,28 @@ static void TAG(interp)( GLcontext *ctx,
}
+#if FX_PACKEDCOLOR
INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] );
INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] );
INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] );
INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] );
+#else /* !FX_PACKEDCOLOR */
+ INTERP_F( t, dst->r, out->r, in->r );
+ INTERP_F( t, dst->g, out->g, in->g );
+ INTERP_F( t, dst->b, out->b, in->b );
+ INTERP_F( t, dst->a, out->a, in->a );
+#endif /* !FX_PACKEDCOLOR */
if (IND & SETUP_SPEC) {
+#if FX_PACKEDCOLOR
INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] );
INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] );
INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] );
+#else /* !FX_PACKEDCOLOR */
+ INTERP_F( t, dst->r1, out->r1, in->r1 );
+ INTERP_F( t, dst->g1, out->g1, in->g1 );
+ INTERP_F( t, dst->b1, out->b1, in->b1 );
+#endif /* !FX_PACKEDCOLOR */
}
if (IND & SETUP_FOGC) {