summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast_setup
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/swrast_setup')
-rw-r--r--src/mesa/swrast_setup/ss_context.c26
-rw-r--r--src/mesa/swrast_setup/ss_tritmp.h40
2 files changed, 35 insertions, 31 deletions
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c
index cd4ac57d37d..a9c7d941e5b 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -125,6 +125,7 @@ setup_vertex_format(GLcontext *ctx)
if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) {
swsetup->intColors = !ctx->FragmentProgram._Current
&& !ctx->ATIFragmentShader._Enabled
+ && ctx->RenderMode == GL_RENDER
&& CHAN_TYPE == GL_UNSIGNED_BYTE;
if (swsetup->intColors)
EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color );
@@ -279,28 +280,29 @@ _swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
/** XXX try to limit these loops someday */
for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i,
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0 + i,
dest->attrib[FRAG_ATTRIB_TEX0 + i] );
for (i = 0 ; i < ctx->Const.MaxVarying ; i++)
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0+i,
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_GENERIC0 + i,
dest->attrib[FRAG_ATTRIB_VAR0 + i] );
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp );
- UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
+ 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_COLOR1, tmp );
- COPY_4V(dest->attrib[FRAG_ATTRIB_COL1], tmp);
- /*
- UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->specular, 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_FOG, tmp );
dest->attrib[FRAG_ATTRIB_FOGC][0] = tmp[0];
- _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR_INDEX, tmp );
- dest->attrib[FRAG_ATTRIB_CI][0] = tmp[0];
-
/* XXX See _tnl_get_attr about pointsize ... */
_tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp );
dest->pointSize = tmp[0];
diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h
index c14468e9514..f6b738d60df 100644
--- a/src/mesa/swrast_setup/ss_tritmp.h
+++ b/src/mesa/swrast_setup/ss_tritmp.h
@@ -37,7 +37,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
SWvertex *v[3];
GLfloat z[3];
- GLfloat offset;
+ GLfloat offset, oz0, oz1, oz2;
GLenum mode = GL_FILL;
GLuint facing = 0;
GLchan saved_color[3][4];
@@ -142,12 +142,16 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
}
}
- if (IND & SS_OFFSET_BIT)
- {
- offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD;
+ if (IND & SS_OFFSET_BIT) {
+ const GLfloat max = ctx->DrawBuffer->_DepthMaxF;
+ /* save original Z values (restored later) */
z[0] = v[0]->attrib[FRAG_ATTRIB_WPOS][2];
z[1] = v[1]->attrib[FRAG_ATTRIB_WPOS][2];
z[2] = v[2]->attrib[FRAG_ATTRIB_WPOS][2];
+ /* Note that Z values are already scaled to [0,65535] (for example)
+ * so no MRD value is used here.
+ */
+ offset = ctx->Polygon.OffsetUnits;
if (cc * cc > 1e-16) {
const GLfloat ez = z[0] - z[2];
const GLfloat fz = z[1] - z[2];
@@ -155,35 +159,33 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
- /* Unfortunately, we need to clamp to prevent negative Zs below.
- * Technically, we should do the clamping per-fragment.
- */
- offset = MAX2(offset, -v[0]->attrib[FRAG_ATTRIB_WPOS][2]);
- offset = MAX2(offset, -v[1]->attrib[FRAG_ATTRIB_WPOS][2]);
- offset = MAX2(offset, -v[2]->attrib[FRAG_ATTRIB_WPOS][2]);
}
+ /* 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);
}
}
if (mode == GL_POINT) {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
- v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
- v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
- v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
}
_swsetup_render_point_tri( ctx, e0, e1, e2, facing );
} else if (mode == GL_LINE) {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
- v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
- v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
- v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
}
_swsetup_render_line_tri( ctx, e0, e1, e2, facing );
} else {
if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
- v[0]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
- v[1]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
- v[2]->attrib[FRAG_ATTRIB_WPOS][2] += offset;
+ v[0]->attrib[FRAG_ATTRIB_WPOS][2] = oz0;
+ v[1]->attrib[FRAG_ATTRIB_WPOS][2] = oz1;
+ v[2]->attrib[FRAG_ATTRIB_WPOS][2] = oz2;
}
_swrast_Triangle( ctx, v[0], v[1], v[2] );
}