summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/glide
diff options
context:
space:
mode:
authorDaniel Borca <dborca@users.sourceforge.net>2005-01-12 09:25:37 +0000
committerDaniel Borca <dborca@users.sourceforge.net>2005-01-12 09:25:37 +0000
commita9531eb2c54bbdbedd7f03583d540a32d9fd918f (patch)
tree3387dc60f14848c1a96b0a3477e64cb49bcffd4b /src/mesa/drivers/glide
parentd7b837ad4aa5306bd318fafa32f40599622f2c2a (diff)
some "safer" type-punning (gcc optimizes float moves with integer moves, anyway).
Diffstat (limited to 'src/mesa/drivers/glide')
-rw-r--r--src/mesa/drivers/glide/fxtris.c51
-rw-r--r--src/mesa/drivers/glide/fxvb.c26
2 files changed, 38 insertions, 39 deletions
diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c
index f722c5c4cc..1b5c869872 100644
--- a/src/mesa/drivers/glide/fxtris.c
+++ b/src/mesa/drivers/glide/fxtris.c
@@ -535,14 +535,9 @@ static struct {
#define VERT_X(_v) _v->x
#define VERT_Y(_v) _v->y
#define VERT_Z(_v) _v->ooz
+#define AREA_IS_CCW( a ) IS_NEGATIVE( a )
#define GET_VERTEX(e) (fxMesa->verts + e)
-#ifdef USE_IEEE
-#define AREA_IS_CCW( a ) (((fi_type *)&(a))->i < 0)
-#else
-#define AREA_IS_CCW( a ) (a < 0)
-#endif
-
#if FX_PACKEDCOLOR
#define VERT_SET_RGBA( dst, f ) \
@@ -595,26 +590,26 @@ do { \
#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; \
+ COPY_FLOAT(v0->r, v1->r); \
+ COPY_FLOAT(v0->g, v1->g); \
+ COPY_FLOAT(v0->b, v1->b); \
+ COPY_FLOAT(v0->a, 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;\
+ COPY_FLOAT(color[idx][0], v[idx]->r); \
+ COPY_FLOAT(color[idx][1], v[idx]->g); \
+ COPY_FLOAT(color[idx][2], v[idx]->b); \
+ COPY_FLOAT(color[idx][3], 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];\
+ COPY_FLOAT(v[idx]->r, color[idx][0]); \
+ COPY_FLOAT(v[idx]->g, color[idx][1]); \
+ COPY_FLOAT(v[idx]->b, color[idx][2]); \
+ COPY_FLOAT(v[idx]->a, color[idx][3]); \
} while (0)
@@ -627,29 +622,29 @@ do { \
#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; \
+ COPY_FLOAT(v0->r1, v1->r1); \
+ COPY_FLOAT(v0->g1, v1->g1); \
+ COPY_FLOAT(v0->b1, 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;\
+ COPY_FLOAT(spec[idx][0], v[idx]->r1); \
+ COPY_FLOAT(spec[idx][1], v[idx]->g1); \
+ COPY_FLOAT(spec[idx][2], 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];\
+ COPY_FLOAT(v[idx]->r1, spec[idx][0]); \
+ COPY_FLOAT(v[idx]->g1, spec[idx][1]); \
+ COPY_FLOAT(v[idx]->b1, spec[idx][2]); \
} while (0)
#define LOCAL_VARS(n) \
fxMesaContext fxMesa = FX_CONTEXT(ctx); \
- GLuint color[n][4], spec[n][4]; \
+ GLfloat color[n][4], spec[n][4]; \
(void) color; (void) spec;
#endif /* !FX_PACKEDCOLOR */
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index 8391392265..8b731355b5 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -58,10 +58,10 @@ static void copy_pv( GLcontext *ctx, GLuint edst, GLuint 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;
+ COPY_FLOAT(dst->r, src->r);
+ COPY_FLOAT(dst->g, src->g);
+ COPY_FLOAT(dst->b, src->b);
+ COPY_FLOAT(dst->a, src->a);
#endif /* !FX_PACKEDCOLOR */
}
@@ -75,13 +75,13 @@ static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
*(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;
+ COPY_FLOAT(dst->r, src->r);
+ COPY_FLOAT(dst->g, src->g);
+ COPY_FLOAT(dst->b, src->b);
+ COPY_FLOAT(dst->a, src->a);
+ COPY_FLOAT(dst->r1, src->r1);
+ COPY_FLOAT(dst->g1, src->g1);
+ COPY_FLOAT(dst->b1, src->b1);
#endif /* !FX_PACKEDCOLOR */
}
@@ -104,6 +104,10 @@ static void interp_extras( GLcontext *ctx,
{
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ /* If stride is zero, ColorPtr[1] is constant across the VB, so
+ * there is no point interpolating between two values as they will
+ * be identical.
+ */
if (VB->ColorPtr[1]) {
assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));