X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmesa%2Ftnl_dd%2Ft_dd_dmatmp.h;h=2424204b886f4f8e08f9fa4c8dfc4daa319967ff;hb=d9ea1af82c233a10adbf9b842546e9322480591b;hp=3d5e496f15f5b34153faf87baef78991e547595b;hpb=3152b1586cfdb06df204c5291db7b0f3850d8cb9;p=mesa.git diff --git a/src/mesa/tnl_dd/t_dd_dmatmp.h b/src/mesa/tnl_dd/t_dd_dmatmp.h index 3d5e496f15f..2424204b886 100644 --- a/src/mesa/tnl_dd/t_dd_dmatmp.h +++ b/src/mesa/tnl_dd/t_dd_dmatmp.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 6.1 + * Version: 6.5.1 * - * Copyright (C) 1999-2004 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2006 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,7 +26,9 @@ */ -/* Template for render stages which build and emit vertices directly +/** + * \file t_dd_dmatmp.h + * Template for render stages which build and emit vertices directly * to fixed-size dma buffers. Useful for rendering strips and other * native primitives where clipping and per-vertex tweaks such as * those in t_dd_tritmp.h are not required. @@ -35,8 +37,6 @@ * Where various primitive types are unaccelerated by hardware, the * code attempts to fallback to other primitive types (quadstrips to * tristrips, lineloops to linestrips), or to indexed vertices. - * Ultimately, a FALLBACK() macro is invoked if there is no way to - * render the primitive natively. */ #if !defined(HAVE_TRIANGLES) @@ -241,6 +241,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx, tmp = ALLOC_VERTS(nr+1); tmp = TAG(emit_verts)( ctx, j, nr, tmp ); tmp = TAG(emit_verts)( ctx, start, 1, tmp ); + (void) tmp; } else { TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) ); @@ -254,6 +255,7 @@ static void TAG(render_line_loop_verts)( GLcontext *ctx, tmp = ALLOC_VERTS(2); tmp = TAG(emit_verts)( ctx, start+1, 1, tmp ); tmp = TAG(emit_verts)( ctx, start, 1, tmp ); + (void) tmp; } FLUSH(); @@ -358,6 +360,7 @@ static void TAG(render_tri_fan_verts)( GLcontext *ctx, tmp = ALLOC_VERTS( nr ); tmp = TAG(emit_verts)( ctx, start, 1, tmp ); tmp = TAG(emit_verts)( ctx, j, nr - 1, tmp ); + (void) tmp; currentsz = dmasz; } @@ -397,12 +400,13 @@ static void TAG(render_poly_verts)( GLcontext *ctx, tmp = ALLOC_VERTS( nr ); tmp = TAG(emit_verts)( ctx, start, 1, tmp ); tmp = TAG(emit_verts)( ctx, j, nr - 1, tmp ); + (void) tmp; currentsz = dmasz; } FLUSH(); } - else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) { + else if (HAVE_TRI_FANS && ctx->Light.ShadeModel == GL_SMOOTH) { TAG(render_tri_fan_verts)( ctx, start, count, flags ); } else { fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__); @@ -441,7 +445,9 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, FLUSH(); - } else if (HAVE_TRI_STRIPS && (ctx->_TriangleCaps & DD_FLATSHADE)) { + } else if (HAVE_TRI_STRIPS && + ctx->Light.ShadeModel == GL_FLAT && + TNL_CONTEXT(ctx)->vb.AttribPtr[_TNL_ATTRIB_COLOR0]->stride) { if (HAVE_ELTS) { LOCAL_VARS; int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); @@ -491,8 +497,8 @@ static void TAG(render_quad_strip_verts)( GLcontext *ctx, FLUSH(); } else { - /* Vertices won't fit in a single buffer or elts not available, - * VERT_FALLBACK. + /* Vertices won't fit in a single buffer or elts not + * available - should never happen. */ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__); return; @@ -561,9 +567,8 @@ static void TAG(render_quads_verts)( GLcontext *ctx, TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) ); currentsz = dmasz; } - - - } else if (HAVE_ELTS) { + } + else if (HAVE_ELTS) { /* Hardware doesn't have a quad primitive type -- try to * simulate it using indexed vertices and the triangle * primitive: @@ -614,8 +619,30 @@ static void TAG(render_quads_verts)( GLcontext *ctx, RELEASE_ELT_VERTS(); } + else if (HAVE_TRIANGLES) { + /* Hardware doesn't have a quad primitive type -- try to + * simulate it using triangle primitive. This is a win for + * gears, but is it useful in the broader world? + */ + LOCAL_VARS; + GLuint j; + + INIT(GL_TRIANGLES); + + for (j = start; j < count-3; j += 4) { + void *tmp = ALLOC_VERTS( 6 ); + /* Send v0, v1, v3 + */ + tmp = EMIT_VERTS(ctx, j, 2, tmp); + tmp = EMIT_VERTS(ctx, j + 3, 1, tmp); + /* Send v1, v2, v3 + */ + tmp = EMIT_VERTS(ctx, j + 1, 3, tmp); + (void) tmp; + } + } else { - /* Vertices won't fit in a single buffer, fallback. + /* Vertices won't fit in a single buffer, should never happen. */ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__); return; @@ -798,6 +825,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, tmp = ALLOC_ELTS(nr+1); tmp = TAG(emit_elts)( ctx, elts+j, nr, tmp ); tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp ); + (void) tmp; } else { TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) ); @@ -811,6 +839,7 @@ static void TAG(render_line_loop_elts)( GLcontext *ctx, tmp = ALLOC_ELTS(2); tmp = TAG(emit_elts)( ctx, elts+start+1, 1, tmp ); tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp ); + (void) tmp; } FLUSH(); @@ -924,6 +953,7 @@ static void TAG(render_tri_fan_elts)( GLcontext *ctx, tmp = ALLOC_ELTS( nr ); tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp ); tmp = TAG(emit_elts)( ctx, elts+j, nr - 1, tmp ); + (void) tmp; FLUSH(); currentsz = dmasz; } @@ -961,10 +991,11 @@ static void TAG(render_poly_elts)( GLcontext *ctx, tmp = ALLOC_ELTS( nr ); tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp ); tmp = TAG(emit_elts)( ctx, elts+j, nr - 1, tmp ); + (void) tmp; FLUSH(); currentsz = dmasz; } - } else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) { + } else if (HAVE_TRI_FANS && ctx->Light.ShadeModel == GL_SMOOTH) { TAG(render_tri_fan_verts)( ctx, start, count, flags ); } else { fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__); @@ -998,7 +1029,7 @@ static void TAG(render_quad_strip_elts)( GLcontext *ctx, if (currentsz < 12) currentsz = dmasz; - if (ctx->_TriangleCaps & DD_FLATSHADE) { + if (ctx->Light.ShadeModel == GL_FLAT) { ELT_INIT( GL_TRIANGLES ); currentsz = currentsz/6*2; @@ -1139,10 +1170,8 @@ static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] = - - - -/* Prevent fallbacks later on. +/* Pre-check the primitives in the VB to prevent the need for + * fallbacks later on. */ static GLboolean TAG(validate_render)( GLcontext *ctx, struct vertex_buffer *VB ) @@ -1189,8 +1218,9 @@ static GLboolean TAG(validate_render)( GLcontext *ctx, if (HAVE_POLYGONS) { ok = GL_TRUE; } - else - ok = (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)); + else { + ok = (HAVE_TRI_FANS && ctx->Light.ShadeModel == GL_SMOOTH); + } break; case GL_QUAD_STRIP: if (VB->Elts) { @@ -1198,7 +1228,9 @@ static GLboolean TAG(validate_render)( GLcontext *ctx, } else if (HAVE_QUAD_STRIPS) { ok = GL_TRUE; - } else if (HAVE_TRI_STRIPS && (ctx->_TriangleCaps & DD_FLATSHADE)) { + } else if (HAVE_TRI_STRIPS && + ctx->Light.ShadeModel == GL_FLAT && + VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride != 0) { if (HAVE_ELTS) { ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS(); } @@ -1216,14 +1248,17 @@ static GLboolean TAG(validate_render)( GLcontext *ctx, ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS(); } else { - ok = GL_FALSE; + ok = HAVE_TRIANGLES; /* flatshading is ok. */ } break; default: break; } - if (!ok) return GL_FALSE; + if (!ok) { +/* fprintf(stderr, "not ok %s\n", _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK)); */ + return GL_FALSE; + } } return GL_TRUE;