summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_eval_api.c246
-rw-r--r--src/mesa/tnl/t_eval_api.h43
-rw-r--r--src/mesa/tnl/t_imm_api.c1387
-rw-r--r--src/mesa/tnl/t_imm_api.h56
-rw-r--r--src/mesa/tnl/t_imm_elt.c744
-rw-r--r--src/mesa/tnl/t_imm_eval.c868
6 files changed, 0 insertions, 3344 deletions
diff --git a/src/mesa/tnl/t_eval_api.c b/src/mesa/tnl/t_eval_api.c
deleted file mode 100644
index 5e68d7c891..0000000000
--- a/src/mesa/tnl/t_eval_api.c
+++ /dev/null
@@ -1,246 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 5.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 - original code
- * Brian Paul - vertex program updates
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "math/m_eval.h"
-
-#include "t_eval_api.h"
-#include "t_imm_api.h"
-#include "t_imm_alloc.h"
-#include "t_imm_exec.h"
-
-
-/* KW: If are compiling, we don't know whether eval will produce a
- * vertex when it is run in the future. If this is pure immediate
- * mode, eval is a noop if neither vertex map is enabled.
- *
- * Thus we need to have a check in the display list code or
- * elsewhere for eval(1,2) vertices in the case where
- * map(1,2)_vertex is disabled, and to purge those vertices from
- * the vb.
- */
-void GLAPIENTRY
-_tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i;
- GLfloat u, du;
- GLenum prim;
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glEvalMesh1()");
-
- switch (mode) {
- case GL_POINT:
- prim = GL_POINTS;
- break;
- case GL_LINE:
- prim = GL_LINE_STRIP;
- break;
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
- return;
- }
-
- /* No effect if vertex maps disabled.
- */
- if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3 &&
- (!ctx->VertexProgram.Enabled || !ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]))
- return;
-
- du = ctx->Eval.MapGrid1du;
- u = ctx->Eval.MapGrid1u1 + i1 * du;
-
- /* Need to turn off compilation -- this is already saved, and the
- * coordinates generated and the test above depend on state that
- * may change before the list is executed.
- *
- * TODO: Anaylse display lists to determine if this state is
- * constant.
- *
- * State to watch:
- * - enabled maps
- * - map state for each enabled map, including control points
- * - grid state
- *
- * Could alternatively cache individual maps in arrays, rather than
- * building immediates.
- */
- {
- GLboolean compiling = ctx->CompileFlag;
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct immediate *im = TNL_CURRENT_IM(ctx);
- GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
-
- NotifyBegin = tnl->Driver.NotifyBegin;
- tnl->Driver.NotifyBegin = 0;
-
- if (compiling) {
- struct immediate *tmp = _tnl_alloc_immediate( ctx );
- FLUSH_VERTICES( ctx, 0 );
- SET_IMMEDIATE( ctx, tmp );
- TNL_CURRENT_IM(ctx)->ref_count++;
- ctx->CompileFlag = GL_FALSE;
- }
-
- _tnl_Begin( prim );
- for (i=i1;i<=i2;i++,u+=du) {
- _tnl_eval_coord1f( ctx, u );
- }
- _tnl_end_ctx(ctx);
-
- /* Need this for replay *and* compile:
- */
- FLUSH_VERTICES( ctx, 0 );
- tnl->Driver.NotifyBegin = NotifyBegin;
-
- if (compiling) {
- TNL_CURRENT_IM(ctx)->ref_count--;
- ASSERT( TNL_CURRENT_IM(ctx)->ref_count == 0 );
- _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) );
- SET_IMMEDIATE( ctx, im );
- ctx->CompileFlag = GL_TRUE;
- }
- }
-}
-
-
-
-void GLAPIENTRY
-_tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i, j;
- GLfloat u, du, v, dv, v1, u1;
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glEvalMesh2()");
-
- /* No effect if vertex maps disabled.
- */
- if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3 &&
- (!ctx->VertexProgram.Enabled || !ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]))
- return;
-
- du = ctx->Eval.MapGrid2du;
- dv = ctx->Eval.MapGrid2dv;
- v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
- u1 = ctx->Eval.MapGrid2u1 + i1 * du;
-
- /* Need to turn off compilation -- this is already saved, and the
- * coordinates generated and the test above depend on state that
- * may change before the list is executed.
- */
- {
- GLboolean compiling = ctx->CompileFlag;
- struct immediate *im = TNL_CURRENT_IM(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
-
- NotifyBegin = tnl->Driver.NotifyBegin;
- tnl->Driver.NotifyBegin = 0;
-
- if (compiling) {
- struct immediate *tmp = _tnl_alloc_immediate( ctx );
- FLUSH_VERTICES( ctx, 0 );
- SET_IMMEDIATE( ctx, tmp );
- TNL_CURRENT_IM(ctx)->ref_count++;
- ctx->CompileFlag = GL_FALSE;
- }
-
- switch (mode) {
- case GL_POINT:
- _tnl_Begin( GL_POINTS );
- for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- _tnl_eval_coord2f( ctx, u, v );
- }
- }
- _tnl_end_ctx(ctx);
- break;
- case GL_LINE:
- for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- _tnl_Begin( GL_LINE_STRIP );
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- _tnl_eval_coord2f( ctx, u, v );
- }
- _tnl_end_ctx(ctx);
- }
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- _tnl_Begin( GL_LINE_STRIP );
- for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- _tnl_eval_coord2f( ctx, u, v );
- }
- _tnl_end_ctx(ctx);
- }
- break;
- case GL_FILL:
- for (v=v1,j=j1;j<j2;j++,v+=dv) {
- _tnl_Begin( GL_TRIANGLE_STRIP );
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- _tnl_eval_coord2f( ctx, u, v );
- _tnl_eval_coord2f( ctx, u, v+dv );
- }
- _tnl_end_ctx(ctx);
- }
- break;
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
- return;
- }
-
- /* Need this for replay *and* compile:
- */
- FLUSH_VERTICES( ctx, 0 );
- tnl->Driver.NotifyBegin = NotifyBegin;
-
- if (compiling) {
- TNL_CURRENT_IM(ctx)->ref_count--;
- _tnl_free_immediate( ctx, TNL_CURRENT_IM( ctx ) );
- SET_IMMEDIATE( ctx, im );
- ctx->CompileFlag = GL_TRUE;
- }
- }
-}
-
-
-void _tnl_eval_init( GLcontext *ctx )
-{
- GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt);
- vfmt->EvalMesh1 = _tnl_exec_EvalMesh1;
- vfmt->EvalMesh2 = _tnl_exec_EvalMesh2;
-}
diff --git a/src/mesa/tnl/t_eval_api.h b/src/mesa/tnl/t_eval_api.h
deleted file mode 100644
index a24b121b81..0000000000
--- a/src/mesa/tnl/t_eval_api.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-
-#ifndef _T_EVAL_H
-#define _T_EVAL_H
-
-
-#include "mtypes.h"
-#include "t_context.h"
-
-/* Use _mesa_save_EvalMesh{1,2} to save these to display lists.
- */
-extern void GLAPIENTRY _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 );
-
-extern void GLAPIENTRY _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2,
- GLint j1, GLint j2 );
-
-void _tnl_eval_init( GLcontext *ctx );
-
-#endif
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c
deleted file mode 100644
index 52c20285cc..0000000000
--- a/src/mesa/tnl/t_imm_api.c
+++ /dev/null
@@ -1,1387 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * 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 <keith@tungstengraphics.com>
- */
-
-
-
-#include "glheader.h"
-#include "context.h"
-#include "dlist.h"
-#include "enums.h"
-#include "light.h"
-#include "imports.h"
-#include "state.h"
-#include "colormac.h"
-#include "macros.h"
-#include "vtxfmt.h"
-
-#include "t_context.h"
-#include "t_imm_api.h"
-#include "t_imm_elt.h"
-#include "t_imm_exec.h"
-#include "t_imm_dlist.h"
-
-
-/* A cassette is full or flushed on a statechange.
- */
-void _tnl_flush_immediate( GLcontext *ctx, struct immediate *IM )
-{
- if (!ctx) {
- /* We were called by glVertex, glEvalCoord, glArrayElement, etc.
- * The current context is corresponds to the IM structure.
- */
- GET_CURRENT_CONTEXT(context);
- ctx = context;
- }
-
- if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
- _mesa_debug(ctx, "_tnl_flush_immediate IM: %d compiling: %d\n",
- IM->id, ctx->CompileFlag);
-
- if (IM->FlushElt == FLUSH_ELT_EAGER) {
- _tnl_translate_array_elts( ctx, IM, IM->LastPrimitive, IM->Count );
- }
-
- /* Mark the last primitive:
- */
- IM->PrimitiveLength[IM->LastPrimitive] = IM->Count - IM->LastPrimitive;
- IM->Primitive[IM->LastPrimitive] |= PRIM_LAST;
-
- if (ctx->CompileFlag)
- _tnl_compile_cassette( ctx, IM );
- else
- _tnl_execute_cassette( ctx, IM );
-}
-
-
-/* Hook for ctx->Driver.FlushVertices:
- */
-void _tnl_flush_vertices( GLcontext *ctx, GLuint flags )
-{
- struct immediate *IM = TNL_CURRENT_IM(ctx);
-
- if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
- _mesa_debug(ctx,
- "_tnl_flush_vertices flags %x IM(%d) %d..%d Flag[%d]: %x\n",
- flags, IM->id, IM->Start, IM->Count, IM->Start,
- IM->Flag[IM->Start]);
-
- if (IM->Flag[IM->Start]) {
- if ((flags & FLUSH_UPDATE_CURRENT) ||
- IM->Count > IM->Start ||
- (IM->Flag[IM->Start] & (VERT_BIT_BEGIN | VERT_BIT_END))) {
- _tnl_flush_immediate( ctx, IM );
- }
- }
-}
-
-
-void GLAPIENTRY
-_tnl_save_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT(ctx);
- struct immediate *IM = TNL_CURRENT_IM(ctx);
- GLuint inflags, state;
-
-/* _mesa_debug(ctx, "%s: before: %x\n", __FUNCTION__, IM->BeginState); */
-
- if (mode > GL_POLYGON) {
- _mesa_compile_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" );
- return;
- }
-
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
-#if 000
- /* if only a very few slots left, might as well flush now
- */
- if (IM->Count > IMM_MAXDATA-8) {
- _tnl_flush_immediate( ctx, IM );
- IM = TNL_CURRENT_IM(ctx);
- }
-#endif
-
- if (IM->Count > IMM_MAXDATA-8) {
- _tnl_flush_immediate( ctx, IM );
- IM = TNL_CURRENT_IM(ctx);
- }
-
- /* Check for and flush buffered vertices from internal operations.
- */
- if (IM->SavedBeginState) {
- _tnl_flush_immediate( ctx, IM );
- IM = TNL_CURRENT_IM(ctx);
- IM->BeginState = IM->SavedBeginState;
- IM->SavedBeginState = 0;
- }
-
- state = IM->BeginState;
- inflags = state & (VERT_BEGIN_0|VERT_BEGIN_1);
- state |= inflags << 2; /* set error conditions */
-
- if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1))
- {
- GLuint count = IM->Count;
- GLuint last = IM->LastPrimitive;
-
- state |= (VERT_BEGIN_0|VERT_BEGIN_1);
- IM->Flag[count] |= VERT_BIT_BEGIN;
- IM->Primitive[count] = mode | PRIM_BEGIN;
- IM->PrimitiveLength[IM->LastPrimitive] = count - IM->LastPrimitive;
- IM->LastPrimitive = count;
-
- /* Not quite right. Need to use the fallback '_aa_ArrayElement'
- * when not known to be inside begin/end and arrays are
- * unlocked.
- */
- if (IM->FlushElt == FLUSH_ELT_EAGER) {
- _tnl_translate_array_elts( ctx, IM, last, count );
- }
- }
-
- ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
- IM->BeginState = state;
-
- /* Update save_primitive now. Don't touch ExecPrimitive as this is
- * updated in the replay of this cassette if we are in
- * COMPILE_AND_EXECUTE mode.
- */
- if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN)
- ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
- else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END)
- ctx->Driver.CurrentSavePrimitive = mode;
-}
-
-
-void GLAPIENTRY
-_tnl_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- ASSERT (!ctx->CompileFlag);
-
- if (mode > GL_POLYGON) {
- _mesa_error( ctx, GL_INVALID_ENUM, "_tnl_Begin(0x%x)", mode );
- return;
- }
-
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
- _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" );
- return;
- }
-
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
- {
- struct immediate *IM = TNL_CURRENT_IM(ctx);
- if (IM->Count > IMM_MAXDATA-8) {
- _tnl_flush_immediate( ctx, IM );
- IM = TNL_CURRENT_IM(ctx);
- }
- }
-
-
- {
- struct immediate *IM = TNL_CURRENT_IM(ctx);
- GLuint count = IM->Count;
- GLuint last = IM->LastPrimitive;
-
- if (IM->Start == IM->Count &&
- tnl->Driver.NotifyBegin &&
- tnl->Driver.NotifyBegin( ctx, mode )) {
- return;
- }
-
- assert( (IM->SavedBeginState & (VERT_BEGIN_0|VERT_BEGIN_1)) == 0 );
- assert( (IM->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1)) == 0 );
-
- /* Not quite right. Need to use the fallback '_aa_ArrayElement'
- * when not known to be inside begin/end and arrays are
- * unlocked.
- */
- if (IM->FlushElt == FLUSH_ELT_EAGER) {
- _tnl_translate_array_elts( ctx, IM, last, count );
- }
-
- IM->Flag[count] |= VERT_BIT_BEGIN;
- IM->Primitive[count] = mode | PRIM_BEGIN;
- IM->PrimitiveLength[last] = count - last;
- IM->LastPrimitive = count;
- IM->BeginState = (VERT_BEGIN_0|VERT_BEGIN_1);
-
-/* _mesa_debug(ctx, "%s: %x\n", __FUNCTION__, IM->BeginState); */
-
- ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
- ctx->Driver.CurrentExecPrimitive = mode;
- }
-}
-
-
-/* Function which allows operations like 'glRectf' to decompose to a
- * begin/end object and vertices without worrying about what happens
- * with display lists.
- */
-GLboolean
-_tnl_hard_begin( GLcontext *ctx, GLenum p )
-{
-/* _mesa_debug(ctx, "%s\n", __FUNCTION__); */
-
- if (!ctx->CompileFlag) {
- /* If not compiling, treat as a normal begin().
- */
-/* _mesa_debug(ctx, "%s: treating as glBegin\n", __FUNCTION__); */
- glBegin( p );
- return GL_TRUE;
- }
- else {
- /* Otherwise, need to do special processing to preserve the
- * condition that these vertices will only be replayed outside
- * future begin/end objects.
- */
- struct immediate *IM = TNL_CURRENT_IM(ctx);
-
- if (ctx->NewState)
- _mesa_update_state(ctx);
-
- if (IM->Count > IMM_MAXDATA-8) {
- _tnl_flush_immediate( ctx, IM );
- IM = TNL_CURRENT_IM(ctx);
- }
-
- /* A lot depends on the degree to which the display list has
- * constrained the possible begin/end states at this point:
- */
- switch (IM->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1)) {
- case VERT_BEGIN_0|VERT_BEGIN_1:
- /* This is an immediate known to be inside a begin/end object.
- */
- ASSERT(ctx->Driver.CurrentSavePrimitive <= GL_POLYGON);
- IM->BeginState |= (VERT_ERROR_1|VERT_ERROR_0);
- return GL_FALSE;
-
- case VERT_BEGIN_0:
- case VERT_BEGIN_1:
- /* This is a display-list immediate in an unknown begin/end
- * state. Assert it is empty and convert it to a 'hard' one.
- */
- ASSERT(IM->SavedBeginState == 0);
- ASSERT(ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN);
-
- /* Push current beginstate, to be restored later. Don't worry
- * about raising errors.
- */
- IM->SavedBeginState = IM->BeginState;
-
- /* FALLTHROUGH */
-
- case 0:
- /* Unless we have fallen through, this is an immediate known to
- * be outside begin/end objects.
- */
- ASSERT(ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN ||
- ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END);
- ASSERT (IM->FlushElt != FLUSH_ELT_EAGER);
-
- IM->BeginState |= VERT_BEGIN_0|VERT_BEGIN_1;
- IM->Flag[IM->Count] |= VERT_BIT_BEGIN;
- IM->Primitive[IM->Count] = p | PRIM_BEGIN;
- IM->PrimitiveLength[IM->LastPrimitive] = IM->Count - IM->LastPrimitive;
- IM->LastPrimitive = IM->Count;
-
- /* This is necessary as this immediate will not be flushed in
- * _tnl_end() -- we leave it active, hoping to pick up more
- * vertices before the next state change.
- */
- ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
- return GL_TRUE;
-
- default:
- assert (0);
- return GL_TRUE;
- }
- }
-}
-
-
-/* Both streams now outside begin/end.
- *
- * Leave SavedBeginState untouched -- attempt to gather several
- * rects/arrays together in a single immediate struct.
- */
-void
-_tnl_end_ctx( GLcontext *ctx )
-{
- struct immediate *IM = TNL_CURRENT_IM(ctx);
- GLuint state = IM->BeginState;
- GLuint inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1);
-
- /* Not the case if vertices emitted without calling glBegin first:
- */
-/* assert( ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES ); */
-
-
- state |= inflags << 2; /* errors */
-
- if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1))
- {
- GLuint count = IM->Count;
- GLuint last = IM->LastPrimitive;
-
- state &= ~(VERT_BEGIN_0|VERT_BEGIN_1); /* update state */
- IM->Flag[count] |= VERT_BIT_END;
- IM->Primitive[last] |= PRIM_END;
- IM->PrimitiveLength[last] = count - last;
- IM->Primitive[count] = PRIM_OUTSIDE_BEGIN_END; /* removes PRIM_BEGIN
- * flag if length == 0
- */
- IM->LastPrimitive = count;
-
- if (IM->FlushElt == FLUSH_ELT_EAGER) {
- _tnl_translate_array_elts( ctx, IM, last, count );
- }
- }
-
- IM->BeginState = state;
-
- if (!ctx->CompileFlag) {
- if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END)
- _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_End" );
- else
- ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
- }
-
- /* You can set this flag to get the old 'flush_vb on glEnd()'
- * behaviour.
- */
- if (MESA_DEBUG_FLAGS & DEBUG_ALWAYS_FLUSH)
- _tnl_flush_immediate( ctx, IM );
-}
-
-void GLAPIENTRY
-_tnl_End(void)
-{
- GET_CURRENT_CONTEXT(ctx);
-
- _tnl_end_ctx( ctx );
-
- /* Need to keep save primitive uptodate in COMPILE and
- * COMPILE_AND_EXEC modes, need to keep exec primitive uptodate
- * otherwise.
- */
- if (ctx->CompileFlag)
- ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
-}
-
-
-/* If the given vertex attribute array hasn't been allocated yet,
- * allocate it now.
- */
-#define CHECK_ATTRIB_ARRAY(IM, ATTR) \
- if (!IM->Attrib[ATTR]) { \
- IM->Attrib[ATTR] = \
- (GLfloat (*)[4]) _mesa_malloc(IMM_SIZE * 4 * sizeof(GLfloat)); \
- if (!IM->Attrib[ATTR]) { \
- GET_CURRENT_CONTEXT(ctx); \
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glVertex/Normal/etc"); \
- return; \
- } \
- }
-
-
-#define COLOR( r, g, b, a ) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *color; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_COLOR0); \
- color = IM->Attrib[VERT_ATTRIB_COLOR0][count]; \
- color[0] = r; \
- color[1] = g; \
- color[2] = b; \
- color[3] = a; \
- IM->Flag[count] |= VERT_BIT_COLOR0; \
-}
-
-static void GLAPIENTRY
-_tnl_Color3f( GLfloat red, GLfloat green, GLfloat blue )
-{
- COLOR( red, green, blue, 1.0 );
-}
-
-static void GLAPIENTRY
-_tnl_Color3ub( GLubyte red, GLubyte green, GLubyte blue )
-{
- COLOR(UBYTE_TO_FLOAT(red),
- UBYTE_TO_FLOAT(green),
- UBYTE_TO_FLOAT(blue),
- 1.0);
-}
-
-static void GLAPIENTRY
-_tnl_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
-{
- COLOR( red, green, blue, alpha );
-}
-
-static void GLAPIENTRY
-_tnl_Color4ub( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
-{
- COLOR(UBYTE_TO_FLOAT(red),
- UBYTE_TO_FLOAT(green),
- UBYTE_TO_FLOAT(blue),
- UBYTE_TO_FLOAT(alpha));
-}
-
-static void GLAPIENTRY
-_tnl_Color3fv( const GLfloat *v )
-{
- COLOR( v[0], v[1], v[2], 1.0 );
-}
-
-static void GLAPIENTRY
-_tnl_Color3ubv( const GLubyte *v )
-{
- COLOR(UBYTE_TO_FLOAT(v[0]),
- UBYTE_TO_FLOAT(v[1]),
- UBYTE_TO_FLOAT(v[2]),
- 1.0 );
-}
-
-static void GLAPIENTRY
-_tnl_Color4fv( const GLfloat *v )
-{
- COLOR( v[0], v[1], v[2], v[3] );
-}
-
-static void GLAPIENTRY
-_tnl_Color4ubv( const GLubyte *v)
-{
- COLOR(UBYTE_TO_FLOAT(v[0]),
- UBYTE_TO_FLOAT(v[1]),
- UBYTE_TO_FLOAT(v[2]),
- UBYTE_TO_FLOAT(v[3]));
-}
-
-
-
-#define SECONDARY_COLOR( r, g, b ) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *color; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_COLOR1); \
- color = IM->Attrib[VERT_ATTRIB_COLOR1][count]; \
- color[0] = r; \
- color[1] = g; \
- color[2] = b; \
- IM->Flag[count] |= VERT_BIT_COLOR1; \
-}
-
-static void GLAPIENTRY
-_tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue )
-{
- SECONDARY_COLOR( red, green, blue );
-}
-
-static void GLAPIENTRY
-_tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue )
-{
- SECONDARY_COLOR(UBYTE_TO_FLOAT(red),
- UBYTE_TO_FLOAT(green),
- UBYTE_TO_FLOAT(blue));
-}
-
-static void GLAPIENTRY
-_tnl_SecondaryColor3fvEXT( const GLfloat *v )
-{
- SECONDARY_COLOR( v[0], v[1], v[2] );
-}
-
-static void GLAPIENTRY
-_tnl_SecondaryColor3ubvEXT( const GLubyte *v )
-{
- SECONDARY_COLOR(UBYTE_TO_FLOAT(v[0]),
- UBYTE_TO_FLOAT(v[1]),
- UBYTE_TO_FLOAT(v[2]));
-}
-
-
-static void GLAPIENTRY
-_tnl_EdgeFlag( GLboolean flag )
-{
- GLuint count;
- GET_IMMEDIATE;
- count = IM->Count;
- IM->EdgeFlag[count] = flag;
- IM->Flag[count] |= VERT_BIT_EDGEFLAG;
-}
-
-
-static void GLAPIENTRY
-_tnl_EdgeFlagv( const GLboolean *flag )
-{
- GLuint count;
- GET_IMMEDIATE;
- count = IM->Count;
- IM->EdgeFlag[count] = *flag;
- IM->Flag[count] |= VERT_BIT_EDGEFLAG;
-}
-
-
-static void GLAPIENTRY
-_tnl_FogCoordfEXT( GLfloat f )
-{
- GET_IMMEDIATE;
- GLuint count = IM->Count;
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_FOG);
- IM->Attrib[VERT_ATTRIB_FOG][count][0] = f;
- IM->Flag[count] |= VERT_BIT_FOG;
-}
-
-static void GLAPIENTRY
-_tnl_FogCoordfvEXT( const GLfloat *v )
-{
- GET_IMMEDIATE;
- GLuint count = IM->Count;
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_FOG);
- IM->Attrib[VERT_ATTRIB_FOG][count][0] = v[0];
- IM->Flag[count] |= VERT_BIT_FOG;
-}
-
-
-static void GLAPIENTRY
-_tnl_Indexi( GLint c )
-{
- GLuint count;
- GET_IMMEDIATE;
- count = IM->Count;
- IM->Index[count] = c;
- IM->Flag[count] |= VERT_BIT_INDEX;
-}
-
-
-static void GLAPIENTRY
-_tnl_Indexiv( const GLint *c )
-{
- GLuint count;
- GET_IMMEDIATE;
- count = IM->Count;
- IM->Index[count] = *c;
- IM->Flag[count] |= VERT_BIT_INDEX;
-}
-
-
-#define NORMAL( x, y, z ) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *normal; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_NORMAL); \
- normal = IM->Attrib[VERT_ATTRIB_NORMAL][count]; \
- ASSIGN_3V(normal, x,y,z); \
- IM->Flag[count] |= VERT_BIT_NORMAL; \
-}
-
-#if defined(USE_IEEE_foo)
-#define NORMALF( x, y, z ) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- fi_type *normal; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_NORMAL); \
- normal = (fi_type *)IM->Attrib[VERT_ATTRIB_NORMAL][count]; \
- normal[0].i = ((fi_type *)&(x))->i; \
- normal[1].i = ((fi_type *)&(y))->i; \
- normal[2].i = ((fi_type *)&(z))->i; \
- IM->Flag[count] |= VERT_BIT_NORMAL; \
-}
-#else
-#define NORMALF NORMAL
-#endif
-
-static void GLAPIENTRY
-_tnl_Normal3f( GLfloat nx, GLfloat ny, GLfloat nz )
-{
- NORMALF(nx, ny, nz);
-}
-
-
-static void GLAPIENTRY
-_tnl_Normal3fv( const GLfloat *v )
-{
- NORMALF( v[0], v[1], v[2] );
-}
-
-
-
-#define TEXCOORD1(s) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *tc; \
- IM->Flag[count] |= VERT_BIT_TEX0; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \
- ASSIGN_4V(tc,s,0,0,1); \
-}
-
-#define TEXCOORD2(s, t) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *tc; \
- IM->Flag[count] |= VERT_BIT_TEX0; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \
- ASSIGN_4V(tc, s, t, 0, 1); \
-}
-
-#define TEXCOORD3(s, t, u) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *tc; \
- IM->Flag[count] |= VERT_BIT_TEX0; \
- IM->TexSize |= TEX_0_SIZE_3; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \
- ASSIGN_4V(tc, s, t, u, 1); \
-}
-
-#define TEXCOORD4(s, t, u, v) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- GLfloat *tc; \
- IM->Flag[count] |= VERT_BIT_TEX0; \
- IM->TexSize |= TEX_0_SIZE_4; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \
- ASSIGN_4V(tc, s, t, u, v); \
-}
-
-#if defined(USE_IEEE)
-#define TEXCOORD2F(s, t) \
-{ \
- GET_IMMEDIATE; \
- GLuint count = IM->Count; \
- fi_type *tc; \
- IM->Flag[count] |= VERT_BIT_TEX0; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0); \
- tc = (fi_type *)IM->Attrib[VERT_ATTRIB_TEX0][count]; \
- tc[0].i = ((fi_type *)&(s))->i; \
- tc[1].i = ((fi_type *)&(t))->i; \
- tc[2].i = 0; \
- tc[3].i = IEEE_ONE; \
-}
-#else
-#define TEXCOORD2F TEXCOORD2
-#endif
-
-static void GLAPIENTRY
-_tnl_TexCoord1f( GLfloat s )
-{
- TEXCOORD1(s);
-}
-
-
-static void GLAPIENTRY
-_tnl_TexCoord2f( GLfloat s, GLfloat t )
-{
- TEXCOORD2F(s, t);
-}
-
-
-static void GLAPIENTRY
-_tnl_TexCoord3f( GLfloat s, GLfloat t, GLfloat r )
-{
- TEXCOORD3(s, t, r);
-}
-
-static void GLAPIENTRY
-_tnl_TexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q )
-{
- TEXCOORD4(s, t, r, q)
-}
-
-static void GLAPIENTRY
-_tnl_TexCoord1fv( const GLfloat *v )
-{
- TEXCOORD1(v[0]);
-}
-
-static void GLAPIENTRY
-_tnl_TexCoord2fv( const GLfloat *v )
-{
- TEXCOORD2F(v[0], v[1]);
-}
-
-static void GLAPIENTRY
-_tnl_TexCoord3fv( const GLfloat *v )
-{
- TEXCOORD3(v[0], v[1], v[2]);
-}
-
-static void GLAPIENTRY
-_tnl_TexCoord4fv( const GLfloat *v )
-{
- TEXCOORD4(v[0], v[1], v[2], v[3]);
-}
-
-
-
-/* KW: Run into bad problems in vertex copying if we don't fully pad
- * the incoming vertices.
- */
-#define VERTEX2(IM, x,y) \
-{ \
- GLuint count = IM->Count++; \
- GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BIT_POS; \
- ASSIGN_4V(dest, x, y, 0, 1); \
- /*ASSERT(IM->Flag[IM->Count]==0);*/ \
- if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-#define VERTEX3(IM,x,y,z) \
-{ \
- GLuint count = IM->Count++; \
- GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BITS_OBJ_23; \
- ASSIGN_4V(dest, x, y, z, 1); \
- /*ASSERT(IM->Flag[IM->Count]==0);*/ \
- if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-#define VERTEX4(IM, x,y,z,w) \
-{ \
- GLuint count = IM->Count++; \
- GLfloat *dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BITS_OBJ_234; \
- ASSIGN_4V(dest, x, y, z, w); \
- if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-#if defined(USE_IEEE)
-#define VERTEX2F(IM, x, y) \
-{ \
- GLuint count = IM->Count++; \
- fi_type *dest = (fi_type *)IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BIT_POS; \
- dest[0].i = ((fi_type *)&(x))->i; \
- dest[1].i = ((fi_type *)&(y))->i; \
- dest[2].i = 0; \
- dest[3].i = IEEE_ONE; \
- /*ASSERT(IM->Flag[IM->Count]==0);*/ \
- if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-#else
-#define VERTEX2F VERTEX2
-#endif
-
-#if defined(USE_IEEE)
-#define VERTEX3F(IM, x, y, z) \
-{ \
- GLuint count = IM->Count++; \
- fi_type *dest = (fi_type *)IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BITS_OBJ_23; \
- dest[0].i = ((fi_type *)&(x))->i; \
- dest[1].i = ((fi_type *)&(y))->i; \
- dest[2].i = ((fi_type *)&(z))->i; \
- dest[3].i = IEEE_ONE; \
- /*ASSERT(IM->Flag[IM->Count]==0);*/ \
- if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-#else
-#define VERTEX3F VERTEX3
-#endif
-
-#if defined(USE_IEEE)
-#define VERTEX4F(IM, x, y, z, w) \
-{ \
- GLuint count = IM->Count++; \
- fi_type *dest = (fi_type *)IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BITS_OBJ_234; \
- dest[0].i = ((fi_type *)&(x))->i; \
- dest[1].i = ((fi_type *)&(y))->i; \
- dest[2].i = ((fi_type *)&(z))->i; \
- dest[3].i = ((fi_type *)&(w))->i; \
- if (count == IMM_MAXDATA - 1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-#else
-#define VERTEX4F VERTEX4
-#endif
-
-
-
-static void GLAPIENTRY
-_tnl_Vertex2f( GLfloat x, GLfloat y )
-{
- GET_IMMEDIATE;
- VERTEX2F( IM, x, y );
-}
-
-static void GLAPIENTRY
-_tnl_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
-{
- GET_IMMEDIATE;
- VERTEX3F( IM, x, y, z );
-}
-static void GLAPIENTRY
-_tnl_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- GET_IMMEDIATE;
- VERTEX4F( IM, x, y, z, w );
-}
-
-static void GLAPIENTRY
-_tnl_Vertex2fv( const GLfloat *v )
-{
- GET_IMMEDIATE;
- VERTEX2F( IM, v[0], v[1] );
-}
-
-static void GLAPIENTRY
-_tnl_Vertex3fv( const GLfloat *v )
-{
- GET_IMMEDIATE;
- VERTEX3F( IM, v[0], v[1], v[2] );
-}
-
-static void GLAPIENTRY
-_tnl_Vertex4fv( const GLfloat *v )
-{
- GET_IMMEDIATE;
- VERTEX4F( IM, v[0], v[1], v[2], v[3] );
-}
-
-
-
-
-/*
- * GL_ARB_multitexture
- *
- * Note: the multitexture spec says that specifying an invalid target
- * has undefined results and does not have to generate an error. Just
- * don't crash. We no-op on invalid targets.
- */
-
-#define MAX_TARGET (GL_TEXTURE0_ARB + MAX_TEXTURE_COORD_UNITS)
-
-#define MULTI_TEXCOORD1(target, s) \
-{ \
- GET_IMMEDIATE; \
- const GLuint texunit = target - GL_TEXTURE0_ARB; \
- if (texunit < IM->MaxTextureUnits) { \
- const GLuint count = IM->Count; \
- GLfloat *tc; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0 + texunit); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \
- ASSIGN_4V(tc, s, 0.0F, 0.0F, 1.0F); \
- IM->Flag[count] |= VERT_BIT_TEX(texunit); \
- } \
-}
-
-#define MULTI_TEXCOORD2(target, s, t) \
-{ \
- GET_IMMEDIATE; \
- const GLuint texunit = target - GL_TEXTURE0_ARB; \
- if (texunit < IM->MaxTextureUnits) { \
- const GLuint count = IM->Count; \
- GLfloat *tc; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0 + texunit); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \
- ASSIGN_4V(tc, s, t, 0.0F, 1.0F); \
- IM->Flag[count] |= VERT_BIT_TEX(texunit); \
- } \
-}
-
-#define MULTI_TEXCOORD3(target, s, t, u) \
-{ \
- GET_IMMEDIATE; \
- const GLuint texunit = target - GL_TEXTURE0_ARB; \
- if (texunit < IM->MaxTextureUnits) { \
- const GLuint count = IM->Count; \
- GLfloat *tc; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0 + texunit); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \
- ASSIGN_4V(tc, s, t, u, 1.0F); \
- IM->Flag[count] |= VERT_BIT_TEX(texunit); \
- IM->TexSize |= TEX_SIZE_3(texunit); \
- } \
-}
-
-#define MULTI_TEXCOORD4(target, s, t, u, v) \
-{ \
- GET_IMMEDIATE; \
- const GLuint texunit = target - GL_TEXTURE0_ARB; \
- if (texunit < IM->MaxTextureUnits) { \
- const GLuint count = IM->Count; \
- GLfloat *tc; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0 + texunit); \
- tc = IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \
- ASSIGN_4V(tc, s, t, u, v); \
- IM->Flag[count] |= VERT_BIT_TEX(texunit); \
- IM->TexSize |= TEX_SIZE_4(texunit); \
- } \
-}
-
-#if defined(USE_IEEE)
-#define MULTI_TEXCOORD2F(target, s, t) \
-{ \
- GET_IMMEDIATE; \
- const GLuint texunit = target - GL_TEXTURE0_ARB; \
- if (texunit < IM->MaxTextureUnits) { \
- const GLuint count = IM->Count; \
- fi_type *tc; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_TEX0 + texunit); \
- tc = (fi_type *)IM->Attrib[VERT_ATTRIB_TEX0 + texunit][count]; \
- IM->Flag[count] |= VERT_BIT_TEX(texunit); \
- tc[0].i = ((fi_type *)&(s))->i; \
- tc[1].i = ((fi_type *)&(t))->i; \
- tc[2].i = 0; \
- tc[3].i = IEEE_ONE; \
- } \
-}
-#else
-#define MULTI_TEXCOORD2F MULTI_TEXCOORD2
-#endif
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord1fARB(GLenum target, GLfloat s)
-{
- MULTI_TEXCOORD1( target, s );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord1fvARB(GLenum target, const GLfloat *v)
-{
- MULTI_TEXCOORD1( target, v[0] );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
-{
- MULTI_TEXCOORD2F( target, s, t );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord2fvARB(GLenum target, const GLfloat *v)
-{
- MULTI_TEXCOORD2F( target, v[0], v[1] );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r)
-{
- MULTI_TEXCOORD3( target, s, t, r );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord3fvARB(GLenum target, const GLfloat *v)
-{
- MULTI_TEXCOORD3( target, v[0], v[1], v[2] );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
-{
- MULTI_TEXCOORD4( target, s, t, r, q );
-}
-
-static void GLAPIENTRY
-_tnl_MultiTexCoord4fvARB(GLenum target, const GLfloat *v)
-{
- MULTI_TEXCOORD4( target, v[0], v[1], v[2], v[3] );
-}
-
-
-
-/* KW: Because the eval values don't become 'current', fixup will flow
- * through these vertices, and then evaluation will write on top
- * of the fixup results.
- *
- * Note: using Obj to hold eval coord data.
- */
-#define EVALCOORD1(IM, x) \
-{ \
- const GLuint count = IM->Count++; \
- GLfloat *dest; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_POS); \
- dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BIT_EVAL_C1; \
- ASSIGN_4V(dest, x, 0, 0, 1); \
- if (count == IMM_MAXDATA-1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-#define EVALCOORD2(IM, x, y) \
-{ \
- const GLuint count = IM->Count++; \
- GLfloat *dest; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_POS); \
- dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BIT_EVAL_C2; \
- ASSIGN_4V(dest, x, y, 0, 1); \
- if (count == IMM_MAXDATA-1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-#define EVALPOINT1(IM, x) \
-{ \
- const GLuint count = IM->Count++; \
- GLfloat *dest; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_POS); \
- dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BIT_EVAL_P1; \
- ASSIGN_4V(dest, x, 0, 0, 1); \
- if (count == IMM_MAXDATA-1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-#define EVALPOINT2(IM, x, y) \
-{ \
- const GLuint count = IM->Count++; \
- GLfloat *dest; \
- CHECK_ATTRIB_ARRAY(IM, VERT_ATTRIB_POS); \
- dest = IM->Attrib[VERT_ATTRIB_POS][count]; \
- IM->Flag[count] |= VERT_BIT_EVAL_P2; \
- ASSIGN_4V(dest, x, y, 0, 1); \
- if (count == IMM_MAXDATA-1) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-static void GLAPIENTRY
-_tnl_EvalCoord1f( GLfloat u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, u );
-}
-
-static void GLAPIENTRY
-_tnl_EvalCoord1fv( const GLfloat *u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) *u );
-}
-
-static void GLAPIENTRY
-_tnl_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, u, v );
-}
-
-static void GLAPIENTRY
-_tnl_EvalCoord2fv( const GLfloat *u )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, u[0], u[1] );
-}
-
-
-static void GLAPIENTRY
-_tnl_EvalPoint1( GLint i )
-{
- GET_IMMEDIATE;
- EVALPOINT1( IM, (GLfloat) i );
-}
-
-
-static void GLAPIENTRY
-_tnl_EvalPoint2( GLint i, GLint j )
-{
- GET_IMMEDIATE;
- EVALPOINT2( IM, (GLfloat) i, (GLfloat) j );
-}
-
-
-/* Need to use the default array-elt outside begin/end for strict
- * conformance.
- * XXX If ctx->Const.CheckArrayBounds is true, we need to test i against
- * ctx->Array._MaxElement
- */
-#define ARRAY_ELT( IM, i ) \
-{ \
- GLuint count = IM->Count; \
- IM->Elt[count] = i; \
- IM->Flag[count] &= IM->ArrayEltFlags; \
- IM->Flag[count] |= VERT_BIT_ELT; \
- IM->FlushElt = IM->ArrayEltFlush; \
- IM->Count += IM->ArrayEltIncr; \
- if (IM->Count == IMM_MAXDATA) \
- _tnl_flush_immediate( NULL, IM ); \
-}
-
-
-static void GLAPIENTRY
-_tnl_ArrayElement( GLint i )
-{
- GET_IMMEDIATE;
- ARRAY_ELT( IM, i );
-}
-
-
-/* Internal functions. These are safe to use providing either:
- *
- * - It is determined that a display list is not being compiled, or
- * if so that these commands won't be compiled into the list (see
- * t_eval.c for an example).
- *
- * - _tnl_hard_begin() is used instead of _tnl_[bB]egin, and tested
- * for a GL_TRUE return value. See _tnl_Rectf, below.
- */
-void
-_tnl_eval_coord1f( GLcontext *CC, GLfloat u )
-{
- struct immediate *i = TNL_CURRENT_IM(CC);
- EVALCOORD1( i, u );
-}
-
-void
-_tnl_eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v )
-{
- struct immediate *i = TNL_CURRENT_IM(CC);
- EVALCOORD2( i, u, v );
-}
-
-
-
-
-/*
- * NV_vertex_program
- */
-
-static void GLAPIENTRY
-_tnl_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- if (index < VERT_ATTRIB_MAX) {
- GET_IMMEDIATE;
- const GLuint count = IM->Count;
- GLfloat *attrib;
- CHECK_ATTRIB_ARRAY(IM, index);
- attrib = IM->Attrib[index][count];
- ASSIGN_4V(attrib, x, y, z, w);
- IM->Flag[count] |= (1 << index);
- if (index == 0) {
- IM->Count++;
- if (count == IMM_MAXDATA - 1)
- _tnl_flush_immediate( NULL, IM );
- }
- }
- else {
- GET_CURRENT_CONTEXT(ctx);
- _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribNV(index > 15)");
- }
-}
-
-static void GLAPIENTRY
-_tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX) {
- GET_IMMEDIATE;
- const GLuint count = IM->Count;
- GLfloat *attrib;
- CHECK_ATTRIB_ARRAY(IM, index);
- attrib = IM->Attrib[index][count];
- COPY_4V(attrib, v);
- IM->Flag[count] |= (1 << index);
- if (index == 0) {
- IM->Count++;
- if (count == IMM_MAXDATA - 1)
- _tnl_flush_immediate( NULL, IM );
- }
- }
- else {
- GET_CURRENT_CONTEXT(ctx);
- _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribNV(index > 15)");
- }
-}
-
-
-/* Execute a glRectf() function. _tnl_hard_begin() ensures the check
- * on outside_begin_end is executed even in compiled lists. These
- * vertices can now participate in the same immediate as regular ones,
- * even in most display lists.
- */
-static void GLAPIENTRY
-_tnl_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
-{
- GET_CURRENT_CONTEXT(ctx);
-
- if (_tnl_hard_begin( ctx, GL_QUADS )) {
- glVertex2f( x1, y1 );
- glVertex2f( x2, y1 );
- glVertex2f( x2, y2 );
- glVertex2f( x1, y2 );
- glEnd();
- }
-}
-
-static void GLAPIENTRY
-_tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
-{
- GET_CURRENT_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct immediate *IM = TNL_CURRENT_IM(ctx);
- GLuint count = IM->Count;
- struct gl_material *mat;
- GLuint bitmask = _mesa_material_bitmask(ctx, face, pname, ~0, "Materialfv");
- int i, nr;
-
- if (bitmask == 0)
- return;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "_tnl_Materialfv\n");
-
- if (tnl->IsolateMaterials &&
- !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */
- {
- _tnl_flush_immediate( ctx, IM );
- IM = TNL_CURRENT_IM(ctx);
- count = IM->Count;
- }
-
- if (!(IM->Flag[count] & VERT_BIT_MATERIAL)) {
- if (!IM->Material) {
- IM->Material = (struct gl_material *)
- MALLOC( sizeof(struct gl_material) * IMM_SIZE );
- IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE );
- IM->MaterialMask[IM->LastMaterial] = 0;
- }
- else if (IM->MaterialOrMask & ~bitmask) {
- _mesa_copy_materials( &IM->Material[count],
- &IM->Material[IM->LastMaterial],
- IM->MaterialOrMask & ~bitmask );
- }
-
- IM->Flag[count] |= VERT_BIT_MATERIAL;
- IM->MaterialMask[count] = 0;
- IM->MaterialAndMask &= IM->MaterialMask[IM->LastMaterial];
- IM->LastMaterial = count;
- }
-
- IM->MaterialOrMask |= bitmask;
- IM->MaterialMask[count] |= bitmask;
- mat = &IM->Material[count];
-
- switch (face) {
- case GL_SHININESS: nr = 1; break;
- case GL_COLOR_INDEXES: nr = 3; break;
- default: nr = 4 ; break;
- }
-
- for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
- if (bitmask & (1<<i))
- COPY_SZ_4V( mat->Attrib[i], nr, params );
-
- if (tnl->IsolateMaterials &&
- !(IM->BeginState & VERT_BEGIN_1)) /* heuristic */
- {
- _tnl_flush_immediate( ctx, IM );
- }
-}
-
-void _tnl_imm_vtxfmt_init( GLcontext *ctx )
-{
- GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt);
-
- /* All begin/end operations are handled by this vertex format:
- */
- vfmt->ArrayElement = _tnl_ArrayElement;
- vfmt->Begin = _tnl_Begin;
- vfmt->Color3f = _tnl_Color3f;
- vfmt->Color3fv = _tnl_Color3fv;
- vfmt->Color3ub = _tnl_Color3ub;
- vfmt->Color3ubv = _tnl_Color3ubv;
- vfmt->Color4f = _tnl_Color4f;
- vfmt->Color4fv = _tnl_Color4fv;
- vfmt->Color4ub = _tnl_Color4ub;
- vfmt->Color4ubv = _tnl_Color4ubv;
- vfmt->EdgeFlag = _tnl_EdgeFlag;
- vfmt->EdgeFlagv = _tnl_EdgeFlagv;
- vfmt->End = _tnl_End;
- vfmt->EvalCoord1f = _tnl_EvalCoord1f;
- vfmt->EvalCoord1fv = _tnl_EvalCoord1fv;
- vfmt->EvalCoord2f = _tnl_EvalCoord2f;
- vfmt->EvalCoord2fv = _tnl_EvalCoord2fv;
- vfmt->EvalPoint1 = _tnl_EvalPoint1;
- vfmt->EvalPoint2 = _tnl_EvalPoint2;
- vfmt->FogCoordfEXT = _tnl_FogCoordfEXT;
- vfmt->FogCoordfvEXT = _tnl_FogCoordfvEXT;
- vfmt->Indexi = _tnl_Indexi;
- vfmt->Indexiv = _tnl_Indexiv;
- vfmt->Materialfv = _tnl_Materialfv;
- vfmt->MultiTexCoord1fARB = _tnl_MultiTexCoord1fARB;
- vfmt->MultiTexCoord1fvARB = _tnl_MultiTexCoord1fvARB;
- vfmt->MultiTexCoord2fARB = _tnl_MultiTexCoord2fARB;
- vfmt->MultiTexCoord2fvARB = _tnl_MultiTexCoord2fvARB;
- vfmt->MultiTexCoord3fARB = _tnl_MultiTexCoord3fARB;
- vfmt->MultiTexCoord3fvARB = _tnl_MultiTexCoord3fvARB;
- vfmt->MultiTexCoord4fARB = _tnl_MultiTexCoord4fARB;
- vfmt->MultiTexCoord4fvARB = _tnl_MultiTexCoord4fvARB;
- vfmt->Normal3f = _tnl_Normal3f;
- vfmt->Normal3fv = _tnl_Normal3fv;
- vfmt->SecondaryColor3fEXT = _tnl_SecondaryColor3fEXT;
- vfmt->SecondaryColor3fvEXT = _tnl_SecondaryColor3fvEXT;
- vfmt->SecondaryColor3ubEXT = _tnl_SecondaryColor3ubEXT;
- vfmt->SecondaryColor3ubvEXT = _tnl_SecondaryColor3ubvEXT;
- vfmt->TexCoord1f = _tnl_TexCoord1f;
- vfmt->TexCoord1fv = _tnl_TexCoord1fv;
- vfmt->TexCoord2f = _tnl_TexCoord2f;
- vfmt->TexCoord2fv = _tnl_TexCoord2fv;
- vfmt->TexCoord3f = _tnl_TexCoord3f;
- vfmt->TexCoord3fv = _tnl_TexCoord3fv;
- vfmt->TexCoord4f = _tnl_TexCoord4f;
- vfmt->TexCoord4fv = _tnl_TexCoord4fv;
- vfmt->Vertex2f = _tnl_Vertex2f;
- vfmt->Vertex2fv = _tnl_Vertex2fv;
- vfmt->Vertex3f = _tnl_Vertex3f;
- vfmt->Vertex3fv = _tnl_Vertex3fv;
- vfmt->Vertex4f = _tnl_Vertex4f;
- vfmt->Vertex4fv = _tnl_Vertex4fv;
- vfmt->VertexAttrib4fNV = _tnl_VertexAttrib4fNV;
- vfmt->VertexAttrib4fvNV = _tnl_VertexAttrib4fvNV;
-
- /* Outside begin/end functions (from t_varray.c, t_eval.c, ...):
- */
- vfmt->Rectf = _tnl_Rectf;
-
- /* Just use the core function:
- */
- vfmt->CallList = _mesa_CallList;
-
- vfmt->prefer_float_colors = GL_FALSE;
-}
diff --git a/src/mesa/tnl/t_imm_api.h b/src/mesa/tnl/t_imm_api.h
deleted file mode 100644
index a61b0d0228..0000000000
--- a/src/mesa/tnl/t_imm_api.h
+++ /dev/null
@@ -1,56 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 4.1
- *
- * 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.
- */
-
-
-#ifndef _T_VTXFMT_H
-#define _T_VTXFMT_H
-
-#include "mtypes.h"
-#include "t_context.h"
-
-
-extern void GLAPIENTRY _tnl_save_Begin( GLenum mode );
-extern void GLAPIENTRY _tnl_Begin( GLenum mode );
-
-extern void GLAPIENTRY _tnl_Begin( GLenum mode );
-
-extern void GLAPIENTRY _tnl_End(void);
-
-
-/* TNL-private internal functions for building higher-level operations:
- */
-extern GLboolean _tnl_hard_begin( GLcontext *ctx, GLenum p );
-extern void _tnl_end_ctx( GLcontext *ctx );
-extern void _tnl_vertex2f( GLcontext *ctx, GLfloat x, GLfloat y );
-extern void _tnl_eval_coord1f( GLcontext *CC, GLfloat u );
-extern void _tnl_eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v );
-extern void _tnl_array_element( GLcontext *CC, GLint i );
-
-/* Initialize our part of the vtxfmt struct:
- */
-extern void _tnl_imm_vtxfmt_init( GLcontext *ctx );
-
-
-#endif
diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c
deleted file mode 100644
index 50f97a3f20..0000000000
--- a/src/mesa/tnl/t_imm_elt.c
+++ /dev/null
@@ -1,744 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 5.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 <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_translate.h"
-
-#include "t_context.h"
-#include "t_imm_elt.h"
-
-
-
-typedef void (*trans_elt_1ui_func)(GLuint *to,
- CONST void *ptr,
- GLuint stride,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n );
-
-typedef void (*trans_elt_1ub_func)(GLubyte *to,
- CONST void *ptr,
- GLuint stride,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n );
-
-typedef void (*trans_elt_4f_func)(GLfloat (*to)[4],
- CONST void *ptr,
- GLuint stride,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n );
-
-
-
-static trans_elt_1ui_func _tnl_trans_elt_1ui_tab[MAX_TYPES];
-static trans_elt_1ub_func _tnl_trans_elt_1ub_tab[MAX_TYPES];
-static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
-static trans_elt_4f_func _tnl_trans_elt_4fc_tab[5][MAX_TYPES];
-
-
-#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
-
-
-
-/* Code specific to array element implementation. There is a small
- * subtlety in the bits CHECK() tests, and the way bits are set in
- * glArrayElement which ensures that if, eg, in the case that the
- * vertex array is disabled and normal array is enabled, and we get
- * either sequence:
- *
- * ArrayElement() OR Normal()
- * Normal() ArrayElement()
- * Vertex() Vertex()
- *
- * That the correct value for normal is used.
- */
-#define TAB(x) _tnl_trans_elt##x##_tab
-#define ARGS const GLuint *flags, const GLuint *elts, GLuint match, \
- GLuint start, GLuint n
-#define SRC_START 0
-#define DST_START start
-#define CHECK if ((flags[i]&match) == VERT_BIT_ELT)
-#define NEXT_F (void)1
-#define NEXT_F2 f = first + elts[i] * stride;
-
-
-/* GL_BYTE
- */
-#define SRC GLbyte
-#define SRC_IDX TYPE_IDX(GL_BYTE)
-#define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_4FC(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
-#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
-
-
-#define SZ 4
-#define INIT init_trans_4_GLbyte_elt
-#define DEST_4F trans_4_GLbyte_4f_elt
-#define DEST_4FC trans_4_GLbyte_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLbyte_elt
-#define DEST_4F trans_3_GLbyte_4f_elt
-#define DEST_4FC trans_3_GLbyte_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLbyte_elt
-#define DEST_4F trans_2_GLbyte_4f_elt
-#define DEST_4FC trans_2_GLbyte_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLbyte_elt
-#define DEST_4F trans_1_GLbyte_4f_elt
-#define DEST_4FC trans_1_GLbyte_4fc_elt
-#define DEST_1UB trans_1_GLbyte_1ub_elt
-#define DEST_1UI trans_1_GLbyte_1ui_elt
-#include "math/m_trans_tmp.h"
-
-#undef SRC
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-#undef SRC_IDX
-
-/* GL_UNSIGNED_BYTE
- */
-#define SRC GLubyte
-#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
-#define TRX_4F(f,n) UBYTE_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_4FC(f,n) UBYTE_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
-#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
-
-/* 4ub->4ub handled in special case below.
- */
-#define SZ 4
-#define INIT init_trans_4_GLubyte_elt
-#define DEST_4F trans_4_GLubyte_4f_elt
-#define DEST_4FC trans_4_GLubyte_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLubyte_elt
-#define DEST_4F trans_3_GLubyte_4f_elt
-#define DEST_4FC trans_3_GLubyte_4fc_elt
-#include "math/m_trans_tmp.h"
-
-
-#define SZ 1
-#define INIT init_trans_1_GLubyte_elt
-#define DEST_4F trans_1_GLubyte_4f_elt
-#define DEST_4FC trans_1_GLubyte_4fc_elt
-#define DEST_1UB trans_1_GLubyte_1ub_elt
-#define DEST_1UI trans_1_GLubyte_1ui_elt
-#include "math/m_trans_tmp.h"
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-
-/* GL_SHORT
- */
-#define SRC GLshort
-#define SRC_IDX TYPE_IDX(GL_SHORT)
-#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
-#define TRX_4FC(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
-#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
-
-
-#define SZ 4
-#define INIT init_trans_4_GLshort_elt
-#define DEST_4F trans_4_GLshort_4f_elt
-#define DEST_4FC trans_4_GLshort_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLshort_elt
-#define DEST_4F trans_3_GLshort_4f_elt
-#define DEST_4FC trans_3_GLshort_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLshort_elt
-#define DEST_4F trans_2_GLshort_4f_elt
-#define DEST_4FC trans_2_GLshort_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLshort_elt
-#define DEST_4F trans_1_GLshort_4f_elt
-#define DEST_4FC trans_1_GLshort_4fc_elt
-#define DEST_1UB trans_1_GLshort_1ub_elt
-#define DEST_1UI trans_1_GLshort_1ui_elt
-#include "math/m_trans_tmp.h"
-
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-
-/* GL_UNSIGNED_SHORT
- */
-#define SRC GLushort
-#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
-#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
-#define TRX_4FC(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
-#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
-
-
-#define SZ 4
-#define INIT init_trans_4_GLushort_elt
-#define DEST_4F trans_4_GLushort_4f_elt
-#define DEST_4FC trans_4_GLushort_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLushort_elt
-#define DEST_4F trans_3_GLushort_4f_elt
-#define DEST_4FC trans_3_GLushort_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLushort_elt
-#define DEST_4F trans_2_GLushort_4f_elt
-#define DEST_4FC trans_2_GLushort_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLushort_elt
-#define DEST_4F trans_1_GLushort_4f_elt
-#define DEST_4FC trans_1_GLushort_4fc_elt
-#define DEST_1UB trans_1_GLushort_1ub_elt
-#define DEST_1UI trans_1_GLushort_1ui_elt
-#include "math/m_trans_tmp.h"
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-
-/* GL_INT
- */
-#define SRC GLint
-#define SRC_IDX TYPE_IDX(GL_INT)
-#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
-#define TRX_4FC(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
-#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
-
-
-#define SZ 4
-#define INIT init_trans_4_GLint_elt
-#define DEST_4F trans_4_GLint_4f_elt
-#define DEST_4FC trans_4_GLint_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLint_elt
-#define DEST_4F trans_3_GLint_4f_elt
-#define DEST_4FC trans_3_GLint_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLint_elt
-#define DEST_4F trans_2_GLint_4f_elt
-#define DEST_4FC trans_2_GLint_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLint_elt
-#define DEST_4F trans_1_GLint_4f_elt
-#define DEST_4FC trans_1_GLint_4fc_elt
-#define DEST_1UB trans_1_GLint_1ub_elt
-#define DEST_1UI trans_1_GLint_1ui_elt
-#include "math/m_trans_tmp.h"
-
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-
-/* GL_UNSIGNED_INT
- */
-#define SRC GLuint
-#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
-#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
-#define TRX_4FC(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) )
-#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
-#define TRX_UI(f,n) PTR_ELT(f,n)
-
-
-#define SZ 4
-#define INIT init_trans_4_GLuint_elt
-#define DEST_4F trans_4_GLuint_4f_elt
-#define DEST_4FC trans_4_GLuint_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLuint_elt
-#define DEST_4F trans_3_GLuint_4f_elt
-#define DEST_4FC trans_3_GLuint_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLuint_elt
-#define DEST_4F trans_2_GLuint_4f_elt
-#define DEST_4FC trans_2_GLuint_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLuint_elt
-#define DEST_4F trans_1_GLuint_4f_elt
-#define DEST_4FC trans_1_GLuint_4fc_elt
-#define DEST_1UB trans_1_GLuint_1ub_elt
-#define DEST_1UI trans_1_GLuint_1ui_elt
-#include "math/m_trans_tmp.h"
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-
-/* GL_DOUBLE
- */
-#define SRC GLdouble
-#define SRC_IDX TYPE_IDX(GL_DOUBLE)
-#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n)
-#define TRX_4FC(f,n) (GLfloat) PTR_ELT(f,n)
-#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
-#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
-#define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n)
-
-
-#define SZ 4
-#define INIT init_trans_4_GLdouble_elt
-#define DEST_4F trans_4_GLdouble_4f_elt
-#define DEST_4FC trans_4_GLdouble_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLdouble_elt
-#define DEST_4F trans_3_GLdouble_4f_elt
-#define DEST_4FC trans_3_GLdouble_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLdouble_elt
-#define DEST_4F trans_2_GLdouble_4f_elt
-#define DEST_4FC trans_2_GLdouble_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLdouble_elt
-#define DEST_4F trans_1_GLdouble_4f_elt
-#define DEST_4FC trans_1_GLdouble_4fc_elt
-#define DEST_1UB trans_1_GLdouble_1ub_elt
-#define DEST_1UI trans_1_GLdouble_1ui_elt
-#include "math/m_trans_tmp.h"
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-/* GL_FLOAT
- */
-#define SRC GLfloat
-#define SRC_IDX TYPE_IDX(GL_FLOAT)
-#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n)
-#define TRX_4FC(f,n) (GLfloat) PTR_ELT(f,n)
-#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
-#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
-#define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n)
-
-
-#define SZ 4
-#define INIT init_trans_4_GLfloat_elt
-#define DEST_4F trans_4_GLfloat_4f_elt
-#define DEST_4FC trans_4_GLfloat_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 3
-#define INIT init_trans_3_GLfloat_elt
-#define DEST_4F trans_3_GLfloat_4f_elt
-#define DEST_4FC trans_3_GLfloat_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 2
-#define INIT init_trans_2_GLfloat_elt
-#define DEST_4F trans_2_GLfloat_4f_elt
-#define DEST_4FC trans_2_GLfloat_4fc_elt
-#include "math/m_trans_tmp.h"
-
-#define SZ 1
-#define INIT init_trans_1_GLfloat_elt
-#define DEST_4F trans_1_GLfloat_4f_elt
-#define DEST_4FC trans_1_GLfloat_4fc_elt
-#define DEST_1UB trans_1_GLfloat_1ub_elt
-#define DEST_1UI trans_1_GLfloat_1ui_elt
-#include "math/m_trans_tmp.h"
-
-#undef SRC
-#undef SRC_IDX
-#undef TRX_4F
-#undef TRX_4FC
-#undef TRX_UB
-#undef TRX_UI
-
-
-
-
-static void init_translate_elt(void)
-{
- MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
- MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
- MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
- MEMSET( TAB(_4fc), 0, sizeof(TAB(_4fc)) );
-
- init_trans_4_GLbyte_elt();
- init_trans_3_GLbyte_elt();
- init_trans_2_GLbyte_elt();
- init_trans_1_GLbyte_elt();
- init_trans_1_GLubyte_elt();
- init_trans_3_GLubyte_elt();
- init_trans_4_GLubyte_elt();
- init_trans_4_GLshort_elt();
- init_trans_3_GLshort_elt();
- init_trans_2_GLshort_elt();
- init_trans_1_GLshort_elt();
- init_trans_4_GLushort_elt();
- init_trans_3_GLushort_elt();
- init_trans_2_GLushort_elt();
- init_trans_1_GLushort_elt();
- init_trans_4_GLint_elt();
- init_trans_3_GLint_elt();
- init_trans_2_GLint_elt();
- init_trans_1_GLint_elt();
- init_trans_4_GLuint_elt();
- init_trans_3_GLuint_elt();
- init_trans_2_GLuint_elt();
- init_trans_1_GLuint_elt();
- init_trans_4_GLdouble_elt();
- init_trans_3_GLdouble_elt();
- init_trans_2_GLdouble_elt();
- init_trans_1_GLdouble_elt();
- init_trans_4_GLfloat_elt();
- init_trans_3_GLfloat_elt();
- init_trans_2_GLfloat_elt();
- init_trans_1_GLfloat_elt();
-}
-
-
-#undef TAB
-#undef CLASS
-#undef ARGS
-#undef CHECK
-#ifdef START
-#undef START
-#endif
-
-
-
-void _tnl_imm_elt_init( void )
-{
- init_translate_elt();
-}
-
-
-static void _tnl_trans_elt_1ui(GLuint *to,
- const struct gl_client_array *from,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
-{
- const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data );
- _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to,
- fromData,
- from->StrideB,
- flags,
- elts,
- match,
- start,
- n );
-
-}
-
-
-static void _tnl_trans_elt_1ub(GLubyte *to,
- const struct gl_client_array *from,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
-{
- const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data );
- _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to,
- fromData,
- from->StrideB,
- flags,
- elts,
- match,
- start,
- n );
-
-}
-
-static void _tnl_trans_elt_4f(GLfloat (*to)[4],
- const struct gl_client_array *from,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
-{
- const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data );
- _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to,
- fromData,
- from->StrideB,
- flags,
- elts,
- match,
- start,
- n );
-
-}
-
-
-static void _tnl_trans_elt_4fc(GLfloat (*to)[4],
- const struct gl_client_array *from,
- const GLuint *flags,
- const GLuint *elts,
- GLuint match,
- GLuint start,
- GLuint n )
-{
- const GLubyte *fromData = ADD_POINTERS( from->Ptr, from->BufferObj->Data );
- _tnl_trans_elt_4fc_tab[from->Size][TYPE_IDX(from->Type)]( to,
- fromData,
- from->StrideB,
- flags,
- elts,
- match,
- start,
- n );
-
-}
-
-
-
-
-/* Batch function to translate away all the array elements in the
- * input buffer prior to transform. Done only the first time a vertex
- * buffer is executed or compiled.
- *
- * KW: Have to do this after each glEnd if arrays aren't locked.
- */
-void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
- GLuint start, GLuint count )
-{
- GLuint *flags = IM->Flag;
- const GLuint *elts = IM->Elt;
- GLuint translate = ctx->Array._Enabled;
- GLuint translateConventional;
- GLuint attr;
-
- if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
- _mesa_debug(ctx, "exec_array_elements %d .. %d\n", start, count);
-
- /* XXX It would be nice to replace this code with a loop over the vertex
- * attributes but there's a fair number of special cases.
- */
-
- /* Allocate destination attribute arrays if needed */
- ASSERT(IM->Attrib[VERT_ATTRIB_POS]);
- for (attr = 1; attr < VERT_ATTRIB_MAX; attr++) {
- if ((translate & (1 << attr)) && !IM->Attrib[attr]) {
- IM->Attrib[attr] = (GLfloat (*)[4]) _mesa_malloc(IMM_SIZE * 4 * sizeof(GLfloat));
- if (!IM->Attrib[attr]) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "vertex processing2");
- return;
- }
- }
- }
-
- translateConventional = translate;
-
- /*
- * When vertex program mode is enabled, the generic vertex attribute arrays
- * have priority over the conventional arrays. Process those arrays now.
- * When we're done here, translateConventional will indicate which
- * conventional arrays still have to be translated when we're done.
- */
- if (ctx->VertexProgram.Enabled) {
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- const GLuint attrBit = 1 << attr;
- if ((translate & attrBit) && ctx->Array.VertexAttrib[attr].Enabled) {
- _tnl_trans_elt_4f( IM->Attrib[attr],
- &ctx->Array.VertexAttrib[attr],
- flags, elts, (VERT_BIT_ELT | attrBit),
- start, count);
- /* special case stuff */
- if (attr == VERT_ATTRIB_POS) {
- if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Size == 4)
- translate |= VERT_BITS_OBJ_234;
- else if (ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Size == 3)
- translate |= VERT_BITS_OBJ_23;
- }
- else if (attr >= VERT_ATTRIB_TEX0 && attr <= VERT_ATTRIB_TEX7) {
- if (ctx->Array.VertexAttrib[attr].Size == 4)
- IM->TexSize |= TEX_SIZE_4(attr - VERT_ATTRIB_TEX0);
- else if (ctx->Array.VertexAttrib[attr].Size == 3)
- IM->TexSize |= TEX_SIZE_3(attr - VERT_ATTRIB_TEX0);
- }
- /* override the conventional array */
- translateConventional &= ~attrBit;
- }
- }
- }
-
- /*
- * Check which conventional arrays are needed.
- */
- if (translateConventional & VERT_BIT_POS) {
- _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_POS],
- &ctx->Array.Vertex,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_POS),
- start, count);
-
- if (ctx->Array.Vertex.Size == 4)
- translate |= VERT_BITS_OBJ_234;
- else if (ctx->Array.Vertex.Size == 3)
- translate |= VERT_BITS_OBJ_23;
- }
-
- if (translateConventional & VERT_BIT_NORMAL) {
- _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_NORMAL],
- &ctx->Array.Normal,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_NORMAL),
- start, count);
- }
-
- if (translateConventional & VERT_BIT_COLOR0) {
- _tnl_trans_elt_4fc( IM->Attrib[VERT_ATTRIB_COLOR0],
- &ctx->Array.Color,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0),
- start, count);
- }
-
- if (translateConventional & VERT_BIT_COLOR1) {
- _tnl_trans_elt_4fc( IM->Attrib[VERT_ATTRIB_COLOR1],
- &ctx->Array.SecondaryColor,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1),
- start, count);
- }
-
- if (translateConventional & VERT_BIT_FOG) {
- _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_FOG],
- &ctx->Array.FogCoord,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_FOG),
- start, count);
- }
-
- if (translateConventional & VERT_BITS_TEX_ANY) {
- GLuint i;
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
- if (translateConventional & VERT_BIT_TEX(i)) {
- _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i],
- &ctx->Array.TexCoord[i],
- flags, elts, (VERT_BIT_ELT|VERT_BIT_TEX(i)),
- start, count);
-
- if (ctx->Array.TexCoord[i].Size == 4)
- IM->TexSize |= TEX_SIZE_4(i);
- else if (ctx->Array.TexCoord[i].Size == 3)
- IM->TexSize |= TEX_SIZE_3(i);
- }
- }
-
- if (translate & VERT_BIT_INDEX)
- _tnl_trans_elt_1ui( IM->Index,
- &ctx->Array.Index,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_INDEX),
- start, count);
-
- if (translate & VERT_BIT_EDGEFLAG)
- _tnl_trans_elt_1ub( IM->EdgeFlag,
- &ctx->Array.EdgeFlag,
- flags, elts, (VERT_BIT_ELT|VERT_BIT_EDGEFLAG),
- start, count);
-
- {
- GLuint i;
- for (i = start ; i < count ; i++)
- if (flags[i] & VERT_BIT_ELT)
- flags[i] |= translate;
- }
-
- IM->FlushElt = 0;
-}
diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c
deleted file mode 100644
index f72ada7835..0000000000
--- a/src/mesa/tnl/t_imm_eval.c
+++ /dev/null
@@ -1,868 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 5.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 <keith@tungstengraphics.com>
- * Brian Paul - vertex program updates
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "math/m_eval.h"
-
-#include "t_context.h"
-#include "t_imm_debug.h"
-#include "t_imm_eval.h"
-#include "t_imm_exec.h"
-#include "t_imm_fixup.h"
-#include "t_imm_alloc.h"
-
-
-static void eval_points1( GLfloat outcoord[][4],
- GLfloat coord[][4],
- const GLuint *flags,
- GLfloat du, GLfloat u1 )
-{
- GLuint i;
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & VERT_BITS_EVAL_ANY) {
- outcoord[i][0] = coord[i][0];
- outcoord[i][1] = coord[i][1];
- if (flags[i] & VERT_BIT_EVAL_P1)
- outcoord[i][0] = coord[i][0] * du + u1;
- }
-}
-
-static void eval_points2( GLfloat outcoord[][4],
- GLfloat coord[][4],
- const GLuint *flags,
- GLfloat du, GLfloat u1,
- GLfloat dv, GLfloat v1 )
-{
- GLuint i;
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++) {
- if (flags[i] & VERT_BITS_EVAL_ANY) {
- outcoord[i][0] = coord[i][0];
- outcoord[i][1] = coord[i][1];
- if (flags[i] & VERT_BIT_EVAL_P2) {
- outcoord[i][0] = coord[i][0] * du + u1;
- outcoord[i][1] = coord[i][1] * dv + v1;
- }
- }
- }
-}
-
-static const GLubyte dirty_flags[5] = {
- 0, /* not possible */
- VEC_DIRTY_0,
- VEC_DIRTY_1,
- VEC_DIRTY_2,
- VEC_DIRTY_3
-};
-
-
-static void eval1_4f( GLvector4f *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint dimension,
- const struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLfloat (*to)[4] = dest->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- ASSIGN_4V(to[i], 0,0,0,1);
- _math_horner_bezier_curve(map->Points, to[i], u,
- dimension, map->Order);
- }
-
- dest->size = MAX2(dest->size, dimension);
- dest->flags |= dirty_flags[dimension];
-}
-
-
-/* as above, but dest is a gl_client_array */
-static void eval1_4f_ca( struct gl_client_array *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint dimension,
- const struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data);
- GLfloat (*to)[4] = (GLfloat (*)[4]) destData;
- GLuint i;
-
- ASSERT(dest->Type == GL_FLOAT);
- ASSERT(dest->StrideB == 4 * sizeof(GLfloat));
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- ASSIGN_4V(to[i], 0,0,0,1);
- _math_horner_bezier_curve(map->Points, to[i], u,
- dimension, map->Order);
- }
-
- dest->Size = MAX2(dest->Size, (GLint) dimension);
-}
-
-
-static void eval1_1ui( GLvector1ui *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- const struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLuint *to = dest->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat tmp;
- _math_horner_bezier_curve(map->Points, &tmp, u, 1, map->Order);
- to[i] = (GLuint) (GLint) tmp;
- }
-
-}
-
-static void eval1_norm( GLvector4f *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- const struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLfloat (*to)[4] = dest->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- _math_horner_bezier_curve(map->Points, to[i], u, 3, map->Order);
- }
-}
-
-
-static void eval2_obj_norm( GLvector4f *obj_ptr,
- GLvector4f *norm_ptr,
- GLfloat coord[][4],
- GLuint *flags,
- GLuint dimension,
- const struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLfloat (*obj)[4] = obj_ptr->data;
- GLfloat (*normal)[4] = norm_ptr->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- GLfloat du[4], dv[4];
-
- ASSIGN_4V(obj[i], 0,0,0,1);
- _math_de_casteljau_surf(map->Points, obj[i], du, dv, u, v, dimension,
- map->Uorder, map->Vorder);
-
- if (dimension == 4) {
- du[0] = du[0]*obj[i][3] - du[3]*obj[i][0];
- du[1] = du[1]*obj[i][3] - du[3]*obj[i][1];
- du[2] = du[2]*obj[i][3] - du[3]*obj[i][2];
-
- dv[0] = dv[0]*obj[i][3] - dv[3]*obj[i][0];
- dv[1] = dv[1]*obj[i][3] - dv[3]*obj[i][1];
- dv[2] = dv[2]*obj[i][3] - dv[3]*obj[i][2];
- }
-
- CROSS3(normal[i], du, dv);
- NORMALIZE_3FV(normal[i]);
- }
-
- obj_ptr->size = MAX2(obj_ptr->size, dimension);
- obj_ptr->flags |= dirty_flags[dimension];
-}
-
-
-static void eval2_4f( GLvector4f *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint dimension,
- const struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLfloat (*to)[4] = dest->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
-
- _math_horner_bezier_surf(map->Points, to[i], u, v, dimension,
- map->Uorder, map->Vorder);
- }
-
- dest->size = MAX2(dest->size, dimension);
- dest->flags |= dirty_flags[dimension];
-}
-
-
-/* as above, but dest is a gl_client_array */
-static void eval2_4f_ca( struct gl_client_array *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint dimension,
- const struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- const GLubyte *destData = ADD_POINTERS(dest->Ptr, dest->BufferObj->Data);
- GLfloat (*to)[4] = (GLfloat (*)[4]) destData;
- GLuint i;
-
- ASSERT(dest->Type == GL_FLOAT);
- ASSERT(dest->StrideB == 4 * sizeof(GLfloat));
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- _math_horner_bezier_surf(map->Points, to[i], u, v, dimension,
- map->Uorder, map->Vorder);
- }
-
- dest->Size = MAX2(dest->Size, (GLint) dimension);
-}
-
-
-static void eval2_norm( GLvector4f *dest,
- GLfloat coord[][4],
- GLuint *flags,
- const struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLfloat (*to)[4] = dest->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++) {
- if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- _math_horner_bezier_surf(map->Points, to[i], u, v, 3,
- map->Uorder, map->Vorder);
- }
- }
-}
-
-
-static void eval2_1ui( GLvector1ui *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- const struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLuint *to = dest->data;
- GLuint i;
-
- for (i = 0 ; !(flags[i] & VERT_BIT_END_VB) ; i++)
- if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- GLfloat tmp;
- _math_horner_bezier_surf(map->Points, &tmp, u, v, 1,
- map->Uorder, map->Vorder);
-
- to[i] = (GLuint) (GLint) tmp;
- }
-}
-
-
-static void copy_4f( GLfloat to[][4], GLfloat from[][4], GLuint count )
-{
- MEMCPY( to, from, count * sizeof(to[0]));
-}
-
-static void copy_4f_stride( GLfloat to[][4], const GLfloat *from,
- GLuint stride, GLuint count )
-{
- if (stride == 4 * sizeof(GLfloat))
- MEMCPY( to, from, count * sizeof(to[0]));
- else {
- GLuint i;
- for (i = 0 ; i < count ; i++, STRIDE_F(from, stride))
- COPY_4FV( to[i], from );
- }
-}
-
-static void copy_3f( GLfloat to[][4], GLfloat from[][4], GLuint count )
-{
- GLuint i;
- for (i = 0 ; i < count ; i++) {
- COPY_3FV(to[i], from[i]);
- }
-}
-
-
-static void copy_1ui( GLuint to[], const GLuint from[], GLuint count )
-{
- MEMCPY( to, from, (count) * sizeof(to[0]));
-}
-
-
-
-/* Translate eval enabled flags to VERT_* flags.
- */
-static void update_eval( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint eval1 = 0, eval2 = 0;
- GLuint i;
-
- if (ctx->Eval.Map1Index)
- eval1 |= VERT_BIT_INDEX;
-
- if (ctx->Eval.Map2Index)
- eval2 |= VERT_BIT_INDEX;
-
- if (ctx->Eval.Map1Color4)
- eval1 |= VERT_BIT_COLOR0;
-
- if (ctx->Eval.Map2Color4)
- eval2 |= VERT_BIT_COLOR0;
-
- if (ctx->Eval.Map1Normal)
- eval1 |= VERT_BIT_NORMAL;
-
- if (ctx->Eval.Map2Normal)
- eval2 |= VERT_BIT_NORMAL;
-
- if (ctx->Eval.Map1TextureCoord4 ||
- ctx->Eval.Map1TextureCoord3 ||
- ctx->Eval.Map1TextureCoord2 ||
- ctx->Eval.Map1TextureCoord1)
- eval1 |= VERT_BIT_TEX0;
-
- if (ctx->Eval.Map2TextureCoord4 ||
- ctx->Eval.Map2TextureCoord3 ||
- ctx->Eval.Map2TextureCoord2 ||
- ctx->Eval.Map2TextureCoord1)
- eval2 |= VERT_BIT_TEX0;
-
- if (ctx->Eval.Map1Vertex4)
- eval1 |= VERT_BITS_OBJ_234;
-
- if (ctx->Eval.Map1Vertex3)
- eval1 |= VERT_BITS_OBJ_23;
-
- if (ctx->Eval.Map2Vertex4) {
- if (ctx->Eval.AutoNormal)
- eval2 |= VERT_BITS_OBJ_234 | VERT_BIT_NORMAL;
- else
- eval2 |= VERT_BITS_OBJ_234;
- }
- else if (ctx->Eval.Map2Vertex3) {
- if (ctx->Eval.AutoNormal)
- eval2 |= VERT_BITS_OBJ_23 | VERT_BIT_NORMAL;
- else
- eval2 |= VERT_BITS_OBJ_23;
- }
-
- tnl->eval.EvalMap1Flags = eval1;
- tnl->eval.EvalMap2Flags = eval2;
-
- /* GL_NV_vertex_program evaluators */
- eval1 = eval2 = 0;
- for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- if (ctx->Eval.Map1Attrib[i])
- eval1 |= (1 << i);
- if (ctx->Eval.Map2Attrib[i])
- eval2 |= (1 << i);
- }
- tnl->eval.EvalMap1AttribFlags = eval1;
- tnl->eval.EvalMap2AttribFlags = eval2;
-
- tnl->eval.EvalNewState = 0;
-}
-
-
-/* This looks a lot like a pipeline stage, but for various reasons is
- * better handled outside the pipeline, and considered the final stage
- * of fixing up an immediate struct for execution.
- *
- * Really want to cache the results of this function in display lists,
- * at least for EvalMesh commands.
- */
-void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_arrays *tmp = &tnl->imm_inputs;
- struct immediate *store = tnl->eval.im;
- GLuint *flags = IM->Flag + IM->CopyStart;
- GLuint copycount;
- GLuint orflag = IM->OrFlag;
- GLuint any_eval1 = orflag & (VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1);
- GLuint any_eval2 = orflag & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2);
- GLuint req = 0;
- GLuint purge_flags = 0;
- GLfloat (*coord)[4] = IM->Attrib[VERT_ATTRIB_POS] + IM->CopyStart;
- GLuint attr;
-
- if (IM->AndFlag & VERT_BITS_EVAL_ANY)
- copycount = IM->Start - IM->CopyStart; /* just copy copied vertices */
- else
- copycount = IM->Count - IM->CopyStart; /* copy all vertices */
-
- if (!store)
- store = tnl->eval.im = _tnl_alloc_immediate( ctx );
-
- if (tnl->eval.EvalNewState & _NEW_EVAL)
- update_eval( ctx );
-
- if (any_eval1) {
- req |= tnl->pipeline.inputs
- & (tnl->eval.EvalMap1Flags | tnl->eval.EvalMap1AttribFlags);
-
- if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3 &&
- !ctx->Eval.Map1Attrib[0])
- purge_flags = (VERT_BIT_EVAL_P1|VERT_BIT_EVAL_C1);
-
- if (orflag & VERT_BIT_EVAL_P1) {
- eval_points1( store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart,
- coord, flags,
- ctx->Eval.MapGrid1du,
- ctx->Eval.MapGrid1u1);
-
- coord = store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart;
- }
- }
-
- if (any_eval2) {
- req |= tnl->pipeline.inputs
- & (tnl->eval.EvalMap2Flags | tnl->eval.EvalMap2AttribFlags);
-
- if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3 &&
- !ctx->Eval.Map2Attrib[0])
- purge_flags |= (VERT_BIT_EVAL_P2|VERT_BIT_EVAL_C2);
-
- if (orflag & VERT_BIT_EVAL_P2) {
- eval_points2( store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart,
- coord, flags,
- ctx->Eval.MapGrid2du,
- ctx->Eval.MapGrid2u1,
- ctx->Eval.MapGrid2dv,
- ctx->Eval.MapGrid2v1 );
-
- coord = store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart;
- }
- }
-
- /* Allocate vertex attribute storage now */
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if ((req & (1 << attr)) && !store->Attrib[attr]) {
- store->Attrib[attr] = (GLfloat (*)[4]) _mesa_malloc(IMM_SIZE * 4 * sizeof(GLfloat));
- if (!store->Attrib[attr]) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "evaluator processing");
- return;
- }
- }
- }
-
-
- /* Perform the evaluations on active data elements.
- */
- if (req & VERT_BIT_INDEX) {
- GLuint generated = 0;
-
- if (copycount)
- copy_1ui( store->Index + IM->CopyStart, tmp->Index.data, copycount );
-
- tmp->Index.data = store->Index + IM->CopyStart;
- tmp->Index.start = store->Index + IM->CopyStart;
-
- if (ctx->Eval.Map1Index && any_eval1) {
- eval1_1ui( &tmp->Index, coord, flags, &ctx->EvalMap.Map1Index );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
-
- if (ctx->Eval.Map2Index && any_eval2) {
- eval2_1ui( &tmp->Index, coord, flags, &ctx->EvalMap.Map2Index );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- }
-
- if (req & VERT_BIT_COLOR0) {
- GLuint generated = 0;
-
- if (copycount) {
- const GLubyte *destData = ADD_POINTERS(tmp->Color.Ptr, tmp->Color.BufferObj->Data);
- copy_4f_stride( store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart,
- (GLfloat *) destData,
- tmp->Color.StrideB,
- copycount );
- }
-
- tmp->Color.Ptr = (GLubyte *) (store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart);
- tmp->Color.StrideB = 4 * sizeof(GLfloat);
- tmp->Color.Flags = 0;
- tnl->vb.importable_data &= ~VERT_BIT_COLOR0;
-
- if (ctx->VertexProgram.Enabled) {
- tmp->Attribs[VERT_ATTRIB_COLOR0].data =
- store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart;
- tmp->Attribs[VERT_ATTRIB_COLOR0].start =
- (GLfloat *) tmp->Attribs[VERT_ATTRIB_COLOR0].data;
- tmp->Attribs[VERT_ATTRIB_COLOR0].size = 0;
- }
-
- /* Vertex program maps have priority over conventional attribs */
- if (any_eval1) {
- if (ctx->VertexProgram.Enabled
- && ctx->Eval.Map1Attrib[VERT_ATTRIB_COLOR0]) {
- eval1_4f_ca( &tmp->Color, coord, flags, 4,
- &ctx->EvalMap.Map1Attrib[VERT_ATTRIB_COLOR0] );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map1Color4) {
- eval1_4f_ca( &tmp->Color, coord, flags, 4,
- &ctx->EvalMap.Map1Color4 );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- }
-
- if (any_eval2) {
- if (ctx->VertexProgram.Enabled
- && ctx->Eval.Map2Attrib[VERT_ATTRIB_COLOR0]) {
- eval2_4f_ca( &tmp->Color, coord, flags, 4,
- &ctx->EvalMap.Map2Attrib[VERT_ATTRIB_COLOR0] );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- else if (ctx->Eval.Map2Color4) {
- eval2_4f_ca( &tmp->Color, coord, flags, 4,
- &ctx->EvalMap.Map2Color4 );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- }
- }
-
- if (req & VERT_BIT_TEX0) {
- GLuint generated = 0;
-
- if (copycount)
- copy_4f( store->Attrib[VERT_ATTRIB_TEX0] + IM->CopyStart,
- tmp->TexCoord[0].data, copycount );
- else
- tmp->TexCoord[0].size = 0;
-
- tmp->TexCoord[0].data = store->Attrib[VERT_ATTRIB_TEX0] + IM->CopyStart;
- tmp->TexCoord[0].start = (GLfloat *)tmp->TexCoord[0].data;
-
- if (ctx->VertexProgram.Enabled) {
- tmp->Attribs[VERT_ATTRIB_TEX0].data =
- store->Attrib[VERT_ATTRIB_TEX0] + IM->CopyStart;
- tmp->Attribs[VERT_ATTRIB_TEX0].start =
- (GLfloat *) tmp->Attribs[VERT_ATTRIB_TEX0].data;
- tmp->Attribs[VERT_ATTRIB_TEX0].size = 0;
- }
-
- /* Vertex program maps have priority over conventional attribs */
- if (any_eval1) {
- if (ctx->VertexProgram.Enabled
- && ctx->Eval.Map1Attrib[VERT_ATTRIB_TEX0]) {
- eval1_4f( &tmp->TexCoord[0], coord, flags, 4,
- &ctx->EvalMap.Map1Attrib[VERT_ATTRIB_TEX0] );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map1TextureCoord4) {
- eval1_4f( &tmp->TexCoord[0], coord, flags, 4,
- &ctx->EvalMap.Map1Texture4 );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map1TextureCoord3) {
- eval1_4f( &tmp->TexCoord[0], coord, flags, 3,
- &ctx->EvalMap.Map1Texture3 );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map1TextureCoord2) {
- eval1_4f( &tmp->TexCoord[0], coord, flags, 2,
- &ctx->EvalMap.Map1Texture2 );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map1TextureCoord1) {
- eval1_4f( &tmp->TexCoord[0], coord, flags, 1,
- &ctx->EvalMap.Map1Texture1 );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- }
-
- if (any_eval2) {
- if (ctx->VertexProgram.Enabled
- && ctx->Eval.Map2Attrib[VERT_ATTRIB_TEX0]) {
- eval2_4f( &tmp->TexCoord[0], coord, flags, 4,
- &ctx->EvalMap.Map2Attrib[VERT_ATTRIB_TEX0] );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map2TextureCoord4) {
- eval2_4f( &tmp->TexCoord[0], coord, flags, 4,
- &ctx->EvalMap.Map2Texture4 );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- else if (ctx->Eval.Map2TextureCoord3) {
- eval2_4f( &tmp->TexCoord[0], coord, flags, 3,
- &ctx->EvalMap.Map2Texture3 );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- else if (ctx->Eval.Map2TextureCoord2) {
- eval2_4f( &tmp->TexCoord[0], coord, flags, 2,
- &ctx->EvalMap.Map2Texture2 );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- else if (ctx->Eval.Map2TextureCoord1) {
- eval2_4f( &tmp->TexCoord[0], coord, flags, 1,
- &ctx->EvalMap.Map2Texture1 );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- }
- }
-
- if (req & VERT_BIT_NORMAL) {
- GLuint generated = 0;
-
- if (copycount) {
- copy_3f( store->Attrib[VERT_ATTRIB_NORMAL] + IM->CopyStart,
- tmp->Normal.data, copycount );
- }
-
- tmp->Normal.data = store->Attrib[VERT_ATTRIB_NORMAL] + IM->CopyStart;
- tmp->Normal.start = (GLfloat *)tmp->Normal.data;
-
- if (ctx->VertexProgram.Enabled) {
- tmp->Attribs[VERT_ATTRIB_NORMAL].data =
- store->Attrib[VERT_ATTRIB_NORMAL] + IM->CopyStart;
- tmp->Attribs[VERT_ATTRIB_NORMAL].start =
- (GLfloat *) tmp->Attribs[VERT_ATTRIB_NORMAL].data;
- tmp->Attribs[VERT_ATTRIB_NORMAL].size = 0;
- }
-
- if (any_eval1) {
- if (ctx->VertexProgram.Enabled &&
- ctx->Eval.Map1Attrib[VERT_ATTRIB_NORMAL]) {
- eval1_norm( &tmp->Normal, coord, flags,
- &ctx->EvalMap.Map1Attrib[VERT_ATTRIB_NORMAL] );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- else if (ctx->Eval.Map1Normal) {
- eval1_norm( &tmp->Normal, coord, flags, &ctx->EvalMap.Map1Normal );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- }
-
- if (any_eval2) {
- if (ctx->VertexProgram.Enabled &&
- ctx->Eval.Map2Attrib[VERT_ATTRIB_NORMAL]) {
- eval2_norm( &tmp->Normal, coord, flags,
- &ctx->EvalMap.Map2Attrib[VERT_ATTRIB_NORMAL] );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- else if (ctx->Eval.Map2Normal) {
- eval2_norm( &tmp->Normal, coord, flags, &ctx->EvalMap.Map2Normal );
- generated |= VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2;
- }
- }
- }
-
- /* In the AutoNormal case, the copy and assignment of tmp->NormalPtr
- * are done above.
- */
- if (req & VERT_BIT_POS) {
- if (copycount) {
- /* This copy may already have occurred when eliminating
- * glEvalPoint calls:
- */
- if (coord != store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart) {
- copy_4f( store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart,
- tmp->Obj.data, copycount );
- }
- }
- else {
- tmp->Obj.size = 0;
- }
-
- tmp->Obj.data = store->Attrib[VERT_ATTRIB_POS] + IM->CopyStart;
- tmp->Obj.start = (GLfloat *) tmp->Obj.data;
-
-#if 1
- /*tmp->Attribs[0].count = count;*/
- tmp->Attribs[0].data = store->Attrib[0] + IM->CopyStart;
- tmp->Attribs[0].start = (GLfloat *) tmp->Attribs[0].data;
- tmp->Attribs[0].size = 0;
-#endif
-
- /* Note: Normal data is already prepared above.
- */
-
- if (any_eval1) {
- if (ctx->VertexProgram.Enabled &&
- ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]) {
- eval1_4f( &tmp->Obj, coord, flags, 4,
- &ctx->EvalMap.Map1Attrib[VERT_ATTRIB_POS] );
- }
- else if (ctx->Eval.Map1Vertex4) {
- eval1_4f( &tmp->Obj, coord, flags, 4,
- &ctx->EvalMap.Map1Vertex4 );
- }
- else if (ctx->Eval.Map1Vertex3) {
- eval1_4f( &tmp->Obj, coord, flags, 3,
- &ctx->EvalMap.Map1Vertex3 );
- }
- }
-
- if (any_eval2) {
- if (ctx->VertexProgram.Enabled &&
- ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]) {
- if (ctx->Eval.AutoNormal && (req & VERT_BIT_NORMAL))
- eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 4,
- &ctx->EvalMap.Map2Attrib[VERT_ATTRIB_POS] );
- else
- eval2_4f( &tmp->Obj, coord, flags, 4,
- &ctx->EvalMap.Map2Attrib[VERT_ATTRIB_POS] );
- }
- else if (ctx->Eval.Map2Vertex4) {
- if (ctx->Eval.AutoNormal && (req & VERT_BIT_NORMAL))
- eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 4,
- &ctx->EvalMap.Map2Vertex4 );
- else
- eval2_4f( &tmp->Obj, coord, flags, 4,
- &ctx->EvalMap.Map2Vertex4 );
- }
- else if (ctx->Eval.Map2Vertex3) {
- if (ctx->Eval.AutoNormal && (req & VERT_BIT_NORMAL))
- eval2_obj_norm( &tmp->Obj, &tmp->Normal, coord, flags, 3,
- &ctx->EvalMap.Map2Vertex3 );
- else
- eval2_4f( &tmp->Obj, coord, flags, 3,
- &ctx->EvalMap.Map2Vertex3 );
- }
- }
- }
-
-
- if (ctx->VertexProgram.Enabled) {
- /* We already evaluated position, normal, color and texture 0 above.
- * now evaluate any other generic attributes.
- */
- const GLuint skipBits = (VERT_BIT_POS |
- VERT_BIT_NORMAL |
- VERT_BIT_COLOR0 |
- VERT_BIT_TEX0);
- GLuint generated = 0;
- GLuint attr;
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if ((1 << attr) & req & ~skipBits) {
- if (any_eval1 && ctx->Eval.Map1Attrib[attr]) {
- /* evaluate 1-D vertex attrib map [i] */
- eval1_4f( &tmp->Attribs[attr], coord, flags, 4,
- &ctx->EvalMap.Map1Attrib[attr] );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- if (any_eval2 && ctx->Eval.Map2Attrib[attr]) {
- /* evaluate 2-D vertex attrib map [i] */
- eval2_4f( &tmp->Attribs[attr], coord, flags, 4,
- &ctx->EvalMap.Map2Attrib[attr] );
- generated |= VERT_BIT_EVAL_C1|VERT_BIT_EVAL_P1;
- }
- }
- }
- }
-
- /* Calculate new IM->Elts, IM->Primitive, IM->PrimitiveLength for
- * the case where vertex maps are not enabled for some received
- * eval coordinates. In this case those slots in the immediate
- * must be ignored.
- */
- if (purge_flags) {
- const GLuint vertex = VERT_BIT_POS|(VERT_BITS_EVAL_ANY & ~purge_flags);
- GLuint last_new_prim = 0;
- GLuint new_prim_length = 0;
- GLuint next_old_prim = 0;
- struct vertex_buffer *VB = &tnl->vb;
- const GLuint count = VB->Count;
- GLuint i, j;
-
- for (i = 0, j = 0 ; i < count ; i++) {
- if (flags[i] & vertex) {
- store->Elt[j++] = i;
- new_prim_length++;
- }
- if (i == next_old_prim) {
- next_old_prim += VB->PrimitiveLength[i];
- VB->PrimitiveLength[last_new_prim] = new_prim_length;
- VB->Primitive[j] = VB->Primitive[i];
- last_new_prim = j;
- }
- }
-
- VB->Elts = store->Elt;
- _tnl_get_purged_copy_verts( ctx, store );
- }
-
- /* Produce new flags array:
- */
- {
- const GLuint count = tnl->vb.Count + 1;
- GLuint i;
-
- copy_1ui( store->Flag, flags, count );
- tnl->vb.Flag = store->Flag;
- for (i = 0 ; i < count ; i++)
- store->Flag[i] |= req;
- IM->Evaluated = req; /* hack for copying. */
- }
-}