summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2005-05-25 13:34:52 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2005-05-25 13:34:52 +0000
commit741b9804336e291d6ea1f1b664a68e08d77d2e24 (patch)
tree1f1612685ea2d94a057c9ef5bb0acb45a54d6e05 /src
parent3f6d9857532ee5161ae4032f9aa3d9d375c1b43a (diff)
add special case for flat shaded + separate specular triangles
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.h1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_state.c1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_tris.c67
3 files changed, 51 insertions, 18 deletions
diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h
index 2ef4884698..54460d56f5 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.h
+++ b/src/mesa/drivers/dri/unichrome/via_context.h
@@ -184,6 +184,7 @@ struct via_context {
GLmatrix ViewportMatrix;
GLenum renderPrimitive;
GLenum hwPrimitive;
+ GLenum hwShadeModel;
unsigned char *verts;
/* drmBufPtr dma_buffer;
diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c
index ba6c9932d3..4037d14fff 100644
--- a/src/mesa/drivers/dri/unichrome/via_state.c
+++ b/src/mesa/drivers/dri/unichrome/via_state.c
@@ -463,7 +463,6 @@ void viaEmitState(struct via_context *vmesa)
for (j = 0; j < table->Size; j++) {
OUT_RING( tableF[j] );
}
-
ADVANCE_RING();
}
diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c
index 898a343856..9cb88ae239 100644
--- a/src/mesa/drivers/dri/unichrome/via_tris.c
+++ b/src/mesa/drivers/dri/unichrome/via_tris.c
@@ -48,6 +48,11 @@
/***********************************************************************
* Emit primitives as inline vertices *
***********************************************************************/
+#define LINE_FALLBACK (0)
+#define POINT_FALLBACK (0)
+#define TRI_FALLBACK (0)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
#if 0
@@ -238,7 +243,7 @@ static struct {
tnl_line_func line;
tnl_triangle_func triangle;
tnl_quad_func quad;
-} rast_tab[VIA_MAX_TRIFUNC];
+} rast_tab[VIA_MAX_TRIFUNC + 1];
#define DO_FALLBACK (IND & VIA_FALLBACK_BIT)
@@ -298,20 +303,21 @@ do { \
#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
-#define VERT_SET_SPEC( v0, c ) \
+#define VERT_SET_SPEC( v, c ) \
do { \
if (specoffset) { \
- 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]); \
+ via_color_t *color = (via_color_t *)&((v)->ui[specoffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
} \
} while (0)
#define VERT_COPY_SPEC( v0, v1 ) \
do { \
if (specoffset) { \
- v0->v.specular.red = v1->v.specular.red; \
- v0->v.specular.green = v1->v.specular.green; \
- v0->v.specular.blue = v1->v.specular.blue; \
+ v0->ub4[specoffset][0] = v1->ub4[specoffset][0]; \
+ v0->ub4[specoffset][1] = v1->ub4[specoffset][1]; \
+ v0->ub4[specoffset][2] = v1->ub4[specoffset][2]; \
} \
} while (0)
@@ -428,6 +434,24 @@ static const GLenum hwPrim[GL_POLYGON + 2] = {
#include "tnl_dd/t_dd_tritmp.h"
+/* Catchall case for flat, separate specular triangles (via has flat
+ * diffuse shading, but always does specular color with gouraud).
+ */
+#undef DO_FALLBACK
+#undef DO_OFFSET
+#undef DO_UNFILLED
+#undef DO_TWOSIDE
+#undef DO_FLAT
+#define DO_FALLBACK (0)
+#define DO_OFFSET (ctx->_TriangleCaps & DD_TRI_OFFSET)
+#define DO_UNFILLED (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+#define DO_TWOSIDE (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+#define DO_FLAT 1
+#define TAG(x) x##_flat_specular
+#define IND VIA_MAX_TRIFUNC
+#include "tnl_dd/t_dd_tritmp.h"
+
+
static void init_rast_tab(void)
{
init();
@@ -446,6 +470,8 @@ static void init_rast_tab(void)
init_offset_unfilled_fallback();
init_twoside_unfilled_fallback();
init_twoside_offset_unfilled_fallback();
+
+ init_flat_specular(); /* special! */
}
@@ -619,11 +645,6 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
_DD_NEW_TRI_STIPPLE | \
_NEW_POLYGONSTIPPLE)
-#define LINE_FALLBACK (0)
-#define POINT_FALLBACK (0)
-#define TRI_FALLBACK (0)
-#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
-#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
static void viaChooseRenderState(GLcontext *ctx)
{
@@ -662,6 +683,12 @@ static void viaChooseRenderState(GLcontext *ctx)
vmesa->drawTri = via_fallback_tri;
}
+
+ if ((flags & DD_SEPARATE_SPECULAR) &&
+ ctx->Light.ShadeModel == GL_FLAT) {
+ index = VIA_MAX_TRIFUNC; /* flat specular */
+ }
+
if (vmesa->renderIndex != index) {
vmesa->renderIndex = index;
@@ -875,13 +902,18 @@ void viaRasterPrimitive(GLcontext *ctx,
RING_VARS;
if (VIA_DEBUG & DEBUG_PRIMS)
- fprintf(stderr, "%s: %s/%s\n",
+ fprintf(stderr, "%s: %s/%s/%s\n",
__FUNCTION__, _mesa_lookup_enum_by_nr(glprim),
- _mesa_lookup_enum_by_nr(hwprim));
+ _mesa_lookup_enum_by_nr(hwprim),
+ _mesa_lookup_enum_by_nr(ctx->Light.ShadeModel));
+
+ assert (!vmesa->newState);
vmesa->renderPrimitive = glprim;
- if (hwprim != vmesa->hwPrimitive) {
+ if (hwprim != vmesa->hwPrimitive ||
+ ctx->Light.ShadeModel != vmesa->hwShadeModel) {
+
VIA_FINISH_PRIM(vmesa);
/* Ensure no wrapping inside this function */
@@ -896,7 +928,8 @@ void viaRasterPrimitive(GLcontext *ctx,
if (ctx->Light.ShadeModel == GL_SMOOTH) {
vmesa->regCmdA_End |= HC_HShading_Gouraud;
}
-
+
+ vmesa->hwShadeModel = ctx->Light.ShadeModel;
regCmdB = vmesa->regCmdB;
switch (hwprim) {