diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2002-10-15 16:56:52 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2002-10-15 16:56:52 +0000 |
commit | 9cfc9dc28b469b65bfd89d6c95b01d51639e9a4b (patch) | |
tree | b3967060cabef5f7200039ae636b51f7c867c947 | |
parent | 0fc8d555095d49bd51a0eae73c38d0541620ac5b (diff) |
checkpoint
31 files changed, 227 insertions, 6555 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index e2b37ccfb4..95552c9d7e 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.27 2002/06/29 19:48:17 brianp Exp $ */ +/* $Id: t_array_api.c,v 1.27.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -360,7 +360,7 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, /** - * Initialize context's vertex array fields. Called during T 'n L context + * Initialize context's vertex array fields. Called during tnl context * creation. */ void _tnl_array_init( GLcontext *ctx ) diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index b949bc639a..749cc56ad2 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $Id: t_array_import.c,v 1.25 2002/06/29 19:48:17 brianp Exp $ */ +/* $Id: t_array_import.c,v 1.25.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -256,81 +256,6 @@ static void _tnl_import_attrib( GLcontext *ctx, -/** - * Callback for VB stages that need to improve the quality of arrays - * bound to the VB. This is only necessary for client arrays which - * have not been transformed at any point in the pipeline. - * \param required - bitmask of VERT_*_BIT flags - * \param flags - bitmask of VEC_* flags (ex: VEC_NOT_WRITABLE) - */ -static void _tnl_upgrade_client_data( GLcontext *ctx, - GLuint required, - GLuint flags ) -{ - GLuint i; - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLboolean writeable = (flags & VEC_NOT_WRITEABLE) != 0; - GLboolean stride = (flags & VEC_BAD_STRIDE) != 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - GLuint ca_flags = 0; - (void) inputs; - - if (writeable || stride) ca_flags |= CA_CLIENT_DATA; - - if ((required & VERT_BIT_CLIP) && VB->ClipPtr == VB->ObjPtr) - required |= VERT_BIT_POS; - -/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ - - if ((required & VERT_BIT_POS) && (VB->ObjPtr->flags & flags)) { - ASSERT(VB->ObjPtr == &inputs->Obj); - _tnl_import_vertex( ctx, writeable, stride ); - VB->importable_data &= ~(VERT_BIT_POS|VERT_BIT_CLIP); - } - - if ((required & VERT_BIT_NORMAL) && (VB->NormalPtr->flags & flags)) { - ASSERT(VB->NormalPtr == &inputs->Normal); - _tnl_import_normal( ctx, writeable, stride ); - VB->importable_data &= ~VERT_BIT_NORMAL; - } - - if ((required & VERT_BIT_COLOR0) && (VB->ColorPtr[0]->Flags & ca_flags)) { - ASSERT(VB->ColorPtr[0] == &inputs->Color); - _tnl_import_color( ctx, GL_FLOAT, writeable, stride ); - VB->importable_data &= ~VERT_BIT_COLOR0; - } - - if ((required & VERT_BIT_COLOR1) && - (VB->SecondaryColorPtr[0]->Flags & ca_flags)) { - ASSERT(VB->SecondaryColorPtr[0] == &inputs->SecondaryColor); - _tnl_import_secondarycolor( ctx, GL_FLOAT, writeable, stride ); - VB->importable_data &= ~VERT_BIT_COLOR1; - } - - if ((required & VERT_BIT_FOG) - && (VB->FogCoordPtr->flags & flags)) { - ASSERT(VB->FogCoordPtr == &inputs->FogCoord); - _tnl_import_fogcoord( ctx, writeable, stride ); - VB->importable_data &= ~VERT_BIT_FOG; - } - - if ((required & VERT_BIT_INDEX) && (VB->IndexPtr[0]->flags & flags)) { - ASSERT(VB->IndexPtr[0] == &inputs->Index); - _tnl_import_index( ctx, writeable, stride ); - VB->importable_data &= ~VERT_BIT_INDEX; - } - - if (required & VERT_BITS_TEX_ANY) - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) - if ((required & VERT_BIT_TEX(i)) && (VB->TexCoordPtr[i]->flags & flags)) { - ASSERT(VB->TexCoordPtr[i] == &inputs->TexCoord[i]); - _tnl_import_texcoord( ctx, i, writeable, stride ); - VB->importable_data &= ~VERT_BIT_TEX(i); - } - - /* XXX not sure what to do here for vertex program arrays */ -} - void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) @@ -344,7 +269,6 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) /* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */ /* _tnl_print_vert_flags(" inputs", inputs); */ /* _tnl_print_vert_flags(" _Enabled", ctx->Array._Enabled); */ -/* _tnl_print_vert_flags(" importable", inputs & VERT_BITS_FIXUP); */ VB->Count = count - start; VB->FirstClipped = VB->Count; @@ -354,8 +278,6 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) VB->Flag = NULL; VB->Primitive = tnl->tmp_primitive; VB->PrimitiveLength = tnl->tmp_primitive_length; - VB->import_data = _tnl_upgrade_client_data; - VB->importable_data = inputs & VERT_BITS_FIXUP; if (ctx->Array.LockCount) { ASSERT(start == (GLint) ctx->Array.LockFirst); diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index db66479dc6..39aa01e005 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.43 2002/10/09 19:45:53 brianp Exp $ */ +/* $Id: t_context.h,v 1.43.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -44,184 +44,84 @@ #define MAX_PIPELINE_STAGES 30 -/* Numbers for sizing immediate structs. - */ -#define IMM_MAX_COPIED_VERTS 3 -#define IMM_MAXDATA (216 + IMM_MAX_COPIED_VERTS) -#define IMM_SIZE (IMM_MAXDATA + MAX_CLIPPED_VERTICES) - - -/* Values for IM->BeginState - */ -#define VERT_BEGIN_0 0x1 /* glBegin (if initially inside beg/end) */ -#define VERT_BEGIN_1 0x2 /* glBegin (if initially outside beg/end) */ -#define VERT_ERROR_0 0x4 /* invalid_operation in initial state 0 */ -#define VERT_ERROR_1 0x8 /* invalid_operation in initial state 1 */ - - -/* Flags to be added to the primitive enum in VB->Primitive. - */ -#define PRIM_MODE_MASK 0xff /* Extract the actual primitive */ -#define PRIM_BEGIN 0x100 /* The prim starts here (not wrapped) */ -#define PRIM_END 0x200 /* The prim ends in this VB (does not wrap) */ -#define PRIM_PARITY 0x400 /* The prim wrapped on an odd number of verts */ -#define PRIM_LAST 0x800 /* No more prims in the VB */ - - /** - * Flags that describe the inputs and outputs of pipeline stages, and - * the contents of a vertex-cassette. We reuse the VERT_BIT_* flags - * defined in mtypes.h and add a bunch of new ones. + * Flags that describe the inputs and outputs of pipeline stages. We + * reuse the VERT_BIT_* flags defined in mtypes.h and add a bunch of + * new ones. */ +#define VERT_ATTRIB_INDEX VERT_ATTRIB_SIX +#define VERT_ATTRIB_EDGEFLAG VERT_ATTRIB_SEVEN +/* */ +#define VERT_ATTRIB_MAT_FRONT_AMBIENT 16 +#define VERT_ATTRIB_MAT_FRONT_DIFFUSE 17 +#define VERT_ATTRIB_MAT_FRONT_SPECULAR 18 +#define VERT_ATTRIB_MAT_FRONT_EMISSION 19 +#define VERT_ATTRIB_MAT_FRONT_SHININESS 20 +#define VERT_ATTRIB_MAT_FRONT_INDEXES 21 +#define VERT_ATTRIB_MAT_BACK_AMBIENT 22 +#define VERT_ATTRIB_MAT_BACK_DIFFUSE 23 +#define VERT_ATTRIB_MAT_BACK_SPECULAR 24 +#define VERT_ATTRIB_MAT_BACK_EMISSION 25 +#define VERT_ATTRIB_MAT_BACK_SHININESS 26 +#define VERT_ATTRIB_MAT_BACK_INDEXES 27 +#define VERT_ATTRIB_BACK_COLOR0 28 +#define VERT_ATTRIB_BACK_COLOR1 29 +#define VERT_ATTRIB_BACK_INDEX 30 + /* bits 0..5 defined in mtypes.h */ #define VERT_BIT_INDEX VERT_BIT_SIX /* a free vertex attrib bit */ #define VERT_BIT_EDGEFLAG VERT_BIT_SEVEN /* a free vertex attrib bit */ /* bits 8..15 defined in mtypes.h */ -#define VERT_BIT_EVAL_C1 (1 << 16) /* imm only */ -#define VERT_BIT_EVAL_C2 (1 << 17) /* imm only */ -#define VERT_BIT_EVAL_P1 (1 << 18) /* imm only */ -#define VERT_BIT_EVAL_P2 (1 << 19) /* imm only */ -#define VERT_BIT_OBJ_3 (1 << 20) /* imm only */ -#define VERT_BIT_OBJ_4 (1 << 21) /* imm only */ -#define VERT_BIT_MATERIAL (1 << 22) /* imm only, but tested in vb code */ -#define VERT_BIT_ELT (1 << 23) /* imm only */ -#define VERT_BIT_BEGIN (1 << 24) /* imm only, but tested in vb code */ -#define VERT_BIT_END (1 << 25) /* imm only, but tested in vb code */ -#define VERT_BIT_END_VB (1 << 26) /* imm only, but tested in vb code */ -#define VERT_BIT_POINT_SIZE (1 << 27) /* vb only, could reuse a bit */ -#define VERT_BIT_EYE VERT_BIT_BEGIN /* vb only, reuse imm bit */ -#define VERT_BIT_CLIP VERT_BIT_END /* vb only, reuse imm bit*/ - - -/* Flags for IM->TexCoordSize. Enough flags for 16 units. - */ -#define TEX_0_SIZE_3 (unsigned)0x1 -#define TEX_0_SIZE_4 (unsigned)0x10001 -#define TEX_SIZE_3(unit) (TEX_0_SIZE_3 << (unit)) -#define TEX_SIZE_4(unit) (TEX_0_SIZE_4 << (unit)) +#define VERT_BIT_MAT_FRONT_AMBIENT (1 << 16) +#define VERT_BIT_MAT_FRONT_DIFFUSE (1 << 17) +#define VERT_BIT_MAT_FRONT_SPECULAR (1 << 18) +#define VERT_BIT_MAT_FRONT_EMISSION (1 << 19) +#define VERT_BIT_MAT_FRONT_SHININESS (1 << 20) +#define VERT_BIT_MAT_FRONT_INDEXES (1 << 21) +#define VERT_BIT_MAT_BACK_AMBIENT (1 << 22) +#define VERT_BIT_MAT_BACK_DIFFUSE (1 << 23) +#define VERT_BIT_MAT_BACK_SPECULAR (1 << 24) +#define VERT_BIT_MAT_BACK_EMISSION (1 << 25) +#define VERT_BIT_MAT_BACK_SHININESS (1 << 26) +#define VERT_BIT_MAT_BACK_INDEXES (1 << 27) +#define VERT_BIT_BACK_COLOR (1 << 28) +#define VERT_BIT_BACK_SPECULAR (1 << 29) + + +#define VERT_BITS_MATERIAL (VERT_BIT_MAT_FRONT_AMBIENT | \ + VERT_BIT_MAT_FRONT_DIFFUSE | \ + VERT_BIT_MAT_FRONT_SPECULAR | \ + VERT_BIT_MAT_FRONT_EMISSION | \ + VERT_BIT_MAT_FRONT_SHININESS_INDEXES | \ + VERT_BIT_MAT_BACK_AMBIENT | \ + VERT_BIT_MAT_BACK_DIFFUSE | \ + VERT_BIT_MAT_BACK_SPECULAR | \ + VERT_BIT_MAT_BACK_EMISSION | \ + VERT_BIT_MAT_BACK_SHININESS_INDEXES) -/* Shorthands. +/* Numbers for sizing immediate structs. */ -#define VERT_BITS_OBJ_23 (VERT_BIT_POS | VERT_BIT_OBJ_3) -#define VERT_BITS_OBJ_234 (VERT_BIT_POS | VERT_BIT_OBJ_3 | VERT_BIT_OBJ_4) - -#define VERT_BITS_TEX_ANY (VERT_BIT_TEX0 | \ - VERT_BIT_TEX1 | \ - VERT_BIT_TEX2 | \ - VERT_BIT_TEX3 | \ - VERT_BIT_TEX4 | \ - VERT_BIT_TEX5 | \ - VERT_BIT_TEX6 | \ - VERT_BIT_TEX7) - -#define VERT_BITS_EVAL_ANY (VERT_BIT_EVAL_C1 | VERT_BIT_EVAL_P1 | \ - VERT_BIT_EVAL_C2 | VERT_BIT_EVAL_P2) - -#define VERT_BITS_FIXUP (VERT_BITS_TEX_ANY | \ - VERT_BIT_COLOR0 | \ - VERT_BIT_COLOR1 | \ - VERT_BIT_FOG | \ - VERT_BIT_INDEX | \ - VERT_BIT_EDGEFLAG | \ - VERT_BIT_NORMAL) - -#define VERT_BITS_CURRENT_DATA (VERT_BITS_FIXUP | \ - VERT_BIT_MATERIAL) - -#define VERT_BITS_DATA (VERT_BITS_TEX_ANY | \ - VERT_BIT_COLOR0 | \ - VERT_BIT_COLOR1 | \ - VERT_BIT_FOG | \ - VERT_BIT_INDEX | \ - VERT_BIT_EDGEFLAG | \ - VERT_BIT_NORMAL | \ - VERT_BIT_POS | \ - VERT_BIT_MATERIAL | \ - VERT_BIT_ELT | \ - VERT_BITS_EVAL_ANY) +#define IMM_MAX_COPIED_VERTS 3 -/** - * KW: Represents everything that can take place between a begin and - * end, and can represent multiple begin/end pairs. Can be used to - * losslessly encode this information in display lists. +/* Storage for vertices generated by. */ -struct immediate +struct vertex_block { - GLuint id, ref_count; + GLuint refcount; + GLuint vertex_format[4]; + GLubyte *verts; +} - /* This must be saved when immediates are shared in display lists. - */ - GLuint CopyStart, Start, Count; - GLuint LastData; /* count or count+1 */ - GLuint AndFlag, OrFlag; - GLuint TexSize; /* keep track of texcoord sizes */ - GLuint BeginState, SavedBeginState; - GLuint LastPrimitive; - GLuint ArrayEltFlags; /* precalc'ed for glArrayElt */ - GLuint ArrayEltIncr; - GLuint ArrayEltFlush; - -#define FLUSH_ELT_EAGER 0x1 -#define FLUSH_ELT_LAZY 0x2 - GLuint FlushElt; - - GLuint MaxTextureUnits; /* precalc'ed for glMultiTexCoordARB */ - - /* Temporary values created when vertices are copied into the - * first 3 slots of the struct: - */ - GLuint CopyOrFlag; - GLuint CopyAndFlag; - GLuint CopyTexSize; - GLuint Evaluated; - - - /* allocate storage for these on demand: - */ - struct gl_material (*Material)[2]; - GLuint *MaterialMask; - GLuint LastMaterial; - GLuint MaterialOrMask; - GLuint MaterialAndMask; - - GLuint Primitive[IMM_SIZE]; /* BEGIN/END */ - GLuint PrimitiveLength[IMM_SIZE]; /* BEGIN/END */ - GLuint Flag[IMM_SIZE]; /* VERT_BIT_* flags */ - - /* All vertex attributes (position, normal, color, secondary color, - * texcoords, fog coord) are stored in the Attrib[] arrays instead - * of individual arrays as we did prior to Mesa 4.1. - * - * XXX may need to use 32-byte aligned allocation for this!!! - */ - GLfloat Attrib[VERT_ATTRIB_MAX][IMM_SIZE][4]; /* GL_NV_vertex_program */ - - GLfloat *NormalLengthPtr; /* length of normal vectors (display list only) */ - - GLuint Elt[IMM_SIZE]; - GLubyte EdgeFlag[IMM_SIZE]; - GLuint Index[IMM_SIZE]; +struct r200_prim { + GLuint start; + GLuint end; + GLuint prim; }; -struct vertex_arrays -{ - /* XXX move a bunch of these fields into the Attribs[] array??? */ - GLvector4f Obj; - GLvector4f Normal; - struct gl_client_array Color; - struct gl_client_array SecondaryColor; - GLvector1ui Index; - GLvector1ub EdgeFlag; - GLvector4f TexCoord[MAX_TEXTURE_UNITS]; - GLvector1ui Elt; - GLvector4f FogCoord; - GLvector4f Attribs[VERT_ATTRIB_MAX]; -}; - /** * Contains the current state of a running pipeline. @@ -240,41 +140,21 @@ typedef struct vertex_buffer /* Pointers to current data. */ - GLuint *Elts; /* VERT_BIT_ELT */ - GLvector4f *ObjPtr; /* VERT_BIT_POS */ - GLvector4f *EyePtr; /* VERT_BIT_EYE */ - GLvector4f *ClipPtr; /* VERT_BIT_CLIP */ - GLvector4f *NdcPtr; /* VERT_BIT_CLIP (2) */ - GLubyte ClipOrMask; /* VERT_BIT_CLIP (3) */ - GLubyte *ClipMask; /* VERT_BIT_CLIP (4) */ - GLvector4f *NormalPtr; /* VERT_BIT_NORMAL */ - GLfloat *NormalLengthPtr; /* VERT_BIT_NORMAL */ - GLboolean *EdgeFlag; /* VERT_BIT_EDGEFLAG */ - GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */ - GLvector1ui *IndexPtr[2]; /* VERT_BIT_INDEX */ - struct gl_client_array *ColorPtr[2]; /* VERT_BIT_COLOR0 */ - struct gl_client_array *SecondaryColorPtr[2];/* VERT_BIT_COLOR1 */ - GLvector4f *PointSizePtr; /* VERT_BIT_POINT_SIZE */ - GLvector4f *FogCoordPtr; /* VERT_BIT_FOG */ - struct gl_material (*Material)[2]; /* VERT_BIT_MATERIAL, optional */ - GLuint *MaterialMask; /* VERT_BIT_MATERIAL, optional */ - GLuint *Flag; /* VERT_BIT_* flags, optional */ - GLuint *Primitive; /* GL_(mode)|PRIM_* flags */ - GLuint *PrimitiveLength; /* integers */ - - /* Inputs to the vertex program stage */ - GLvector4f *AttribPtr[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */ - - GLuint importable_data; - void *import_source; - void (*import_data)( GLcontext *ctx, GLuint flags, GLuint vecflags ); - /* Callback to the provider of the untransformed input for the - * render stage (or other stages) to call if they need to write into - * write-protected arrays, or fixup the stride on input arrays. - * - * This is currently only necessary for client arrays that make it - * as far down the pipeline as the render stage. + GLuint *Elts; + GLvector4f *EyePtr; + GLvector4f *ClipPtr; + GLvector4f *NdcPtr; + GLubyte ClipOrMask; + GLubyte *ClipMask; + GLfloat *NormalLengthPtr; + GLvector4f *PointSizePtr; /* why not just a float *? */ + + struct tnl_prim *Primitive; /* primitive descriptors */ + GLuint nrPrimitives; /* nr */ + + /* All other vertex data */ + GLvector4f *AttribPtr[TNL_ATTRIB_MAX]; GLuint LastClipped; /* Private data from _tnl_render_stage that has no business being @@ -516,7 +396,7 @@ typedef struct { * Will add save versions to precompute vertex copying where * possible. */ - struct immediate *ExecCopySource; + struct vertex_block *ExecCopySource; GLuint ExecCopyCount; GLuint ExecCopyElts[IMM_MAX_COPIED_VERTS]; GLuint ExecCopyTexSize; @@ -526,9 +406,6 @@ typedef struct { GLuint DlistPrimitiveLength; GLuint DlistLastPrimitive; - /* Cache a single free immediate (refcount == 0) - */ - struct immediate *freed_immediate; /* Probably need a better configuration mechanism: */ @@ -541,10 +418,10 @@ typedef struct { */ struct tnl_eval_store eval; - /* Functions to be plugged into dispatch when tnl is active. + /* We have our own dispatch table for EXECUTE modes. In COMPILE + * and COMPILE_AND_EXECUTE, we plug directly into ctx->Save. */ - GLvertexformat vtxfmt; - GLvertexformat save_vtxfmt; + struct _glapi_table *Exec; /* Execute funcs */ } TNLcontext; diff --git a/src/mesa/tnl/t_imm_alloc.c b/src/mesa/tnl/t_imm_alloc.c deleted file mode 100644 index 76bfd16512..0000000000 --- a/src/mesa/tnl/t_imm_alloc.c +++ /dev/null @@ -1,124 +0,0 @@ -/* $Id: t_imm_alloc.c,v 1.15 2002/04/19 12:32:14 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.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 <keithw@valinux.com> - */ - -#include "glheader.h" -#include "mem.h" -#include "mtypes.h" - -#include "t_imm_alloc.h" - - -static int id = 0; /* give each struct immediate a unique ID number */ - -static struct immediate *real_alloc_immediate( GLcontext *ctx ) -{ - struct immediate *IM = ALIGN_CALLOC_STRUCT( immediate, 32 ); - - if (!IM) - return 0; - -/* memset(IM, 0, sizeof(*IM)); */ - - IM->id = id++; - IM->ref_count = 0; - IM->FlushElt = 0; - IM->LastPrimitive = IMM_MAX_COPIED_VERTS; - IM->Count = IMM_MAX_COPIED_VERTS; - IM->Start = IMM_MAX_COPIED_VERTS; - IM->Material = 0; - IM->MaterialMask = 0; - IM->MaxTextureUnits = ctx->Const.MaxTextureUnits; - IM->TexSize = 0; - IM->NormalLengthPtr = 0; - - IM->CopyTexSize = 0; - IM->CopyStart = IM->Start; - - return IM; -} - - -static void real_free_immediate( struct immediate *IM ) -{ - static int freed = 0; - - if (IM->Material) { - FREE( IM->Material ); - FREE( IM->MaterialMask ); - IM->Material = 0; - IM->MaterialMask = 0; - } - - if (IM->NormalLengthPtr) - ALIGN_FREE( IM->NormalLengthPtr ); - - ALIGN_FREE( IM ); - freed++; -/* printf("outstanding %d\n", id - freed); */ -} - - -/* Cache a single allocated immediate struct. - */ -struct immediate *_tnl_alloc_immediate( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct immediate *tmp = tnl->freed_immediate; - - if (tmp) { - tnl->freed_immediate = 0; - return tmp; - } - else - return real_alloc_immediate( ctx ); -} - -/* May be called after tnl is destroyed. - */ -void _tnl_free_immediate( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - ASSERT(IM->ref_count == 0); - - if (IM->NormalLengthPtr) { - ALIGN_FREE(IM->NormalLengthPtr); - IM->NormalLengthPtr = NULL; - } - - if (!tnl) { - real_free_immediate( IM ); - } - else { - if (tnl->freed_immediate) - real_free_immediate( tnl->freed_immediate ); - - tnl->freed_immediate = IM; - } -} diff --git a/src/mesa/tnl/t_imm_alloc.h b/src/mesa/tnl/t_imm_alloc.h deleted file mode 100644 index 862daf224d..0000000000 --- a/src/mesa/tnl/t_imm_alloc.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $Id: t_imm_alloc.h,v 1.3 2002/04/19 12:32:14 brianp Exp $ */ - -/* - * 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_IMM_ALLOC_H -#define _T_IMM_ALLOC_H - -#include "mtypes.h" -#include "t_context.h" - - -extern struct immediate *_tnl_alloc_immediate( GLcontext *ctx ); - -extern void _tnl_free_immediate( GLcontext *ctx, struct immediate *im ); - - -#endif diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c deleted file mode 100644 index 9f9d4ab5d1..0000000000 --- a/src/mesa/tnl/t_imm_api.c +++ /dev/null @@ -1,1368 +0,0 @@ -/* $Id: t_imm_api.c,v 1.33 2002/10/09 19:38:32 brianp Exp $ */ - -/* - * 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. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - */ - - - -#include "glheader.h" -#include "context.h" -#include "dlist.h" -#include "enums.h" -#include "light.h" -#include "mem.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 -_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 - - /* 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 -_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); - 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 == 0 ); - assert( IM->BeginState == 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( GLcontext *ctx ) -{ - struct immediate *IM = TNL_CURRENT_IM(ctx); - GLuint state = IM->BeginState; - GLuint inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1); - - 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 -_tnl_End(void) -{ - GET_CURRENT_CONTEXT(ctx); - - _tnl_end( 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; -} - - -#define COLOR( r, g, b, a ) \ -{ \ - GET_IMMEDIATE; \ - GLuint count = IM->Count; \ - GLfloat *color = IM->Attrib[VERT_ATTRIB_COLOR0][count]; \ - IM->Flag[count] |= VERT_BIT_COLOR0; \ - color[0] = r; \ - color[1] = g; \ - color[2] = b; \ - color[3] = a; \ -} - -static void -_tnl_Color3f( GLfloat red, GLfloat green, GLfloat blue ) -{ - COLOR( red, green, blue, 1.0 ); -} - -static void -_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 -_tnl_Color4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) -{ - COLOR( red, green, blue, alpha ); -} - -static void -_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 -_tnl_Color3fv( const GLfloat *v ) -{ - COLOR( v[0], v[1], v[2], 1.0 ); -} - -static void -_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 -_tnl_Color4fv( const GLfloat *v ) -{ - COLOR( v[0], v[1], v[2], v[3] ); -} - -static void -_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 ) \ -{ \ - GLuint count; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_COLOR1; \ - IM->Attrib[VERT_ATTRIB_COLOR1][count][0] = r; \ - IM->Attrib[VERT_ATTRIB_COLOR1][count][1] = g; \ - IM->Attrib[VERT_ATTRIB_COLOR1][count][2] = b; \ -} - -static void -_tnl_SecondaryColor3fEXT( GLfloat red, GLfloat green, GLfloat blue ) -{ - SECONDARY_COLOR( red, green, blue ); -} - -static void -_tnl_SecondaryColor3ubEXT( GLubyte red, GLubyte green, GLubyte blue ) -{ - SECONDARY_COLOR(UBYTE_TO_FLOAT(red), - UBYTE_TO_FLOAT(green), - UBYTE_TO_FLOAT(blue)); -} - -static void -_tnl_SecondaryColor3fvEXT( const GLfloat *v ) -{ - SECONDARY_COLOR( v[0], v[1], v[2] ); -} - -static void -_tnl_SecondaryColor3ubvEXT( const GLubyte *v ) -{ - SECONDARY_COLOR(UBYTE_TO_FLOAT(v[0]), - UBYTE_TO_FLOAT(v[1]), - UBYTE_TO_FLOAT(v[2])); -} - - -static void -_tnl_EdgeFlag( GLboolean flag ) -{ - GLuint count; - GET_IMMEDIATE; - count = IM->Count; - IM->EdgeFlag[count] = flag; - IM->Flag[count] |= VERT_BIT_EDGEFLAG; -} - - -static void -_tnl_EdgeFlagv( const GLboolean *flag ) -{ - GLuint count; - GET_IMMEDIATE; - count = IM->Count; - IM->EdgeFlag[count] = *flag; - IM->Flag[count] |= VERT_BIT_EDGEFLAG; -} - - -static void -_tnl_FogCoordfEXT( GLfloat f ) -{ - GLuint count; - GET_IMMEDIATE; - count = IM->Count; - IM->Attrib[VERT_ATTRIB_FOG][count][0] = f; /*FogCoord[count] = f;*/ - IM->Flag[count] |= VERT_BIT_FOG; -} - -static void -_tnl_FogCoordfvEXT( const GLfloat *v ) -{ - GLuint count; - GET_IMMEDIATE; - count = IM->Count; - IM->Attrib[VERT_ATTRIB_FOG][count][0] = v[0]; /*FogCoord[count] = v[0];*/ - IM->Flag[count] |= VERT_BIT_FOG; -} - - -static void -_tnl_Indexi( GLint c ) -{ - GLuint count; - GET_IMMEDIATE; - count = IM->Count; - IM->Index[count] = c; - IM->Flag[count] |= VERT_BIT_INDEX; -} - - -static void -_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 ) \ -{ \ - GLuint count; \ - GLfloat *normal; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_NORMAL; \ - normal = IM->Attrib[VERT_ATTRIB_NORMAL][count]; \ - ASSIGN_3V(normal, x,y,z); \ -} - -#if defined(USE_IEEE) -#define NORMALF( x, y, z ) \ -{ \ - GLuint count; \ - fi_type *normal; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_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; \ -} -#else -#define NORMALF NORMAL -#endif - -static void -_tnl_Normal3f( GLfloat nx, GLfloat ny, GLfloat nz ) -{ - NORMALF(nx, ny, nz); -} - - -static void -_tnl_Normal3fv( const GLfloat *v ) -{ - NORMALF( v[0], v[1], v[2] ); -/* struct immediate *IM = (struct immediate *)(((GLcontext *) _glapi_Context)->swtnl_im); */ -/* IM->Flag[IM->Count] = VERT_NORM; */ -} - - - -#define TEXCOORD1(s) \ -{ \ - GLuint count; \ - GLfloat *tc; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_TEX0; \ - tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ - ASSIGN_4V(tc,s,0,0,1); \ -} - -#define TEXCOORD2(s, t) \ -{ \ - GLuint count; \ - GLfloat *tc; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_TEX0; \ - tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ - ASSIGN_4V(tc, s, t, 0, 1); \ -} - -#define TEXCOORD3(s, t, u) \ -{ \ - GLuint count; \ - GLfloat *tc; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_TEX0; \ - IM->TexSize |= TEX_0_SIZE_3; \ - tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ - ASSIGN_4V(tc, s, t, u, 1); \ -} - -#define TEXCOORD4(s, t, u, v) \ -{ \ - GLuint count; \ - GLfloat *tc; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_TEX0; \ - IM->TexSize |= TEX_0_SIZE_4; \ - tc = IM->Attrib[VERT_ATTRIB_TEX0][count]; \ - ASSIGN_4V(tc, s, t, u, v); \ -} - -#if defined(USE_IEEE) -#define TEXCOORD2F(s, t) \ -{ \ - GLuint count; \ - fi_type *tc; \ - GET_IMMEDIATE; \ - count = IM->Count; \ - IM->Flag[count] |= VERT_BIT_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 -_tnl_TexCoord1f( GLfloat s ) -{ - TEXCOORD1(s); -} - - -static void -_tnl_TexCoord2f( GLfloat s, GLfloat t ) -{ - TEXCOORD2F(s, t); -} - - -static void -_tnl_TexCoord3f( GLfloat s, GLfloat t, GLfloat r ) -{ - TEXCOORD3(s, t, r); -} - -static void -_tnl_TexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) -{ - TEXCOORD4(s, t, r, q) -} - -static void -_tnl_TexCoord1fv( const GLfloat *v ) -{ - TEXCOORD1(v[0]); -} - -static void -_tnl_TexCoord2fv( const GLfloat *v ) -{ - TEXCOORD2F(v[0], v[1]); -} - -static void -_tnl_TexCoord3fv( const GLfloat *v ) -{ - TEXCOORD3(v[0], v[1], v[2]); -} - -static void -_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 -_tnl_Vertex2f( GLfloat x, GLfloat y ) -{ - GET_IMMEDIATE; - VERTEX2F( IM, x, y ); -} - -static void -_tnl_Vertex3f( GLfloat x, GLfloat y, GLfloat z ) -{ - GET_IMMEDIATE; - VERTEX3F( IM, x, y, z ); -} -static void -_tnl_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - GET_IMMEDIATE; - VERTEX4F( IM, x, y, z, w ); -} - -static void -_tnl_Vertex2fv( const GLfloat *v ) -{ - GET_IMMEDIATE; - VERTEX2F( IM, v[0], v[1] ); -} - -static void -_tnl_Vertex3fv( const GLfloat *v ) -{ - GET_IMMEDIATE; - VERTEX3F( IM, v[0], v[1], v[2] ); -} - -static void -_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_UNITS) - -#define MULTI_TEXCOORD1(target, s) \ -{ \ - GET_IMMEDIATE; \ - GLuint texunit = target - GL_TEXTURE0_ARB; \ - if (texunit < IM->MaxTextureUnits) { \ - GLuint count = IM->Count; \ - GLfloat *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; \ - GLuint texunit = target - GL_TEXTURE0_ARB; \ - if (texunit < IM->MaxTextureUnits) { \ - GLuint count = IM->Count; \ - GLfloat *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; \ - GLuint texunit = target - GL_TEXTURE0_ARB; \ - if (texunit < IM->MaxTextureUnits) { \ - GLuint count = IM->Count; \ - GLfloat *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; \ - GLuint texunit = target - GL_TEXTURE0_ARB; \ - if (texunit < IM->MaxTextureUnits) { \ - GLuint count = IM->Count; \ - GLfloat *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; \ - GLuint texunit = target - GL_TEXTURE0_ARB; \ - if (texunit < IM->MaxTextureUnits) { \ - GLuint count = IM->Count; \ - fi_type *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 -_tnl_MultiTexCoord1fARB(GLenum target, GLfloat s) -{ - MULTI_TEXCOORD1( target, s ); -} - -static void -_tnl_MultiTexCoord1fvARB(GLenum target, const GLfloat *v) -{ - MULTI_TEXCOORD1( target, v[0] ); -} - -static void -_tnl_MultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t) -{ - MULTI_TEXCOORD2F( target, s, t ); -} - -static void -_tnl_MultiTexCoord2fvARB(GLenum target, const GLfloat *v) -{ - MULTI_TEXCOORD2F( target, v[0], v[1] ); -} - -static void -_tnl_MultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r) -{ - MULTI_TEXCOORD3( target, s, t, r ); -} - -static void -_tnl_MultiTexCoord3fvARB(GLenum target, const GLfloat *v) -{ - MULTI_TEXCOORD3( target, v[0], v[1], v[2] ); -} - -static void -_tnl_MultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) -{ - MULTI_TEXCOORD4( target, s, t, r, q ); -} - -static void -_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) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *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) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *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) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *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) \ -{ \ - GLuint count = IM->Count++; \ - GLfloat *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 -_tnl_EvalCoord1f( GLfloat u ) -{ - GET_IMMEDIATE; - EVALCOORD1( IM, u ); -} - -static void -_tnl_EvalCoord1fv( const GLfloat *u ) -{ - GET_IMMEDIATE; - EVALCOORD1( IM, (GLfloat) *u ); -} - -static void -_tnl_EvalCoord2f( GLfloat u, GLfloat v ) -{ - GET_IMMEDIATE; - EVALCOORD2( IM, u, v ); -} - -static void -_tnl_EvalCoord2fv( const GLfloat *u ) -{ - GET_IMMEDIATE; - EVALCOORD2( IM, u[0], u[1] ); -} - - -static void -_tnl_EvalPoint1( GLint i ) -{ - GET_IMMEDIATE; - EVALPOINT1( IM, (GLfloat) i ); -} - - -static void -_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. - */ -#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 -_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 -_tnl_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - if (index < 16) { - GET_IMMEDIATE; - const GLuint count = IM->Count; - GLfloat *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 -_tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) -{ - if (index < 16) { - GET_IMMEDIATE; - const GLuint count = IM->Count; - GLfloat *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 -_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 -_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"); - - 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 (*)[2]) - MALLOC( sizeof(struct gl_material) * IMM_SIZE * 2 ); - IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); - IM->MaterialMask[IM->LastMaterial] = 0; - } - else if (IM->MaterialOrMask & ~bitmask) { - _mesa_copy_material_pairs( 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]; - - if (bitmask & FRONT_AMBIENT_BIT) { - COPY_4FV( mat[0].Ambient, params ); - } - if (bitmask & BACK_AMBIENT_BIT) { - COPY_4FV( mat[1].Ambient, params ); - } - if (bitmask & FRONT_DIFFUSE_BIT) { - COPY_4FV( mat[0].Diffuse, params ); - } - if (bitmask & BACK_DIFFUSE_BIT) { - COPY_4FV( mat[1].Diffuse, params ); - } - if (bitmask & FRONT_SPECULAR_BIT) { - COPY_4FV( mat[0].Specular, params ); - } - if (bitmask & BACK_SPECULAR_BIT) { - COPY_4FV( mat[1].Specular, params ); - } - if (bitmask & FRONT_EMISSION_BIT) { - COPY_4FV( mat[0].Emission, params ); - } - if (bitmask & BACK_EMISSION_BIT) { - COPY_4FV( mat[1].Emission, params ); - } - if (bitmask & FRONT_SHININESS_BIT) { - GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F ); - mat[0].Shininess = shininess; - } - if (bitmask & BACK_SHININESS_BIT) { - GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F ); - mat[1].Shininess = shininess; - } - if (bitmask & FRONT_INDEXES_BIT) { - mat[0].AmbientIndex = params[0]; - mat[0].DiffuseIndex = params[1]; - mat[0].SpecularIndex = params[2]; - } - if (bitmask & BACK_INDEXES_BIT) { - mat[1].AmbientIndex = params[0]; - mat[1].DiffuseIndex = params[1]; - mat[1].SpecularIndex = params[2]; - } - - 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 6615a9ce93..0000000000 --- a/src/mesa/tnl/t_imm_api.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $Id: t_imm_api.h,v 1.5 2002/04/09 16:56:52 keithw Exp $ */ - -/* - * 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 _tnl_save_Begin( GLenum mode ); -extern void _tnl_Begin( GLenum mode ); - -extern void _tnl_Begin( GLenum mode ); - -extern void _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( 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_debug.c b/src/mesa/tnl/t_imm_debug.c deleted file mode 100644 index 5def0d73a7..0000000000 --- a/src/mesa/tnl/t_imm_debug.c +++ /dev/null @@ -1,181 +0,0 @@ -/* $Id: t_imm_debug.c,v 1.8 2002/06/29 19:48:17 brianp Exp $ */ - -/* - * 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. - */ - -#include "mtypes.h" -#include "context.h" -#include "t_context.h" -#include "t_imm_debug.h" - -void _tnl_print_vert_flags( const char *name, GLuint flags ) -{ - _mesa_debug(NULL, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", - name, - flags, - (flags & VERT_BIT_CLIP) ? "clip/proj-clip/glend, " : "", - (flags & VERT_BIT_EDGEFLAG) ? "edgeflag, " : "", - (flags & VERT_BIT_ELT) ? "array-elt, " : "", - (flags & VERT_BIT_END_VB) ? "end-vb, " : "", - (flags & VERT_BITS_EVAL_ANY) ? "eval-coord, " : "", - (flags & VERT_BIT_EYE) ? "eye/glbegin, " : "", - (flags & VERT_BIT_FOG) ? "fog-coord, " : "", - (flags & VERT_BIT_INDEX) ? "index, " : "", - (flags & VERT_BIT_MATERIAL) ? "material, " : "", - (flags & VERT_BIT_NORMAL) ? "normals, " : "", - (flags & VERT_BIT_POS) ? "obj, " : "", - (flags & VERT_BIT_OBJ_3) ? "obj-3, " : "", - (flags & VERT_BIT_OBJ_4) ? "obj-4, " : "", - (flags & VERT_BIT_POINT_SIZE) ? "point-size, " : "", - (flags & VERT_BIT_COLOR0) ? "colors, " : "", - (flags & VERT_BIT_COLOR1) ? "specular, " : "", - (flags & VERT_BIT_TEX0) ? "texcoord0, " : "", - (flags & VERT_BIT_TEX1) ? "texcoord1, " : "", - (flags & VERT_BIT_TEX2) ? "texcoord2, " : "", - (flags & VERT_BIT_TEX3) ? "texcoord3, " : "", - (flags & VERT_BIT_TEX4) ? "texcoord4, " : "", - (flags & VERT_BIT_TEX5) ? "texcoord5, " : "", - (flags & VERT_BIT_TEX6) ? "texcoord6, " : "", - (flags & VERT_BIT_TEX7) ? "texcoord7, " : "" - ); -} - -void _tnl_print_cassette( struct immediate *IM ) -{ - GLuint i; - GLuint *flags = IM->Flag; - GLuint andflag = IM->CopyAndFlag; - GLuint orflag = (IM->CopyOrFlag|IM->Evaluated); - GLuint state = IM->BeginState; - GLuint req = ~0; - - _mesa_debug(NULL, "Cassette id %d, %u rows.\n", IM->id, - IM->Count - IM->CopyStart); - - _tnl_print_vert_flags("Contains at least one", orflag); - - if (IM->Count != IM->CopyStart) - { - _tnl_print_vert_flags("Contains a full complement of", andflag); - - _mesa_debug(NULL, "Final begin/end state %s/%s, errors %s/%s\n", - (state & VERT_BEGIN_0) ? "in" : "out", - (state & VERT_BEGIN_1) ? "in" : "out", - (state & VERT_ERROR_0) ? "y" : "n", - (state & VERT_ERROR_1) ? "y" : "n"); - - } - - for (i = IM->CopyStart ; i <= IM->Count ; i++) { - _mesa_debug(NULL, "%u: ", i); - if (req & VERT_BITS_OBJ_234) { - if (flags[i] & VERT_BIT_EVAL_C1) - _mesa_debug(NULL, "EvalCoord %f ", - IM->Attrib[VERT_ATTRIB_POS][i][0]); - else if (flags[i] & VERT_BIT_EVAL_P1) - _mesa_debug(NULL, "EvalPoint %.0f ", - IM->Attrib[VERT_ATTRIB_POS][i][0]); - else if (flags[i] & VERT_BIT_EVAL_C2) - _mesa_debug(NULL, "EvalCoord %f %f ", - IM->Attrib[VERT_ATTRIB_POS][i][0], - IM->Attrib[VERT_ATTRIB_POS][i][1]); - else if (flags[i] & VERT_BIT_EVAL_P2) - _mesa_debug(NULL, "EvalPoint %.0f %.0f ", - IM->Attrib[VERT_ATTRIB_POS][i][0], - IM->Attrib[VERT_ATTRIB_POS][i][1]); - else if (i < IM->Count && (flags[i] & VERT_BITS_OBJ_234)) { - _mesa_debug(NULL, "Obj %f %f %f %f", - IM->Attrib[VERT_ATTRIB_POS][i][0], - IM->Attrib[VERT_ATTRIB_POS][i][1], - IM->Attrib[VERT_ATTRIB_POS][i][2], - IM->Attrib[VERT_ATTRIB_POS][i][3]); - } - } - - if (req & flags[i] & VERT_BIT_ELT) - _mesa_debug(NULL, " Elt %u\t", IM->Elt[i]); - - if (req & flags[i] & VERT_BIT_NORMAL) - _mesa_debug(NULL, " Norm %f %f %f ", - IM->Attrib[VERT_ATTRIB_NORMAL][i][0], - IM->Attrib[VERT_ATTRIB_NORMAL][i][1], - IM->Attrib[VERT_ATTRIB_NORMAL][i][2]); - - if (req & flags[i] & VERT_BITS_TEX_ANY) { - GLuint j; - for (j = 0 ; j < MAX_TEXTURE_UNITS ; j++) { - if (req & flags[i] & VERT_BIT_TEX(j)) { - _mesa_debug(NULL, "TC%d %f %f %f %f", j, - IM->Attrib[VERT_ATTRIB_TEX0 + j][i][0], - IM->Attrib[VERT_ATTRIB_TEX0 + j][i][1], - IM->Attrib[VERT_ATTRIB_TEX0 + j][i][2], - IM->Attrib[VERT_ATTRIB_TEX0 + j][i][3]); - } - } - } - - if (req & flags[i] & VERT_BIT_COLOR0) - _mesa_debug(NULL, " Rgba %f %f %f %f ", - IM->Attrib[VERT_ATTRIB_COLOR0][i][0], - IM->Attrib[VERT_ATTRIB_COLOR0][i][1], - IM->Attrib[VERT_ATTRIB_COLOR0][i][2], - IM->Attrib[VERT_ATTRIB_COLOR0][i][3]); - - if (req & flags[i] & VERT_BIT_COLOR1) - _mesa_debug(NULL, " Spec %f %f %f ", - IM->Attrib[VERT_ATTRIB_COLOR1][i][0], - IM->Attrib[VERT_ATTRIB_COLOR1][i][1], - IM->Attrib[VERT_ATTRIB_COLOR1][i][2]); - - if (req & flags[i] & VERT_BIT_FOG) - _mesa_debug(NULL, " Fog %f ", IM->Attrib[VERT_ATTRIB_FOG][i][0]); - - if (req & flags[i] & VERT_BIT_INDEX) - _mesa_debug(NULL, " Index %u ", IM->Index[i]); - - if (req & flags[i] & VERT_BIT_EDGEFLAG) - _mesa_debug(NULL, " Edgeflag %d ", IM->EdgeFlag[i]); - - if (req & flags[i] & VERT_BIT_MATERIAL) - _mesa_debug(NULL, " Material "); - - - /* The order of these two is not easily knowable, but this is - * the usually correct way to look at them. - */ - if (req & flags[i] & VERT_BIT_END) - _mesa_debug(NULL, " END "); - - if (req & flags[i] & VERT_BIT_BEGIN) - _mesa_debug(NULL, " BEGIN(%s) (%s%s%s%s)", - _mesa_prim_name[IM->Primitive[i] & PRIM_MODE_MASK], - (IM->Primitive[i] & PRIM_LAST) ? "LAST," : "", - (IM->Primitive[i] & PRIM_BEGIN) ? "BEGIN," : "", - (IM->Primitive[i] & PRIM_END) ? "END," : "", - (IM->Primitive[i] & PRIM_PARITY) ? "PARITY," : ""); - - _mesa_debug(NULL, "\n"); - } -} diff --git a/src/mesa/tnl/t_imm_debug.h b/src/mesa/tnl/t_imm_debug.h deleted file mode 100644 index f735a9ca9f..0000000000 --- a/src/mesa/tnl/t_imm_debug.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id: t_imm_debug.h,v 1.2 2001/03/12 00:48:43 gareth Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - */ - -#ifndef _T_DEBUG_H -#define _T_DEBUG_H - -#include "mtypes.h" -#include "t_context.h" - -void _tnl_print_cassette( struct immediate *IM ); -void _tnl_print_vert_flags( const char *name, GLuint flags ); - -#endif diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c deleted file mode 100644 index 66285b4d19..0000000000 --- a/src/mesa/tnl/t_imm_dlist.c +++ /dev/null @@ -1,656 +0,0 @@ -/* $Id: t_imm_dlist.c,v 1.42 2002/06/15 02:38:18 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - */ - - -#include "glheader.h" -#include "context.h" -#include "dlist.h" -#include "debug.h" -#include "mmath.h" -#include "mem.h" -#include "state.h" - -#include "t_context.h" -#include "t_imm_api.h" -#include "t_imm_elt.h" -#include "t_imm_alloc.h" -#include "t_imm_dlist.h" -#include "t_imm_debug.h" -#include "t_imm_exec.h" -#include "t_imm_fixup.h" -#include "t_pipeline.h" - -typedef struct { - struct immediate *IM; - GLuint Start; - GLuint Count; - GLuint BeginState; - GLuint SavedBeginState; - GLuint OrFlag; - GLuint AndFlag; - GLuint TexSize; - GLuint LastData; - GLuint LastPrimitive; - GLuint LastMaterial; - GLuint MaterialOrMask; - GLuint MaterialAndMask; -} TNLvertexcassette; - -static void execute_compiled_cassette( GLcontext *ctx, void *data ); -static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ); - - -static void build_normal_lengths( struct immediate *IM ) -{ - GLuint i; - GLfloat len; - GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL] + IM->Start; - GLfloat *dest = IM->NormalLengthPtr; - GLuint *flags = IM->Flag + IM->Start; - GLuint count = IM->Count - IM->Start; - - if (!dest) { - dest = IM->NormalLengthPtr = (GLfloat *) ALIGN_MALLOC( IMM_SIZE*sizeof(GLfloat), 32 ); - if (!dest) return; - } - dest += IM->Start; - - len = (GLfloat) LEN_3FV( data[0] ); - if (len > 0.0F) len = 1.0F / len; - - for (i = 0 ; i < count ; ) { - dest[i] = len; - if (flags[++i] & VERT_BIT_NORMAL) { - len = (GLfloat) LEN_3FV( data[i] ); - if (len > 0.0F) len = 1.0F / len; - } - } -} - -static void fixup_normal_lengths( struct immediate *IM ) -{ - GLuint i; - GLfloat len = 1.0F; /* just to silence warnings */ - GLfloat (*data)[4] = IM->Attrib[VERT_ATTRIB_NORMAL]; - GLfloat *dest = IM->NormalLengthPtr; - GLuint *flags = IM->Flag; - - for (i = IM->CopyStart ; i <= IM->Start ; i++) { - len = (GLfloat) LEN_3FV( data[i] ); - if (len > 0.0F) len = 1.0F / len; - dest[i] = len; - } - - if (i < IM->Count) { - while (!(flags[i] & (VERT_BIT_NORMAL|VERT_BIT_END_VB))) { - dest[i] = len; - i++; - } - } -} - - - -/* Insert the active immediate struct onto the display list currently - * being built. - */ -void -_tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ) -{ - struct immediate *im = TNL_CURRENT_IM(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - TNLvertexcassette *node; - GLuint new_beginstate; - - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) - _mesa_debug(ctx, "_tnl_compiled_cassette IM: %d\n", IM->id); - - if (IM->FlushElt) { - ASSERT (IM->FlushElt == FLUSH_ELT_LAZY); - _tnl_translate_array_elts( ctx, IM, IM->Start, IM->Count ); - } - - _tnl_compute_orflag( IM, IM->Start ); - - /* Need to clear this flag, or fixup gets confused. (The - * array-elements have been translated away by now, so it's ok to - * remove it.) - */ - IM->OrFlag &= ~VERT_BIT_ELT; - IM->AndFlag &= ~VERT_BIT_ELT; - - _tnl_fixup_input( ctx, IM ); - - node = (TNLvertexcassette *) - _mesa_alloc_instruction(ctx, - tnl->opcode_vertex_cassette, - sizeof(TNLvertexcassette)); - if (!node) - return; - - node->IM = im; im->ref_count++; - node->Start = im->Start; - node->Count = im->Count; - node->BeginState = im->BeginState; - node->SavedBeginState = im->SavedBeginState; - node->OrFlag = im->OrFlag; - node->TexSize = im->TexSize; - node->AndFlag = im->AndFlag; - node->LastData = im->LastData; - node->LastPrimitive = im->LastPrimitive; - node->LastMaterial = im->LastMaterial; - node->MaterialOrMask = im->MaterialOrMask; - node->MaterialAndMask = im->MaterialAndMask; - - if (tnl->CalcDListNormalLengths) { - build_normal_lengths( im ); - } - - if (ctx->ExecuteFlag) { - execute_compiled_cassette( ctx, (void *)node ); - } - - /* Discard any errors raised in the last cassette. - */ - new_beginstate = node->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1); - - /* Decide whether this immediate struct is full, or can be used for - * the next batch of vertices as well. - */ - if (im->Count > IMM_MAXDATA - 16) { - /* Call it full... - */ - struct immediate *new_im = _tnl_alloc_immediate(ctx); - new_im->ref_count++; - im->ref_count--; /* remove CURRENT_IM reference */ - ASSERT(im->ref_count > 0); /* it is compiled into a display list */ - SET_IMMEDIATE( ctx, new_im ); - _tnl_reset_compile_input( ctx, IMM_MAX_COPIED_VERTS, - new_beginstate, node->SavedBeginState ); - } else { - /* Still some room in the current immediate. - */ - _tnl_reset_compile_input( ctx, im->Count+1+IMM_MAX_COPIED_VERTS, - new_beginstate, node->SavedBeginState); - } -} - - -static void fixup_compiled_primitives( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - /* Can potentially overwrite primitive details - need to save the - * first slot: - */ - tnl->DlistPrimitive = IM->Primitive[IM->Start]; - tnl->DlistPrimitiveLength = IM->PrimitiveLength[IM->Start]; - tnl->DlistLastPrimitive = IM->LastPrimitive; - - /* The first primitive may be different from what was recorded in - * the immediate struct. Consider an immediate that starts with a - * glBegin, compiled in a display list, which is called from within - * an existing Begin/End object. - */ - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) { - GLuint i; - - if (IM->BeginState & VERT_ERROR_1) - _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin/glEnd"); - - for (i = IM->Start ; i <= IM->Count ; i += IM->PrimitiveLength[i]) - if (IM->Flag[i] & (VERT_BIT_BEGIN|VERT_BIT_END_VB)) - break; - - /* Would like to just ignore vertices upto this point. Can't - * set copystart because it might skip materials? - */ - ASSERT(IM->Start == IM->CopyStart); - if (i > IM->CopyStart || !(IM->Flag[IM->Start] & VERT_BIT_BEGIN)) { - IM->Primitive[IM->CopyStart] = GL_POLYGON+1; - IM->PrimitiveLength[IM->CopyStart] = i - IM->CopyStart; - if (IM->Flag[i] & VERT_BIT_END_VB) { - IM->Primitive[IM->CopyStart] |= PRIM_LAST; - IM->LastPrimitive = IM->CopyStart; - } - } - } else { - GLuint i; - - if (IM->BeginState & VERT_ERROR_0) - _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin/glEnd"); - - if (IM->CopyStart == IM->Start && - IM->Flag[IM->Start] & (VERT_BIT_END | VERT_BIT_END_VB)) - { - } - else - { - IM->Primitive[IM->CopyStart] = ctx->Driver.CurrentExecPrimitive; - if (tnl->ExecParity) - IM->Primitive[IM->CopyStart] |= PRIM_PARITY; - - /* one of these should be true, else we'll be in an infinite loop - */ - ASSERT(IM->PrimitiveLength[IM->Start] > 0 || - IM->Flag[IM->Start] & (VERT_BIT_END | VERT_BIT_END_VB)); - - for (i = IM->Start ; i <= IM->Count ; i += IM->PrimitiveLength[i]) - if (IM->Flag[i] & (VERT_BIT_END | VERT_BIT_END_VB)) { - IM->PrimitiveLength[IM->CopyStart] = i - IM->CopyStart; - if (IM->Flag[i] & VERT_BIT_END_VB) { - IM->Primitive[IM->CopyStart] |= PRIM_LAST; - IM->LastPrimitive = IM->CopyStart; - } - if (IM->Flag[i] & VERT_BIT_END) { - IM->Primitive[IM->CopyStart] |= PRIM_END; - } - break; - } - } - } -} - -/* Undo any changes potentially made to the immediate in the range - * IM->Start..IM->Count above. - */ -static void restore_compiled_primitives( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - IM->Primitive[IM->Start] = tnl->DlistPrimitive; - IM->PrimitiveLength[IM->Start] = tnl->DlistPrimitiveLength; -} - - - -static void -execute_compiled_cassette( GLcontext *ctx, void *data ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - TNLvertexcassette *node = (TNLvertexcassette *)data; - struct immediate *IM = node->IM; - -/* _mesa_debug("%s\n", __FUNCTION__); */ - - IM->Start = node->Start; - IM->CopyStart = node->Start; - IM->Count = node->Count; - IM->BeginState = node->BeginState; - IM->SavedBeginState = node->SavedBeginState; - IM->OrFlag = node->OrFlag; - IM->TexSize = node->TexSize; - IM->AndFlag = node->AndFlag; - IM->LastData = node->LastData; - IM->LastPrimitive = node->LastPrimitive; - IM->LastMaterial = node->LastMaterial; - IM->MaterialOrMask = node->MaterialOrMask; - IM->MaterialAndMask = node->MaterialAndMask; - - if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) && - (MESA_VERBOSE & VERBOSE_IMMEDIATE)) - _tnl_print_cassette( IM ); - - if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) { - _mesa_debug(ctx, "Run cassette %d, rows %d..%d, beginstate %x ", - IM->id, IM->Start, IM->Count, IM->BeginState); - _tnl_print_vert_flags("orflag", IM->OrFlag); - } - - - /* Need to respect 'HardBeginEnd' even if the commands are looped - * back to a driver tnl module. - */ - if (IM->SavedBeginState) { - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) - tnl->ReplayHardBeginEnd = 1; - if (!tnl->ReplayHardBeginEnd) { - /* This is a user error. Whatever operation (like glRectf) - * decomposed to this hard begin/end pair is now being run - * inside a begin/end object -- illegally. Reject it and - * raise an error. - */ - _mesa_error(ctx, GL_INVALID_OPERATION, "hard replay"); - return; - } - } - - if (tnl->LoopbackDListCassettes) { -/* (tnl->IsolateMaterials && (IM->OrFlag & VERT_MATERIAL)) ) { */ - fixup_compiled_primitives( ctx, IM ); - loopback_compiled_cassette( ctx, IM ); - restore_compiled_primitives( ctx, IM ); - } - else { - if (ctx->NewState) - _mesa_update_state(ctx); - - if (tnl->pipeline.build_state_changes) - _tnl_validate_pipeline( ctx ); - - _tnl_fixup_compiled_cassette( ctx, IM ); - fixup_compiled_primitives( ctx, IM ); - - if (IM->Primitive[IM->LastPrimitive] & PRIM_END) - ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1; - else if ((IM->Primitive[IM->LastPrimitive] & PRIM_BEGIN) || - (IM->Primitive[IM->LastPrimitive] & PRIM_MODE_MASK) == - PRIM_OUTSIDE_BEGIN_END) { - ctx->Driver.CurrentExecPrimitive = - IM->Primitive[IM->LastPrimitive] & PRIM_MODE_MASK; - } - - _tnl_get_exec_copy_verts( ctx, IM ); - - if (IM->NormalLengthPtr) - fixup_normal_lengths( IM ); - - if (IM->Count == IM->Start) - _tnl_copy_to_current( ctx, IM, IM->OrFlag, IM->LastData ); - else { -/* _tnl_print_cassette( IM ); */ - _tnl_run_cassette( ctx, IM ); - } - - restore_compiled_primitives( ctx, IM ); - } - - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) - tnl->ReplayHardBeginEnd = 0; -} - -static void -destroy_compiled_cassette( GLcontext *ctx, void *data ) -{ - TNLvertexcassette *node = (TNLvertexcassette *)data; - - if ( --node->IM->ref_count == 0 ) - _tnl_free_immediate( ctx, node->IM ); -} - - -static void -print_compiled_cassette( GLcontext *ctx, void *data ) -{ - TNLvertexcassette *node = (TNLvertexcassette *)data; - struct immediate *IM = node->IM; - - _mesa_debug(ctx, "TNL-VERTEX-CASSETTE, id %u, rows %u..%u\n", - node->IM->id, node->Start, node->Count); - - IM->Start = node->Start; - IM->CopyStart = node->Start; - IM->Count = node->Count; - IM->BeginState = node->BeginState; - IM->OrFlag = node->OrFlag; - IM->TexSize = node->TexSize; - IM->AndFlag = node->AndFlag; - IM->LastData = node->LastData; - IM->LastPrimitive = node->LastPrimitive; - IM->LastMaterial = node->LastMaterial; - IM->MaterialOrMask = node->MaterialOrMask; - IM->MaterialAndMask = node->MaterialAndMask; - - _tnl_print_cassette( node->IM ); -} - -void -_tnl_BeginCallList( GLcontext *ctx, GLuint list ) -{ - (void) ctx; - (void) list; - FLUSH_CURRENT(ctx, 0); -} - - -/* Called at the tail of a CallList. Make current immediate aware of - * any new to-be-copied vertices. - */ -void -_tnl_EndCallList( GLcontext *ctx ) -{ - GLuint beginstate = 0; - - if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) - beginstate = VERT_BEGIN_0|VERT_BEGIN_1; - - _tnl_reset_exec_input( ctx, TNL_CURRENT_IM(ctx)->Start, beginstate, 0 ); -} - - -void -_tnl_EndList( GLcontext *ctx ) -{ - struct immediate *IM = TNL_CURRENT_IM(ctx); - - ctx->swtnl_im = 0; - IM->ref_count--; - - /* outside begin/end, even in COMPILE_AND_EXEC, - * so no vertices to copy, right? - */ - ASSERT(TNL_CONTEXT(ctx)->ExecCopyCount == 0); - - /* If this one isn't free, get a clean one. (Otherwise we'll be - * using one that's already half full). - */ - if (IM->ref_count != 0) - IM = _tnl_alloc_immediate( ctx ); - - ASSERT(IM->ref_count == 0); - - SET_IMMEDIATE( ctx, IM ); - IM->ref_count++; - - _tnl_reset_exec_input( ctx, IMM_MAX_COPIED_VERTS, 0, 0 ); -} - - -void -_tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode ) -{ - struct immediate *IM = TNL_CURRENT_IM(ctx); - - /* Use the installed immediate struct. No vertices in the current - * immediate, no copied vertices in the system. - */ - ASSERT(TNL_CURRENT_IM(ctx)); - ASSERT(TNL_CURRENT_IM(ctx)->Start == IMM_MAX_COPIED_VERTS); - ASSERT(TNL_CURRENT_IM(ctx)->Start == TNL_CURRENT_IM(ctx)->Count); - ASSERT(TNL_CONTEXT(ctx)->ExecCopyCount == 0); - - /* Set current Begin/End state to unknown: - */ - IM->BeginState = VERT_BEGIN_0; - ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN; -} - - -void -_tnl_dlist_init( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - tnl->opcode_vertex_cassette = - _mesa_alloc_opcode( ctx, - sizeof(TNLvertexcassette), - execute_compiled_cassette, - destroy_compiled_cassette, - print_compiled_cassette ); -} - - -static void emit_material( struct gl_material *src, GLuint bitmask ) -{ - if (bitmask & FRONT_EMISSION_BIT) - glMaterialfv( GL_FRONT, GL_EMISSION, src[0].Emission ); - - if (bitmask & BACK_EMISSION_BIT) - glMaterialfv( GL_BACK, GL_EMISSION, src[1].Emission ); - - if (bitmask & FRONT_AMBIENT_BIT) - glMaterialfv( GL_FRONT, GL_AMBIENT, src[0].Ambient ); - - if (bitmask & BACK_AMBIENT_BIT) - glMaterialfv( GL_BACK, GL_AMBIENT, src[1].Ambient ); - - if (bitmask & FRONT_DIFFUSE_BIT) - glMaterialfv( GL_FRONT, GL_DIFFUSE, src[0].Diffuse ); - - if (bitmask & BACK_DIFFUSE_BIT) - glMaterialfv( GL_BACK, GL_DIFFUSE, src[1].Diffuse ); - - if (bitmask & FRONT_SPECULAR_BIT) - glMaterialfv( GL_FRONT, GL_SPECULAR, src[0].Specular ); - - if (bitmask & BACK_SPECULAR_BIT) - glMaterialfv( GL_BACK, GL_SPECULAR, src[1].Specular ); - - if (bitmask & FRONT_SHININESS_BIT) - glMaterialfv( GL_FRONT, GL_SHININESS, &src[0].Shininess ); - - if (bitmask & BACK_SHININESS_BIT) - glMaterialfv( GL_BACK, GL_SHININESS, &src[1].Shininess ); - - if (bitmask & FRONT_INDEXES_BIT) { - GLfloat ind[3]; - ind[0] = src[0].AmbientIndex; - ind[1] = src[0].DiffuseIndex; - ind[2] = src[0].SpecularIndex; - glMaterialfv( GL_FRONT, GL_COLOR_INDEXES, ind ); - } - - if (bitmask & BACK_INDEXES_BIT) { - GLfloat ind[3]; - ind[0] = src[1].AmbientIndex; - ind[1] = src[1].DiffuseIndex; - ind[2] = src[1].SpecularIndex; - glMaterialfv( GL_BACK, GL_COLOR_INDEXES, ind ); - } -} - - -/* Low-performance helper function to allow driver-supplied tnl - * modules to process tnl display lists. This is primarily supplied - * to avoid fallbacks if CallList is invoked inside a Begin/End pair. - * For higher performance, drivers should fallback to tnl (if outside - * begin/end), or (for tnl hardware) implement their own display list - * mechanism. - */ -static void loopback_compiled_cassette( GLcontext *ctx, struct immediate *IM ) -{ - GLuint i; - GLuint *flags = IM->Flag; - GLuint orflag = IM->OrFlag; - GLuint j; - void (GLAPIENTRY *vertex)( const GLfloat * ); - void (GLAPIENTRY *texcoordfv[MAX_TEXTURE_UNITS])( GLenum, const GLfloat * ); - GLuint maxtex = 0; - GLuint p, length, prim = 0; - - if (orflag & VERT_BITS_OBJ_234) - vertex = (void (GLAPIENTRY *)(const GLfloat *)) glVertex4fv; - else - vertex = (void (GLAPIENTRY *)(const GLfloat *)) glVertex3fv; - - if (orflag & VERT_BITS_TEX_ANY) { - for (j = 0 ; j < ctx->Const.MaxTextureUnits ; j++) { - if (orflag & VERT_BIT_TEX(j)) { - maxtex = j+1; - if ((IM->TexSize & TEX_SIZE_4(j)) == TEX_SIZE_4(j)) - texcoordfv[j] = glMultiTexCoord4fvARB; - else if (IM->TexSize & TEX_SIZE_3(j)) - texcoordfv[j] = glMultiTexCoord3fvARB; - else - texcoordfv[j] = glMultiTexCoord2fvARB; - } - } - } - - for (p = IM->Start ; !(prim & PRIM_LAST) ; p += length) - { - prim = IM->Primitive[p]; - length= IM->PrimitiveLength[p]; - ASSERT(length || (prim & PRIM_LAST)); - ASSERT((prim & PRIM_MODE_MASK) <= GL_POLYGON+1); - - if (prim & PRIM_BEGIN) { - glBegin(prim & PRIM_MODE_MASK); - } - - for ( i = p ; i <= p+length ; i++) { - if (flags[i] & VERT_BITS_TEX_ANY) { - GLuint k; - for (k = 0 ; k < maxtex ; k++) { - if (flags[i] & VERT_BIT_TEX(k)) { - texcoordfv[k]( GL_TEXTURE0_ARB + k, - IM->Attrib[VERT_ATTRIB_TEX0 + k][i] ); - } - } - } - - if (flags[i] & VERT_BIT_NORMAL) - glNormal3fv(IM->Attrib[VERT_ATTRIB_NORMAL][i]); - - if (flags[i] & VERT_BIT_COLOR0) - glColor4fv( IM->Attrib[VERT_ATTRIB_COLOR0][i] ); - - if (flags[i] & VERT_BIT_COLOR1) - _glapi_Dispatch->SecondaryColor3fvEXT( IM->Attrib[VERT_ATTRIB_COLOR1][i] ); - - if (flags[i] & VERT_BIT_FOG) - _glapi_Dispatch->FogCoordfEXT( IM->Attrib[VERT_ATTRIB_FOG][i][0] ); - - if (flags[i] & VERT_BIT_INDEX) - glIndexi( IM->Index[i] ); - - if (flags[i] & VERT_BIT_EDGEFLAG) - glEdgeFlag( IM->EdgeFlag[i] ); - - if (flags[i] & VERT_BIT_MATERIAL) - emit_material( IM->Material[i], IM->MaterialMask[i] ); - - if (flags[i]&VERT_BITS_OBJ_234) - vertex( IM->Attrib[VERT_ATTRIB_POS][i] ); - else if (flags[i] & VERT_BIT_EVAL_C1) - glEvalCoord1f( IM->Attrib[VERT_ATTRIB_POS][i][0] ); - else if (flags[i] & VERT_BIT_EVAL_P1) - glEvalPoint1( (GLint) IM->Attrib[VERT_ATTRIB_POS][i][0] ); - else if (flags[i] & VERT_BIT_EVAL_C2) - glEvalCoord2f( IM->Attrib[VERT_ATTRIB_POS][i][0], - IM->Attrib[VERT_ATTRIB_POS][i][1] ); - else if (flags[i] & VERT_BIT_EVAL_P2) - glEvalPoint2( (GLint) IM->Attrib[VERT_ATTRIB_POS][i][0], - (GLint) IM->Attrib[VERT_ATTRIB_POS][i][1] ); - } - - if (prim & PRIM_END) { - glEnd(); - } - } -} diff --git a/src/mesa/tnl/t_imm_dlist.h b/src/mesa/tnl/t_imm_dlist.h deleted file mode 100644 index e4080832ed..0000000000 --- a/src/mesa/tnl/t_imm_dlist.h +++ /dev/null @@ -1,45 +0,0 @@ -/* $Id: t_imm_dlist.h,v 1.3 2001/03/12 00:48:43 gareth Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - */ - -#ifndef _T_DLIST_H -#define _T_DLIST_H - -#include "mtypes.h" -#include "t_context.h" - -extern void _tnl_dlist_init( GLcontext *ctx ); - -extern void _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM ); -extern void _tnl_EndList( GLcontext *ctx ); -extern void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode ); - -extern void _tnl_EndCallList( GLcontext *ctx ); -extern void _tnl_BeginCallList( GLcontext *ctx, GLuint list ); - -#endif diff --git a/src/mesa/tnl/t_imm_elt.c b/src/mesa/tnl/t_imm_elt.c deleted file mode 100644 index f0c470de92..0000000000 --- a/src/mesa/tnl/t_imm_elt.c +++ /dev/null @@ -1,834 +0,0 @@ -/* $Id: t_imm_elt.c,v 1.18 2002/06/15 02:38:18 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.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 <keithw@valinux.com> - */ - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "mem.h" -#include "mmath.h" -#include "mtypes.h" - -#include "math/m_translate.h" - -#include "t_context.h" -#include "t_imm_elt.h" - - - -typedef void (*trans_elt_1f_func)(GLfloat *to, - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - -typedef void (*trans_elt_1ui_func)(GLuint *to, - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - -typedef void (*trans_elt_1ub_func)(GLubyte *to, - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - -typedef void (*trans_elt_4ub_func)(GLubyte (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - -typedef void (*trans_elt_4us_func)(GLushort (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - -typedef void (*trans_elt_4f_func)(GLfloat (*to)[4], - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - -typedef void (*trans_elt_3f_func)(GLfloat (*to)[3], - CONST void *ptr, - GLuint stride, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ); - - - - -static trans_elt_1f_func _tnl_trans_elt_1f_tab[MAX_TYPES]; -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_3f_func _tnl_trans_elt_3f_tab[MAX_TYPES]; -static trans_elt_4ub_func _tnl_trans_elt_4ub_tab[5][MAX_TYPES]; -static trans_elt_4us_func _tnl_trans_elt_4us_tab[5][MAX_TYPES]; -static trans_elt_4f_func _tnl_trans_elt_4f_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 GLuint *flags, 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_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(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_US(us, f,n) us = BYTE_TO_USHORT( 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_4UB trans_4_GLbyte_4ub_elt -#define DEST_4US trans_4_GLbyte_4us_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_4UB trans_3_GLbyte_4ub_elt -#define DEST_4US trans_3_GLbyte_4us_elt -#define DEST_3F trans_3_GLbyte_3f_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 -#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_1UB trans_1_GLbyte_1ub_elt -#define DEST_1UI trans_1_GLbyte_1ui_elt -#include "math/m_trans_tmp.h" - -#undef SRC -#undef TRX_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI -#undef SRC_IDX - -/* GL_UNSIGNED_BYTE - */ -#define SRC GLubyte -#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE) -#define TRX_3F(f,n) UBYTE_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) UBYTE_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n) -#define TRX_US(us, f,n) us = 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_4US trans_4_GLubyte_4us_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_3F trans_3_GLubyte_3f_elt -#define DEST_4UB trans_3_GLubyte_4ub_elt -#define DEST_4US trans_3_GLubyte_4us_elt -#include "math/m_trans_tmp.h" - - -#define SZ 1 -#define INIT init_trans_1_GLubyte_elt -#define DEST_1UI trans_1_GLubyte_1ui_elt -#define DEST_1UB trans_1_GLubyte_1ub_elt -#include "math/m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX -#undef TRX_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_SHORT - */ -#define SRC GLshort -#define SRC_IDX TYPE_IDX(GL_SHORT) -#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n)) -#define TRX_US(us, f,n) us = SHORT_TO_USHORT(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_4UB trans_4_GLshort_4ub_elt -#define DEST_4US trans_4_GLshort_4us_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_4UB trans_3_GLshort_4ub_elt -#define DEST_4US trans_3_GLshort_4us_elt -#define DEST_3F trans_3_GLshort_3f_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 -#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_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_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_UNSIGNED_SHORT - */ -#define SRC GLushort -#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT) -#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8) -#define TRX_US(us,f,n) us = PTR_ELT(f,n) -#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_4UB trans_4_GLushort_4ub_elt -#define DEST_4US trans_4_GLushort_4us_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_4UB trans_3_GLushort_4ub_elt -#define DEST_4US trans_3_GLushort_4us_elt -#define DEST_3F trans_3_GLushort_3f_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 -#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_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_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_INT - */ -#define SRC GLint -#define SRC_IDX TYPE_IDX(GL_INT) -#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n)) -#define TRX_US(us, f,n) us = INT_TO_USHORT(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_4UB trans_4_GLint_4ub_elt -#define DEST_4US trans_4_GLint_4us_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_4UB trans_3_GLint_4ub_elt -#define DEST_4US trans_3_GLint_4us_elt -#define DEST_3F trans_3_GLint_3f_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 -#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_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_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_UNSIGNED_INT - */ -#define SRC GLuint -#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT) -#define TRX_3F(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) ) -#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) ) -#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24) -#define TRX_US(us, f,n) us = (GLushort) (PTR_ELT(f,n) >> 16) -#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_4UB trans_4_GLuint_4ub_elt -#define DEST_4US trans_4_GLuint_4us_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_4UB trans_3_GLuint_4ub_elt -#define DEST_4US trans_3_GLuint_4us_elt -#define DEST_3F trans_3_GLuint_3f_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 -#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_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_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -/* GL_DOUBLE - */ -#define SRC GLdouble -#define SRC_IDX TYPE_IDX(GL_DOUBLE) -#define TRX_3F(f,n) (GLfloat) PTR_ELT(f,n) -#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n) -#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n)) -#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, 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_4UB trans_4_GLdouble_4ub_elt -#define DEST_4US trans_4_GLdouble_4us_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_4UB trans_3_GLdouble_4ub_elt -#define DEST_4US trans_3_GLdouble_4us_elt -#define DEST_3F trans_3_GLdouble_3f_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 -#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_1UB trans_1_GLdouble_1ub_elt -#define DEST_1UI trans_1_GLdouble_1ui_elt -#define DEST_1F trans_1_GLdouble_1f_elt -#include "math/m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX - -/* GL_FLOAT - */ -#define SRC GLfloat -#define SRC_IDX TYPE_IDX(GL_FLOAT) -#define SZ 4 -#define INIT init_trans_4_GLfloat_elt -#define DEST_4UB trans_4_GLfloat_4ub_elt -#define DEST_4US trans_4_GLfloat_4us_elt -#define DEST_4F trans_4_GLfloat_4f_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_4UB trans_3_GLfloat_4ub_elt -#define DEST_4US trans_3_GLfloat_4us_elt -#define DEST_3F trans_3_GLfloat_3f_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 -#include "math/m_trans_tmp.h" - -#define SZ 1 -#define INIT init_trans_1_GLfloat_elt -#define DEST_4F trans_1_GLfloat_3f_elt -#define DEST_1UB trans_1_GLfloat_1ub_elt -#define DEST_1UI trans_1_GLfloat_1ui_elt -#define DEST_1F trans_1_GLfloat_1f_elt -#include "math/m_trans_tmp.h" - -#undef SRC -#undef SRC_IDX -#undef TRX_3F -#undef TRX_4F -#undef TRX_UB -#undef TRX_US -#undef TRX_UI - - -static void trans_4_GLubyte_4ub(GLubyte (*t)[4], - CONST void *Ptr, - GLuint stride, - ARGS ) -{ - const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride; - const GLubyte *first = f; - GLuint i; - (void) start; - if (((((long) f | (long) stride)) & 3L) == 0L) { - /* Aligned. - */ - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - COPY_4UBV( t[i], f ); - } - } - } else { - for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i][0] = f[0]; - t[i][1] = f[1]; - t[i][2] = f[2]; - t[i][3] = f[3]; - } - } - } -} - - -static void init_translate_elt(void) -{ - MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) ); - MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) ); - MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) ); - MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) ); - MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) ); - MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) ); - - TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub; - - 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 -#undef START - - - - -void _tnl_imm_elt_init( void ) -{ - init_translate_elt(); -} - - -#if 00 -static void _tnl_trans_elt_1f(GLfloat *to, - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_1f_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); - -} -#endif - -static void _tnl_trans_elt_1ui(GLuint *to, - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); - -} - - -static void _tnl_trans_elt_1ub(GLubyte *to, - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); - -} - - -#if 0 -static void _tnl_trans_elt_4ub(GLubyte (*to)[4], - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); - -} -#endif - -#if 0 -static void _tnl_trans_elt_4us(GLushort (*to)[4], - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_4us_tab[from->Size][TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); - -} -#endif - -static void _tnl_trans_elt_4f(GLfloat (*to)[4], - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); - -} - - - -#if 0 -static void _tnl_trans_elt_3f(GLfloat (*to)[3], - const struct gl_client_array *from, - GLuint *flags, - GLuint *elts, - GLuint match, - GLuint start, - GLuint n ) -{ - _tnl_trans_elt_3f_tab[TYPE_IDX(from->Type)]( to, - from->Ptr, - from->StrideB, - flags, - elts, - match, - start, - n ); -} -#endif - - - -/* 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; - GLuint *elts = IM->Elt; - GLuint translate = ctx->Array._Enabled; - GLuint i; - - if (MESA_VERBOSE & VERBOSE_IMMEDIATE) - _mesa_debug(ctx, "exec_array_elements %d .. %d\n", start, count); - - if (translate & 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 (translate & 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 (translate & VERT_BIT_EDGEFLAG) - _tnl_trans_elt_1ub( IM->EdgeFlag, - &ctx->Array.EdgeFlag, - flags, elts, (VERT_BIT_ELT|VERT_BIT_EDGEFLAG), - start, count); - - if (translate & VERT_BIT_COLOR0) { - _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR0], - &ctx->Array.Color, - flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR0), - start, count); - } - - if (translate & VERT_BIT_COLOR1) { - _tnl_trans_elt_4f( IM->Attrib[VERT_ATTRIB_COLOR1], - &ctx->Array.SecondaryColor, - flags, elts, (VERT_BIT_ELT|VERT_BIT_COLOR1), - start, count); - } - - if (translate & 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 (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_BITS_TEX_ANY) { - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) - if (translate & 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); - } - } - - 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_elt.h b/src/mesa/tnl/t_imm_elt.h deleted file mode 100644 index d2d709d9c0..0000000000 --- a/src/mesa/tnl/t_imm_elt.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $Id: t_imm_elt.h,v 1.2 2001/03/12 00:48:43 gareth Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - */ - - -#ifndef _T_IMM_ELT_H_ -#define _T_IMM_ELT_H_ - -#include "mtypes.h" -#include "t_context.h" - - -extern void _tnl_imm_elt_init( void ); - -extern void _tnl_translate_array_elts( GLcontext *ctx, - struct immediate *IM, - GLuint start, - GLuint end ); - - -#endif diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c deleted file mode 100644 index e7ffdaaeae..0000000000 --- a/src/mesa/tnl/t_imm_eval.c +++ /dev/null @@ -1,854 +0,0 @@ -/* $Id: t_imm_eval.c,v 1.25 2002/06/25 02:56:45 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.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 <keithw@valinux.com> - * Brian Paul - vertex program updates - */ - - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "macros.h" -#include "mem.h" -#include "mmath.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; - GLfloat (*to)[4] = (GLfloat (*)[4])dest->Ptr; - 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; - GLfloat (*to)[4] = (GLfloat (*)[4])dest->Ptr; - 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; - - 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; - } - } - - /* 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) - copy_4f_stride( store->Attrib[VERT_ATTRIB_COLOR0] + IM->CopyStart, - (GLfloat *)tmp->Color.Ptr, - tmp->Color.StrideB, - copycount ); - - tmp->Color.Ptr = 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. */ - } -} diff --git a/src/mesa/tnl/t_imm_eval.h b/src/mesa/tnl/t_imm_eval.h deleted file mode 100644 index 341da51481..0000000000 --- a/src/mesa/tnl/t_imm_eval.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $Id: t_imm_eval.h,v 1.3 2001/04/30 21:08:52 keithw Exp $ */ - -/* - * 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_IMM_EVAL_H -#define _T_IMM_EVAL_H - - -#include "mtypes.h" -#include "t_context.h" - -extern void _tnl_eval_init( void ); - -extern void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ); - -#endif diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c deleted file mode 100644 index 137c7ec514..0000000000 --- a/src/mesa/tnl/t_imm_exec.c +++ /dev/null @@ -1,598 +0,0 @@ -/* $Id: t_imm_exec.c,v 1.42 2002/08/08 16:55:17 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.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. - */ - -/** - * \file tnl/t_imm_exec.c - * \brief Setup to execute immediate-mode vertex data. - * \author Keith Whitwell - */ - -#include "glheader.h" -#include "colormac.h" -#include "context.h" -#include "enums.h" -#include "dlist.h" -#include "macros.h" -#include "mem.h" -#include "mmath.h" -#include "light.h" -#include "state.h" -#include "mtypes.h" - -#include "math/m_matrix.h" -#include "math/m_xform.h" - -#include "t_context.h" -#include "t_array_import.h" -#include "t_imm_alloc.h" -#include "t_imm_api.h" -#include "t_imm_debug.h" -#include "t_imm_dlist.h" -#include "t_imm_eval.h" -#include "t_imm_elt.h" -#include "t_imm_exec.h" -#include "t_imm_fixup.h" -#include "t_pipeline.h" - - - -static void reset_input( GLcontext *ctx, - GLuint start, - GLuint beginstate, - GLuint savedbeginstate ) -{ - struct immediate *IM = TNL_CURRENT_IM(ctx); - - /* Clear the dirty part of the flag array. - */ - if (start < IM->Count+2) - MEMSET(IM->Flag + start, 0, sizeof(GLuint) * (IM->Count+2-start)); - - if (MESA_VERBOSE & VERBOSE_IMMEDIATE) - _mesa_debug(ctx, "reset_input: IM(%d) new %x\n", IM->id, beginstate); - - IM->Start = start; - IM->Count = start; - IM->LastMaterial = start; - IM->BeginState = beginstate; - IM->SavedBeginState = savedbeginstate; - IM->TexSize = 0; - IM->MaterialOrMask = 0; - - if (IM->MaterialMask) - IM->MaterialMask[IM->Start] = 0; - - IM->ArrayEltFlags = ~ctx->Array._Enabled; - IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0; - IM->ArrayEltFlush = ctx->Array.LockCount ? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER; -} - -void _tnl_reset_exec_input( GLcontext *ctx, - GLuint start, - GLuint beginstate, - GLuint savedbeginstate ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct immediate *IM = TNL_CURRENT_IM(ctx); - - reset_input( ctx, start, beginstate, savedbeginstate ); - - IM->CopyStart = start - tnl->ExecCopyCount; - - IM->Primitive[IM->CopyStart] = ctx->Driver.CurrentExecPrimitive; - if (tnl->ExecParity) - IM->Primitive[IM->CopyStart] |= PRIM_PARITY; - - IM->LastPrimitive = IM->CopyStart; -} - - -void _tnl_reset_compile_input( GLcontext *ctx, - GLuint start, - GLuint beginstate, - GLuint savedbeginstate ) -{ - struct immediate *IM = TNL_CURRENT_IM(ctx); - - reset_input( ctx, start, beginstate, savedbeginstate ); - IM->CopyStart = start; - IM->LastPrimitive = IM->Start; -} - - -/** - * Copy the last specified normal, color, texcoord, edge flag, etc - * from the immediate struct into the ctx->Current attribute group. - */ -void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, - GLuint flag, GLuint count ) -{ - if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - _tnl_print_vert_flags("copy to current", flag); - - /* XXX should be able to replace these conditions with a loop over - * the 16 vertex attributes. - */ - if (flag & VERT_BIT_NORMAL) - COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], - IM->Attrib[VERT_ATTRIB_NORMAL][count]); - - if (flag & VERT_BIT_INDEX) - ctx->Current.Index = IM->Index[count]; - - if (flag & VERT_BIT_EDGEFLAG) - ctx->Current.EdgeFlag = IM->EdgeFlag[count]; - - if (flag & VERT_BIT_COLOR0) { - COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], - IM->Attrib[VERT_ATTRIB_COLOR0][count]); - if (ctx->Light.ColorMaterialEnabled) { - _mesa_update_color_material( ctx, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - } - } - - if (flag & VERT_BIT_COLOR1) - COPY_4FV(ctx->Current.Attrib[VERT_ATTRIB_COLOR1], - IM->Attrib[VERT_ATTRIB_COLOR1][count]); - - if (flag & VERT_BIT_FOG) - ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = IM->Attrib[VERT_ATTRIB_FOG][count][0]; - - if (flag & VERT_BITS_TEX_ANY) { - GLuint i; - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - if (flag & VERT_BIT_TEX(i)) { - COPY_4FV( ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i], - IM->Attrib[VERT_ATTRIB_TEX0 + i][count]); - } - } - } - - if (flag & VERT_BIT_MATERIAL) { - _mesa_update_material( ctx, - IM->Material[IM->LastMaterial], - IM->MaterialOrMask ); - - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - } -} - - - -void _tnl_compute_orflag( struct immediate *IM, GLuint start ) -{ - GLuint count = IM->Count; - GLuint orflag = 0; - GLuint andflag = ~0U; - GLuint i; - - IM->LastData = count-1; - - - /* Compute the flags for the whole buffer. - */ - for (i = start ; i < count ; i++) { - andflag &= IM->Flag[i]; - orflag |= IM->Flag[i]; - } - - /* It is possible there will be data in the buffer arising from - * calls like 'glNormal', 'glMaterial' that occur after the final - * glVertex, glEval, etc. Additionally, a buffer can consist of - * eg. a single glMaterial call, in which case IM->Start == - * IM->Count, but the buffer is definitely not empty. - */ - if (IM->Flag[i] & VERT_BITS_DATA) { - IM->LastData++; - orflag |= IM->Flag[i]; - } - - IM->Flag[IM->LastData+1] |= VERT_BIT_END_VB; - IM->CopyAndFlag = IM->AndFlag = andflag; - IM->OrFlag = orflag; - IM->CopyOrFlag = orflag; - IM->Evaluated = 0; -} - - -/** - * This is where the vertex data is transfered from the 'struct immediate - * into the 'struct vertex_buffer'. - * - * Note: The 'start' member of the GLvector structs is now redundant - * because we always re-transform copied vertices, and the vectors - * below are set up so that the first copied vertex (if any) appears - * at position zero. - */ -static void _tnl_vb_bind_immediate( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - struct vertex_arrays *tmp = &tnl->imm_inputs; - GLuint inputs = tnl->pipeline.inputs; /* for copy-to-current */ - const GLuint start = IM->CopyStart; - const GLuint count = IM->Count - start; - - /* TODO: optimize the case where nothing has changed. (Just bind - * tmp to vb). - */ - - /* Setup constant data in the VB. - */ - VB->Count = count; - VB->FirstClipped = IMM_MAXDATA - IM->CopyStart; - VB->import_data = NULL; - VB->importable_data = 0; - - /* Need an IM->FirstPrimitive? - */ - VB->Primitive = IM->Primitive + IM->CopyStart; - VB->PrimitiveLength = IM->PrimitiveLength + IM->CopyStart; - VB->FirstPrimitive = 0; - - VB->Flag = IM->Flag + start; - - /* TexCoordPtr's are zeroed in loop below. - */ - VB->NormalPtr = NULL; - VB->NormalLengthPtr = NULL; - VB->EdgeFlag = NULL; - VB->IndexPtr[0] = NULL; - VB->IndexPtr[1] = NULL; - VB->ColorPtr[0] = NULL; - VB->ColorPtr[1] = NULL; - VB->SecondaryColorPtr[0] = NULL; - VB->SecondaryColorPtr[1] = NULL; - VB->Elts = NULL; - VB->MaterialMask = NULL; - VB->Material = NULL; - -/* _tnl_print_vert_flags("copy-orflag", IM->CopyOrFlag); */ -/* _tnl_print_vert_flags("orflag", IM->OrFlag); */ -/* _tnl_print_vert_flags("inputs", inputs); */ - - /* Setup the initial values of array pointers in the vb. - */ - if (inputs & VERT_BIT_POS) { - tmp->Obj.data = IM->Attrib[VERT_ATTRIB_POS] + start; - tmp->Obj.start = (GLfloat *)(IM->Attrib[VERT_ATTRIB_POS] + start); - tmp->Obj.count = count; - VB->ObjPtr = &tmp->Obj; - if ((IM->CopyOrFlag & VERT_BITS_OBJ_234) == VERT_BITS_OBJ_234) - tmp->Obj.size = 4; - else if ((IM->CopyOrFlag & VERT_BITS_OBJ_234) == VERT_BITS_OBJ_23) - tmp->Obj.size = 3; - else - tmp->Obj.size = 2; - } - - if (inputs & VERT_BIT_NORMAL) { - tmp->Normal.data = IM->Attrib[VERT_ATTRIB_NORMAL] + start; - tmp->Normal.start = (GLfloat *) (IM->Attrib[VERT_ATTRIB_NORMAL] + start); - tmp->Normal.count = count; - tmp->Normal.size = 3; /* just to be safe */ - VB->NormalPtr = &tmp->Normal; - if (IM->NormalLengthPtr) - VB->NormalLengthPtr = IM->NormalLengthPtr + start; - } - - if (inputs & VERT_BIT_INDEX) { - tmp->Index.count = count; - tmp->Index.data = IM->Index + start; - tmp->Index.start = IM->Index + start; - VB->IndexPtr[0] = &tmp->Index; - } - - if (inputs & VERT_BIT_FOG) { - tmp->FogCoord.data = IM->Attrib[VERT_ATTRIB_FOG] + start; - tmp->FogCoord.start = (GLfloat *) (IM->Attrib[VERT_ATTRIB_FOG] + start); - tmp->FogCoord.count = count; - VB->FogCoordPtr = &tmp->FogCoord; - } - - if (inputs & VERT_BIT_COLOR1) { - tmp->SecondaryColor.Ptr = IM->Attrib[VERT_ATTRIB_COLOR1] + start; - VB->SecondaryColorPtr[0] = &tmp->SecondaryColor; - } - - if (inputs & VERT_BIT_EDGEFLAG) { - VB->EdgeFlag = IM->EdgeFlag + start; - } - - if (inputs & VERT_BIT_COLOR0) { - if (IM->CopyOrFlag & VERT_BIT_COLOR0) { - tmp->Color.Ptr = IM->Attrib[VERT_ATTRIB_COLOR0] + start; - tmp->Color.StrideB = 4 * sizeof(GLfloat); - tmp->Color.Flags = 0; - } - else { - tmp->Color.Ptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - tmp->Color.StrideB = 0; - tmp->Color.Flags = CA_CLIENT_DATA; /* hack */ - VB->import_source = IM; - VB->importable_data |= VERT_BIT_COLOR0; - VB->import_data = _tnl_upgrade_current_data; - } - VB->ColorPtr[0] = &tmp->Color; - } - - if (inputs & VERT_BITS_TEX_ANY) { - GLuint i; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { - VB->TexCoordPtr[i] = NULL; - if (inputs & VERT_BIT_TEX(i)) { - tmp->TexCoord[i].count = count; - tmp->TexCoord[i].data = IM->Attrib[VERT_ATTRIB_TEX0 + i] + start; - tmp->TexCoord[i].start = (GLfloat *)(IM->Attrib[VERT_ATTRIB_TEX0 + i] + start); - tmp->TexCoord[i].size = 2; - if (IM->TexSize & TEX_SIZE_3(i)) { - tmp->TexCoord[i].size = 3; - if (IM->TexSize & TEX_SIZE_4(i)) - tmp->TexCoord[i].size = 4; - } - VB->TexCoordPtr[i] = &tmp->TexCoord[i]; - } - } - } - - if ((inputs & IM->OrFlag & VERT_BIT_MATERIAL) && IM->Material) { - VB->MaterialMask = IM->MaterialMask + start; - VB->Material = IM->Material + start; - } - - /* GL_NV_vertex_program */ - if (ctx->VertexProgram.Enabled) { - GLuint attr; - for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { - tmp->Attribs[attr].count = count; - tmp->Attribs[attr].data = IM->Attrib[attr] + start; - tmp->Attribs[attr].start = (GLfloat *) (IM->Attrib[attr] + start); - tmp->Attribs[attr].size = 4; - VB->AttribPtr[attr] = &(tmp->Attribs[attr]); - } - } -} - - - - -/** - * Called by exec_vert_cassette, execute_compiled_cassette, but not - * exec_elt_cassette. - */ -void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - _tnl_vb_bind_immediate( ctx, IM ); - - if (IM->OrFlag & VERT_BITS_EVAL_ANY) - _tnl_eval_immediate( ctx, IM ); - - /* Invalidate all stored data before and after run: - */ - tnl->pipeline.run_input_changes |= tnl->pipeline.inputs; - tnl->Driver.RunPipeline( ctx ); - tnl->pipeline.run_input_changes |= tnl->pipeline.inputs; - - _tnl_copy_to_current( ctx, IM, IM->OrFlag, IM->LastData ); -} - - -/** - * Called for regular vertex cassettes. - */ -static void exec_vert_cassette( GLcontext *ctx, struct immediate *IM ) -{ - if (IM->FlushElt) { - /* Orflag is computed twice, but only reach this code if app is - * using a mixture of glArrayElement() and glVertex() while - * arrays are locked (else would be in exec_elt_cassette now). - */ - ASSERT(ctx->Array.LockCount); - ASSERT(IM->FlushElt == FLUSH_ELT_LAZY); - _tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->Count ); - _tnl_compute_orflag( IM, IM->CopyStart ); - } - - _tnl_fixup_input( ctx, IM ); -/* _tnl_print_cassette( IM ); */ - _tnl_run_cassette( ctx, IM ); -} - - -/* Called for pure, locked VERT_BIT_ELT cassettes instead of - * _tnl_run_cassette. - */ -static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - - _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount ); - - /* Take only elements and primitive information from the immediate: - */ - VB->Elts = IM->Elt + IM->CopyStart; - VB->Primitive = IM->Primitive + IM->CopyStart; - VB->PrimitiveLength = IM->PrimitiveLength + IM->CopyStart; - VB->FirstPrimitive = 0; - - /* Run the pipeline. No input changes as a result of this action. - */ - tnl->Driver.RunPipeline( ctx ); - - /* Still need to update current values: - */ - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) { - _tnl_translate_array_elts( ctx, IM, IM->LastData, IM->LastData ); - _tnl_copy_to_current( ctx, IM, ctx->Array._Enabled, IM->LastData ); - } -} - - -static void -exec_empty_cassette( GLcontext *ctx, struct immediate *IM ) -{ - if (IM->FlushElt) - _tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->CopyStart ); - - _tnl_copy_to_current( ctx, IM, IM->OrFlag, IM->LastData ); -} - - - -/** - * Called for all cassettes when not compiling or playing a display - * list. - */ -void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - _tnl_compute_orflag( IM, IM->Start ); - _tnl_copy_immediate_vertices( ctx, IM ); - _tnl_get_exec_copy_verts( ctx, IM ); - - if (tnl->pipeline.build_state_changes) - _tnl_validate_pipeline( ctx ); - - if (IM->CopyStart == IM->Count) { - exec_empty_cassette( ctx, IM ); - } - else if ((IM->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT && - ctx->Array.LockCount && - ctx->Array.Vertex.Enabled) { - exec_elt_cassette( ctx, IM ); - } - else { - exec_vert_cassette( ctx, IM ); - } - - /* Only reuse the immediate if there are no copied vertices living - * inside it: - */ - { - GLuint begin_state = IM->BeginState & (VERT_BEGIN_0|VERT_BEGIN_1); - GLuint saved_begin_state = IM->SavedBeginState; - - if (--IM->ref_count != 0) { - IM = _tnl_alloc_immediate( ctx ); - SET_IMMEDIATE( ctx, IM ); - } - - IM->ref_count++; - - _tnl_reset_exec_input( ctx, IMM_MAX_COPIED_VERTS, - begin_state, saved_begin_state ); - } - - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) - ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES; -} - - - - -/** - * Setup vector pointers that will be used to bind immediates to VB's. - */ -void _tnl_imm_init( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_arrays *tmp = &tnl->imm_inputs; - GLuint i; - static int firsttime = 1; - - if (firsttime) { - firsttime = 0; - _tnl_imm_elt_init(); - } - - ctx->swtnl_im = _tnl_alloc_immediate( ctx ); - TNL_CURRENT_IM(ctx)->ref_count++; - - tnl->ExecCopyTexSize = 0; - tnl->ExecCopyCount = 0; - tnl->ExecCopySource = 0; - - TNL_CURRENT_IM(ctx)->CopyStart = IMM_MAX_COPIED_VERTS; - - _mesa_vector4f_init( &tmp->Obj, 0, 0 ); - _mesa_vector4f_init( &tmp->Normal, 0, 0 ); - - tmp->Color.Ptr = NULL; - tmp->Color.Type = GL_FLOAT; - tmp->Color.Size = 4; - tmp->Color.Stride = 0; - tmp->Color.StrideB = 4 * sizeof(GLfloat); - tmp->Color.Flags = 0; - - tmp->SecondaryColor.Ptr = NULL; - tmp->SecondaryColor.Type = GL_FLOAT; - tmp->SecondaryColor.Size = 4; - tmp->SecondaryColor.Stride = 0; - tmp->SecondaryColor.StrideB = 4 * sizeof(GLfloat); - tmp->SecondaryColor.Flags = 0; - - _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); - _mesa_vector1ui_init( &tmp->Index, 0, 0 ); - _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); - - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - _mesa_vector4f_init( &tmp->TexCoord[i], 0, 0); - - /* Install the first immediate. Intially outside begin/end. - */ - _tnl_reset_exec_input( ctx, IMM_MAX_COPIED_VERTS, 0, 0 ); - tnl->ReplayHardBeginEnd = 0; - - _tnl_imm_vtxfmt_init( ctx ); -} - - -/** - * Deallocate the immediate-mode buffer for the given context, if - * its reference count goes to zero. - */ -void _tnl_imm_destroy( GLcontext *ctx ) -{ - if (TNL_CURRENT_IM(ctx)) { - TNL_CURRENT_IM(ctx)->ref_count--; - if (TNL_CURRENT_IM(ctx)->ref_count == 0) - _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) ); - /* - * Don't use SET_IMMEDIATE here, or else we'll whack the - * _tnl_CurrentInput pointer - not good when another - * context has already been made current. - * So we just set the context's own tnl immediate pointer - * to 0. - */ - ctx->swtnl_im = NULL; - } -} diff --git a/src/mesa/tnl/t_imm_exec.h b/src/mesa/tnl/t_imm_exec.h deleted file mode 100644 index 99b816d82e..0000000000 --- a/src/mesa/tnl/t_imm_exec.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $Id: t_imm_exec.h,v 1.8 2002/04/19 12:32:14 brianp Exp $ */ - -/* - * 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_VBXFORM_H -#define _T_VBXFORM_H - -#include "mtypes.h" -#include "t_context.h" - - -/* Hook for ctx->Driver.FlushVertices: - */ -extern void _tnl_flush_vertices( GLcontext *ctx, GLuint flush_flags ); - -/* Called from imm_api.c and _tnl_flush_vertices: - */ -extern void _tnl_flush_immediate( GLcontext *ctx, struct immediate *IM ); - -/* Called from imm_dlist.c and _tnl_flush_immediate: - */ -extern void _tnl_run_cassette( GLcontext *ctx, struct immediate *IM ); -extern void _tnl_copy_to_current( GLcontext *ctx, struct immediate *IM, - GLuint flag, GLuint row ); - -/* Initialize some stuff: - */ -extern void _tnl_imm_init( GLcontext *ctx ); - -extern void _tnl_imm_destroy( GLcontext *ctx ); - -extern void _tnl_reset_exec_input( GLcontext *ctx, - GLuint start, - GLuint beginstate, - GLuint savedbeginstate ); - -extern void _tnl_reset_compile_input( GLcontext *ctx, - GLuint start, - GLuint beginstate, - GLuint savedbeginstate ); - -extern void _tnl_compute_orflag( struct immediate *IM, GLuint start ); -extern void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM ); - - - -#endif diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c deleted file mode 100644 index 007a2130a5..0000000000 --- a/src/mesa/tnl/t_imm_fixup.c +++ /dev/null @@ -1,871 +0,0 @@ -/* $Id: t_imm_fixup.c,v 1.37 2002/06/29 19:48:17 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.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 <keithw@valinux.com> - */ - - -#include "glheader.h" -#include "context.h" -#include "enums.h" -#include "dlist.h" -#include "colormac.h" -#include "light.h" -#include "macros.h" -#include "mem.h" -#include "mmath.h" -#include "state.h" -#include "mtypes.h" - -#include "math/m_matrix.h" -#include "math/m_xform.h" - -#include "t_context.h" -#include "t_imm_alloc.h" -#include "t_imm_debug.h" -#include "t_imm_elt.h" -#include "t_imm_fixup.h" -#include "t_imm_exec.h" -#include "t_pipeline.h" - - -static const GLuint increment[GL_POLYGON+2] = { 1,2,1,1,3,1,1,4,2,1,1 }; -static const GLuint intro[GL_POLYGON+2] = { 0,0,2,2,0,2,2,0,2,2,0 }; - -void -_tnl_fixup_4f( GLfloat data[][4], GLuint flag[], GLuint start, GLuint match ) -{ - GLuint i = start; - - for (;;) { - if ((flag[++i] & match) == 0) { - COPY_4FV(data[i], data[i-1]); - if (flag[i] & VERT_BIT_END_VB) break; - } - } -} - -void -_tnl_fixup_3f( float data[][3], GLuint flag[], GLuint start, GLuint match ) -{ - GLuint i = start; - - - for (;;) { - if ((flag[++i] & match) == 0) { -/* _mesa_debug(NULL, "_tnl_fixup_3f copy to %p values %f %f %f\n", */ -/* data[i], */ -/* data[i-1][0], */ -/* data[i-1][1], */ -/* data[i-1][2]); */ - COPY_3V(data[i], data[i-1]); - if (flag[i] & VERT_BIT_END_VB) break; - } - } -} - - -void -_tnl_fixup_1ui( GLuint *data, GLuint flag[], GLuint start, GLuint match ) -{ - GLuint i = start; - - for (;;) { - if ((flag[++i] & match) == 0) { - data[i] = data[i-1]; - if (flag[i] & VERT_BIT_END_VB) break; - } - } - flag[i] |= match; -} - - -void -_tnl_fixup_1f( GLfloat *data, GLuint flag[], GLuint start, GLuint match ) -{ - GLuint i = start; - - for (;;) { - if ((flag[++i] & match) == 0) { - data[i] = data[i-1]; - if (flag[i] & VERT_BIT_END_VB) break; - } - } - flag[i] |= match; -} - -void -_tnl_fixup_1ub( GLubyte *data, GLuint flag[], GLuint start, GLuint match ) -{ - GLuint i = start; - - for (;;) { - if ((flag[++i] & match) == 0) { - data[i] = data[i-1]; - if (flag[i] & VERT_BIT_END_VB) break; - } - } - flag[i] |= match; -} - - -static void -fixup_first_4f( GLfloat data[][4], GLuint flag[], GLuint match, - GLuint start, GLfloat *dflt ) -{ - GLuint i = start-1; - match |= VERT_BIT_END_VB; - - while ((flag[++i]&match) == 0) - COPY_4FV(data[i], dflt); -} - -#if 0 -static void -fixup_first_3f( GLfloat data[][3], GLuint flag[], GLuint match, - GLuint start, GLfloat *dflt ) -{ - GLuint i = start-1; - match |= VERT_BIT_END_VB; - -/* _mesa_debug(NULL, "fixup_first_3f default: %f %f %f start: %d\n", */ -/* dflt[0], dflt[1], dflt[2], start); */ - - while ((flag[++i]&match) == 0) - COPY_3FV(data[i], dflt); -} -#endif - -static void -fixup_first_1ui( GLuint data[], GLuint flag[], GLuint match, - GLuint start, GLuint dflt ) -{ - GLuint i = start-1; - match |= VERT_BIT_END_VB; - - while ((flag[++i]&match) == 0) - data[i] = dflt; -} - -#if 00 -static void -fixup_first_1f( GLfloat data[], GLuint flag[], GLuint match, - GLuint start, GLfloat dflt ) -{ - GLuint i = start-1; - match |= VERT_BIT_END_VB; - - while ((flag[++i]&match) == 0) - data[i] = dflt; -} -#endif - -static void -fixup_first_1ub( GLubyte data[], GLuint flag[], GLuint match, - GLuint start, GLubyte dflt ) -{ - GLuint i = start-1; - match |= VERT_BIT_END_VB; - - while ((flag[++i]&match) == 0) - data[i] = dflt; -} - -/* - * Copy vertex attributes from the ctx->Current group into the immediate - * struct at the given position according to copyMask. - */ -static void copy_from_current( GLcontext *ctx, struct immediate *IM, - GLuint pos, GLuint copyMask ) -{ - GLuint attrib, attribBit; - - if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - _tnl_print_vert_flags("copy from current", copyMask); - -#if 0 - if (copyMask & VERT_BIT_NORMAL) { - COPY_4V(IM->Attrib[VERT_ATTRIB_NORMAL][pos], - ctx->Current.Attrib[VERT_ATTRIB_NORMAL]); - } - - if (copyMask & VERT_BIT_COLOR0) { - COPY_4FV( IM->Attrib[VERT_ATTRIB_COLOR0][pos], - ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); - } - - if (copyMask & VERT_BIT_COLOR1) - COPY_4FV( IM->Attrib[VERT_ATTRIB_COLOR1][pos], - ctx->Current.Attrib[VERT_ATTRIB_COLOR1]); - - if (copyMask & VERT_BIT_FOG) - IM->Attrib[VERT_ATTRIB_FOG][pos][0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0]; - - if (copyMask & VERT_BITS_TEX_ANY) { - GLuint i; - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - if (copyMask & VERT_BIT_TEX(i)) - COPY_4FV(IM->Attrib[VERT_ATTRIB_TEX0 + i][pos], - ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i]); - } - } -#else - for (attrib = 0, attribBit = 1; attrib < 16; attrib++, attribBit <<= 1) { - if (copyMask & attribBit) { - COPY_4FV( IM->Attrib[attrib][pos], ctx->Current.Attrib[attrib]); - } - } -#endif - - if (copyMask & VERT_BIT_INDEX) - IM->Index[pos] = ctx->Current.Index; - - if (copyMask & VERT_BIT_EDGEFLAG) - IM->EdgeFlag[pos] = ctx->Current.EdgeFlag; -} - - -void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint start = IM->CopyStart; - GLuint andflag = IM->CopyAndFlag; - GLuint orflag = IM->CopyOrFlag | IM->Evaluated; - GLuint fixup; - - IM->CopyTexSize = IM->TexSize; - -/* _mesa_debug(ctx, "Fixup input, Start: %u Count: %u LastData: %u\n", */ -/* IM->Start, IM->Count, IM->LastData); */ -/* _tnl_print_vert_flags("Orflag", orflag); */ -/* _tnl_print_vert_flags("Andflag", andflag); */ - - - fixup = ~andflag & VERT_BITS_FIXUP; - - if (!ctx->CompileFlag) - fixup &= tnl->pipeline.inputs; - - if (!ctx->ExecuteFlag) - fixup &= orflag; - - if ((orflag & (VERT_BIT_POS|VERT_BITS_EVAL_ANY)) == 0) - fixup = 0; - - if (fixup) { - GLuint copy = fixup & ~IM->Flag[start]; - - - /* Equivalent to a lazy copy-from-current when setting up the - * immediate. - */ - if (ctx->ExecuteFlag && copy) - copy_from_current( ctx, IM, start, copy ); - - if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - _tnl_print_vert_flags("fixup", fixup); - - /* XXX replace these conditionals with a loop over the 16 - * vertex attributes. - */ - - if (fixup & VERT_BITS_TEX_ANY) { - GLuint i; - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - if (fixup & VERT_BIT_TEX(i)) { - if (orflag & VERT_BIT_TEX(i)) - _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], IM->Flag, - start, VERT_BIT_TEX(i) ); - else - fixup_first_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], IM->Flag, - VERT_BIT_END_VB, start, - IM->Attrib[VERT_ATTRIB_TEX0 + i][start]); - } - } - } - - - if (fixup & VERT_BIT_EDGEFLAG) { - if (orflag & VERT_BIT_EDGEFLAG) - _tnl_fixup_1ub( IM->EdgeFlag, IM->Flag, start, VERT_BIT_EDGEFLAG ); - else - fixup_first_1ub( IM->EdgeFlag, IM->Flag, VERT_BIT_END_VB, start, - IM->EdgeFlag[start] ); - } - - if (fixup & VERT_BIT_INDEX) { - if (orflag & VERT_BIT_INDEX) - _tnl_fixup_1ui( IM->Index, IM->Flag, start, VERT_BIT_INDEX ); - else - fixup_first_1ui( IM->Index, IM->Flag, VERT_BIT_END_VB, start, - IM->Index[start] ); - } - - if (fixup & VERT_BIT_COLOR0) { - if (orflag & VERT_BIT_COLOR0) - _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_COLOR0], IM->Flag, start, - VERT_BIT_COLOR0 ); - /* No need for else case as the drivers understand stride - * zero here. (TODO - propogate this) - */ - } - - if (fixup & VERT_BIT_COLOR1) { - if (orflag & VERT_BIT_COLOR1) - _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_COLOR1], IM->Flag, start, - VERT_BIT_COLOR1 ); - else - fixup_first_4f( IM->Attrib[VERT_ATTRIB_COLOR1], IM->Flag, VERT_BIT_END_VB, start, - IM->Attrib[VERT_ATTRIB_COLOR1][start] ); - } - - if (fixup & VERT_BIT_FOG) { - if (orflag & VERT_BIT_FOG) - _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_FOG], IM->Flag, - start, VERT_BIT_FOG ); - else - fixup_first_4f( IM->Attrib[VERT_ATTRIB_FOG], IM->Flag, VERT_BIT_END_VB, - start, IM->Attrib[VERT_ATTRIB_FOG][start] ); - } - - if (fixup & VERT_BIT_NORMAL) { - if (orflag & VERT_BIT_NORMAL) - _tnl_fixup_4f( IM->Attrib[VERT_ATTRIB_NORMAL], IM->Flag, start, - VERT_BIT_NORMAL ); - else - fixup_first_4f( IM->Attrib[VERT_ATTRIB_NORMAL], IM->Flag, - VERT_BIT_END_VB, start, - IM->Attrib[VERT_ATTRIB_NORMAL][start] ); - } - } - - /* Prune possible half-filled slot. - */ - IM->Flag[IM->LastData+1] &= ~VERT_BIT_END_VB; - IM->Flag[IM->Count] |= VERT_BIT_END_VB; - - - /* Materials: - */ - if (IM->MaterialOrMask & ~IM->MaterialAndMask) { - GLuint vulnerable = IM->MaterialOrMask; - GLuint i = IM->Start; - - do { - while (!(IM->Flag[i] & VERT_BIT_MATERIAL)) - i++; - - vulnerable &= ~IM->MaterialMask[i]; - _mesa_copy_material_pairs( IM->Material[i], - ctx->Light.Material, - vulnerable ); - - - ++i; - } while (vulnerable); - } -} - - -static void -copy_material( struct immediate *next, - struct immediate *prev, - GLuint dst, GLuint src ) -{ -/* _mesa_debug(NULL, "%s\n", __FUNCTION__); */ - - if (next->Material == 0) { - next->Material = (struct gl_material (*)[2]) - MALLOC( sizeof(struct gl_material) * IMM_SIZE * 2 ); - next->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * IMM_SIZE ); - } - - next->MaterialMask[dst] = prev->MaterialOrMask; - MEMCPY(next->Material[dst], prev->Material[src], - 2 * sizeof(struct gl_material)); -} - - - -static GLboolean is_fan_like[GL_POLYGON+1] = { - GL_FALSE, - GL_FALSE, - GL_TRUE, /* line loop */ - GL_FALSE, - GL_FALSE, - GL_FALSE, - GL_TRUE, /* tri fan */ - GL_FALSE, - GL_FALSE, - GL_TRUE /* polygon */ -}; - - -/* Copy the untransformed data from the shared vertices of a primitive - * that wraps over two immediate structs. This is done prior to - * set_immediate so that prev and next may point to the same - * structure. In general it's difficult to avoid this copy on long - * primitives. - * - * Have to be careful with the transitions between display list - * replay, compile and normal execute modes. - */ -void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct immediate *prev = tnl->ExecCopySource; - struct vertex_arrays *inputs = &tnl->imm_inputs; - GLuint count = tnl->ExecCopyCount; - GLuint *elts = tnl->ExecCopyElts; - GLuint offset = IMM_MAX_COPIED_VERTS - count; - GLuint i; - - if (!prev) { - ASSERT(tnl->ExecCopyCount == 0); - return; - } - - next->CopyStart = next->Start - count; - - if ((prev->CopyOrFlag & VERT_BITS_DATA) == VERT_BIT_ELT && - ctx->Array.LockCount && - ctx->Array.Vertex.Enabled) - { - /* Copy Elt values only - */ - for (i = 0 ; i < count ; i++) - { - GLuint src = elts[i+offset]; - GLuint dst = next->CopyStart+i; - next->Elt[dst] = prev->Elt[src]; - next->Flag[dst] = VERT_BIT_ELT; - elts[i+offset] = dst; - } -/* _mesa_debug(ctx, "ADDING VERT_BIT_ELT!\n"); */ - next->CopyOrFlag |= VERT_BIT_ELT; - next->CopyAndFlag &= VERT_BIT_ELT; - } - else { - GLuint copy = tnl->pipeline.inputs & (prev->CopyOrFlag|prev->Evaluated); - GLuint flag; - - if (is_fan_like[ctx->Driver.CurrentExecPrimitive]) { - flag = ((prev->CopyOrFlag|prev->Evaluated) & VERT_BITS_FIXUP); - next->CopyOrFlag |= flag; - } - else { - /* Don't let an early 'glColor', etc. poison the elt path. - */ - flag = ((prev->OrFlag|prev->Evaluated) & VERT_BITS_FIXUP); - } - - next->TexSize |= tnl->ExecCopyTexSize; - next->CopyAndFlag &= flag; - - -/* _tnl_print_vert_flags("copy vertex components", copy); */ -/* _tnl_print_vert_flags("prev copyorflag", prev->CopyOrFlag); */ -/* _tnl_print_vert_flags("flag", flag); */ - - /* Copy whole vertices - */ - for (i = 0 ; i < count ; i++) - { - GLuint src = elts[i+offset]; - GLuint isrc = src - prev->CopyStart; - GLuint dst = next->CopyStart+i; - - /* Values subject to eval must be copied out of the 'inputs' - * struct. (Copied rows should not be evaluated twice). - * - * Note these pointers are null when inactive. - */ - COPY_4FV( next->Attrib[VERT_ATTRIB_POS][dst], - inputs->Obj.data[isrc] ); - - if (copy & VERT_BIT_NORMAL) { -/* _mesa_debug(ctx, "copy vert norm %d to %d (%p): %f %f %f\n", */ -/* isrc, dst, */ -/* next->Normal[dst], */ -/* inputs->Normal.data[isrc][0], */ -/* inputs->Normal.data[isrc][1], */ -/* inputs->Normal.data[isrc][2]); */ - COPY_3FV( next->Attrib[VERT_ATTRIB_NORMAL][dst], inputs->Normal.data[isrc] ); - } - - if (copy & VERT_BIT_COLOR0) - COPY_4FV( next->Attrib[VERT_ATTRIB_COLOR0][dst], - ((GLfloat (*)[4])inputs->Color.Ptr)[isrc] ); - - if (copy & VERT_BIT_INDEX) - next->Index[dst] = inputs->Index.data[isrc]; - - if (copy & VERT_BITS_TEX_ANY) { - GLuint i; - for (i = 0 ; i < prev->MaxTextureUnits ; i++) { - if (copy & VERT_BIT_TEX(i)) - COPY_4FV( next->Attrib[VERT_ATTRIB_TEX0 + i][dst], - inputs->TexCoord[i].data[isrc] ); - } - } - - /* Remaining values should be the same in the 'input' struct and the - * original immediate. - */ - if (copy & (VERT_BIT_ELT|VERT_BIT_EDGEFLAG|VERT_BIT_COLOR1|VERT_BIT_FOG| - VERT_BIT_MATERIAL)) { - - if (prev->Flag[src] & VERT_BIT_MATERIAL) - copy_material(next, prev, dst, src); - - next->Elt[dst] = prev->Elt[src]; - next->EdgeFlag[dst] = prev->EdgeFlag[src]; - COPY_4FV( next->Attrib[VERT_ATTRIB_COLOR1][dst], - prev->Attrib[VERT_ATTRIB_COLOR1][src] ); - COPY_4FV( next->Attrib[VERT_ATTRIB_FOG][dst], - prev->Attrib[VERT_ATTRIB_FOG][src] ); - } - - next->Flag[dst] = flag; - next->CopyOrFlag |= prev->Flag[src] & (VERT_BITS_FIXUP| - VERT_BIT_MATERIAL| - VERT_BIT_POS); - elts[i+offset] = dst; - } - } - - if (--tnl->ExecCopySource->ref_count == 0) - _tnl_free_immediate( ctx, tnl->ExecCopySource ); - - tnl->ExecCopySource = next; next->ref_count++; -} - - - -/* Revive a compiled immediate struct - propogate new 'Current' - * values. Often this is redundant because the current values were - * known and fixed up at compile time (or in the first execution of - * the cassette). - */ -void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint fixup; - GLuint start = IM->Start; - -/* _mesa_debug(ctx, "%s\n", __FUNCTION__); */ - - IM->Evaluated = 0; - IM->CopyOrFlag = IM->OrFlag; - IM->CopyAndFlag = IM->AndFlag; - IM->CopyTexSize = IM->TexSize | tnl->ExecCopyTexSize; - - _tnl_copy_immediate_vertices( ctx, IM ); - - if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) { - ASSERT(IM->CopyStart == IM->Start); - } - - /* Naked array elements can be copied into the first cassette in a - * display list. Need to translate them away: - */ - if (IM->CopyOrFlag & VERT_BIT_ELT) { - GLuint copy = tnl->pipeline.inputs & ~ctx->Array._Enabled; - GLuint i; - - ASSERT(IM->CopyStart < IM->Start); - - _tnl_translate_array_elts( ctx, IM, IM->CopyStart, IM->Start ); - - for (i = IM->CopyStart ; i < IM->Start ; i++) - copy_from_current( ctx, IM, i, copy ); - - _tnl_copy_to_current( ctx, IM, ctx->Array._Enabled, IM->Start ); - } - - fixup = tnl->pipeline.inputs & ~IM->Flag[start] & VERT_BITS_FIXUP; - -/* _tnl_print_vert_flags("fixup compiled", fixup); */ - - if (fixup) { - - /* XXX try to replace this code with a loop over the 16 vertex - * attributes. - */ - - if (fixup & VERT_BIT_NORMAL) { - fixup_first_4f(IM->Attrib[VERT_ATTRIB_NORMAL], IM->Flag, - VERT_BIT_NORMAL, start, - ctx->Current.Attrib[VERT_ATTRIB_NORMAL] ); - } - - if (fixup & VERT_BIT_COLOR0) { - if (IM->CopyOrFlag & VERT_BIT_COLOR0) - fixup_first_4f(IM->Attrib[VERT_ATTRIB_COLOR0], IM->Flag, - VERT_BIT_COLOR0, start, - ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); - else - fixup &= ~VERT_BIT_COLOR0; - } - - if (fixup & VERT_BIT_COLOR1) - fixup_first_4f(IM->Attrib[VERT_ATTRIB_COLOR1], IM->Flag, - VERT_BIT_COLOR1, start, - ctx->Current.Attrib[VERT_ATTRIB_COLOR1] ); - - if (fixup & VERT_BIT_FOG) - fixup_first_4f( IM->Attrib[VERT_ATTRIB_FOG], IM->Flag, - VERT_BIT_FOG, start, - ctx->Current.Attrib[VERT_ATTRIB_FOG] ); - - if (fixup & VERT_BITS_TEX_ANY) { - GLuint i; - for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { - if (fixup & VERT_BIT_TEX(i)) - fixup_first_4f( IM->Attrib[VERT_ATTRIB_TEX0 + i], IM->Flag, - VERT_BIT_TEX(i), start, - ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i] ); - } - } - - if (fixup & VERT_BIT_EDGEFLAG) - fixup_first_1ub(IM->EdgeFlag, IM->Flag, VERT_BIT_EDGEFLAG, start, - ctx->Current.EdgeFlag ); - - if (fixup & VERT_BIT_INDEX) - fixup_first_1ui(IM->Index, IM->Flag, VERT_BIT_INDEX, start, - ctx->Current.Index ); - - IM->CopyOrFlag |= fixup; - } - - - /* Materials: - */ - if (IM->MaterialOrMask & ~IM->MaterialAndMask) { - GLuint vulnerable = IM->MaterialOrMask; - GLuint i = IM->Start; - - do { - while (!(IM->Flag[i] & VERT_BIT_MATERIAL)) - i++; - - vulnerable &= ~IM->MaterialMask[i]; - _mesa_copy_material_pairs( IM->Material[i], - ctx->Light.Material, - vulnerable ); - - - ++i; - } while (vulnerable); - } -} - - - - - - -static void copy_none( TNLcontext *tnl, GLuint start, GLuint count, GLuint ovf) -{ - (void) (start && ovf && tnl && count); -} - -static void copy_last( TNLcontext *tnl, GLuint start, GLuint count, GLuint ovf) -{ - (void) start; (void) ovf; - tnl->ExecCopyCount = 1; - tnl->ExecCopyElts[2] = count-1; -} - -static void copy_first_and_last( TNLcontext *tnl, GLuint start, GLuint count, - GLuint ovf) -{ - (void) ovf; - tnl->ExecCopyCount = 2; - tnl->ExecCopyElts[1] = start; - tnl->ExecCopyElts[2] = count-1; -} - -static void copy_last_two( TNLcontext *tnl, GLuint start, GLuint count, - GLuint ovf ) -{ - (void) start; - tnl->ExecCopyCount = 2+ovf; - tnl->ExecCopyElts[0] = count-3; - tnl->ExecCopyElts[1] = count-2; - tnl->ExecCopyElts[2] = count-1; -} - -static void copy_overflow( TNLcontext *tnl, GLuint start, GLuint count, - GLuint ovf ) -{ - (void) start; - tnl->ExecCopyCount = ovf; - tnl->ExecCopyElts[0] = count-3; - tnl->ExecCopyElts[1] = count-2; - tnl->ExecCopyElts[2] = count-1; -} - - -typedef void (*copy_func)( TNLcontext *tnl, GLuint start, GLuint count, - GLuint ovf ); - -static copy_func copy_tab[GL_POLYGON+2] = -{ - copy_none, - copy_overflow, - copy_first_and_last, - copy_last, - copy_overflow, - copy_last_two, - copy_first_and_last, - copy_overflow, - copy_last_two, - copy_first_and_last, - copy_none -}; - - - - - -/* Figure out what vertices need to be copied next time. - */ -void -_tnl_get_exec_copy_verts( GLcontext *ctx, struct immediate *IM ) -{ - - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint last = IM->LastPrimitive; - GLuint prim = ctx->Driver.CurrentExecPrimitive; - GLuint pincr = increment[prim]; - GLuint pintro = intro[prim]; - GLuint ovf = 0; - -/* _mesa_debug(ctx, "_tnl_get_exec_copy_verts %s\n", */ -/* _mesa_lookup_enum_by_nr(prim)); */ - - if (tnl->ExecCopySource) - if (--tnl->ExecCopySource->ref_count == 0) - _tnl_free_immediate( ctx, tnl->ExecCopySource ); - - if (prim == GL_POLYGON+1) { - tnl->ExecCopySource = 0; - tnl->ExecCopyCount = 0; - tnl->ExecCopyTexSize = 0; - tnl->ExecParity = 0; - } else { - /* Remember this immediate as the one to copy from. - */ - tnl->ExecCopySource = IM; IM->ref_count++; - tnl->ExecCopyCount = 0; - tnl->ExecCopyTexSize = IM->CopyTexSize; - - if (IM->LastPrimitive != IM->CopyStart) - tnl->ExecParity = 0; - - tnl->ExecParity ^= IM->PrimitiveLength[IM->LastPrimitive] & 1; - - - if (pincr != 1 && (IM->Count - last - pintro)) - ovf = (IM->Count - last - pintro) % pincr; - - if (last < IM->Count) - copy_tab[prim]( tnl, last, IM->Count, ovf ); - } -} - - -/* Recalculate ExecCopyElts, ExecParity, etc. - */ -void -_tnl_get_purged_copy_verts( GLcontext *ctx, struct immediate *IM ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) { - GLuint last = IM->LastPrimitive; - GLenum prim = IM->Primitive[last]; - GLuint pincr = increment[prim]; - GLuint pintro = intro[prim]; - GLuint ovf = 0, i; - - tnl->ExecCopyCount = 0; - if (IM->LastPrimitive != IM->CopyStart) - tnl->ExecParity = 0; - - tnl->ExecParity ^= IM->PrimitiveLength[IM->LastPrimitive] & 1; - - if (pincr != 1 && (IM->Count - last - pintro)) - ovf = (IM->Count - last - pintro) % pincr; - - if (last < IM->Count) - copy_tab[prim]( tnl, last, IM->Count, ovf ); - - for (i = 0 ; i < tnl->ExecCopyCount ; i++) - tnl->ExecCopyElts[i] = IM->Elt[tnl->ExecCopyElts[i]]; - } -} - - -void _tnl_upgrade_current_data( GLcontext *ctx, - GLuint required, - GLuint flags ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_buffer *VB = &tnl->vb; - struct immediate *IM = (struct immediate *)VB->import_source; - - ASSERT(IM); - -/* _tnl_print_vert_flags("_tnl_upgrade_client_data", required); */ - - if ((required & VERT_BIT_COLOR0) && (VB->ColorPtr[0]->Flags & CA_CLIENT_DATA)) { - struct gl_client_array *tmp = &tnl->imm_inputs.Color; - GLuint start = IM->CopyStart; - - tmp->Ptr = IM->Attrib[VERT_ATTRIB_COLOR0] + start; - tmp->StrideB = 4 * sizeof(GLfloat); - tmp->Flags = 0; - - COPY_4FV( IM->Attrib[VERT_ATTRIB_COLOR0][start], - ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); - - /* - ASSERT(IM->Flag[IM->LastData+1] & VERT_BIT_END_VB); - */ - - fixup_first_4f( IM->Attrib[VERT_ATTRIB_COLOR0], IM->Flag, - VERT_BIT_END_VB, - start, IM->Attrib[VERT_ATTRIB_COLOR0][start] ); - - VB->importable_data &= ~VERT_BIT_COLOR0; - } -} - diff --git a/src/mesa/tnl/t_imm_fixup.h b/src/mesa/tnl/t_imm_fixup.h deleted file mode 100644 index 806933aa68..0000000000 --- a/src/mesa/tnl/t_imm_fixup.h +++ /dev/null @@ -1,64 +0,0 @@ -/* $Id: t_imm_fixup.h,v 1.6 2001/06/04 16:09:28 keithw Exp $ */ - -/* - * 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_IMM_FIXUP_H -#define _T_IMM_FIXUP_H - -#include "mtypes.h" -#include "t_context.h" - -extern void _tnl_fixup_1ub( GLubyte *data, GLuint flag[], - GLuint start, GLuint match ); - -extern void _tnl_fixup_1f( GLfloat *data, GLuint flag[], - GLuint start, GLuint match ); - -extern void _tnl_fixup_1ui( GLuint *data, GLuint flag[], - GLuint start, GLuint match ); - -extern void _tnl_fixup_3f( float data[][3], GLuint flag[], - GLuint start, GLuint match ); - -extern void _tnl_fixup_4f( GLfloat data[][4], GLuint flag[], - GLuint start, GLuint match ); - -extern void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ); - -extern void _tnl_fixup_compiled_cassette( GLcontext *ctx, - struct immediate *IM ); - -extern void _tnl_copy_immediate_vertices( GLcontext *ctx, - struct immediate *IM ); - -extern void _tnl_get_purged_copy_verts( GLcontext *ctx, struct immediate *IM ); - -extern void _tnl_get_exec_copy_verts( GLcontext *ctx, struct immediate *IM ); - -extern void _tnl_upgrade_current_data( GLcontext *ctx, GLuint required, - GLuint flags ); - -#endif diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c index d17719f6d7..47a3b32260 100644 --- a/src/mesa/tnl/t_pipeline.c +++ b/src/mesa/tnl/t_pipeline.c @@ -1,4 +1,4 @@ -/* $Id: t_pipeline.c,v 1.22 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_pipeline.c,v 1.22.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -155,7 +155,6 @@ void _tnl_run_pipeline( GLcontext *ctx ) running = s->run( ctx, s ); s->changed_inputs = 0; - VB->importable_data &= ~s->outputs; } } diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index 33d605f96d..9a2c91e0c9 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_cliptmp.h,v 1.15 2002/03/29 17:27:59 brianp Exp $ */ +/* $Id: t_vb_cliptmp.h,v 1.15.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -118,7 +118,7 @@ do { \ /* Clip a line against the viewport and user clip planes. */ -static INLINE void +static void TAG(clip_line)( GLcontext *ctx, GLuint i, GLuint j, GLubyte mask ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -159,7 +159,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint i, GLuint j, GLubyte mask ) /* Clip a triangle against the viewport and user clip planes. */ -static INLINE void +static void TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) { TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -211,7 +211,7 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask ) /* Clip a quad against the viewport and user clip planes. */ -static INLINE void +static void TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLubyte mask ) { diff --git a/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c index 01b553a191..32b4039b36 100644 --- a/src/mesa/tnl/t_vb_fog.c +++ b/src/mesa/tnl/t_vb_fog.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_fog.c,v 1.17 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_vb_fog.c,v 1.17.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -142,7 +142,7 @@ static GLboolean run_fog_stage( GLcontext *ctx, /* fog computed from Z depth */ /* source = VB->ObjPtr or VB->EyePtr coords */ /* dest = VB->FogCoordPtr = fog stage private storage */ - VB->FogCoordPtr = &store->fogcoord; + VB->AttrPtr[VERT_ATTRIB_FOG] = &store->fogcoord; if (!ctx->_NeedEyeCoords) { const GLfloat *m = ctx->ModelviewMatrixStack.Top->m; @@ -180,13 +180,13 @@ static GLboolean run_fog_stage( GLcontext *ctx, } else { /* use glFogCoord() coordinates */ - /* source = VB->FogCoordPtr */ - input = VB->FogCoordPtr; + /* source = VB->AttrPtr[VERT_ATTRIB_FOG] */ + input = VB->AttrPtr[VERT_ATTRIB_FOG]; /* dest = fog stage private storage */ - VB->FogCoordPtr = &store->fogcoord; + VB->AttrPtr[VERT_ATTRIB_FOG] = &store->fogcoord; } - make_win_fog_coords( ctx, VB->FogCoordPtr, input ); + make_win_fog_coords( ctx, VB->AttrPtr[VERT_ATTRIB_FOG], input ); return GL_TRUE; } diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index 99f15d8036..1735e7ac7d 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_light.c,v 1.18 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_vb_light.c,v 1.18.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -40,7 +40,6 @@ #include "t_context.h" #include "t_pipeline.h" -#define LIGHT_FLAGS 0x1 /* must be first */ #define LIGHT_TWOSIDE 0x2 #define LIGHT_COLORMATERIAL 0x4 #define MAX_LIGHT_FUNC 0x8 @@ -62,39 +61,6 @@ struct light_stage_data { #define LIGHT_STAGE_DATA(stage) ((struct light_stage_data *)(stage->privatePtr)) -static void import_color_material( GLcontext *ctx, - struct gl_pipeline_stage *stage ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct gl_client_array *to = &LIGHT_STAGE_DATA(stage)->FloatColor; - struct gl_client_array *from = VB->ColorPtr[0]; - GLuint count = VB->Count; - - if (!to->Ptr) { - to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLfloat), 32 ); - to->Type = GL_FLOAT; - } - - /* No need to transform the same value 3000 times. - */ - if (!from->StrideB) { - to->StrideB = 0; - count = 1; - } - else - to->StrideB = 4 * sizeof(GLfloat); - - _math_trans_4f( (GLfloat (*)[4]) to->Ptr, - from->Ptr, - from->StrideB, - from->Type, - from->Size, - 0, - count); - - VB->ColorPtr[0] = to; -} - /* Tables for all the shading functions. */ @@ -112,28 +78,12 @@ static light_func _tnl_light_ci_tab[MAX_LIGHT_FUNC]; #define IDX (LIGHT_TWOSIDE) #include "t_vb_lighttmp.h" -#define TAG(x) x##_fl -#define IDX (LIGHT_FLAGS) -#include "t_vb_lighttmp.h" - -#define TAG(x) x##_tw_fl -#define IDX (LIGHT_FLAGS|LIGHT_TWOSIDE) -#include "t_vb_lighttmp.h" - #define TAG(x) x##_cm -#define IDX (LIGHT_COLORMATERIAL) +#define IDX (LIGHT_MATERIAL) #include "t_vb_lighttmp.h" #define TAG(x) x##_tw_cm -#define IDX (LIGHT_TWOSIDE|LIGHT_COLORMATERIAL) -#include "t_vb_lighttmp.h" - -#define TAG(x) x##_fl_cm -#define IDX (LIGHT_FLAGS|LIGHT_COLORMATERIAL) -#include "t_vb_lighttmp.h" - -#define TAG(x) x##_tw_fl_cm -#define IDX (LIGHT_FLAGS|LIGHT_TWOSIDE|LIGHT_COLORMATERIAL) +#define IDX (LIGHT_TWOSIDE|LIGHT_MATERIAL) #include "t_vb_lighttmp.h" @@ -144,12 +94,8 @@ static void init_lighting( void ) if (!done) { init_light_tab(); init_light_tab_tw(); - init_light_tab_fl(); - init_light_tab_tw_fl(); init_light_tab_cm(); init_light_tab_tw_cm(); - init_light_tab_fl_cm(); - init_light_tab_tw_fl_cm(); done = 1; } } @@ -163,30 +109,17 @@ static GLboolean run_lighting( GLcontext *ctx, struct gl_pipeline_stage *stage ) GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; GLuint ind; -/* _tnl_print_vert_flags( __FUNCTION__, stage->changed_inputs ); */ - /* Make sure we can talk about elements 0..2 in the vector we are * lighting. */ - if (stage->changed_inputs & (VERT_BIT_EYE|VERT_BIT_POS)) { - if (input->size <= 2) { - if (input->flags & VEC_NOT_WRITEABLE) { - ASSERT(VB->importable_data & VERT_BIT_POS); - - VB->import_data( ctx, VERT_BIT_POS, VEC_NOT_WRITEABLE ); - input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr; - - ASSERT((input->flags & VEC_NOT_WRITEABLE) == 0); - } - + if (input->size <= 2) { + if (stage->changed_inputs & (VERT_BIT_EYE|VERT_BIT_POS)) { + copy_data( input, stage->pos_tmp ); _mesa_vector4f_clean_elem(input, VB->Count, 2); } - } - if (VB->Flag) - ind = LIGHT_FLAGS; - else - ind = 0; + input = stage->postmp; + } /* The individual functions know about replaying side-effects * vs. full re-execution. diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index aac8890180..34d9047be4 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_lighttmp.h,v 1.25 2002/02/13 00:53:20 keithw Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.25.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -30,46 +30,15 @@ */ -#if (IDX & LIGHT_FLAGS) -# define VSTRIDE (4 * sizeof(GLfloat)) -# define NSTRIDE nstride /*(3 * sizeof(GLfloat))*/ -# define CHECK_MATERIAL(x) (flags[x] & VERT_BIT_MATERIAL) -# define CHECK_END_VB(x) (flags[x] & VERT_BIT_END_VB) -# if (IDX & LIGHT_COLORMATERIAL) -# define CMSTRIDE STRIDE_F(CMcolor, CMstride) -# define CHECK_COLOR_MATERIAL(x) (flags[x] & VERT_BIT_COLOR0) -# define CHECK_VALIDATE(x) (flags[x] & (VERT_BIT_COLOR0|VERT_BIT_MATERIAL)) -# define DO_ANOTHER_NORMAL(x) \ - ((flags[x] & (VERT_BIT_COLOR0|VERT_BIT_NORMAL|VERT_BIT_END_VB|VERT_BIT_MATERIAL)) == VERT_BIT_NORMAL) -# define REUSE_LIGHT_RESULTS(x) \ - ((flags[x] & (VERT_BIT_COLOR0|VERT_BIT_NORMAL|VERT_BIT_END_VB|VERT_BIT_MATERIAL)) == 0) -# else -# define CMSTRIDE (void)0 -# define CHECK_COLOR_MATERIAL(x) 0 -# define CHECK_VALIDATE(x) (flags[x] & (VERT_BIT_MATERIAL)) -# define DO_ANOTHER_NORMAL(x) \ - ((flags[x] & (VERT_BIT_NORMAL|VERT_BIT_END_VB|VERT_BIT_MATERIAL)) == VERT_BIT_NORMAL) -# define REUSE_LIGHT_RESULTS(x) \ - ((flags[x] & (VERT_BIT_NORMAL|VERT_BIT_END_VB|VERT_BIT_MATERIAL)) == 0) -# endif -#else # define VSTRIDE vstride # define NSTRIDE nstride -# define CHECK_MATERIAL(x) 0 /* no materials on array paths */ # define CHECK_END_VB(XX) (XX >= nr) -# if (IDX & LIGHT_COLORMATERIAL) -# define CMSTRIDE STRIDE_F(CMcolor, CMstride) -# define CHECK_COLOR_MATERIAL(x) (x < nr) /* always have colormaterial */ -# define CHECK_VALIDATE(x) (x < nr) +# if (IDX & LIGHT_MATERIAL) # define DO_ANOTHER_NORMAL(x) 0 /* always stop to recalc colormat */ # else -# define CMSTRIDE (void)0 -# define CHECK_COLOR_MATERIAL(x) 0 /* no colormaterial */ -# define CHECK_VALIDATE(x) (0) # define DO_ANOTHER_NORMAL(XX) (XX < nr) /* keep going to end of vb */ # endif # define REUSE_LIGHT_RESULTS(x) 0 /* always have a new normal */ -#endif @@ -96,28 +65,21 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); GLfloat (*base)[3] = ctx->Light._BaseColor; - GLchan sumA[2]; + GLfloat sumA[2]; GLuint j; const GLuint vstride = input->stride; const GLfloat *vertex = (GLfloat *)input->data; - const GLuint nstride = VB->NormalPtr->stride; - const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - - GLfloat *CMcolor; - GLuint CMstride; + const GLuint nstride = VB->AttrPtr[VERT_ATTRIB_NORMAL]->stride; + const GLfloat *normal = (GLfloat *)VB->AttrPtr[VERT_ATTRIB_NORMAL]->data; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr; - GLchan (*Fspec)[4] = (GLchan (*)[4]) store->LitSecondary[0].Ptr; - GLchan (*Bspec)[4] = (GLchan (*)[4]) store->LitSecondary[1].Ptr; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; + GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].Ptr; + GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].Ptr; const GLuint nr = VB->Count; - const GLuint *flags = VB->Flag; - struct gl_material (*new_material)[2] = VB->Material; - const GLuint *new_material_mask = VB->MaterialMask; - (void) flags; (void) nstride; (void) vstride; @@ -125,23 +87,14 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, fprintf(stderr, "%s\n", __FUNCTION__ ); #endif - if (IDX & LIGHT_COLORMATERIAL) { - if (VB->ColorPtr[0]->Type != GL_FLOAT || - VB->ColorPtr[0]->Size != 4) - import_color_material( ctx, stage ); - - CMcolor = (GLfloat *) VB->ColorPtr[0]->Ptr; - CMstride = VB->ColorPtr[0]->StrideB; - } - - VB->ColorPtr[0] = &store->LitColor[0]; - VB->SecondaryColorPtr[0] = &store->LitSecondary[0]; - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + VB->AttrPtr[VERT_ATTRIB_COLOR0] = &store->LitColor[0]; + VB->AttrPtr[VERT_ATTRIB_COLOR1] = &store->LitSecondary[0]; + sumA[0] = ctx->Light.Material[0].Diffuse[3]; if (IDX & LIGHT_TWOSIDE) { - VB->ColorPtr[1] = &store->LitColor[1]; - VB->SecondaryColorPtr[1] = &store->LitSecondary[1]; - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + VB->AttrPtr[VERT_ATTRIB_BACK_COLOR0] = &store->LitColor[1]; + VB->AttrPtr[VERT_ATTRIB_BACK_COLOR1] = &store->LitSecondary[1]; + sumA[1] = ctx->Light.Material[1].Diffuse[3]; } /* Side-effects done, can we finish now? @@ -151,22 +104,16 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, for ( j=0 ; j<nr ; - j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal,NSTRIDE),CMSTRIDE) + j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal,NSTRIDE)) { GLfloat sum[2][3], spec[2][3]; struct gl_light *light; - if ( CHECK_COLOR_MATERIAL(j) ) - _mesa_update_color_material( ctx, CMcolor ); - - if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); - - if ( CHECK_VALIDATE(j) ) { - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); + if ( IDX & LIGHT_MATERIAL ) { + update_material( ctx, VB, j ); + sumA[0] = ctx->Light.Material[0].Diffuse[3]; if (IDX & LIGHT_TWOSIDE) - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); + sumA[1] = ctx->Light.Material[1].Diffuse[3]; } COPY_3V(sum[0], base[0]); @@ -289,13 +236,13 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, } } /*loop over lights*/ - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fcolor[j], sum[0] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( Fspec[j], spec[0] ); + COPY_3V( Fcolor[j], sum[0] ); + COPY_3V( Fspec[j], spec[0] ); Fcolor[j][3] = sumA[0]; if (IDX & LIGHT_TWOSIDE) { - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bcolor[j], sum[1] ); - UNCLAMPED_FLOAT_TO_RGB_CHAN( Bspec[j], spec[1] ); + COPY_3V( Bcolor[j], sum[1] ); + COPY_3V( Bspec[j], spec[1] ); Bcolor[j][3] = sumA[1]; } } @@ -311,50 +258,34 @@ static void TAG(light_rgba)( GLcontext *ctx, GLuint j; GLfloat (*base)[3] = ctx->Light._BaseColor; - GLchan sumA[2]; + GLfloat sumA[2]; const GLuint vstride = input->stride; const GLfloat *vertex = (GLfloat *) input->data; - const GLuint nstride = VB->NormalPtr->stride; - const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - - GLfloat *CMcolor; - GLuint CMstride; + const GLuint nstride = VB->AttrPtr[VERT_ATTRIB_NORMAL]->stride; + const GLfloat *normal = (GLfloat *)VB->AttrPtr[VERT_ATTRIB_NORMAL]->data; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr; - GLchan (*color[2])[4]; - const GLuint *flags = VB->Flag; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; + GLfloat (*color[2])[4]; - struct gl_material (*new_material)[2] = VB->Material; - const GLuint *new_material_mask = VB->MaterialMask; const GLuint nr = VB->Count; #ifdef TRACE fprintf(stderr, "%s\n", __FUNCTION__ ); #endif - (void) flags; (void) nstride; (void) vstride; color[0] = Fcolor; color[1] = Bcolor; - if (IDX & LIGHT_COLORMATERIAL) { - if (VB->ColorPtr[0]->Type != GL_FLOAT || - VB->ColorPtr[0]->Size != 4) - import_color_material( ctx, stage ); - - CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; - CMstride = VB->ColorPtr[0]->StrideB; - } - - VB->ColorPtr[0] = &store->LitColor[0]; + VB->AttrPtr[VERT_ATTRIB_COLOR0] = &store->LitColor[0]; UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); if (IDX & LIGHT_TWOSIDE) { - VB->ColorPtr[1] = &store->LitColor[1]; + VB->AttrPtr[VERT_ATTRIB_BACK_COLOR0] = &store->LitColor[1]; UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); } @@ -363,23 +294,13 @@ static void TAG(light_rgba)( GLcontext *ctx, for ( j=0 ; j<nr ; - j++,STRIDE_F(vertex,VSTRIDE), STRIDE_F(normal,NSTRIDE),CMSTRIDE) + j++,STRIDE_F(vertex,VSTRIDE), STRIDE_F(normal,NSTRIDE)) { GLfloat sum[2][3]; struct gl_light *light; - if ( CHECK_COLOR_MATERIAL(j) ) - _mesa_update_color_material( ctx, CMcolor ); - - if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); - - if ( CHECK_VALIDATE(j) ) { - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); - if (IDX & LIGHT_TWOSIDE) - UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); - } + if ( IDX & LIGHT_MATERIAL ) + update_material( ctx, VB, j ); COPY_3V(sum[0], base[0]); @@ -526,18 +447,13 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - const GLuint nstride = VB->NormalPtr->stride; - const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLfloat *CMcolor; - GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr; + const GLuint nstride = VB->AttrPtr[VERT_ATTRIB_NORMAL]->stride; + const GLfloat *normal = (GLfloat *)VB->AttrPtr[VERT_ATTRIB_NORMAL]->data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; const struct gl_light *light = ctx->Light.EnabledList.next; - const GLuint *flags = VB->Flag; - GLchan basechan[2][4]; + GLfloat basechan[2][4]; GLuint j = 0; - struct gl_material (*new_material)[2] = VB->Material; - const GLuint *new_material_mask = VB->MaterialMask; GLfloat base[2][3]; const GLuint nr = VB->Count; @@ -546,38 +462,20 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, #endif (void) input; /* doesn't refer to Eye or Obj */ - (void) flags; (void) nr; (void) nstride; - if (IDX & LIGHT_COLORMATERIAL) { - if (VB->ColorPtr[0]->Type != GL_FLOAT || - VB->ColorPtr[0]->Size != 4) - import_color_material( ctx, stage ); - - CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; - CMstride = VB->ColorPtr[0]->StrideB; - } - - VB->ColorPtr[0] = &store->LitColor[0]; + VB->AttrPtr[VERT_ATTRIB_COLOR0] = &store->LitColor[0]; if (IDX & LIGHT_TWOSIDE) - VB->ColorPtr[1] = &store->LitColor[1]; + VB->AttrPtr[VERT_ATTRIB_BACK_COLOR0] = &store->LitColor[1]; if (stage->changed_inputs == 0) return; do { - if ( CHECK_COLOR_MATERIAL(j) ) { - _mesa_update_color_material( ctx, CMcolor ); - } - - if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); - - if ( CHECK_VALIDATE(j) ) - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); - + if ( IDX & LIGHT_MATERIAL ) + update_material( ctx, VB, j ); /* No attenuation, so incoporate _MatAmbient into base color. */ @@ -631,12 +529,11 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, } j++; - CMSTRIDE; STRIDE_F(normal, NSTRIDE); } while (DO_ANOTHER_NORMAL(j)); - for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal,NSTRIDE)) + for ( ; REUSE_LIGHT_RESULTS(j) ; j++, STRIDE_F(normal,NSTRIDE)) { COPY_CHAN4(Fcolor[j], Fcolor[j-1]); if (IDX & LIGHT_TWOSIDE) @@ -655,17 +552,12 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, GLvector4f *input ) { struct light_stage_data *store = LIGHT_STAGE_DATA(stage); - GLchan sumA[2]; - const GLuint nstride = VB->NormalPtr->stride; - const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLfloat *CMcolor; - GLuint CMstride; - GLchan (*Fcolor)[4] = (GLchan (*)[4]) store->LitColor[0].Ptr; - GLchan (*Bcolor)[4] = (GLchan (*)[4]) store->LitColor[1].Ptr; - const GLuint *flags = VB->Flag; + GLfloat sumA[2]; + const GLuint nstride = VB->AttrPtr[VERT_ATTRIB_NORMAL]->stride; + const GLfloat *normal = (GLfloat *)VB->AttrPtr[VERT_ATTRIB_NORMAL]->data; + GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].Ptr; + GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].Ptr; GLuint j = 0; - struct gl_material (*new_material)[2] = VB->Material; - GLuint *new_material_mask = VB->MaterialMask; const GLuint nr = VB->Count; const struct gl_light *light; @@ -673,7 +565,6 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, fprintf(stderr, "%s\n", __FUNCTION__ ); #endif - (void) flags; (void) input; (void) nr; (void) nstride; @@ -681,18 +572,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); UNCLAMPED_FLOAT_TO_CHAN(sumA[1], ctx->Light.Material[1].Diffuse[3]); - if (IDX & LIGHT_COLORMATERIAL) { - if (VB->ColorPtr[0]->Type != GL_FLOAT || - VB->ColorPtr[0]->Size != 4) - import_color_material( ctx, stage ); - - CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; - CMstride = VB->ColorPtr[0]->StrideB; - } - - VB->ColorPtr[0] = &store->LitColor[0]; + VB->AttrPtr[VERT_ATTRIB_COLOR0] = &store->LitColor[0]; if (IDX & LIGHT_TWOSIDE) - VB->ColorPtr[1] = &store->LitColor[1]; + VB->AttrPtr[VERT_ATTRIB_BACK_COLOR0] = &store->LitColor[1]; if (stage->changed_inputs == 0) return; @@ -701,14 +583,9 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, do { GLfloat sum[2][3]; - if ( CHECK_COLOR_MATERIAL(j) ) - _mesa_update_color_material( ctx, CMcolor ); + if ( IDX & LIGHT_MATERIAL ) { + update_material( ctx, VB, j ); - if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); - - if ( CHECK_VALIDATE(j) ) { - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); UNCLAMPED_FLOAT_TO_CHAN(sumA[0], ctx->Light.Material[0].Diffuse[3]); if (IDX & LIGHT_TWOSIDE) UNCLAMPED_FLOAT_TO_CHAN(sumA[1], @@ -760,14 +637,13 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, } j++; - CMSTRIDE; STRIDE_F(normal, NSTRIDE); } while (DO_ANOTHER_NORMAL(j)); /* Reuse the shading results while there is no change to * normal or material values. */ - for ( ; REUSE_LIGHT_RESULTS(j) ; j++, CMSTRIDE, STRIDE_F(normal, NSTRIDE)) + for ( ; REUSE_LIGHT_RESULTS(j) ; j++, STRIDE_F(normal, NSTRIDE)) { COPY_CHAN4(Fcolor[j], Fcolor[j-1]); if (IDX & LIGHT_TWOSIDE) @@ -799,61 +675,40 @@ static void TAG(light_ci)( GLcontext *ctx, GLuint j; const GLuint vstride = input->stride; const GLfloat *vertex = (GLfloat *) input->data; - const GLuint nstride = VB->NormalPtr->stride; - const GLfloat *normal = (GLfloat *)VB->NormalPtr->data; - GLfloat *CMcolor; - GLuint CMstride; - const GLuint *flags = VB->Flag; + const GLuint nstride = VB->AttrPtr[VERT_ATTRIB_NORMAL]->stride; + const GLfloat *normal = (GLfloat *)VB->AttrPtr[VERT_ATTRIB_NORMAL]->data; GLuint *indexResult[2]; - struct gl_material (*new_material)[2] = VB->Material; - GLuint *new_material_mask = VB->MaterialMask; const GLuint nr = VB->Count; #ifdef TRACE fprintf(stderr, "%s\n", __FUNCTION__ ); #endif - (void) flags; (void) nstride; (void) vstride; - VB->IndexPtr[0] = &store->LitIndex[0]; + VB->AttrPtr[VERT_ATTRIB_INDEX] = &store->LitIndex[0]; if (IDX & LIGHT_TWOSIDE) - VB->IndexPtr[1] = &store->LitIndex[1]; + VB->AttrPtr[VERT_ATTRIB_BACK_INDEX] = &store->LitIndex[1]; if (stage->changed_inputs == 0) return; - indexResult[0] = VB->IndexPtr[0]->data; + indexResult[0] = VB->AttrPtr[VERT_ATTRIB_INDEX]->data; if (IDX & LIGHT_TWOSIDE) - indexResult[1] = VB->IndexPtr[1]->data; - - if (IDX & LIGHT_COLORMATERIAL) { - if (VB->ColorPtr[0]->Type != GL_FLOAT || - VB->ColorPtr[0]->Size != 4) - import_color_material( ctx, stage ); - - CMcolor = (GLfloat *)VB->ColorPtr[0]->Ptr; - CMstride = VB->ColorPtr[0]->StrideB; - } + indexResult[1] = VB->AttrPtr[VERT_ATTRIB_BACK_INDEX]->data; /* loop over vertices */ for ( j=0 ; j<nr ; - j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal, NSTRIDE), CMSTRIDE) + j++,STRIDE_F(vertex,VSTRIDE),STRIDE_F(normal, NSTRIDE)) { GLfloat diffuse[2], specular[2]; GLuint side = 0; struct gl_light *light; - if ( CHECK_COLOR_MATERIAL(j) ) - _mesa_update_color_material( ctx, CMcolor ); - - if ( CHECK_MATERIAL(j) ) - _mesa_update_material( ctx, new_material[j], new_material_mask[j] ); - - if ( CHECK_VALIDATE(j) ) - TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx ); + if ( IDX & LIGHT_MATERIAL ) + update_material( ctx, VB, j ); diffuse[0] = specular[0] = 0.0F; @@ -994,10 +849,7 @@ static void TAG(init_light_tab)( void ) #undef NR_SIDES #undef NSTRIDE #undef VSTRIDE -#undef CHECK_MATERIAL #undef CHECK_END_VB #undef DO_ANOTHER_NORMAL #undef REUSE_LIGHT_RESULTS -#undef CMSTRIDE -#undef CHECK_COLOR_MATERIAL #undef CHECK_VALIDATE diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index ac09792138..57a947d83b 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_normals.c,v 1.15 2002/08/08 16:54:43 brianp Exp $ */ +/* $Id: t_vb_normals.c,v 1.15.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -73,12 +73,12 @@ static GLboolean run_normal_stage( GLcontext *ctx, store->NormalTransform( ctx->ModelviewMatrixStack.Top, ctx->_ModelViewInvScale, - VB->NormalPtr, /* input normals */ + VB->AttrPtr[VERT_ATTRIB_NORMAL], /* input */ lengths, &store->normal ); /* resulting normals */ } - VB->NormalPtr = &store->normal; + VB->AttrPtr[VERT_ATTRIB_NORMAL] = &store->normal; VB->NormalLengthPtr = 0; /* no longer valid */ return GL_TRUE; } diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 0416766478..24a24e4816 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_program.c,v 1.14 2002/08/08 16:55:56 brianp Exp $ */ +/* $Id: t_vb_program.c,v 1.14.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -245,14 +245,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) VB->ClipPtr = &store->attribs[VERT_RESULT_HPOS]; VB->ClipPtr->size = 4; VB->ClipPtr->count = VB->Count; - VB->ColorPtr[0] = &store->color0[0]; - VB->ColorPtr[1] = &store->color0[1]; - VB->SecondaryColorPtr[0] = &store->color1[0]; - VB->SecondaryColorPtr[1] = &store->color1[1]; - VB->FogCoordPtr = &store->attribs[VERT_RESULT_FOGC]; VB->PointSizePtr = &store->attribs[VERT_RESULT_PSIZ]; - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - VB->TexCoordPtr[i] = &store->attribs[VERT_RESULT_TEX0 + i]; /* Cliptest and perspective divide. Clip functions must clear * the clipmask. @@ -289,11 +282,6 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) VB->ClipOrMask = store->ormask; VB->ClipMask = store->clipmask; - /* XXXX what's this? - if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_BIT_POS)) - VB->importable_data |= VERT_BIT_CLIP; - */ - return GL_TRUE; } diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c index 687f286f98..7a06719007 100644 --- a/src/mesa/tnl/t_vb_render.c +++ b/src/mesa/tnl/t_vb_render.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_render.c,v 1.31 2002/06/29 19:48:17 brianp Exp $ */ +/* $Id: t_vb_render.c,v 1.31.2.1 2002/10/15 16:56:52 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -87,8 +87,8 @@ /**********************************************************************/ #define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED) -#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx] -#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val +#define EDGEFLAG_GET(idx) VEC_ELT( VB->AttrPtr[VERT_ATTRIB_EDGEFLAG], GLboolean, idx ) +#define EDGEFLAG_SET(idx, val) VEC_ELT( VB->AttrPtr[VERT_ATTRIB_EDGEFLAG], GLfloat, idx ) = (GLfloat)val /* Vertices, with the possibility of clipping. @@ -199,8 +199,8 @@ static void clip_elt_triangles( GLcontext *ctx, /**********************************************************************/ #define NEED_EDGEFLAG_SETUP (ctx->_TriangleCaps & DD_TRI_UNFILLED) -#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx] -#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val +#define EDGEFLAG_GET(idx) VEC_ELT( VB->AttrPtr[VERT_ATTRIB_EDGEFLAG], GLboolean, idx ) +#define EDGEFLAG_SET(idx, val) VEC_ELT( VB->AttrPtr[VERT_ATTRIB_EDGEFLAG], GLfloat, idx ) = (GLfloat)val /* Vertices, no clipping. @@ -318,21 +318,23 @@ static GLboolean run_render( GLcontext *ctx, do { - GLuint i, length, flags = 0; - for (i = VB->FirstPrimitive ; !(flags & PRIM_LAST) ; i += length) + GLuint i; + for (i = 0 ; i < VB->NrPrimitives ; i ++) { - flags = VB->Primitive[i]; - length= VB->PrimitiveLength[i]; - ASSERT(length || (flags & PRIM_LAST)); + GLuint flags = VB->Primitive[i].prim; + GLuint start = VB->Primitive[i].start; + GLuint finish = VB->Primitive[i].finish; + + ASSERT(start != finish || (flags & PRIM_LAST)); ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1); if (MESA_VERBOSE & VERBOSE_PRIMS) _mesa_debug(NULL, "MESA prim %s %d..%d\n", _mesa_lookup_enum_by_nr(flags & PRIM_MODE_MASK), - i, i+length); + start, finish); - if (length) - tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags ); + if (start != finish) + tab[flags & PRIM_MODE_MASK]( ctx, start, finish, flags ); } } while (tnl->Driver.Render.Multipass && tnl->Driver.Render.Multipass( ctx, ++pass )); diff --git a/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c index 81751508bf..a3c63e0e74 100644 --- a/src/mesa/tnl/t_vb_texgen.c +++ b/src/mesa/tnl/t_vb_texgen.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_texgen.c,v 1.13 2002/06/29 19:48:17 brianp Exp $ */ +/* $Id: t_vb_texgen.c,v 1.13.2.1 2002/10/15 16:56:53 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -249,12 +249,12 @@ static void texgen_reflection_map_nv( GLcontext *ctx, GLuint unit ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->TexCoordPtr[unit]; + GLvector4f *in = VB->AttrPtr[VERT_ATTRIB_TEX0 + unit]; GLvector4f *out = &store->texcoord[unit]; build_f_tab[VB->EyePtr->size]( out->start, out->stride, - VB->NormalPtr, + VB->AttrPtr[VERT_ATTRIB_NORMAL], VB->EyePtr ); if (in) { @@ -279,9 +279,9 @@ static void texgen_normal_map_nv( GLcontext *ctx, GLuint unit ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->TexCoordPtr[unit]; + GLvector4f *in = VB->AttrPtr[VERT_ATTRIB_TEX0+unit]; GLvector4f *out = &store->texcoord[unit]; - GLvector4f *normal = VB->NormalPtr; + GLvector4f *normal = VB->AttrPtr[VERT_ATTRIB_NORMAL]; GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start; GLuint count = VB->Count; GLuint i; @@ -314,7 +314,7 @@ static void texgen_sphere_map( GLcontext *ctx, GLuint unit ) { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLvector4f *in = VB->TexCoordPtr[unit]; + GLvector4f *in = VB->AttrPtr[VERT_ATTRIB_TEX0+unit]; GLvector4f *out = &store->texcoord[unit]; GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start; GLuint count = VB->Count; @@ -322,13 +322,9 @@ static void texgen_sphere_map( GLcontext *ctx, GLfloat (*f)[3] = store->tmp_f; GLfloat *m = store->tmp_m; -/* _mesa_debug(NULL, "%s normstride %d eyestride %d\n", */ -/* __FUNCTION__, VB->NormalPtr->stride, */ -/* VB->EyePtr->stride); */ - (build_m_tab[VB->EyePtr->size])( store->tmp_f, store->tmp_m, - VB->NormalPtr, + VB->AttrPtr[VERT_ATTRIB_NORMAL], VB->EyePtr ); for (i=0;i<count;i++) { @@ -357,12 +353,12 @@ static void texgen( GLcontext *ctx, { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - GLvector4f *in = VB->TexCoordPtr[unit]; + GLvector4f *in = VB->AttrPtr[VERT_ATTRIB_TEX0+unit]; GLvector4f *out = &store->texcoord[unit]; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; const GLvector4f *obj = VB->ObjPtr; const GLvector4f *eye = VB->EyePtr; - const GLvector4f *normal = VB->NormalPtr; + const GLvector4f *normal = VB->AttrPtr[VERT_ATTRIB_NORMAL]; GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data; GLfloat *indata; GLuint count = VB->Count; @@ -532,7 +528,7 @@ static GLboolean run_texgen_stage( GLcontext *ctx, if (stage->changed_inputs & (VERT_BIT_EYE | VERT_BIT_NORMAL | VERT_BIT_TEX(i))) store->TexgenFunc[i]( ctx, store, i ); - VB->TexCoordPtr[i] = &store->texcoord[i]; + VB->AttrPtr[VERT_ATTRIB_TEX0+i] = &store->texcoord[i]; } return GL_TRUE; diff --git a/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c index 135278d740..61214ffc30 100644 --- a/src/mesa/tnl/t_vb_texmat.c +++ b/src/mesa/tnl/t_vb_texmat.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_texmat.c,v 1.8 2002/01/22 14:35:17 brianp Exp $ */ +/* $Id: t_vb_texmat.c,v 1.8.2.1 2002/10/15 16:56:53 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -88,9 +88,9 @@ static GLboolean run_texmat_stage( GLcontext *ctx, if (stage->changed_inputs & VERT_BIT_TEX(i)) (void) TransformRaw( &store->texcoord[i], ctx->TextureMatrixStack[i].Top, - VB->TexCoordPtr[i]); + VB->AttrPtr[VERT_ATTRIB_TEX0+i]); - VB->TexCoordPtr[i] = &store->texcoord[i]; + VB->AttrPtr[VERT_ATTRIB_TEX0+i] = &store->texcoord[i]; } return GL_TRUE; } diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c index e13b8bc0a1..0d99b86d68 100644 --- a/src/mesa/tnl/t_vb_vertex.c +++ b/src/mesa/tnl/t_vb_vertex.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_vertex.c,v 1.14 2002/04/09 16:56:52 keithw Exp $ */ +/* $Id: t_vb_vertex.c,v 1.14.2.1 2002/10/15 16:56:53 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -144,42 +144,36 @@ static GLboolean run_vertex_stage( GLcontext *ctx, * Use combined ModelProject to avoid some depth artifacts */ if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY) - VB->EyePtr = VB->ObjPtr; + VB->EyePtr = VB->AttrPtr[VERT_ATTRIB_POS]; else VB->EyePtr = TransformRaw( &store->eye, ctx->ModelviewMatrixStack.Top, - VB->ObjPtr); + VB->AttrPtr[VERT_ATTRIB_POS]); - if (ctx->ProjectionMatrixStack.Top->type == MATRIX_IDENTITY) + /* Need to make sure ClipPtr is clean to element 4, hence the + * second & third conditions: + */ + if (ctx->ProjectionMatrixStack.Top->type == MATRIX_IDENTITY && + (ctx->ModelviewMatrixStack.Top->type != MATRIX_IDENTITY || + VB->EyePtr->Size == 4)) VB->ClipPtr = VB->EyePtr; else VB->ClipPtr = TransformRaw( &store->clip, &ctx->_ModelProjectMatrix, - VB->ObjPtr ); + VB->AttrPtr[VERT_ATTRIB_POS] ); } else { /* Combined modelviewproject transform: */ - if (ctx->_ModelProjectMatrix.type == MATRIX_IDENTITY) - VB->ClipPtr = VB->ObjPtr; + if (ctx->_ModelProjectMatrix.type == MATRIX_IDENTITY && + VB->AttrPtr[VERT_ATTRIB_POS]->Size == 4) + VB->ClipPtr = VB->AttrPtr[VERT_ATTRIB_POS]; else VB->ClipPtr = TransformRaw( &store->clip, &ctx->_ModelProjectMatrix, - VB->ObjPtr ); + VB->AttrPtr[VERT_ATTRIB_POS] ); } - /* Drivers expect this to be clean to element 4... - */ - if (VB->ClipPtr->size < 4) { - if (VB->ClipPtr->flags & VEC_NOT_WRITEABLE) { - ASSERT(VB->ClipPtr == VB->ObjPtr); - VB->import_data( ctx, VERT_BIT_POS, VEC_NOT_WRITEABLE ); - VB->ClipPtr = VB->ObjPtr; - } - if (VB->ClipPtr->size == 2) - _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 ); - _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 ); - } /* Cliptest and perspective divide. Clip functions must clear * the clipmask. @@ -226,9 +220,6 @@ static GLboolean run_vertex_stage( GLcontext *ctx, VB->ClipOrMask = store->ormask; VB->ClipMask = store->clipmask; - if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_BIT_POS)) - VB->importable_data |= VERT_BIT_CLIP; - store->save_eyeptr = VB->EyePtr; store->save_clipptr = VB->ClipPtr; store->save_ndcptr = VB->NdcPtr; @@ -241,8 +232,6 @@ static GLboolean run_vertex_stage( GLcontext *ctx, VB->NdcPtr = store->save_ndcptr; VB->ClipMask = store->clipmask; VB->ClipOrMask = store->ormask; - if (VB->ClipPtr == VB->ObjPtr && (VB->importable_data & VERT_BIT_POS)) - VB->importable_data |= VERT_BIT_CLIP; if (store->andmask) return GL_FALSE; } diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index 3299a0b782..c935248add 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -300,51 +300,51 @@ static void op_error( void ) * Assembly can optimize the generation of arrays by using &s instead * of building 'v'. */ -static void tnl_MultiTexCoord1fARB( GLenum target, GLfloat s ) +static void tnl_MultiTexCoord1f( GLenum target, GLfloat s ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR1FV( attr, &s ); } -static void tnl_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ) +static void tnl_MultiTexCoord1fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR1FV( attr, v ); } -static void tnl_MultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t ) +static void tnl_MultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR2F( attr, s, t ); } -static void tnl_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ) +static void tnl_MultiTexCoord2fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR2FV( attr, v ); } -static void tnl_MultiTexCoord3fARB( GLenum target, GLfloat s, GLfloat t, +static void tnl_MultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR3F( attr, s, t, r ); } -static void tnl_MultiTexCoord3fvARB( GLenum target, const GLfloat *v ) +static void tnl_MultiTexCoord3fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7); DISPATCH_ATTR3FV( attr, v ); } -static void tnl_MultiTexCoord4fARB( GLenum target, GLfloat s, GLfloat t, +static void tnl_MultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR4F( attr, s, t, r, q ); } -static void tnl_MultiTexCoord4fvARB( GLenum target, const GLfloat *v ) +static void tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR4FV( attr, v ); @@ -606,14 +606,14 @@ void _tnl_InitVtxfmtChoosers( GLvertexformat *vfmt ) vfmt->Color4fv = choose_Color4fv; vfmt->SecondaryColor3fEXT = choose_SecondaryColor3fEXT; vfmt->SecondaryColor3fvEXT = choose_SecondaryColor3fvEXT; - vfmt->MultiTexCoord1fARB = dd_MultiTexCoord1fARB; - vfmt->MultiTexCoord1fvARB = dd_MultiTexCoord1fvARB; - vfmt->MultiTexCoord2fARB = dd_MultiTexCoord2fARB; - vfmt->MultiTexCoord2fvARB = dd_MultiTexCoord2fvARB; - vfmt->MultiTexCoord3fARB = dd_MultiTexCoord3fARB; - vfmt->MultiTexCoord3fvARB = dd_MultiTexCoord3fvARB; - vfmt->MultiTexCoord4fARB = dd_MultiTexCoord4fARB; - vfmt->MultiTexCoord4fvARB = dd_MultiTexCoord4fvARB; + vfmt->MultiTexCoord1fARB = dd_MultiTexCoord1f; + vfmt->MultiTexCoord1fvARB = dd_MultiTexCoord1fv; + vfmt->MultiTexCoord2fARB = dd_MultiTexCoord2f; + vfmt->MultiTexCoord2fvARB = dd_MultiTexCoord2fv; + vfmt->MultiTexCoord3fARB = dd_MultiTexCoord3f; + vfmt->MultiTexCoord3fvARB = dd_MultiTexCoord3fv; + vfmt->MultiTexCoord4fARB = dd_MultiTexCoord4f; + vfmt->MultiTexCoord4fvARB = dd_MultiTexCoord4fv; vfmt->Normal3f = choose_Normal3f; vfmt->Normal3fv = choose_Normal3fv; vfmt->TexCoord1f = choose_TexCoord1f; |