mesa: remove old tnl device driver header files

The last users of these were removed when the classic drivers were
dropped.

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14070>
This commit is contained in:
Timothy Arceri 2021-12-06 11:28:34 +11:00
parent e914a6710f
commit 80719f08a7
8 changed files with 0 additions and 2527 deletions

View File

@ -41,8 +41,6 @@
- src/mesa/state_tracker/**/*
- src/mesa/swrast/**/*
- src/mesa/swrast_setup/**/*
- src/mesa/tnl/**/*
- src/mesa/tnl_dd/**/*
- src/mesa/vbo/**/*
- src/mesa/x86/**/*
- src/mesa/x86-64/**/*

View File

@ -88,10 +88,6 @@ each directory.
- **swrast_setup** - Software primitive setup. Does things like
polygon culling, glPolygonMode, polygon offset, etc. (not used
with Gallium)
- **tnl** - Software vertex Transformation 'n Lighting. (not used
with Gallium)
- **tnl_dd** - TNL code for device drivers. (not used with
Gallium)
- **vbo** - Vertex Buffer Object code. All drawing with
glBegin/glEnd, glDrawArrays, display lists, etc. goes through
this module. The results is a well-defined set of vertex arrays

View File

@ -1,488 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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 <keithw@vmware.com>
*/
#include <stdbool.h>
/**
* \file t_dd_dmatmp.h
* Template for render stages which build and emit vertices directly
* to fixed-size dma buffers. Useful for rendering strips and other
* native primitives where clipping and per-vertex tweaks such as
* those in t_dd_tritmp.h are not required.
*
* 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.
*/
#if !HAVE_TRIANGLES || !HAVE_LINES || !HAVE_LINE_STRIPS || !HAVE_TRI_STRIPS || !HAVE_TRI_FANS
#error "must have lines, line strips, triangles, triangle fans, and triangle strips to use render template"
#endif
#if HAVE_QUAD_STRIPS || HAVE_QUADS || HAVE_ELTS
#error "ELTs, quads, and quad strips not supported by render template"
#endif
/**********************************************************************/
/* Render whole begin/end objects */
/**********************************************************************/
static inline void *TAG(emit_verts)(struct gl_context *ctx, GLuint start,
GLuint count, void *buf)
{
return EMIT_VERTS(ctx, start, count, buf);
}
/***********************************************************************
* Render non-indexed primitives.
***********************************************************************/
static void TAG(render_points_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
if (HAVE_POINTS) {
LOCAL_VARS;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
unsigned currentsz;
GLuint j, nr;
INIT(GL_POINTS);
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8)
currentsz = dmasz;
for (j = 0; j < count; j += nr) {
nr = MIN2(currentsz, count - j);
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
} else {
unreachable("Cannot draw primitive; validate_render should have "
"prevented this");
}
}
static void TAG(render_lines_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
LOCAL_VARS;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS() & ~1;
unsigned currentsz;
GLuint j, nr;
INIT(GL_LINES);
/* Emit whole number of lines in total and in each buffer:
*/
count -= count & 1;
currentsz = GET_CURRENT_VB_MAX_VERTS();
currentsz -= currentsz & 1;
if (currentsz < 8)
currentsz = dmasz;
for (j = 0; j < count; j += nr) {
nr = MIN2(currentsz, count - j);
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
}
static void TAG(render_line_strip_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
LOCAL_VARS;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
unsigned currentsz;
GLuint j, nr;
INIT(GL_LINE_STRIP);
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8)
currentsz = dmasz;
for (j = 0; j + 1 < count; j += nr - 1) {
nr = MIN2(currentsz, count - j);
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
FLUSH();
}
static void TAG(render_line_loop_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
LOCAL_VARS;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS() - 1;
unsigned currentsz;
GLuint j, nr;
INIT(GL_LINE_STRIP);
j = (flags & PRIM_BEGIN) ? 0 : 1;
/* Ensure last vertex won't wrap buffers:
*/
currentsz = GET_CURRENT_VB_MAX_VERTS();
currentsz--;
if (currentsz < 8)
currentsz = dmasz;
if (j + 1 < count) {
for (/* empty */; j + 1 < count; j += nr - 1) {
nr = MIN2(currentsz, count - j);
if (j + nr >= count &&
count > 1 &&
(flags & PRIM_END)) {
void *tmp;
tmp = ALLOC_VERTS(nr+1);
tmp = TAG(emit_verts)(ctx, start + j, nr, tmp);
tmp = TAG(emit_verts)( ctx, start, 1, tmp );
(void) tmp;
} else {
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
}
} else if (count > 1 && (flags & PRIM_END)) {
void *tmp;
tmp = ALLOC_VERTS(2);
tmp = TAG(emit_verts)( ctx, start+1, 1, tmp );
tmp = TAG(emit_verts)( ctx, start, 1, tmp );
(void) tmp;
}
FLUSH();
}
static void TAG(render_triangles_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
LOCAL_VARS;
const unsigned dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS() / 3) * 3;
unsigned currentsz;
GLuint j, nr;
INIT(GL_TRIANGLES);
currentsz = (GET_CURRENT_VB_MAX_VERTS() / 3) * 3;
/* Emit whole number of tris in total. dmasz is already a multiple
* of 3.
*/
count -= count % 3;
if (currentsz < 8)
currentsz = dmasz;
for (j = 0; j < count; j += nr) {
nr = MIN2(currentsz, count - j);
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
}
static void TAG(render_tri_strip_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
LOCAL_VARS;
GLuint j, nr;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS() & ~1;
unsigned currentsz;
INIT(GL_TRIANGLE_STRIP);
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8)
currentsz = dmasz;
/* From here on emit even numbers of tris when wrapping over buffers:
*/
currentsz -= (currentsz & 1);
for (j = 0; j + 2 < count; j += nr - 2) {
nr = MIN2(currentsz, count - j);
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
FLUSH();
}
static void TAG(render_tri_fan_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
LOCAL_VARS;
GLuint j, nr;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
unsigned currentsz;
INIT(GL_TRIANGLE_FAN);
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8)
currentsz = dmasz;
for (j = 1; j + 1 < count; j += nr - 2) {
void *tmp;
nr = MIN2(currentsz, count - j + 1);
tmp = ALLOC_VERTS(nr);
tmp = TAG(emit_verts)(ctx, start, 1, tmp);
tmp = TAG(emit_verts)(ctx, start + j, nr - 1, tmp);
(void) tmp;
currentsz = dmasz;
}
FLUSH();
}
static void TAG(render_poly_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
if (HAVE_POLYGONS) {
LOCAL_VARS;
GLuint j, nr;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
unsigned currentsz;
INIT(GL_POLYGON);
currentsz = GET_CURRENT_VB_MAX_VERTS();
if (currentsz < 8) {
currentsz = dmasz;
}
for (j = 1; j + 1 < count; j += nr - 2) {
void *tmp;
nr = MIN2(currentsz, count - j + 1);
tmp = ALLOC_VERTS(nr);
tmp = TAG(emit_verts)(ctx, start, 1, tmp);
tmp = TAG(emit_verts)(ctx, start + j, nr - 1, tmp);
(void) tmp;
currentsz = dmasz;
}
FLUSH();
} else if (ctx->Light.ShadeModel == GL_SMOOTH ||
ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION) {
TAG(render_tri_fan_verts)( ctx, start, count, flags );
} else {
unreachable("Cannot draw primitive; validate_render should have "
"prevented this");
}
}
static void TAG(render_quad_strip_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
GLuint j, nr;
if (ctx->Light.ShadeModel == GL_SMOOTH) {
LOCAL_VARS;
const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS() & ~1;
unsigned currentsz;
/* Emit smooth-shaded quadstrips as tristrips:
*/
FLUSH();
INIT(GL_TRIANGLE_STRIP);
/* Emit whole number of quads in total, and in each buffer.
*/
currentsz = GET_CURRENT_VB_MAX_VERTS();
currentsz -= currentsz & 1;
count -= count & 1;
if (currentsz < 8)
currentsz = dmasz;
for (j = 0; j + 3 < count; j += nr - 2) {
nr = MIN2(currentsz, count - j);
TAG(emit_verts)(ctx, start + j, nr, ALLOC_VERTS(nr));
currentsz = dmasz;
}
FLUSH();
} else {
unreachable("Cannot draw primitive; validate_render should have "
"prevented this");
}
}
static void TAG(render_quads_verts)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
if (ctx->Light.ShadeModel == GL_SMOOTH ||
ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION) {
LOCAL_VARS;
GLuint j;
/* Emit whole number of quads in total. */
count -= count & 3;
/* Hardware doesn't have a quad primitive type -- try to simulate it using
* triangle primitive. This is a win for gears, but is it useful in the
* broader world?
*/
INIT(GL_TRIANGLES);
for (j = 0; j + 3 < count; j += 4) {
void *tmp = ALLOC_VERTS(6);
/* Send v0, v1, v3
*/
tmp = EMIT_VERTS(ctx, start + j, 2, tmp);
tmp = EMIT_VERTS(ctx, start + j + 3, 1, tmp);
/* Send v1, v2, v3
*/
tmp = EMIT_VERTS(ctx, start + j + 1, 3, tmp);
(void) tmp;
}
} else {
unreachable("Cannot draw primitive");
}
}
static void TAG(render_noop)(struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags)
{
(void) ctx;
(void) start;
(void) count;
(void) flags;
}
static const tnl_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),
};
/* Pre-check the primitives in the VB to prevent the need for
* fallbacks later on.
*/
static bool TAG(validate_render)(struct gl_context *ctx,
struct vertex_buffer *VB)
{
GLint i;
if (VB->ClipOrMask & ~CLIP_CULL_BIT)
return false;
if (VB->Elts)
return false;
for (i = 0 ; i < VB->PrimitiveCount ; i++) {
GLuint prim = VB->Primitive[i].mode;
GLuint count = VB->Primitive[i].count;
bool ok = false;
if (!count)
continue;
switch (prim & PRIM_MODE_MASK) {
case GL_POINTS:
ok = HAVE_POINTS;
break;
case GL_LINES:
case GL_LINE_STRIP:
case GL_LINE_LOOP:
ok = !ctx->Line.StippleFlag;
break;
case GL_TRIANGLES:
case GL_TRIANGLE_STRIP:
case GL_TRIANGLE_FAN:
ok = true;
break;
case GL_POLYGON:
ok = (HAVE_POLYGONS) || ctx->Light.ShadeModel == GL_SMOOTH ||
ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION;
break;
case GL_QUAD_STRIP:
ok = VB->Elts || ctx->Light.ShadeModel == GL_SMOOTH;
break;
case GL_QUADS:
ok = ctx->Light.ShadeModel == GL_SMOOTH ||
ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION;
break;
default:
break;
}
if (!ok) {
/* fprintf(stderr, "not ok %s\n", _mesa_enum_to_string(prim & PRIM_MODE_MASK)); */
return false;
}
}
return true;
}

View File

@ -1,926 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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 <keithw@vmware.com>
*/
/**
* \file t_dd_dmatmp2.h
* Template for render stages which build and emit vertices directly
* to fixed-size dma buffers. Useful for rendering strips and other
* native primitives where clipping and per-vertex tweaks such as
* those in t_dd_tritmp.h are not required.
*
*/
#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)( struct gl_context *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)( struct gl_context *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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
if (start < count) {
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
EMIT_PRIM( ctx, GL_POINTS, HW_POINTS, start, count );
}
}
static void TAG(render_lines_verts)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
GLuint j, nr;
if (0) fprintf(stderr, "%s\n", __func__);
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 );
(void) dest;
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 );
(void) dest;
j += nr;
CLOSE_ELTS();
}
}
}
} else {
TAG(render_line_strip_verts)( ctx, j, count, flags );
}
}
static void TAG(render_triangles_verts)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
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
EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count );
}
static void TAG(render_tri_fan_verts)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
if (start+2 >= count)
return;
EMIT_PRIM( ctx, GL_POLYGON, HW_POLYGON, start, count );
}
static void TAG(render_quad_strip_verts)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
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->Light.ShadeModel == GL_FLAT) {
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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
LOCAL_VARS;
if (0) fprintf(stderr, "%s\n", __func__);
count -= (count-start)%4;
if (start+3 >= count)
return;
if (HAVE_QUADS) {
EMIT_PRIM( ctx, GL_QUADS, HW_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)( struct gl_context *ctx,
GLuint start,
GLuint count,
GLuint flags )
{
}
static tnl_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)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
}
static void TAG(render_lines_elts)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
if ((flags & PRIM_END) && ctx->Line.StippleFlag)
AUTO_STIPPLE( GL_FALSE );
}
static void TAG(render_line_strip_elts)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
}
static void TAG(render_line_loop_elts)( struct gl_context *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", __func__);
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 );
(void) dest;
}
CLOSE_ELTS();
}
}
static void TAG(render_triangles_elts)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
}
static void TAG(render_tri_strip_elts)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
}
static void TAG(render_tri_fan_elts)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
}
static void TAG(render_poly_elts)( struct gl_context *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 );
(void) dest;
CLOSE_ELTS();
}
}
static void TAG(render_quad_strip_elts)( struct gl_context *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->Light.ShadeModel == GL_FLAT) {
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 );
(void) dest;
CLOSE_ELTS();
}
}
}
}
static void TAG(render_quads_elts)( struct gl_context *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 tnl_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),
};

View File

@ -1,157 +0,0 @@
#ifndef DO_DEBUG_VERTS
#define DO_DEBUG_VERTS 0
#endif
#ifndef PRINT_VERTEX
#define PRINT_VERTEX(x)
#endif
#if defined(USE_X86_ASM)
#define COPY_DWORDS( j, vb, vertsize, v ) \
do { \
int __tmp; \
__asm__ __volatile__( "rep ; movsl" \
: "=%c" (j), "=D" (vb), "=S" (__tmp) \
: "0" (vertsize), \
"D" ((long)vb), \
"S" ((long)v) ); \
} while (0)
#else
#define COPY_DWORDS( j, vb, vertsize, v ) \
do { \
for ( j = 0 ; j < vertsize ; j++ ) \
vb[j] = ((GLuint *)v)[j]; \
vb += vertsize; \
} while (0)
#endif
#if HAVE_QUADS
static __inline void TAG(quad)( CTX_ARG,
VERTEX *v0,
VERTEX *v1,
VERTEX *v2,
VERTEX *v3 )
{
GLuint vertsize = GET_VERTEX_DWORDS();
GLuint *vb = (GLuint *)ALLOC_VERTS( 4, vertsize);
GLuint j;
if (DO_DEBUG_VERTS) {
fprintf(stderr, "%s\n", __func__);
PRINT_VERTEX(v0);
PRINT_VERTEX(v1);
PRINT_VERTEX(v2);
PRINT_VERTEX(v3);
}
COPY_DWORDS( j, vb, vertsize, v0 );
COPY_DWORDS( j, vb, vertsize, v1 );
COPY_DWORDS( j, vb, vertsize, v2 );
COPY_DWORDS( j, vb, vertsize, v3 );
}
#else
static __inline void TAG(quad)( CTX_ARG,
VERTEX *v0,
VERTEX *v1,
VERTEX *v2,
VERTEX *v3 )
{
GLuint vertsize = GET_VERTEX_DWORDS();
GLuint *vb = (GLuint *)ALLOC_VERTS( 6, vertsize);
GLuint j;
if (DO_DEBUG_VERTS) {
fprintf(stderr, "%s\n", __func__);
PRINT_VERTEX(v0);
PRINT_VERTEX(v1);
PRINT_VERTEX(v2);
PRINT_VERTEX(v3);
}
COPY_DWORDS( j, vb, vertsize, v0 );
COPY_DWORDS( j, vb, vertsize, v1 );
COPY_DWORDS( j, vb, vertsize, v3 );
COPY_DWORDS( j, vb, vertsize, v1 );
COPY_DWORDS( j, vb, vertsize, v2 );
COPY_DWORDS( j, vb, vertsize, v3 );
}
#endif
static __inline void TAG(triangle)( CTX_ARG,
VERTEX *v0,
VERTEX *v1,
VERTEX *v2 )
{
GLuint vertsize = GET_VERTEX_DWORDS();
GLuint *vb = (GLuint *)ALLOC_VERTS( 3, vertsize);
GLuint j;
if (DO_DEBUG_VERTS) {
fprintf(stderr, "%s\n", __func__);
PRINT_VERTEX(v0);
PRINT_VERTEX(v1);
PRINT_VERTEX(v2);
}
COPY_DWORDS( j, vb, vertsize, v0 );
COPY_DWORDS( j, vb, vertsize, v1 );
COPY_DWORDS( j, vb, vertsize, v2 );
}
#if HAVE_LINES
static __inline void TAG(line)( CTX_ARG,
VERTEX *v0,
VERTEX *v1 )
{
GLuint vertsize = GET_VERTEX_DWORDS();
GLuint *vb = (GLuint *)ALLOC_VERTS( 2, vertsize);
GLuint j;
COPY_DWORDS( j, vb, vertsize, v0 );
COPY_DWORDS( j, vb, vertsize, v1 );
}
#endif
#if HAVE_POINTS
static __inline void TAG(point)( CTX_ARG,
VERTEX *v0 )
{
GLuint vertsize = GET_VERTEX_DWORDS();
GLuint *vb = (GLuint *)ALLOC_VERTS( 1, vertsize);
int j;
COPY_DWORDS( j, vb, vertsize, v0 );
}
#endif
static void TAG(fast_clipped_poly)( struct gl_context *ctx, const GLuint *elts,
GLuint n )
{
LOCAL_VARS
GLuint vertsize = GET_VERTEX_DWORDS();
GLuint *vb = (GLuint *)ALLOC_VERTS( (n-2) * 3, vertsize );
const GLuint *start = (const GLuint *)VERT(elts[0]);
GLuint i,j;
if (DO_DEBUG_VERTS) {
fprintf(stderr, "%s\n", __func__);
PRINT_VERTEX(VERT(elts[0]));
PRINT_VERTEX(VERT(elts[1]));
}
for (i = 2 ; i < n ; i++) {
if (DO_DEBUG_VERTS) {
PRINT_VERTEX(VERT(elts[i]));
}
COPY_DWORDS( j, vb, vertsize, VERT(elts[i-1]) );
COPY_DWORDS( j, vb, vertsize, VERT(elts[i]) );
COPY_DWORDS( j, vb, vertsize, start );
}
}

View File

@ -1,702 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2005 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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 <keithw@vmware.com>
*/
/* 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.
* DO_TWOSTENCIL:Gross hack for two-sided stencil.
*
* 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 constant offset.
* REVERSE_DEPTH: Viewport depth range reversed.
*
* 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 SPEC.
*
* LOCAL_VARS(n): (At least) define local vars for save/restore rgba.
*
*/
#if HAVE_BACK_COLORS
#define VERT_SET_RGBA( v, c )
#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_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
#ifndef REVERSE_DEPTH
#define REVERSE_DEPTH 0
#endif
/* disable twostencil for un-aware drivers */
#ifndef HAVE_STENCIL_TWOSIDE
#define HAVE_STENCIL_TWOSIDE 0
#endif
#ifndef DO_TWOSTENCIL
#define DO_TWOSTENCIL 0
#endif
#ifndef SETUP_STENCIL
#define SETUP_STENCIL(f)
#endif
#ifndef UNSET_STENCIL
#define UNSET_STENCIL(f)
#endif
#if DO_TRI
static void TAG(triangle)( struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e2 )
{
struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
VERTEX *v[3];
GLfloat offset = 0;
GLfloat z[3] = { 0 };
GLenum mode = GL_FILL;
GLuint facing = 0;
LOCAL_VARS(3);
/* fprintf(stderr, "%s\n", __func__); */
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 || DO_TWOSTENCIL)
{
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 || DO_TWOSTENCIL)
{
facing = AREA_IS_CCW( cc ) ^ _mesa_polygon_get_front_bit(ctx);
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_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->BackfaceColorPtr->data;
(void) vbcolor;
if (!DO_FLAT) {
VERT_SAVE_RGBA( 0 );
VERT_SAVE_RGBA( 1 );
}
VERT_SAVE_RGBA( 2 );
if (VB->BackfaceColorPtr->stride) {
assert(VB->BackfaceColorPtr->stride == 4*sizeof(GLfloat));
if (!DO_FLAT) {
VERT_SET_RGBA( v[0], vbcolor[e0] );
VERT_SET_RGBA( v[1], vbcolor[e1] );
}
VERT_SET_RGBA( v[2], vbcolor[e2] );
}
else {
if (!DO_FLAT) {
VERT_SET_RGBA( v[0], vbcolor[0] );
VERT_SET_RGBA( v[1], vbcolor[0] );
}
VERT_SET_RGBA( v[2], vbcolor[0] );
}
if (HAVE_SPEC && VB->BackfaceSecondaryColorPtr) {
GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data;
assert(VB->BackfaceSecondaryColorPtr->stride == 4*sizeof(GLfloat));
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] );
}
}
}
}
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 / ctx->DrawBuffer->_MRD;
}
offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
}
}
if (DO_FLAT) {
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->AttribPtr[_TNL_ATTRIB_COLOR1]) {
VERT_SAVE_SPEC( 0 );
VERT_SAVE_SPEC( 1 );
VERT_COPY_SPEC( v[0], v[2] );
VERT_COPY_SPEC( 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);
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
SETUP_STENCIL(facing);
UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 );
UNSET_STENCIL(facing);
} else {
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);
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
SETUP_STENCIL(facing);
UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 );
UNSET_STENCIL(facing);
} else {
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 );
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
SETUP_STENCIL(facing);
TRI( v[0], v[1], v[2] );
UNSET_STENCIL(facing);
} else {
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 (!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 );
}
}
if (DO_FLAT) {
VERT_RESTORE_RGBA( 0 );
VERT_RESTORE_RGBA( 1 );
if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
VERT_RESTORE_SPEC( 0 );
VERT_RESTORE_SPEC( 1 );
}
}
}
#endif
#if DO_QUAD
#if DO_FULL_QUAD
static void TAG(quadr)( struct gl_context *ctx,
GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
{
struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
VERTEX *v[4];
GLfloat offset = 0;
GLfloat z[4] = { 0 };
GLenum mode = GL_FILL;
GLuint facing = 0;
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 || DO_TWOSTENCIL)
{
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 || DO_TWOSTENCIL)
{
facing = AREA_IS_CCW( cc ) ^ _mesa_polygon_get_front_bit(ctx);
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) {
GLfloat (*vbcolor)[4] = VB->BackfaceColorPtr->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_SAVE_RGBA( 3 );
if (VB->BackfaceColorPtr->stride) {
if (!DO_FLAT) {
VERT_SET_RGBA( v[0], vbcolor[e0] );
VERT_SET_RGBA( v[1], vbcolor[e1] );
VERT_SET_RGBA( v[2], vbcolor[e2] );
}
VERT_SET_RGBA( v[3], vbcolor[e3] );
}
else {
if (!DO_FLAT) {
VERT_SET_RGBA( v[0], vbcolor[0] );
VERT_SET_RGBA( v[1], vbcolor[0] );
VERT_SET_RGBA( v[2], vbcolor[0] );
}
VERT_SET_RGBA( v[3], vbcolor[0] );
}
if (HAVE_SPEC && VB->BackfaceSecondaryColorPtr) {
GLfloat (*vbspec)[4] = VB->BackfaceSecondaryColorPtr->data;
assert(VB->BackfaceSecondaryColorPtr->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] );
}
}
}
}
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 / ctx->DrawBuffer->_MRD;
}
offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
}
}
if (DO_FLAT) {
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->AttribPtr[_TNL_ATTRIB_COLOR1]) {
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] );
}
}
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);
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
SETUP_STENCIL(facing);
UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 );
UNSET_STENCIL(facing);
} else {
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);
}
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
SETUP_STENCIL(facing);
UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 );
UNSET_STENCIL(facing);
} else {
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_QUADS );
if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
SETUP_STENCIL(facing);
QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );
UNSET_STENCIL(facing);
} else {
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 (!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 );
}
}
if (DO_FLAT) {
VERT_RESTORE_RGBA( 0 );
VERT_RESTORE_RGBA( 1 );
VERT_RESTORE_RGBA( 2 );
if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
VERT_RESTORE_SPEC( 0 );
VERT_RESTORE_SPEC( 1 );
VERT_RESTORE_SPEC( 2 );
}
}
}
#else
static void TAG(quadr)( struct gl_context *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)( struct gl_context *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) {
VERT_SAVE_RGBA( 0 );
VERT_COPY_RGBA( v[0], v[1] );
if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
VERT_SAVE_SPEC( 0 );
VERT_COPY_SPEC( v[0], v[1] );
}
}
LINE( v[0], v[1] );
if (DO_FLAT) {
VERT_RESTORE_RGBA( 0 );
if (HAVE_SPEC && VB->AttribPtr[_TNL_ATTRIB_COLOR1]) {
VERT_RESTORE_SPEC( 0 );
}
}
}
#endif
#if DO_POINTS
static void TAG(points)( struct gl_context *ctx, GLuint first, GLuint last )
{
struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
GLuint 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(quadr);
#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_BACK_COLORS
#undef VERT_SET_RGBA
#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_RGBA1
#endif
#ifndef INSANE_VERTICES
#undef VERT_SET_Z
#undef VERT_Z_ADD
#endif

View File

@ -1,170 +0,0 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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 <keithw@vmware.com>
*/
#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)( struct gl_context *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->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
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]);
}
}
/* fprintf(stderr, "%s %s %d %d %d\n", __func__, */
/* _mesa_enum_to_string( 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->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
VERT_RESTORE_RGBA(0);
VERT_RESTORE_RGBA(1);
if (HAVE_SPEC) {
VERT_RESTORE_SPEC(0);
VERT_RESTORE_SPEC(1);
}
}
}
static void TAG(unfilled_quad)( struct gl_context *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->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
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]);
}
}
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->Light.ShadeModel == GL_FLAT && HAVE_HW_FLATSHADE) {
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);
}
}
}
#if !HAVE_SPEC
#undef VERT_SET_SPEC
#undef VERT_COPY_SPEC
#undef VERT_SAVE_SPEC
#undef VERT_RESTORE_SPEC
#endif
#undef TAG

View File

@ -1,78 +0,0 @@
/*
* Mesa 3-D graphics library
*
* 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
* THE AUTHORS OR COPYRIGHT HOLDERS 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 <keithw@vmware.com>
*/
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);