diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-05-23 15:33:46 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-05-23 15:34:50 -0600 |
commit | a7008322146f589ed5cb7a563365ff5e31844c62 (patch) | |
tree | f95da3ee9e567c3c63e27a8afdf15aa4bec665d9 | |
parent | 491618b33dcb388f5d2335862cba8cf110d72ae7 (diff) |
Fix problem w/ two-sided lighting and fragment programs (depth-peel regression)
-rw-r--r-- | src/mesa/swrast_setup/ss_context.c | 13 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_context.h | 6 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_tritmp.h | 66 |
3 files changed, 62 insertions, 23 deletions
diff --git a/src/mesa/swrast_setup/ss_context.c b/src/mesa/swrast_setup/ss_context.c index 9f83fde1f5..cd4ac57d37 100644 --- a/src/mesa/swrast_setup/ss_context.c +++ b/src/mesa/swrast_setup/ss_context.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -123,12 +123,13 @@ setup_vertex_format(GLcontext *ctx) EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] ); if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) { - if (ctx->FragmentProgram._Current - || ctx->ATIFragmentShader._Enabled - || CHAN_TYPE == GL_FLOAT) - EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F, attrib[FRAG_ATTRIB_COL0]); - else + swsetup->intColors = !ctx->FragmentProgram._Current + && !ctx->ATIFragmentShader._Enabled + && CHAN_TYPE == GL_UNSIGNED_BYTE; + if (swsetup->intColors) EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color ); + else + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F, attrib[FRAG_ATTRIB_COL0]); } if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) { diff --git a/src/mesa/swrast_setup/ss_context.h b/src/mesa/swrast_setup/ss_context.h index e5d890447a..11f9ded3ff 100644 --- a/src/mesa/swrast_setup/ss_context.h +++ b/src/mesa/swrast_setup/ss_context.h @@ -1,9 +1,8 @@ - /* * Mesa 3-D graphics library - * Version: 6.5 + * Version: 7.1 * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -39,6 +38,7 @@ typedef struct { GLenum render_prim; DECLARE_RENDERINPUTS(last_index_bitset); SWvertex *verts; + GLboolean intColors; } SScontext; #define SWSETUP_CONTEXT(ctx) ((SScontext *)ctx->swsetup_context) diff --git a/src/mesa/swrast_setup/ss_tritmp.h b/src/mesa/swrast_setup/ss_tritmp.h index 9fcde31644..c14468e951 100644 --- a/src/mesa/swrast_setup/ss_tritmp.h +++ b/src/mesa/swrast_setup/ss_tritmp.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 7.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -26,9 +26,14 @@ */ +/** + * This is where we handle assigning vertex colors based on front/back + * facing, compute polygon offset and handle glPolygonMode(). + */ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + SScontext *swsetup = SWSETUP_CONTEXT(ctx); SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; SWvertex *v[3]; GLfloat z[3]; @@ -36,6 +41,7 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) GLenum mode = GL_FILL; GLuint facing = 0; GLchan saved_color[3][4]; + GLfloat saved_col0[3][4]; GLfloat saved_spec[3][4]; GLfloat saved_index[3]; @@ -66,19 +72,41 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) if (VB->ColorPtr[1]) { GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; - COPY_CHAN4(saved_color[0], v[0]->color); - COPY_CHAN4(saved_color[1], v[1]->color); - COPY_CHAN4(saved_color[2], v[2]->color); + 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->ColorPtr[1]->stride) { - SS_COLOR(v[0]->color, vbcolor[e0]); - SS_COLOR(v[1]->color, vbcolor[e1]); - SS_COLOR(v[2]->color, vbcolor[e2]); + 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 { - SS_COLOR(v[0]->color, vbcolor[0]); - SS_COLOR(v[1]->color, vbcolor[0]); - SS_COLOR(v[2]->color, vbcolor[0]); + /* 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]); + } } } @@ -160,6 +188,9 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) _swrast_Triangle( ctx, v[0], v[1], v[2] ); } + /* + * Restore original vertex colors, etc. + */ if (IND & SS_OFFSET_BIT) { v[0]->attrib[FRAG_ATTRIB_WPOS][2] = z[0]; v[1]->attrib[FRAG_ATTRIB_WPOS][2] = z[1]; @@ -170,9 +201,16 @@ static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) if (facing == 1) { if (IND & SS_RGBA_BIT) { if (VB->ColorPtr[1]) { - COPY_CHAN4(v[0]->color, saved_color[0]); - COPY_CHAN4(v[1]->color, saved_color[1]); - COPY_CHAN4(v[2]->color, saved_color[2]); + 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]) { |