From e755144e797ded1679d828ba58cff9e7861e59cd Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 20 Jan 2004 11:22:20 +0000 Subject: remove duplicate t_dd_* files --- src/mesa/drivers/common/t_dd.c | 58 -- src/mesa/drivers/common/t_dd_dmatmp.h | 1093 ------------------------------ src/mesa/drivers/common/t_dd_dmatmp2.h | 935 ------------------------- src/mesa/drivers/common/t_dd_rendertmp.h | 434 ------------ src/mesa/drivers/common/t_dd_triemit.h | 157 ----- src/mesa/drivers/common/t_dd_tritmp.h | 743 -------------------- src/mesa/drivers/common/t_dd_unfilled.h | 212 ------ src/mesa/drivers/common/t_dd_vb.c | 344 ---------- src/mesa/drivers/common/t_dd_vbtmp.h | 679 ------------------- src/mesa/drivers/common/t_dd_vertex.h | 78 --- 10 files changed, 4733 deletions(-) delete mode 100644 src/mesa/drivers/common/t_dd.c delete mode 100644 src/mesa/drivers/common/t_dd_dmatmp.h delete mode 100644 src/mesa/drivers/common/t_dd_dmatmp2.h delete mode 100644 src/mesa/drivers/common/t_dd_rendertmp.h delete mode 100644 src/mesa/drivers/common/t_dd_triemit.h delete mode 100644 src/mesa/drivers/common/t_dd_tritmp.h delete mode 100644 src/mesa/drivers/common/t_dd_unfilled.h delete mode 100644 src/mesa/drivers/common/t_dd_vb.c delete mode 100644 src/mesa/drivers/common/t_dd_vbtmp.h delete mode 100644 src/mesa/drivers/common/t_dd_vertex.h (limited to 'src/mesa') diff --git a/src/mesa/drivers/common/t_dd.c b/src/mesa/drivers/common/t_dd.c deleted file mode 100644 index 731da5c320..0000000000 --- a/src/mesa/drivers/common/t_dd.c +++ /dev/null @@ -1,58 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - GLubyte *i810verts = (GLubyte *)imesa->verts; - GLuint shift = imesa->vertex_stride_shift; - i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift)); - i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift)); - dst->ui[4] = src->ui[4]; - dst->ui[5] = src->ui[5]; -} - -static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - GLubyte *i810verts = (GLubyte *)imesa->verts; - GLuint shift = imesa->vertex_stride_shift; - i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift)); - i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift)); - dst->ui[4] = src->ui[4]; -} - -static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - i810ContextPtr imesa = I810_CONTEXT( ctx ); - GLubyte *i810verts = (GLubyte *)imesa->verts; - GLuint shift = imesa->vertex_stride_shift; - i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift)); - i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift)); - dst->ui[3] = src->ui[3]; -} diff --git a/src/mesa/drivers/common/t_dd_dmatmp.h b/src/mesa/drivers/common/t_dd_dmatmp.h deleted file mode 100644 index 10ff1df5f0..0000000000 --- a/src/mesa/drivers/common/t_dd_dmatmp.h +++ /dev/null @@ -1,1093 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -/* 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. - * - * Produces code for both inline triangles and indexed triangles. - * 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) -#error "must have at least triangles to use render template" -#endif - -#if !HAVE_ELTS -#define ELTS_VARS -#define ALLOC_ELTS( nr ) -#define EMIT_ELT( offset, elt ) -#define EMIT_TWO_ELTS( offset, elt0, elt1 ) -#define INCR_ELTS( nr ) -#define ELT_INIT(prim) -#define GET_CURRENT_VB_MAX_ELTS() 0 -#define GET_SUBSEQUENT_VB_MAX_ELTS() 0 -#define ALLOC_ELTS_NEW_PRIMITIVE(nr) -#define RELEASE_ELT_VERTS() -#define EMIT_INDEXED_VERTS( ctx, start, count ) -#endif - -#ifndef EMIT_TWO_ELTS -#define EMIT_TWO_ELTS( offset, elt0, elt1 ) \ -do { \ - EMIT_ELT( offset, elt0 ); \ - EMIT_ELT( offset+1, elt1 ); \ -} while (0) -#endif - -#ifndef FINISH -#define FINISH -#endif - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - - - -static GLboolean TAG(emit_elt_verts)( GLcontext *ctx, - GLuint start, GLuint count ) -{ - if (HAVE_ELTS) { - LOCAL_VARS; - GLuint nr = count - start; - - if ( nr >= GET_SUBSEQUENT_VB_MAX_VERTS() ) /* assumes same packing for - * indexed and regualar verts - */ - return GL_FALSE; - - NEW_PRIMITIVE(); /* finish last prim */ - EMIT_INDEXED_VERTS( ctx, start, count ); - return GL_TRUE; - } else { - return GL_FALSE; - } -} - -#if (HAVE_ELTS) -static void TAG(emit_elts)( GLcontext *ctx, GLuint *elts, GLuint nr ) -{ - GLint i; - LOCAL_VARS; - ELTS_VARS; - - ALLOC_ELTS( nr ); - - for ( i = 0 ; i < nr ; i+=2, elts += 2 ) { - EMIT_TWO_ELTS( 0, elts[0], elts[1] ); - INCR_ELTS( 2 ); - } -} -#endif - - -/*********************************************************************** - * Render non-indexed primitives. - ***********************************************************************/ - - - -static void TAG(render_points_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_POINTS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - GLuint j, nr; - - INIT( GL_POINTS ); - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - FINISH; - - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - -static void TAG(render_lines_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_LINES) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - GLuint j, nr; - - INIT( GL_LINES ); - - /* Emit whole number of lines in total and in each buffer: - */ - count -= (count-start) & 1; - currentsz -= currentsz & 1; - dmasz -= dmasz & 1; - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - FINISH; - - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_line_strip_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_LINE_STRIPS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - GLuint j, nr; - - NEW_PRIMITIVE(); /* always a new primitive */ - INIT( GL_LINE_STRIP ); - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - FINISH; - - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_line_loop_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_LINE_STRIPS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - GLuint j, nr; - - NEW_PRIMITIVE(); - INIT( GL_LINE_STRIP ); - - if (flags & PRIM_BEGIN) - j = start; - else - j = start + 1; - - /* Ensure last vertex won't wrap buffers: - */ - currentsz--; - dmasz--; - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - if (j + 1 < count) { - for ( ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - if (start < count - 1 && (flags & PRIM_END)) - EMIT_VERTS( ctx, start, 1 ); - } - else if (start + 1 < count && (flags & PRIM_END)) { - EMIT_VERTS( ctx, start+1, 1 ); - EMIT_VERTS( ctx, start, 1 ); - } - - FINISH; - - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_triangles_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS()/3) * 3; - int currentsz = (GET_CURRENT_VB_MAX_VERTS()/3) * 3; - GLuint j, nr; - - INIT(GL_TRIANGLES); - - /* Emit whole number of tris in total. dmasz is already a multiple - * of 3. - */ - count -= (count-start)%3; - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - FINISH; -} - - - -static void TAG(render_tri_strip_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_TRI_STRIPS) { - LOCAL_VARS; - GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz; - - INIT(GL_TRIANGLE_STRIP); - NEW_PRIMITIVE(); - - currentsz = GET_CURRENT_VB_MAX_VERTS(); - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - /* From here on emit even numbers of tris when wrapping over buffers: - */ - dmasz -= (dmasz & 1); - currentsz -= (currentsz & 1); - - for (j = start ; j + 2 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - FINISH; - - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - -static void TAG(render_tri_fan_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_TRI_FANS) { - LOCAL_VARS; - GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - - NEW_PRIMITIVE(); - INIT(GL_TRIANGLE_FAN); - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - for (j = start + 1 ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j + 1 ); - EMIT_VERTS( ctx, start, 1 ); - EMIT_VERTS( ctx, j, nr - 1 ); - currentsz = dmasz; - } - - FINISH; - - } - else { - /* Could write code to emit these as indexed vertices (for the - * g400, for instance). - */ - VERT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_poly_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_POLYGONS) { - LOCAL_VARS; - GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - - NEW_PRIMITIVE(); - INIT(GL_POLYGON); - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) { - nr = MIN2( currentsz, count - j + 1 ); - EMIT_VERTS( ctx, start, 1 ); - EMIT_VERTS( ctx, j, nr - 1 ); - currentsz = dmasz; - } - - FINISH; - - } - else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) { - TAG(render_tri_fan_verts)( ctx, start, count, flags ); - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - -static void TAG(render_quad_strip_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - GLuint j, nr; - - if (HAVE_QUAD_STRIPS) { - LOCAL_VARS; - GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz; - - INIT(GL_QUAD_STRIP); - NEW_PRIMITIVE(); - - currentsz = GET_CURRENT_VB_MAX_VERTS(); - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - dmasz -= (dmasz & 2); - currentsz -= (currentsz & 2); - - for (j = start ; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - FINISH; - - } else if (HAVE_TRI_STRIPS && (ctx->_TriangleCaps & DD_FLATSHADE)) { - if (TAG(emit_elt_verts)( ctx, start, count )) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint j, nr; - - /* Simulate flat-shaded quadstrips using indexed vertices: - */ - NEW_PRIMITIVE(); - ELT_INIT( GL_TRIANGLES ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 1; - count -= (count-start) & 1; - currentsz -= currentsz & 1; - - if (currentsz < 12) - currentsz = dmasz; - - currentsz = currentsz/6*2; - dmasz = dmasz/6*2; - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - if (nr >= 4) { - GLint quads = (nr/2)-1; - GLint i; - ELTS_VARS; - - NEW_PRIMITIVE(); - ALLOC_ELTS_NEW_PRIMITIVE( quads*6 ); - - for ( i = j-start ; i < j-start+quads*2 ; i+=2 ) { - EMIT_TWO_ELTS( 0, (i+0), (i+1) ); - EMIT_TWO_ELTS( 2, (i+2), (i+1) ); - EMIT_TWO_ELTS( 4, (i+3), (i+2) ); - INCR_ELTS( 6 ); - } - - NEW_PRIMITIVE(); - } - currentsz = dmasz; - } - - RELEASE_ELT_VERTS(); - } - else { - /* Vertices won't fit in a single buffer or elts not available, - * VERT_FALLBACK. - */ - VERT_FALLBACK( ctx, start, count, flags ); - } - } - else if (HAVE_TRI_STRIPS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS(); - int currentsz = GET_CURRENT_VB_MAX_VERTS(); - - /* Emit smooth-shaded quadstrips as tristrips: - */ - NEW_PRIMITIVE(); - INIT( GL_TRIANGLE_STRIP ); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 1; - currentsz -= currentsz & 1; - count -= (count-start) & 1; - - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - - FINISH; - - } else { - VERT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_quads_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_QUADS) { - LOCAL_VARS; - int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS()/4) * 4; - int currentsz = (GET_CURRENT_VB_MAX_VERTS()/4) * 4; - GLuint j, nr; - - INIT(GL_QUADS); - - /* Emit whole number of quads in total. dmasz is already a multiple - * of 4. - */ - count -= (count-start)%4; - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr) { - nr = MIN2( currentsz, count - j ); - EMIT_VERTS( ctx, j, nr ); - currentsz = dmasz; - } - FINISH; - } else if (TAG(emit_elt_verts)( ctx, start, count )) { - /* Hardware doesn't have a quad primitive type -- try to - * simulate it using indexed vertices and the triangle - * primitive: - */ - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint j, nr; - - NEW_PRIMITIVE(); - ELT_INIT( GL_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 3; - count -= (count-start) & 3; - currentsz -= currentsz & 3; - - /* Adjust for rendering as triangles: - */ - currentsz = currentsz/6*4; - dmasz = dmasz/6*4; - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr ) { - nr = MIN2( currentsz, count - j ); - if (nr >= 4) { - GLint quads = nr/4; - GLint i; - ELTS_VARS; - - NEW_PRIMITIVE(); - ALLOC_ELTS_NEW_PRIMITIVE( quads*6 ); - - for ( i = j-start ; i < j-start+quads*4 ; i+=4 ) { - EMIT_TWO_ELTS( 0, (i+0), (i+1) ); - EMIT_TWO_ELTS( 2, (i+3), (i+1) ); - EMIT_TWO_ELTS( 4, (i+2), (i+3) ); - INCR_ELTS( 6 ); - } - - NEW_PRIMITIVE(); - } - currentsz = dmasz; - } - - RELEASE_ELT_VERTS(); - } - else { - /* Vertices won't fit in a single buffer, fallback. - */ - VERT_FALLBACK( ctx, start, count, flags ); - } -} - -static void TAG(render_noop)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ -} - - - - -static render_func TAG(render_tab_verts)[GL_POLYGON+2] = -{ - TAG(render_points_verts), - TAG(render_lines_verts), - TAG(render_line_loop_verts), - TAG(render_line_strip_verts), - TAG(render_triangles_verts), - TAG(render_tri_strip_verts), - TAG(render_tri_fan_verts), - TAG(render_quads_verts), - TAG(render_quad_strip_verts), - TAG(render_poly_verts), - TAG(render_noop), -}; - - -/**************************************************************************** - * Render elts using hardware indexed verts * - ****************************************************************************/ - -#if (HAVE_ELTS) -static void TAG(render_points_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_POINTS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - GLuint j, nr; - - ELT_INIT( GL_POINTS ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } else { - ELT_FALLBACK( ctx, start, count, flags ); - } -} - - - -static void TAG(render_lines_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_LINES) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - GLuint j, nr; - - ELT_INIT( GL_LINES ); - - /* Emit whole number of lines in total and in each buffer: - */ - count -= (count-start) & 1; - currentsz -= currentsz & 1; - dmasz -= dmasz & 1; - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } else { - ELT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_line_strip_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_LINE_STRIPS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - GLuint j, nr; - - NEW_PRIMITIVE(); /* always a new primitive */ - ELT_INIT( GL_LINE_STRIP ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } else { - /* TODO: Try to emit as indexed lines. - */ - ELT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_line_loop_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_LINE_STRIPS) { - LOCAL_VARS; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - GLuint j, nr; - - NEW_PRIMITIVE(); - ELT_INIT( GL_LINE_STRIP ); - - if (flags & PRIM_BEGIN) - j = start; - else - j = start + 1; - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - /* Ensure last vertex doesn't wrap: - */ - currentsz--; - dmasz--; - - for ( ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j ); -/* NEW_PRIMITIVE(); */ - TAG(emit_elts)( ctx, elts+j, nr ); - currentsz = dmasz; - } - - if (flags & PRIM_END) - TAG(emit_elts)( ctx, elts+start, 1 ); - - NEW_PRIMITIVE(); - } else { - /* TODO: Try to emit as indexed lines */ - ELT_FALLBACK( ctx, start, count, flags ); - } -} - - -/* For verts, we still eliminate the copy from main memory to dma - * buffers. For elts, this is probably no better (worse?) than the - * standard path. - */ -static void TAG(render_triangles_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/3*3; - int currentsz; - GLuint j, nr; - - NEW_PRIMITIVE(); - ELT_INIT( GL_TRIANGLES ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - - /* Emit whole number of tris in total. dmasz is already a multiple - * of 3. - */ - count -= (count-start)%3; - currentsz -= currentsz%3; - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j < count; j += nr) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } -} - - - -static void TAG(render_tri_strip_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_TRI_STRIPS) { - LOCAL_VARS; - GLuint j, nr; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - - NEW_PRIMITIVE(); - ELT_INIT( GL_TRIANGLE_STRIP ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - /* Keep the same winding over multiple buffers: - */ - dmasz -= (dmasz & 1); - currentsz -= (currentsz & 1); - - for (j = start ; j + 2 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } else { - /* TODO: try to emit as indexed triangles */ - ELT_FALLBACK( ctx, start, count, flags ); - } -} - -static void TAG(render_tri_fan_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_TRI_FANS) { - LOCAL_VARS; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - - NEW_PRIMITIVE(); - ELT_INIT( GL_TRIANGLE_FAN ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - for (j = start + 1 ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( currentsz, count - j + 1 ); - TAG(emit_elts)( ctx, elts+start, 1 ); - TAG(emit_elts)( ctx, elts+j, nr - 1 ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } else { - /* TODO: try to emit as indexed triangles */ - ELT_FALLBACK( ctx, start, count, flags ); - } -} - - -static void TAG(render_poly_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_POLYGONS && 0) { - } else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) { - LOCAL_VARS; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - GLuint j, nr; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - - NEW_PRIMITIVE(); - ELT_INIT( GL_TRIANGLE_FAN ); - - currentsz = GET_CURRENT_VB_MAX_ELTS(); - if (currentsz < 8) { - NEW_BUFFER(); - currentsz = dmasz; - } - - for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) { - nr = MIN2( currentsz, count - j + 1 ); - TAG(emit_elts)( ctx, elts+start, 1 ); - TAG(emit_elts)( ctx, elts+j, nr - 1 ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } else { - ELT_FALLBACK( ctx, start, count, flags ); - } -} - -static void TAG(render_quad_strip_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_QUAD_STRIPS && 0) { - } - else if (HAVE_TRI_STRIPS) { - LOCAL_VARS; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint j, nr; - - NEW_PRIMITIVE(); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 1; - count -= (count-start) & 1; - currentsz -= currentsz & 1; - - if (currentsz < 12) - currentsz = dmasz; - - if (ctx->_TriangleCaps & DD_FLATSHADE) { - ELT_INIT( GL_TRIANGLES ); - - currentsz = currentsz/6*2; - dmasz = dmasz/6*2; - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - - if (nr >= 4) - { - GLint i; - GLint quads = (nr/2)-1; - ELTS_VARS; - - - NEW_PRIMITIVE(); - ALLOC_ELTS_NEW_PRIMITIVE( quads*6 ); - - for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) { - EMIT_TWO_ELTS( 0, elts[0], elts[1] ); - EMIT_TWO_ELTS( 2, elts[2], elts[1] ); - EMIT_TWO_ELTS( 4, elts[3], elts[2] ); - INCR_ELTS( 6 ); - } - - NEW_PRIMITIVE(); - } - - currentsz = dmasz; - } - } - else { - ELT_INIT( GL_TRIANGLE_STRIP ); - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - TAG(emit_elts)( ctx, elts+j, nr ); - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } - } -} - - -static void TAG(render_quads_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (HAVE_QUADS && 0) { - } else { - LOCAL_VARS; - GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts; - int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS(); - int currentsz; - GLuint j, nr; - - ELT_INIT( GL_TRIANGLES ); - currentsz = GET_CURRENT_VB_MAX_ELTS(); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 3; - count -= (count-start) & 3; - currentsz -= currentsz & 3; - - /* Adjust for rendering as triangles: - */ - currentsz = currentsz/6*4; - dmasz = dmasz/6*4; - - if (currentsz < 8) - currentsz = dmasz; - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( currentsz, count - j ); - - if (nr >= 4) - { - GLint quads = nr/4; - GLint i; - ELTS_VARS; - NEW_PRIMITIVE(); - ALLOC_ELTS_NEW_PRIMITIVE( quads * 6 ); - - for ( i = j-start ; i < j-start+quads ; i++, elts += 4 ) { - EMIT_TWO_ELTS( 0, elts[0], elts[1] ); - EMIT_TWO_ELTS( 2, elts[3], elts[1] ); - EMIT_TWO_ELTS( 4, elts[2], elts[3] ); - INCR_ELTS( 6 ); - } - } - - NEW_PRIMITIVE(); - currentsz = dmasz; - } - } -} - - - -static render_func TAG(render_tab_elts)[GL_POLYGON+2] = -{ - TAG(render_points_elts), - TAG(render_lines_elts), - TAG(render_line_loop_elts), - TAG(render_line_strip_elts), - TAG(render_triangles_elts), - TAG(render_tri_strip_elts), - TAG(render_tri_fan_elts), - TAG(render_quads_elts), - TAG(render_quad_strip_elts), - TAG(render_poly_elts), - TAG(render_noop), -}; -#endif diff --git a/src/mesa/drivers/common/t_dd_dmatmp2.h b/src/mesa/drivers/common/t_dd_dmatmp2.h deleted file mode 100644 index dd0286b453..0000000000 --- a/src/mesa/drivers/common/t_dd_dmatmp2.h +++ /dev/null @@ -1,935 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 4.0.3 - * - * Copyright (C) 1999-2002 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -/* 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. - * - */ - -#if !HAVE_TRIANGLES || !HAVE_POINTS || !HAVE_LINES -#error "must have points, lines & triangles to use render template" -#endif - -#if !HAVE_TRI_STRIPS || !HAVE_TRI_FANS -#error "must have tri strip and fans to use render template" -#endif - -#if !HAVE_LINE_STRIPS -#error "must have line strips to use render template" -#endif - -#if !HAVE_POLYGONS -#error "must have polygons to use render template" -#endif - -#if !HAVE_ELTS -#error "must have elts to use render template" -#endif - - -#ifndef EMIT_TWO_ELTS -#define EMIT_TWO_ELTS( dest, offset, elt0, elt1 ) \ -do { \ - (dest)[offset] = (elt0); \ - (dest)[offset+1] = (elt1); \ -} while (0) -#endif - - -/**********************************************************************/ -/* Render whole begin/end objects */ -/**********************************************************************/ - - -static ELT_TYPE *TAG(emit_elts)( GLcontext *ctx, - ELT_TYPE *dest, - GLuint *elts, GLuint nr ) -{ - GLint i; - LOCAL_VARS; - - for ( i = 0 ; i+1 < nr ; i+=2, elts += 2 ) { - EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] ); - dest += 2; - } - if (i < nr) { - EMIT_ELT( dest, 0, elts[0] ); - dest += 1; - } - - return dest; -} - -static ELT_TYPE *TAG(emit_consecutive_elts)( GLcontext *ctx, - ELT_TYPE *dest, - GLuint start, GLuint nr ) -{ - GLint i; - LOCAL_VARS; - - for ( i = 0 ; i+1 < nr ; i+=2, start += 2 ) { - EMIT_TWO_ELTS( dest, 0, start, start+1 ); - dest += 2; - } - if (i < nr) { - EMIT_ELT( dest, 0, start ); - dest += 1; - } - - return dest; -} - -/*********************************************************************** - * Render non-indexed primitives. - ***********************************************************************/ - - - -static void TAG(render_points_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (start < count) { - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - EMIT_PRIM( ctx, GL_POINTS, HW_POINTS, start, count ); - } -} - -static void TAG(render_lines_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - count -= (count-start) & 1; - - if (start+1 >= count) - return; - - if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) { - RESET_STIPPLE(); - AUTO_STIPPLE( GL_TRUE ); - } - - EMIT_PRIM( ctx, GL_LINES, HW_LINES, start, count ); - - if ((flags & PRIM_END) && ctx->Line.StippleFlag) - AUTO_STIPPLE( GL_FALSE ); -} - - -static void TAG(render_line_strip_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - if (start+1 >= count) - return; - - if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) - RESET_STIPPLE(); - - - if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES )) - { - int dmasz = GET_MAX_HW_ELTS(); - GLuint j, nr; - - ELT_INIT( GL_LINES, HW_LINES ); - - /* Emit whole number of lines in each full buffer. - */ - dmasz = dmasz/2; - - - for (j = start; j + 1 < count; j += nr - 1 ) { - ELT_TYPE *dest; - GLint i; - - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( (nr-1)*2 ); - - for ( i = j ; i+1 < j+nr ; i+=1 ) { - EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) ); - dest += 2; - } - - CLOSE_ELTS(); - } - } - else - EMIT_PRIM( ctx, GL_LINE_STRIP, HW_LINE_STRIP, start, count ); -} - - -static void TAG(render_line_loop_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - GLuint j, nr; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - if (flags & PRIM_BEGIN) { - j = start; - if (ctx->Line.StippleFlag) - RESET_STIPPLE( ); - } - else - j = start + 1; - - if (flags & PRIM_END) { - - if (start+1 >= count) - return; - - if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES )) { - int dmasz = GET_MAX_HW_ELTS(); - - ELT_INIT( GL_LINES, HW_LINES ); - - /* Emit whole number of lines in each full buffer. - */ - dmasz = dmasz/2; - - /* Ensure last vertex doesn't wrap: - */ - dmasz--; - - for (; j + 1 < count; ) { - GLint i; - ELT_TYPE *dest; - - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr*2 ); /* allocs room for 1 more line */ - - for ( i = 0 ; i < nr - 1 ; i+=1 ) { - EMIT_TWO_ELTS( dest, 0, (j+i), (j+i+1) ); - dest += 2; - } - - j += nr - 1; - - /* Emit 1 more line into space alloced above */ - if (j + 1 >= count) { - EMIT_TWO_ELTS( dest, 0, (j), (start) ); - dest += 2; - } - - CLOSE_ELTS(); - } - } - else - { - int dmasz = GET_MAX_HW_ELTS() - 1; - - ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP ); - - for ( ; j + 1 < count; ) { - nr = MIN2( dmasz, count - j ); - if (j + nr < count) { - ELT_TYPE *dest = ALLOC_ELTS( nr ); - dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr ); - j += nr - 1; - CLOSE_ELTS(); - } - else if (nr) { - ELT_TYPE *dest = ALLOC_ELTS( nr + 1 ); - dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr ); - dest = TAG(emit_consecutive_elts)( ctx, dest, start, 1 ); - j += nr; - CLOSE_ELTS(); - } - } - } - } else { - TAG(render_line_strip_verts)( ctx, j, count, flags ); - } -} - - -static void TAG(render_triangles_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - count -= (count-start)%3; - - if (start+2 >= count) { - return; - } - - /* need a PREFER_DISCRETE_ELT_PRIM here too.. - */ - EMIT_PRIM( ctx, GL_TRIANGLES, HW_TRIANGLES, start, count ); -} - - - -static void TAG(render_tri_strip_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - if (start + 2 >= count) - return; - - if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES )) - { - int dmasz = GET_MAX_HW_ELTS(); - int parity = 0; - GLuint j, nr; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - /* Emit even number of tris in each full buffer. - */ - dmasz = dmasz/3; - dmasz -= dmasz & 1; - - for (j = start; j + 2 < count; j += nr - 2 ) { - ELT_TYPE *dest; - GLint i; - - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( (nr-2)*3 ); - - for ( i = j ; i+2 < j+nr ; i++, parity^=1 ) { - EMIT_ELT( dest, 0, (i+0+parity) ); - EMIT_ELT( dest, 1, (i+1-parity) ); - EMIT_ELT( dest, 2, (i+2) ); - dest += 3; - } - - CLOSE_ELTS(); - } - } - else if (HAVE_TRI_STRIP_1) - EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_1, start, count ); - else { - /* Emit the first triangle with elts, then the rest as a regular strip. - * TODO: Make this unlikely in t_imm_api.c - */ - ELT_TYPE *dest; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - dest = ALLOC_ELTS( 3 ); - EMIT_ELT( dest, 0, (start+1) ); - EMIT_ELT( dest, 1, (start+0) ); - EMIT_ELT( dest, 2, (start+2) ); - dest += 3; - CLOSE_ELTS(); - - start++; - if (start + 2 >= count) - return; - - EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, - count ); - } -} - -static void TAG(render_tri_fan_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - if (start+2 >= count) - return; - - if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES )) - { - int dmasz = GET_MAX_HW_ELTS(); - GLuint j, nr; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - dmasz = dmasz/3; - - for (j = start + 1; j + 1 < count; j += nr - 1 ) { - ELT_TYPE *dest; - GLint i; - - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( (nr-1)*3 ); - - for ( i = j ; i+1 < j+nr ; i++ ) { - EMIT_ELT( dest, 0, (start) ); - EMIT_ELT( dest, 1, (i) ); - EMIT_ELT( dest, 2, (i+1) ); - dest += 3; - } - - CLOSE_ELTS(); - } - } - else { - EMIT_PRIM( ctx, GL_TRIANGLE_FAN, HW_TRIANGLE_FAN, start, count ); - } -} - - -static void TAG(render_poly_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - if (start+2 >= count) - return; - - EMIT_PRIM( ctx, GL_POLYGON, HW_POLYGON, start, count ); -} - -static void TAG(render_quad_strip_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - count -= (count-start) & 1; - - if (start+3 >= count) - return; - - if (HAVE_QUAD_STRIPS) { - EMIT_PRIM( ctx, GL_QUAD_STRIP, HW_QUAD_STRIP, start, count ); - } - else if (ctx->_TriangleCaps & DD_FLATSHADE) { - LOCAL_VARS; - int dmasz = GET_MAX_HW_ELTS(); - GLuint j, nr; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz = (dmasz/6)*2; - - for (j = start; j + 3 < count; j += nr - 2 ) { - ELT_TYPE *dest; - GLint quads, i; - - nr = MIN2( dmasz, count - j ); - quads = (nr/2)-1; - dest = ALLOC_ELTS( quads*6 ); - - for ( i = j ; i < j+quads*2 ; i+=2 ) { - EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) ); - EMIT_TWO_ELTS( dest, 2, (i+2), (i+1) ); - EMIT_TWO_ELTS( dest, 4, (i+3), (i+2) ); - dest += 6; - } - - CLOSE_ELTS(); - } - } - else { - EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count ); - } -} - - -static void TAG(render_quads_verts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - count -= (count-start)%4; - - if (start+3 >= count) - return; - - if (HAVE_QUADS) { - EMIT_PRIM( ctx, HW_QUADS, GL_QUADS, start, count ); - } - else { - /* Hardware doesn't have a quad primitive type -- simulate it - * using indexed vertices and the triangle primitive: - */ - LOCAL_VARS; - int dmasz = GET_MAX_HW_ELTS(); - GLuint j, nr; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - /* Adjust for rendering as triangles: - */ - dmasz = (dmasz/6)*4; - - for (j = start; j < count; j += nr ) { - ELT_TYPE *dest; - GLint quads, i; - - nr = MIN2( dmasz, count - j ); - quads = nr/4; - dest = ALLOC_ELTS( quads*6 ); - - for ( i = j ; i < j+quads*4 ; i+=4 ) { - EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) ); - EMIT_TWO_ELTS( dest, 2, (i+3), (i+1) ); - EMIT_TWO_ELTS( dest, 4, (i+2), (i+3) ); - dest += 6; - } - - CLOSE_ELTS(); - } - } -} - -static void TAG(render_noop)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ -} - - - - -static render_func TAG(render_tab_verts)[GL_POLYGON+2] = -{ - TAG(render_points_verts), - TAG(render_lines_verts), - TAG(render_line_loop_verts), - TAG(render_line_strip_verts), - TAG(render_triangles_verts), - TAG(render_tri_strip_verts), - TAG(render_tri_fan_verts), - TAG(render_quads_verts), - TAG(render_quad_strip_verts), - TAG(render_poly_verts), - TAG(render_noop), -}; - - -/**************************************************************************** - * Render elts using hardware indexed verts * - ****************************************************************************/ - -static void TAG(render_points_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - int dmasz = GET_MAX_HW_ELTS(); - GLuint *elts = GET_MESA_ELTS(); - GLuint j, nr; - ELT_TYPE *dest; - - ELT_INIT( GL_POINTS, HW_POINTS ); - - for (j = start; j < count; j += nr ) { - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } -} - - - -static void TAG(render_lines_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - int dmasz = GET_MAX_HW_ELTS(); - GLuint *elts = GET_MESA_ELTS(); - GLuint j, nr; - ELT_TYPE *dest; - - if (start+1 >= count) - return; - - if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) { - RESET_STIPPLE(); - AUTO_STIPPLE( GL_TRUE ); - } - - ELT_INIT( GL_LINES, HW_LINES ); - - /* Emit whole number of lines in total and in each buffer: - */ - count -= (count-start) & 1; - dmasz -= dmasz & 1; - - for (j = start; j < count; j += nr ) { - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } - - if ((flags & PRIM_END) && ctx->Line.StippleFlag) - AUTO_STIPPLE( GL_FALSE ); -} - - -static void TAG(render_line_strip_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - int dmasz = GET_MAX_HW_ELTS(); - GLuint *elts = GET_MESA_ELTS(); - GLuint j, nr; - ELT_TYPE *dest; - - if (start+1 >= count) - return; - - ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP ); - - if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) - RESET_STIPPLE(); - - for (j = start; j + 1 < count; j += nr - 1 ) { - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } -} - - -static void TAG(render_line_loop_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - int dmasz = GET_MAX_HW_ELTS(); - GLuint *elts = GET_MESA_ELTS(); - GLuint j, nr; - ELT_TYPE *dest; - - if (0) fprintf(stderr, "%s\n", __FUNCTION__); - - if (flags & PRIM_BEGIN) - j = start; - else - j = start + 1; - - - if (flags & PRIM_END) { - if (start+1 >= count) - return; - } - else { - if (j+1 >= count) - return; - } - - ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP ); - - if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) - RESET_STIPPLE(); - - - /* Ensure last vertex doesn't wrap: - */ - dmasz--; - - for ( ; j + 1 < count; ) { - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr+1 ); /* Reserve possible space for last elt */ - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - j += nr - 1; - if (j + 1 >= count && (flags & PRIM_END)) { - dest = TAG(emit_elts)( ctx, dest, elts+start, 1 ); - } - CLOSE_ELTS(); - } -} - - -static void TAG(render_triangles_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - GLuint *elts = GET_MESA_ELTS(); - int dmasz = GET_MAX_HW_ELTS()/3*3; - GLuint j, nr; - ELT_TYPE *dest; - - if (start+2 >= count) - return; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - - /* Emit whole number of tris in total. dmasz is already a multiple - * of 3. - */ - count -= (count-start)%3; - - for (j = start; j < count; j += nr) { - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } -} - - - -static void TAG(render_tri_strip_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - GLuint j, nr; - GLuint *elts = GET_MESA_ELTS(); - int dmasz = GET_MAX_HW_ELTS(); - ELT_TYPE *dest; - - if (start+2 >= count) - return; - - ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 ); - - /* Keep the same winding over multiple buffers: - */ - dmasz -= (dmasz & 1); - - for (j = start ; j + 2 < count; j += nr - 2 ) { - nr = MIN2( dmasz, count - j ); - - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } -} - -static void TAG(render_tri_fan_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - GLuint *elts = GET_MESA_ELTS(); - GLuint j, nr; - int dmasz = GET_MAX_HW_ELTS(); - ELT_TYPE *dest; - - if (start+2 >= count) - return; - - ELT_INIT( GL_TRIANGLE_FAN, HW_TRIANGLE_FAN ); - - for (j = start + 1 ; j + 1 < count; j += nr - 1 ) { - nr = MIN2( dmasz, count - j + 1 ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+start, 1 ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 ); - CLOSE_ELTS(); - } -} - - -static void TAG(render_poly_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - GLuint *elts = GET_MESA_ELTS(); - GLuint j, nr; - int dmasz = GET_MAX_HW_ELTS(); - ELT_TYPE *dest; - - if (start+2 >= count) - return; - - ELT_INIT( GL_POLYGON, HW_POLYGON ); - - for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) { - nr = MIN2( dmasz, count - j + 1 ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+start, 1 ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 ); - CLOSE_ELTS(); - } -} - -static void TAG(render_quad_strip_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (start+3 >= count) - return; - - if (HAVE_QUAD_STRIPS && 0) { - } - else { - LOCAL_VARS; - GLuint *elts = GET_MESA_ELTS(); - int dmasz = GET_MAX_HW_ELTS(); - GLuint j, nr; - ELT_TYPE *dest; - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 1; - count -= (count-start) & 1; - - if (ctx->_TriangleCaps & DD_FLATSHADE) { - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - dmasz = dmasz/6*2; - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( dmasz, count - j ); - - if (nr >= 4) - { - GLint quads = (nr/2)-1; - ELT_TYPE *dest = ALLOC_ELTS( quads*6 ); - GLint i; - - for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) { - EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] ); - EMIT_TWO_ELTS( dest, 2, elts[2], elts[1] ); - EMIT_TWO_ELTS( dest, 4, elts[3], elts[2] ); - dest += 6; - } - - CLOSE_ELTS(); - } - } - } - else { - ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 ); - - for (j = start; j + 3 < count; j += nr - 2 ) { - nr = MIN2( dmasz, count - j ); - dest = ALLOC_ELTS( nr ); - dest = TAG(emit_elts)( ctx, dest, elts+j, nr ); - CLOSE_ELTS(); - } - } - } -} - - -static void TAG(render_quads_elts)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - if (start+3 >= count) - return; - - if (HAVE_QUADS && 0) { - } else { - LOCAL_VARS; - GLuint *elts = GET_MESA_ELTS(); - int dmasz = GET_MAX_HW_ELTS(); - GLuint j, nr; - - ELT_INIT( GL_TRIANGLES, HW_TRIANGLES ); - - /* Emit whole number of quads in total, and in each buffer. - */ - dmasz -= dmasz & 3; - count -= (count-start) & 3; - - /* Adjust for rendering as triangles: - */ - dmasz = dmasz/6*4; - - for (j = start; j + 3 < count; j += nr ) { - nr = MIN2( dmasz, count - j ); - - { - GLint quads = nr/4; - ELT_TYPE *dest = ALLOC_ELTS( quads * 6 ); - GLint i; - - for ( i = j-start ; i < j-start+quads ; i++, elts += 4 ) { - EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] ); - EMIT_TWO_ELTS( dest, 2, elts[3], elts[1] ); - EMIT_TWO_ELTS( dest, 4, elts[2], elts[3] ); - dest += 6; - } - - CLOSE_ELTS(); - } - } - } -} - - - -static render_func TAG(render_tab_elts)[GL_POLYGON+2] = -{ - TAG(render_points_elts), - TAG(render_lines_elts), - TAG(render_line_loop_elts), - TAG(render_line_strip_elts), - TAG(render_triangles_elts), - TAG(render_tri_strip_elts), - TAG(render_tri_fan_elts), - TAG(render_quads_elts), - TAG(render_quad_strip_elts), - TAG(render_poly_elts), - TAG(render_noop), -}; diff --git a/src/mesa/drivers/common/t_dd_rendertmp.h b/src/mesa/drivers/common/t_dd_rendertmp.h deleted file mode 100644 index b9f030195d..0000000000 --- a/src/mesa/drivers/common/t_dd_rendertmp.h +++ /dev/null @@ -1,434 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -#ifndef POSTFIX -#define POSTFIX -#endif - -#ifndef INIT -#define INIT(x) -#endif - -#ifndef NEED_EDGEFLAG_SETUP -#define NEED_EDGEFLAG_SETUP 0 -#define EDGEFLAG_GET(a) 0 -#define EDGEFLAG_SET(a,b) (void)b -#endif - -#ifndef RESET_STIPPLE -#define RESET_STIPPLE -#endif - -#ifndef RESET_OCCLUSION -#define RESET_OCCLUSION -#endif - -#ifndef TEST_PRIM_END -#define TEST_PRIM_END(flags) (flags & PRIM_END) -#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN) -#define TEST_PRIM_PARITY(flags) (flags & PRIM_PARITY) -#endif - -#ifndef ELT -#define ELT(x) x -#endif - -#ifndef RENDER_TAB_QUALIFIER -#define RENDER_TAB_QUALIFIER static -#endif - -static void TAG(render_points)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - LOCAL_VARS; - (void) flags; - - RESET_OCCLUSION; - INIT(GL_POINTS); - RENDER_POINTS( start, count ); - POSTFIX; -} - -static void TAG(render_lines)( GLcontext *ctx, - GLuint start, - GLuint count, - GLuint flags ) -{ - GLuint j; - LOCAL_VARS; - (void) flags; - - RESET_OCCLUSION; - INIT(GL_LINES); - for (j=start+1; j - */ - - -/* Template for building functions to plug into the driver interface - * of t_vb_render.c: - * ctx->Driver.QuadFunc - * ctx->Driver.TriangleFunc - * ctx->Driver.LineFunc - * ctx->Driver.PointsFunc - * - * DO_TWOSIDE: Plug back-color values from the VB into backfacing triangles, - * and restore vertices afterwards. - * DO_OFFSET: Calculate offset for triangles and adjust vertices. Restore - * vertices after rendering. - * DO_FLAT: For hardware without native flatshading, copy provoking colors - * into the other vertices. Restore after rendering. - * DO_UNFILLED: Decompose triangles to lines and points where appropriate. - * - * HAVE_RGBA: Vertices have rgba values (otherwise index values). - * HAVE_SPEC: Vertices have secondary rgba values. - * - * VERT_X(v): Alias for vertex x value. - * VERT_Y(v): Alias for vertex y value. - * VERT_Z(v): Alias for vertex z value. - * DEPTH_SCALE: Scale for offset. - * - * VERTEX: Hardware vertex type. - * GET_VERTEX(n): Retreive vertex with index n. - * AREA_IS_CCW(a): Return true if triangle with signed area a is ccw. - * - * VERT_SET_RGBA: Assign vertex rgba from VB color. - * VERT_COPY_RGBA: Copy vertex rgba another vertex. - * VERT_SAVE_RGBA: Save vertex rgba to a local variable. - * VERT_RESTORE_RGBA: Restore vertex rgba from a local variable. - * --> Similar for IND and SPEC. - * - * LOCAL_VARS(n): (At least) define local vars for save/restore rgba. - * - */ - -#if HAVE_RGBA -#define VERT_SET_IND( v, c ) (void) c -#define VERT_COPY_IND( v0, v1 ) -#define VERT_SAVE_IND( idx ) -#define VERT_RESTORE_IND( idx ) -#if HAVE_BACK_COLORS -#define VERT_SET_RGBA( v, c ) -#endif -#else -#define VERT_SET_RGBA( v, c ) (void) c -#define VERT_COPY_RGBA( v0, v1 ) -#define VERT_SAVE_RGBA( idx ) -#define VERT_RESTORE_RGBA( idx ) -#if HAVE_BACK_COLORS -#define VERT_SET_IND( v, c ) -#endif -#endif - -#if !HAVE_SPEC -#define VERT_SET_SPEC( v, c ) (void) c -#define VERT_COPY_SPEC( v0, v1 ) -#define VERT_SAVE_SPEC( idx ) -#define VERT_RESTORE_SPEC( idx ) -#if HAVE_BACK_COLORS -#define VERT_COPY_SPEC1( v ) -#endif -#else -#if HAVE_BACK_COLORS -#define VERT_SET_SPEC( v, c ) -#endif -#endif - -#if !HAVE_BACK_COLORS -#define VERT_COPY_SPEC1( v ) -#define VERT_COPY_IND1( v ) -#define VERT_COPY_RGBA1( v ) -#endif - -#ifndef INSANE_VERTICES -#define VERT_SET_Z(v,val) VERT_Z(v) = val -#define VERT_Z_ADD(v,val) VERT_Z(v) += val -#endif - -#if DO_TRI -static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; - VERTEX *v[3]; - GLfloat offset; - GLfloat z[3]; - GLenum mode = GL_FILL; - GLuint facing; - LOCAL_VARS(3); - -/* fprintf(stderr, "%s\n", __FUNCTION__); */ - - v[0] = (VERTEX *)GET_VERTEX(e0); - v[1] = (VERTEX *)GET_VERTEX(e1); - v[2] = (VERTEX *)GET_VERTEX(e2); - - if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED) - { - GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]); - GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]); - GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]); - GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]); - GLfloat cc = ex*fy - ey*fx; - - if (DO_TWOSIDE || DO_UNFILLED) - { - facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit; - - if (DO_UNFILLED) { - if (facing) { - mode = ctx->Polygon.BackMode; - if (ctx->Polygon.CullFlag && - ctx->Polygon.CullFaceMode != GL_FRONT) { - return; - } - } else { - mode = ctx->Polygon.FrontMode; - if (ctx->Polygon.CullFlag && - ctx->Polygon.CullFaceMode != GL_BACK) { - return; - } - } - } - - if (DO_TWOSIDE && facing == 1) - { - if (HAVE_RGBA) { - if (HAVE_BACK_COLORS) { - if (!DO_FLAT) { - VERT_SAVE_RGBA( 0 ); - VERT_SAVE_RGBA( 1 ); - VERT_COPY_RGBA1( v[0] ); - VERT_COPY_RGBA1( v[1] ); - } - VERT_SAVE_RGBA( 2 ); - VERT_COPY_RGBA1( v[2] ); - if (HAVE_SPEC) { - if (!DO_FLAT) { - VERT_SAVE_SPEC( 0 ); - VERT_SAVE_SPEC( 1 ); - VERT_COPY_SPEC1( v[0] ); - VERT_COPY_SPEC1( v[1] ); - } - VERT_SAVE_SPEC( 2 ); - VERT_COPY_SPEC1( v[2] ); - } - } - else { - GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; - ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLfloat)); - (void) vbcolor; - - if (!DO_FLAT) { - VERT_SAVE_RGBA( 0 ); - VERT_SAVE_RGBA( 1 ); - VERT_SET_RGBA( v[0], vbcolor[e0] ); - VERT_SET_RGBA( v[1], vbcolor[e1] ); - } - VERT_SAVE_RGBA( 2 ); - VERT_SET_RGBA( v[2], vbcolor[e2] ); - - if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { - GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; - - if (!DO_FLAT) { - VERT_SAVE_SPEC( 0 ); - VERT_SAVE_SPEC( 1 ); - VERT_SET_SPEC( v[0], vbspec[e0] ); - VERT_SET_SPEC( v[1], vbspec[e1] ); - } - VERT_SAVE_SPEC( 2 ); - VERT_SET_SPEC( v[2], vbspec[e2] ); - } - } - } - else { - GLfloat (*vbindex) = (GLfloat *)VB->IndexPtr[1]->data; - if (!DO_FLAT) { - VERT_SAVE_IND( 0 ); - VERT_SAVE_IND( 1 ); - VERT_SET_IND( v[0], vbindex[e0] ); - VERT_SET_IND( v[1], vbindex[e1] ); - } - VERT_SAVE_IND( 2 ); - VERT_SET_IND( v[2], vbindex[e2] ); - } - } - } - - - if (DO_OFFSET) - { - offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE; - z[0] = VERT_Z(v[0]); - z[1] = VERT_Z(v[1]); - z[2] = VERT_Z(v[2]); - if (cc * cc > 1e-16) { - GLfloat ic = 1.0 / cc; - GLfloat ez = z[0] - z[2]; - GLfloat fz = z[1] - z[2]; - GLfloat a = ey*fz - ez*fy; - GLfloat b = ez*fx - ex*fz; - GLfloat ac = a * ic; - GLfloat bc = b * ic; - if ( ac < 0.0f ) ac = -ac; - if ( bc < 0.0f ) bc = -bc; - offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor; - } - offset *= ctx->MRD; - } - } - - if (DO_FLAT) { - if (HAVE_RGBA) { - VERT_SAVE_RGBA( 0 ); - VERT_SAVE_RGBA( 1 ); - VERT_COPY_RGBA( v[0], v[2] ); - VERT_COPY_RGBA( v[1], v[2] ); - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - VERT_SAVE_SPEC( 0 ); - VERT_SAVE_SPEC( 1 ); - VERT_COPY_SPEC( v[0], v[2] ); - VERT_COPY_SPEC( v[1], v[2] ); - } - } - else { - VERT_SAVE_IND( 0 ); - VERT_SAVE_IND( 1 ); - VERT_COPY_IND( v[0], v[2] ); - VERT_COPY_IND( v[1], v[2] ); - } - } - - if (mode == GL_POINT) { - if (DO_OFFSET && ctx->Polygon.OffsetPoint) { - VERT_Z_ADD(v[0], offset); - VERT_Z_ADD(v[1], offset); - VERT_Z_ADD(v[2], offset); - } - UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 ); - } else if (mode == GL_LINE) { - if (DO_OFFSET && ctx->Polygon.OffsetLine) { - VERT_Z_ADD(v[0], offset); - VERT_Z_ADD(v[1], offset); - VERT_Z_ADD(v[2], offset); - } - UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 ); - } else { - if (DO_OFFSET && ctx->Polygon.OffsetFill) { - VERT_Z_ADD(v[0], offset); - VERT_Z_ADD(v[1], offset); - VERT_Z_ADD(v[2], offset); - } - if (DO_UNFILLED) - RASTERIZE( GL_TRIANGLES ); - TRI( v[0], v[1], v[2] ); - } - - if (DO_OFFSET) - { - VERT_SET_Z(v[0], z[0]); - VERT_SET_Z(v[1], z[1]); - VERT_SET_Z(v[2], z[2]); - } - - if (DO_TWOSIDE && facing == 1) - { - if (HAVE_RGBA) { - if (!DO_FLAT) { - VERT_RESTORE_RGBA( 0 ); - VERT_RESTORE_RGBA( 1 ); - } - VERT_RESTORE_RGBA( 2 ); - if (HAVE_SPEC) { - if (!DO_FLAT) { - VERT_RESTORE_SPEC( 0 ); - VERT_RESTORE_SPEC( 1 ); - } - VERT_RESTORE_SPEC( 2 ); - } - } - else { - if (!DO_FLAT) { - VERT_RESTORE_IND( 0 ); - VERT_RESTORE_IND( 1 ); - } - VERT_RESTORE_IND( 2 ); - } - } - - - if (DO_FLAT) { - if (HAVE_RGBA) { - VERT_RESTORE_RGBA( 0 ); - VERT_RESTORE_RGBA( 1 ); - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - VERT_RESTORE_SPEC( 0 ); - VERT_RESTORE_SPEC( 1 ); - } - } - else { - VERT_RESTORE_IND( 0 ); - VERT_RESTORE_IND( 1 ); - } - } -} -#endif - -#if DO_QUAD -#if DO_FULL_QUAD -static void TAG(quad)( GLcontext *ctx, - GLuint e0, GLuint e1, GLuint e2, GLuint e3 ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; - VERTEX *v[4]; - GLfloat offset; - GLfloat z[4]; - GLenum mode = GL_FILL; - GLuint facing; - LOCAL_VARS(4); - - v[0] = (VERTEX *)GET_VERTEX(e0); - v[1] = (VERTEX *)GET_VERTEX(e1); - v[2] = (VERTEX *)GET_VERTEX(e2); - v[3] = (VERTEX *)GET_VERTEX(e3); - - if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED) - { - GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]); - GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]); - GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]); - GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]); - GLfloat cc = ex*fy - ey*fx; - - if (DO_TWOSIDE || DO_UNFILLED) - { - facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit; - - if (DO_UNFILLED) { - if (facing) { - mode = ctx->Polygon.BackMode; - if (ctx->Polygon.CullFlag && - ctx->Polygon.CullFaceMode != GL_FRONT) { - return; - } - } else { - mode = ctx->Polygon.FrontMode; - if (ctx->Polygon.CullFlag && - ctx->Polygon.CullFaceMode != GL_BACK) { - return; - } - } - } - - if (DO_TWOSIDE && facing == 1) - { - if (HAVE_RGBA) { - GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data; - (void)vbcolor; - - if (HAVE_BACK_COLORS) { - if (!DO_FLAT) { - VERT_SAVE_RGBA( 0 ); - VERT_SAVE_RGBA( 1 ); - VERT_SAVE_RGBA( 2 ); - VERT_COPY_RGBA1( v[0] ); - VERT_COPY_RGBA1( v[1] ); - VERT_COPY_RGBA1( v[2] ); - } - VERT_SAVE_RGBA( 3 ); - VERT_COPY_RGBA1( v[3] ); - if (HAVE_SPEC) { - if (!DO_FLAT) { - VERT_SAVE_SPEC( 0 ); - VERT_SAVE_SPEC( 1 ); - VERT_SAVE_SPEC( 2 ); - VERT_COPY_SPEC1( v[0] ); - VERT_COPY_SPEC1( v[1] ); - VERT_COPY_SPEC1( v[2] ); - } - VERT_SAVE_SPEC( 3 ); - VERT_COPY_SPEC1( v[3] ); - } - } - else { - if (!DO_FLAT) { - VERT_SAVE_RGBA( 0 ); - VERT_SAVE_RGBA( 1 ); - VERT_SAVE_RGBA( 2 ); - VERT_SET_RGBA( v[0], vbcolor[e0] ); - VERT_SET_RGBA( v[1], vbcolor[e1] ); - VERT_SET_RGBA( v[2], vbcolor[e2] ); - } - VERT_SAVE_RGBA( 3 ); - VERT_SET_RGBA( v[3], vbcolor[e3] ); - - if (HAVE_SPEC && VB->SecondaryColorPtr[1]) { - GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data; - ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat)); - - if (!DO_FLAT) { - VERT_SAVE_SPEC( 0 ); - VERT_SAVE_SPEC( 1 ); - VERT_SAVE_SPEC( 2 ); - VERT_SET_SPEC( v[0], vbspec[e0] ); - VERT_SET_SPEC( v[1], vbspec[e1] ); - VERT_SET_SPEC( v[2], vbspec[e2] ); - } - VERT_SAVE_SPEC( 3 ); - VERT_SET_SPEC( v[3], vbspec[e3] ); - } - } - } - else { - GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data; - if (!DO_FLAT) { - VERT_SAVE_IND( 0 ); - VERT_SAVE_IND( 1 ); - VERT_SAVE_IND( 2 ); - VERT_SET_IND( v[0], vbindex[e0] ); - VERT_SET_IND( v[1], vbindex[e1] ); - VERT_SET_IND( v[2], vbindex[e2] ); - } - VERT_SAVE_IND( 3 ); - VERT_SET_IND( v[3], vbindex[e3] ); - } - } - } - - - if (DO_OFFSET) - { - offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE; - z[0] = VERT_Z(v[0]); - z[1] = VERT_Z(v[1]); - z[2] = VERT_Z(v[2]); - z[3] = VERT_Z(v[3]); - if (cc * cc > 1e-16) { - GLfloat ez = z[2] - z[0]; - GLfloat fz = z[3] - z[1]; - GLfloat a = ey*fz - ez*fy; - GLfloat b = ez*fx - ex*fz; - GLfloat ic = 1.0 / cc; - GLfloat ac = a * ic; - GLfloat bc = b * ic; - if ( ac < 0.0f ) ac = -ac; - if ( bc < 0.0f ) bc = -bc; - offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor; - } - offset *= ctx->MRD; - } - } - - if (DO_FLAT) { - if (HAVE_RGBA) { - VERT_SAVE_RGBA( 0 ); - VERT_SAVE_RGBA( 1 ); - VERT_SAVE_RGBA( 2 ); - VERT_COPY_RGBA( v[0], v[3] ); - VERT_COPY_RGBA( v[1], v[3] ); - VERT_COPY_RGBA( v[2], v[3] ); - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - VERT_SAVE_SPEC( 0 ); - VERT_SAVE_SPEC( 1 ); - VERT_SAVE_SPEC( 2 ); - VERT_COPY_SPEC( v[0], v[3] ); - VERT_COPY_SPEC( v[1], v[3] ); - VERT_COPY_SPEC( v[2], v[3] ); - } - } - else { - VERT_SAVE_IND( 0 ); - VERT_SAVE_IND( 1 ); - VERT_SAVE_IND( 2 ); - VERT_COPY_IND( v[0], v[3] ); - VERT_COPY_IND( v[1], v[3] ); - VERT_COPY_IND( v[2], v[3] ); - } - } - - if (mode == GL_POINT) { - if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) { - VERT_Z_ADD(v[0], offset); - VERT_Z_ADD(v[1], offset); - VERT_Z_ADD(v[2], offset); - VERT_Z_ADD(v[3], offset); - } - UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 ); - } else if (mode == GL_LINE) { - if (DO_OFFSET && ctx->Polygon.OffsetLine) { - VERT_Z_ADD(v[0], offset); - VERT_Z_ADD(v[1], offset); - VERT_Z_ADD(v[2], offset); - VERT_Z_ADD(v[3], offset); - } - UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 ); - } else { - if (DO_OFFSET && ctx->Polygon.OffsetFill) { - VERT_Z_ADD(v[0], offset); - VERT_Z_ADD(v[1], offset); - VERT_Z_ADD(v[2], offset); - VERT_Z_ADD(v[3], offset); - } - RASTERIZE( GL_TRIANGLES ); - QUAD( (v[0]), (v[1]), (v[2]), (v[3]) ); - } - - if (DO_OFFSET) - { - VERT_SET_Z(v[0], z[0]); - VERT_SET_Z(v[1], z[1]); - VERT_SET_Z(v[2], z[2]); - VERT_SET_Z(v[3], z[3]); - } - - if (DO_TWOSIDE && facing == 1) - { - if (HAVE_RGBA) { - if (!DO_FLAT) { - VERT_RESTORE_RGBA( 0 ); - VERT_RESTORE_RGBA( 1 ); - VERT_RESTORE_RGBA( 2 ); - } - VERT_RESTORE_RGBA( 3 ); - if (HAVE_SPEC) { - if (!DO_FLAT) { - VERT_RESTORE_SPEC( 0 ); - VERT_RESTORE_SPEC( 1 ); - VERT_RESTORE_SPEC( 2 ); - } - VERT_RESTORE_SPEC( 3 ); - } - } - else { - if (!DO_FLAT) { - VERT_RESTORE_IND( 0 ); - VERT_RESTORE_IND( 1 ); - VERT_RESTORE_IND( 2 ); - } - VERT_RESTORE_IND( 3 ); - } - } - - - if (DO_FLAT) { - if (HAVE_RGBA) { - VERT_RESTORE_RGBA( 0 ); - VERT_RESTORE_RGBA( 1 ); - VERT_RESTORE_RGBA( 2 ); - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - VERT_RESTORE_SPEC( 0 ); - VERT_RESTORE_SPEC( 1 ); - VERT_RESTORE_SPEC( 2 ); - } - } - else { - VERT_RESTORE_IND( 0 ); - VERT_RESTORE_IND( 1 ); - VERT_RESTORE_IND( 2 ); - } - } -} -#else -static void TAG(quad)( GLcontext *ctx, GLuint e0, - GLuint e1, GLuint e2, GLuint e3 ) -{ - if (DO_UNFILLED) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte ef1 = VB->EdgeFlag[e1]; - GLubyte ef3 = VB->EdgeFlag[e3]; - VB->EdgeFlag[e1] = 0; - TAG(triangle)( ctx, e0, e1, e3 ); - VB->EdgeFlag[e1] = ef1; - VB->EdgeFlag[e3] = 0; - TAG(triangle)( ctx, e1, e2, e3 ); - VB->EdgeFlag[e3] = ef3; - } else { - TAG(triangle)( ctx, e0, e1, e3 ); - TAG(triangle)( ctx, e1, e2, e3 ); - } -} -#endif -#endif - -#if DO_LINE -static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - VERTEX *v[2]; - LOCAL_VARS(2); - - v[0] = (VERTEX *)GET_VERTEX(e0); - v[1] = (VERTEX *)GET_VERTEX(e1); - - if (DO_FLAT) { - if (HAVE_RGBA) { - VERT_SAVE_RGBA( 0 ); - VERT_COPY_RGBA( v[0], v[1] ); - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - VERT_SAVE_SPEC( 0 ); - VERT_COPY_SPEC( v[0], v[1] ); - } - } - else { - VERT_SAVE_IND( 0 ); - VERT_COPY_IND( v[0], v[1] ); - } - } - - LINE( v[0], v[1] ); - - if (DO_FLAT) { - if (HAVE_RGBA) { - VERT_RESTORE_RGBA( 0 ); - - if (HAVE_SPEC && VB->SecondaryColorPtr[0]) { - VERT_RESTORE_SPEC( 0 ); - } - } - else { - VERT_RESTORE_IND( 0 ); - } - } -} -#endif - -#if DO_POINTS -static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb; - int i; - LOCAL_VARS(1); - - if (VB->Elts == 0) { - for ( i = first ; i < last ; i++ ) { - if ( VB->ClipMask[i] == 0 ) { - VERTEX *v = (VERTEX *)GET_VERTEX(i); - POINT( v ); - } - } - } else { - for ( i = first ; i < last ; i++ ) { - GLuint e = VB->Elts[i]; - if ( VB->ClipMask[e] == 0 ) { - VERTEX *v = (VERTEX *)GET_VERTEX(e); - POINT( v ); - } - } - } -} -#endif - -static void TAG(init)( void ) -{ -#if DO_QUAD - TAB[IND].quad = TAG(quad); -#endif -#if DO_TRI - TAB[IND].triangle = TAG(triangle); -#endif -#if DO_LINE - TAB[IND].line = TAG(line); -#endif -#if DO_POINTS - TAB[IND].points = TAG(points); -#endif -} - -#undef IND -#undef TAG - -#if HAVE_RGBA -#undef VERT_SET_IND -#undef VERT_COPY_IND -#undef VERT_SAVE_IND -#undef VERT_RESTORE_IND -#if HAVE_BACK_COLORS -#undef VERT_SET_RGBA -#endif -#else -#undef VERT_SET_RGBA -#undef VERT_COPY_RGBA -#undef VERT_SAVE_RGBA -#undef VERT_RESTORE_RGBA -#if HAVE_BACK_COLORS -#undef VERT_SET_IND -#endif -#endif - -#if !HAVE_SPEC -#undef VERT_SET_SPEC -#undef VERT_COPY_SPEC -#undef VERT_SAVE_SPEC -#undef VERT_RESTORE_SPEC -#if HAVE_BACK_COLORS -#undef VERT_COPY_SPEC1 -#endif -#else -#if HAVE_BACK_COLORS -#undef VERT_SET_SPEC -#endif -#endif - -#if !HAVE_BACK_COLORS -#undef VERT_COPY_SPEC1 -#undef VERT_COPY_IND1 -#undef VERT_COPY_RGBA1 -#endif - -#ifndef INSANE_VERTICES -#undef VERT_SET_Z -#undef VERT_Z_ADD -#endif diff --git a/src/mesa/drivers/common/t_dd_unfilled.h b/src/mesa/drivers/common/t_dd_unfilled.h deleted file mode 100644 index 46415ea5f6..0000000000 --- a/src/mesa/drivers/common/t_dd_unfilled.h +++ /dev/null @@ -1,212 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -#if HAVE_RGBA -#define VERT_SET_IND( v, c ) -#define VERT_COPY_IND( v0, v1 ) -#define VERT_SAVE_IND( idx ) -#define VERT_RESTORE_IND( idx ) -#endif - -#if !HAVE_SPEC -#define VERT_SET_SPEC( v, c ) -#define VERT_COPY_SPEC( v0, v1 ) -#define VERT_SAVE_SPEC( idx ) -#define VERT_RESTORE_SPEC( idx ) -#endif - -static void TAG(unfilled_tri)( GLcontext *ctx, - GLenum mode, - GLuint e0, GLuint e1, GLuint e2 ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte *ef = VB->EdgeFlag; - VERTEX *v[3]; - LOCAL_VARS(3); - - v[0] = (VERTEX *)GET_VERTEX(e0); - v[1] = (VERTEX *)GET_VERTEX(e1); - v[2] = (VERTEX *)GET_VERTEX(e2); - - if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) { - if (HAVE_RGBA) { - VERT_SAVE_RGBA(0); - VERT_SAVE_RGBA(1); - VERT_COPY_RGBA(v[0], v[2]); - VERT_COPY_RGBA(v[1], v[2]); - - if (HAVE_SPEC) { - VERT_SAVE_SPEC(0); - VERT_SAVE_SPEC(1); - VERT_COPY_SPEC(v[0], v[2]); - VERT_COPY_SPEC(v[1], v[2]); - } - } else { - VERT_SAVE_IND(0); - VERT_SAVE_IND(1); - VERT_COPY_IND(v[0], v[2]); - VERT_COPY_IND(v[1], v[2]); - } - } - -/* fprintf(stderr, "%s %s %d %d %d\n", __FUNCTION__, */ -/* _mesa_lookup_enum_by_nr( mode ), */ -/* ef[e0], ef[e1], ef[e2]); */ - - if (mode == GL_POINT) { - RASTERIZE(GL_POINTS); - if (ef[e0]) POINT( v[0] ); - if (ef[e1]) POINT( v[1] ); - if (ef[e2]) POINT( v[2] ); - } - else { - RASTERIZE(GL_LINES); - if (RENDER_PRIMITIVE == GL_POLYGON) { - if (ef[e2]) LINE( v[2], v[0] ); - if (ef[e0]) LINE( v[0], v[1] ); - if (ef[e1]) LINE( v[1], v[2] ); - } - else { - if (ef[e0]) LINE( v[0], v[1] ); - if (ef[e1]) LINE( v[1], v[2] ); - if (ef[e2]) LINE( v[2], v[0] ); - } - } - - if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) { - if (HAVE_RGBA) { - VERT_RESTORE_RGBA(0); - VERT_RESTORE_RGBA(1); - - if (HAVE_SPEC) { - VERT_RESTORE_SPEC(0); - VERT_RESTORE_SPEC(1); - } - } else { - VERT_RESTORE_IND(0); - VERT_RESTORE_IND(1); - } - } -} - - -static void TAG(unfilled_quad)( GLcontext *ctx, - GLenum mode, - GLuint e0, GLuint e1, - GLuint e2, GLuint e3 ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte *ef = VB->EdgeFlag; - VERTEX *v[4]; - LOCAL_VARS(4); - - v[0] = (VERTEX *)GET_VERTEX(e0); - v[1] = (VERTEX *)GET_VERTEX(e1); - v[2] = (VERTEX *)GET_VERTEX(e2); - v[3] = (VERTEX *)GET_VERTEX(e3); - - /* Hardware flatshading breaks down here. If the hardware doesn't - * support flatshading, this will already have been done: - */ - if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) { - if (HAVE_RGBA) { - VERT_SAVE_RGBA(0); - VERT_SAVE_RGBA(1); - VERT_SAVE_RGBA(2); - VERT_COPY_RGBA(v[0], v[3]); - VERT_COPY_RGBA(v[1], v[3]); - VERT_COPY_RGBA(v[2], v[3]); - - if (HAVE_SPEC) { - VERT_SAVE_SPEC(0); - VERT_SAVE_SPEC(1); - VERT_SAVE_SPEC(2); - VERT_COPY_SPEC(v[0], v[3]); - VERT_COPY_SPEC(v[1], v[3]); - VERT_COPY_SPEC(v[2], v[3]); - } - } else { - VERT_SAVE_IND(0); - VERT_SAVE_IND(1); - VERT_SAVE_IND(2); - VERT_COPY_IND(v[0], v[3]); - VERT_COPY_IND(v[1], v[3]); - VERT_COPY_IND(v[2], v[3]); - } - } - - if (mode == GL_POINT) { - RASTERIZE(GL_POINTS); - if (ef[e0]) POINT( v[0] ); - if (ef[e1]) POINT( v[1] ); - if (ef[e2]) POINT( v[2] ); - if (ef[e3]) POINT( v[3] ); - } - else { - RASTERIZE(GL_LINES); - if (ef[e0]) LINE( v[0], v[1] ); - if (ef[e1]) LINE( v[1], v[2] ); - if (ef[e2]) LINE( v[2], v[3] ); - if (ef[e3]) LINE( v[3], v[0] ); - } - - if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) { - if (HAVE_RGBA) { - VERT_RESTORE_RGBA(0); - VERT_RESTORE_RGBA(1); - VERT_RESTORE_RGBA(2); - - if (HAVE_SPEC) { - VERT_RESTORE_SPEC(0); - VERT_RESTORE_SPEC(1); - VERT_RESTORE_SPEC(2); - } - } else { - VERT_RESTORE_IND(0); - VERT_RESTORE_IND(1); - VERT_RESTORE_IND(2); - } - } -} - - -#if HAVE_RGBA -#undef VERT_SET_IND -#undef VERT_COPY_IND -#undef VERT_SAVE_IND -#undef VERT_RESTORE_IND -#endif - -#if !HAVE_SPEC -#undef VERT_SET_SPEC -#undef VERT_COPY_SPEC -#undef VERT_SAVE_SPEC -#undef VERT_RESTORE_SPEC -#endif - -#undef TAG diff --git a/src/mesa/drivers/common/t_dd_vb.c b/src/mesa/drivers/common/t_dd_vb.c deleted file mode 100644 index 380b0424b4..0000000000 --- a/src/mesa/drivers/common/t_dd_vb.c +++ /dev/null @@ -1,344 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ -#include "math/m_translate.h" - -#if (HAVE_HW_VIEWPORT) -#define UNVIEWPORT_VARS -#define UNVIEWPORT_X(x) x -#define UNVIEWPORT_Y(x) x -#define UNVIEWPORT_Z(x) x -#endif - -#ifndef LOCALVARS -#define LOCALVARS -#endif - -#ifndef CHECK_HW_DIVIDE -#define CHECK_HW_DIVIDE 1 -#endif - -/* These don't need to be duplicated, but there's currently nowhere - * really convenient to put them. Need to build some actual .o files in - * this directory? - */ -static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - LOCALVARS - GLubyte *verts = GET_VERTEX_STORE(); - GLuint shift = GET_VERTEX_STRIDE_SHIFT(); - GLuint *dst = (GLuint *)(verts + (edst << shift)); - GLuint *src = (GLuint *)(verts + (esrc << shift)); - dst[4] = src[4]; - dst[5] = src[5]; -} - -static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - LOCALVARS - GLubyte *verts = GET_VERTEX_STORE(); - GLuint shift = GET_VERTEX_STRIDE_SHIFT(); - GLuint *dst = (GLuint *)(verts + (edst << shift)); - GLuint *src = (GLuint *)(verts + (esrc << shift)); - dst[4] = src[4]; -} - -static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc ) -{ - LOCALVARS - GLubyte *verts = GET_VERTEX_STORE(); - GLuint shift = GET_VERTEX_STRIDE_SHIFT(); - GLuint *dst = (GLuint *)(verts + (edst << shift)); - GLuint *src = (GLuint *)(verts + (esrc << shift)); - dst[3] = src[3]; -} - - -void TAG(translate_vertex)(GLcontext *ctx, - const VERTEX *src, - SWvertex *dst) -{ - LOCALVARS - GLuint format = GET_VERTEX_FORMAT(); - GLfloat *s = ctx->Viewport._WindowMap.m; - UNVIEWPORT_VARS; - - if (format == TINY_VERTEX_FORMAT) { - if (HAVE_HW_VIEWPORT) { - dst->win[0] = s[0] * src->v.x + s[12]; - dst->win[1] = s[5] * src->v.y + s[13]; - dst->win[2] = s[10] * src->v.z + s[14]; - dst->win[3] = 1.0; - } else { - dst->win[0] = UNVIEWPORT_X( src->v.x ); - dst->win[1] = UNVIEWPORT_Y( src->v.y ); - dst->win[2] = UNVIEWPORT_Z( src->v.z ); - dst->win[3] = 1.0; - } - - dst->color[0] = src->tv.color.red; - dst->color[1] = src->tv.color.green; - dst->color[2] = src->tv.color.blue; - dst->color[3] = src->tv.color.alpha; - } - else { - if (HAVE_HW_VIEWPORT) { - if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) { - GLfloat oow = 1.0 / src->v.w; - dst->win[0] = s[0] * src->v.x * oow + s[12]; - dst->win[1] = s[5] * src->v.y * oow + s[13]; - dst->win[2] = s[10] * src->v.z * oow + s[14]; - dst->win[3] = oow; - } else { - dst->win[0] = s[0] * src->v.x + s[12]; - dst->win[1] = s[5] * src->v.y + s[13]; - dst->win[2] = s[10] * src->v.z + s[14]; - dst->win[3] = src->v.w; - } - } else { - dst->win[0] = UNVIEWPORT_X( src->v.x ); - dst->win[1] = UNVIEWPORT_Y( src->v.y ); - dst->win[2] = UNVIEWPORT_Z( src->v.z ); - dst->win[3] = src->v.w; - } - - dst->color[0] = src->v.color.red; - dst->color[1] = src->v.color.green; - dst->color[2] = src->v.color.blue; - dst->color[3] = src->v.color.alpha; - - dst->specular[0] = src->v.specular.red; - dst->specular[1] = src->v.specular.green; - dst->specular[2] = src->v.specular.blue; - - dst->fog = src->v.specular.alpha/255.0; - - if (HAVE_PTEX_VERTICES && - ((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) || - (format == PROJ_TEX1_VERTEX_FORMAT))) { - - dst->texcoord[0][0] = src->pv.u0; - dst->texcoord[0][1] = src->pv.v0; - dst->texcoord[0][3] = src->pv.q0; - - dst->texcoord[1][0] = src->pv.u1; - dst->texcoord[1][1] = src->pv.v1; - dst->texcoord[1][3] = src->pv.q1; - - if (HAVE_TEX2_VERTICES) { - dst->texcoord[2][0] = src->pv.u2; - dst->texcoord[2][1] = src->pv.v2; - dst->texcoord[2][3] = src->pv.q2; - } - - if (HAVE_TEX3_VERTICES) { - dst->texcoord[3][0] = src->pv.u3; - dst->texcoord[3][1] = src->pv.v3; - dst->texcoord[3][3] = src->pv.q3; - } - } - else { - dst->texcoord[0][0] = src->v.u0; - dst->texcoord[0][1] = src->v.v0; - dst->texcoord[0][3] = 1.0; - - dst->texcoord[1][0] = src->v.u1; - dst->texcoord[1][1] = src->v.v1; - dst->texcoord[1][3] = 1.0; - - if (HAVE_TEX2_VERTICES) { - dst->texcoord[2][0] = src->v.u2; - dst->texcoord[2][1] = src->v.v2; - dst->texcoord[2][3] = 1.0; - } - - if (HAVE_TEX3_VERTICES) { - dst->texcoord[3][0] = src->v.u3; - dst->texcoord[3][1] = src->v.v3; - dst->texcoord[3][3] = 1.0; - } - } - } - - dst->pointSize = ctx->Point._Size; -} - - - -void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v ) -{ - LOCALVARS - GLuint format = GET_VERTEX_FORMAT(); - - fprintf(stderr, "(%x) ", format); - - switch (format) { -#if HAVE_TINY_VERTICES - case TINY_VERTEX_FORMAT: - fprintf(stderr, "xyz %.4f,%.4f,%.4f rgba %x:%x:%x:%x\n", - v->v.x, v->v.y, v->v.z, - v->tv.color.red, - v->tv.color.green, - v->tv.color.blue, - v->tv.color.alpha); - break; -#endif -#if HAVE_NOTEX_VERTICES - case NOTEX_VERTEX_FORMAT: - fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x spec %x:%x:%x:%x\n", - v->v.x, v->v.y, v->v.z, v->v.w, - v->v.color.red, - v->v.color.green, - v->v.color.blue, - v->v.color.alpha, - v->v.specular.red, - v->v.specular.green, - v->v.specular.blue, - v->v.specular.alpha); - break; -#endif -#if HAVE_TEX0_VERTICES - case TEX0_VERTEX_FORMAT: - fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f\n", - v->v.x, v->v.y, v->v.z, v->v.w, - v->v.color.red, - v->v.color.green, - v->v.color.blue, - v->v.color.alpha, - v->v.u0, - v->v.v0); - break; -#endif -#if HAVE_TEX1_VERTICES - case TEX1_VERTEX_FORMAT: - fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f st %.4f,%.4f\n", - v->v.x, v->v.y, v->v.z, v->v.w, - v->v.color.red, - v->v.color.green, - v->v.color.blue, - v->v.color.alpha, - v->v.u0, - v->v.v0, - v->v.u1, - v->v.u2); - break; -#endif -#if HAVE_PTEX_VERTICES - case PROJ_TEX1_VERTEX_FORMAT: - fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x stq %.4f,%.4f,%.4f stq %.4f,%.4f,%.4f\n", - v->v.x, v->v.y, v->v.z, v->v.w, - v->v.color.red, - v->v.color.green, - v->v.color.blue, - v->v.color.alpha, - v->pv.u0, - v->pv.v0, - v->pv.q0, - v->pv.u1, - v->pv.v1, - v->pv.q1); - break; -#endif - default: - fprintf(stderr, "???\n"); - break; - } - - fprintf(stderr, "\n"); -} - - - -/* Interpolate the elements of the VB not included in typical hardware - * vertices. - * - * NOTE: All these arrays are guarenteed by tnl to be writeable and - * have good stride. - */ -#ifndef INTERP_QUALIFIER -#define INTERP_QUALIFIER static -#endif - -#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) - - -INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx, - GLfloat t, - GLuint dst, GLuint out, GLuint in, - GLboolean force_boundary ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->ColorPtr[1]) { - assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat)); - - INTERP_4F( t, - GET_COLOR(VB->ColorPtr[1], dst), - GET_COLOR(VB->ColorPtr[1], out), - GET_COLOR(VB->ColorPtr[1], in) ); - - if (VB->SecondaryColorPtr[1]) { - INTERP_3F( t, - GET_COLOR(VB->SecondaryColorPtr[1], dst), - GET_COLOR(VB->SecondaryColorPtr[1], out), - GET_COLOR(VB->SecondaryColorPtr[1], in) ); - } - } - - if (VB->EdgeFlag) { - VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary; - } - - INTERP_VERTEX(ctx, t, dst, out, in, force_boundary); -} - -INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx, - GLuint dst, GLuint src ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - if (VB->ColorPtr[1]) { - COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), - GET_COLOR(VB->ColorPtr[1], src) ); - - if (VB->SecondaryColorPtr[1]) { - COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), - GET_COLOR(VB->SecondaryColorPtr[1], src) ); - } - } - - COPY_PV_VERTEX(ctx, dst, src); -} - - -#undef INTERP_QUALIFIER -#undef GET_COLOR - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/common/t_dd_vbtmp.h b/src/mesa/drivers/common/t_dd_vbtmp.h deleted file mode 100644 index 14b4a28651..0000000000 --- a/src/mesa/drivers/common/t_dd_vbtmp.h +++ /dev/null @@ -1,679 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 5.0.1 - * - * Copyright (C) 1999-2003 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - - -/* Unlike the other templates here, this assumes quite a bit about the - * underlying hardware. Specifically it assumes a d3d-like vertex - * format, with a layout more or less constrained to look like the - * following: - * - * union { - * struct { - * float x, y, z, w; - * struct { char r, g, b, a; } color; - * struct { char r, g, b, fog; } spec; - * float u0, v0; - * float u1, v1; - * float u2, v2; - * float u3, v3; - * } v; - * struct { - * float x, y, z, w; - * struct { char r, g, b, a; } color; - * struct { char r, g, b, fog; } spec; - * float u0, v0, q0; - * float u1, v1, q1; - * float u2, v2, q2; - * float u3, v3, q3; - * } pv; - * struct { - * float x, y, z; - * struct { char r, g, b, a; } color; - * } tv; - * float f[16]; - * unsigned int ui[16]; - * unsigned char ub4[4][16]; - * } - * - - * VERTEX: hw vertex type as above - * VERTEX_COLOR: hw color struct type in VERTEX - * - * DO_XYZW: Emit xyz and maybe w coordinates. - * DO_RGBA: Emit color. - * DO_SPEC: Emit specular color. - * DO_FOG: Emit fog coordinate in specular alpha. - * DO_TEX0: Emit tex0 u,v coordinates. - * DO_TEX1: Emit tex1 u,v coordinates. - * DO_TEX2: Emit tex2 u,v coordinates. - * DO_TEX3: Emit tex3 u,v coordinates. - * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible. - * - * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra). - * - * HAVE_HW_VIEWPORT: Hardware performs viewport transform. - * HAVE_HW_DIVIDE: Hardware performs perspective divide. - * - * HAVE_TINY_VERTICES: Hardware understands v.tv format. - * HAVE_PTEX_VERTICES: Hardware understands v.pv format. - * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0. - * - * Additionally, this template assumes it is emitting *transformed* - * vertices; the modifications to emit untransformed vertices (ie. to - * t&l hardware) are probably too great to cooexist with the code - * already in this file. - * - * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if - * only TEX0 is enabled, in order to maintain a vertex size which is - * an exact number of quadwords. - */ - -#if (HAVE_HW_VIEWPORT) -#define VIEWPORT_X(dst,x) dst = x -#define VIEWPORT_Y(dst,y) dst = y -#define VIEWPORT_Z(dst,z) dst = z -#else -#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] -#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] -#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] -#endif - -#if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES) -#error "can't cope with this combination" -#endif - -#ifndef LOCALVARS -#define LOCALVARS -#endif - -#ifndef CHECK_HW_DIVIDE -#define CHECK_HW_DIVIDE 1 -#endif - -#if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES) - -static void TAG(emit)( GLcontext *ctx, - GLuint start, GLuint end, - void *dest, - GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4]; - GLfloat (*tc2)[4], (*tc3)[4]; - GLfloat (*col)[4], (*spec)[4]; - GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride; - GLuint tc2_stride, tc3_stride; - GLuint tc0_size, tc1_size; - GLuint tc2_size, tc3_size; - GLfloat (*coord)[4]; - GLuint coord_stride; - VERTEX *v = (VERTEX *)dest; - const GLfloat *s = GET_VIEWPORT_MAT(); - const GLubyte *mask = VB->ClipMask; - int i; - -/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */ -/* __FUNCTION__, VB->importable_data, start, end); */ - - if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) { - (void) s; - coord = VB->ClipPtr->data; - coord_stride = VB->ClipPtr->stride; - } - else { - coord = VB->NdcPtr->data; - coord_stride = VB->NdcPtr->stride; - } - - if (DO_TEX3) { - const GLuint t3 = GET_TEXSOURCE(3); - tc3 = VB->TexCoordPtr[t3]->data; - tc3_stride = VB->TexCoordPtr[t3]->stride; - if (DO_PTEX) - tc3_size = VB->TexCoordPtr[t3]->size; - } - - if (DO_TEX2) { - const GLuint t2 = GET_TEXSOURCE(2); - tc2 = VB->TexCoordPtr[t2]->data; - tc2_stride = VB->TexCoordPtr[t2]->stride; - if (DO_PTEX) - tc2_size = VB->TexCoordPtr[t2]->size; - } - - if (DO_TEX1) { - const GLuint t1 = GET_TEXSOURCE(1); - tc1 = VB->TexCoordPtr[t1]->data; - tc1_stride = VB->TexCoordPtr[t1]->stride; - if (DO_PTEX) - tc1_size = VB->TexCoordPtr[t1]->size; - } - - if (DO_TEX0) { - const GLuint t0 = GET_TEXSOURCE(0); - tc0_stride = VB->TexCoordPtr[t0]->stride; - tc0 = VB->TexCoordPtr[t0]->data; - if (DO_PTEX) - tc0_size = VB->TexCoordPtr[t0]->size; - } - - if (DO_RGBA) { - col_stride = VB->ColorPtr[0]->stride; - col = VB->ColorPtr[0]->data; - } - - if (DO_SPEC) { - if (VB->SecondaryColorPtr[0]) { - spec_stride = VB->SecondaryColorPtr[0]->stride; - spec = VB->SecondaryColorPtr[0]->data; - } else { - spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - spec_stride = 0; - } - } - - if (DO_FOG) { - if (VB->FogCoordPtr) { - fog = VB->FogCoordPtr->data; - fog_stride = VB->FogCoordPtr->stride; - } - else { - static GLfloat tmp[4] = {0, 0, 0, 0}; - fog = &tmp; - fog_stride = 0; - } - } - - /* May have nonstandard strides: - */ - if (start) { - STRIDE_4F(coord, start * coord_stride); - if (DO_TEX0) - STRIDE_4F(tc0, start * tc0_stride); - if (DO_TEX1) - STRIDE_4F(tc1, start * tc1_stride); - if (DO_TEX2) - STRIDE_4F(tc2, start * tc2_stride); - if (DO_TEX3) - STRIDE_4F(tc3, start * tc3_stride); - if (DO_RGBA) - STRIDE_4F(col, start * col_stride); - if (DO_SPEC) - STRIDE_4F(spec, start * spec_stride); - if (DO_FOG) - STRIDE_4F(fog, start * fog_stride); - } - - for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) { - if (DO_XYZW) { - if (HAVE_HW_VIEWPORT || mask[i] == 0) { - VIEWPORT_X(v->v.x, coord[0][0]); - VIEWPORT_Y(v->v.y, coord[0][1]); - VIEWPORT_Z(v->v.z, coord[0][2]); - v->v.w = coord[0][3]; - } - STRIDE_4F(coord, coord_stride); - } - if (DO_RGBA) { - UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.red, col[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.green, col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.blue, col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.alpha, col[0][3]); - STRIDE_4F(col, col_stride); - } - if (DO_SPEC) { - UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.red, spec[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.green, spec[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.blue, spec[0][2]); - STRIDE_4F(spec, spec_stride); - } - if (DO_FOG) { - UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.alpha, fog[0][0]); - STRIDE_4F(fog, fog_stride); - } - if (DO_TEX0) { - v->v.u0 = tc0[0][0]; - v->v.v0 = tc0[0][1]; - if (DO_PTEX) { - if (HAVE_PTEX_VERTICES) { - if (tc0_size == 4) - v->pv.q0 = tc0[0][3]; - else - v->pv.q0 = 1.0; - } - else if (tc0_size == 4) { - float rhw = 1.0 / tc0[0][3]; - v->v.w *= tc0[0][3]; - v->v.u0 *= rhw; - v->v.v0 *= rhw; - } - } - STRIDE_4F(tc0, tc0_stride); - } - if (DO_TEX1) { - if (DO_PTEX) { - v->pv.u1 = tc1[0][0]; - v->pv.v1 = tc1[0][1]; - if (tc1_size == 4) - v->pv.q1 = tc1[0][3]; - else - v->pv.q1 = 1.0; - } - else { - v->v.u1 = tc1[0][0]; - v->v.v1 = tc1[0][1]; - } - STRIDE_4F(tc1, tc1_stride); - } - else if (DO_PTEX) { - *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */ - } - if (DO_TEX2) { - if (DO_PTEX) { - v->pv.u2 = tc2[0][0]; - v->pv.v2 = tc2[0][1]; - if (tc2_size == 4) - v->pv.q2 = tc2[0][3]; - else - v->pv.q2 = 1.0; - } - else { - v->v.u2 = tc2[0][0]; - v->v.v2 = tc2[0][1]; - } - STRIDE_4F(tc2, tc2_stride); - } - if (DO_TEX3) { - if (DO_PTEX) { - v->pv.u3 = tc3[0][0]; - v->pv.v3 = tc3[0][1]; - if (tc3_size == 4) - v->pv.q3 = tc3[0][3]; - else - v->pv.q3 = 1.0; - } - else { - v->v.u3 = tc3[0][0]; - v->v.v3 = tc3[0][1]; - } - STRIDE_4F(tc3, tc3_stride); - } - } - -} -#else - -#if HAVE_HW_DIVIDE -#error "cannot use tiny vertices with hw perspective divide" -#endif - -static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, - void *dest, GLuint stride ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLfloat (*col)[4]; - GLuint col_stride; - GLfloat (*coord)[4] = VB->NdcPtr->data; - GLuint coord_stride = VB->NdcPtr->stride; - GLfloat *v = (GLfloat *)dest; - const GLubyte *mask = VB->ClipMask; - const GLfloat *s = GET_VIEWPORT_MAT(); - int i; - - (void) s; - - ASSERT(stride == 4); - - col = VB->ColorPtr[0]->data; - col_stride = VB->ColorPtr[0]->stride; - -/* fprintf(stderr, "%s(small) importable %x\n", */ -/* __FUNCTION__, VB->importable_data); */ - - /* Pack what's left into a 4-dword vertex. Color is in a different - * place, and there is no 'w' coordinate. - */ - if (start) { - STRIDE_4F(coord, start * coord_stride); - STRIDE_4F(col, start * col_stride); - } - - for (i=start; i < end; i++, v+=4) { - if (DO_XYZW) { - if (HAVE_HW_VIEWPORT || mask[i] == 0) { - VIEWPORT_X(v[0], coord[0][0]); - VIEWPORT_Y(v[1], coord[0][1]); - VIEWPORT_Z(v[2], coord[0][2]); - } - STRIDE_4F( coord, coord_stride ); - } - if (DO_RGBA) { - VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3]; - UNCLAMPED_FLOAT_TO_UBYTE(c->red, col[0][0]); - UNCLAMPED_FLOAT_TO_UBYTE(c->green, col[0][1]); - UNCLAMPED_FLOAT_TO_UBYTE(c->blue, col[0][2]); - UNCLAMPED_FLOAT_TO_UBYTE(c->alpha, col[0][3]); - STRIDE_4F( col, col_stride ); - } -/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */ -/* i, v[0], v[1], v[2], *(int *)&v[3]); */ - } -} - -#endif /* emit */ - -#if (DO_XYZW) && (DO_RGBA) - - -#if (HAVE_PTEX_VERTICES) -static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* Force 'missing' texcoords to something valid. - */ - if (DO_TEX3 && VB->TexCoordPtr[2] == 0) - VB->TexCoordPtr[2] = VB->TexCoordPtr[3]; - - if (DO_TEX2 && VB->TexCoordPtr[1] == 0) - VB->TexCoordPtr[1] = VB->TexCoordPtr[2]; - - if (DO_TEX1 && VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[1]; - - if (DO_PTEX) - return GL_TRUE; - - if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) || - (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) || - (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) || - (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4)) - return GL_FALSE; - - return GL_TRUE; -} -#else -static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - - /* Force 'missing' texcoords to something valid. - */ - if (DO_TEX3 && VB->TexCoordPtr[2] == 0) - VB->TexCoordPtr[2] = VB->TexCoordPtr[3]; - - if (DO_TEX2 && VB->TexCoordPtr[1] == 0) - VB->TexCoordPtr[1] = VB->TexCoordPtr[2]; - - if (DO_TEX1 && VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[1]; - - if (DO_PTEX) - return GL_TRUE; - - /* No hardware support for projective texture. Can fake it for - * TEX0 only. - */ - if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) || - (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) || - (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) { - PTEX_FALLBACK(); - return GL_FALSE; - } - - if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) { - if (DO_TEX1 || DO_TEX2 || DO_TEX3) { - PTEX_FALLBACK(); - } - return GL_FALSE; - } - - return GL_TRUE; -} -#endif /* ptex */ - - -static void TAG(interp)( GLcontext *ctx, - GLfloat t, - GLuint edst, GLuint eout, GLuint ein, - GLboolean force_boundary ) -{ - LOCALVARS - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte *ddverts = GET_VERTEX_STORE(); - GLuint shift = GET_VERTEX_STRIDE_SHIFT(); - const GLfloat *dstclip = VB->ClipPtr->data[edst]; - GLfloat w; - const GLfloat *s = GET_VIEWPORT_MAT(); - - VERTEX *dst = (VERTEX *)(ddverts + (edst << shift)); - VERTEX *in = (VERTEX *)(ddverts + (ein << shift)); - VERTEX *out = (VERTEX *)(ddverts + (eout << shift)); - - (void)s; - - if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) { - VIEWPORT_X( dst->v.x, dstclip[0] ); - VIEWPORT_Y( dst->v.y, dstclip[1] ); - VIEWPORT_Z( dst->v.z, dstclip[2] ); - w = dstclip[3]; - } - else { - w = 1.0 / dstclip[3]; - VIEWPORT_X( dst->v.x, dstclip[0] * w ); - VIEWPORT_Y( dst->v.y, dstclip[1] * w ); - VIEWPORT_Z( dst->v.z, dstclip[2] * w ); - } - - if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) || - DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 || - DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) { - - dst->v.w = w; - - INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] ); - INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] ); - INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] ); - INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] ); - - if (DO_SPEC) { - INTERP_UB( t, dst->v.specular.red, out->v.specular.red, in->v.specular.red ); - INTERP_UB( t, dst->v.specular.green, out->v.specular.green, in->v.specular.green ); - INTERP_UB( t, dst->v.specular.blue, out->v.specular.blue, in->v.specular.blue ); - } - if (DO_FOG) { - INTERP_UB( t, dst->v.specular.alpha, out->v.specular.alpha, in->v.specular.alpha ); - } - if (DO_TEX0) { - if (DO_PTEX) { - if (HAVE_PTEX_VERTICES) { - INTERP_F( t, dst->pv.u0, out->pv.u0, in->pv.u0 ); - INTERP_F( t, dst->pv.v0, out->pv.v0, in->pv.v0 ); - INTERP_F( t, dst->pv.q0, out->pv.q0, in->pv.q0 ); - } else { - GLfloat wout = VB->NdcPtr->data[eout][3]; - GLfloat win = VB->NdcPtr->data[ein][3]; - GLfloat qout = out->pv.w / wout; - GLfloat qin = in->pv.w / win; - GLfloat qdst, rqdst; - - ASSERT( !HAVE_HW_DIVIDE ); - - INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin ); - INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin ); - INTERP_F( t, qdst, qout, qin ); - - rqdst = 1.0 / qdst; - dst->v.u0 *= rqdst; - dst->v.v0 *= rqdst; - dst->v.w *= rqdst; - } - } - else { - INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 ); - INTERP_F( t, dst->v.v0, out->v.v0, in->v.v0 ); - } - } - if (DO_TEX1) { - if (DO_PTEX) { - INTERP_F( t, dst->pv.u1, out->pv.u1, in->pv.u1 ); - INTERP_F( t, dst->pv.v1, out->pv.v1, in->pv.v1 ); - INTERP_F( t, dst->pv.q1, out->pv.q1, in->pv.q1 ); - } else { - INTERP_F( t, dst->v.u1, out->v.u1, in->v.u1 ); - INTERP_F( t, dst->v.v1, out->v.v1, in->v.v1 ); - } - } - else if (DO_PTEX) { - dst->pv.q1 = 0.0; /* must be a valid float on radeon */ - } - if (DO_TEX2) { - if (DO_PTEX) { - INTERP_F( t, dst->pv.u2, out->pv.u2, in->pv.u2 ); - INTERP_F( t, dst->pv.v2, out->pv.v2, in->pv.v2 ); - INTERP_F( t, dst->pv.q2, out->pv.q2, in->pv.q2 ); - } else { - INTERP_F( t, dst->v.u2, out->v.u2, in->v.u2 ); - INTERP_F( t, dst->v.v2, out->v.v2, in->v.v2 ); - } - } - if (DO_TEX3) { - if (DO_PTEX) { - INTERP_F( t, dst->pv.u3, out->pv.u3, in->pv.u3 ); - INTERP_F( t, dst->pv.v3, out->pv.v3, in->pv.v3 ); - INTERP_F( t, dst->pv.q3, out->pv.q3, in->pv.q3 ); - } else { - INTERP_F( t, dst->v.u3, out->v.u3, in->v.u3 ); - INTERP_F( t, dst->v.v3, out->v.v3, in->v.v3 ); - } - } - } else { - /* 4-dword vertex. Color is in v[3] and there is no oow coordinate. - */ - INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] ); - INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] ); - INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] ); - INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] ); - } -} - -#endif /* rgba && xyzw */ - - -static void TAG(init)( void ) -{ - setup_tab[IND].emit = TAG(emit); - -#if (DO_XYZW && DO_RGBA) - setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); - setup_tab[IND].interp = TAG(interp); -#endif - - if (DO_SPEC) - setup_tab[IND].copy_pv = copy_pv_rgba4_spec5; - else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 || - DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) - setup_tab[IND].copy_pv = copy_pv_rgba4; - else - setup_tab[IND].copy_pv = copy_pv_rgba3; - - if (DO_TEX3) { - if (DO_PTEX) { - ASSERT(HAVE_PTEX_VERTICES); - setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 18; - setup_tab[IND].vertex_stride_shift = 7; - } - else { - setup_tab[IND].vertex_format = TEX3_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 14; - setup_tab[IND].vertex_stride_shift = 6; - } - } - else if (DO_TEX2) { - if (DO_PTEX) { - ASSERT(HAVE_PTEX_VERTICES); - setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 18; - setup_tab[IND].vertex_stride_shift = 7; - } - else { - setup_tab[IND].vertex_format = TEX2_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 12; - setup_tab[IND].vertex_stride_shift = 6; - } - } - else if (DO_TEX1) { - if (DO_PTEX) { - ASSERT(HAVE_PTEX_VERTICES); - setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 12; - setup_tab[IND].vertex_stride_shift = 6; - } - else { - setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 10; - setup_tab[IND].vertex_stride_shift = 6; - } - } - else if (DO_TEX0) { - if (DO_PTEX && HAVE_PTEX_VERTICES) { - setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 12; - setup_tab[IND].vertex_stride_shift = 6; - } else { - setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 8; - setup_tab[IND].vertex_stride_shift = 5; - } - } - else if (!HAVE_HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) { - setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 4; - setup_tab[IND].vertex_stride_shift = 4; - } else if (HAVE_NOTEX_VERTICES) { - setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 6; - setup_tab[IND].vertex_stride_shift = 5; - } else { - setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT; - setup_tab[IND].vertex_size = 8; - setup_tab[IND].vertex_stride_shift = 5; - } - - assert(setup_tab[IND].vertex_size * 4 <= - 1 << setup_tab[IND].vertex_stride_shift); -} - - -#undef IND -#undef TAG diff --git a/src/mesa/drivers/common/t_dd_vertex.h b/src/mesa/drivers/common/t_dd_vertex.h deleted file mode 100644 index d45dd09fbd..0000000000 --- a/src/mesa/drivers/common/t_dd_vertex.h +++ /dev/null @@ -1,78 +0,0 @@ - -/* - * Mesa 3-D graphics library - * Version: 4.0.3 - * - * Copyright (C) 1999-2002 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"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell - */ - -typedef struct { - GLfloat x, y, z, w; -} TAG(_coord_t); - -#ifdef COLOR_IS_RGBA -typedef struct { -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN - GLubyte alpha, blue, green, red; -#else - GLubyte red, green, blue, alpha; -#endif -} TAG(_color_t); -#else -typedef struct { -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN - GLubyte alpha, red, green, blue; -#else - GLubyte blue, green, red, alpha; -#endif -} TAG(_color_t); -#endif - -typedef union { - struct { - GLfloat x, y, z, w; - TAG(_color_t) color; - TAG(_color_t) specular; - GLfloat u0, v0; - GLfloat u1, v1; - GLfloat u2, v2; - GLfloat u3, v3; - } v; - struct { - GLfloat x, y, z, w; - TAG(_color_t) color; - TAG(_color_t) specular; - GLfloat u0, v0, q0; - GLfloat u1, v1, q1; - GLfloat u2, v2, q2; - GLfloat u3, v3, q3; - } pv; - struct { - GLfloat x, y, z; - TAG(_color_t) color; - } tv; - GLfloat f[24]; - GLuint ui[24]; - GLubyte ub4[24][4]; -} TAG(Vertex), *TAG(VertexPtr); - -- cgit v1.2.3