Fix VERT_SET_RGBA, VERT_SET_SPEC macros to account for change to floating
authorKeith Whitwell <keith@tungstengraphics.com>
Tue, 9 Dec 2003 16:14:24 +0000 (16:14 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Tue, 9 Dec 2003 16:14:24 +0000 (16:14 +0000)
point colors throughout mesa.

src/mesa/drivers/dri/gamma/gamma_tris.c
src/mesa/drivers/dri/i810/i810tris.c
src/mesa/drivers/dri/mga/mgatris.c
src/mesa/drivers/dri/sis/sis_tris.c
src/mesa/drivers/dri/tdfx/tdfx_tris.c

index f0391030268acea08f2eac27b263b18302bb3328..4d3578d15e4e98f8035ff5e80d98b3926f388218 100644 (file)
@@ -309,7 +309,13 @@ static struct {
 #define AREA_IS_CCW( a ) (a > 0)
 #define GET_VERTEX(e) (gmesa->verts + (e<<gmesa->vertex_stride_shift))
 
-#define VERT_SET_RGBA( v, c )    COPY_4V( v->ub4[4], c)
+#define VERT_SET_RGBA( v, c )                                          \
+do {                                                           \
+   UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][0], (c)[0]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][1], (c)[1]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][2], (c)[2]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(v->uv4[4][3], (c)[3]);             \
+} while (0)
 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
 #define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[4]
 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]   
index 364b571152b08a3f31e9163a11fbae3c8501454c..e3e2afb3f22c971b94d933577314513745fb736f 100644 (file)
@@ -224,24 +224,6 @@ static struct {
 #define VERTEX            i810Vertex
 #define TAB               rast_tab
 
-/* Only used to pull back colors into vertices (ie, we know color is
- * floating point).
- */
-#define I810_COLOR( dst, src )                 \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-   dst[3] = src[3];                            \
-} while (0)
-
-#define I810_SPEC( dst, src )                  \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-} while (0)
-
 
 #define DEPTH_SCALE (1.0/0xffff)
 #define UNFILLED_TRI unfilled_tri
@@ -252,13 +234,36 @@ do {                                              \
 #define AREA_IS_CCW( a ) (a > 0)
 #define GET_VERTEX(e) (imesa->verts + (e<<imesa->vertex_stride_shift))
 
-#define VERT_SET_RGBA( v, c )    I810_COLOR( v->ub4[coloroffset], c )
+#define VERT_SET_RGBA( v, c )                                          \
+do {                                                           \
+   i810_color_t *color = (i810_color_t *)&((v)->ui[coloroffset]);      \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]);               \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]);              \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]);             \
+} while (0)
+
 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c )                                 \
+do {                                                           \
+   if (havespec) {                                             \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]);    \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]);  \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]);   \
+   }                                                           \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 )                       \
+do {                                                   \
+   if (havespec) {                                     \
+      v0->v.specular.red   = v1->v.specular.red;       \
+      v0->v.specular.green = v1->v.specular.green;     \
+      v0->v.specular.blue  = v1->v.specular.blue;      \
+   }                                                   \
+} while (0)
+
 #define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
-
-#define VERT_SET_SPEC( v, c )    if (havespec) I810_SPEC( v->ub4[5], c )
-#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
 #define VERT_SAVE_SPEC( idx )    if (havespec) spec[idx] = v[idx]->ui[5]
 #define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
 
index 651c93ccd420dab812d3311b34336577193e59a4..ca5f5a23cee3691a50a919e9969aa1ee95efe712 100644 (file)
@@ -352,20 +352,6 @@ static struct {
 #define VERTEX mgaVertex
 #define TAB rast_tab
 
-#define MGA_COLOR( dst, src )                  \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-   dst[3] = src[3];                            \
-} while (0)
-
-#define MGA_SPEC( dst, src )                   \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-} while (0)
 
 #define DEPTH_SCALE mmesa->depth_scale
 #define UNFILLED_TRI unfilled_tri
@@ -376,15 +362,38 @@ do {                                              \
 #define AREA_IS_CCW( a ) (a > 0)
 #define GET_VERTEX(e) (mmesa->verts + (e<<mmesa->vertex_stride_shift))
 
-#define VERT_SET_RGBA( v, c )  MGA_COLOR( v->ub4[4], c )
-#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
-#define VERT_SAVE_RGBA( idx )  color[idx] = v[idx]->ui[4]
-#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]   
+#define VERT_SET_RGBA( v, c )                                          \
+do {                                                           \
+   mga_color_t *color = (mga_color_t *)&((v)->ui[coloroffset]);        \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]);               \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]);              \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]);             \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c )                                 \
+do {                                                           \
+   if (havespec) {                                             \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]);    \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]);  \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]);   \
+   }                                                           \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 )                       \
+do {                                                   \
+   if (havespec) {                                     \
+      v0->v.specular.red   = v1->v.specular.red;       \
+      v0->v.specular.green = v1->v.specular.green;     \
+      v0->v.specular.blue  = v1->v.specular.blue;      \
+   }                                                   \
+} while (0)
 
-#define VERT_SET_SPEC( v, c )  MGA_SPEC( v->ub4[5], c )
-#define VERT_COPY_SPEC( v0, v1 ) COPY_3V(v0->ub4[5], v1->ub4[5])
-#define VERT_SAVE_SPEC( idx )  spec[idx] = v[idx]->ui[5]
-#define VERT_RESTORE_SPEC( idx ) v[idx]->ui[5] = spec[idx]   
+#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx )    if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
 
 #define LOCAL_VARS(n)                                  \
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);             \
index abe6a3fb075d2fca0099cee2ea86b4e37e5b4fa4..6c7865f6c4bc07896b2da856c2bc9ff6fae575c9 100644 (file)
@@ -267,31 +267,36 @@ static struct {
 #define AREA_IS_CCW( a ) (a > 0)
 #define GET_VERTEX(e) (smesa->verts + (e << smesa->vertex_stride_shift))
 
-#define VERT_SET_RGBA( v, c )  \
-       do {                    \
-               sis_color_t *vc = (sis_color_t *)&(v)->ui[coloroffset]; \
-               vc->blue  = (c)[2];     \
-               vc->green = (c)[1];     \
-               vc->red   = (c)[0];     \
-               vc->alpha = (c)[3];     \
-       } while (0)
+#define VERT_SET_RGBA( v, c )                                          \
+do {                                                           \
+   sis_color_t *color = (sis_color_t *)&((v)->ui[coloroffset]);        \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]);               \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]);              \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]);             \
+} while (0)
+
 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
-#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
-#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
 
-#define VERT_SET_SPEC( v0, c )                         \
-       if (havespec) {                                 \
-               (v0)->v.specular.red   = (c)[0];        \
-               (v0)->v.specular.green = (c)[1];        \
-               (v0)->v.specular.blue  = (c)[2];        \
-       }
+#define VERT_SET_SPEC( v0, c )                                 \
+do {                                                           \
+   if (havespec) {                                             \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]);    \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]);  \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]);   \
+   }                                                           \
+} while (0)
 #define VERT_COPY_SPEC( v0, v1 )                       \
-       if (havespec) {                                 \
-               (v0)->v.specular.red   = v1->v.specular.red;    \
-               (v0)->v.specular.green = v1->v.specular.green;  \
-               (v0)->v.specular.blue  = v1->v.specular.blue;   \
-       }
+do {                                                   \
+   if (havespec) {                                     \
+      v0->v.specular.red   = v1->v.specular.red;       \
+      v0->v.specular.green = v1->v.specular.green;     \
+      v0->v.specular.blue  = v1->v.specular.blue;      \
+   }                                                   \
+} while (0)
 
+#define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
 #define VERT_SAVE_SPEC( idx )    if (havespec) spec[idx] = v[idx]->ui[5]
 #define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
 
index 131c2f1a0e7091a28230e723107503637906208b..408682e1fac417db14c79c56da53a54345789e8a 100644 (file)
@@ -327,12 +327,12 @@ static struct {
 #define VERTEX tdfxVertex
 #define TAB rast_tab
 
-#define TDFX_COLOR( dst, src )                 \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-   dst[3] = src[3];                            \
+#define TDFX_COLOR( dst, src )                         \
+do {                                                   \
+   UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]);       \
+   UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]);       \
+   UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]);       \
+   UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]);       \
 } while (0)
 
 #define DEPTH_SCALE 1.0