summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast_setup
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2001-07-17 19:39:32 +0000
committerKeith Whitwell <[email protected]>2001-07-17 19:39:32 +0000
commit53560311294814ae0daa8457307a2b25077bf4e9 (patch)
treecffad805f3e213014d055f53609d71dd81aa37fc /src/mesa/swrast_setup
parent4ae22b9721e4f123354aad9921da1613fd078367 (diff)
Lighting now emits colors as CHAN_TYPE, as it used to. This will require
minor adjustments in the dri drivers for twosided lighting to work again.
Diffstat (limited to 'src/mesa/swrast_setup')
-rw-r--r--src/mesa/swrast_setup/ss_context.c18
-rw-r--r--src/mesa/swrast_setup/ss_context.h8
-rw-r--r--src/mesa/swrast_setup/ss_triangle.c6
-rw-r--r--src/mesa/swrast_setup/ss_tritmp.h10
-rw-r--r--src/mesa/swrast_setup/ss_vb.c70
-rw-r--r--src/mesa/swrast_setup/ss_vbtmp.h29
6 files changed, 100 insertions, 41 deletions
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index 2e92342e079..4b8c003c2e7 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -1,4 +1,4 @@
-/* $Id: ss_context.c,v 1.14 2001/07/12 22:09:21 keithw Exp $ */
+/* $Id: ss_context.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -78,11 +78,19 @@ _swsetup_CreateContext( GLcontext *ctx )
void
_swsetup_DestroyContext( GLcontext *ctx )
{
- if (SWSETUP_CONTEXT(ctx)) {
- if (SWSETUP_CONTEXT(ctx)->verts)
- ALIGN_FREE(SWSETUP_CONTEXT(ctx)->verts);
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ if (swsetup) {
+ if (swsetup->verts)
+ ALIGN_FREE(swsetup->verts);
+
+ if (swsetup->ChanSecondaryColor.Ptr)
+ ALIGN_FREE(swsetup->ChanSecondaryColor.Ptr);
- FREE(SWSETUP_CONTEXT(ctx));
+ if (swsetup->ChanColor.Ptr)
+ ALIGN_FREE(swsetup->ChanColor.Ptr);
+
+ FREE(swsetup);
ctx->swsetup_context = 0;
}
}
diff --git a/src/mesa/swrast_setup/ss_context.h b/src/mesa/swrast_setup/ss_context.h
index f477f850cd3..ed4da78d629 100644
--- a/src/mesa/swrast_setup/ss_context.h
+++ b/src/mesa/swrast_setup/ss_context.h
@@ -1,4 +1,4 @@
-/* $Id: ss_context.h,v 1.8 2001/07/12 22:09:21 keithw Exp $ */
+/* $Id: ss_context.h,v 1.9 2001/07/17 19:39:32 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -40,6 +40,12 @@ typedef struct {
GLenum render_prim;
GLuint SetupIndex;
+ /* Temporaries for translating away float colors:
+ */
+ struct gl_client_array ChanColor;
+ struct gl_client_array ChanSecondaryColor;
+
+
struct {
void (*Start)( GLcontext * );
void (*Finish)( GLcontext * );
diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c
index 7b2d638213d..7612a64d06f 100644
--- a/src/mesa/swrast_setup/ss_triangle.c
+++ b/src/mesa/swrast_setup/ss_triangle.c
@@ -1,4 +1,4 @@
-/* $Id: ss_triangle.c,v 1.14 2001/07/12 22:09:21 keithw Exp $ */
+/* $Id: ss_triangle.c,v 1.15 2001/07/17 19:39:32 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -141,8 +141,8 @@ static void _swsetup_render_point_tri( GLcontext *ctx,
}
}
-#define SS_COLOR(a,b) UNCLAMPED_FLOAT_TO_RGBA_CHAN(a,b)
-#define SS_SPEC(a,b) UNCLAMPED_FLOAT_TO_RGB_CHAN(a,b)
+#define SS_COLOR(a,b) COPY_CHAN4(a,b)
+#define SS_SPEC(a,b) COPY_3V(a,b)
#define SS_IND(a,b) (a = b)
#define IND (0)
diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h
index 49e92acf1c3..aeb407da494 100644
--- a/src/mesa/swrast_setup/ss_tritmp.h
+++ b/src/mesa/swrast_setup/ss_tritmp.h
@@ -1,4 +1,4 @@
-/* $Id: ss_tritmp.h,v 1.13 2001/07/12 22:09:21 keithw Exp $ */
+/* $Id: ss_tritmp.h,v 1.14 2001/07/17 19:39:32 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -61,12 +61,12 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (facing == 1) {
if (IND & SS_TWOSIDE_BIT) {
if (IND & SS_RGBA_BIT) {
- GLfloat (*vbcolor)[4] = (GLfloat (*)[4])VB->ColorPtr[1]->Ptr;
+ GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[1]->Ptr;
SS_COLOR(v[0]->color, vbcolor[e0]);
SS_COLOR(v[1]->color, vbcolor[e1]);
SS_COLOR(v[2]->color, vbcolor[e2]);
if (VB->SecondaryColorPtr[1]) {
- GLfloat (*vbspec)[4] = (GLfloat (*)[4])VB->SecondaryColorPtr[1]->Ptr;
+ GLchan (*vbspec)[4] = (GLchan (*)[4])VB->SecondaryColorPtr[1]->Ptr;
SS_SPEC(v[0]->specular, vbspec[e0]);
SS_SPEC(v[1]->specular, vbspec[e1]);
SS_SPEC(v[2]->specular, vbspec[e2]);
@@ -136,12 +136,12 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
if (IND & SS_TWOSIDE_BIT) {
if (facing == 1) {
if (IND & SS_RGBA_BIT) {
- GLfloat (*vbcolor)[4] = (GLfloat (*)[4])VB->ColorPtr[0]->Ptr;
+ GLchan (*vbcolor)[4] = (GLchan (*)[4])VB->ColorPtr[0]->Ptr;
SS_COLOR(v[0]->color, vbcolor[e0]);
SS_COLOR(v[1]->color, vbcolor[e1]);
SS_COLOR(v[2]->color, vbcolor[e2]);
if (VB->SecondaryColorPtr[0]) {
- GLfloat (*vbspec)[4] = (GLfloat (*)[4])VB->SecondaryColorPtr[0]->Ptr;
+ GLchan (*vbspec)[4] = (GLchan (*)[4])VB->SecondaryColorPtr[0]->Ptr;
SS_SPEC(v[0]->specular, vbspec[e0]);
SS_SPEC(v[1]->specular, vbspec[e1]);
SS_SPEC(v[2]->specular, vbspec[e2]);
diff --git a/src/mesa/swrast_setup/ss_vb.c b/src/mesa/swrast_setup/ss_vb.c
index 7afb646769f..d77f5f1e198 100644
--- a/src/mesa/swrast_setup/ss_vb.c
+++ b/src/mesa/swrast_setup/ss_vb.c
@@ -1,4 +1,4 @@
-/* $Id: ss_vb.c,v 1.13 2001/07/12 22:09:21 keithw Exp $ */
+/* $Id: ss_vb.c,v 1.14 2001/07/17 19:39:32 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,15 +30,60 @@
#include "glheader.h"
#include "colormac.h"
#include "macros.h"
+#include "mem.h"
#include "swrast/swrast.h"
-
#include "tnl/t_context.h"
-
#include "math/m_vector.h"
+#include "math/m_translate.h"
+
#include "ss_context.h"
#include "ss_vb.h"
+static void do_import( struct vertex_buffer *VB,
+ struct gl_client_array *to,
+ struct gl_client_array *from )
+{
+ GLuint count = VB->Count;
+
+ if (!to->Ptr) {
+ to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLchan), 32 );
+ to->Type = CHAN_TYPE;
+ }
+
+ /* No need to transform the same value 3000 times.
+ */
+ if (!from->StrideB) {
+ to->StrideB = 0;
+ count = 1;
+ }
+ else
+ to->StrideB = 4 * sizeof(GLchan);
+
+ _math_trans_4chan( (GLchan (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ count);
+}
+
+static void import_float_colors( GLcontext *ctx )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanColor;
+ do_import( VB, to, VB->ColorPtr[0] );
+ VB->ColorPtr[0] = to;
+}
+
+static void import_float_spec_colors( GLcontext *ctx )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct gl_client_array *to = &SWSETUP_CONTEXT(ctx)->ChanSecondaryColor;
+ do_import( VB, to, VB->SecondaryColorPtr[0] );
+ VB->SecondaryColorPtr[0] = to;
+}
/* Provides a RasterSetup function which prebuilds vertices for the
@@ -182,7 +227,7 @@ static copy_pv_func copy_pv_tab[MAX_SETUPFUNC];
* Additional setup and interp for back color and edgeflag.
***********************************************************************/
-#define GET_COLOR(ptr, idx) (((GLfloat (*)[4])((ptr)->Ptr))[idx])
+#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx])
static void interp_extras( GLcontext *ctx,
GLfloat t,
@@ -192,13 +237,13 @@ static void interp_extras( GLcontext *ctx,
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
if (VB->ColorPtr[1]) {
- INTERP_4F( t,
+ INTERP_4CHAN( t,
GET_COLOR(VB->ColorPtr[1], dst),
GET_COLOR(VB->ColorPtr[1], out),
GET_COLOR(VB->ColorPtr[1], in) );
if (VB->SecondaryColorPtr[1]) {
- INTERP_3F( t,
+ INTERP_3CHAN( t,
GET_COLOR(VB->SecondaryColorPtr[1], dst),
GET_COLOR(VB->SecondaryColorPtr[1], out),
GET_COLOR(VB->SecondaryColorPtr[1], in) );
@@ -224,12 +269,12 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
if (VB->ColorPtr[1]) {
- COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
- GET_COLOR(VB->ColorPtr[1], src) );
-
+ COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
+
if (VB->SecondaryColorPtr[1]) {
- COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
- GET_COLOR(VB->SecondaryColorPtr[1], src) );
+ COPY_3V( GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], src) );
}
}
else if (VB->IndexPtr[1]) {
@@ -239,6 +284,9 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
copy_pv_tab[SWSETUP_CONTEXT(ctx)->SetupIndex](ctx, dst, src);
}
+
+
+
/***********************************************************************
* Initialization
***********************************************************************/
diff --git a/src/mesa/swrast_setup/ss_vbtmp.h b/src/mesa/swrast_setup/ss_vbtmp.h
index 4a83cf23019..682ca90866a 100644
--- a/src/mesa/swrast_setup/ss_vbtmp.h
+++ b/src/mesa/swrast_setup/ss_vbtmp.h
@@ -1,4 +1,4 @@
-/* $Id: ss_vbtmp.h,v 1.16 2001/07/12 22:09:21 keithw Exp $ */
+/* $Id: ss_vbtmp.h,v 1.17 2001/07/17 19:39:32 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,8 +36,8 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
SWvertex *v;
GLfloat *proj; /* projected clip coordinates */
GLfloat *tc[MAX_TEXTURE_UNITS];
- GLfloat *color;
- GLfloat *spec;
+ GLchan *color;
+ GLchan *spec;
GLuint *index;
GLfloat *fog;
GLfloat *pointSize;
@@ -81,10 +81,16 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
fog_stride = VB->FogCoordPtr->stride;
}
if (IND & COLOR) {
+ if (VB->ColorPtr[0]->Type != CHAN_TYPE)
+ import_float_colors( ctx );
+
color = VB->ColorPtr[0]->Ptr;
color_stride = VB->ColorPtr[0]->StrideB;
}
if (IND & SPEC) {
+ if (VB->SecondaryColorPtr[0]->Type != CHAN_TYPE)
+ import_float_spec_colors( ctx );
+
spec = VB->SecondaryColorPtr[0]->Ptr;
spec_stride = VB->SecondaryColorPtr[0]->StrideB;
}
@@ -123,17 +129,13 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
}
if (IND & COLOR) {
- UNCLAMPED_FLOAT_TO_RGBA_CHAN(v->color, color);
- STRIDE_F(color, color_stride);
-/* COPY_CHAN4(v->color, color); */
-/* STRIDE_CHAN(color, color_stride); */
+ COPY_CHAN4(v->color, color);
+ STRIDE_CHAN(color, color_stride);
}
if (IND & SPEC) {
- UNCLAMPED_FLOAT_TO_RGB_CHAN(v->specular, spec);
- STRIDE_F(spec, spec_stride);
-/* COPY_CHAN4(v->specular, spec); */
-/* STRIDE_CHAN(spec, spec_stride); */
+ COPY_CHAN4(v->specular, spec);
+ STRIDE_CHAN(spec, spec_stride);
}
if (IND & FOG) {
@@ -150,7 +152,6 @@ static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end,
v->pointSize = pointSize[0];
STRIDE_F(pointSize, pointSize_stride);
}
-
}
}
@@ -180,10 +181,6 @@ static void TAG(interp)( GLcontext *ctx,
dst->win[3] = oow;
}
-/* fprintf(stderr, "%s edst %d win %f %f %f %f\n", */
-/* __FUNCTION__, edst, */
-/* dst->win[0], dst->win[1], dst->win[2], dst->win[3]); */
-
if (IND & TEX0) {
INTERP_4F( t, dst->texcoord[0], out->texcoord[0], in->texcoord[0] );
}