aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/swrast_setup
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/swrast_setup')
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_context.c23
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_triangle.c74
-rw-r--r--mesalib/src/mesa/swrast_setup/ss_tritmp.h152
3 files changed, 84 insertions, 165 deletions
diff --git a/mesalib/src/mesa/swrast_setup/ss_context.c b/mesalib/src/mesa/swrast_setup/ss_context.c
index 61172f997..ebd1574c4 100644
--- a/mesalib/src/mesa/swrast_setup/ss_context.c
+++ b/mesalib/src/mesa/swrast_setup/ss_context.c
@@ -122,7 +122,7 @@ setup_vertex_format(GLcontext *ctx)
swsetup->last_index_bitset)) {
DECLARE_RENDERINPUTS(index_bitset);
struct tnl_attr_map map[_TNL_ATTRIB_MAX];
- int i, e = 0;
+ unsigned int i, e = 0;
swsetup->intColors = intColors;
@@ -141,11 +141,6 @@ setup_vertex_format(GLcontext *ctx)
EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[FRAG_ATTRIB_COL1]);
}
- if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR_INDEX )) {
- EMIT_ATTR( _TNL_ATTRIB_COLOR_INDEX, EMIT_1F,
- attrib[FRAG_ATTRIB_CI][0] );
- }
-
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : EMIT_1F;
EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[FRAG_ATTRIB_FOGC]);
@@ -294,18 +289,12 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i,
dest->attrib[FRAG_ATTRIB_VAR0 + i] );
- if (ctx->Visual.rgbMode) {
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0,
- dest->attrib[FRAG_ATTRIB_COL0] );
- UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0,
+ dest->attrib[FRAG_ATTRIB_COL0] );
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1,
- dest->attrib[FRAG_ATTRIB_COL1]);
- }
- else {
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
- dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
- }
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1,
+ dest->attrib[FRAG_ATTRIB_COL1]);
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp );
dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0];
diff --git a/mesalib/src/mesa/swrast_setup/ss_triangle.c b/mesalib/src/mesa/swrast_setup/ss_triangle.c
index e15b1348d..bad0d8194 100644
--- a/mesalib/src/mesa/swrast_setup/ss_triangle.c
+++ b/mesalib/src/mesa/swrast_setup/ss_triangle.c
@@ -35,11 +35,10 @@
#include "ss_triangle.h"
#include "ss_context.h"
-#define SS_RGBA_BIT 0x1
-#define SS_OFFSET_BIT 0x2
-#define SS_TWOSIDE_BIT 0x4
-#define SS_UNFILLED_BIT 0x8
-#define SS_MAX_TRIFUNC 0x10
+#define SS_OFFSET_BIT 0x1
+#define SS_TWOSIDE_BIT 0x2
+#define SS_UNFILLED_BIT 0x4
+#define SS_MAX_TRIFUNC 0x8
static tnl_triangle_func tri_tab[SS_MAX_TRIFUNC];
static tnl_quad_func quad_tab[SS_MAX_TRIFUNC];
@@ -134,23 +133,18 @@ static void _swsetup_render_tri(GLcontext *ctx,
if (ctx->Light.ShadeModel == GL_FLAT) {
GLchan c[2][4];
GLfloat s[2][4];
- GLfloat i[2];
/* save colors/indexes for v0, v1 vertices */
COPY_CHAN4(c[0], v0->color);
COPY_CHAN4(c[1], v1->color);
COPY_4V(s[0], v0->attrib[FRAG_ATTRIB_COL1]);
COPY_4V(s[1], v1->attrib[FRAG_ATTRIB_COL1]);
- i[0] = v0->attrib[FRAG_ATTRIB_CI][0];
- i[1] = v1->attrib[FRAG_ATTRIB_CI][0];
/* copy v2 color/indexes to v0, v1 indexes */
COPY_CHAN4(v0->color, v2->color);
COPY_CHAN4(v1->color, v2->color);
COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], v2->attrib[FRAG_ATTRIB_COL1]);
- v0->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
- v1->attrib[FRAG_ATTRIB_CI][0] = v2->attrib[FRAG_ATTRIB_CI][0];
render(ctx, ef, e0, e1, e2, v0, v1, v2);
@@ -158,8 +152,6 @@ static void _swsetup_render_tri(GLcontext *ctx,
COPY_CHAN4(v1->color, c[1]);
COPY_4V(v0->attrib[FRAG_ATTRIB_COL1], s[0]);
COPY_4V(v1->attrib[FRAG_ATTRIB_COL1], s[1]);
- v0->attrib[FRAG_ATTRIB_CI][0] = i[0];
- v1->attrib[FRAG_ATTRIB_CI][0] = i[1];
}
else {
render(ctx, ef, e0, e1, e2, v0, v1, v2);
@@ -171,66 +163,34 @@ static void _swsetup_render_tri(GLcontext *ctx,
#define SS_IND(a,b) (a = b)
#define IND (0)
-#define TAG(x) x
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT)
-#define TAG(x) x##_offset
-#include "ss_tritmp.h"
-
-#define IND (SS_TWOSIDE_BIT)
-#define TAG(x) x##_twoside
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
-#define TAG(x) x##_offset_twoside
-#include "ss_tritmp.h"
-
-#define IND (SS_UNFILLED_BIT)
-#define TAG(x) x##_unfilled
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_offset_unfilled
-#include "ss_tritmp.h"
-
-#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled
-#include "ss_tritmp.h"
-
-#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
-#define TAG(x) x##_offset_twoside_unfilled
-#include "ss_tritmp.h"
-
-#define IND (0|SS_RGBA_BIT)
#define TAG(x) x##_rgba
#include "ss_tritmp.h"
-#define IND (SS_OFFSET_BIT|SS_RGBA_BIT)
+#define IND (SS_OFFSET_BIT)
#define TAG(x) x##_offset_rgba
#include "ss_tritmp.h"
-#define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT)
+#define IND (SS_TWOSIDE_BIT)
#define TAG(x) x##_twoside_rgba
#include "ss_tritmp.h"
-#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
#define TAG(x) x##_offset_twoside_rgba
#include "ss_tritmp.h"
-#define IND (SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define IND (SS_UNFILLED_BIT)
#define TAG(x) x##_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_offset_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_twoside_unfilled_rgba
#include "ss_tritmp.h"
-#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
#define TAG(x) x##_offset_twoside_unfilled_rgba
#include "ss_tritmp.h"
@@ -239,15 +199,6 @@ void _swsetup_trifuncs_init( GLcontext *ctx )
{
(void) ctx;
- init();
- init_offset();
- init_twoside();
- init_offset_twoside();
- init_unfilled();
- init_offset_unfilled();
- init_twoside_unfilled();
- init_offset_twoside_unfilled();
-
init_rgba();
init_offset_rgba();
init_twoside_rgba();
@@ -307,9 +258,6 @@ void _swsetup_choose_trifuncs( GLcontext *ctx )
(ctx->Stencil.Enabled && ctx->Stencil._TestTwoSide))
ind |= SS_UNFILLED_BIT;
- if (ctx->Visual.rgbMode)
- ind |= SS_RGBA_BIT;
-
tnl->Driver.Render.Triangle = tri_tab[ind];
tnl->Driver.Render.Quad = quad_tab[ind];
tnl->Driver.Render.Line = swsetup_line;
diff --git a/mesalib/src/mesa/swrast_setup/ss_tritmp.h b/mesalib/src/mesa/swrast_setup/ss_tritmp.h
index bd20a8d97..8e9fa1bd5 100644
--- a/mesalib/src/mesa/swrast_setup/ss_tritmp.h
+++ b/mesalib/src/mesa/swrast_setup/ss_tritmp.h
@@ -40,10 +40,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
GLfloat offset, oz0, oz1, oz2;
GLenum mode = GL_FILL;
GLuint facing = 0;
- GLchan saved_color[3][4];
+ GLchan saved_color[3][4] = { { 0 } };
GLfloat saved_col0[3][4] = { { 0 } };
GLfloat saved_spec[3][4] = { { 0 } };
- GLfloat saved_index[3] = { 0 };
v[0] = &verts[e0];
v[1] = &verts[e1];
@@ -66,75 +65,64 @@ 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) {
- if (VB->ColorPtr[1]) {
- GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+ if (VB->BackfaceColorPtr) {
+ GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->data;
+ if (swsetup->intColors) {
+ COPY_CHAN4(saved_color[0], v[0]->color);
+ COPY_CHAN4(saved_color[1], v[1]->color);
+ COPY_CHAN4(saved_color[2], v[2]->color);
+ }
+ else {
+ COPY_4V(saved_col0[0], v[0]->attrib[FRAG_ATTRIB_COL0]);
+ COPY_4V(saved_col0[1], v[1]->attrib[FRAG_ATTRIB_COL0]);
+ COPY_4V(saved_col0[2], v[2]->attrib[FRAG_ATTRIB_COL0]);
+ }
+
+ if (VB->BackfaceColorPtr->stride) {
if (swsetup->intColors) {
- COPY_CHAN4(saved_color[0], v[0]->color);
- COPY_CHAN4(saved_color[1], v[1]->color);
- COPY_CHAN4(saved_color[2], v[2]->color);
+ SS_COLOR(v[0]->color, vbcolor[e0]);
+ SS_COLOR(v[1]->color, vbcolor[e1]);
+ SS_COLOR(v[2]->color, vbcolor[e2]);
}
else {
- COPY_4V(saved_col0[0], v[0]->attrib[FRAG_ATTRIB_COL0]);
- COPY_4V(saved_col0[1], v[1]->attrib[FRAG_ATTRIB_COL0]);
- COPY_4V(saved_col0[2], v[2]->attrib[FRAG_ATTRIB_COL0]);
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[e0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[e1]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[e2]);
}
-
- if (VB->ColorPtr[1]->stride) {
- if (swsetup->intColors) {
- SS_COLOR(v[0]->color, vbcolor[e0]);
- SS_COLOR(v[1]->color, vbcolor[e1]);
- SS_COLOR(v[2]->color, vbcolor[e2]);
- }
- else {
- COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[e0]);
- COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[e1]);
- COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[e2]);
- }
+ }
+ else {
+ /* flat shade */
+ if (swsetup->intColors) {
+ SS_COLOR(v[0]->color, vbcolor[0]);
+ SS_COLOR(v[1]->color, vbcolor[0]);
+ SS_COLOR(v[2]->color, vbcolor[0]);
}
else {
- /* flat shade */
- if (swsetup->intColors) {
- SS_COLOR(v[0]->color, vbcolor[0]);
- SS_COLOR(v[1]->color, vbcolor[0]);
- SS_COLOR(v[2]->color, vbcolor[0]);
- }
- else {
- COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
- COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
- COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
- }
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], vbcolor[0]);
}
}
+ }
- if (VB->SecondaryColorPtr[1]) {
- GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+ if (VB->BackfaceSecondaryColorPtr) {
+ GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data;
- COPY_4V(saved_spec[0], v[0]->attrib[FRAG_ATTRIB_COL1]);
- COPY_4V(saved_spec[1], v[1]->attrib[FRAG_ATTRIB_COL1]);
- COPY_4V(saved_spec[2], v[2]->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(saved_spec[0], v[0]->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(saved_spec[1], v[1]->attrib[FRAG_ATTRIB_COL1]);
+ COPY_4V(saved_spec[2], v[2]->attrib[FRAG_ATTRIB_COL1]);
- if (VB->SecondaryColorPtr[1]->stride) {
- SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[e0]);
- SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[e1]);
- SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[e2]);
- }
- else {
- SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
- SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
- SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
- }
+ if (VB->BackfaceSecondaryColorPtr->stride) {
+ SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[e0]);
+ SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[e1]);
+ SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[e2]);
+ }
+ else {
+ SS_SPEC(v[0]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
+ SS_SPEC(v[1]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
+ SS_SPEC(v[2]->attrib[FRAG_ATTRIB_COL1], vbspec[0]);
}
- } else {
- GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
- saved_index[0] = v[0]->attrib[FRAG_ATTRIB_CI][0];
- saved_index[1] = v[1]->attrib[FRAG_ATTRIB_CI][0];
- saved_index[2] = v[2]->attrib[FRAG_ATTRIB_CI][0];
-
- SS_IND(v[0]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e0]);
- SS_IND(v[1]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e1]);
- SS_IND(v[2]->attrib[FRAG_ATTRIB_CI][0], (GLuint) vbindex[e2]);
}
}
}
@@ -159,9 +147,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
}
/* new Z values */
- oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
- oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
- oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0, max);
+ oz0 = CLAMP(v[0]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
+ oz1 = CLAMP(v[1]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
+ oz2 = CLAMP(v[2]->attrib[FRAG_ATTRIB_WPOS][2] + offset, 0.0F, max);
}
}
@@ -199,30 +187,24 @@ 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) {
- if (VB->ColorPtr[1]) {
- if (swsetup->intColors) {
- COPY_CHAN4(v[0]->color, saved_color[0]);
- COPY_CHAN4(v[1]->color, saved_color[1]);
- COPY_CHAN4(v[2]->color, saved_color[2]);
- }
- else {
- COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], saved_col0[0]);
- COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], saved_col0[1]);
- COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], saved_col0[2]);
- }
- }
-
- if (VB->SecondaryColorPtr[1]) {
- COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL1], saved_spec[0]);
- COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL1], saved_spec[1]);
- COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL1], saved_spec[2]);
- }
- } else {
- v[0]->attrib[FRAG_ATTRIB_CI][0] = saved_index[0];
- v[1]->attrib[FRAG_ATTRIB_CI][0] = saved_index[1];
- v[2]->attrib[FRAG_ATTRIB_CI][0] = saved_index[2];
- }
+ if (VB->BackfaceColorPtr) {
+ if (swsetup->intColors) {
+ COPY_CHAN4(v[0]->color, saved_color[0]);
+ COPY_CHAN4(v[1]->color, saved_color[1]);
+ COPY_CHAN4(v[2]->color, saved_color[2]);
+ }
+ else {
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL0], saved_col0[0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL0], saved_col0[1]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL0], saved_col0[2]);
+ }
+ }
+
+ if (VB->BackfaceSecondaryColorPtr) {
+ COPY_4V(v[0]->attrib[FRAG_ATTRIB_COL1], saved_spec[0]);
+ COPY_4V(v[1]->attrib[FRAG_ATTRIB_COL1], saved_spec[1]);
+ COPY_4V(v[2]->attrib[FRAG_ATTRIB_COL1], saved_spec[2]);
+ }
}
}
}