aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa/src/mesa/tnl
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/extras/Mesa/src/mesa/tnl')
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c414
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c352
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_context.c294
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_context.h806
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c218
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h76
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c1724
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h58
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c342
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c215
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c1496
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h189
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c1222
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h270
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c97
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c266
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c362
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h824
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c189
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c111
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c281
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c352
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h440
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c611
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c130
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c264
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c509
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h169
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c1119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c670
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c1497
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h35
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c995
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h90
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c254
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c284
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c538
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c385
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S557
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/tnl.h89
42 files changed, 0 insertions, 18876 deletions
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c
deleted file mode 100644
index 1ad77c5a9..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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 t_array_api.c
- * \brief Vertex array API functions (glDrawArrays, etc)
- * \author Keith Whitwell
- */
-
-#include "glheader.h"
-#include "api_validate.h"
-#include "context.h"
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "state.h"
-
-#include "array_cache/acache.h"
-
-#include "t_array_api.h"
-#include "t_array_import.h"
-#include "t_save_api.h"
-#include "t_context.h"
-#include "t_pipeline.h"
-#include "dispatch.h"
-
-static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start,
- GLsizei count )
-{
- GLint i;
-
- assert(!ctx->CompileFlag);
- assert(ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1);
-
- CALL_Begin(GET_DISPATCH(), (mode));
- for (i = 0; i < count; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( start + i ));
- CALL_End(GET_DISPATCH(), ());
-}
-
-
-static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count,
- const GLuint *indices)
-{
- GLint i;
-
- assert(!ctx->CompileFlag);
- assert(ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1);
-
- /* Here, indices will already reflect the buffer object if active */
-
- CALL_Begin(GET_DISPATCH(), (mode));
- for (i = 0 ; i < count ; i++) {
- CALL_ArrayElement(GET_DISPATCH(), ( indices[i] ));
- }
- CALL_End(GET_DISPATCH(), ());
-}
-
-
-/* Note this function no longer takes a 'start' value, the range is
- * assumed to start at zero. The old trick of subtracting 'start'
- * from each index won't work if the indices are not in writeable
- * memory.
- */
-static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode,
- GLuint max_index,
- GLsizei index_count, GLuint *indices )
-
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_prim prim;
- FLUSH_CURRENT( ctx, 0 );
-
- _tnl_vb_bind_arrays( ctx, 0, max_index );
-
- tnl->vb.Primitive = &prim;
- tnl->vb.Primitive[0].mode = mode | PRIM_BEGIN | PRIM_END;
- tnl->vb.Primitive[0].start = 0;
- tnl->vb.Primitive[0].count = index_count;
- tnl->vb.PrimitiveCount = 1;
-
- tnl->vb.Elts = (GLuint *)indices;
-
- tnl->Driver.RunPipeline( ctx );
-}
-
-
-
-/**
- * Called via the GL API dispatcher.
- */
-void GLAPIENTRY
-_tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(NULL, "_tnl_DrawArrays %d %d\n", start, count);
-
- /* Check arguments, etc.
- */
- if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
- return;
-
- assert(!ctx->CompileFlag);
-
- if (!ctx->Array.LockCount && (GLuint) count < thresh) {
- /* Small primitives: attempt to share a vb (at the expense of
- * using the immediate interface).
- */
- fallback_drawarrays( ctx, mode, start, count );
- }
- else if (start >= (GLint) ctx->Array.LockFirst &&
- start + count <= (GLint)(ctx->Array.LockFirst + ctx->Array.LockCount)) {
-
- struct tnl_prim prim;
-
- /* Locked primitives which can fit in a single vertex buffer:
- */
- FLUSH_CURRENT( ctx, 0 );
-
- /* Locked drawarrays. Reuse any previously transformed data.
- */
- _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst,
- ctx->Array.LockFirst + ctx->Array.LockCount );
-
- tnl->vb.Primitive = &prim;
- tnl->vb.Primitive[0].mode = mode | PRIM_BEGIN | PRIM_END;
- tnl->vb.Primitive[0].start = start;
- tnl->vb.Primitive[0].count = count;
- tnl->vb.PrimitiveCount = 1;
-
- tnl->Driver.RunPipeline( ctx );
- }
- else {
- int bufsz = 256; /* Use a small buffer for cache goodness */
- int j, nr;
- int minimum, modulo, skip;
-
- /* Large primitives requiring decomposition to multiple vertex
- * buffers:
- */
- switch (mode) {
- case GL_POINTS:
- minimum = 0;
- modulo = 1;
- skip = 0;
- break;
- case GL_LINES:
- minimum = 1;
- modulo = 2;
- skip = 1;
- break;
- case GL_LINE_STRIP:
- minimum = 1;
- modulo = 1;
- skip = 0;
- break;
- case GL_TRIANGLES:
- minimum = 2;
- modulo = 3;
- skip = 2;
- break;
- case GL_TRIANGLE_STRIP:
- minimum = 2;
- modulo = 1;
- skip = 0;
- break;
- case GL_QUADS:
- minimum = 3;
- modulo = 4;
- skip = 3;
- break;
- case GL_QUAD_STRIP:
- minimum = 3;
- modulo = 2;
- skip = 0;
- break;
- case GL_LINE_LOOP:
- case GL_TRIANGLE_FAN:
- case GL_POLYGON:
- default:
- /* Primitives requiring a copied vertex (fan-like primitives)
- * must use the slow path if they cannot fit in a single
- * vertex buffer.
- */
- if (count <= (GLint) ctx->Const.MaxArrayLockSize) {
- bufsz = ctx->Const.MaxArrayLockSize;
- minimum = 0;
- modulo = 1;
- skip = 0;
- }
- else {
- fallback_drawarrays( ctx, mode, start, count );
- return;
- }
- }
-
- FLUSH_CURRENT( ctx, 0 );
-
- bufsz -= bufsz % modulo;
- bufsz -= minimum;
- count += start;
-
- for (j = start + minimum ; j < count ; j += nr + skip ) {
-
- struct tnl_prim prim;
-
- nr = MIN2( bufsz, count - j );
-
- /* XXX is the last parameter a count or index into the array??? */
- _tnl_vb_bind_arrays( ctx, j - minimum, j + nr );
-
- tnl->vb.Primitive = &prim;
- tnl->vb.Primitive[0].mode = mode;
-
- if (j == start + minimum)
- tnl->vb.Primitive[0].mode |= PRIM_BEGIN;
-
- if (j + nr + skip >= count)
- tnl->vb.Primitive[0].mode |= PRIM_END;
-
- tnl->vb.Primitive[0].start = 0;
- tnl->vb.Primitive[0].count = nr + minimum;
- tnl->vb.PrimitiveCount = 1;
-
- tnl->Driver.RunPipeline( ctx );
- }
- }
-}
-
-
-/**
- * Called via the GL API dispatcher.
- */
-void GLAPIENTRY
-_tnl_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type, const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLuint *ui_indices;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(NULL, "_tnl_DrawRangeElements %d %d %d\n", start, end, count);
-
- if (ctx->Array.ElementArrayBufferObj->Name) {
- /* use indices in the buffer object */
- if (!ctx->Array.ElementArrayBufferObj->Data) {
- _mesa_warning(ctx,
- "DrawRangeElements with empty vertex elements buffer!");
- return;
- }
- /* actual address is the sum of pointers */
- indices = (const GLvoid *)
- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
- (const GLubyte *) indices);
- }
-
- /* Check arguments, etc.
- */
- if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
- type, indices ))
- return;
-
- ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
- count, type, indices );
-
-
- assert(!ctx->CompileFlag);
-
- if (ctx->Array.LockCount) {
- /* Are the arrays already locked? If so we currently have to look
- * at the whole locked range.
- */
-
- if (start == 0 && ctx->Array.LockFirst == 0 &&
- end < (ctx->Array.LockFirst + ctx->Array.LockCount))
- _tnl_draw_range_elements( ctx, mode,
- ctx->Array.LockCount,
- count, ui_indices );
- else {
- fallback_drawelements( ctx, mode, count, ui_indices );
- }
- }
- else if (start == 0 && end < ctx->Const.MaxArrayLockSize) {
- /* The arrays aren't locked but we can still fit them inside a
- * single vertexbuffer.
- */
- _tnl_draw_range_elements( ctx, mode, end + 1, count, ui_indices );
- }
- else {
- /* Range is too big to optimize:
- */
- fallback_drawelements( ctx, mode, count, ui_indices );
- }
-}
-
-
-
-/**
- * Called via the GL API dispatcher.
- */
-void GLAPIENTRY
-_tnl_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLuint *ui_indices;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(NULL, "_tnl_DrawElements %d\n", count);
-
- /* Check arguments, etc. */
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
- return;
-
- if (ctx->Array.ElementArrayBufferObj->Name) {
- /* actual address is the sum of pointers */
- indices = (const GLvoid *)
- ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
- (const GLubyte *) indices);
- }
-
- ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
- count, type, indices );
-
- assert(!ctx->CompileFlag);
-
- if (ctx->Array.LockCount) {
- if (ctx->Array.LockFirst == 0)
- _tnl_draw_range_elements( ctx, mode,
- ctx->Array.LockCount,
- count, ui_indices );
- else
- fallback_drawelements( ctx, mode, count, ui_indices );
- }
- else {
- /* Scan the index list and see if we can use the locked path anyway.
- */
- GLuint max_elt = 0;
- GLint i;
-
- for (i = 0 ; i < count ; i++)
- if (ui_indices[i] > max_elt)
- max_elt = ui_indices[i];
-
- if (max_elt < ctx->Const.MaxArrayLockSize && /* can we use it? */
- max_elt < (GLuint) count) /* do we want to use it? */
- _tnl_draw_range_elements( ctx, mode, max_elt+1, count, ui_indices );
- else
- fallback_drawelements( ctx, mode, count, ui_indices );
- }
-}
-
-
-/**
- * Initialize context's vertex array fields. Called during T 'n L context
- * creation.
- */
-void _tnl_array_init( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_vertex_arrays *tmp = &tnl->array_inputs;
- GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
- GLuint i;
-
- vfmt->DrawArrays = _tnl_DrawArrays;
- vfmt->DrawElements = _tnl_DrawElements;
- vfmt->DrawRangeElements = _tnl_DrawRangeElements;
-
- /* Setup vector pointers that will be used to bind arrays to VB's.
- */
- _mesa_vector4f_init( &tmp->Obj, 0, NULL);
- _mesa_vector4f_init( &tmp->Normal, 0, NULL);
- _mesa_vector4f_init( &tmp->FogCoord, 0, NULL);
- _mesa_vector4f_init( &tmp->Index, 0, NULL);
-
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
- _mesa_vector4f_init( &tmp->TexCoord[i], 0, NULL);
-}
-
-
-/**
- * Destroy the context's vertex array stuff.
- * Called during T 'n L context destruction.
- */
-void _tnl_array_destroy( GLcontext *ctx )
-{
- (void) ctx;
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h
deleted file mode 100644
index 61d1f696b..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h
+++ /dev/null
@@ -1,46 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _T_VARRAY_H
-#define _T_VARRAY_H
-
-#include "mtypes.h"
-#include "t_context.h"
-
-
-extern void GLAPIENTRY _tnl_DrawArrays(GLenum mode, GLint first, GLsizei count);
-
-extern void GLAPIENTRY _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices);
-
-extern void GLAPIENTRY _tnl_DrawRangeElements(GLenum mode, GLuint start,
- GLuint end, GLsizei count, GLenum type,
- const GLvoid *indices);
-
-
-extern void _tnl_array_init( GLcontext *ctx );
-extern void _tnl_array_destroy( GLcontext *ctx );
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c
deleted file mode 100644
index 7cc834ffa..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "state.h"
-#include "mtypes.h"
-
-#include "array_cache/acache.h"
-#include "math/m_translate.h"
-
-#include "t_array_import.h"
-#include "t_context.h"
-
-
-static void _tnl_import_vertex( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- const GLubyte *data;
-
- tmp = _ac_import_vertex(ctx,
- GL_FLOAT,
- stride ? 4*sizeof(GLfloat) : 0,
- 0,
- writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->Obj.data = (GLfloat (*)[4]) data;
- inputs->Obj.start = (GLfloat *) data;
- inputs->Obj.stride = tmp->StrideB;
- inputs->Obj.size = tmp->Size;
-}
-
-static void _tnl_import_normal( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- const GLubyte *data;
-
- tmp = _ac_import_normal(ctx, GL_FLOAT,
- stride ? 3*sizeof(GLfloat) : 0, writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->Normal.data = (GLfloat (*)[4]) data;
- inputs->Normal.start = (GLfloat *) data;
- inputs->Normal.stride = tmp->StrideB;
- inputs->Normal.size = 3;
-}
-
-
-static void _tnl_import_color( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- const GLubyte *data;
-
- tmp = _ac_import_color(ctx,
- GL_FLOAT,
- stride ? 4*sizeof(GLfloat) : 0,
- 4,
- writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->Color.data = (GLfloat (*)[4]) data;
- inputs->Color.start = (GLfloat *) data;
- inputs->Color.stride = tmp->StrideB;
- inputs->Color.size = tmp->Size;
-}
-
-
-static void _tnl_import_secondarycolor( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- const GLubyte *data;
-
- tmp = _ac_import_secondarycolor(ctx,
- GL_FLOAT,
- stride ? 4*sizeof(GLfloat) : 0,
- 4,
- writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->SecondaryColor.data = (GLfloat (*)[4]) data;
- inputs->SecondaryColor.start = (GLfloat *) data;
- inputs->SecondaryColor.stride = tmp->StrideB;
- inputs->SecondaryColor.size = tmp->Size;
-}
-
-static void _tnl_import_fogcoord( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- const GLubyte *data;
-
- tmp = _ac_import_fogcoord(ctx, GL_FLOAT,
- stride ? sizeof(GLfloat) : 0, writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->FogCoord.data = (GLfloat (*)[4]) data;
- inputs->FogCoord.start = (GLfloat *) data;
- inputs->FogCoord.stride = tmp->StrideB;
-}
-
-static void _tnl_import_index( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- const GLubyte *data;
-
- tmp = _ac_import_index(ctx, GL_FLOAT,
- stride ? sizeof(GLfloat) : 0, writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->Index.data = (GLfloat (*)[4]) data;
- inputs->Index.start = (GLfloat *) data;
- inputs->Index.stride = tmp->StrideB;
-}
-
-
-static void _tnl_import_texcoord( GLcontext *ctx,
- GLuint unit,
- GLboolean writeable,
- GLboolean stride )
-{
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- const GLubyte *data;
-
- tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT,
- stride ? 4 * sizeof(GLfloat) : 0,
- 0,
- writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->TexCoord[unit].data = (GLfloat (*)[4]) data;
- inputs->TexCoord[unit].start = (GLfloat *) data;
- inputs->TexCoord[unit].stride = tmp->StrideB;
- inputs->TexCoord[unit].size = tmp->Size;
-}
-
-
-static void _tnl_import_edgeflag( GLcontext *ctx,
- GLboolean writeable,
- GLboolean stride )
-{
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- const GLubyte *data;
- (void) writeable; (void) stride;
-
- tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE,
- sizeof(GLubyte),
- 0,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->EdgeFlag = (GLubyte *) data;
-}
-
-
-
-static void _tnl_import_attrib( GLcontext *ctx,
- GLuint index,
- GLboolean writeable,
- GLboolean stride )
-{
- struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
- struct gl_client_array *tmp;
- GLboolean is_writeable = 0;
- const GLubyte *data;
-
- tmp = _ac_import_attrib(ctx, index, GL_FLOAT,
- stride ? 4 * sizeof(GLfloat) : 0,
- 4, /* want GLfloat[4] */
- writeable,
- &is_writeable);
-
- data = tmp->Ptr;
- inputs->Attribs[index].data = (GLfloat (*)[4]) data;
- inputs->Attribs[index].start = (GLfloat *) data;
- inputs->Attribs[index].stride = tmp->StrideB;
- inputs->Attribs[index].size = tmp->Size;
-}
-
-
-static void _tnl_constant_attrib( TNLcontext *tnl,
- struct tnl_vertex_arrays *tmp,
- GLuint i )
-{
- tmp->Attribs[i].count = 1;
- tmp->Attribs[i].data = (GLfloat (*)[4]) tnl->vtx.current[i];
- tmp->Attribs[i].start = tnl->vtx.current[i];
- tmp->Attribs[i].size = 4;
- tmp->Attribs[i].stride = 0;
- tnl->vb.AttribPtr[i] = &tmp->Attribs[i];
-}
-
-
-
-void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLint end)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- struct tnl_vertex_arrays *tmp = &tnl->array_inputs;
- GLuint i, index;
-
- VB->Count = end - start;
- VB->Elts = NULL;
-
- _ac_import_range( ctx, start, end );
-
- /* When vertex program mode is enabled, the generic vertex program
- * attribute arrays have priority over the conventional attributes.
- * Try to use them now.
- */
- for (index = 0; index < VERT_ATTRIB_MAX; index++) {
- /* When vertex program mode is enabled, the generic vertex attribute
- * arrays have priority over the conventional vertex arrays.
- */
- if (ctx->VertexProgram._Enabled
- && ctx->Array.VertexAttrib[index].Enabled) {
- /* Use generic attribute array */
- _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE );
- VB->AttribPtr[index] = &tmp->Attribs[index];
- }
- /* use conventional arrays... */
- else if (index == VERT_ATTRIB_POS) {
- _tnl_import_vertex( ctx, 0, 0 );
- tmp->Obj.count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_POS] = &tmp->Obj;
- }
- else if (index == VERT_ATTRIB_NORMAL) {
- _tnl_import_normal( ctx, 0, 0 );
- tmp->Normal.count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &tmp->Normal;
- }
- else if (index == VERT_ATTRIB_COLOR0) {
- _tnl_import_color( ctx, 0, 0 );
- tmp->Color.count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &tmp->Color;
- }
- else if (index == VERT_ATTRIB_COLOR1) {
- _tnl_import_secondarycolor( ctx, 0, 0 );
- tmp->SecondaryColor.count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &tmp->SecondaryColor;
- }
- else if (index == VERT_ATTRIB_FOG) {
- _tnl_import_fogcoord( ctx, 0, 0 );
- tmp->FogCoord.count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_FOG] = &tmp->FogCoord;
- }
- else if (index >= VERT_ATTRIB_TEX0 && index <= VERT_ATTRIB_TEX7) {
- i = index - VERT_ATTRIB_TEX0;
- _tnl_import_texcoord( ctx, i, GL_FALSE, GL_FALSE );
- tmp->TexCoord[i].count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &tmp->TexCoord[i];
- }
- else {
- _tnl_constant_attrib(tnl, tmp, index);
- }
- }
-
- /* odd-ball vertex attributes */
- {
- _tnl_import_index( ctx, 0, 0 );
- tmp->Index.count = VB->Count;
- VB->AttribPtr[_TNL_ATTRIB_INDEX] = &tmp->Index;
- }
-
- {
- _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) );
- VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag;
- }
-
- /* These are constant & could be precalculated:
- */
- for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) {
- _tnl_constant_attrib(tnl, tmp, i);
- }
-
-
- /* Legacy pointers -- remove one day.
- */
- VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
- VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
- VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
- VB->ColorPtr[1] = NULL;
- VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX];
- VB->IndexPtr[1] = NULL;
- VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
- VB->SecondaryColorPtr[1] = NULL;
- VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
-
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
- }
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h
deleted file mode 100644
index 39b77641d..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _T_ARRAY_IMPORT_H
-#define _T_ARRAY_IMPORT_H
-
-#include "mtypes.h"
-#include "t_context.h"
-
-extern void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLint end );
-
-extern void _tnl_array_import_init( GLcontext *ctx );
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_context.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_context.c
deleted file mode 100644
index 3be8f8dd3..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_context.c
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "api_arrayelt.h"
-#include "glheader.h"
-#include "imports.h"
-#include "context.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "dlist.h"
-#include "light.h"
-#include "vtxfmt.h"
-#include "nvfragprog.h"
-
-#include "tnl.h"
-#include "t_array_api.h"
-#include "t_context.h"
-#include "t_pipeline.h"
-#include "t_save_api.h"
-#include "t_vp_build.h"
-#include "t_vtx_api.h"
-
-
-
-void
-_tnl_MakeCurrent( GLcontext *ctx,
- GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer )
-{
- (void) ctx; (void) drawBuffer; (void) readBuffer;
-}
-
-
-static void
-install_driver_callbacks( GLcontext *ctx )
-{
- ctx->Driver.NewList = _tnl_NewList;
- ctx->Driver.EndList = _tnl_EndList;
- ctx->Driver.FlushVertices = _tnl_FlushVertices;
- ctx->Driver.SaveFlushVertices = _tnl_SaveFlushVertices;
- ctx->Driver.MakeCurrent = _tnl_MakeCurrent;
- ctx->Driver.BeginCallList = _tnl_BeginCallList;
- ctx->Driver.EndCallList = _tnl_EndCallList;
-}
-
-
-
-GLboolean
-_tnl_CreateContext( GLcontext *ctx )
-{
- TNLcontext *tnl;
-
- /* Create the TNLcontext structure
- */
- ctx->swtnl_context = tnl = (TNLcontext *) CALLOC( sizeof(TNLcontext) );
-
- if (!tnl) {
- return GL_FALSE;
- }
-
- if (getenv("MESA_CODEGEN"))
- tnl->AllowCodegen = GL_TRUE;
-
- /* Initialize the VB.
- */
- tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
-
-
- /* Initialize tnl state and tnl->vtxfmt.
- */
- _tnl_save_init( ctx );
- _tnl_array_init( ctx );
- _tnl_vtx_init( ctx );
-
- if (ctx->_MaintainTnlProgram)
- _tnl_install_pipeline( ctx, _tnl_vp_pipeline );
- else
- _tnl_install_pipeline( ctx, _tnl_default_pipeline );
-
- /* Initialize the arrayelt helper
- */
- if (!_ae_create_context( ctx ))
- return GL_FALSE;
-
-
- tnl->NeedNdcCoords = GL_TRUE;
- tnl->LoopbackDListCassettes = GL_FALSE;
- tnl->CalcDListNormalLengths = GL_TRUE;
- tnl->AllowVertexFog = GL_TRUE;
- tnl->AllowPixelFog = GL_TRUE;
-
- /* Hook our functions into exec and compile dispatch tables.
- */
- _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
-
-
- /* Set a few default values in the driver struct.
- */
- install_driver_callbacks(ctx);
- ctx->Driver.NeedFlush = 0;
- ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
- ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
-
- tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
- tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
- tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables;
-
- return GL_TRUE;
-}
-
-
-void
-_tnl_DestroyContext( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- _tnl_array_destroy( ctx );
- _tnl_vtx_destroy( ctx );
- _tnl_save_destroy( ctx );
- _tnl_destroy_pipeline( ctx );
- _ae_destroy_context( ctx );
-
- _tnl_ProgramCacheDestroy( ctx );
-
- FREE(tnl);
- ctx->swtnl_context = NULL;
-}
-
-
-void
-_tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- if (new_state & (_NEW_HINT)) {
- ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog);
- tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
- || !tnl->AllowPixelFog;
- }
-
- _ae_invalidate_state(ctx, new_state);
-
- tnl->pipeline.new_state |= new_state;
- tnl->vtx.eval.new_state |= new_state;
-
- /* Calculate tnl->render_inputs:
- */
- if (ctx->Visual.rgbMode) {
- tnl->render_inputs = (_TNL_BIT_POS|
- _TNL_BIT_COLOR0|
- (ctx->Texture._EnabledCoordUnits << _TNL_ATTRIB_TEX0));
-
- if (NEED_SECONDARY_COLOR(ctx))
- tnl->render_inputs |= _TNL_BIT_COLOR1;
- }
- else {
- tnl->render_inputs |= (_TNL_BIT_POS|_TNL_BIT_INDEX);
- }
-
- if (ctx->Fog.Enabled ||
- (ctx->FragmentProgram._Active &&
- ctx->FragmentProgram._Current->FogOption != GL_NONE))
- tnl->render_inputs |= _TNL_BIT_FOG;
-
- if (ctx->Polygon.FrontMode != GL_FILL ||
- ctx->Polygon.BackMode != GL_FILL)
- tnl->render_inputs |= _TNL_BIT_EDGEFLAG;
-
- if (ctx->RenderMode == GL_FEEDBACK)
- tnl->render_inputs |= _TNL_BIT_TEX0;
-
- if (ctx->Point._Attenuated ||
- (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled))
- tnl->render_inputs |= _TNL_BIT_POINTSIZE;
-}
-
-
-void
-_tnl_wakeup_exec( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- install_driver_callbacks(ctx);
- ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
-
- /* Hook our functions into exec and compile dispatch tables.
- */
- _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
-
- /* Call all appropriate driver callbacks to revive state.
- */
- _tnl_MakeCurrent( ctx, ctx->DrawBuffer, ctx->ReadBuffer );
-
- /* Assume we haven't been getting state updates either:
- */
- _tnl_InvalidateState( ctx, ~0 );
-
- if (ctx->Light.ColorMaterialEnabled) {
- _mesa_update_color_material( ctx,
- ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
- }
-}
-
-
-void
-_tnl_wakeup_save_exec( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- _tnl_wakeup_exec( ctx );
- _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt );
-}
-
-
-/**
- * Drivers call this function to tell the TCL module whether or not
- * it wants Normalized Device Coords (NDC) computed. I.e. whether
- * we should "Divide-by-W". Software renders will want that.
- */
-void
-_tnl_need_projected_coords( GLcontext *ctx, GLboolean mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- if (tnl->NeedNdcCoords != mode) {
- tnl->NeedNdcCoords = mode;
- _tnl_InvalidateState( ctx, _NEW_PROJECTION );
- }
-}
-
-void
-_tnl_need_dlist_loopback( GLcontext *ctx, GLboolean mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->LoopbackDListCassettes = mode;
-}
-
-void
-_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->CalcDListNormalLengths = mode;
-}
-
-void
-_tnl_isolate_materials( GLcontext *ctx, GLboolean mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->IsolateMaterials = mode;
-}
-
-void
-_tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->AllowVertexFog = value;
- tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
- || !tnl->AllowPixelFog;
-
-}
-
-void
-_tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->AllowPixelFog = value;
- tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
- || !tnl->AllowPixelFog;
-}
-
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_context.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_context.h
deleted file mode 100644
index 9c8f2003b..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_context.h
+++ /dev/null
@@ -1,806 +0,0 @@
-/*
- * mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * 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 t_context.h
- * \brief TnL module datatypes and definitions.
- * \author Keith Whitwell
- */
-
-
-/**
- * \mainpage The TNL-module
- *
- * TNL stands for "transform and lighting", i.e. this module implements
- * a pipeline that receives as input a buffer of vertices and does all
- * necessary transformations (rotations, clipping, vertex shader etc.)
- * and passes then the output to the rasterizer.
- *
- * The tnl_pipeline contains the array of all stages, which should be
- * applied. Each stage is a black-box, which is described by an
- * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the
- * stages to the vertex_buffer TNLcontext::vb, where the vertex data
- * is stored. The last stage in the pipeline is the rasterizer.
- *
- * The initial vertex_buffer data may either come from an ::immediate
- * structure or client vertex_arrays or display lists:
- *
- *
- * - The ::immediate structure records all the GL commands issued between
- * glBegin and glEnd. \n
- * The structure accumulates data, until it is either full or it is
- * flushed (usually by a state change). Before starting then the pipeline,
- * the collected vertex data in ::immediate has to be pushed into
- * TNLcontext::vb.
- * This happens in ::_tnl_vb_bind_immediate. The pipeline is then run by
- * calling tnl_device_driver::RunPipeline = ::_tnl_run_pipeline, which
- * is stored in TNLcontext::Driver. \n
- * An ::immediate does (for performance reasons) usually not finish with a
- * glEnd, and hence it also does not need to start with a glBegin.
- * This means that the last vertices of one ::immediate may need to be
- * saved for the next one.
- *
- *
- * - NOT SURE ABOUT THIS: The vertex_arrays structure is used to handle
- * glDrawArrays etc. \n
- * Here, the data of the vertex_arrays is copied by ::_tnl_vb_bind_arrays
- * into TNLcontext::vb, so that the pipeline can be started.
- */
-
-
-#ifndef _T_CONTEXT_H
-#define _T_CONTEXT_H
-
-#include "glheader.h"
-#include "mtypes.h"
-
-#include "math/m_matrix.h"
-#include "math/m_vector.h"
-#include "math/m_xform.h"
-
-
-#define MAX_PIPELINE_STAGES 30
-
-/*
- * Note: The first attributes match the VERT_ATTRIB_* definitions
- * in mtypes.h. However, the tnl module has additional attributes
- * for materials, color indexes, edge flags, etc.
- */
-/* Although it's nice to use these as bit indexes in a DWORD flag, we
- * could manage without if necessary. Another limit currently is the
- * number of bits allocated for these numbers in places like vertex
- * program instruction formats and register layouts.
- */
-enum {
- _TNL_ATTRIB_POS = 0,
- _TNL_ATTRIB_WEIGHT = 1,
- _TNL_ATTRIB_NORMAL = 2,
- _TNL_ATTRIB_COLOR0 = 3,
- _TNL_ATTRIB_COLOR1 = 4,
- _TNL_ATTRIB_FOG = 5,
- _TNL_ATTRIB_SIX = 6,
- _TNL_ATTRIB_SEVEN = 7,
- _TNL_ATTRIB_TEX0 = 8,
- _TNL_ATTRIB_TEX1 = 9,
- _TNL_ATTRIB_TEX2 = 10,
- _TNL_ATTRIB_TEX3 = 11,
- _TNL_ATTRIB_TEX4 = 12,
- _TNL_ATTRIB_TEX5 = 13,
- _TNL_ATTRIB_TEX6 = 14,
- _TNL_ATTRIB_TEX7 = 15,
- _TNL_ATTRIB_MAT_FRONT_AMBIENT = 16,
- _TNL_ATTRIB_MAT_BACK_AMBIENT = 17,
- _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 18,
- _TNL_ATTRIB_MAT_BACK_DIFFUSE = 19,
- _TNL_ATTRIB_MAT_FRONT_SPECULAR = 20,
- _TNL_ATTRIB_MAT_BACK_SPECULAR = 21,
- _TNL_ATTRIB_MAT_FRONT_EMISSION = 22,
- _TNL_ATTRIB_MAT_BACK_EMISSION = 23,
- _TNL_ATTRIB_MAT_FRONT_SHININESS = 24,
- _TNL_ATTRIB_MAT_BACK_SHININESS = 25,
- _TNL_ATTRIB_MAT_FRONT_INDEXES = 26,
- _TNL_ATTRIB_MAT_BACK_INDEXES = 27,
- _TNL_ATTRIB_INDEX = 28,
- _TNL_ATTRIB_EDGEFLAG = 29,
- _TNL_ATTRIB_POINTSIZE = 30,
- _TNL_ATTRIB_MAX = 31
-} ;
-
-/* Will probably have to revise this scheme fairly shortly, eg. by
- * compacting all the MAT flags down to one bit, or by using two
- * dwords to store the flags.
- */
-#define _TNL_BIT_POS (1<<0)
-#define _TNL_BIT_WEIGHT (1<<1)
-#define _TNL_BIT_NORMAL (1<<2)
-#define _TNL_BIT_COLOR0 (1<<3)
-#define _TNL_BIT_COLOR1 (1<<4)
-#define _TNL_BIT_FOG (1<<5)
-#define _TNL_BIT_SIX (1<<6)
-#define _TNL_BIT_SEVEN (1<<7)
-#define _TNL_BIT_TEX0 (1<<8)
-#define _TNL_BIT_TEX1 (1<<9)
-#define _TNL_BIT_TEX2 (1<<10)
-#define _TNL_BIT_TEX3 (1<<11)
-#define _TNL_BIT_TEX4 (1<<12)
-#define _TNL_BIT_TEX5 (1<<13)
-#define _TNL_BIT_TEX6 (1<<14)
-#define _TNL_BIT_TEX7 (1<<15)
-#define _TNL_BIT_MAT_FRONT_AMBIENT (1<<16)
-#define _TNL_BIT_MAT_BACK_AMBIENT (1<<17)
-#define _TNL_BIT_MAT_FRONT_DIFFUSE (1<<18)
-#define _TNL_BIT_MAT_BACK_DIFFUSE (1<<19)
-#define _TNL_BIT_MAT_FRONT_SPECULAR (1<<20)
-#define _TNL_BIT_MAT_BACK_SPECULAR (1<<21)
-#define _TNL_BIT_MAT_FRONT_EMISSION (1<<22)
-#define _TNL_BIT_MAT_BACK_EMISSION (1<<23)
-#define _TNL_BIT_MAT_FRONT_SHININESS (1<<24)
-#define _TNL_BIT_MAT_BACK_SHININESS (1<<25)
-#define _TNL_BIT_MAT_FRONT_INDEXES (1<<26)
-#define _TNL_BIT_MAT_BACK_INDEXES (1<<27)
-#define _TNL_BIT_INDEX (1<<28)
-#define _TNL_BIT_EDGEFLAG (1<<29)
-#define _TNL_BIT_POINTSIZE (1<<30)
-
-#define _TNL_BIT_TEX(u) (1 << (_TNL_ATTRIB_TEX0 + (u)))
-
-
-
-#define _TNL_BITS_MAT_ANY (_TNL_BIT_MAT_FRONT_AMBIENT | \
- _TNL_BIT_MAT_BACK_AMBIENT | \
- _TNL_BIT_MAT_FRONT_DIFFUSE | \
- _TNL_BIT_MAT_BACK_DIFFUSE | \
- _TNL_BIT_MAT_FRONT_SPECULAR | \
- _TNL_BIT_MAT_BACK_SPECULAR | \
- _TNL_BIT_MAT_FRONT_EMISSION | \
- _TNL_BIT_MAT_BACK_EMISSION | \
- _TNL_BIT_MAT_FRONT_SHININESS | \
- _TNL_BIT_MAT_BACK_SHININESS | \
- _TNL_BIT_MAT_FRONT_INDEXES | \
- _TNL_BIT_MAT_BACK_INDEXES)
-
-
-#define _TNL_BITS_TEX_ANY (_TNL_BIT_TEX0 | \
- _TNL_BIT_TEX1 | \
- _TNL_BIT_TEX2 | \
- _TNL_BIT_TEX3 | \
- _TNL_BIT_TEX4 | \
- _TNL_BIT_TEX5 | \
- _TNL_BIT_TEX6 | \
- _TNL_BIT_TEX7)
-
-
-#define _TNL_BITS_PROG_ANY (_TNL_BIT_POS | \
- _TNL_BIT_WEIGHT | \
- _TNL_BIT_NORMAL | \
- _TNL_BIT_COLOR0 | \
- _TNL_BIT_COLOR1 | \
- _TNL_BIT_FOG | \
- _TNL_BIT_SIX | \
- _TNL_BIT_SEVEN | \
- _TNL_BITS_TEX_ANY)
-
-
-
-#define PRIM_BEGIN 0x10
-#define PRIM_END 0x20
-#define PRIM_WEAK 0x40
-#define PRIM_MODE_MASK 0x0f
-
-/*
- */
-struct tnl_prim {
- GLuint mode;
- GLuint start;
- GLuint count;
-};
-
-
-
-struct tnl_eval1_map {
- struct gl_1d_map *map;
- GLuint sz;
-};
-
-struct tnl_eval2_map {
- struct gl_2d_map *map;
- GLuint sz;
-};
-
-struct tnl_eval {
- GLuint new_state;
- struct tnl_eval1_map map1[_TNL_ATTRIB_INDEX + 1];
- struct tnl_eval2_map map2[_TNL_ATTRIB_INDEX + 1];
-};
-
-
-#define TNL_MAX_PRIM 16
-#define TNL_MAX_COPIED_VERTS 3
-
-struct tnl_copied_vtx {
- GLfloat buffer[_TNL_ATTRIB_MAX * 4 * TNL_MAX_COPIED_VERTS];
- GLuint nr;
-};
-
-#define VERT_BUFFER_SIZE 2048 /* 8kbytes */
-
-
-typedef void (*tnl_attrfv_func)( const GLfloat * );
-
-struct _tnl_dynfn {
- struct _tnl_dynfn *next, *prev;
- GLuint key;
- char *code;
-};
-
-struct _tnl_dynfn_lists {
- struct _tnl_dynfn Vertex[4];
- struct _tnl_dynfn Attribute[4];
-};
-
-struct _tnl_dynfn_generators {
- struct _tnl_dynfn *(*Vertex[4])( GLcontext *ctx, int key );
- struct _tnl_dynfn *(*Attribute[4])( GLcontext *ctx, int key );
-};
-
-#define _TNL_MAX_ATTR_CODEGEN 16
-
-
-/* The assembly of vertices in immediate mode is separated from
- * display list compilation. This allows a simpler immediate mode
- * treatment and a display list compiler better suited to
- * hardware-acceleration.
- */
-struct tnl_vtx {
- GLfloat buffer[VERT_BUFFER_SIZE];
- GLubyte attrsz[_TNL_ATTRIB_MAX];
- GLuint vertex_size;
- struct tnl_prim prim[TNL_MAX_PRIM];
- GLuint prim_count;
- GLfloat *vbptr; /* cursor, points into buffer */
- GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current vertex */
- GLfloat *attrptr[_TNL_ATTRIB_MAX]; /* points into vertex */
- GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->Current, etc */
- GLfloat CurrentFloatEdgeFlag;
- GLuint counter, initial_counter;
- struct tnl_copied_vtx copied;
-
- tnl_attrfv_func tabfv[_TNL_MAX_ATTR_CODEGEN+1][4]; /* plus 1 for ERROR_ATTRIB */
-
- struct _tnl_dynfn_lists cache;
- struct _tnl_dynfn_generators gen;
-
- struct tnl_eval eval;
- GLboolean *edgeflag_tmp;
- GLboolean have_materials;
-};
-
-
-
-
-/* For display lists, this structure holds a run of vertices of the
- * same format, and a strictly well-formed set of begin/end pairs,
- * starting on the first vertex and ending at the last. Vertex
- * copying on buffer breaks is precomputed according to these
- * primitives, though there are situations where the copying will need
- * correction at execute-time, perhaps by replaying the list as
- * immediate mode commands.
- *
- * On executing this list, the 'current' values may be updated with
- * the values of the final vertex, and often no fixup of the start of
- * the vertex list is required.
- *
- * Eval and other commands that don't fit into these vertex lists are
- * compiled using the fallback opcode mechanism provided by dlist.c.
- */
-struct tnl_vertex_list {
- GLubyte attrsz[_TNL_ATTRIB_MAX];
- GLuint vertex_size;
-
- GLfloat *buffer;
- GLuint count;
- GLuint wrap_count; /* number of copied vertices at start */
- GLboolean have_materials; /* bit of a hack - quick check for materials */
- GLboolean dangling_attr_ref; /* current attr implicitly referenced
- outside the list */
-
- GLfloat *normal_lengths;
- struct tnl_prim *prim;
- GLuint prim_count;
-
- struct tnl_vertex_store *vertex_store;
- struct tnl_primitive_store *prim_store;
-};
-
-/* These buffers should be a reasonable size to support upload to
- * hardware? Maybe drivers should stitch them back together, or
- * specify a desired size?
- */
-#define SAVE_BUFFER_SIZE (16*1024)
-#define SAVE_PRIM_SIZE 128
-
-/* Storage to be shared among several vertex_lists.
- */
-struct tnl_vertex_store {
- GLfloat buffer[SAVE_BUFFER_SIZE];
- GLuint used;
- GLuint refcount;
-};
-
-struct tnl_primitive_store {
- struct tnl_prim buffer[SAVE_PRIM_SIZE];
- GLuint used;
- GLuint refcount;
-};
-
-
-struct tnl_save {
- GLubyte attrsz[_TNL_ATTRIB_MAX];
- GLuint vertex_size;
-
- GLfloat *buffer;
- GLuint count;
- GLuint wrap_count;
- GLuint replay_flags;
-
- struct tnl_prim *prim;
- GLuint prim_count, prim_max;
-
- struct tnl_vertex_store *vertex_store;
- struct tnl_primitive_store *prim_store;
-
- GLfloat *vbptr; /* cursor, points into buffer */
- GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current values */
- GLfloat *attrptr[_TNL_ATTRIB_MAX];
- GLuint counter, initial_counter;
- GLboolean dangling_attr_ref;
- GLboolean have_materials;
-
- GLuint opcode_vertex_list;
-
- struct tnl_copied_vtx copied;
-
- GLfloat CurrentFloatEdgeFlag;
-
- GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->ListState */
- GLubyte *currentsz[_TNL_ATTRIB_MAX];
-
- void (*tabfv[_TNL_ATTRIB_MAX][4])( const GLfloat * );
-};
-
-
-struct tnl_vertex_arrays
-{
- /* Conventional vertex attribute arrays */
- GLvector4f Obj;
- GLvector4f Normal;
- GLvector4f Color;
- GLvector4f SecondaryColor;
- GLvector4f FogCoord;
- GLvector4f TexCoord[MAX_TEXTURE_COORD_UNITS];
- GLvector4f Index;
-
- GLubyte *EdgeFlag;
- GLuint *Elt;
-
- /* These attributes don't alias with the conventional attributes.
- * The GL_NV_vertex_program extension defines 16 extra sets of vertex
- * arrays which have precedent over the conventional arrays when enabled.
- */
- GLvector4f Attribs[_TNL_ATTRIB_MAX];
-};
-
-
-/**
- * Contains the current state of a running pipeline.
- */
-struct vertex_buffer
-{
- /* Constant over life of the vertex_buffer.
- */
- GLuint Size;
-
- /* Constant over the pipeline.
- */
- GLuint Count; /* for everything except Elts */
-
- /* Pointers to current data.
- */
- GLuint *Elts;
- GLvector4f *ObjPtr; /* _TNL_BIT_POS */
- GLvector4f *EyePtr; /* _TNL_BIT_POS */
- GLvector4f *ClipPtr; /* _TNL_BIT_POS */
- GLvector4f *NdcPtr; /* _TNL_BIT_POS */
- GLubyte ClipOrMask; /* _TNL_BIT_POS */
- GLubyte ClipAndMask; /* _TNL_BIT_POS */
- GLubyte *ClipMask; /* _TNL_BIT_POS */
- GLvector4f *NormalPtr; /* _TNL_BIT_NORMAL */
- GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */
- GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */
- GLvector4f *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
- GLvector4f *IndexPtr[2]; /* _TNL_BIT_INDEX */
- GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
- GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
- GLvector4f *PointSizePtr; /* _TNL_BIT_POS */
- GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
-
- struct tnl_prim *Primitive;
- GLuint PrimitiveCount;
-
- /* Inputs to the vertex program stage */
- GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */
-
- GLuint LastClipped;
- /* Private data from _tnl_render_stage that has no business being
- * in this struct.
- */
-};
-
-
-/** Describes an individual operation on the pipeline.
- */
-struct tnl_pipeline_stage
-{
- const char *name;
-
- /* Private data for the pipeline stage:
- */
- void *privatePtr;
-
- /* Allocate private data
- */
- GLboolean (*create)( GLcontext *ctx, struct tnl_pipeline_stage * );
-
- /* Free private data.
- */
- void (*destroy)( struct tnl_pipeline_stage * );
-
- /* Called on any statechange or input array size change or
- * input array change to/from zero stride.
- */
- void (*validate)( GLcontext *ctx, struct tnl_pipeline_stage * );
-
- /* Called from _tnl_run_pipeline(). The stage.changed_inputs value
- * encodes all inputs to thee struct which have changed. If
- * non-zero, recompute all affected outputs of the stage, otherwise
- * execute any 'sideeffects' of the stage.
- *
- * Return value: GL_TRUE - keep going
- * GL_FALSE - finished pipeline
- */
- GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * );
-};
-
-
-
-/** Contains the array of all pipeline stages.
- * The default values are defined at the end of t_pipeline.c
- */
-struct tnl_pipeline {
-
- GLuint last_attrib_stride[_TNL_ATTRIB_MAX];
- GLuint last_attrib_size[_TNL_ATTRIB_MAX];
- GLuint input_changes;
- GLuint new_state;
-
- struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
- GLuint nr_stages;
-};
-
-struct tnl_clipspace;
-struct tnl_clipspace_attr;
-
-typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a,
- GLfloat *out,
- const GLubyte *v );
-
-typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a,
- GLubyte *v,
- const GLfloat *in );
-
-typedef void (*tnl_emit_func)( GLcontext *ctx,
- GLuint count,
- GLubyte *dest );
-
-
-/**
- * Describes how to convert/move a vertex attribute from a vertex array
- * to a vertex structure.
- */
-struct tnl_clipspace_attr
-{
- GLuint attrib; /* which vertex attrib (0=position, etc) */
- GLuint format;
- GLuint vertoffset; /* position of the attrib in the vertex struct */
- GLuint vertattrsize; /* size of the attribute in bytes */
- GLubyte *inputptr;
- GLuint inputstride;
- GLuint inputsize;
- const tnl_insert_func *insert;
- tnl_insert_func emit;
- tnl_extract_func extract;
- const GLfloat *vp; /* NDC->Viewport mapping matrix */
-};
-
-
-
-
-typedef void (*tnl_points_func)( GLcontext *ctx, GLuint first, GLuint last );
-typedef void (*tnl_line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
-typedef void (*tnl_triangle_func)( GLcontext *ctx,
- GLuint v1, GLuint v2, GLuint v3 );
-typedef void (*tnl_quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
- GLuint v3, GLuint v4 );
-typedef void (*tnl_render_func)( GLcontext *ctx, GLuint start, GLuint count,
- GLuint flags );
-typedef void (*tnl_interp_func)( GLcontext *ctx,
- GLfloat t, GLuint dst, GLuint out, GLuint in,
- GLboolean force_boundary );
-typedef void (*tnl_copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
-typedef void (*tnl_setup_func)( GLcontext *ctx,
- GLuint start, GLuint end,
- GLuint new_inputs);
-
-
-struct tnl_clipspace_fastpath {
- GLuint vertex_size;
- GLuint attr_count;
- GLboolean match_strides;
-
- struct {
- GLuint format;
- GLuint size;
- GLuint stride;
- GLuint offset;
- } *attr;
-
- tnl_emit_func func;
- struct tnl_clipspace_fastpath *next;
-};
-
-/**
- * Used to describe conversion of vertex arrays to vertex structures.
- * I.e. Structure of arrays to arrays of structs.
- */
-struct tnl_clipspace
-{
- GLboolean need_extras;
-
- GLuint new_inputs;
-
- GLubyte *vertex_buf;
- GLuint vertex_size;
- GLuint max_vertex_size;
-
- struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX];
- GLuint attr_count;
-
- tnl_emit_func emit;
- tnl_interp_func interp;
- tnl_copy_pv_func copy_pv;
-
- /* Parameters and constants for codegen:
- */
- GLboolean need_viewport;
- GLfloat vp_scale[4];
- GLfloat vp_xlate[4];
- GLfloat chan_scale[4];
- GLfloat identity[4];
-
- struct tnl_clipspace_fastpath *fastpath;
-
- void (*codegen_emit)( GLcontext *ctx );
-};
-
-
-
-struct tnl_cache {
- GLuint hash;
- void *key;
- void *data;
- struct tnl_cache *next;
-};
-
-
-struct tnl_device_driver
-{
- /***
- *** TNL Pipeline
- ***/
-
- void (*RunPipeline)(GLcontext *ctx);
- /* Replaces PipelineStart/PipelineFinish -- intended to allow
- * drivers to wrap _tnl_run_pipeline() with code to validate state
- * and grab/release hardware locks.
- */
-
- void (*NotifyMaterialChange)(GLcontext *ctx);
- /* Alert tnl-aware drivers of changes to material.
- */
-
- GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
- /* Allow drivers to hook in optimized begin/end engines.
- * Return value: GL_TRUE - driver handled the begin
- * GL_FALSE - driver didn't handle the begin
- */
-
- /***
- *** Rendering -- These functions called only from t_vb_render.c
- ***/
- struct
- {
- void (*Start)(GLcontext *ctx);
- void (*Finish)(GLcontext *ctx);
- /* Called before and after all rendering operations, including DrawPixels,
- * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
- * These are a suitable place for grabbing/releasing hardware locks.
- */
-
- void (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
- /* Called between RenderStart() and RenderFinish() to indicate the
- * type of primitive we're about to draw. Mode will be one of the
- * modes accepted by glBegin().
- */
-
- tnl_interp_func Interp;
- /* The interp function is called by the clipping routines when we need
- * to generate an interpolated vertex. All pertinant vertex ancilliary
- * data should be computed by interpolating between the 'in' and 'out'
- * vertices.
- */
-
- tnl_copy_pv_func CopyPV;
- /* The copy function is used to make a copy of a vertex. All pertinant
- * vertex attributes should be copied.
- */
-
- void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
- /* Render a polygon with <n> vertices whose indexes are in the <elts>
- * array.
- */
-
- void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
- /* Render a line between the two vertices given by indexes v0 and v1. */
-
- tnl_points_func Points; /* must now respect vb->elts */
- tnl_line_func Line;
- tnl_triangle_func Triangle;
- tnl_quad_func Quad;
- /* These functions are called in order to render points, lines,
- * triangles and quads. These are only called via the T&L module.
- */
-
- tnl_render_func *PrimTabVerts;
- tnl_render_func *PrimTabElts;
- /* Render whole unclipped primitives (points, lines, linestrips,
- * lineloops, etc). The tables are indexed by the GL enum of the
- * primitive to be rendered. RenderTabVerts is used for non-indexed
- * arrays of vertices. RenderTabElts is used for indexed arrays of
- * vertices.
- */
-
- void (*ResetLineStipple)( GLcontext *ctx );
- /* Reset the hardware's line stipple counter.
- */
-
- tnl_setup_func BuildVertices;
- /* This function is called whenever new vertices are required for
- * rendering. The vertices in question are those n such that start
- * <= n < end. The new_inputs parameter indicates those fields of
- * the vertex which need to be updated, if only a partial repair of
- * the vertex is required.
- *
- * This function is called only from _tnl_render_stage in tnl/t_render.c.
- */
-
-
- GLboolean (*Multipass)( GLcontext *ctx, GLuint passno );
- /* Driver may request additional render passes by returning GL_TRUE
- * when this function is called. This function will be called
- * after the first pass, and passes will be made until the function
- * returns GL_FALSE. If no function is registered, only one pass
- * is made.
- *
- * This function will be first invoked with passno == 1.
- */
- } Render;
-};
-
-
-/**
- * Context state for T&L context.
- */
-typedef struct
-{
- /* Driver interface.
- */
- struct tnl_device_driver Driver;
-
- /* Execute:
- */
- struct tnl_vtx vtx;
-
- /* Compile:
- */
- struct tnl_save save;
-
- /* Pipeline
- */
- struct tnl_pipeline pipeline;
- struct vertex_buffer vb;
-
- /* GLvectors for binding to vb:
- */
- struct tnl_vertex_arrays vtx_inputs;
- struct tnl_vertex_arrays save_inputs;
- struct tnl_vertex_arrays current;
- struct tnl_vertex_arrays array_inputs;
-
- /* Clipspace/ndc/window vertex managment:
- */
- struct tnl_clipspace clipspace;
-
- /* Probably need a better configuration mechanism:
- */
- GLboolean NeedNdcCoords;
- GLboolean LoopbackDListCassettes;
- GLboolean CalcDListNormalLengths;
- GLboolean IsolateMaterials;
- GLboolean AllowVertexFog;
- GLboolean AllowPixelFog;
- GLboolean AllowCodegen;
-
- GLboolean _DoVertexFog; /* eval fog function at each vertex? */
-
- /* If True, it means we started a glBegin/End primtive with an invalid
- * vertex/fragment program or incomplete framebuffer. In that case,
- * discard any buffered vertex data.
- */
- GLboolean DiscardPrimitive;
-
- GLuint render_inputs;
-
- GLvertexformat exec_vtxfmt;
- GLvertexformat save_vtxfmt;
-
- struct tnl_cache *vp_cache;
-
-} TNLcontext;
-
-
-
-#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context))
-
-
-#define TYPE_IDX(t) ((t) & 0xf)
-#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
-
-extern void _tnl_MakeCurrent( GLcontext *ctx,
- GLframebuffer *drawBuffer,
- GLframebuffer *readBuffer );
-
-
-
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c
deleted file mode 100644
index 61bfed290..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c
+++ /dev/null
@@ -1,218 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "state.h"
-#include "mtypes.h"
-
-#include "math/m_translate.h"
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-#include "t_vp_build.h"
-#include "t_vertex.h"
-
-void _tnl_install_pipeline( GLcontext *ctx,
- const struct tnl_pipeline_stage **stages )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- tnl->pipeline.new_state = ~0;
-
- /* Create a writeable copy of each stage.
- */
- for (i = 0 ; i < MAX_PIPELINE_STAGES && stages[i] ; i++) {
- struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
- MEMCPY(s, stages[i], sizeof(*s));
- if (s->create)
- s->create(ctx, s);
- }
-
- tnl->pipeline.nr_stages = i;
-}
-
-void _tnl_destroy_pipeline( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- for (i = 0 ; i < tnl->pipeline.nr_stages ; i++) {
- struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
- if (s->destroy)
- s->destroy(s);
- }
-
- tnl->pipeline.nr_stages = 0;
-}
-
-
-
-static GLuint check_input_changes( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- for (i = 0; i < _TNL_ATTRIB_EDGEFLAG; i++) {
- if (tnl->vb.AttribPtr[i]->size != tnl->pipeline.last_attrib_size[i] ||
- tnl->vb.AttribPtr[i]->stride != tnl->pipeline.last_attrib_stride[i]) {
- tnl->pipeline.last_attrib_size[i] = tnl->vb.AttribPtr[i]->size;
- tnl->pipeline.last_attrib_stride[i] = tnl->vb.AttribPtr[i]->stride;
- tnl->pipeline.input_changes |= 1<<i;
- }
- }
-
- return tnl->pipeline.input_changes;
-}
-
-
-static GLuint check_output_changes( GLcontext *ctx )
-{
-#if 0
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- for (i = 0; i < VERT_RESULT_MAX; i++) {
- if (tnl->vb.ResultPtr[i]->size != tnl->last_result_size[i] ||
- tnl->vb.ResultPtr[i]->stride != tnl->last_result_stride[i]) {
- tnl->last_result_size[i] = tnl->vb.ResultPtr[i]->size;
- tnl->last_result_stride[i] = tnl->vb.ResultPtr[i]->stride;
- tnl->pipeline.output_changes |= 1<<i;
- }
- }
-
- if (tnl->pipeline.output_changes)
- tnl->Driver.NotifyOutputChanges( ctx, tnl->pipeline.output_changes );
-
- return tnl->pipeline.output_changes;
-#else
- return ~0;
-#endif
-}
-
-
-void _tnl_run_pipeline( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- unsigned short __tmp;
- GLuint i;
-
- if (!tnl->vb.Count)
- return;
-
- /* Check for changed input sizes or change in stride to/from zero
- * (ie const or non-const).
- */
- if (check_input_changes( ctx ) || tnl->pipeline.new_state) {
- if (ctx->_MaintainTnlProgram)
- _tnl_UpdateFixedFunctionProgram( ctx );
-
- for (i = 0; i < tnl->pipeline.nr_stages ; i++) {
- struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
- if (s->validate)
- s->validate( ctx, s );
- }
-
- tnl->pipeline.new_state = 0;
- tnl->pipeline.input_changes = 0;
-
- /* Pipeline can only change its output in response to either a
- * statechange or an input size/stride change. No other changes
- * are allowed.
- */
- if (check_output_changes( ctx ))
- _tnl_notify_pipeline_output_change( ctx );
- }
-
- START_FAST_MATH(__tmp);
-
- for (i = 0; i < tnl->pipeline.nr_stages ; i++) {
- struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
- if (!s->run( ctx, s ))
- break;
- }
-
- END_FAST_MATH(__tmp);
-}
-
-
-
-/* The default pipeline. This is useful for software rasterizers, and
- * simple hardware rasterizers. For customization, I don't recommend
- * tampering with the internals of these stages in the way that
- * drivers did in Mesa 3.4. These stages are basically black boxes,
- * and should be left intact.
- *
- * To customize the pipeline, consider:
- *
- * - removing redundant stages (making sure that the software rasterizer
- * can cope with this on fallback paths). An example is fog
- * coordinate generation, which is not required in the FX driver.
- *
- * - replacing general-purpose machine-independent stages with
- * general-purpose machine-specific stages. There is no example of
- * this to date, though it must be borne in mind that all subsequent
- * stages that reference the output of the new stage must cope with
- * any machine-specific data introduced. This may not be easy
- * unless there are no such stages (ie the new stage is the last in
- * the pipe).
- *
- * - inserting optimized (but specialized) stages ahead of the
- * general-purpose fallback implementation. For example, the old
- * fastpath mechanism, which only works when the VB->Elts input is
- * available, can be duplicated by placing the fastpath stage at the
- * head of this pipeline. Such specialized stages are currently
- * constrained to have no outputs (ie. they must either finish the *
- * pipeline by returning GL_FALSE from run(), or do nothing).
- *
- * Some work can be done to lift some of the restrictions in the final
- * case, if it becomes necessary to do so.
- */
-const struct tnl_pipeline_stage *_tnl_default_pipeline[] = {
- &_tnl_vertex_transform_stage,
- &_tnl_normal_transform_stage,
- &_tnl_lighting_stage,
- &_tnl_fog_coordinate_stage,
- &_tnl_texgen_stage,
- &_tnl_texture_transform_stage,
- &_tnl_point_attenuation_stage,
-#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
- &_tnl_arb_vertex_program_stage,
- &_tnl_vertex_program_stage,
-#endif
- &_tnl_render_stage,
- NULL
-};
-
-const struct tnl_pipeline_stage *_tnl_vp_pipeline[] = {
- &_tnl_arb_vertex_program_stage,
- &_tnl_render_stage,
- NULL
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h
deleted file mode 100644
index 6c7a0814c..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h
+++ /dev/null
@@ -1,76 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-#ifndef _T_PIPELINE_H_
-#define _T_PIPELINE_H_
-
-#include "mtypes.h"
-#include "t_context.h"
-
-extern void _tnl_run_pipeline( GLcontext *ctx );
-
-extern void _tnl_destroy_pipeline( GLcontext *ctx );
-
-extern void _tnl_install_pipeline( GLcontext *ctx,
- const struct tnl_pipeline_stage **stages );
-
-
-/* These are implemented in the t_vb_*.c files:
- */
-extern const struct tnl_pipeline_stage _tnl_vertex_transform_stage;
-extern const struct tnl_pipeline_stage _tnl_vertex_cull_stage;
-extern const struct tnl_pipeline_stage _tnl_normal_transform_stage;
-extern const struct tnl_pipeline_stage _tnl_lighting_stage;
-extern const struct tnl_pipeline_stage _tnl_fog_coordinate_stage;
-extern const struct tnl_pipeline_stage _tnl_texgen_stage;
-extern const struct tnl_pipeline_stage _tnl_texture_transform_stage;
-extern const struct tnl_pipeline_stage _tnl_point_attenuation_stage;
-extern const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage;
-extern const struct tnl_pipeline_stage _tnl_vertex_program_stage;
-extern const struct tnl_pipeline_stage _tnl_render_stage;
-
-/* Shorthand to plug in the default pipeline:
- */
-extern const struct tnl_pipeline_stage *_tnl_default_pipeline[];
-extern const struct tnl_pipeline_stage *_tnl_vp_pipeline[];
-
-
-/* Convenience routines provided by t_vb_render.c:
- */
-extern tnl_render_func _tnl_render_tab_elts[];
-extern tnl_render_func _tnl_render_tab_verts[];
-
-extern void _tnl_RenderClippedPolygon( GLcontext *ctx,
- const GLuint *elts, GLuint n );
-
-extern void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj );
-
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c
deleted file mode 100644
index 9788468d5..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c
+++ /dev/null
@@ -1,1724 +0,0 @@
-/* $XFree86$ */
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-/* Display list compiler attempts to store lists of vertices with the
- * same vertex layout. Additionally it attempts to minimize the need
- * for execute-time fixup of these vertex lists, allowing them to be
- * cached on hardware.
- *
- * There are still some circumstances where this can be thwarted, for
- * example by building a list that consists of one very long primitive
- * (eg Begin(Triangles), 1000 vertices, End), and calling that list
- * from inside a different begin/end object (Begin(Lines), CallList,
- * End).
- *
- * In that case the code will have to replay the list as individual
- * commands through the Exec dispatch table, or fix up the copied
- * vertices at execute-time.
- *
- * The other case where fixup is required is when a vertex attribute
- * is introduced in the middle of a primitive. Eg:
- * Begin(Lines)
- * TexCoord1f() Vertex2f()
- * TexCoord1f() Color3f() Vertex2f()
- * End()
- *
- * If the current value of Color isn't known at compile-time, this
- * primitive will require fixup.
- *
- *
- * The list compiler currently doesn't attempt to compile lists
- * containing EvalCoord or EvalPoint commands. On encountering one of
- * these, compilation falls back to opcodes.
- *
- * This could be improved to fallback only when a mix of EvalCoord and
- * Vertex commands are issued within a single primitive.
- */
-
-
-#include "glheader.h"
-#include "context.h"
-#include "dlist.h"
-#include "enums.h"
-#include "macros.h"
-#include "api_validate.h"
-#include "api_arrayelt.h"
-#include "vtxfmt.h"
-#include "t_save_api.h"
-#include "dispatch.h"
-
-/*
- * NOTE: Old 'parity' issue is gone, but copying can still be
- * wrong-footed on replay.
- */
-static GLuint _save_copy_vertices( GLcontext *ctx,
- const struct tnl_vertex_list *node )
-{
- TNLcontext *tnl = TNL_CONTEXT( ctx );
- const struct tnl_prim *prim = &node->prim[node->prim_count-1];
- GLuint nr = prim->count;
- GLuint sz = tnl->save.vertex_size;
- const GLfloat *src = node->buffer + prim->start * sz;
- GLfloat *dst = tnl->save.copied.buffer;
- GLuint ovf, i;
-
- if (prim->mode & PRIM_END)
- return 0;
-
- switch( prim->mode & PRIM_MODE_MASK )
- {
- case GL_POINTS:
- return 0;
- case GL_LINES:
- ovf = nr&1;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- case GL_TRIANGLES:
- ovf = nr%3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- case GL_QUADS:
- ovf = nr&3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- case GL_LINE_STRIP:
- if (nr == 0)
- return 0;
- else {
- _mesa_memcpy( dst, src+(nr-1)*sz, sz*sizeof(GLfloat) );
- return 1;
- }
- case GL_LINE_LOOP:
- case GL_TRIANGLE_FAN:
- case GL_POLYGON:
- if (nr == 0)
- return 0;
- else if (nr == 1) {
- _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) );
- return 1;
- } else {
- _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) );
- _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz*sizeof(GLfloat) );
- return 2;
- }
- case GL_TRIANGLE_STRIP:
- case GL_QUAD_STRIP:
- switch (nr) {
- case 0: ovf = 0; break;
- case 1: ovf = 1; break;
- default: ovf = 2 + (nr&1); break;
- }
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
- return i;
- default:
- assert(0);
- return 0;
- }
-}
-
-
-static void
-build_normal_lengths( struct tnl_vertex_list *node )
-{
- GLuint i;
- GLfloat *len;
- GLfloat *n = node->buffer;
- GLuint stride = node->vertex_size;
- GLuint count = node->count;
-
- len = node->normal_lengths = (GLfloat *) MALLOC( count * sizeof(GLfloat) );
- if (!len)
- return;
-
- /* Find the normal of the first vertex:
- */
- for (i = 0 ; i < _TNL_ATTRIB_NORMAL ; i++)
- n += node->attrsz[i];
-
- for (i = 0 ; i < count ; i++, n += stride) {
- len[i] = LEN_3FV( n );
- if (len[i] > 0.0F) len[i] = 1.0F / len[i];
- }
-}
-
-static struct tnl_vertex_store *alloc_vertex_store( GLcontext *ctx )
-{
- struct tnl_vertex_store *store = MALLOC_STRUCT(tnl_vertex_store);
- (void) ctx;
- store->used = 0;
- store->refcount = 1;
- return store;
-}
-
-static struct tnl_primitive_store *alloc_prim_store( GLcontext *ctx )
-{
- struct tnl_primitive_store *store = MALLOC_STRUCT(tnl_primitive_store);
- (void) ctx;
- store->used = 0;
- store->refcount = 1;
- return store;
-}
-
-static void _save_reset_counters( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- tnl->save.prim = tnl->save.prim_store->buffer + tnl->save.prim_store->used;
- tnl->save.buffer = (tnl->save.vertex_store->buffer +
- tnl->save.vertex_store->used);
-
- if (tnl->save.vertex_size)
- tnl->save.initial_counter = ((SAVE_BUFFER_SIZE -
- tnl->save.vertex_store->used) /
- tnl->save.vertex_size);
- else
- tnl->save.initial_counter = 0;
-
- if (tnl->save.initial_counter > ctx->Const.MaxArrayLockSize )
- tnl->save.initial_counter = ctx->Const.MaxArrayLockSize;
-
- tnl->save.counter = tnl->save.initial_counter;
- tnl->save.prim_count = 0;
- tnl->save.prim_max = SAVE_PRIM_SIZE - tnl->save.prim_store->used;
- tnl->save.copied.nr = 0;
- tnl->save.dangling_attr_ref = 0;
-}
-
-
-/* Insert the active immediate struct onto the display list currently
- * being built.
- */
-static void _save_compile_vertex_list( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_vertex_list *node;
-
- /* Allocate space for this structure in the display list currently
- * being compiled.
- */
- node = (struct tnl_vertex_list *)
- _mesa_alloc_instruction(ctx, tnl->save.opcode_vertex_list, sizeof(*node));
-
- if (!node)
- return;
-
- /* Duplicate our template, increment refcounts to the storage structs:
- */
- _mesa_memcpy(node->attrsz, tnl->save.attrsz, sizeof(node->attrsz));
- node->vertex_size = tnl->save.vertex_size;
- node->buffer = tnl->save.buffer;
- node->count = tnl->save.initial_counter - tnl->save.counter;
- node->wrap_count = tnl->save.copied.nr;
- node->have_materials = tnl->save.have_materials;
- node->dangling_attr_ref = tnl->save.dangling_attr_ref;
- node->normal_lengths = NULL;
- node->prim = tnl->save.prim;
- node->prim_count = tnl->save.prim_count;
- node->vertex_store = tnl->save.vertex_store;
- node->prim_store = tnl->save.prim_store;
-
- node->vertex_store->refcount++;
- node->prim_store->refcount++;
-
- assert(node->attrsz[_TNL_ATTRIB_POS] != 0 ||
- node->count == 0);
-
- if (tnl->save.dangling_attr_ref)
- ctx->ListState.CurrentList->flags |= MESA_DLIST_DANGLING_REFS;
-
- /* Maybe calculate normal lengths:
- */
- if (tnl->CalcDListNormalLengths &&
- node->attrsz[_TNL_ATTRIB_NORMAL] == 3 &&
- !(ctx->ListState.CurrentList->flags & MESA_DLIST_DANGLING_REFS))
- build_normal_lengths( node );
-
-
- tnl->save.vertex_store->used += tnl->save.vertex_size * node->count;
- tnl->save.prim_store->used += node->prim_count;
-
- /* Decide whether the storage structs are full, or can be used for
- * the next vertex lists as well.
- */
- if (tnl->save.vertex_store->used >
- SAVE_BUFFER_SIZE - 16 * (tnl->save.vertex_size + 4)) {
-
- tnl->save.vertex_store->refcount--;
- assert(tnl->save.vertex_store->refcount != 0);
- tnl->save.vertex_store = alloc_vertex_store( ctx );
- tnl->save.vbptr = tnl->save.vertex_store->buffer;
- }
-
- if (tnl->save.prim_store->used > SAVE_PRIM_SIZE - 6) {
- tnl->save.prim_store->refcount--;
- assert(tnl->save.prim_store->refcount != 0);
- tnl->save.prim_store = alloc_prim_store( ctx );
- }
-
- /* Reset our structures for the next run of vertices:
- */
- _save_reset_counters( ctx );
-
- /* Copy duplicated vertices
- */
- tnl->save.copied.nr = _save_copy_vertices( ctx, node );
-
-
- /* Deal with GL_COMPILE_AND_EXECUTE:
- */
- if (ctx->ExecuteFlag) {
- _tnl_playback_vertex_list( ctx, (void *) node );
- }
-}
-
-
-/* TODO -- If no new vertices have been stored, don't bother saving
- * it.
- */
-static void _save_wrap_buffers( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i = tnl->save.prim_count - 1;
- GLenum mode;
-
- assert(i < (GLint) tnl->save.prim_max);
- assert(i >= 0);
-
- /* Close off in-progress primitive.
- */
- tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) -
- tnl->save.prim[i].start);
- mode = tnl->save.prim[i].mode & ~(PRIM_BEGIN|PRIM_END);
-
- /* store the copied vertices, and allocate a new list.
- */
- _save_compile_vertex_list( ctx );
-
- /* Restart interrupted primitive
- */
- tnl->save.prim[0].mode = mode;
- tnl->save.prim[0].start = 0;
- tnl->save.prim[0].count = 0;
- tnl->save.prim_count = 1;
-}
-
-
-
-/* Called only when buffers are wrapped as the result of filling the
- * vertex_store struct.
- */
-static void _save_wrap_filled_vertex( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLfloat *data = tnl->save.copied.buffer;
- GLuint i;
-
- /* Emit a glEnd to close off the last vertex list.
- */
- _save_wrap_buffers( ctx );
-
- /* Copy stored stored vertices to start of new list.
- */
- assert(tnl->save.counter > tnl->save.copied.nr);
-
- for (i = 0 ; i < tnl->save.copied.nr ; i++) {
- _mesa_memcpy( tnl->save.vbptr, data, tnl->save.vertex_size * sizeof(GLfloat));
- data += tnl->save.vertex_size;
- tnl->save.vbptr += tnl->save.vertex_size;
- tnl->save.counter--;
- }
-}
-
-
-static void _save_copy_to_current( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++) {
- if (tnl->save.attrsz[i]) {
- tnl->save.currentsz[i][0] = tnl->save.attrsz[i];
- COPY_CLEAN_4V(tnl->save.current[i],
- tnl->save.attrsz[i],
- tnl->save.attrptr[i]);
- }
- }
-
- /* Edgeflag requires special treatment:
- *
- * TODO: change edgeflag to GLfloat in Mesa.
- */
- if (tnl->save.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- ctx->ListState.ActiveEdgeFlag = 1;
- tnl->save.CurrentFloatEdgeFlag =
- tnl->save.attrptr[_TNL_ATTRIB_EDGEFLAG][0];
- ctx->ListState.CurrentEdgeFlag =
- (tnl->save.CurrentFloatEdgeFlag == 1.0);
- }
-}
-
-
-static void _save_copy_from_current( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i;
-
- for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++)
- switch (tnl->save.attrsz[i]) {
- case 4: tnl->save.attrptr[i][3] = tnl->save.current[i][3];
- case 3: tnl->save.attrptr[i][2] = tnl->save.current[i][2];
- case 2: tnl->save.attrptr[i][1] = tnl->save.current[i][1];
- case 1: tnl->save.attrptr[i][0] = tnl->save.current[i][0];
- case 0: break;
- }
-
- /* Edgeflag requires special treatment:
- */
- if (tnl->save.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- tnl->save.CurrentFloatEdgeFlag = (GLfloat)ctx->ListState.CurrentEdgeFlag;
- tnl->save.attrptr[_TNL_ATTRIB_EDGEFLAG][0] = tnl->save.CurrentFloatEdgeFlag;
- }
-}
-
-
-
-
-/* Flush existing data, set new attrib size, replay copied vertices.
- */
-static void _save_upgrade_vertex( GLcontext *ctx,
- GLuint attr,
- GLuint newsz )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint oldsz;
- GLuint i;
- GLfloat *tmp;
-
- /* Store the current run of vertices, and emit a GL_END. Emit a
- * BEGIN in the new buffer.
- */
- if (tnl->save.initial_counter != tnl->save.counter)
- _save_wrap_buffers( ctx );
- else
- assert( tnl->save.copied.nr == 0 );
-
- /* Do a COPY_TO_CURRENT to ensure back-copying works for the case
- * when the attribute already exists in the vertex and is having
- * its size increased.
- */
- _save_copy_to_current( ctx );
-
- /* Fix up sizes:
- */
- oldsz = tnl->save.attrsz[attr];
- tnl->save.attrsz[attr] = newsz;
-
- tnl->save.vertex_size += newsz - oldsz;
- tnl->save.counter = ((SAVE_BUFFER_SIZE - tnl->save.vertex_store->used) /
- tnl->save.vertex_size);
- if (tnl->save.counter > ctx->Const.MaxArrayLockSize )
- tnl->save.counter = ctx->Const.MaxArrayLockSize;
- tnl->save.initial_counter = tnl->save.counter;
-
- /* Recalculate all the attrptr[] values:
- */
- for (i = 0, tmp = tnl->save.vertex ; i < _TNL_ATTRIB_MAX ; i++) {
- if (tnl->save.attrsz[i]) {
- tnl->save.attrptr[i] = tmp;
- tmp += tnl->save.attrsz[i];
- }
- else
- tnl->save.attrptr[i] = NULL; /* will not be dereferenced. */
- }
-
- /* Copy from current to repopulate the vertex with correct values.
- */
- _save_copy_from_current( ctx );
-
- /* Replay stored vertices to translate them to new format here.
- *
- * If there are copied vertices and the new (upgraded) attribute
- * has not been defined before, this list is somewhat degenerate,
- * and will need fixup at runtime.
- */
- if (tnl->save.copied.nr)
- {
- GLfloat *data = tnl->save.copied.buffer;
- GLfloat *dest = tnl->save.buffer;
- GLuint j;
-
- /* Need to note this and fix up at runtime (or loopback):
- */
- if (tnl->save.currentsz[attr][0] == 0) {
- assert(oldsz == 0);
- tnl->save.dangling_attr_ref = GL_TRUE;
-
-/* _mesa_debug(NULL, "_save_upgrade_vertex: dangling reference attr %d\n", */
-/* attr); */
-
-#if 0
- /* The current strategy is to punt these degenerate cases
- * through _tnl_loopback_vertex_list(), a lower-performance
- * option. To minimize the impact of this, artificially
- * reduce the size of this vertex_list.
- */
- if (t->save.counter > 10) {
- t->save.initial_counter = 10;
- t->save.counter = 10;
- }
-#endif
- }
-
- for (i = 0 ; i < tnl->save.copied.nr ; i++) {
- for (j = 0 ; j < _TNL_ATTRIB_MAX ; j++) {
- if (tnl->save.attrsz[j]) {
- if (j == attr) {
- if (oldsz) {
- COPY_CLEAN_4V( dest, oldsz, data );
- data += oldsz;
- dest += newsz;
- }
- else {
- COPY_SZ_4V( dest, newsz, tnl->save.current[attr] );
- dest += newsz;
- }
- }
- else {
- GLint sz = tnl->save.attrsz[j];
- COPY_SZ_4V( dest, sz, data );
- data += sz;
- dest += sz;
- }
- }
- }
- }
-
- tnl->save.vbptr = dest;
- tnl->save.counter -= tnl->save.copied.nr;
- }
-}
-
-
-
-
-/* Helper function for 'CHOOSE' macro. Do what's necessary when an
- * entrypoint is called for the first time.
- */
-static void do_choose( GLuint attr, GLuint sz,
- void (*attr_func)( const GLfloat *),
- void (*choose1)( const GLfloat *),
- void (*choose2)( const GLfloat *),
- void (*choose3)( const GLfloat *),
- void (*choose4)( const GLfloat *),
- const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- static GLfloat id[4] = { 0, 0, 0, 1 };
- int i;
-
- if (tnl->save.attrsz[attr] < sz) {
- /* New size is larger. Need to flush existing vertices and get
- * an enlarged vertex format.
- */
- _save_upgrade_vertex( ctx, attr, sz );
- }
- else {
- /* New size is equal or smaller - just need to fill in some
- * zeros.
- */
- for (i = sz ; i <= tnl->save.attrsz[attr] ; i++)
- tnl->save.attrptr[attr][i-1] = id[i-1];
- }
-
- /* Reset any active pointers for this attribute
- */
- tnl->save.tabfv[attr][0] = choose1;
- tnl->save.tabfv[attr][1] = choose2;
- tnl->save.tabfv[attr][2] = choose3;
- tnl->save.tabfv[attr][3] = choose4;
-
- /* Update the secondary dispatch table with the new function
- */
- tnl->save.tabfv[attr][sz-1] = attr_func;
-
- (*attr_func)(v);
-}
-
-
-
-/* Only one size for each attribute may be active at once. Eg. if
- * Color3f is installed/active, then Color4f may not be, even if the
- * vertex actually contains 4 color coordinates. This is because the
- * 3f version won't otherwise set color[3] to 1.0 -- this is the job
- * of the chooser function when switching between Color4f and Color3f.
- */
-#define ATTRFV( ATTR, N ) \
-static void save_choose_##ATTR##_##N( const GLfloat *v ); \
- \
-static void save_attrib_##ATTR##_##N( const GLfloat *v ) \
-{ \
- GET_CURRENT_CONTEXT( ctx ); \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- \
- if ((ATTR) == 0) { \
- GLuint i; \
- \
- if (N>0) tnl->save.vbptr[0] = v[0]; \
- if (N>1) tnl->save.vbptr[1] = v[1]; \
- if (N>2) tnl->save.vbptr[2] = v[2]; \
- if (N>3) tnl->save.vbptr[3] = v[3]; \
- \
- for (i = N; i < tnl->save.vertex_size; i++) \
- tnl->save.vbptr[i] = tnl->save.vertex[i]; \
- \
- tnl->save.vbptr += tnl->save.vertex_size; \
- \
- if (--tnl->save.counter == 0) \
- _save_wrap_filled_vertex( ctx ); \
- } \
- else { \
- GLfloat *dest = tnl->save.attrptr[ATTR]; \
- if (N>0) dest[0] = v[0]; \
- if (N>1) dest[1] = v[1]; \
- if (N>2) dest[2] = v[2]; \
- if (N>3) dest[3] = v[3]; \
- } \
-}
-
-#define CHOOSE( ATTR, N ) \
-static void save_choose_##ATTR##_##N( const GLfloat *v ) \
-{ \
- do_choose(ATTR, N, \
- save_attrib_##ATTR##_##N, \
- save_choose_##ATTR##_1, \
- save_choose_##ATTR##_2, \
- save_choose_##ATTR##_3, \
- save_choose_##ATTR##_4, \
- v ); \
-}
-
-#define INIT(ATTR) \
-static void save_init_##ATTR( TNLcontext *tnl ) \
-{ \
- tnl->save.tabfv[ATTR][0] = save_choose_##ATTR##_1; \
- tnl->save.tabfv[ATTR][1] = save_choose_##ATTR##_2; \
- tnl->save.tabfv[ATTR][2] = save_choose_##ATTR##_3; \
- tnl->save.tabfv[ATTR][3] = save_choose_##ATTR##_4; \
-}
-
-#define ATTRS( ATTRIB ) \
- ATTRFV( ATTRIB, 1 ) \
- ATTRFV( ATTRIB, 2 ) \
- ATTRFV( ATTRIB, 3 ) \
- ATTRFV( ATTRIB, 4 ) \
- CHOOSE( ATTRIB, 1 ) \
- CHOOSE( ATTRIB, 2 ) \
- CHOOSE( ATTRIB, 3 ) \
- CHOOSE( ATTRIB, 4 ) \
- INIT( ATTRIB ) \
-
-
-/* Generate a lot of functions. These are the actual worker
- * functions, which are equivalent to those generated via codegen
- * elsewhere.
- */
-ATTRS( 0 )
-ATTRS( 1 )
-ATTRS( 2 )
-ATTRS( 3 )
-ATTRS( 4 )
-ATTRS( 5 )
-ATTRS( 6 )
-ATTRS( 7 )
-ATTRS( 8 )
-ATTRS( 9 )
-ATTRS( 10 )
-ATTRS( 11 )
-ATTRS( 12 )
-ATTRS( 13 )
-ATTRS( 14 )
-ATTRS( 15 )
-
-
-static void _save_reset_vertex( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- save_init_0( tnl );
- save_init_1( tnl );
- save_init_2( tnl );
- save_init_3( tnl );
- save_init_4( tnl );
- save_init_5( tnl );
- save_init_6( tnl );
- save_init_7( tnl );
- save_init_8( tnl );
- save_init_9( tnl );
- save_init_10( tnl );
- save_init_11( tnl );
- save_init_12( tnl );
- save_init_13( tnl );
- save_init_14( tnl );
- save_init_15( tnl );
-
- for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
- tnl->save.attrsz[i] = 0;
-
- tnl->save.vertex_size = 0;
- tnl->save.have_materials = 0;
-
- _save_reset_counters( ctx );
-}
-
-
-
-/* Cope with aliasing of classic Vertex, Normal, etc. and the fan-out
- * of glMultTexCoord and glProgramParamterNV by routing all these
- * through a second level dispatch table.
- */
-#define DISPATCH_ATTRFV( ATTR, COUNT, P ) \
-do { \
- GET_CURRENT_CONTEXT( ctx ); \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- tnl->save.tabfv[ATTR][COUNT-1]( P ); \
-} while (0)
-
-#define DISPATCH_ATTR1FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 1, V )
-#define DISPATCH_ATTR2FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 2, V )
-#define DISPATCH_ATTR3FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 3, V )
-#define DISPATCH_ATTR4FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 4, V )
-
-#define DISPATCH_ATTR1F( ATTR, S ) DISPATCH_ATTRFV( ATTR, 1, &(S) )
-
-#if defined(USE_X86_ASM) && 0 /* will break register calling convention */
-/* Naughty cheat:
- */
-#define DISPATCH_ATTR2F( ATTR, S,T ) DISPATCH_ATTRFV( ATTR, 2, &(S) )
-#define DISPATCH_ATTR3F( ATTR, S,T,R ) DISPATCH_ATTRFV( ATTR, 3, &(S) )
-#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) DISPATCH_ATTRFV( ATTR, 4, &(S) )
-#else
-/* Safe:
- */
-#define DISPATCH_ATTR2F( ATTR, S,T ) \
-do { \
- GLfloat v[2]; \
- v[0] = S; v[1] = T; \
- DISPATCH_ATTR2FV( ATTR, v ); \
-} while (0)
-#define DISPATCH_ATTR3F( ATTR, S,T,R ) \
-do { \
- GLfloat v[3]; \
- v[0] = S; v[1] = T; v[2] = R; \
- DISPATCH_ATTR3FV( ATTR, v ); \
-} while (0)
-#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) \
-do { \
- GLfloat v[4]; \
- v[0] = S; v[1] = T; v[2] = R; v[3] = Q; \
- DISPATCH_ATTR4FV( ATTR, v ); \
-} while (0)
-#endif
-
-
-static void enum_error( void )
-{
- GET_CURRENT_CONTEXT( ctx );
- _mesa_compile_error( ctx, GL_INVALID_ENUM, "glVertexAttrib" );
-}
-
-static void GLAPIENTRY _save_Vertex2f( GLfloat x, GLfloat y )
-{
- DISPATCH_ATTR2F( _TNL_ATTRIB_POS, x, y );
-}
-
-static void GLAPIENTRY _save_Vertex2fv( const GLfloat *v )
-{
- DISPATCH_ATTR2FV( _TNL_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY _save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_POS, x, y, z );
-}
-
-static void GLAPIENTRY _save_Vertex3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY _save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- DISPATCH_ATTR4F( _TNL_ATTRIB_POS, x, y, z, w );
-}
-
-static void GLAPIENTRY _save_Vertex4fv( const GLfloat *v )
-{
- DISPATCH_ATTR4FV( _TNL_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY _save_TexCoord1f( GLfloat x )
-{
- DISPATCH_ATTR1F( _TNL_ATTRIB_TEX0, x );
-}
-
-static void GLAPIENTRY _save_TexCoord1fv( const GLfloat *v )
-{
- DISPATCH_ATTR1FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _save_TexCoord2f( GLfloat x, GLfloat y )
-{
- DISPATCH_ATTR2F( _TNL_ATTRIB_TEX0, x, y );
-}
-
-static void GLAPIENTRY _save_TexCoord2fv( const GLfloat *v )
-{
- DISPATCH_ATTR2FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_TEX0, x, y, z );
-}
-
-static void GLAPIENTRY _save_TexCoord3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- DISPATCH_ATTR4F( _TNL_ATTRIB_TEX0, x, y, z, w );
-}
-
-static void GLAPIENTRY _save_TexCoord4fv( const GLfloat *v )
-{
- DISPATCH_ATTR4FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_NORMAL, x, y, z );
-}
-
-static void GLAPIENTRY _save_Normal3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_NORMAL, v );
-}
-
-static void GLAPIENTRY _save_FogCoordfEXT( GLfloat x )
-{
- DISPATCH_ATTR1F( _TNL_ATTRIB_FOG, x );
-}
-
-static void GLAPIENTRY _save_FogCoordfvEXT( const GLfloat *v )
-{
- DISPATCH_ATTR1FV( _TNL_ATTRIB_FOG, v );
-}
-
-static void GLAPIENTRY _save_Color3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR0, x, y, z );
-}
-
-static void GLAPIENTRY _save_Color3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY _save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- DISPATCH_ATTR4F( _TNL_ATTRIB_COLOR0, x, y, z, w );
-}
-
-static void GLAPIENTRY _save_Color4fv( const GLfloat *v )
-{
- DISPATCH_ATTR4FV( _TNL_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY _save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR1, x, y, z );
-}
-
-static void GLAPIENTRY _save_SecondaryColor3fvEXT( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR1, v );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord1f( GLenum target, GLfloat x )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR1F( attr, x );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR1FV( attr, v );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR2F( attr, x, y );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR2FV( attr, v );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
- GLfloat z)
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR3F( attr, x, y, z );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR3FV( attr, v );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
- GLfloat z, GLfloat w )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR4F( attr, x, y, z, w );
-}
-
-static void GLAPIENTRY _save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR4FV( attr, v );
-}
-
-static void GLAPIENTRY _save_VertexAttrib1fNV( GLuint index, GLfloat x )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR1F( index, x );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR1FV( index, v );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR2F( index, x, y );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR2FV( index, v );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y,
- GLfloat z )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR3F( index, x, y, z );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR3FV( index, v );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
- GLfloat z, GLfloat w )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR4F( index, x, y, z, w );
- else
- enum_error();
-}
-
-static void GLAPIENTRY _save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR4FV( index, v );
- else
- enum_error();
-}
-
-
-static void GLAPIENTRY
-_save_VertexAttrib1fARB( GLuint index, GLfloat x )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR1F( index, x );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR1FV( index, v );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR2F( index, x, y );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR2FV( index, v );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR3F( index, x, y, z );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR3FV( index, v );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR4F( index, x, y, z, w );
- else
- enum_error();
-}
-
-static void GLAPIENTRY
-_save_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
-{
- if (index < VERT_ATTRIB_MAX)
- DISPATCH_ATTR4FV( index, v );
- else
- enum_error();
-}
-
-
-/* Materials:
- *
- * These are treated as per-vertex attributes, at indices above where
- * the NV_vertex_program leaves off. There are a lot of good things
- * about treating materials this way.
- *
- * However: I don't want to double the number of generated functions
- * just to cope with this, so I unroll the 'C' varients of CHOOSE and
- * ATTRF into this function, and dispense with codegen and
- * second-level dispatch.
- *
- * There is no aliasing of material attributes with other entrypoints.
- */
-#define MAT_ATTR( A, N, params ) \
-do { \
- if (tnl->save.attrsz[A] < N) { \
- _save_upgrade_vertex( ctx, A, N ); \
- tnl->save.have_materials = GL_TRUE; \
- } \
- \
- { \
- GLfloat *dest = tnl->save.attrptr[A]; \
- if (N>0) dest[0] = params[0]; \
- if (N>1) dest[1] = params[1]; \
- if (N>2) dest[2] = params[2]; \
- if (N>3) dest[3] = params[3]; \
- } \
-} while (0)
-
-
-#define MAT( ATTR, N, face, params ) \
-do { \
- if (face != GL_BACK) \
- MAT_ATTR( ATTR, N, params ); /* front */ \
- if (face != GL_FRONT) \
- MAT_ATTR( ATTR + 1, N, params ); /* back */ \
-} while (0)
-
-
-/* NOTE: Have to remove/deal-with colormaterial crossovers, probably
- * later on - in the meantime just store everything.
- */
-static void GLAPIENTRY _save_Materialfv( GLenum face, GLenum pname,
- const GLfloat *params )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- switch (pname) {
- case GL_EMISSION:
- MAT( _TNL_ATTRIB_MAT_FRONT_EMISSION, 4, face, params );
- break;
- case GL_AMBIENT:
- MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
- break;
- case GL_DIFFUSE:
- MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
- break;
- case GL_SPECULAR:
- MAT( _TNL_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params );
- break;
- case GL_SHININESS:
- MAT( _TNL_ATTRIB_MAT_FRONT_SHININESS, 1, face, params );
- break;
- case GL_COLOR_INDEXES:
- MAT( _TNL_ATTRIB_MAT_FRONT_INDEXES, 3, face, params );
- break;
- case GL_AMBIENT_AND_DIFFUSE:
- MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
- MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
- break;
- default:
- _mesa_compile_error( ctx, GL_INVALID_ENUM, "glMaterialfv" );
- return;
- }
-}
-
-
-#define IDX_ATTR( A, IDX ) \
-do { \
- GET_CURRENT_CONTEXT( ctx ); \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- \
- if (tnl->save.attrsz[A] < 1) { \
- _save_upgrade_vertex( ctx, A, 1 ); \
- } \
- \
- { \
- GLfloat *dest = tnl->save.attrptr[A]; \
- dest[0] = IDX; \
- } \
-} while (0)
-
-
-static void GLAPIENTRY _save_EdgeFlag( GLboolean b )
-{
- IDX_ATTR( _TNL_ATTRIB_EDGEFLAG, (GLfloat)b );
-}
-
-static void GLAPIENTRY _save_EdgeFlagv( const GLboolean *v )
-{
- IDX_ATTR( _TNL_ATTRIB_EDGEFLAG, (GLfloat)(v[0]) );
-}
-
-static void GLAPIENTRY _save_Indexf( GLfloat f )
-{
- IDX_ATTR( _TNL_ATTRIB_INDEX, f );
-}
-
-static void GLAPIENTRY _save_Indexfv( const GLfloat *f )
-{
- IDX_ATTR( _TNL_ATTRIB_INDEX, f[0] );
-}
-
-
-
-
-/* Cope with EvalCoord/CallList called within a begin/end object:
- * -- Flush current buffer
- * -- Fallback to opcodes for the rest of the begin/end object.
- */
-#define FALLBACK(ctx) \
-do { \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- \
- if (tnl->save.initial_counter != tnl->save.counter || \
- tnl->save.prim_count) \
- _save_compile_vertex_list( ctx ); \
- \
- _save_copy_to_current( ctx ); \
- _save_reset_vertex( ctx ); \
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); \
- ctx->Driver.SaveNeedFlush = 0; \
-} while (0)
-
-static void GLAPIENTRY _save_EvalCoord1f( GLfloat u )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_EvalCoord1f(ctx->Save, ( u ));
-}
-
-static void GLAPIENTRY _save_EvalCoord1fv( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_EvalCoord1fv(ctx->Save, ( v ));
-}
-
-static void GLAPIENTRY _save_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_EvalCoord2f(ctx->Save, ( u, v ));
-}
-
-static void GLAPIENTRY _save_EvalCoord2fv( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_EvalCoord2fv(ctx->Save, ( v ));
-}
-
-static void GLAPIENTRY _save_EvalPoint1( GLint i )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_EvalPoint1(ctx->Save, ( i ));
-}
-
-static void GLAPIENTRY _save_EvalPoint2( GLint i, GLint j )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_EvalPoint2(ctx->Save, ( i, j ));
-}
-
-static void GLAPIENTRY _save_CallList( GLuint l )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_CallList(ctx->Save, ( l ));
-}
-
-static void GLAPIENTRY _save_CallLists( GLsizei n, GLenum type, const GLvoid *v )
-{
- GET_CURRENT_CONTEXT(ctx);
- FALLBACK(ctx);
- CALL_CallLists(ctx->Save, ( n, type, v ));
-}
-
-
-
-
-/* This begin is hooked into ... Updating of
- * ctx->Driver.CurrentSavePrimitive is already taken care of.
- */
-static GLboolean _save_NotifyBegin( GLcontext *ctx, GLenum mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- if (1) {
- GLuint i = tnl->save.prim_count++;
-
- assert(i < tnl->save.prim_max);
- tnl->save.prim[i].mode = mode | PRIM_BEGIN;
- tnl->save.prim[i].start = tnl->save.initial_counter - tnl->save.counter;
- tnl->save.prim[i].count = 0;
-
- _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt );
- ctx->Driver.SaveNeedFlush = 1;
- return GL_TRUE;
- }
- else
- return GL_FALSE;
-}
-
-
-
-static void GLAPIENTRY _save_End( void )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i = tnl->save.prim_count - 1;
-
- ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
- tnl->save.prim[i].mode |= PRIM_END;
- tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) -
- tnl->save.prim[i].start);
-
- if (i == (GLint) tnl->save.prim_max - 1) {
- _save_compile_vertex_list( ctx );
- assert(tnl->save.copied.nr == 0);
- }
-
- /* Swap out this vertex format while outside begin/end. Any color,
- * etc. received between here and the next begin will be compiled
- * as opcodes.
- */
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
-}
-
-
-/* These are all errors as this vtxfmt is only installed inside
- * begin/end pairs.
- */
-static void GLAPIENTRY _save_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) count; (void) type; (void) indices;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawElements" );
-}
-
-
-static void GLAPIENTRY _save_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) start; (void) end; (void) count; (void) type; (void) indices;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawRangeElements" );
-}
-
-static void GLAPIENTRY _save_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) start; (void) count;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawArrays" );
-}
-
-static void GLAPIENTRY _save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) x1; (void) y1; (void) x2; (void) y2;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glRectf" );
-}
-
-static void GLAPIENTRY _save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) i1; (void) i2;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh1" );
-}
-
-static void GLAPIENTRY _save_EvalMesh2( GLenum mode, GLint i1, GLint i2,
- GLint j1, GLint j2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- (void) mode; (void) i1; (void) i2; (void) j1; (void) j2;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh2" );
-}
-
-static void GLAPIENTRY _save_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT( ctx );
- (void) mode;
- _mesa_compile_error( ctx, GL_INVALID_OPERATION, "Recursive glBegin" );
-}
-
-
-/* Unlike the functions above, these are to be hooked into the vtxfmt
- * maintained in ctx->ListState, active when the list is known or
- * suspected to be outside any begin/end primitive.
- */
-static void GLAPIENTRY _save_OBE_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- _save_NotifyBegin( ctx, GL_QUADS | PRIM_WEAK );
- CALL_Vertex2f(GET_DISPATCH(), ( x1, y1 ));
- CALL_Vertex2f(GET_DISPATCH(), ( x2, y1 ));
- CALL_Vertex2f(GET_DISPATCH(), ( x2, y2 ));
- CALL_Vertex2f(GET_DISPATCH(), ( x1, y2 ));
- CALL_End(GET_DISPATCH(), ());
-}
-
-
-static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i;
-
- if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
- return;
-
- _save_NotifyBegin( ctx, mode | PRIM_WEAK );
- for (i = 0; i < count; i++)
- CALL_ArrayElement(GET_DISPATCH(), (start + i));
- CALL_End(GET_DISPATCH(), ());
-}
-
-
-static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i;
-
- if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
- return;
-
- _save_NotifyBegin( ctx, mode | PRIM_WEAK );
-
- switch (type) {
- case GL_UNSIGNED_BYTE:
- for (i = 0 ; i < count ; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] ));
- break;
- case GL_UNSIGNED_SHORT:
- for (i = 0 ; i < count ; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] ));
- break;
- case GL_UNSIGNED_INT:
- for (i = 0 ; i < count ; i++)
- CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] ));
- break;
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
- break;
- }
-
- CALL_End(GET_DISPATCH(), ());
-}
-
-static void GLAPIENTRY _save_OBE_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- if (_mesa_validate_DrawRangeElements( ctx, mode,
- start, end,
- count, type, indices ))
- _save_OBE_DrawElements( mode, count, type, indices );
-}
-
-
-
-
-
-static void _save_vtxfmt_init( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLvertexformat *vfmt = &tnl->save_vtxfmt;
-
- vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
- vfmt->Begin = _save_Begin;
- vfmt->Color3f = _save_Color3f;
- vfmt->Color3fv = _save_Color3fv;
- vfmt->Color4f = _save_Color4f;
- vfmt->Color4fv = _save_Color4fv;
- vfmt->EdgeFlag = _save_EdgeFlag;
- vfmt->EdgeFlagv = _save_EdgeFlagv;
- vfmt->End = _save_End;
- vfmt->FogCoordfEXT = _save_FogCoordfEXT;
- vfmt->FogCoordfvEXT = _save_FogCoordfvEXT;
- vfmt->Indexf = _save_Indexf;
- vfmt->Indexfv = _save_Indexfv;
- vfmt->Materialfv = _save_Materialfv;
- vfmt->MultiTexCoord1fARB = _save_MultiTexCoord1f;
- vfmt->MultiTexCoord1fvARB = _save_MultiTexCoord1fv;
- vfmt->MultiTexCoord2fARB = _save_MultiTexCoord2f;
- vfmt->MultiTexCoord2fvARB = _save_MultiTexCoord2fv;
- vfmt->MultiTexCoord3fARB = _save_MultiTexCoord3f;
- vfmt->MultiTexCoord3fvARB = _save_MultiTexCoord3fv;
- vfmt->MultiTexCoord4fARB = _save_MultiTexCoord4f;
- vfmt->MultiTexCoord4fvARB = _save_MultiTexCoord4fv;
- vfmt->Normal3f = _save_Normal3f;
- vfmt->Normal3fv = _save_Normal3fv;
- vfmt->SecondaryColor3fEXT = _save_SecondaryColor3fEXT;
- vfmt->SecondaryColor3fvEXT = _save_SecondaryColor3fvEXT;
- vfmt->TexCoord1f = _save_TexCoord1f;
- vfmt->TexCoord1fv = _save_TexCoord1fv;
- vfmt->TexCoord2f = _save_TexCoord2f;
- vfmt->TexCoord2fv = _save_TexCoord2fv;
- vfmt->TexCoord3f = _save_TexCoord3f;
- vfmt->TexCoord3fv = _save_TexCoord3fv;
- vfmt->TexCoord4f = _save_TexCoord4f;
- vfmt->TexCoord4fv = _save_TexCoord4fv;
- vfmt->Vertex2f = _save_Vertex2f;
- vfmt->Vertex2fv = _save_Vertex2fv;
- vfmt->Vertex3f = _save_Vertex3f;
- vfmt->Vertex3fv = _save_Vertex3fv;
- vfmt->Vertex4f = _save_Vertex4f;
- vfmt->Vertex4fv = _save_Vertex4fv;
- vfmt->VertexAttrib1fNV = _save_VertexAttrib1fNV;
- vfmt->VertexAttrib1fvNV = _save_VertexAttrib1fvNV;
- vfmt->VertexAttrib2fNV = _save_VertexAttrib2fNV;
- vfmt->VertexAttrib2fvNV = _save_VertexAttrib2fvNV;
- vfmt->VertexAttrib3fNV = _save_VertexAttrib3fNV;
- vfmt->VertexAttrib3fvNV = _save_VertexAttrib3fvNV;
- vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV;
- vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV;
- vfmt->VertexAttrib1fARB = _save_VertexAttrib1fARB;
- vfmt->VertexAttrib1fvARB = _save_VertexAttrib1fvARB;
- vfmt->VertexAttrib2fARB = _save_VertexAttrib2fARB;
- vfmt->VertexAttrib2fvARB = _save_VertexAttrib2fvARB;
- vfmt->VertexAttrib3fARB = _save_VertexAttrib3fARB;
- vfmt->VertexAttrib3fvARB = _save_VertexAttrib3fvARB;
- vfmt->VertexAttrib4fARB = _save_VertexAttrib4fARB;
- vfmt->VertexAttrib4fvARB = _save_VertexAttrib4fvARB;
-
- /* This will all require us to fallback to saving the list as opcodes:
- */
- vfmt->CallList = _save_CallList; /* inside begin/end */
- vfmt->CallLists = _save_CallLists; /* inside begin/end */
- vfmt->EvalCoord1f = _save_EvalCoord1f;
- vfmt->EvalCoord1fv = _save_EvalCoord1fv;
- vfmt->EvalCoord2f = _save_EvalCoord2f;
- vfmt->EvalCoord2fv = _save_EvalCoord2fv;
- vfmt->EvalPoint1 = _save_EvalPoint1;
- vfmt->EvalPoint2 = _save_EvalPoint2;
-
- /* These are all errors as we at least know we are in some sort of
- * begin/end pair:
- */
- vfmt->EvalMesh1 = _save_EvalMesh1;
- vfmt->EvalMesh2 = _save_EvalMesh2;
- vfmt->Begin = _save_Begin;
- vfmt->Rectf = _save_Rectf;
- vfmt->DrawArrays = _save_DrawArrays;
- vfmt->DrawElements = _save_DrawElements;
- vfmt->DrawRangeElements = _save_DrawRangeElements;
-
-}
-
-
-void _tnl_SaveFlushVertices( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /* Noop when we are actually active:
- */
- if (ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM ||
- ctx->Driver.CurrentSavePrimitive <= GL_POLYGON)
- return;
-
- if (tnl->save.initial_counter != tnl->save.counter ||
- tnl->save.prim_count)
- _save_compile_vertex_list( ctx );
-
- _save_copy_to_current( ctx );
- _save_reset_vertex( ctx );
- ctx->Driver.SaveNeedFlush = 0;
-}
-
-void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- (void) list; (void) mode;
-
- if (!tnl->save.prim_store)
- tnl->save.prim_store = alloc_prim_store( ctx );
-
- if (!tnl->save.vertex_store) {
- tnl->save.vertex_store = alloc_vertex_store( ctx );
- tnl->save.vbptr = tnl->save.vertex_store->buffer;
- }
-
- _save_reset_vertex( ctx );
- ctx->Driver.SaveNeedFlush = 0;
-}
-
-void _tnl_EndList( GLcontext *ctx )
-{
- (void) ctx;
- assert(TNL_CONTEXT(ctx)->save.vertex_size == 0);
-}
-
-void _tnl_BeginCallList( GLcontext *ctx, struct mesa_display_list *dlist )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->save.replay_flags |= dlist->flags;
- tnl->save.replay_flags |= tnl->LoopbackDListCassettes;
-}
-
-void _tnl_EndCallList( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- if (ctx->ListState.CallDepth == 1)
- tnl->save.replay_flags = 0;
-}
-
-
-static void _tnl_destroy_vertex_list( GLcontext *ctx, void *data )
-{
- struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
- (void) ctx;
-
- if ( --node->vertex_store->refcount == 0 )
- FREE( node->vertex_store );
-
- if ( --node->prim_store->refcount == 0 )
- FREE( node->prim_store );
-
- if ( node->normal_lengths )
- FREE( node->normal_lengths );
-}
-
-
-static void _tnl_print_vertex_list( GLcontext *ctx, void *data )
-{
- struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
- GLuint i;
- (void) ctx;
-
- _mesa_debug(NULL, "TNL-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n",
- node->count,
- node->prim_count,
- node->vertex_size);
-
- for (i = 0 ; i < node->prim_count ; i++) {
- struct tnl_prim *prim = &node->prim[i];
- _mesa_debug(NULL, " prim %d: %s %d..%d %s %s\n",
- i,
- _mesa_lookup_enum_by_nr(prim->mode & PRIM_MODE_MASK),
- prim->start,
- prim->start + prim->count,
- (prim->mode & PRIM_BEGIN) ? "BEGIN" : "(wrap)",
- (prim->mode & PRIM_END) ? "END" : "(wrap)");
- }
-}
-
-
-static void _save_current_init( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i;
-
- for (i = 0; i < _TNL_ATTRIB_MAT_FRONT_AMBIENT; i++) {
- ASSERT(i < VERT_ATTRIB_MAX);
- tnl->save.currentsz[i] = &ctx->ListState.ActiveAttribSize[i];
- tnl->save.current[i] = ctx->ListState.CurrentAttrib[i];
- }
-
- for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) {
- const GLuint j = i - _TNL_ATTRIB_MAT_FRONT_AMBIENT;
- ASSERT(j < MAT_ATTRIB_MAX);
- tnl->save.currentsz[i] = &ctx->ListState.ActiveMaterialSize[j];
- tnl->save.current[i] = ctx->ListState.CurrentMaterial[j];
- }
-
- tnl->save.currentsz[_TNL_ATTRIB_INDEX] = &ctx->ListState.ActiveIndex;
- tnl->save.current[_TNL_ATTRIB_INDEX] = &ctx->ListState.CurrentIndex;
-
- tnl->save.currentsz[_TNL_ATTRIB_EDGEFLAG] = &ctx->ListState.ActiveEdgeFlag;
- tnl->save.current[_TNL_ATTRIB_EDGEFLAG] = &tnl->save.CurrentFloatEdgeFlag;
-}
-
-/**
- * Initialize the display list compiler
- */
-void _tnl_save_init( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_vertex_arrays *tmp = &tnl->save_inputs;
- GLuint i;
-
-
- for (i = 0; i < _TNL_ATTRIB_MAX; i++)
- _mesa_vector4f_init( &tmp->Attribs[i], 0, NULL);
-
- tnl->save.opcode_vertex_list =
- _mesa_alloc_opcode( ctx,
- sizeof(struct tnl_vertex_list),
- _tnl_playback_vertex_list,
- _tnl_destroy_vertex_list,
- _tnl_print_vertex_list );
-
- ctx->Driver.NotifySaveBegin = _save_NotifyBegin;
-
- _save_vtxfmt_init( ctx );
- _save_current_init( ctx );
-
- /* Hook our array functions into the outside-begin-end vtxfmt in
- * ctx->ListState.
- */
- ctx->ListState.ListVtxfmt.Rectf = _save_OBE_Rectf;
- ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays;
- ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements;
- ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements;
- _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
-}
-
-
-/**
- * Deallocate the immediate-mode buffer for the given context, if
- * its reference count goes to zero.
- */
-void _tnl_save_destroy( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /* Decrement the refcounts. References may still be held by
- * display lists yet to be destroyed, so it may not yet be time to
- * free these items.
- */
- if (tnl->save.prim_store &&
- --tnl->save.prim_store->refcount == 0 )
- FREE( tnl->save.prim_store );
-
- if (tnl->save.vertex_store &&
- --tnl->save.vertex_store->refcount == 0 )
- FREE( tnl->save.vertex_store );
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h
deleted file mode 100644
index 8ffb7f573..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* $XFree86$ */
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- *
- */
-
-#ifndef __T_SAVE_API_H__
-#define __T_SAVE_API_H__
-
-#include "t_context.h"
-
-extern GLboolean _tnl_weak_begin( GLcontext *ctx, GLenum mode );
-
-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, struct mesa_display_list *list );
-
-extern void _tnl_SaveFlushVertices( GLcontext *ctx );
-
-extern void _tnl_save_init( GLcontext *ctx );
-extern void _tnl_save_destroy( GLcontext *ctx );
-
-extern void _tnl_loopback_vertex_list( GLcontext *ctx,
- const struct tnl_vertex_list *list );
-
-extern void _tnl_playback_vertex_list( GLcontext *ctx, void *data );
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c
deleted file mode 100644
index 7b2e4a432..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2004 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.
- */
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "enums.h"
-#include "glapi.h"
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "t_context.h"
-#include "t_save_api.h"
-#include "dispatch.h"
-
-/* If someone compiles a display list like:
- * glBegin(Triangles)
- * glVertex()
- * ... lots of vertices ...
- * glEnd()
- *
- * or:
- * glDrawArrays(...)
- *
- * and then tries to execute it like this:
- *
- * glBegin(Lines)
- * glCallList()
- * glEnd()
- *
- * it will wind up in here, as the vertex copying used when wrapping
- * buffers in list compilation (Triangles) won't be right for how the
- * list is being executed (as Lines).
- *
- * This could be avoided by not compiling as vertex_lists until after
- * the first glEnd() has been seen. However, that would miss an
- * important category of display lists, for the sake of a degenerate
- * usage.
- *
- * Further, replaying degenerately-called lists in this fashion is
- * probably still faster than the replay using opcodes.
- */
-
-typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * );
-
-
-/* Wrapper functions in case glVertexAttrib*fvNV doesn't exist */
-static void VertexAttrib1fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib1fvNV(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib2fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib2fvNV(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib3fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib3fvNV(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib4fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib4fvNV(ctx->Exec, (target, v));
-}
-
-static attr_func vert_attrfunc[4] = {
- VertexAttrib1fvNV,
- VertexAttrib2fvNV,
- VertexAttrib3fvNV,
- VertexAttrib4fvNV
-};
-
-
-static void VertexAttrib1fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib1fvARB(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib2fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib2fvARB(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib3fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib3fvARB(ctx->Exec, (target, v));
-}
-
-static void VertexAttrib4fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- CALL_VertexAttrib4fvARB(ctx->Exec, (target, v));
-}
-
-static attr_func vert_attrfunc_arb[4] = {
- VertexAttrib1fvARB,
- VertexAttrib2fvARB,
- VertexAttrib3fvARB,
- VertexAttrib4fvARB
-};
-
-
-
-
-
-
-
-static void mat_attr1fv( GLcontext *ctx, GLint target, const GLfloat *v )
-{
- switch (target) {
- case _TNL_ATTRIB_MAT_FRONT_SHININESS:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SHININESS, v ));
- break;
- case _TNL_ATTRIB_MAT_BACK_SHININESS:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SHININESS, v ));
- break;
- }
-}
-
-
-static void mat_attr3fv( GLcontext *ctx, GLint target, const GLfloat *v )
-{
- switch (target) {
- case _TNL_ATTRIB_MAT_FRONT_INDEXES:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_COLOR_INDEXES, v ));
- break;
- case _TNL_ATTRIB_MAT_BACK_INDEXES:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_COLOR_INDEXES, v ));
- break;
- }
-}
-
-
-static void mat_attr4fv( GLcontext *ctx, GLint target, const GLfloat *v )
-{
- switch (target) {
- case _TNL_ATTRIB_MAT_FRONT_EMISSION:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_EMISSION, v ));
- break;
- case _TNL_ATTRIB_MAT_BACK_EMISSION:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_EMISSION, v ));
- break;
- case _TNL_ATTRIB_MAT_FRONT_AMBIENT:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_AMBIENT, v ));
- break;
- case _TNL_ATTRIB_MAT_BACK_AMBIENT:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_AMBIENT, v ));
- break;
- case _TNL_ATTRIB_MAT_FRONT_DIFFUSE:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_DIFFUSE, v ));
- break;
- case _TNL_ATTRIB_MAT_BACK_DIFFUSE:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_DIFFUSE, v ));
- break;
- case _TNL_ATTRIB_MAT_FRONT_SPECULAR:
- CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SPECULAR, v ));
- break;
- case _TNL_ATTRIB_MAT_BACK_SPECULAR:
- CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SPECULAR, v ));
- break;
- }
-}
-
-
-static attr_func mat_attrfunc[4] = {
- mat_attr1fv,
- NULL,
- mat_attr3fv,
- mat_attr4fv
-};
-
-
-static void index_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- (void) target;
- CALL_Indexf(ctx->Exec, (v[0]));
-}
-
-static void edgeflag_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
-{
- (void) target;
- CALL_EdgeFlag(ctx->Exec, ((GLboolean)(v[0] == 1.0)));
-}
-
-struct loopback_attr {
- GLint target;
- GLint sz;
- attr_func func;
-};
-
-/* Don't emit ends and begins on wrapped primitives. Don't replay
- * wrapped vertices. If we get here, it's probably because the the
- * precalculated wrapping is wrong.
- */
-static void loopback_prim( GLcontext *ctx,
- const struct tnl_vertex_list *list, GLuint i,
- const struct loopback_attr *la, GLuint nr )
-{
- struct tnl_prim *prim = &list->prim[i];
- GLint begin = prim->start;
- GLint end = begin + prim->count;
- GLfloat *data;
- GLint j;
- GLuint k;
-
- if (prim->mode & PRIM_BEGIN) {
- CALL_Begin(GET_DISPATCH(), ( prim->mode & PRIM_MODE_MASK ));
- }
- else {
- assert(i == 0);
- assert(begin == 0);
- begin += list->wrap_count;
- }
-
- data = list->buffer + begin * list->vertex_size;
-
- for (j = begin ; j < end ; j++) {
- GLfloat *tmp = data + la[0].sz;
-
- for (k = 1 ; k < nr ; k++) {
- la[k].func( ctx, la[k].target, tmp );
- tmp += la[k].sz;
- }
-
- /* Fire the vertex
- */
- la[0].func( ctx, VERT_ATTRIB_POS, data );
- data = tmp;
- }
-
- if (prim->mode & PRIM_END) {
- CALL_End(GET_DISPATCH(), ());
- }
- else {
- assert (i == list->prim_count-1);
- }
-}
-
-/* Primitives generated by DrawArrays/DrawElements/Rectf may be
- * caught here. If there is no primitive in progress, execute them
- * normally, otherwise need to track and discard the generated
- * primitives.
- */
-static void loopback_weak_prim( GLcontext *ctx,
- const struct tnl_vertex_list *list, GLuint i,
- const struct loopback_attr *la, GLuint nr )
-{
- if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END)
- loopback_prim( ctx, list, i, la, nr );
- else {
- struct tnl_prim *prim = &list->prim[i];
-
- /* Use the prim_weak flag to ensure that if this primitive
- * wraps, we don't mistake future vertex_lists for part of the
- * surrounding primitive.
- *
- * While this flag is set, we are simply disposing of data
- * generated by an operation now known to be a noop.
- */
- if (prim->mode & PRIM_BEGIN)
- ctx->Driver.CurrentExecPrimitive |= PRIM_WEAK;
- if (prim->mode & PRIM_END)
- ctx->Driver.CurrentExecPrimitive &= ~PRIM_WEAK;
- }
-}
-
-
-
-void _tnl_loopback_vertex_list( GLcontext *ctx,
- const struct tnl_vertex_list *list )
-{
- struct loopback_attr la[_TNL_ATTRIB_MAX];
- GLuint i, nr = 0;
-
- for (i = 0 ; i <= _TNL_ATTRIB_TEX7 ; i++) {
- if (list->attrsz[i]) {
- la[nr].target = i;
- la[nr].sz = list->attrsz[i];
- la[nr].func = vert_attrfunc[list->attrsz[i]-1];
- nr++;
- }
- }
-
- for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ;
- i <= _TNL_ATTRIB_MAT_BACK_INDEXES ;
- i++) {
- if (list->attrsz[i]) {
- la[nr].target = i;
- la[nr].sz = list->attrsz[i];
- la[nr].func = mat_attrfunc[list->attrsz[i]-1];
- nr++;
- }
- }
-
- if (list->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- la[nr].target = _TNL_ATTRIB_EDGEFLAG;
- la[nr].sz = list->attrsz[_TNL_ATTRIB_EDGEFLAG];
- la[nr].func = edgeflag_attr1fv;
- nr++;
- }
-
- if (list->attrsz[_TNL_ATTRIB_INDEX]) {
- la[nr].target = _TNL_ATTRIB_INDEX;
- la[nr].sz = list->attrsz[_TNL_ATTRIB_INDEX];
- la[nr].func = index_attr1fv;
- nr++;
- }
-
- /* XXX ARB vertex attribs */
-
- for (i = 0 ; i < list->prim_count ; i++) {
- if (list->prim[i].mode & PRIM_WEAK)
- loopback_weak_prim( ctx, list, i, la, nr );
- else
- loopback_prim( ctx, list, i, la, nr );
- }
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c
deleted file mode 100644
index 995964c96..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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.
- */
-
-/* Author:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "light.h"
-#include "state.h"
-#include "t_pipeline.h"
-#include "t_save_api.h"
-#include "t_vtx_api.h"
-
-static INLINE GLint get_size( const GLfloat *f )
-{
- if (f[3] != 1.0) return 4;
- if (f[2] != 0.0) return 3;
- return 2;
-}
-
-
-/* Some nasty stuff still hanging on here.
- *
- * TODO - remove VB->ColorPtr, etc and just use the AttrPtr's.
- */
-static void _tnl_bind_vertex_list( GLcontext *ctx,
- const struct tnl_vertex_list *node )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- struct tnl_vertex_arrays *tmp = &tnl->save_inputs;
- GLfloat *data = node->buffer;
- GLuint attr, i;
-
- /* Setup constant data in the VB.
- */
- VB->Count = node->count;
- VB->Primitive = node->prim;
- VB->PrimitiveCount = node->prim_count;
- VB->Elts = NULL;
- VB->NormalLengthPtr = node->normal_lengths;
-
- for (attr = 0; attr <= _TNL_ATTRIB_INDEX; attr++) {
- if (node->attrsz[attr]) {
- tmp->Attribs[attr].count = node->count;
- tmp->Attribs[attr].data = (GLfloat (*)[4]) data;
- tmp->Attribs[attr].start = data;
- tmp->Attribs[attr].size = node->attrsz[attr];
- tmp->Attribs[attr].stride = node->vertex_size * sizeof(GLfloat);
- VB->AttribPtr[attr] = &tmp->Attribs[attr];
- data += node->attrsz[attr];
- }
- else {
- tmp->Attribs[attr].count = 1;
- tmp->Attribs[attr].data = (GLfloat (*)[4]) tnl->vtx.current[attr];
- tmp->Attribs[attr].start = tnl->vtx.current[attr];
- tmp->Attribs[attr].size = get_size( tnl->vtx.current[attr] );
- tmp->Attribs[attr].stride = 0;
- VB->AttribPtr[attr] = &tmp->Attribs[attr];
- }
- }
-
-
- /* Copy edgeflag to a contiguous array
- */
- if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) {
- if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data,
- node->count,
- node->vertex_size );
- data++;
- }
- else
- VB->EdgeFlag = _tnl_import_current_edgeflag( ctx, node->count );
- }
-
- /* Legacy pointers -- remove one day.
- */
- VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
- VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
- VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
- VB->ColorPtr[1] = NULL;
- VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX];
- VB->IndexPtr[1] = NULL;
- VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
- VB->SecondaryColorPtr[1] = NULL;
- VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
-
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
- }
-}
-
-static void _playback_copy_to_current( GLcontext *ctx,
- const struct tnl_vertex_list *node )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- const GLfloat *data;
- GLuint i;
-
- if (node->count)
- data = node->buffer + (node->count-1) * node->vertex_size;
- else
- data = node->buffer;
-
- for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++) {
- if (node->attrsz[i]) {
- COPY_CLEAN_4V(tnl->vtx.current[i], node->attrsz[i], data);
- data += node->attrsz[i];
- }
- }
-
- /* Edgeflag requires special treatment:
- */
- if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- ctx->Current.EdgeFlag = (data[0] == 1.0);
- }
-
- /* Colormaterial -- this kindof sucks.
- */
- if (ctx->Light.ColorMaterialEnabled) {
- _mesa_update_color_material(ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
- }
-
- if (node->have_materials) {
- tnl->Driver.NotifyMaterialChange( ctx );
- }
-
- /* CurrentExecPrimitive
- */
- if (node->prim_count) {
- GLenum mode = node->prim[node->prim_count - 1].mode;
- if (mode & PRIM_END)
- ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
- else
- ctx->Driver.CurrentExecPrimitive = (mode & PRIM_MODE_MASK);
- }
-}
-
-
-/**
- * Execute the buffer and save copied verts.
- */
-void _tnl_playback_vertex_list( GLcontext *ctx, void *data )
-{
- const struct tnl_vertex_list *node = (const struct tnl_vertex_list *) data;
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- FLUSH_CURRENT(ctx, 0);
-
- if (node->prim_count > 0 && node->count > 0) {
-
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END &&
- (node->prim[0].mode & PRIM_BEGIN)) {
-
- /* Degenerate case: list is called inside begin/end pair and
- * includes operations such as glBegin or glDrawArrays.
- */
- _mesa_error( ctx, GL_INVALID_OPERATION, "displaylist recursive begin");
- _tnl_loopback_vertex_list( ctx, node );
- return;
- }
- else if (tnl->save.replay_flags) {
- /* Various degnerate cases: translate into immediate mode
- * calls rather than trying to execute in place.
- */
- _tnl_loopback_vertex_list( ctx, node );
- return;
- }
-
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
- if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
- (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBegin (invalid vertex/fragment program)");
- return;
- }
-
- _tnl_bind_vertex_list( ctx, node );
-
- tnl->Driver.RunPipeline( ctx );
- }
-
- /* Copy to current?
- */
- _playback_copy_to_current( ctx, node );
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c
deleted file mode 100644
index 0b76bd008..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c
+++ /dev/null
@@ -1,1496 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.4.1
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * 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 t_arb_program.c
- * Compile vertex programs to an intermediate representation.
- * Execute vertex programs over a buffer of vertices.
- * \author Keith Whitwell, Brian Paul
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "arbprogparse.h"
-#include "light.h"
-#include "program.h"
-#include "math/m_matrix.h"
-#include "math/m_translate.h"
-#include "t_context.h"
-#include "t_pipeline.h"
-#include "t_vb_arbprogram.h"
-#include "tnl.h"
-
-
-#define DISASSEM 0
-
-/*--------------------------------------------------------------------------- */
-
-struct opcode_info {
- GLuint nr_args;
- const char *string;
- void (*print)( union instruction , const struct opcode_info * );
-};
-
-struct compilation {
- GLuint reg_active;
- union instruction *csr;
-};
-
-
-#define ARB_VP_MACHINE(stage) ((struct arb_vp_machine *)(stage->privatePtr))
-
-#define PUFF(x) ((x)[1] = (x)[2] = (x)[3] = (x)[0])
-
-
-
-/* Lower precision functions for the EXP, LOG and LIT opcodes. The
- * LOG2() implementation is probably not accurate enough, and the
- * attempted optimization for Exp2 is definitely not accurate
- * enough - it discards all of t's fractional bits!
- */
-static GLfloat RoughApproxLog2(GLfloat t)
-{
- return LOG2(t);
-}
-
-static GLfloat RoughApproxExp2(GLfloat t)
-{
-#if 0
- fi_type fi;
- fi.i = (GLint) t;
- fi.i = (fi.i << 23) + 0x3f800000;
- return fi.f;
-#else
- return (GLfloat) _mesa_pow(2.0, t);
-#endif
-}
-
-static GLfloat RoughApproxPower(GLfloat x, GLfloat y)
-{
- if (x == 0.0 && y == 0.0)
- return 1.0; /* spec requires this */
- else
- return RoughApproxExp2(y * RoughApproxLog2(x));
-}
-
-
-/* Higher precision functions for the EX2, LG2 and POW opcodes:
- */
-static GLfloat ApproxLog2(GLfloat t)
-{
- return (GLfloat) (log(t) * 1.442695F);
-}
-
-static GLfloat ApproxExp2(GLfloat t)
-{
- return (GLfloat) _mesa_pow(2.0, t);
-}
-
-static GLfloat ApproxPower(GLfloat x, GLfloat y)
-{
- return (GLfloat) _mesa_pow(x, y);
-}
-
-static GLfloat rough_approx_log2_0_1(GLfloat x)
-{
- return LOG2(x);
-}
-
-
-
-
-/**
- * Perform a reduced swizzle:
- */
-static void do_RSW( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.rsw.dst];
- const GLfloat *arg0 = m->File[op.rsw.file0][op.rsw.idx0];
- GLuint swz = op.rsw.swz;
- GLuint neg = op.rsw.neg;
- GLfloat tmp[4];
-
- /* Need a temporary to be correct in the case where result == arg0.
- */
- COPY_4V(tmp, arg0);
-
- result[0] = tmp[GET_RSW(swz, 0)];
- result[1] = tmp[GET_RSW(swz, 1)];
- result[2] = tmp[GET_RSW(swz, 2)];
- result[3] = tmp[GET_RSW(swz, 3)];
-
- if (neg) {
- if (neg & 0x1) result[0] = -result[0];
- if (neg & 0x2) result[1] = -result[1];
- if (neg & 0x4) result[2] = -result[2];
- if (neg & 0x8) result[3] = -result[3];
- }
-}
-
-/* Used to implement write masking. To make things easier for the sse
- * generator I've gone back to a 1 argument version of this function
- * (dst.msk = arg), rather than the semantically cleaner (dst = SEL
- * arg0, arg1, msk)
- *
- * That means this is the only instruction which doesn't write a full
- * 4 dwords out. This would make such a program harder to analyse,
- * but it looks like analysis is going to take place on a higher level
- * anyway.
- */
-static void do_MSK( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *dst = m->File[0][op.msk.dst];
- const GLfloat *arg = m->File[op.msk.file][op.msk.idx];
-
- if (op.msk.mask & 0x1) dst[0] = arg[0];
- if (op.msk.mask & 0x2) dst[1] = arg[1];
- if (op.msk.mask & 0x4) dst[2] = arg[2];
- if (op.msk.mask & 0x8) dst[3] = arg[3];
-}
-
-
-static void do_PRT( struct arb_vp_machine *m, union instruction op )
-{
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- _mesa_printf("%d: %f %f %f %f\n", m->vtx_nr,
- arg0[0], arg0[1], arg0[2], arg0[3]);
-}
-
-
-/**
- * The traditional ALU and texturing instructions. All operate on
- * internal registers and ignore write masks and swizzling issues.
- */
-
-static void do_ABS( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = (arg0[0] < 0.0) ? -arg0[0] : arg0[0];
- result[1] = (arg0[1] < 0.0) ? -arg0[1] : arg0[1];
- result[2] = (arg0[2] < 0.0) ? -arg0[2] : arg0[2];
- result[3] = (arg0[3] < 0.0) ? -arg0[3] : arg0[3];
-}
-
-static void do_ADD( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = arg0[0] + arg1[0];
- result[1] = arg0[1] + arg1[1];
- result[2] = arg0[2] + arg1[2];
- result[3] = arg0[3] + arg1[3];
-}
-
-
-static void do_DP3( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] * arg1[0] +
- arg0[1] * arg1[1] +
- arg0[2] * arg1[2]);
-
- PUFF(result);
-}
-
-
-
-static void do_DP4( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] * arg1[0] +
- arg0[1] * arg1[1] +
- arg0[2] * arg1[2] +
- arg0[3] * arg1[3]);
-
- PUFF(result);
-}
-
-static void do_DPH( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] * arg1[0] +
- arg0[1] * arg1[1] +
- arg0[2] * arg1[2] +
- 1.0 * arg1[3]);
-
- PUFF(result);
-}
-
-static void do_DST( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- /* This should be ok even if result == arg0 or result == arg1.
- */
- result[0] = 1.0F;
- result[1] = arg0[1] * arg1[1];
- result[2] = arg0[2];
- result[3] = arg1[3];
-}
-
-
-/* Intended to be high precision:
- */
-static void do_EX2( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = (GLfloat)ApproxExp2(arg0[0]);
- PUFF(result);
-}
-
-
-/* Allowed to be lower precision:
- */
-static void do_EXP( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- GLfloat tmp = arg0[0];
- GLfloat flr_tmp = FLOORF(tmp);
- GLfloat frac_tmp = tmp - flr_tmp;
-
- result[0] = LDEXPF(1.0, (int)flr_tmp);
- result[1] = frac_tmp;
- result[2] = LDEXPF(rough_approx_log2_0_1(frac_tmp), (int)flr_tmp);
- result[3] = 1.0F;
-}
-
-static void do_FLR( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = FLOORF(arg0[0]);
- result[1] = FLOORF(arg0[1]);
- result[2] = FLOORF(arg0[2]);
- result[3] = FLOORF(arg0[3]);
-}
-
-static void do_FRC( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = arg0[0] - FLOORF(arg0[0]);
- result[1] = arg0[1] - FLOORF(arg0[1]);
- result[2] = arg0[2] - FLOORF(arg0[2]);
- result[3] = arg0[3] - FLOORF(arg0[3]);
-}
-
-/* High precision log base 2:
- */
-static void do_LG2( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = ApproxLog2(arg0[0]);
- PUFF(result);
-}
-
-
-
-static void do_LIT( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- GLfloat tmp[4];
-
- tmp[0] = 1.0;
- tmp[1] = arg0[0];
- if (arg0[0] > 0.0) {
- tmp[2] = RoughApproxPower(arg0[1], arg0[3]);
- }
- else {
- tmp[2] = 0.0;
- }
- tmp[3] = 1.0;
-
-
- COPY_4V(result, tmp);
-}
-
-
-/* Intended to allow a lower precision than required for LG2 above.
- */
-static void do_LOG( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- GLfloat tmp = FABSF(arg0[0]);
- int exponent;
- GLfloat mantissa = FREXPF(tmp, &exponent);
-
- result[0] = (GLfloat) (exponent - 1);
- result[1] = 2.0 * mantissa; /* map [.5, 1) -> [1, 2) */
- result[2] = exponent + LOG2(mantissa);
- result[3] = 1.0;
-}
-
-static void do_MAX( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] > arg1[0]) ? arg0[0] : arg1[0];
- result[1] = (arg0[1] > arg1[1]) ? arg0[1] : arg1[1];
- result[2] = (arg0[2] > arg1[2]) ? arg0[2] : arg1[2];
- result[3] = (arg0[3] > arg1[3]) ? arg0[3] : arg1[3];
-}
-
-
-static void do_MIN( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] < arg1[0]) ? arg0[0] : arg1[0];
- result[1] = (arg0[1] < arg1[1]) ? arg0[1] : arg1[1];
- result[2] = (arg0[2] < arg1[2]) ? arg0[2] : arg1[2];
- result[3] = (arg0[3] < arg1[3]) ? arg0[3] : arg1[3];
-}
-
-static void do_MOV( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = arg0[0];
- result[1] = arg0[1];
- result[2] = arg0[2];
- result[3] = arg0[3];
-}
-
-static void do_MUL( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = arg0[0] * arg1[0];
- result[1] = arg0[1] * arg1[1];
- result[2] = arg0[2] * arg1[2];
- result[3] = arg0[3] * arg1[3];
-}
-
-
-/* Intended to be "high" precision
- */
-static void do_POW( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (GLfloat)ApproxPower(arg0[0], arg1[0]);
- PUFF(result);
-}
-
-static void do_REL( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- GLuint idx = (op.alu.idx0 + (GLint)m->File[0][REG_ADDR][0]) & (MAX_NV_VERTEX_PROGRAM_PARAMS-1);
- const GLfloat *arg0 = m->File[op.alu.file0][idx];
-
- result[0] = arg0[0];
- result[1] = arg0[1];
- result[2] = arg0[2];
- result[3] = arg0[3];
-}
-
-static void do_RCP( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = 1.0F / arg0[0];
- PUFF(result);
-}
-
-static void do_RSQ( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
-
- result[0] = INV_SQRTF(FABSF(arg0[0]));
- PUFF(result);
-}
-
-
-static void do_SGE( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] >= arg1[0]) ? 1.0F : 0.0F;
- result[1] = (arg0[1] >= arg1[1]) ? 1.0F : 0.0F;
- result[2] = (arg0[2] >= arg1[2]) ? 1.0F : 0.0F;
- result[3] = (arg0[3] >= arg1[3]) ? 1.0F : 0.0F;
-}
-
-
-static void do_SLT( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = (arg0[0] < arg1[0]) ? 1.0F : 0.0F;
- result[1] = (arg0[1] < arg1[1]) ? 1.0F : 0.0F;
- result[2] = (arg0[2] < arg1[2]) ? 1.0F : 0.0F;
- result[3] = (arg0[3] < arg1[3]) ? 1.0F : 0.0F;
-}
-
-static void do_SUB( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
-
- result[0] = arg0[0] - arg1[0];
- result[1] = arg0[1] - arg1[1];
- result[2] = arg0[2] - arg1[2];
- result[3] = arg0[3] - arg1[3];
-}
-
-
-static void do_XPD( struct arb_vp_machine *m, union instruction op )
-{
- GLfloat *result = m->File[0][op.alu.dst];
- const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
- const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
- GLfloat tmp[3];
-
- tmp[0] = arg0[1] * arg1[2] - arg0[2] * arg1[1];
- tmp[1] = arg0[2] * arg1[0] - arg0[0] * arg1[2];
- tmp[2] = arg0[0] * arg1[1] - arg0[1] * arg1[0];
-
- /* Need a temporary to be correct in the case where result == arg0
- * or result == arg1.
- */
- result[0] = tmp[0];
- result[1] = tmp[1];
- result[2] = tmp[2];
-}
-
-static void do_NOP( struct arb_vp_machine *m, union instruction op )
-{
-}
-
-/* Some useful debugging functions:
- */
-static void print_mask( GLuint mask )
-{
- _mesa_printf(".");
- if (mask&0x1) _mesa_printf("x");
- if (mask&0x2) _mesa_printf("y");
- if (mask&0x4) _mesa_printf("z");
- if (mask&0x8) _mesa_printf("w");
-}
-
-static void print_reg( GLuint file, GLuint reg )
-{
- static const char *reg_file[] = {
- "REG",
- "LOCAL_PARAM",
- "ENV_PARAM",
- "STATE_VAR",
- };
-
- if (file == 0) {
- if (reg == REG_RES)
- _mesa_printf("RES");
- else if (reg >= REG_ARG0 && reg <= REG_ARG1)
- _mesa_printf("ARG%d", reg - REG_ARG0);
- else if (reg >= REG_TMP0 && reg <= REG_TMP11)
- _mesa_printf("TMP%d", reg - REG_TMP0);
- else if (reg >= REG_IN0 && reg <= REG_IN31)
- _mesa_printf("IN%d", reg - REG_IN0);
- else if (reg >= REG_OUT0 && reg <= REG_OUT14)
- _mesa_printf("OUT%d", reg - REG_OUT0);
- else if (reg == REG_ADDR)
- _mesa_printf("ADDR");
- else if (reg == REG_ID)
- _mesa_printf("ID");
- else
- _mesa_printf("REG%d", reg);
- }
- else
- _mesa_printf("%s:%d", reg_file[file], reg);
-}
-
-
-static void print_RSW( union instruction op, const struct opcode_info *info )
-{
- GLuint swz = op.rsw.swz;
- GLuint neg = op.rsw.neg;
- GLuint i;
-
- _mesa_printf("%s ", info->string);
- print_reg(0, op.rsw.dst);
- _mesa_printf(", ");
- print_reg(op.rsw.file0, op.rsw.idx0);
- _mesa_printf(".");
- for (i = 0; i < 4; i++, swz >>= 2) {
- const char *cswz = "xyzw";
- if (neg & (1<<i))
- _mesa_printf("-");
- _mesa_printf("%c", cswz[swz&0x3]);
- }
- _mesa_printf("\n");
-}
-
-
-static void print_ALU( union instruction op, const struct opcode_info *info )
-{
- _mesa_printf("%s ", info->string);
- print_reg(0, op.alu.dst);
- _mesa_printf(", ");
- print_reg(op.alu.file0, op.alu.idx0);
- if (info->nr_args > 1) {
- _mesa_printf(", ");
- print_reg(op.alu.file1, op.alu.idx1);
- }
- _mesa_printf("\n");
-}
-
-static void print_MSK( union instruction op, const struct opcode_info *info )
-{
- _mesa_printf("%s ", info->string);
- print_reg(0, op.msk.dst);
- print_mask(op.msk.mask);
- _mesa_printf(", ");
- print_reg(op.msk.file, op.msk.idx);
- _mesa_printf("\n");
-}
-
-
-static void print_NOP( union instruction op, const struct opcode_info *info )
-{
-}
-
-#define NOP 0
-#define ALU 1
-#define SWZ 2
-
-static const struct opcode_info opcode_info[] =
-{
- { 1, "ABS", print_ALU },
- { 2, "ADD", print_ALU },
- { 1, "ARL", print_NOP },
- { 2, "DP3", print_ALU },
- { 2, "DP4", print_ALU },
- { 2, "DPH", print_ALU },
- { 2, "DST", print_ALU },
- { 0, "END", print_NOP },
- { 1, "EX2", print_ALU },
- { 1, "EXP", print_ALU },
- { 1, "FLR", print_ALU },
- { 1, "FRC", print_ALU },
- { 1, "LG2", print_ALU },
- { 1, "LIT", print_ALU },
- { 1, "LOG", print_ALU },
- { 3, "MAD", print_NOP },
- { 2, "MAX", print_ALU },
- { 2, "MIN", print_ALU },
- { 1, "MOV", print_ALU },
- { 2, "MUL", print_ALU },
- { 2, "POW", print_ALU },
- { 1, "PRT", print_ALU }, /* PRINT */
- { 1, "RCC", print_NOP },
- { 1, "RCP", print_ALU },
- { 1, "RSQ", print_ALU },
- { 2, "SGE", print_ALU },
- { 2, "SLT", print_ALU },
- { 2, "SUB", print_ALU },
- { 1, "SWZ", print_NOP },
- { 2, "XPD", print_ALU },
- { 1, "RSW", print_RSW },
- { 2, "MSK", print_MSK },
- { 1, "REL", print_ALU },
-};
-
-void _tnl_disassem_vba_insn( union instruction op )
-{
- const struct opcode_info *info = &opcode_info[op.alu.opcode];
- info->print( op, info );
-}
-
-
-static void (* const opcode_func[])(struct arb_vp_machine *, union instruction) =
-{
- do_ABS,
- do_ADD,
- do_NOP,
- do_DP3,
- do_DP4,
- do_DPH,
- do_DST,
- do_NOP,
- do_EX2,
- do_EXP,
- do_FLR,
- do_FRC,
- do_LG2,
- do_LIT,
- do_LOG,
- do_NOP,
- do_MAX,
- do_MIN,
- do_MOV,
- do_MUL,
- do_POW,
- do_PRT,
- do_NOP,
- do_RCP,
- do_RSQ,
- do_SGE,
- do_SLT,
- do_SUB,
- do_RSW,
- do_XPD,
- do_RSW,
- do_MSK,
- do_REL,
-};
-
-static union instruction *cvp_next_instruction( struct compilation *cp )
-{
- union instruction *op = cp->csr++;
- op->dword = 0;
- return op;
-}
-
-static struct reg cvp_make_reg( GLuint file, GLuint idx )
-{
- struct reg reg;
- reg.file = file;
- reg.idx = idx;
- return reg;
-}
-
-static struct reg cvp_emit_rel( struct compilation *cp,
- struct reg reg,
- struct reg tmpreg )
-{
- union instruction *op = cvp_next_instruction(cp);
- op->alu.opcode = REL;
- op->alu.file0 = reg.file;
- op->alu.idx0 = reg.idx;
- op->alu.dst = tmpreg.idx;
- return tmpreg;
-}
-
-
-static struct reg cvp_load_reg( struct compilation *cp,
- GLuint file,
- GLuint index,
- GLuint rel,
- GLuint tmpidx )
-{
- struct reg tmpreg = cvp_make_reg(FILE_REG, tmpidx);
- struct reg reg;
-
- switch (file) {
- case PROGRAM_TEMPORARY:
- return cvp_make_reg(FILE_REG, REG_TMP0 + index);
-
- case PROGRAM_INPUT:
- return cvp_make_reg(FILE_REG, REG_IN0 + index);
-
- case PROGRAM_OUTPUT:
- return cvp_make_reg(FILE_REG, REG_OUT0 + index);
-
- /* These two aren't populated by the parser?
- */
- case PROGRAM_LOCAL_PARAM:
- reg = cvp_make_reg(FILE_LOCAL_PARAM, index);
- if (rel)
- return cvp_emit_rel(cp, reg, tmpreg);
- else
- return reg;
-
- case PROGRAM_ENV_PARAM:
- reg = cvp_make_reg(FILE_ENV_PARAM, index);
- if (rel)
- return cvp_emit_rel(cp, reg, tmpreg);
- else
- return reg;
-
- case PROGRAM_STATE_VAR:
- reg = cvp_make_reg(FILE_STATE_PARAM, index);
- if (rel)
- return cvp_emit_rel(cp, reg, tmpreg);
- else
- return reg;
-
- /* Invalid values:
- */
- case PROGRAM_WRITE_ONLY:
- case PROGRAM_ADDRESS:
- default:
- assert(0);
- return tmpreg; /* can't happen */
- }
-}
-
-static struct reg cvp_emit_arg( struct compilation *cp,
- const struct vp_src_register *src,
- GLuint arg )
-{
- struct reg reg = cvp_load_reg( cp, src->File, src->Index, src->RelAddr, arg );
- union instruction rsw, noop;
-
- /* Emit any necessary swizzling.
- */
- rsw.dword = 0;
- rsw.rsw.neg = src->Negate ? WRITEMASK_XYZW : 0;
- rsw.rsw.swz = ((GET_SWZ(src->Swizzle, 0) << 0) |
- (GET_SWZ(src->Swizzle, 1) << 2) |
- (GET_SWZ(src->Swizzle, 2) << 4) |
- (GET_SWZ(src->Swizzle, 3) << 6));
-
- noop.dword = 0;
- noop.rsw.neg = 0;
- noop.rsw.swz = RSW_NOOP;
-
- if (rsw.dword != noop.dword) {
- union instruction *op = cvp_next_instruction(cp);
- struct reg rsw_reg = cvp_make_reg(FILE_REG, REG_ARG0 + arg);
- op->dword = rsw.dword;
- op->rsw.opcode = RSW;
- op->rsw.file0 = reg.file;
- op->rsw.idx0 = reg.idx;
- op->rsw.dst = rsw_reg.idx;
- return rsw_reg;
- }
- else
- return reg;
-}
-
-static GLuint cvp_choose_result( struct compilation *cp,
- const struct vp_dst_register *dst,
- union instruction *fixup )
-{
- GLuint mask = dst->WriteMask;
- GLuint idx;
-
- switch (dst->File) {
- case PROGRAM_TEMPORARY:
- idx = REG_TMP0 + dst->Index;
- break;
- case PROGRAM_OUTPUT:
- idx = REG_OUT0 + dst->Index;
- break;
- default:
- assert(0);
- return REG_RES; /* can't happen */
- }
-
- /* Optimization: When writing (with a writemask) to an undefined
- * value for the first time, the writemask may be ignored.
- */
- if (mask != WRITEMASK_XYZW && (cp->reg_active & (1 << idx))) {
- fixup->msk.opcode = MSK;
- fixup->msk.dst = idx;
- fixup->msk.file = FILE_REG;
- fixup->msk.idx = REG_RES;
- fixup->msk.mask = mask;
- cp->reg_active |= 1 << idx;
- return REG_RES;
- }
- else {
- fixup->dword = 0;
- cp->reg_active |= 1 << idx;
- return idx;
- }
-}
-
-static struct reg cvp_emit_rsw( struct compilation *cp,
- GLuint dst,
- struct reg src,
- GLuint neg,
- GLuint swz,
- GLboolean force)
-{
- struct reg retval;
-
- if (swz != RSW_NOOP || neg != 0) {
- union instruction *op = cvp_next_instruction(cp);
- op->rsw.opcode = RSW;
- op->rsw.dst = dst;
- op->rsw.file0 = src.file;
- op->rsw.idx0 = src.idx;
- op->rsw.neg = neg;
- op->rsw.swz = swz;
-
- retval.file = FILE_REG;
- retval.idx = dst;
- return retval;
- }
- else if (force) {
- /* Oops. Degenerate case:
- */
- union instruction *op = cvp_next_instruction(cp);
- op->alu.opcode = VP_OPCODE_MOV;
- op->alu.dst = dst;
- op->alu.file0 = src.file;
- op->alu.idx0 = src.idx;
-
- retval.file = FILE_REG;
- retval.idx = dst;
- return retval;
- }
- else {
- return src;
- }
-}
-
-
-static void cvp_emit_inst( struct compilation *cp,
- const struct vp_instruction *inst )
-{
- const struct opcode_info *info = &opcode_info[inst->Opcode];
- union instruction *op;
- union instruction fixup;
- struct reg reg[3];
- GLuint result, i;
-
- assert(sizeof(*op) == sizeof(GLuint));
-
- /* Need to handle SWZ, ARL specially.
- */
- switch (inst->Opcode) {
- /* Split into mul and add:
- */
- case VP_OPCODE_MAD:
- result = cvp_choose_result( cp, &inst->DstReg, &fixup );
- for (i = 0; i < 3; i++)
- reg[i] = cvp_emit_arg( cp, &inst->SrcReg[i], REG_ARG0+i );
-
- op = cvp_next_instruction(cp);
- op->alu.opcode = VP_OPCODE_MUL;
- op->alu.file0 = reg[0].file;
- op->alu.idx0 = reg[0].idx;
- op->alu.file1 = reg[1].file;
- op->alu.idx1 = reg[1].idx;
- op->alu.dst = REG_ARG0;
-
- op = cvp_next_instruction(cp);
- op->alu.opcode = VP_OPCODE_ADD;
- op->alu.file0 = FILE_REG;
- op->alu.idx0 = REG_ARG0;
- op->alu.file1 = reg[2].file;
- op->alu.idx1 = reg[2].idx;
- op->alu.dst = result;
-
- if (result == REG_RES) {
- op = cvp_next_instruction(cp);
- op->dword = fixup.dword;
- }
- break;
-
- case VP_OPCODE_ARL:
- reg[0] = cvp_emit_arg( cp, &inst->SrcReg[0], REG_ARG0 );
-
- op = cvp_next_instruction(cp);
- op->alu.opcode = VP_OPCODE_FLR;
- op->alu.dst = REG_ADDR;
- op->alu.file0 = reg[0].file;
- op->alu.idx0 = reg[0].idx;
- break;
-
- case VP_OPCODE_SWZ: {
- GLuint swz0 = 0, swz1 = 0;
- GLuint neg0 = 0, neg1 = 0;
- GLuint mask = 0;
-
- /* Translate 3-bit-per-element swizzle into two 2-bit swizzles,
- * one from the source register the other from a constant
- * {0,0,0,1}.
- */
- for (i = 0; i < 4; i++) {
- GLuint swzelt = GET_SWZ(inst->SrcReg[0].Swizzle, i);
- if (swzelt >= SWIZZLE_ZERO) {
- neg0 |= inst->SrcReg[0].Negate & (1<<i);
- if (swzelt == SWIZZLE_ONE)
- swz0 |= SWIZZLE_W << (i*2);
- else if (i < SWIZZLE_W)
- swz0 |= i << (i*2);
- }
- else {
- mask |= 1<<i;
- neg1 |= inst->SrcReg[0].Negate & (1<<i);
- swz1 |= swzelt << (i*2);
- }
- }
-
- result = cvp_choose_result( cp, &inst->DstReg, &fixup );
- reg[0].file = FILE_REG;
- reg[0].idx = REG_ID;
- reg[1] = cvp_emit_arg( cp, &inst->SrcReg[0], REG_ARG0 );
-
- if (mask == WRITEMASK_XYZW) {
- cvp_emit_rsw(cp, result, reg[0], neg0, swz0, GL_TRUE);
-
- }
- else if (mask == 0) {
- cvp_emit_rsw(cp, result, reg[1], neg1, swz1, GL_TRUE);
- }
- else {
- cvp_emit_rsw(cp, result, reg[0], neg0, swz0, GL_TRUE);
- reg[1] = cvp_emit_rsw(cp, REG_ARG0, reg[1], neg1, swz1, GL_FALSE);
-
- op = cvp_next_instruction(cp);
- op->msk.opcode = MSK;
- op->msk.dst = result;
- op->msk.file = reg[1].file;
- op->msk.idx = reg[1].idx;
- op->msk.mask = mask;
- }
-
- if (result == REG_RES) {
- op = cvp_next_instruction(cp);
- op->dword = fixup.dword;
- }
- break;
- }
-
- case VP_OPCODE_END:
- break;
-
- default:
- result = cvp_choose_result( cp, &inst->DstReg, &fixup );
- for (i = 0; i < info->nr_args; i++)
- reg[i] = cvp_emit_arg( cp, &inst->SrcReg[i], REG_ARG0 + i );
-
- op = cvp_next_instruction(cp);
- op->alu.opcode = inst->Opcode;
- op->alu.file0 = reg[0].file;
- op->alu.idx0 = reg[0].idx;
- op->alu.file1 = reg[1].file;
- op->alu.idx1 = reg[1].idx;
- op->alu.dst = result;
-
- if (result == REG_RES) {
- op = cvp_next_instruction(cp);
- op->dword = fixup.dword;
- }
- break;
- }
-}
-
-static void free_tnl_data( struct vertex_program *program )
-{
- struct tnl_compiled_program *p = program->TnlData;
- if (p->compiled_func)
- _mesa_free((void *)p->compiled_func);
- _mesa_free(p);
- program->TnlData = NULL;
-}
-
-static void compile_vertex_program( struct vertex_program *program,
- GLboolean try_codegen )
-{
- struct compilation cp;
- struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program);
- GLuint i;
-
- if (program->TnlData)
- free_tnl_data( program );
-
- program->TnlData = p;
-
- /* Initialize cp. Note that ctx and VB aren't used in compilation
- * so we don't have to worry about statechanges:
- */
- _mesa_memset(&cp, 0, sizeof(cp));
- cp.csr = p->instructions;
-
- /* Compile instructions:
- */
- for (i = 0; i < program->Base.NumInstructions; i++) {
- cvp_emit_inst(&cp, &program->Instructions[i]);
- }
-
- /* Finish up:
- */
- p->nr_instructions = cp.csr - p->instructions;
-
- /* Print/disassemble:
- */
- if (DISASSEM) {
- for (i = 0; i < p->nr_instructions; i++) {
- _tnl_disassem_vba_insn(p->instructions[i]);
- }
- _mesa_printf("\n\n");
- }
-
-#ifdef USE_SSE_ASM
- if (try_codegen)
- _tnl_sse_codegen_vertex_program(p);
-#endif
-
-}
-
-
-
-
-/* ----------------------------------------------------------------------
- * Execution
- */
-static void userclip( GLcontext *ctx,
- GLvector4f *clip,
- GLubyte *clipmask,
- GLubyte *clipormask,
- GLubyte *clipandmask )
-{
- GLuint p;
-
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- GLuint nr, i;
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- GLfloat *coord = (GLfloat *)clip->data;
- GLuint stride = clip->stride;
- GLuint count = clip->count;
-
- for (nr = 0, i = 0 ; i < count ; i++) {
- GLfloat dp = (coord[0] * a +
- coord[1] * b +
- coord[2] * c +
- coord[3] * d);
-
- if (dp < 0) {
- nr++;
- clipmask[i] |= CLIP_USER_BIT;
- }
-
- STRIDE_F(coord, stride);
- }
-
- if (nr > 0) {
- *clipormask |= CLIP_USER_BIT;
- if (nr == count) {
- *clipandmask |= CLIP_USER_BIT;
- return;
- }
- }
- }
- }
-}
-
-
-static GLboolean do_ndc_cliptest( struct arb_vp_machine *m )
-{
- GLcontext *ctx = m->ctx;
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = m->VB;
-
- /* Cliptest and perspective divide. Clip functions must clear
- * the clipmask.
- */
- m->ormask = 0;
- m->andmask = CLIP_ALL_BITS;
-
- if (tnl->NeedNdcCoords) {
- VB->NdcPtr =
- _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &m->ndcCoords,
- m->clipmask,
- &m->ormask,
- &m->andmask );
- }
- else {
- VB->NdcPtr = NULL;
- _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
- NULL,
- m->clipmask,
- &m->ormask,
- &m->andmask );
- }
-
- if (m->andmask) {
- /* All vertices are outside the frustum */
- return GL_FALSE;
- }
-
- /* Test userclip planes. This contributes to VB->ClipMask.
- */
- if (ctx->Transform.ClipPlanesEnabled && !ctx->VertexProgram._Enabled) {
- userclip( ctx,
- VB->ClipPtr,
- m->clipmask,
- &m->ormask,
- &m->andmask );
-
- if (m->andmask) {
- return GL_FALSE;
- }
- }
-
- VB->ClipAndMask = m->andmask;
- VB->ClipOrMask = m->ormask;
- VB->ClipMask = m->clipmask;
-
- return GL_TRUE;
-}
-
-
-static INLINE void call_func( struct tnl_compiled_program *p,
- struct arb_vp_machine *m )
-{
- p->compiled_func(m);
-}
-
-/**
- * Execute the given vertex program.
- *
- * TODO: Integrate the t_vertex.c code here, to build machine vertices
- * directly at this point.
- *
- * TODO: Eliminate the VB struct entirely and just use
- * struct arb_vertex_machine.
- */
-static GLboolean
-run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- struct vertex_program *program = (ctx->VertexProgram._Enabled ?
- ctx->VertexProgram.Current :
- ctx->_TnlProgram);
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
- struct tnl_compiled_program *p;
- GLuint i, j, outputs;
-
- if (!program || program->IsNVProgram)
- return GL_TRUE;
-
- if (program->Parameters) {
- _mesa_load_state_parameters(ctx, program->Parameters);
- }
-
- p = (struct tnl_compiled_program *)program->TnlData;
- assert(p);
-
-
- m->nr_inputs = m->nr_outputs = 0;
-
- for (i = 0; i < _TNL_ATTRIB_MAX; i++) {
- if (program->InputsRead & (1<<i)) {
- GLuint j = m->nr_inputs++;
- m->input[j].idx = i;
- m->input[j].data = (GLfloat *)m->VB->AttribPtr[i]->data;
- m->input[j].stride = m->VB->AttribPtr[i]->stride;
- m->input[j].size = m->VB->AttribPtr[i]->size;
- ASSIGN_4V(m->File[0][REG_IN0 + i], 0, 0, 0, 1);
- }
- }
-
- for (i = 0; i < 15; i++) {
- if (program->OutputsWritten & (1<<i)) {
- GLuint j = m->nr_outputs++;
- m->output[j].idx = i;
- m->output[j].data = (GLfloat *)m->attribs[i].data;
- }
- }
-
-
- /* Run the actual program:
- */
- for (m->vtx_nr = 0; m->vtx_nr < VB->Count; m->vtx_nr++) {
- for (j = 0; j < m->nr_inputs; j++) {
- GLuint idx = REG_IN0 + m->input[j].idx;
- switch (m->input[j].size) {
- case 4: m->File[0][idx][3] = m->input[j].data[3];
- case 3: m->File[0][idx][2] = m->input[j].data[2];
- case 2: m->File[0][idx][1] = m->input[j].data[1];
- case 1: m->File[0][idx][0] = m->input[j].data[0];
- }
-
- STRIDE_F(m->input[j].data, m->input[j].stride);
- }
-
- if (p->compiled_func) {
- call_func( p, m );
- }
- else {
- for (j = 0; j < p->nr_instructions; j++) {
- union instruction inst = p->instructions[j];
- opcode_func[inst.alu.opcode]( m, inst );
- }
- }
-
- for (j = 0; j < m->nr_outputs; j++) {
- GLuint idx = REG_OUT0 + m->output[j].idx;
- m->output[j].data[0] = m->File[0][idx][0];
- m->output[j].data[1] = m->File[0][idx][1];
- m->output[j].data[2] = m->File[0][idx][2];
- m->output[j].data[3] = m->File[0][idx][3];
- m->output[j].data += 4;
- }
- }
-
- /* Setup the VB pointers so that the next pipeline stages get
- * their data from the right place (the program output arrays).
- *
- * TODO: 1) Have tnl use these RESULT values for outputs rather
- * than trying to shoe-horn inputs and outputs into one set of
- * values.
- *
- * TODO: 2) Integrate t_vertex.c so that we just go straight ahead
- * and build machine vertices here.
- */
- VB->ClipPtr = &m->attribs[VERT_RESULT_HPOS];
- VB->ClipPtr->count = VB->Count;
-
- outputs = program->OutputsWritten;
-
- if (outputs & (1<<VERT_RESULT_COL0)) {
- VB->ColorPtr[0] = &m->attribs[VERT_RESULT_COL0];
- VB->AttribPtr[VERT_ATTRIB_COLOR0] = VB->ColorPtr[0];
- }
-
- if (outputs & (1<<VERT_RESULT_BFC0)) {
- VB->ColorPtr[1] = &m->attribs[VERT_RESULT_BFC0];
- }
-
- if (outputs & (1<<VERT_RESULT_COL1)) {
- VB->SecondaryColorPtr[0] = &m->attribs[VERT_RESULT_COL1];
- VB->AttribPtr[VERT_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
- }
-
- if (outputs & (1<<VERT_RESULT_BFC1)) {
- VB->SecondaryColorPtr[1] = &m->attribs[VERT_RESULT_BFC1];
- }
-
- if (outputs & (1<<VERT_RESULT_FOGC)) {
- VB->FogCoordPtr = &m->attribs[VERT_RESULT_FOGC];
- VB->AttribPtr[VERT_ATTRIB_FOG] = VB->FogCoordPtr;
- }
-
- if (outputs & (1<<VERT_RESULT_PSIZ)) {
- VB->PointSizePtr = &m->attribs[VERT_RESULT_PSIZ];
- VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &m->attribs[VERT_RESULT_PSIZ];
- }
-
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- if (outputs & (1<<(VERT_RESULT_TEX0+i))) {
- VB->TexCoordPtr[i] = &m->attribs[VERT_RESULT_TEX0 + i];
- VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i];
- }
- }
-
-#if 0
- for (i = 0; i < VB->Count; i++) {
- printf("Out %d: %f %f %f %f %f %f %f %f\n", i,
- VEC_ELT(VB->ClipPtr, GLfloat, i)[0],
- VEC_ELT(VB->ClipPtr, GLfloat, i)[1],
- VEC_ELT(VB->ClipPtr, GLfloat, i)[2],
- VEC_ELT(VB->ClipPtr, GLfloat, i)[3],
- VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[0],
- VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[1],
- VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[2],
- VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[3]);
- }
-#endif
-
- /* Perform NDC and cliptest operations:
- */
- return do_ndc_cliptest(m);
-}
-
-
-static void
-validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage )
-{
- struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
- struct vertex_program *program =
- (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : 0);
-
- if (!program && ctx->_MaintainTnlProgram) {
- program = ctx->_TnlProgram;
- }
-
- if (program) {
- if (!program->TnlData)
- compile_vertex_program( program, m->try_codegen );
-
- /* Grab the state GL state and put into registers:
- */
- m->File[FILE_LOCAL_PARAM] = program->Base.LocalParams;
- m->File[FILE_ENV_PARAM] = ctx->VertexProgram.Parameters;
- /* GL_NV_vertex_programs can't reference GL state */
- if (program->Parameters)
- m->File[FILE_STATE_PARAM] = program->Parameters->ParameterValues;
- else
- m->File[FILE_STATE_PARAM] = NULL;
- }
-}
-
-
-
-
-
-
-
-/**
- * Called the first time stage->run is called. In effect, don't
- * allocate data until the first time the stage is run.
- */
-static GLboolean init_vertex_program( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &(tnl->vb);
- struct arb_vp_machine *m;
- const GLuint size = VB->Size;
- GLuint i;
-
- stage->privatePtr = _mesa_malloc(sizeof(*m));
- m = ARB_VP_MACHINE(stage);
- if (!m)
- return GL_FALSE;
-
- /* arb_vertex_machine struct should subsume the VB:
- */
- m->VB = VB;
- m->ctx = ctx;
-
- m->File[0] = ALIGN_MALLOC(REG_MAX * sizeof(GLfloat) * 4, 16);
-
- /* Initialize regs where necessary:
- */
- ASSIGN_4V(m->File[0][REG_ID], 0, 0, 0, 1);
- ASSIGN_4V(m->File[0][REG_ONES], 1, 1, 1, 1);
- ASSIGN_4V(m->File[0][REG_SWZ], -1, 1, 0, 0);
- ASSIGN_4V(m->File[0][REG_NEG], -1, -1, -1, -1);
- ASSIGN_4V(m->File[0][REG_LIT], 1, 0, 0, 1);
- ASSIGN_4V(m->File[0][REG_LIT2], 1, .5, .2, 1); /* debug value */
-
- if (_mesa_getenv("MESA_EXPERIMENTAL"))
- m->try_codegen = 1;
-
- /* Allocate arrays of vertex output values */
- for (i = 0; i < VERT_RESULT_MAX; i++) {
- _mesa_vector4f_alloc( &m->attribs[i], 0, size, 32 );
- m->attribs[i].size = 4;
- }
-
- /* a few other misc allocations */
- _mesa_vector4f_alloc( &m->ndcCoords, 0, size, 32 );
- m->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
-
- if (ctx->_MaintainTnlProgram)
- _mesa_allow_light_in_model( ctx, GL_FALSE );
-
- m->fpucntl_rnd_neg = RND_NEG_FPU; /* const value */
- m->fpucntl_restore = RESTORE_FPU; /* const value */
-
- return GL_TRUE;
-}
-
-
-
-
-/**
- * Destructor for this pipeline stage.
- */
-static void dtr( struct tnl_pipeline_stage *stage )
-{
- struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
-
- if (m) {
- GLuint i;
-
- /* free the vertex program result arrays */
- for (i = 0; i < VERT_RESULT_MAX; i++)
- _mesa_vector4f_free( &m->attribs[i] );
-
- /* free misc arrays */
- _mesa_vector4f_free( &m->ndcCoords );
- ALIGN_FREE( m->clipmask );
- ALIGN_FREE( m->File[0] );
-
- _mesa_free( m );
- stage->privatePtr = NULL;
- }
-}
-
-/**
- * Public description of this pipeline stage.
- */
-const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage =
-{
- "vertex-program",
- NULL, /* private_data */
- init_vertex_program, /* create */
- dtr, /* destroy */
- validate_vertex_program, /* validate */
- run_arb_vertex_program /* run */
-};
-
-
-/**
- * Called via ctx->Driver.ProgramStringNotify() after a new vertex program
- * string has been parsed.
- */
-void
-_tnl_program_string(GLcontext *ctx, GLenum target, struct program *program)
-{
- if (program->Target == GL_VERTEX_PROGRAM_ARB) {
- /* free any existing tnl data hanging off the program */
- struct vertex_program *vprog = (struct vertex_program *) program;
- if (vprog->TnlData) {
- free_tnl_data(vprog);
- }
- }
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h
deleted file mode 100644
index 02cd43282..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2004 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 t_arb_program.c
- * Compile vertex programs to an intermediate representation.
- * Execute vertex programs over a buffer of vertices.
- * \author Keith Whitwell, Brian Paul
- */
-
-
-#ifndef _T_VB_ARBPROGRAM_H_
-#define _T_VB_ARBPROGRAM_H_
-
-
-/* New, internal instructions:
- */
-#define RSW (VP_MAX_OPCODE)
-#define MSK (VP_MAX_OPCODE+1)
-#define REL (VP_MAX_OPCODE+2)
-
-/**
- * Register files for vertex programs
- */
-#define FILE_REG 0 /* temporaries */
-#define FILE_LOCAL_PARAM 1 /* local parameters */
-#define FILE_ENV_PARAM 2 /* global parameters */
-#define FILE_STATE_PARAM 3 /* GL state references */
-
-#define REG_ARG0 0
-#define REG_ARG1 1
-#define REG_ARG2 2
-#define REG_RES 3
-#define REG_ADDR 4
-#define REG_TMP0 5
-#define REG_TMP11 16
-#define REG_OUT0 17
-#define REG_OUT14 31
-#define REG_IN0 32
-#define REG_IN31 63
-#define REG_ID 64 /* 0,0,0,1 */
-#define REG_ONES 65 /* 1,1,1,1 */
-#define REG_SWZ 66 /* -1,1,0,0 */
-#define REG_NEG 67 /* -1,-1,-1,-1 */
-#define REG_LIT 68 /* 1,0,0,1 */
-#define REG_LIT2 69 /* 1,0,0,1 */
-#define REG_SCRATCH 70 /* internal temporary */
-#define REG_UNDEF 127 /* special case - never used */
-#define REG_MAX 128
-#define REG_INVALID ~0
-
-/* ARB_vp instructions are broken down into one or more of the
- * following micro-instructions, each representable in a 32 bit packed
- * structure.
- */
-struct reg {
- GLuint file:2;
- GLuint idx:7;
-};
-
-
-union instruction {
- struct {
- GLuint opcode:6;
- GLuint dst:5;
- GLuint file0:2;
- GLuint idx0:7;
- GLuint file1:2;
- GLuint idx1:7;
- GLuint pad:3;
- } alu;
-
- struct {
- GLuint opcode:6;
- GLuint dst:5;
- GLuint file0:2;
- GLuint idx0:7;
- GLuint neg:4;
- GLuint swz:8; /* xyzw only */
- } rsw;
-
- struct {
- GLuint opcode:6;
- GLuint dst:5;
- GLuint file:2;
- GLuint idx:7;
- GLuint mask:4;
- GLuint pad:1;
- } msk;
-
- GLuint dword;
-};
-
-#define RSW_NOOP ((0<<0) | (1<<2) | (2<<4) | (3<<6))
-#define GET_RSW(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
-
-
-struct input {
- GLuint idx;
- GLfloat *data;
- GLuint stride;
- GLuint size;
-};
-
-struct output {
- GLuint idx;
- GLfloat *data;
-};
-
-
-
-/*--------------------------------------------------------------------------- */
-#if defined(USE_SSE_ASM)
-#ifdef NO_FAST_MATH
-#define RESTORE_FPU (DEFAULT_X86_FPU)
-#define RND_NEG_FPU (DEFAULT_X86_FPU | 0x400)
-#else
-#define RESTORE_FPU (FAST_X86_FPU)
-#define RND_NEG_FPU (FAST_X86_FPU | 0x400)
-#endif
-#else
-#define RESTORE_FPU 0
-#define RND_NEG_FPU 0
-#endif
-
-
-/*!
- * Private storage for the vertex program pipeline stage.
- */
-struct arb_vp_machine {
- GLfloat (*File[4])[4]; /* All values referencable from the program. */
-
- struct input input[_TNL_ATTRIB_MAX];
- GLuint nr_inputs;
-
- struct output output[15];
- GLuint nr_outputs;
-
- GLvector4f attribs[VERT_RESULT_MAX]; /**< result vectors. */
- GLvector4f ndcCoords; /**< normalized device coords */
- GLubyte *clipmask; /**< clip flags */
- GLubyte ormask, andmask; /**< for clipping */
-
- GLuint vtx_nr; /**< loop counter */
-
- struct vertex_buffer *VB;
- GLcontext *ctx;
-
- GLshort fpucntl_rnd_neg; /* constant value */
- GLshort fpucntl_restore; /* constant value */
-
- GLboolean try_codegen;
-};
-
-struct tnl_compiled_program {
- union instruction instructions[1024];
- GLint nr_instructions;
- void (*compiled_func)( struct arb_vp_machine * ); /**< codegen'd program */
-};
-
-void _tnl_program_string_change( struct vertex_program * );
-void _tnl_program_destroy( struct vertex_program * );
-
-void _tnl_disassem_vba_insn( union instruction op );
-
-GLboolean _tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p);
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c
deleted file mode 100644
index 330d30efb..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c
+++ /dev/null
@@ -1,1222 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2004 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 t_vb_arb_program_sse.c
- *
- * Translate simplified vertex_program representation to
- * x86/x87/SSE/SSE2 machine code using mesa's rtasm runtime assembler.
- *
- * This is very much a first attempt - build something that works.
- * There are probably better approaches for applying SSE to vertex
- * programs, and the whole thing is crying out for static analysis of
- * the programs to avoid redundant operations.
- *
- * \author Keith Whitwell
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "imports.h"
-#include "macros.h"
-#include "mtypes.h"
-#include "arbprogparse.h"
-#include "program.h"
-#include "math/m_matrix.h"
-#include "math/m_translate.h"
-#include "t_context.h"
-#include "t_vb_arbprogram.h"
-
-#if defined(USE_SSE_ASM)
-
-#include "x86/rtasm/x86sse.h"
-#include "x86/common_x86_asm.h"
-
-#define X 0
-#define Y 1
-#define Z 2
-#define W 3
-
-/* Reg usage:
- *
- * EAX - temp
- * EBX - point to 'm->File[0]'
- * ECX - point to 'm->File[3]'
- * EDX - holds 'm'
- * EBP,
- * ESI,
- * EDI
- */
-
-#define DISASSEM 0
-
-#define FAIL \
-do { \
- _mesa_printf("x86 translation failed in %s\n", __FUNCTION__); \
- return GL_FALSE; \
-} while (0)
-
-struct compilation {
- struct x86_function func;
- struct tnl_compiled_program *p;
- GLuint insn_counter;
-
- struct {
- GLuint file:2;
- GLuint idx:7;
- GLuint dirty:1;
- GLuint last_used:10;
- } xmm[8];
-
- struct {
- struct x86_reg base;
- } file[4];
-
- GLboolean have_sse2;
- GLshort fpucntl;
-};
-
-static INLINE GLboolean eq( struct x86_reg a,
- struct x86_reg b )
-{
- return (a.file == b.file &&
- a.idx == b.idx &&
- a.mod == b.mod &&
- a.disp == b.disp);
-}
-
-static GLint get_offset( const void *a, const void *b )
-{
- return (const char *)b - (const char *)a;
-}
-
-
-static struct x86_reg get_reg_ptr(GLuint file,
- GLuint idx )
-{
- struct x86_reg reg;
-
- switch (file) {
- case FILE_REG:
- reg = x86_make_reg(file_REG32, reg_BX);
- assert(idx != REG_UNDEF);
- break;
- case FILE_STATE_PARAM:
- reg = x86_make_reg(file_REG32, reg_CX);
- break;
- default:
- assert(0);
- }
-
- return x86_make_disp(reg, 16 * idx);
-}
-
-
-static void spill( struct compilation *cp, GLuint idx )
-{
- struct x86_reg oldval = get_reg_ptr(cp->xmm[idx].file,
- cp->xmm[idx].idx);
-
- assert(cp->xmm[idx].dirty);
- sse_movups(&cp->func, oldval, x86_make_reg(file_XMM, idx));
- cp->xmm[idx].dirty = 0;
-}
-
-static struct x86_reg get_xmm_reg( struct compilation *cp )
-{
- GLuint i;
- GLuint oldest = 0;
-
- for (i = 0; i < 8; i++)
- if (cp->xmm[i].last_used < cp->xmm[oldest].last_used)
- oldest = i;
-
- /* Need to write out the old value?
- */
- if (cp->xmm[oldest].dirty)
- spill(cp, oldest);
-
- assert(cp->xmm[oldest].last_used != cp->insn_counter);
-
- cp->xmm[oldest].file = FILE_REG;
- cp->xmm[oldest].idx = REG_UNDEF;
- cp->xmm[oldest].last_used = cp->insn_counter;
- return x86_make_reg(file_XMM, oldest);
-}
-
-static void invalidate_xmm( struct compilation *cp,
- GLuint file, GLuint idx )
-{
- GLuint i;
-
- /* Invalidate any old copy of this register in XMM0-7.
- */
- for (i = 0; i < 8; i++) {
- if (cp->xmm[i].file == file && cp->xmm[i].idx == idx) {
- cp->xmm[i].file = FILE_REG;
- cp->xmm[i].idx = REG_UNDEF;
- cp->xmm[i].dirty = 0;
- break;
- }
- }
-}
-
-
-/* Return an XMM reg to receive the results of an operation.
- */
-static struct x86_reg get_dst_xmm_reg( struct compilation *cp,
- GLuint file, GLuint idx )
-{
- struct x86_reg reg;
-
- /* Invalidate any old copy of this register in XMM0-7. Don't reuse
- * as this may be one of the arguments.
- */
- invalidate_xmm( cp, file, idx );
-
- reg = get_xmm_reg( cp );
- cp->xmm[reg.idx].file = file;
- cp->xmm[reg.idx].idx = idx;
- cp->xmm[reg.idx].dirty = 1;
- return reg;
-}
-
-/* As above, but return a pointer. Note - this pointer may alias
- * those returned by get_arg_ptr().
- */
-static struct x86_reg get_dst_ptr( struct compilation *cp,
- GLuint file, GLuint idx )
-{
- /* Invalidate any old copy of this register in XMM0-7. Don't reuse
- * as this may be one of the arguments.
- */
- invalidate_xmm( cp, file, idx );
-
- return get_reg_ptr(file, idx);
-}
-
-
-
-/* Return an XMM reg if the argument is resident, otherwise return a
- * base+offset pointer to the saved value.
- */
-static struct x86_reg get_arg( struct compilation *cp, GLuint file, GLuint idx )
-{
- GLuint i;
-
- for (i = 0; i < 8; i++) {
- if (cp->xmm[i].file == file &&
- cp->xmm[i].idx == idx) {
- cp->xmm[i].last_used = cp->insn_counter;
- return x86_make_reg(file_XMM, i);
- }
- }
-
- return get_reg_ptr(file, idx);
-}
-
-/* As above, but always return a pointer:
- */
-static struct x86_reg get_arg_ptr( struct compilation *cp, GLuint file, GLuint idx )
-{
- GLuint i;
-
- /* If there is a modified version of this register in one of the
- * XMM regs, write it out to memory.
- */
- for (i = 0; i < 8; i++) {
- if (cp->xmm[i].file == file &&
- cp->xmm[i].idx == idx &&
- cp->xmm[i].dirty)
- spill(cp, i);
- }
-
- return get_reg_ptr(file, idx);
-}
-
-/* Emulate pshufd insn in regular SSE, if necessary:
- */
-static void emit_pshufd( struct compilation *cp,
- struct x86_reg dst,
- struct x86_reg arg0,
- GLubyte shuf )
-{
- if (cp->have_sse2) {
- sse2_pshufd(&cp->func, dst, arg0, shuf);
- cp->func.fn = 0;
- }
- else {
- if (!eq(dst, arg0))
- sse_movups(&cp->func, dst, arg0);
-
- sse_shufps(&cp->func, dst, dst, shuf);
- }
-}
-
-static void set_fpu_round_neg_inf( struct compilation *cp )
-{
- if (cp->fpucntl != RND_NEG_FPU) {
- struct x86_reg regEDX = x86_make_reg(file_REG32, reg_DX);
- struct arb_vp_machine *m = NULL;
-
- cp->fpucntl = RND_NEG_FPU;
- x87_fnclex(&cp->func);
- x87_fldcw(&cp->func, x86_make_disp(regEDX, get_offset(m, &m->fpucntl_rnd_neg)));
- }
-}
-
-
-/* Perform a reduced swizzle.
- */
-static GLboolean emit_RSW( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.rsw.file0, op.rsw.idx0);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.rsw.dst);
- GLuint swz = op.rsw.swz;
- GLuint neg = op.rsw.neg;
-
- emit_pshufd(cp, dst, arg0, swz);
-
- if (neg) {
- struct x86_reg negs = get_arg(cp, FILE_REG, REG_SWZ);
- struct x86_reg tmp = get_xmm_reg(cp);
- /* Load 1,-1,0,0
- * Use neg as arg to pshufd
- * Multiply
- */
- emit_pshufd(cp, tmp, negs,
- SHUF((neg & 1) ? 1 : 0,
- (neg & 2) ? 1 : 0,
- (neg & 4) ? 1 : 0,
- (neg & 8) ? 1 : 0));
- sse_mulps(&cp->func, dst, tmp);
- }
-
- return GL_TRUE;
-}
-
-/* Helper for writemask:
- */
-static GLboolean emit_shuf_copy1( struct compilation *cp,
- struct x86_reg dst,
- struct x86_reg arg0,
- struct x86_reg arg1,
- GLubyte shuf )
-{
- struct x86_reg tmp = get_xmm_reg(cp);
- sse_movups(&cp->func, dst, arg1);
- emit_pshufd(cp, dst, dst, shuf);
- emit_pshufd(cp, tmp, arg0, shuf);
-
- sse_movss(&cp->func, dst, tmp);
-
- emit_pshufd(cp, dst, dst, shuf);
- return GL_TRUE;
-}
-
-
-/* Helper for writemask:
- */
-static GLboolean emit_shuf_copy2( struct compilation *cp,
- struct x86_reg dst,
- struct x86_reg arg0,
- struct x86_reg arg1,
- GLubyte shuf )
-{
- struct x86_reg tmp = get_xmm_reg(cp);
- emit_pshufd(cp, dst, arg1, shuf);
- emit_pshufd(cp, tmp, arg0, shuf);
-
- sse_shufps(&cp->func, dst, tmp, SHUF(X, Y, Z, W));
-
- emit_pshufd(cp, dst, dst, shuf);
- return GL_TRUE;
-}
-
-
-static void emit_x87_ex2( struct compilation *cp )
-{
- struct x86_reg st0 = x86_make_reg(file_x87, 0);
- struct x86_reg st1 = x86_make_reg(file_x87, 1);
- struct x86_reg st3 = x86_make_reg(file_x87, 3);
-
- set_fpu_round_neg_inf( cp );
-
- x87_fld(&cp->func, st0); /* a a */
- x87_fprndint( &cp->func ); /* int(a) a */
- x87_fld(&cp->func, st0); /* int(a) int(a) a */
- x87_fstp(&cp->func, st3); /* int(a) a int(a)*/
- x87_fsubp(&cp->func, st1); /* frac(a) int(a) */
- x87_f2xm1(&cp->func); /* (2^frac(a))-1 int(a)*/
- x87_fld1(&cp->func); /* 1 (2^frac(a))-1 int(a)*/
- x87_faddp(&cp->func, st1); /* 2^frac(a) int(a) */
- x87_fscale(&cp->func); /* 2^a */
-}
-
-#if 0
-static GLboolean emit_MSK2( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.msk.file, op.msk.arg);
- struct x86_reg arg1 = get_arg(cp, FILE_REG, op.msk.dst); /* NOTE! */
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.msk.dst);
-
- /* make full width bitmask in tmp
- * dst = ~tmp
- * tmp &= arg0
- * dst &= arg1
- * dst |= tmp
- */
- emit_pshufd(cp, tmp, get_arg(cp, FILE_REG, REG_NEGS),
- SHUF((op.msk.mask & 1) ? 2 : 0,
- (op.msk.mask & 2) ? 2 : 0,
- (op.msk.mask & 4) ? 2 : 0,
- (op.msk.mask & 8) ? 2 : 0));
- sse2_pnot(&cp->func, dst, tmp);
- sse2_pand(&cp->func, arg0, tmp);
- sse2_pand(&cp->func, arg1, dst);
- sse2_por(&cp->func, tmp, dst);
- return GL_TRUE;
-}
-#endif
-
-
-/* Used to implement write masking. This and most of the other instructions
- * here would be easier to implement if there had been a translation
- * to a 2 argument format (dst/arg0, arg1) at the shader level before
- * attempting to translate to x86/sse code.
- */
-static GLboolean emit_MSK( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg = get_arg(cp, op.msk.file, op.msk.idx);
- struct x86_reg dst0 = get_arg(cp, FILE_REG, op.msk.dst); /* NOTE! */
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.msk.dst);
-
- /* Note that dst and dst0 refer to the same program variable, but
- * will definitely be different XMM registers. We're effectively
- * treating this as a 2 argument SEL now, just one of which happens
- * always to be the same register as the destination.
- */
-
- switch (op.msk.mask) {
- case 0:
- sse_movups(&cp->func, dst, dst0);
- return GL_TRUE;
-
- case WRITEMASK_X:
- if (arg.file == file_XMM) {
- sse_movups(&cp->func, dst, dst0);
- sse_movss(&cp->func, dst, arg);
- }
- else {
- struct x86_reg tmp = get_xmm_reg(cp);
- sse_movups(&cp->func, dst, dst0);
- sse_movss(&cp->func, tmp, arg);
- sse_movss(&cp->func, dst, tmp);
- }
- return GL_TRUE;
-
- case WRITEMASK_XY:
- sse_movups(&cp->func, dst, dst0);
- sse_shufps(&cp->func, dst, arg, SHUF(X, Y, Z, W));
- return GL_TRUE;
-
- case WRITEMASK_ZW:
- sse_movups(&cp->func, dst, arg);
- sse_shufps(&cp->func, dst, dst0, SHUF(X, Y, Z, W));
- return GL_TRUE;
-
- case WRITEMASK_YZW:
- if (dst0.file == file_XMM) {
- sse_movups(&cp->func, dst, arg);
- sse_movss(&cp->func, dst, dst0);
- }
- else {
- struct x86_reg tmp = get_xmm_reg(cp);
- sse_movups(&cp->func, dst, arg);
- sse_movss(&cp->func, tmp, dst0);
- sse_movss(&cp->func, dst, tmp);
- }
- return GL_TRUE;
-
- case WRITEMASK_Y:
- emit_shuf_copy1(cp, dst, arg, dst0, SHUF(Y,X,Z,W));
- return GL_TRUE;
-
- case WRITEMASK_Z:
- emit_shuf_copy1(cp, dst, arg, dst0, SHUF(Z,Y,X,W));
- return GL_TRUE;
-
- case WRITEMASK_W:
- emit_shuf_copy1(cp, dst, arg, dst0, SHUF(W,Y,Z,X));
- return GL_TRUE;
-
- case WRITEMASK_XZ:
- emit_shuf_copy2(cp, dst, arg, dst0, SHUF(X,Z,Y,W));
- return GL_TRUE;
-
- case WRITEMASK_XW:
- emit_shuf_copy2(cp, dst, arg, dst0, SHUF(X,W,Z,Y));
-
- case WRITEMASK_YZ:
- emit_shuf_copy2(cp, dst, arg, dst0, SHUF(Z,Y,X,W));
- return GL_TRUE;
-
- case WRITEMASK_YW:
- emit_shuf_copy2(cp, dst, arg, dst0, SHUF(W,Y,Z,X));
- return GL_TRUE;
-
- case WRITEMASK_XZW:
- emit_shuf_copy1(cp, dst, dst0, arg, SHUF(Y,X,Z,W));
- return GL_TRUE;
-
- case WRITEMASK_XYW:
- emit_shuf_copy1(cp, dst, dst0, arg, SHUF(Z,Y,X,W));
- return GL_TRUE;
-
- case WRITEMASK_XYZ:
- emit_shuf_copy1(cp, dst, dst0, arg, SHUF(W,Y,Z,X));
- return GL_TRUE;
-
- case WRITEMASK_XYZW:
- sse_movups(&cp->func, dst, arg);
- return GL_TRUE;
-
- default:
- assert(0);
- break;
- }
-}
-
-
-
-static GLboolean emit_PRT( struct compilation *cp, union instruction op )
-{
- FAIL;
-}
-
-
-/**
- * The traditional instructions. All operate on internal registers
- * and ignore write masks and swizzling issues.
- */
-
-static GLboolean emit_ABS( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg neg = get_reg_ptr(FILE_REG, REG_NEG);
-
- sse_movups(&cp->func, dst, arg0);
- sse_mulps(&cp->func, dst, neg);
- sse_maxps(&cp->func, dst, arg0);
- return GL_TRUE;
-}
-
-static GLboolean emit_ADD( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- sse_movups(&cp->func, dst, arg0);
- sse_addps(&cp->func, dst, arg1);
- return GL_TRUE;
-}
-
-
-/* The dotproduct instructions don't really do that well in sse:
- */
-static GLboolean emit_DP3( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg tmp = get_xmm_reg(cp);
-
- sse_movups(&cp->func, dst, arg0);
- sse_mulps(&cp->func, dst, arg1);
-
- /* Now the hard bit: sum the first 3 values:
- */
- sse_movhlps(&cp->func, tmp, dst);
- sse_addss(&cp->func, dst, tmp); /* a*x+c*z, b*y, ?, ? */
- emit_pshufd(cp, tmp, dst, SHUF(Y,X,W,Z));
- sse_addss(&cp->func, dst, tmp);
- sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
- return GL_TRUE;
-}
-
-
-
-static GLboolean emit_DP4( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg tmp = get_xmm_reg(cp);
-
- sse_movups(&cp->func, dst, arg0);
- sse_mulps(&cp->func, dst, arg1);
-
- /* Now the hard bit: sum the values:
- */
- sse_movhlps(&cp->func, tmp, dst);
- sse_addps(&cp->func, dst, tmp); /* a*x+c*z, b*y+d*w, a*x+c*z, b*y+d*w */
- emit_pshufd(cp, tmp, dst, SHUF(Y,X,W,Z));
- sse_addss(&cp->func, dst, tmp);
- sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
- return GL_TRUE;
-}
-
-static GLboolean emit_DPH( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
- struct x86_reg tmp = get_xmm_reg(cp);
-
- emit_pshufd(cp, dst, arg0, SHUF(W,X,Y,Z));
- sse_movss(&cp->func, dst, ones);
- emit_pshufd(cp, dst, dst, SHUF(W,X,Y,Z));
- sse_mulps(&cp->func, dst, arg1);
-
- /* Now the hard bit: sum the values (from DP4):
- */
- sse_movhlps(&cp->func, tmp, dst);
- sse_addps(&cp->func, dst, tmp); /* a*x+c*z, b*y+d*w, a*x+c*z, b*y+d*w */
- emit_pshufd(cp, tmp, dst, SHUF(Y,X,W,Z));
- sse_addss(&cp->func, dst, tmp);
- sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
- return GL_TRUE;
-}
-
-#if 0
-static GLboolean emit_DST( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg_ptr(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
-
-/* dst[0] = 1.0 * 1.0F; */
-/* dst[1] = arg0[1] * arg1[1]; */
-/* dst[2] = arg0[2] * 1.0; */
-/* dst[3] = 1.0 * arg1[3]; */
-
- /* Would rather do some of this with integer regs, but:
- * 1) No proper support for immediate values yet
- * 2) I'd need to push/pop somewhere to get a free reg.
- */
- x87_fld1(&cp->func);
- x87_fstp(&cp->func, dst); /* would rather do an immediate store... */
- x87_fld(&cp->func, x86_make_disp(arg0, 4));
- x87_fmul(&cp->func, x86_make_disp(arg1, 4));
- x87_fstp(&cp->func, x86_make_disp(dst, 4));
-
- if (!eq(arg0, dst)) {
- x86_fld(&cp->func, x86_make_disp(arg0, 8));
- x86_stp(&cp->func, x86_make_disp(dst, 8));
- }
-
- if (!eq(arg1, dst)) {
- x86_fld(&cp->func, x86_make_disp(arg0, 12));
- x86_stp(&cp->func, x86_make_disp(dst, 12));
- }
-
- return GL_TRUE;
-}
-#else
-static GLboolean emit_DST( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg tmp = get_xmm_reg(cp);
- struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
-
- emit_shuf_copy2(cp, dst, arg0, ones, SHUF(X,W,Z,Y));
- emit_shuf_copy2(cp, tmp, arg1, ones, SHUF(X,Z,Y,W));
- sse_mulps(&cp->func, dst, tmp);
-
-/* dst[0] = 1.0 * 1.0F; */
-/* dst[1] = arg0[1] * arg1[1]; */
-/* dst[2] = arg0[2] * 1.0; */
-/* dst[3] = 1.0 * arg1[3]; */
-
- return GL_TRUE;
-}
-#endif
-
-static GLboolean emit_LG2( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
-
- x87_fld1(&cp->func); /* 1 */
- x87_fld(&cp->func, arg0); /* a0 1 */
- x87_fyl2x(&cp->func); /* log2(a0) */
- x87_fst(&cp->func, x86_make_disp(dst, 0));
- x87_fst(&cp->func, x86_make_disp(dst, 4));
- x87_fst(&cp->func, x86_make_disp(dst, 8));
- x87_fstp(&cp->func, x86_make_disp(dst, 12));
-
- return GL_TRUE;
-}
-
-
-static GLboolean emit_EX2( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
-
- /* CAUTION: dst may alias arg0!
- */
- x87_fld(&cp->func, arg0);
-
- emit_x87_ex2(cp);
-
- x87_fst(&cp->func, x86_make_disp(dst, 0));
- x87_fst(&cp->func, x86_make_disp(dst, 4));
- x87_fst(&cp->func, x86_make_disp(dst, 8));
- x87_fst(&cp->func, x86_make_disp(dst, 12));
- return GL_TRUE;
-}
-
-static GLboolean emit_EXP( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
- struct x86_reg st0 = x86_make_reg(file_x87, 0);
- struct x86_reg st1 = x86_make_reg(file_x87, 1);
- struct x86_reg st3 = x86_make_reg(file_x87, 3);
-
- /* CAUTION: dst may alias arg0!
- */
- x87_fld(&cp->func, arg0); /* arg0.x */
- x87_fld(&cp->func, st0); /* arg arg */
-
- /* by default, fpu is setup to round-to-nearest. We want to
- * change this now, and track the state through to the end of the
- * generated function so that it isn't repeated unnecessarily.
- * Alternately, could subtract .5 to get round to -inf behaviour.
- */
- set_fpu_round_neg_inf( cp );
- x87_fprndint( &cp->func ); /* flr(a) a */
- x87_fld(&cp->func, st0); /* flr(a) flr(a) a */
- x87_fld1(&cp->func); /* 1 floor(a) floor(a) a */
- x87_fst(&cp->func, x86_make_disp(dst, 12)); /* stack unchanged */
- x87_fscale(&cp->func); /* 2^floor(a) floor(a) a */
- x87_fst(&cp->func, st3); /* 2^floor(a) floor(a) a 2^floor(a)*/
- x87_fstp(&cp->func, x86_make_disp(dst, 0)); /* flr(a) a 2^flr(a) */
- x87_fsubrp(&cp->func, st1); /* frac(a) 2^flr(a) */
- x87_fst(&cp->func, x86_make_disp(dst, 4)); /* frac(a) 2^flr(a) */
- x87_f2xm1(&cp->func); /* (2^frac(a))-1 2^flr(a)*/
- x87_fld1(&cp->func); /* 1 (2^frac(a))-1 2^flr(a)*/
- x87_faddp(&cp->func, st1); /* 2^frac(a) 2^flr(a) */
- x87_fmulp(&cp->func, st1); /* 2^a */
- x87_fst(&cp->func, x86_make_disp(dst, 8));
-
-
-
-/* dst[0] = 2^floor(tmp); */
-/* dst[1] = frac(tmp); */
-/* dst[2] = 2^floor(tmp) * 2^frac(tmp); */
-/* dst[3] = 1.0F; */
- return GL_TRUE;
-}
-
-static GLboolean emit_LOG( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
- struct x86_reg st0 = x86_make_reg(file_x87, 0);
- struct x86_reg st1 = x86_make_reg(file_x87, 1);
- struct x86_reg st2 = x86_make_reg(file_x87, 2);
-
- /* CAUTION: dst may alias arg0!
- */
- x87_fld(&cp->func, arg0); /* arg0.x */
- x87_fabs(&cp->func); /* |arg0.x| */
- x87_fxtract(&cp->func); /* mantissa(arg0.x), exponent(arg0.x) */
- x87_fst(&cp->func, st2); /* mantissa, exponent, mantissa */
- x87_fld1(&cp->func); /* 1, mantissa, exponent, mantissa */
- x87_fyl2x(&cp->func); /* log2(mantissa), exponent, mantissa */
- x87_fadd(&cp->func, st0, st1); /* e+l2(m), e, m */
- x87_fstp(&cp->func, x86_make_disp(dst, 8)); /* e, m */
-
- x87_fld1(&cp->func); /* 1, e, m */
- x87_fsub(&cp->func, st1, st0); /* 1, e-1, m */
- x87_fstp(&cp->func, x86_make_disp(dst, 12)); /* e-1,m */
- x87_fstp(&cp->func, dst); /* m */
-
- x87_fadd(&cp->func, st0, st0); /* 2m */
- x87_fstp(&cp->func, x86_make_disp(dst, 4));
-
- return GL_TRUE;
-}
-
-static GLboolean emit_FLR( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
- int i;
-
- set_fpu_round_neg_inf( cp );
-
- for (i = 0; i < 4; i++) {
- x87_fld(&cp->func, x86_make_disp(arg0, i*4));
- x87_fprndint( &cp->func );
- x87_fstp(&cp->func, x86_make_disp(dst, i*4));
- }
-
-
- return GL_TRUE;
-}
-
-static GLboolean emit_FRC( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
- struct x86_reg st0 = x86_make_reg(file_x87, 0);
- struct x86_reg st1 = x86_make_reg(file_x87, 1);
- int i;
-
- set_fpu_round_neg_inf( cp );
-
- /* Knowing liveness info or even just writemask would be useful
- * here:
- */
- for (i = 0; i < 4; i++) {
- x87_fld(&cp->func, x86_make_disp(arg0, i*4));
- x87_fld(&cp->func, st0); /* a a */
- x87_fprndint( &cp->func ); /* flr(a) a */
- x87_fsubrp(&cp->func, st1); /* frc(a) */
- x87_fstp(&cp->func, x86_make_disp(dst, i*4));
- }
-
- return GL_TRUE;
-}
-
-
-
-static GLboolean emit_LIT( struct compilation *cp, union instruction op )
-{
-#if 1
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
- struct x86_reg lit = get_arg(cp, FILE_REG, REG_LIT);
- struct x86_reg tmp = get_xmm_reg(cp);
- struct x86_reg st1 = x86_make_reg(file_x87, 1);
- struct x86_reg regEAX = x86_make_reg(file_REG32, reg_AX);
- GLubyte *fixup1, *fixup2;
-
-
- /* Load the interesting parts of arg0:
- */
- x87_fld(&cp->func, x86_make_disp(arg0, 12)); /* a3 */
- x87_fld(&cp->func, x86_make_disp(arg0, 4)); /* a1 a3 */
- x87_fld(&cp->func, x86_make_disp(arg0, 0)); /* a0 a1 a3 */
-
- /* Intialize dst:
- */
- sse_movaps(&cp->func, tmp, lit);
- sse_movaps(&cp->func, dst, tmp);
-
- /* Check arg0[0]:
- */
- x87_fldz(&cp->func); /* 0 a0 a1 a3 */
- x87_fucomp(&cp->func, st1); /* a0 a1 a3 */
- x87_fnstsw(&cp->func, regEAX);
- x86_sahf(&cp->func);
- fixup1 = x86_jcc_forward(&cp->func, cc_AE);
-
- x87_fstp(&cp->func, x86_make_disp(dst, 4)); /* a1 a3 */
-
- /* Check arg0[1]:
- */
- x87_fldz(&cp->func); /* 0 a1 a3 */
- x87_fucomp(&cp->func, st1); /* a1 a3 */
- x87_fnstsw(&cp->func, regEAX);
- x86_sahf(&cp->func);
- fixup2 = x86_jcc_forward(&cp->func, cc_AE);
-
- /* Compute pow(a1, a3)
- */
- x87_fyl2x(&cp->func); /* a3*log2(a1) */
-
- emit_x87_ex2( cp ); /* 2^(a3*log2(a1)) */
-
- x87_fstp(&cp->func, x86_make_disp(dst, 8));
-
- /* Land jumps:
- */
- x86_fixup_fwd_jump(&cp->func, fixup1);
- x86_fixup_fwd_jump(&cp->func, fixup2);
-#else
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg ones = get_reg_ptr(FILE_REG, REG_LIT);
- sse_movups(&cp->func, dst, ones);
-#endif
- return GL_TRUE;
-}
-
-
-
-static GLboolean emit_MAX( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- sse_movups(&cp->func, dst, arg0);
- sse_maxps(&cp->func, dst, arg1);
- return GL_TRUE;
-}
-
-
-static GLboolean emit_MIN( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- sse_movups(&cp->func, dst, arg0);
- sse_minps(&cp->func, dst, arg1);
- return GL_TRUE;
-}
-
-static GLboolean emit_MOV( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- sse_movups(&cp->func, dst, arg0);
- return GL_TRUE;
-}
-
-static GLboolean emit_MUL( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- sse_movups(&cp->func, dst, arg0);
- sse_mulps(&cp->func, dst, arg1);
- return GL_TRUE;
-}
-
-
-static GLboolean emit_POW( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg_ptr(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
-
- x87_fld(&cp->func, arg1); /* a1 */
- x87_fld(&cp->func, arg0); /* a0 a1 */
- x87_fyl2x(&cp->func); /* a1*log2(a0) */
-
- emit_x87_ex2( cp ); /* 2^(a1*log2(a0)) */
-
- x87_fst(&cp->func, x86_make_disp(dst, 0));
- x87_fst(&cp->func, x86_make_disp(dst, 4));
- x87_fst(&cp->func, x86_make_disp(dst, 8));
- x87_fstp(&cp->func, x86_make_disp(dst, 12));
-
- return GL_TRUE;
-}
-
-static GLboolean emit_REL( struct compilation *cp, union instruction op )
-{
-/* GLuint idx = (op.alu.idx0 + (GLint)cp->File[0][REG_ADDR][0]) & (MAX_NV_VERTEX_PROGRAM_PARAMS-1); */
-/* GLuint idx = 0; */
-/* struct x86_reg arg0 = get_arg(cp, op.alu.file0, idx); */
-/* struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst); */
-
-/* dst[0] = arg0[0]; */
-/* dst[1] = arg0[1]; */
-/* dst[2] = arg0[2]; */
-/* dst[3] = arg0[3]; */
-
- FAIL;
-}
-
-static GLboolean emit_RCP( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- if (cp->have_sse2) {
- sse2_rcpss(&cp->func, dst, arg0);
- }
- else {
- struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
- sse_movss(&cp->func, dst, ones);
- sse_divss(&cp->func, dst, arg0);
- }
-
- sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
- return GL_TRUE;
-}
-
-static GLboolean emit_RSQ( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- /* TODO: Calculate absolute value
- */
-#if 0
- sse_movss(&cp->func, dst, arg0);
- sse_mulss(&cp->func, dst, neg);
- sse_maxss(&cp->func, dst, arg0);
-#endif
-
- sse_rsqrtss(&cp->func, dst, arg0);
- sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
- return GL_TRUE;
-}
-
-
-static GLboolean emit_SGE( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
-
- sse_movups(&cp->func, dst, arg0);
- sse_cmpps(&cp->func, dst, arg1, cc_NotLessThan);
- sse_andps(&cp->func, dst, ones);
- return GL_TRUE;
-}
-
-
-static GLboolean emit_SLT( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
-
- sse_movups(&cp->func, dst, arg0);
- sse_cmpps(&cp->func, dst, arg1, cc_LessThan);
- sse_andps(&cp->func, dst, ones);
- return GL_TRUE;
-}
-
-static GLboolean emit_SUB( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
-
- sse_movups(&cp->func, dst, arg0);
- sse_subps(&cp->func, dst, arg1);
- return GL_TRUE;
-}
-
-
-static GLboolean emit_XPD( struct compilation *cp, union instruction op )
-{
- struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
- struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
- struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
- struct x86_reg tmp0 = get_xmm_reg(cp);
- struct x86_reg tmp1 = get_xmm_reg(cp);
-
- /* Could avoid tmp0, tmp1 if we overwrote arg0, arg1. Need a way
- * to invalidate registers. This will come with better analysis
- * (liveness analysis) of the incoming program.
- */
- emit_pshufd(cp, dst, arg0, SHUF(Y, Z, X, W));
- emit_pshufd(cp, tmp1, arg1, SHUF(Z, X, Y, W));
- sse_mulps(&cp->func, dst, tmp1);
- emit_pshufd(cp, tmp0, arg0, SHUF(Z, X, Y, W));
- emit_pshufd(cp, tmp1, arg1, SHUF(Y, Z, X, W));
- sse_mulps(&cp->func, tmp0, tmp1);
- sse_subps(&cp->func, dst, tmp0);
-
-/* dst[0] = arg0[1] * arg1[2] - arg0[2] * arg1[1]; */
-/* dst[1] = arg0[2] * arg1[0] - arg0[0] * arg1[2]; */
-/* dst[2] = arg0[0] * arg1[1] - arg0[1] * arg1[0]; */
-/* dst[3] is undef */
-
- return GL_TRUE;
-}
-
-static GLboolean emit_NOP( struct compilation *cp, union instruction op )
-{
- return GL_TRUE;
-}
-
-
-static GLboolean (* const emit_func[])(struct compilation *, union instruction) =
-{
- emit_ABS,
- emit_ADD,
- emit_NOP,
- emit_DP3,
- emit_DP4,
- emit_DPH,
- emit_DST,
- emit_NOP,
- emit_EX2,
- emit_EXP,
- emit_FLR,
- emit_FRC,
- emit_LG2,
- emit_LIT,
- emit_LOG,
- emit_NOP,
- emit_MAX,
- emit_MIN,
- emit_MOV,
- emit_MUL,
- emit_POW,
- emit_PRT,
- emit_NOP,
- emit_RCP,
- emit_RSQ,
- emit_SGE,
- emit_SLT,
- emit_SUB,
- emit_RSW,
- emit_XPD,
- emit_RSW,
- emit_MSK,
- emit_REL,
-};
-
-
-
-static GLboolean build_vertex_program( struct compilation *cp )
-{
- struct arb_vp_machine *m = NULL;
- GLuint j;
-
- struct x86_reg regEBX = x86_make_reg(file_REG32, reg_BX);
- struct x86_reg regECX = x86_make_reg(file_REG32, reg_CX);
- struct x86_reg regEDX = x86_make_reg(file_REG32, reg_DX);
-
- x86_push(&cp->func, regEBX);
-
- x86_mov(&cp->func, regEDX, x86_fn_arg(&cp->func, 1));
- x86_mov(&cp->func, regEBX, x86_make_disp(regEDX, get_offset(m, m->File + FILE_REG)));
- x86_mov(&cp->func, regECX, x86_make_disp(regEDX, get_offset(m, m->File + FILE_STATE_PARAM)));
-
- for (j = 0; j < cp->p->nr_instructions; j++) {
- union instruction inst = cp->p->instructions[j];
- cp->insn_counter = j+1; /* avoid zero */
-
- if (DISASSEM) {
- _mesa_printf("%p: ", cp->func.csr);
- _tnl_disassem_vba_insn( inst );
- }
- cp->func.fn = NULL;
-
- if (!emit_func[inst.alu.opcode]( cp, inst )) {
- return GL_FALSE;
- }
- }
-
- /* TODO: only for outputs:
- */
- for (j = 0; j < 8; j++) {
- if (cp->xmm[j].dirty)
- spill(cp, j);
- }
-
-
- /* Exit mmx state?
- */
- if (cp->func.need_emms)
- mmx_emms(&cp->func);
-
- /* Restore FPU control word?
- */
- if (cp->fpucntl != RESTORE_FPU) {
- x87_fnclex(&cp->func);
- x87_fldcw(&cp->func, x86_make_disp(regEDX, get_offset(m, &m->fpucntl_restore)));
- }
-
- x86_pop(&cp->func, regEBX);
- x86_ret(&cp->func);
-
- return GL_TRUE;
-}
-
-/**
- * Execute the given vertex program.
- *
- * TODO: Integrate the t_vertex.c code here, to build machine vertices
- * directly at this point.
- *
- * TODO: Eliminate the VB struct entirely and just use
- * struct arb_vertex_machine.
- */
-GLboolean
-_tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p)
-{
- struct compilation cp;
-
- memset(&cp, 0, sizeof(cp));
- cp.p = p;
- cp.have_sse2 = 1;
-
- if (p->compiled_func) {
- _mesa_free((void *)p->compiled_func);
- p->compiled_func = NULL;
- }
-
- x86_init_func(&cp.func);
-
- cp.fpucntl = RESTORE_FPU;
-
-
- /* Note ctx state is not referenced in building the function, so it
- * depends only on the list of instructions:
- */
- if (!build_vertex_program(&cp)) {
- x86_release_func( &cp.func );
- return GL_FALSE;
- }
-
-
- p->compiled_func = (void (*)(struct arb_vp_machine *))x86_get_func( &cp.func );
- return GL_TRUE;
-}
-
-
-
-#else
-
-GLboolean
-_tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p)
-{
- /* Dummy version for when USE_SSE_ASM not defined */
- return GL_FALSE;
-}
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h
deleted file mode 100644
index 1e3a6b02e..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h
+++ /dev/null
@@ -1,270 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#define CLIP_DOTPROD(K, A, B, C, D) X(K)*A + Y(K)*B + Z(K)*C + W(K)*D
-
-#define POLY_CLIP( PLANE, A, B, C, D ) \
-do { \
- if (mask & PLANE) { \
- GLuint idxPrev = inlist[0]; \
- GLfloat dpPrev = CLIP_DOTPROD(idxPrev, A, B, C, D ); \
- GLuint outcount = 0; \
- GLuint i; \
- \
- inlist[n] = inlist[0]; /* prevent rotation of vertices */ \
- for (i = 1; i <= n; i++) { \
- GLuint idx = inlist[i]; \
- GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D ); \
- \
- clipmask[idxPrev] |= PLANE; \
- if (!IS_NEGATIVE(dpPrev)) { \
- outlist[outcount++] = idxPrev; \
- clipmask[idxPrev] &= ~PLANE; \
- } \
- \
- if (DIFFERENT_SIGNS(dp, dpPrev)) { \
- GLuint newvert = VB->LastClipped++; \
- VB->ClipMask[newvert] = 0; \
- outlist[outcount++] = newvert; \
- if (IS_NEGATIVE(dp)) { \
- /* Going out of bounds. Avoid division by zero as we \
- * know dp != dpPrev from DIFFERENT_SIGNS, above. \
- */ \
- GLfloat t = dp / (dp - dpPrev); \
- INTERP_4F( t, coord[newvert], coord[idx], coord[idxPrev]); \
- interp( ctx, t, newvert, idx, idxPrev, GL_TRUE ); \
- } else { \
- /* Coming back in. \
- */ \
- GLfloat t = dpPrev / (dpPrev - dp); \
- INTERP_4F( t, coord[newvert], coord[idxPrev], coord[idx]); \
- interp( ctx, t, newvert, idxPrev, idx, GL_FALSE ); \
- } \
- } \
- \
- idxPrev = idx; \
- dpPrev = dp; \
- } \
- \
- if (outcount < 3) \
- return; \
- \
- { \
- GLuint *tmp = inlist; \
- inlist = outlist; \
- outlist = tmp; \
- n = outcount; \
- } \
- } \
-} while (0)
-
-
-#define LINE_CLIP(PLANE, A, B, C, D ) \
-do { \
- if (mask & PLANE) { \
- GLfloat dpI = CLIP_DOTPROD( ii, A, B, C, D ); \
- GLfloat dpJ = CLIP_DOTPROD( jj, A, B, C, D ); \
- \
- if (DIFFERENT_SIGNS(dpI, dpJ)) { \
- GLuint newvert = VB->LastClipped++; \
- VB->ClipMask[newvert] = 0; \
- if (IS_NEGATIVE(dpJ)) { \
- GLfloat t = dpI / (dpI - dpJ); \
- VB->ClipMask[jj] |= PLANE; \
- INTERP_4F( t, coord[newvert], coord[ii], coord[jj] ); \
- interp( ctx, t, newvert, ii, jj, GL_FALSE ); \
- jj = newvert; \
- } else { \
- GLfloat t = dpJ / (dpJ - dpI); \
- VB->ClipMask[ii] |= PLANE; \
- INTERP_4F( t, coord[newvert], coord[jj], coord[ii] ); \
- interp( ctx, t, newvert, jj, ii, GL_FALSE ); \
- ii = newvert; \
- } \
- } \
- else if (IS_NEGATIVE(dpI)) \
- return; \
- } \
-} while (0)
-
-
-
-/* Clip a line against the viewport and user clip planes.
- */
-static INLINE void
-TAG(clip_line)( GLcontext *ctx, GLuint i, GLuint j, GLubyte mask )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- tnl_interp_func interp = tnl->Driver.Render.Interp;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint ii = i, jj = j, p;
-
- VB->LastClipped = VB->Count;
-
- if (mask & 0x3f) {
- LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
- LINE_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
- LINE_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
- LINE_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
- LINE_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
- LINE_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
- }
-
- if (mask & CLIP_USER_BIT) {
- for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- LINE_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
- }
- }
-
- if ((ctx->_TriangleCaps & DD_FLATSHADE) && j != jj)
- tnl->Driver.Render.CopyPV( ctx, jj, j );
-
- tnl->Driver.Render.ClippedLine( ctx, ii, jj );
-}
-
-
-/* Clip a triangle against the viewport and user clip planes.
- */
-static INLINE void
-TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- tnl_interp_func interp = tnl->Driver.Render.Interp;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint pv = v2;
- GLuint vlist[2][MAX_CLIPPED_VERTICES];
- GLuint *inlist = vlist[0], *outlist = vlist[1];
- GLuint p;
- GLubyte *clipmask = VB->ClipMask;
- GLuint n = 3;
-
- ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
-
- VB->LastClipped = VB->Count;
-
- if (mask & 0x3f) {
- POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
- POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
- POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
- POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
- POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
- POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
- }
-
- if (mask & CLIP_USER_BIT) {
- for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
- }
- }
-
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- if (pv != inlist[0]) {
- ASSERT( inlist[0] >= VB->Count );
- tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
- }
- }
-
- tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
-}
-
-
-/* Clip a quad against the viewport and user clip planes.
- */
-static INLINE void
-TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
- GLubyte mask )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- tnl_interp_func interp = tnl->Driver.Render.Interp;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint pv = v3;
- GLuint vlist[2][MAX_CLIPPED_VERTICES];
- GLuint *inlist = vlist[0], *outlist = vlist[1];
- GLuint p;
- GLubyte *clipmask = VB->ClipMask;
- GLuint n = 4;
-
- ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */
-
- VB->LastClipped = VB->Count;
-
- if (mask & 0x3f) {
- POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
- POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
- POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
- POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
- POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
- POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
- }
-
- if (mask & CLIP_USER_BIT) {
- for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
- }
- }
-
- if (ctx->_TriangleCaps & DD_FLATSHADE) {
- if (pv != inlist[0]) {
- ASSERT( inlist[0] >= VB->Count );
- tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
- }
- }
-
- tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
-}
-
-#undef W
-#undef Z
-#undef Y
-#undef X
-#undef SIZE
-#undef TAG
-#undef POLY_CLIP
-#undef LINE_CLIP
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c
deleted file mode 100644
index 3f1294570..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-
-/* EXT_vertex_cull. Not really a big win, but probably depends on
- * your application. This stage not included in the default pipeline.
- */
-static GLboolean run_cull_stage( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
-
- const GLfloat a = ctx->Transform.CullObjPos[0];
- const GLfloat b = ctx->Transform.CullObjPos[1];
- const GLfloat c = ctx->Transform.CullObjPos[2];
- GLfloat *norm = (GLfloat *)VB->NormalPtr->data;
- GLuint stride = VB->NormalPtr->stride;
- GLuint count = VB->Count;
- GLuint i;
-
- if (ctx->VertexProgram._Enabled ||
- !ctx->Transform.CullVertexFlag)
- return GL_TRUE;
-
- VB->ClipOrMask &= ~CLIP_CULL_BIT;
- VB->ClipAndMask |= CLIP_CULL_BIT;
-
- for (i = 0 ; i < count ; i++) {
- GLfloat dp = (norm[0] * a +
- norm[1] * b +
- norm[2] * c);
-
- if (dp < 0) {
- VB->ClipMask[i] |= CLIP_CULL_BIT;
- VB->ClipOrMask |= CLIP_CULL_BIT;
- }
- else {
- VB->ClipMask[i] &= ~CLIP_CULL_BIT;
- VB->ClipAndMask &= ~CLIP_CULL_BIT;
- }
-
- STRIDE_F(norm, stride);
- }
-
- return !(VB->ClipAndMask & CLIP_CULL_BIT);
-}
-
-
-
-const struct tnl_pipeline_stage _tnl_vertex_cull_stage =
-{
- "EXT_cull_vertex",
- NULL, /* private data */
- NULL, /* ctr */
- NULL, /* destructor */
- NULL,
- run_cull_stage /* run -- initially set to init */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c
deleted file mode 100644
index f1d01bc47..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-struct fog_stage_data {
- GLvector4f fogcoord; /* has actual storage allocated */
- GLvector4f input; /* points into VB->EyePtr Z values */
-};
-
-#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr)
-
-#define FOG_EXP_TABLE_SIZE 256
-#define FOG_MAX (10.0)
-#define EXP_FOG_MAX .0006595
-#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
-static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
-static GLfloat inited = 0;
-
-#if 1
-#define NEG_EXP( result, narg ) \
-do { \
- GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR)); \
- GLint k = (GLint) f; \
- if (k > FOG_EXP_TABLE_SIZE-2) \
- result = (GLfloat) EXP_FOG_MAX; \
- else \
- result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \
-} while (0)
-#else
-#define NEG_EXP( result, narg ) \
-do { \
- result = exp(-narg); \
-} while (0)
-#endif
-
-
-/**
- * Initialize the exp_table[] lookup table for approximating exp().
- */
-static void
-init_static_data( void )
-{
- GLfloat f = 0.0F;
- GLint i = 0;
- for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
- exp_table[i] = EXPF(-f);
- }
- inited = 1;
-}
-
-
-/**
- * Compute per-vertex fog blend factors from fog coordinates by
- * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
- * Fog coordinates are distances from the eye (typically between the
- * near and far clip plane distances).
- * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
- * Fog blend factors are in the range [0,1].
- */
-static void
-compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
-{
- GLfloat end = ctx->Fog.End;
- GLfloat *v = in->start;
- GLuint stride = in->stride;
- GLuint n = in->count;
- GLfloat (*data)[4] = out->data;
- GLfloat d;
- GLuint i;
-
- out->count = in->count;
-
- switch (ctx->Fog.Mode) {
- case GL_LINEAR:
- if (ctx->Fog.Start == ctx->Fog.End)
- d = 1.0F;
- else
- d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
- for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- const GLfloat z = FABSF(*v);
- GLfloat f = (end - z) * d;
- data[i][0] = CLAMP(f, 0.0F, 1.0F);
- }
- break;
- case GL_EXP:
- d = ctx->Fog.Density;
- for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
- const GLfloat z = FABSF(*v);
- NEG_EXP( data[i][0], d * z );
- }
- break;
- case GL_EXP2:
- d = ctx->Fog.Density*ctx->Fog.Density;
- for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- const GLfloat z = FABSF(*v);
- NEG_EXP( data[i][0], d * z * z );
- }
- break;
- default:
- _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
- return;
- }
-}
-
-
-static GLboolean
-run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- struct fog_stage_data *store = FOG_STAGE_DATA(stage);
- GLvector4f *input;
-
- if (!ctx->Fog.Enabled || ctx->VertexProgram._Enabled)
- return GL_TRUE;
-
-
- if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
- /* Fog is computed from vertex or fragment Z values */
- /* source = VB->ObjPtr or VB->EyePtr coords */
- /* dest = VB->FogCoordPtr = fog stage private storage */
- VB->FogCoordPtr = &store->fogcoord;
-
- if (!ctx->_NeedEyeCoords) {
- /* compute fog coords from object coords */
- const GLfloat *m = ctx->ModelviewMatrixStack.Top->m;
- GLfloat plane[4];
-
- /* Use this to store calculated eye z values:
- */
- input = &store->fogcoord;
-
- /* NOTE: negate plane here so we get positive fog coords! */
- plane[0] = -m[2];
- plane[1] = -m[6];
- plane[2] = -m[10];
- plane[3] = -m[14];
- /* Full eye coords weren't required, just calculate the
- * eye Z values.
- */
- _mesa_dotprod_tab[VB->ObjPtr->size]( (GLfloat *) input->data,
- 4 * sizeof(GLfloat),
- VB->ObjPtr, plane );
-
- input->count = VB->ObjPtr->count;
- }
- else {
- /* fog coordinates = eye Z coordinates (use ABS later) */
- input = &store->input;
-
- if (VB->EyePtr->size < 2)
- _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 );
-
- input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]);
- input->start = VB->EyePtr->start+2;
- input->stride = VB->EyePtr->stride;
- input->count = VB->EyePtr->count;
- }
- }
- else {
- /* use glFogCoord() coordinates */
- input = VB->FogCoordPtr; /* source data */
-
- /* input->count may be one if glFogCoord was only called once
- * before glBegin. But we need to compute fog for all vertices.
- */
- input->count = VB->ObjPtr->count;
-
- VB->FogCoordPtr = &store->fogcoord; /* dest data */
- }
-
- if (tnl->_DoVertexFog) {
- /* compute blend factors from fog coordinates */
- compute_fog_blend_factors( ctx, VB->FogCoordPtr, input );
- }
- else {
- /* results = incoming fog coords (compute fog per-fragment later) */
- VB->FogCoordPtr = input;
- }
-
- VB->AttribPtr[_TNL_ATTRIB_FOG] = VB->FogCoordPtr;
- return GL_TRUE;
-}
-
-
-
-/* Called the first time stage->run() is invoked.
- */
-static GLboolean
-alloc_fog_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct fog_stage_data *store;
- stage->privatePtr = MALLOC(sizeof(*store));
- store = FOG_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- _mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 );
- _mesa_vector4f_init( &store->input, 0, NULL );
-
- if (!inited)
- init_static_data();
-
- return GL_TRUE;
-}
-
-
-static void
-free_fog_data(struct tnl_pipeline_stage *stage)
-{
- struct fog_stage_data *store = FOG_STAGE_DATA(stage);
- if (store) {
- _mesa_vector4f_free( &store->fogcoord );
- FREE( store );
- stage->privatePtr = NULL;
- }
-}
-
-
-const struct tnl_pipeline_stage _tnl_fog_coordinate_stage =
-{
- "build fog coordinates", /* name */
- NULL, /* private_data */
- alloc_fog_data, /* dtr */
- free_fog_data, /* dtr */
- NULL, /* check */
- run_fog_stage /* run -- initially set to init. */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c
deleted file mode 100644
index 1deab4d43..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * 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 "glheader.h"
-#include "colormac.h"
-#include "light.h"
-#include "macros.h"
-#include "imports.h"
-#include "simple_list.h"
-#include "mtypes.h"
-
-#include "math/m_translate.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-#define LIGHT_TWOSIDE 0x1
-#define LIGHT_MATERIAL 0x2
-#define MAX_LIGHT_FUNC 0x4
-
-typedef void (*light_func)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input );
-
-/**
- * Information for updating current material attributes from vertex color,
- * for GL_COLOR_MATERIAL.
- */
-struct material_cursor {
- const GLfloat *ptr; /* points to src vertex color (in VB array) */
- GLuint stride; /* stride to next vertex color (bytes) */
- GLfloat *current; /* points to material attribute to update */
- GLuint size; /* vertex/color size: 1, 2, 3 or 4 */
-};
-
-/**
- * Data private to this pipeline stage.
- */
-struct light_stage_data {
- GLvector4f Input;
- GLvector4f LitColor[2];
- GLvector4f LitSecondary[2];
- GLvector4f LitIndex[2];
- light_func *light_func_tab;
-
- struct material_cursor mat[MAT_ATTRIB_MAX];
- GLuint mat_count;
- GLuint mat_bitmask;
-};
-
-
-#define LIGHT_STAGE_DATA(stage) ((struct light_stage_data *)(stage->privatePtr))
-
-
-
-/**
- * In the case of colormaterial, the effected material attributes
- * should already have been bound to point to the incoming color data,
- * prior to running the pipeline.
- * This function copies the vertex's color to the material attributes
- * which are tracking glColor.
- * It's called per-vertex in the lighting loop.
- */
-static void
-update_materials(GLcontext *ctx, struct light_stage_data *store)
-{
- GLuint i;
-
- for (i = 0 ; i < store->mat_count ; i++) {
- /* update the material */
- COPY_CLEAN_4V(store->mat[i].current, store->mat[i].size, store->mat[i].ptr);
- /* increment src vertex color pointer */
- STRIDE_F(store->mat[i].ptr, store->mat[i].stride);
- }
-
- /* recompute derived light/material values */
- _mesa_update_material( ctx, store->mat_bitmask );
- /* XXX we should only call this if we're tracking/changing the specular
- * exponent.
- */
- _mesa_validate_all_lighting_tables( ctx );
-}
-
-
-/**
- * Prepare things prior to running the lighting stage.
- * Return number of material attributes which will track vertex color.
- */
-static GLuint
-prepare_materials(GLcontext *ctx,
- struct vertex_buffer *VB, struct light_stage_data *store)
-{
- GLuint i;
-
- store->mat_count = 0;
- store->mat_bitmask = 0;
-
- /* Examine the ColorMaterialBitmask to determine which materials
- * track vertex color. Override the material attribute's pointer
- * with the color pointer for each one.
- */
- if (ctx->Light.ColorMaterialEnabled) {
- const GLuint bitmask = ctx->Light.ColorMaterialBitmask;
- for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
- if (bitmask & (1<<i))
- VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->ColorPtr[0];
- }
-
- /* Now, for each material attribute that's tracking vertex color, save
- * some values (ptr, stride, size, current) that we'll need in
- * update_materials(), above, that'll actually copy the vertex color to
- * the material attribute(s).
- */
- for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ; i < _TNL_ATTRIB_INDEX ; i++) {
- if (VB->AttribPtr[i]->stride) {
- const GLuint j = store->mat_count++;
- const GLuint attr = i - _TNL_ATTRIB_MAT_FRONT_AMBIENT;
- store->mat[j].ptr = VB->AttribPtr[i]->start;
- store->mat[j].stride = VB->AttribPtr[i]->stride;
- store->mat[j].size = VB->AttribPtr[i]->size;
- store->mat[j].current = ctx->Light.Material.Attrib[attr];
- store->mat_bitmask |= (1<<attr);
- }
- }
-
- /* FIXME: Is this already done?
- */
- _mesa_update_material( ctx, ~0 );
- _mesa_validate_all_lighting_tables( ctx );
-
- return store->mat_count;
-}
-
-/* Tables for all the shading functions.
- */
-static light_func _tnl_light_tab[MAX_LIGHT_FUNC];
-static light_func _tnl_light_fast_tab[MAX_LIGHT_FUNC];
-static light_func _tnl_light_fast_single_tab[MAX_LIGHT_FUNC];
-static light_func _tnl_light_spec_tab[MAX_LIGHT_FUNC];
-static light_func _tnl_light_ci_tab[MAX_LIGHT_FUNC];
-
-#define TAG(x) x
-#define IDX (0)
-#include "t_vb_lighttmp.h"
-
-#define TAG(x) x##_twoside
-#define IDX (LIGHT_TWOSIDE)
-#include "t_vb_lighttmp.h"
-
-#define TAG(x) x##_material
-#define IDX (LIGHT_MATERIAL)
-#include "t_vb_lighttmp.h"
-
-#define TAG(x) x##_twoside_material
-#define IDX (LIGHT_TWOSIDE|LIGHT_MATERIAL)
-#include "t_vb_lighttmp.h"
-
-
-static void init_lighting_tables( void )
-{
- static int done;
-
- if (!done) {
- init_light_tab();
- init_light_tab_twoside();
- init_light_tab_material();
- init_light_tab_twoside_material();
- done = 1;
- }
-}
-
-
-static GLboolean run_lighting( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr;
- GLuint idx;
-
- if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
- return GL_TRUE;
-
- /* Make sure we can talk about position x,y and z:
- */
- if (input->size <= 2 && input == VB->ObjPtr) {
-
- _math_trans_4f( store->Input.data,
- VB->ObjPtr->data,
- VB->ObjPtr->stride,
- GL_FLOAT,
- VB->ObjPtr->size,
- 0,
- VB->Count );
-
- if (input->size <= 2) {
- /* Clean z.
- */
- _mesa_vector4f_clean_elem(&store->Input, VB->Count, 2);
- }
-
- if (input->size <= 1) {
- /* Clean y.
- */
- _mesa_vector4f_clean_elem(&store->Input, VB->Count, 1);
- }
-
- input = &store->Input;
- }
-
- idx = 0;
-
- if (prepare_materials( ctx, VB, store ))
- idx |= LIGHT_MATERIAL;
-
- if (ctx->Light.Model.TwoSide)
- idx |= LIGHT_TWOSIDE;
-
- /* The individual functions know about replaying side-effects
- * vs. full re-execution.
- */
- store->light_func_tab[idx]( ctx, VB, stage, input );
-
- VB->AttribPtr[_TNL_ATTRIB_COLOR0] = VB->ColorPtr[0];
- VB->AttribPtr[_TNL_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
- VB->AttribPtr[_TNL_ATTRIB_INDEX] = VB->IndexPtr[0];
-
- return GL_TRUE;
-}
-
-
-/* Called in place of do_lighting when the light table may have changed.
- */
-static void validate_lighting( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- light_func *tab;
-
- if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
- return;
-
- if (ctx->Visual.rgbMode) {
- if (ctx->Light._NeedVertices) {
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
- tab = _tnl_light_spec_tab;
- else
- tab = _tnl_light_tab;
- }
- else {
- if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
- tab = _tnl_light_fast_single_tab;
- else
- tab = _tnl_light_fast_tab;
- }
- }
- else
- tab = _tnl_light_ci_tab;
-
-
- LIGHT_STAGE_DATA(stage)->light_func_tab = tab;
-
- /* This and the above should only be done on _NEW_LIGHT:
- */
- TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
-}
-
-
-
-/* Called the first time stage->run is called. In effect, don't
- * allocate data until the first time the stage is run.
- */
-static GLboolean init_lighting( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct light_stage_data *store;
- GLuint size = tnl->vb.Size;
-
- stage->privatePtr = MALLOC(sizeof(*store));
- store = LIGHT_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- /* Do onetime init.
- */
- init_lighting_tables();
-
- _mesa_vector4f_alloc( &store->Input, 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitColor[0], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitColor[1], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitSecondary[0], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitSecondary[1], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitIndex[0], 0, size, 32 );
- _mesa_vector4f_alloc( &store->LitIndex[1], 0, size, 32 );
-
- store->LitColor[0].size = 4;
- store->LitColor[1].size = 4;
- store->LitSecondary[0].size = 3;
- store->LitSecondary[1].size = 3;
-
- store->LitIndex[0].size = 1;
- store->LitIndex[0].stride = sizeof(GLfloat);
- store->LitIndex[1].size = 1;
- store->LitIndex[1].stride = sizeof(GLfloat);
-
- return GL_TRUE;
-}
-
-
-
-
-static void dtr( struct tnl_pipeline_stage *stage )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
-
- if (store) {
- _mesa_vector4f_free( &store->Input );
- _mesa_vector4f_free( &store->LitColor[0] );
- _mesa_vector4f_free( &store->LitColor[1] );
- _mesa_vector4f_free( &store->LitSecondary[0] );
- _mesa_vector4f_free( &store->LitSecondary[1] );
- _mesa_vector4f_free( &store->LitIndex[0] );
- _mesa_vector4f_free( &store->LitIndex[1] );
- FREE( store );
- stage->privatePtr = NULL;
- }
-}
-
-const struct tnl_pipeline_stage _tnl_lighting_stage =
-{
- "lighting", /* name */
- NULL, /* private_data */
- init_lighting,
- dtr, /* destroy */
- validate_lighting,
- run_lighting
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h
deleted file mode 100644
index a27f70842..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h
+++ /dev/null
@@ -1,824 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Authors:
- * Brian Paul
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#if IDX & LIGHT_TWOSIDE
-# define NR_SIDES 2
-#else
-# define NR_SIDES 1
-#endif
-
-
-/* define TRACE to trace lighting code */
-/* #define TRACE 1 */
-
-/*
- * ctx is the current context
- * VB is the vertex buffer
- * stage is the lighting stage-private data
- * input is the vector of eye or object-space vertex coordinates
- */
-static void TAG(light_rgba_spec)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- GLfloat (*base)[3] = ctx->Light._BaseColor;
- 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 (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
- GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data;
-#if IDX & LIGHT_TWOSIDE
- GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
- GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].data;
-#endif
-
- const GLuint nr = VB->Count;
-
-#ifdef TRACE
- fprintf(stderr, "%s\n", __FUNCTION__ );
-#endif
-
- VB->ColorPtr[0] = &store->LitColor[0];
- VB->SecondaryColorPtr[0] = &store->LitSecondary[0];
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-
-#if IDX & LIGHT_TWOSIDE
- VB->ColorPtr[1] = &store->LitColor[1];
- VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-#endif
-
-
- store->LitColor[0].stride = 16;
- store->LitColor[1].stride = 16;
-
- for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
- GLfloat sum[2][3], spec[2][3];
- struct gl_light *light;
-
-#if IDX & LIGHT_MATERIAL
- update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-#if IDX & LIGHT_TWOSIDE
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-#endif
-#endif
-
- COPY_3V(sum[0], base[0]);
- ZERO_3V(spec[0]);
-
-#if IDX & LIGHT_TWOSIDE
- COPY_3V(sum[1], base[1]);
- ZERO_3V(spec[1]);
-#endif
-
- /* Add contribution from each enabled light source */
- foreach (light, &ctx->Light.EnabledList) {
- GLfloat n_dot_h;
- GLfloat correction;
- GLint side;
- GLfloat contrib[3];
- GLfloat attenuation;
- GLfloat VP[3]; /* unit vector from vertex to light */
- GLfloat n_dot_VP; /* n dot VP */
- GLfloat *h;
-
- /* compute VP and attenuation */
- if (!(light->_Flags & LIGHT_POSITIONAL)) {
- /* directional light */
- COPY_3V(VP, light->_VP_inf_norm);
- attenuation = light->_VP_inf_spot_attenuation;
- }
- else {
- GLfloat d; /* distance from vertex to light */
-
- SUB_3V(VP, light->_Position, vertex);
-
- d = (GLfloat) LEN_3FV( VP );
-
- if (d > 1e-6) {
- GLfloat invd = 1.0F / d;
- SELF_SCALE_SCALAR_3V(VP, invd);
- }
-
- attenuation = 1.0F / (light->ConstantAttenuation + d *
- (light->LinearAttenuation + d *
- light->QuadraticAttenuation));
-
- /* spotlight attenuation */
- if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
-
- if (PV_dot_dir<light->_CosCutoff) {
- continue; /* this light makes no contribution */
- }
- else {
- GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- GLint k = (GLint) x;
- GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
- + (x-k)*light->_SpotExpTable[k][1]);
- attenuation *= spot;
- }
- }
- }
-
- if (attenuation < 1e-3)
- continue; /* this light makes no contribution */
-
- /* Compute dot product or normal and vector from V to light pos */
- n_dot_VP = DOT3( normal, VP );
-
- /* Which side gets the diffuse & specular terms? */
- if (n_dot_VP < 0.0F) {
- ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
-#if IDX & LIGHT_TWOSIDE
- side = 1;
- correction = -1;
- n_dot_VP = -n_dot_VP;
-#else
- continue;
-#endif
- }
- else {
-#if IDX & LIGHT_TWOSIDE
- ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
-#endif
- side = 0;
- correction = 1;
- }
-
- /* diffuse term */
- COPY_3V(contrib, light->_MatAmbient[side]);
- ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
- ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib );
-
- /* specular term - cannibalize VP... */
- if (ctx->Light.Model.LocalViewer) {
- GLfloat v[3];
- COPY_3V(v, vertex);
- NORMALIZE_3FV(v);
- SUB_3V(VP, VP, v); /* h = VP + VPe */
- h = VP;
- NORMALIZE_3FV(h);
- }
- else if (light->_Flags & LIGHT_POSITIONAL) {
- h = VP;
- ACC_3V(h, ctx->_EyeZDir);
- NORMALIZE_3FV(h);
- }
- else {
- h = light->_h_inf_norm;
- }
-
- n_dot_h = correction * DOT3(normal, h);
-
- if (n_dot_h > 0.0F) {
- GLfloat spec_coef;
- struct gl_shine_tab *tab = ctx->_ShineTable[side];
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
-
- if (spec_coef > 1.0e-10) {
- spec_coef *= attenuation;
- ACC_SCALE_SCALAR_3V( spec[side], spec_coef,
- light->_MatSpecular[side]);
- }
- }
- } /*loop over lights*/
-
- COPY_3V( Fcolor[j], sum[0] );
- COPY_3V( Fspec[j], spec[0] );
- Fcolor[j][3] = sumA[0];
-
-#if IDX & LIGHT_TWOSIDE
- COPY_3V( Bcolor[j], sum[1] );
- COPY_3V( Bspec[j], spec[1] );
- Bcolor[j][3] = sumA[1];
-#endif
- }
-}
-
-
-static void TAG(light_rgba)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- GLuint j;
-
- GLfloat (*base)[3] = ctx->Light._BaseColor;
- 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 (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
-#if IDX & LIGHT_TWOSIDE
- GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
-#endif
-
- const GLuint nr = VB->Count;
-
-#ifdef TRACE
- fprintf(stderr, "%s\n", __FUNCTION__ );
-#endif
-
- VB->ColorPtr[0] = &store->LitColor[0];
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-
-#if IDX & LIGHT_TWOSIDE
- VB->ColorPtr[1] = &store->LitColor[1];
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-#endif
-
- store->LitColor[0].stride = 16;
- store->LitColor[1].stride = 16;
-
- for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
- GLfloat sum[2][3];
- struct gl_light *light;
-
-#if IDX & LIGHT_MATERIAL
- update_materials( ctx, store );
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-#if IDX & LIGHT_TWOSIDE
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-#endif
-#endif
-
- COPY_3V(sum[0], base[0]);
-
-#if IDX & LIGHT_TWOSIDE
- COPY_3V(sum[1], base[1]);
-#endif
-
- /* Add contribution from each enabled light source */
- foreach (light, &ctx->Light.EnabledList) {
-
- GLfloat n_dot_h;
- GLfloat correction;
- GLint side;
- GLfloat contrib[3];
- GLfloat attenuation = 1.0;
- GLfloat VP[3]; /* unit vector from vertex to light */
- GLfloat n_dot_VP; /* n dot VP */
- GLfloat *h;
-
- /* compute VP and attenuation */
- if (!(light->_Flags & LIGHT_POSITIONAL)) {
- /* directional light */
- COPY_3V(VP, light->_VP_inf_norm);
- attenuation = light->_VP_inf_spot_attenuation;
- }
- else {
- GLfloat d; /* distance from vertex to light */
-
-
- SUB_3V(VP, light->_Position, vertex);
-
- d = (GLfloat) LEN_3FV( VP );
-
- if ( d > 1e-6) {
- GLfloat invd = 1.0F / d;
- SELF_SCALE_SCALAR_3V(VP, invd);
- }
-
- attenuation = 1.0F / (light->ConstantAttenuation + d *
- (light->LinearAttenuation + d *
- light->QuadraticAttenuation));
-
- /* spotlight attenuation */
- if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
-
- if (PV_dot_dir<light->_CosCutoff) {
- continue; /* this light makes no contribution */
- }
- else {
- GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- GLint k = (GLint) x;
- GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
- + (x-k)*light->_SpotExpTable[k][1]);
- attenuation *= spot;
- }
- }
- }
-
- if (attenuation < 1e-3)
- continue; /* this light makes no contribution */
-
- /* Compute dot product or normal and vector from V to light pos */
- n_dot_VP = DOT3( normal, VP );
-
- /* which side are we lighting? */
- if (n_dot_VP < 0.0F) {
- ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
-#if IDX & LIGHT_TWOSIDE
- side = 1;
- correction = -1;
- n_dot_VP = -n_dot_VP;
-#else
- continue;
-#endif
- }
- else {
-#if IDX & LIGHT_TWOSIDE
- ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
-#endif
- side = 0;
- correction = 1;
- }
-
- COPY_3V(contrib, light->_MatAmbient[side]);
-
- /* diffuse term */
- ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
-
- /* specular term - cannibalize VP... */
- {
- if (ctx->Light.Model.LocalViewer) {
- GLfloat v[3];
- COPY_3V(v, vertex);
- NORMALIZE_3FV(v);
- SUB_3V(VP, VP, v); /* h = VP + VPe */
- h = VP;
- NORMALIZE_3FV(h);
- }
- else if (light->_Flags & LIGHT_POSITIONAL) {
- h = VP;
- ACC_3V(h, ctx->_EyeZDir);
- NORMALIZE_3FV(h);
- }
- else {
- h = light->_h_inf_norm;
- }
-
- n_dot_h = correction * DOT3(normal, h);
-
- if (n_dot_h > 0.0F)
- {
- GLfloat spec_coef;
- struct gl_shine_tab *tab = ctx->_ShineTable[side];
-
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
-
- ACC_SCALE_SCALAR_3V( contrib, spec_coef,
- light->_MatSpecular[side]);
- }
- }
-
- ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
- }
-
- COPY_3V( Fcolor[j], sum[0] );
- Fcolor[j][3] = sumA[0];
-
-#if IDX & LIGHT_TWOSIDE
- COPY_3V( Bcolor[j], sum[1] );
- Bcolor[j][3] = sumA[1];
-#endif
- }
-}
-
-
-
-
-/* As below, but with just a single light.
- */
-static void TAG(light_fast_rgba_single)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input )
-
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
- GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
-#if IDX & LIGHT_TWOSIDE
- GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
-#endif
- const struct gl_light *light = ctx->Light.EnabledList.next;
- GLuint j = 0;
- GLfloat base[2][4];
-#if IDX & LIGHT_MATERIAL
- const GLuint nr = VB->Count;
-#else
- const GLuint nr = VB->NormalPtr->count;
-#endif
-
-#ifdef TRACE
- fprintf(stderr, "%s\n", __FUNCTION__ );
-#endif
-
- (void) input; /* doesn't refer to Eye or Obj */
-
- VB->ColorPtr[0] = &store->LitColor[0];
-#if IDX & LIGHT_TWOSIDE
- VB->ColorPtr[1] = &store->LitColor[1];
-#endif
-
- if (nr > 1) {
- store->LitColor[0].stride = 16;
- store->LitColor[1].stride = 16;
- }
- else {
- store->LitColor[0].stride = 0;
- store->LitColor[1].stride = 0;
- }
-
- for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
-
- GLfloat n_dot_VP;
-
-#if IDX & LIGHT_MATERIAL
- update_materials( ctx, store );
-#endif
-
- /* No attenuation, so incoporate _MatAmbient into base color.
- */
-#if !(IDX & LIGHT_MATERIAL)
- if ( j == 0 )
-#endif
- {
- COPY_3V(base[0], light->_MatAmbient[0]);
- ACC_3V(base[0], ctx->Light._BaseColor[0] );
- base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-
-#if IDX & LIGHT_TWOSIDE
- COPY_3V(base[1], light->_MatAmbient[1]);
- ACC_3V(base[1], ctx->Light._BaseColor[1]);
- base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-#endif
- }
-
- n_dot_VP = DOT3(normal, light->_VP_inf_norm);
-
- if (n_dot_VP < 0.0F) {
-#if IDX & LIGHT_TWOSIDE
- GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
- GLfloat sum[3];
- COPY_3V(sum, base[1]);
- ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
- if (n_dot_h > 0.0F) {
- GLfloat spec;
- GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
- ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
- }
- COPY_3V(Bcolor[j], sum );
- Bcolor[j][3] = base[1][3];
-#endif
- COPY_4FV(Fcolor[j], base[0]);
- }
- else {
- GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm);
- GLfloat sum[3];
- COPY_3V(sum, base[0]);
- ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]);
- if (n_dot_h > 0.0F) {
- GLfloat spec;
- GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
- ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
-
- }
- COPY_3V(Fcolor[j], sum );
- Fcolor[j][3] = base[0][3];
-#if IDX & LIGHT_TWOSIDE
- COPY_4FV(Bcolor[j], base[1]);
-#endif
- }
- }
-}
-
-
-/* Light infinite lights
- */
-static void TAG(light_fast_rgba)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- GLfloat sumA[2];
- const GLuint nstride = VB->NormalPtr->stride;
- const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
- GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
-#if IDX & LIGHT_TWOSIDE
- GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
-#endif
- GLuint j = 0;
-#if IDX & LIGHT_MATERIAL
- const GLuint nr = VB->Count;
-#else
- const GLuint nr = VB->NormalPtr->count;
-#endif
- const struct gl_light *light;
-
-#ifdef TRACE
- fprintf(stderr, "%s %d\n", __FUNCTION__, nr );
-#endif
-
- (void) input;
-
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-
- VB->ColorPtr[0] = &store->LitColor[0];
-#if IDX & LIGHT_TWOSIDE
- VB->ColorPtr[1] = &store->LitColor[1];
-#endif
-
- if (nr > 1) {
- store->LitColor[0].stride = 16;
- store->LitColor[1].stride = 16;
- }
- else {
- store->LitColor[0].stride = 0;
- store->LitColor[1].stride = 0;
- }
-
- for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
-
- GLfloat sum[2][3];
-
-#if IDX & LIGHT_MATERIAL
- update_materials( ctx, store );
-
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-#if IDX & LIGHT_TWOSIDE
- sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
-#endif
-#endif
-
-
- COPY_3V(sum[0], ctx->Light._BaseColor[0]);
-#if IDX & LIGHT_TWOSIDE
- COPY_3V(sum[1], ctx->Light._BaseColor[1]);
-#endif
-
- foreach (light, &ctx->Light.EnabledList) {
- GLfloat n_dot_h, n_dot_VP, spec;
-
- ACC_3V(sum[0], light->_MatAmbient[0]);
-#if IDX & LIGHT_TWOSIDE
- ACC_3V(sum[1], light->_MatAmbient[1]);
-#endif
-
- n_dot_VP = DOT3(normal, light->_VP_inf_norm);
-
- if (n_dot_VP > 0.0F) {
- ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]);
- n_dot_h = DOT3(normal, light->_h_inf_norm);
- if (n_dot_h > 0.0F) {
- struct gl_shine_tab *tab = ctx->_ShineTable[0];
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
- ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]);
- }
- }
-#if IDX & LIGHT_TWOSIDE
- else {
- ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]);
- n_dot_h = -DOT3(normal, light->_h_inf_norm);
- if (n_dot_h > 0.0F) {
- struct gl_shine_tab *tab = ctx->_ShineTable[1];
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
- ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]);
- }
- }
-#endif
- }
-
- COPY_3V( Fcolor[j], sum[0] );
- Fcolor[j][3] = sumA[0];
-
-#if IDX & LIGHT_TWOSIDE
- COPY_3V( Bcolor[j], sum[1] );
- Bcolor[j][3] = sumA[1];
-#endif
- }
-}
-
-
-
-
-
-/*
- * Use current lighting/material settings to compute the color indexes
- * for an array of vertices.
- * Input: n - number of vertices to light
- * side - 0=use front material, 1=use back material
- * vertex - array of [n] vertex position in eye coordinates
- * normal - array of [n] surface normal vector
- * Output: indexResult - resulting array of [n] color indexes
- */
-static void TAG(light_ci)( GLcontext *ctx,
- struct vertex_buffer *VB,
- struct tnl_pipeline_stage *stage,
- GLvector4f *input )
-{
- struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
- 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 *indexResult[2];
- const GLuint nr = VB->Count;
-
-#ifdef TRACE
- fprintf(stderr, "%s\n", __FUNCTION__ );
-#endif
-
- VB->IndexPtr[0] = &store->LitIndex[0];
-#if IDX & LIGHT_TWOSIDE
- VB->IndexPtr[1] = &store->LitIndex[1];
-#endif
-
- indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data;
-#if IDX & LIGHT_TWOSIDE
- indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
-#endif
-
- /* loop over vertices */
- for (j=0; j<nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal, nstride)) {
- GLfloat diffuse[2], specular[2];
- GLuint side = 0;
- struct gl_light *light;
-
-#if IDX & LIGHT_MATERIAL
- update_materials( ctx, store );
-#endif
-
- diffuse[0] = specular[0] = 0.0F;
-
-#if IDX & LIGHT_TWOSIDE
- diffuse[1] = specular[1] = 0.0F;
-#endif
-
- /* Accumulate diffuse and specular from each light source */
- foreach (light, &ctx->Light.EnabledList) {
-
- GLfloat attenuation = 1.0F;
- GLfloat VP[3]; /* unit vector from vertex to light */
- GLfloat n_dot_VP; /* dot product of l and n */
- GLfloat *h, n_dot_h, correction = 1.0;
-
- /* compute l and attenuation */
- if (!(light->_Flags & LIGHT_POSITIONAL)) {
- /* directional light */
- COPY_3V(VP, light->_VP_inf_norm);
- }
- else {
- GLfloat d; /* distance from vertex to light */
-
- SUB_3V(VP, light->_Position, vertex);
-
- d = (GLfloat) LEN_3FV( VP );
- if ( d > 1e-6) {
- GLfloat invd = 1.0F / d;
- SELF_SCALE_SCALAR_3V(VP, invd);
- }
-
- attenuation = 1.0F / (light->ConstantAttenuation + d *
- (light->LinearAttenuation + d *
- light->QuadraticAttenuation));
-
- /* spotlight attenuation */
- if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
- if (PV_dot_dir < light->_CosCutoff) {
- continue; /* this light makes no contribution */
- }
- else {
- GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
- GLint k = (GLint) x;
- GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
- + (x-k)*light->_SpotExpTable[k][1]);
- attenuation *= spot;
- }
- }
- }
-
- if (attenuation < 1e-3)
- continue; /* this light makes no contribution */
-
- n_dot_VP = DOT3( normal, VP );
-
- /* which side are we lighting? */
- if (n_dot_VP < 0.0F) {
-#if IDX & LIGHT_TWOSIDE
- side = 1;
- correction = -1;
- n_dot_VP = -n_dot_VP;
-#else
- continue;
-#endif
- }
-
- /* accumulate diffuse term */
- diffuse[side] += n_dot_VP * light->_dli * attenuation;
-
- /* specular term */
- if (ctx->Light.Model.LocalViewer) {
- GLfloat v[3];
- COPY_3V(v, vertex);
- NORMALIZE_3FV(v);
- SUB_3V(VP, VP, v); /* h = VP + VPe */
- h = VP;
- NORMALIZE_3FV(h);
- }
- else if (light->_Flags & LIGHT_POSITIONAL) {
- h = VP;
- /* Strangely, disabling this addition fixes a conformance
- * problem. If this code is enabled, l_sed.c fails.
- */
- /*ACC_3V(h, ctx->_EyeZDir);*/
- NORMALIZE_3FV(h);
- }
- else {
- h = light->_h_inf_norm;
- }
-
- n_dot_h = correction * DOT3(normal, h);
- if (n_dot_h > 0.0F) {
- GLfloat spec_coef;
- struct gl_shine_tab *tab = ctx->_ShineTable[side];
- GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef);
- specular[side] += spec_coef * light->_sli * attenuation;
- }
- } /*loop over lights*/
-
- /* Now compute final color index */
- for (side = 0 ; side < NR_SIDES ; side++) {
- const GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES + side];
- GLfloat index;
-
- if (specular[side] > 1.0F) {
- index = ind[MAT_INDEX_SPECULAR];
- }
- else {
- GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
- GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
- index = (ind[MAT_INDEX_AMBIENT]
- + diffuse[side] * (1.0F-specular[side]) * d_a
- + specular[side] * s_a);
- if (index > ind[MAT_INDEX_SPECULAR]) {
- index = ind[MAT_INDEX_SPECULAR];
- }
- }
- indexResult[side][j] = index;
- }
- } /*for vertex*/
-}
-
-
-
-static void TAG(init_light_tab)( void )
-{
- _tnl_light_tab[IDX] = TAG(light_rgba);
- _tnl_light_fast_tab[IDX] = TAG(light_fast_rgba);
- _tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single);
- _tnl_light_spec_tab[IDX] = TAG(light_rgba_spec);
- _tnl_light_ci_tab[IDX] = TAG(light_ci);
-}
-
-
-#undef TAG
-#undef IDX
-#undef NR_SIDES
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c
deleted file mode 100644
index 7ac33f8be..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-struct normal_stage_data {
- normal_func NormalTransform;
- GLvector4f normal;
-};
-
-#define NORMAL_STAGE_DATA(stage) ((struct normal_stage_data *)stage->privatePtr)
-
-
-static GLboolean
-run_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- const GLfloat *lengths;
-
- if (!store->NormalTransform)
- return GL_TRUE;
-
- /* We can only use the display list's saved normal lengths if we've
- * got a transformation matrix with uniform scaling.
- */
- if (_math_matrix_is_general_scale(ctx->ModelviewMatrixStack.Top))
- lengths = NULL;
- else
- lengths = VB->NormalLengthPtr;
-
- store->NormalTransform( ctx->ModelviewMatrixStack.Top,
- ctx->_ModelViewInvScale,
- VB->NormalPtr, /* input normals */
- lengths,
- &store->normal ); /* resulting normals */
-
- if (VB->NormalPtr->count > 1) {
- store->normal.stride = 4 * sizeof(GLfloat);
- }
- else {
- store->normal.stride = 0;
- }
-
- VB->NormalPtr = &store->normal;
- VB->AttribPtr[_TNL_ATTRIB_NORMAL] = VB->NormalPtr;
-
- VB->NormalLengthPtr = NULL; /* no longer valid */
- return GL_TRUE;
-}
-
-
-/**
- * Examine current GL state and set the store->NormalTransform pointer
- * to point to the appropriate normal transformation routine.
- */
-static void
-validate_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
-
- if (ctx->VertexProgram._Enabled ||
- (!ctx->Light.Enabled &&
- !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) {
- store->NormalTransform = NULL;
- return;
- }
-
- if (ctx->_NeedEyeCoords) {
- /* Eye coordinates are needed, for whatever reasons.
- * Do lighting in eye coordinates, as the GL spec says.
- */
- GLuint transform = NORM_TRANSFORM_NO_ROT;
-
- if (_math_matrix_has_rotation(ctx->ModelviewMatrixStack.Top)) {
- /* need to do full (3x3) matrix transform */
- transform = NORM_TRANSFORM;
- }
-
- if (ctx->Transform.Normalize) {
- store->NormalTransform = _mesa_normal_tab[transform | NORM_NORMALIZE];
- }
- else if (ctx->Transform.RescaleNormals &&
- ctx->_ModelViewInvScale != 1.0) {
- store->NormalTransform = _mesa_normal_tab[transform | NORM_RESCALE];
- }
- else {
- store->NormalTransform = _mesa_normal_tab[transform];
- }
- }
- else {
- /* We don't need eye coordinates.
- * Do lighting in object coordinates. Thus, we don't need to fully
- * transform normal vectors (just leave them in object coordinates)
- * but we still need to do normalization/rescaling if enabled.
- */
- if (ctx->Transform.Normalize) {
- store->NormalTransform = _mesa_normal_tab[NORM_NORMALIZE];
- }
- else if (!ctx->Transform.RescaleNormals &&
- ctx->_ModelViewInvScale != 1.0) {
- store->NormalTransform = _mesa_normal_tab[NORM_RESCALE];
- }
- else {
- store->NormalTransform = NULL;
- }
- }
-}
-
-
-/**
- * Allocate stage's private data (storage for transformed normals).
- */
-static GLboolean
-alloc_normal_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct normal_stage_data *store;
-
- stage->privatePtr = _mesa_malloc(sizeof(*store));
- store = NORMAL_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- _mesa_vector4f_alloc( &store->normal, 0, tnl->vb.Size, 32 );
- return GL_TRUE;
-}
-
-
-/**
- * Free stage's private data.
- */
-static void
-free_normal_data(struct tnl_pipeline_stage *stage)
-{
- struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
- if (store) {
- _mesa_vector4f_free( &store->normal );
- _mesa_free( store );
- stage->privatePtr = NULL;
- }
-}
-
-
-const struct tnl_pipeline_stage _tnl_normal_transform_stage =
-{
- "normal transform", /* name */
- NULL, /* privatePtr */
- alloc_normal_data, /* create */
- free_normal_data, /* destroy */
- validate_normal_stage, /* validate */
- run_normal_stage /* run */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c
deleted file mode 100644
index 47c37930d..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.5
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * 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:
- * Brian Paul
- */
-
-#include "mtypes.h"
-#include "imports.h"
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-struct point_stage_data {
- GLvector4f PointSize;
-};
-
-#define POINT_STAGE_DATA(stage) ((struct point_stage_data *)stage->privatePtr)
-
-
-/**
- * Compute point size for each vertex from the vertex eye-space Z
- * coordinate and the point size attenuation factors.
- * Only done when point size attenuation is enabled and vertex program is
- * disabled.
- */
-static GLboolean
-run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- if (ctx->Point._Attenuated && !ctx->VertexProgram._Enabled) {
- struct point_stage_data *store = POINT_STAGE_DATA(stage);
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data;
- const GLfloat p0 = ctx->Point.Params[0];
- const GLfloat p1 = ctx->Point.Params[1];
- const GLfloat p2 = ctx->Point.Params[2];
- const GLfloat pointSize = ctx->Point.Size;
- GLfloat (*size)[4] = store->PointSize.data;
- GLuint i;
-
- for (i = 0; i < VB->Count; i++) {
- const GLfloat dist = FABSF(eye[i][2]);
- const GLfloat q = p0 + dist * (p1 + dist * p2);
- const GLfloat atten = (q != 0.0) ? SQRTF(1.0 / q) : 1.0;
- size[i][0] = pointSize * atten; /* clamping done in rasterization */
- }
-
- VB->PointSizePtr = &store->PointSize;
- VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->PointSize;
- }
-
- return GL_TRUE;
-}
-
-
-static GLboolean
-alloc_point_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct point_stage_data *store;
- stage->privatePtr = _mesa_malloc(sizeof(*store));
- store = POINT_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- _mesa_vector4f_alloc( &store->PointSize, 0, VB->Size, 32 );
- return GL_TRUE;
-}
-
-
-static void
-free_point_data(struct tnl_pipeline_stage *stage)
-{
- struct point_stage_data *store = POINT_STAGE_DATA(stage);
- if (store) {
- _mesa_vector4f_free( &store->PointSize );
- _mesa_free( store );
- stage->privatePtr = NULL;
- }
-}
-
-
-const struct tnl_pipeline_stage _tnl_point_attenuation_stage =
-{
- "point size attenuation", /* name */
- NULL, /* stage private data */
- alloc_point_data, /* alloc data */
- free_point_data, /* destructor */
- NULL,
- run_point_stage /* run */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c
deleted file mode 100644
index d77f5424c..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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_vb_program.c
- * \brief Pipeline stage for executing NVIDIA vertex programs.
- * \author Brian Paul, Keith Whitwell
- */
-
-
-#include "glheader.h"
-#include "api_noop.h"
-#include "colormac.h"
-#include "context.h"
-#include "dlist.h"
-#include "hash.h"
-#include "light.h"
-#include "macros.h"
-#include "imports.h"
-#include "simple_list.h"
-#include "mtypes.h"
-#include "nvvertprog.h"
-#include "nvvertexec.h"
-#include "nvprogram.h"
-
-#include "math/m_translate.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-
-/*!
- * Private storage for the vertex program pipeline stage.
- */
-struct vp_stage_data {
- /** The results of running the vertex program go into these arrays. */
- GLvector4f attribs[15];
-
- GLvector4f ndcCoords; /**< normalized device coords */
- GLubyte *clipmask; /**< clip flags */
- GLubyte ormask, andmask; /**< for clipping */
-};
-
-
-#define VP_STAGE_DATA(stage) ((struct vp_stage_data *)(stage->privatePtr))
-
-
-/**
- * This function executes vertex programs
- */
-static GLboolean
-run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vp_stage_data *store = VP_STAGE_DATA(stage);
- struct vertex_buffer *VB = &tnl->vb;
- struct vertex_program *program = ctx->VertexProgram.Current;
- GLuint i;
-
- if (!ctx->VertexProgram._Enabled ||
- !program->IsNVProgram)
- return GL_TRUE;
-
- /* load program parameter registers (they're read-only) */
- _mesa_init_vp_per_primitive_registers(ctx);
-
- for (i = 0; i < VB->Count; i++) {
- GLuint attr;
-
- _mesa_init_vp_per_vertex_registers(ctx);
-
-#if 0
- printf("Input %d: %f, %f, %f, %f\n", i,
- VB->AttribPtr[0]->data[i][0],
- VB->AttribPtr[0]->data[i][1],
- VB->AttribPtr[0]->data[i][2],
- VB->AttribPtr[0]->data[i][3]);
- printf(" color: %f, %f, %f, %f\n",
- VB->AttribPtr[3]->data[i][0],
- VB->AttribPtr[3]->data[i][1],
- VB->AttribPtr[3]->data[i][2],
- VB->AttribPtr[3]->data[i][3]);
- printf(" normal: %f, %f, %f, %f\n",
- VB->AttribPtr[2]->data[i][0],
- VB->AttribPtr[2]->data[i][1],
- VB->AttribPtr[2]->data[i][2],
- VB->AttribPtr[2]->data[i][3]);
-#endif
-
- /* the vertex array case */
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (program->InputsRead & (1 << attr)) {
- const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
- const GLuint size = VB->AttribPtr[attr]->size;
- const GLuint stride = VB->AttribPtr[attr]->stride;
- const GLfloat *data = (GLfloat *) (ptr + stride * i);
- COPY_CLEAN_4V(ctx->VertexProgram.Inputs[attr], size, data);
- }
- }
-
- /* execute the program */
- ASSERT(program);
- _mesa_exec_vertex_program(ctx, program);
-
- /* Fixup fog an point size results if needed */
- if (ctx->Fog.Enabled &&
- (program->OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
- ctx->VertexProgram.Outputs[VERT_RESULT_FOGC][0] = 1.0;
- }
-
- if (ctx->VertexProgram.PointSizeEnabled &&
- (program->OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
- ctx->VertexProgram.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
- }
-
- /* copy the output registers into the VB->attribs arrays */
- /* XXX (optimize) could use a conditional and smaller loop limit here */
- for (attr = 0; attr < 15; attr++) {
- COPY_4V(store->attribs[attr].data[i],
- ctx->VertexProgram.Outputs[attr]);
- }
- }
-
- /* Setup the VB pointers so that the next pipeline stages get
- * their data from the right place (the program output arrays).
- */
- VB->ClipPtr = &store->attribs[VERT_RESULT_HPOS];
- VB->ClipPtr->size = 4;
- VB->ClipPtr->count = VB->Count;
- VB->ColorPtr[0] = &store->attribs[VERT_RESULT_COL0];
- VB->ColorPtr[1] = &store->attribs[VERT_RESULT_BFC0];
- VB->SecondaryColorPtr[0] = &store->attribs[VERT_RESULT_COL1];
- VB->SecondaryColorPtr[1] = &store->attribs[VERT_RESULT_BFC1];
- VB->FogCoordPtr = &store->attribs[VERT_RESULT_FOGC];
- VB->PointSizePtr = &store->attribs[VERT_RESULT_PSIZ];
-
- VB->AttribPtr[VERT_ATTRIB_COLOR0] = VB->ColorPtr[0];
- VB->AttribPtr[VERT_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
- VB->AttribPtr[VERT_ATTRIB_FOG] = VB->FogCoordPtr;
- VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->attribs[VERT_RESULT_PSIZ];
-
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] =
- &store->attribs[VERT_RESULT_TEX0 + i];
- }
-
-
-
- /* Cliptest and perspective divide. Clip functions must clear
- * the clipmask.
- */
- store->ormask = 0;
- store->andmask = CLIP_ALL_BITS;
-
- if (tnl->NeedNdcCoords) {
- VB->NdcPtr =
- _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &store->ndcCoords,
- store->clipmask,
- &store->ormask,
- &store->andmask );
- }
- else {
- VB->NdcPtr = NULL;
- _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
- NULL,
- store->clipmask,
- &store->ormask,
- &store->andmask );
- }
-
- if (store->andmask) /* All vertices are outside the frustum */
- return GL_FALSE;
-
-
- /* This is where we'd do clip testing against the user-defined
- * clipping planes, but they're not supported by vertex programs.
- */
-
- VB->ClipOrMask = store->ormask;
- VB->ClipMask = store->clipmask;
-
- return GL_TRUE;
-}
-
-
-
-
-/**
- * Called the first time stage->run is called. In effect, don't
- * allocate data until the first time the stage is run.
- */
-static GLboolean init_vp( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &(tnl->vb);
- struct vp_stage_data *store;
- const GLuint size = VB->Size;
- GLuint i;
-
- stage->privatePtr = MALLOC(sizeof(*store));
- store = VP_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- /* Allocate arrays of vertex output values */
- for (i = 0; i < 15; i++) {
- _mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 );
- store->attribs[i].size = 4;
- }
-
- /* a few other misc allocations */
- _mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
- store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
-
- return GL_TRUE;
-}
-
-
-
-
-
-/**
- * Destructor for this pipeline stage.
- */
-static void dtr( struct tnl_pipeline_stage *stage )
-{
- struct vp_stage_data *store = VP_STAGE_DATA(stage);
-
- if (store) {
- GLuint i;
-
- /* free the vertex program result arrays */
- for (i = 0; i < VERT_RESULT_MAX; i++)
- _mesa_vector4f_free( &store->attribs[i] );
-
- /* free misc arrays */
- _mesa_vector4f_free( &store->ndcCoords );
- ALIGN_FREE( store->clipmask );
-
- FREE( store );
- stage->privatePtr = NULL;
- }
-}
-
-/**
- * Public description of this pipeline stage.
- */
-const struct tnl_pipeline_stage _tnl_vertex_program_stage =
-{
- "vertex-program",
- NULL, /* private_data */
- init_vp, /* create */
- dtr, /* destroy */
- NULL, /* validate */
- run_vp /* run -- initially set to ctr */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c
deleted file mode 100644
index 8c92ac0db..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c
+++ /dev/null
@@ -1,352 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-/*
- * Render whole vertex buffers, including projection of vertices from
- * clip space and clipping of primitives.
- *
- * This file makes calls to project vertices and to the point, line
- * and triangle rasterizers via the function pointers:
- *
- * context->Driver.Render.*
- *
- */
-
-
-#include "glheader.h"
-#include "context.h"
-#include "enums.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-#include "nvfragprog.h"
-#include "math/m_matrix.h"
-#include "math/m_xform.h"
-
-#include "t_pipeline.h"
-
-
-
-/**********************************************************************/
-/* Clip single primitives */
-/**********************************************************************/
-
-
-#define W(i) coord[i][3]
-#define Z(i) coord[i][2]
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 4
-#define TAG(x) x##_4
-#include "t_vb_cliptmp.h"
-
-
-
-/**********************************************************************/
-/* Clip and render whole begin/end objects */
-/**********************************************************************/
-
-#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
-#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
-#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
-
-
-#define CLIPMASK (CLIP_ALL_BITS|CLIP_CULL_BIT)
-
-
-/* Vertices, with the possibility of clipping.
- */
-#define RENDER_POINTS( start, count ) \
- tnl->Driver.Render.Points( ctx, start, count )
-
-#define RENDER_LINE( v1, v2 ) \
-do { \
- GLubyte c1 = mask[v1], c2 = mask[v2]; \
- GLubyte ormask = c1|c2; \
- if (!ormask) \
- LineFunc( ctx, v1, v2 ); \
- else if (!(c1 & c2 & CLIPMASK)) \
- clip_line_4( ctx, v1, v2, ormask ); \
-} while (0)
-
-#define RENDER_TRI( v1, v2, v3 ) \
-do { \
- GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
- GLubyte ormask = c1|c2|c3; \
- if (!ormask) \
- TriangleFunc( ctx, v1, v2, v3 ); \
- else if (!(c1 & c2 & c3 & CLIPMASK)) \
- clip_tri_4( ctx, v1, v2, v3, ormask ); \
-} while (0)
-
-#define RENDER_QUAD( v1, v2, v3, v4 ) \
-do { \
- GLubyte c1 = mask[v1], c2 = mask[v2]; \
- GLubyte c3 = mask[v3], c4 = mask[v4]; \
- GLubyte ormask = c1|c2|c3|c4; \
- if (!ormask) \
- QuadFunc( ctx, v1, v2, v3, v4 ); \
- else if (!(c1 & c2 & c3 & c4 & CLIPMASK)) \
- clip_quad_4( ctx, v1, v2, v3, v4, ormask ); \
-} while (0)
-
-
-#define LOCAL_VARS \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- struct vertex_buffer *VB = &tnl->vb; \
- const GLuint * const elt = VB->Elts; \
- const GLubyte *mask = VB->ClipMask; \
- const GLuint sz = VB->ClipPtr->size; \
- const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
- const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
- const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
- const GLboolean stipple = ctx->Line.StippleFlag; \
- (void) (LineFunc && TriangleFunc && QuadFunc); \
- (void) elt; (void) mask; (void) sz; (void) stipple;
-
-#define TAG(x) clip_##x##_verts
-#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
-#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
-#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
-#define PRESERVE_VB_DEFS
-#include "t_vb_rendertmp.h"
-
-
-
-/* Elts, with the possibility of clipping.
- */
-#undef ELT
-#undef TAG
-#define ELT(x) elt[x]
-#define TAG(x) clip_##x##_elts
-#include "t_vb_rendertmp.h"
-
-/* TODO: do this for all primitives, verts and elts:
- */
-static void clip_elt_triangles( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES];
- struct vertex_buffer *VB = &tnl->vb;
- const GLuint * const elt = VB->Elts;
- GLubyte *mask = VB->ClipMask;
- GLuint last = count-2;
- GLuint j;
- (void) flags;
-
- tnl->Driver.Render.PrimitiveNotify( ctx, GL_TRIANGLES );
-
- for (j=start; j < last; j+=3 ) {
- GLubyte c1 = mask[elt[j]];
- GLubyte c2 = mask[elt[j+1]];
- GLubyte c3 = mask[elt[j+2]];
- GLubyte ormask = c1|c2|c3;
- if (ormask) {
- if (start < j)
- render_tris( ctx, start, j, 0 );
- if (!(c1&c2&c3&CLIPMASK))
- clip_tri_4( ctx, elt[j], elt[j+1], elt[j+2], ormask );
- start = j+3;
- }
- }
-
- if (start < j)
- render_tris( ctx, start, j, 0 );
-}
-
-/**********************************************************************/
-/* Render whole begin/end objects */
-/**********************************************************************/
-
-#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
-#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
-#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
-
-
-/* Vertices, no clipping.
- */
-#define RENDER_POINTS( start, count ) \
- tnl->Driver.Render.Points( ctx, start, count )
-
-#define RENDER_LINE( v1, v2 ) \
- LineFunc( ctx, v1, v2 )
-
-#define RENDER_TRI( v1, v2, v3 ) \
- TriangleFunc( ctx, v1, v2, v3 )
-
-#define RENDER_QUAD( v1, v2, v3, v4 ) \
- QuadFunc( ctx, v1, v2, v3, v4 )
-
-#define TAG(x) _tnl_##x##_verts
-
-#define LOCAL_VARS \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- struct vertex_buffer *VB = &tnl->vb; \
- const GLuint * const elt = VB->Elts; \
- const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
- const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
- const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
- const GLboolean stipple = ctx->Line.StippleFlag; \
- (void) (LineFunc && TriangleFunc && QuadFunc); \
- (void) elt; (void) stipple
-
-#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
-#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
-#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
-#define RENDER_TAB_QUALIFIER
-#define PRESERVE_VB_DEFS
-#include "t_vb_rendertmp.h"
-
-
-/* Elts, no clipping.
- */
-#undef ELT
-#define TAG(x) _tnl_##x##_elts
-#define ELT(x) elt[x]
-#include "t_vb_rendertmp.h"
-
-
-/**********************************************************************/
-/* Helper functions for drivers */
-/**********************************************************************/
-
-void _tnl_RenderClippedPolygon( GLcontext *ctx, const GLuint *elts, GLuint n )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLuint *tmp = VB->Elts;
-
- VB->Elts = (GLuint *)elts;
- tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
- VB->Elts = tmp;
-}
-
-void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->Driver.Render.Line( ctx, ii, jj );
-}
-
-
-
-/**********************************************************************/
-/* Clip and render whole vertex buffers */
-/**********************************************************************/
-
-
-static GLboolean run_render( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- tnl_render_func *tab;
- GLint pass = 0;
-
- /* Allow the drivers to lock before projected verts are built so
- * that window coordinates are guarenteed not to change before
- * rendering.
- */
- ASSERT(tnl->Driver.Render.Start);
-
- tnl->Driver.Render.Start( ctx );
-
- ASSERT(tnl->Driver.Render.BuildVertices);
- ASSERT(tnl->Driver.Render.PrimitiveNotify);
- ASSERT(tnl->Driver.Render.Points);
- ASSERT(tnl->Driver.Render.Line);
- ASSERT(tnl->Driver.Render.Triangle);
- ASSERT(tnl->Driver.Render.Quad);
- ASSERT(tnl->Driver.Render.ResetLineStipple);
- ASSERT(tnl->Driver.Render.Interp);
- ASSERT(tnl->Driver.Render.CopyPV);
- ASSERT(tnl->Driver.Render.ClippedLine);
- ASSERT(tnl->Driver.Render.ClippedPolygon);
- ASSERT(tnl->Driver.Render.Finish);
-
- tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 );
-
- if (VB->ClipOrMask) {
- tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
- clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
- }
- else {
- tab = (VB->Elts ?
- tnl->Driver.Render.PrimTabElts :
- tnl->Driver.Render.PrimTabVerts);
- }
-
- do
- {
- GLuint i;
-
- for (i = 0 ; i < VB->PrimitiveCount ; i++)
- {
- GLuint prim = VB->Primitive[i].mode;
- GLuint start = VB->Primitive[i].start;
- GLuint length = VB->Primitive[i].count;
-
- assert((prim & 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(prim & PRIM_MODE_MASK),
- start, start+length);
-
- if (length)
- tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim );
- }
- } while (tnl->Driver.Render.Multipass &&
- tnl->Driver.Render.Multipass( ctx, ++pass ));
-
- tnl->Driver.Render.Finish( ctx );
-
- return GL_FALSE; /* finished the pipe */
-}
-
-
-/**********************************************************************/
-/* Render pipeline stage */
-/**********************************************************************/
-
-
-
-
-
-const struct tnl_pipeline_stage _tnl_render_stage =
-{
- "render", /* name */
- NULL, /* private data */
- NULL, /* creator */
- NULL, /* destructor */
- NULL, /* validate */
- run_render /* run */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h
deleted file mode 100644
index 3db94bc09..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h
+++ /dev/null
@@ -1,440 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#ifndef POSTFIX
-#define POSTFIX
-#endif
-
-#ifndef INIT
-#define INIT(x)
-#endif
-
-#ifndef NEED_EDGEFLAG_SETUP
-#define NEED_EDGEFLAG_SETUP 0
-#define EDGEFLAG_GET(a) 0
-#define EDGEFLAG_SET(a,b) (void)b
-#endif
-
-#ifndef RESET_STIPPLE
-#define RESET_STIPPLE
-#endif
-
-#ifndef RESET_OCCLUSION
-#define RESET_OCCLUSION
-#endif
-
-#ifndef TEST_PRIM_END
-#define TEST_PRIM_END(flags) (flags & PRIM_END)
-#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
-#endif
-
-#ifndef ELT
-#define ELT(x) x
-#endif
-
-#ifndef RENDER_TAB_QUALIFIER
-#define RENDER_TAB_QUALIFIER static
-#endif
-
-static void TAG(render_points)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- LOCAL_VARS;
- (void) flags;
-
- RESET_OCCLUSION;
- INIT(GL_POINTS);
- RENDER_POINTS( start, count );
- POSTFIX;
-}
-
-static void TAG(render_lines)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- RESET_OCCLUSION;
- INIT(GL_LINES);
- for (j=start+1; j<count; j+=2 ) {
- RESET_STIPPLE;
- RENDER_LINE( ELT(j-1), ELT(j) );
- }
- POSTFIX;
-}
-
-
-static void TAG(render_line_strip)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- RESET_OCCLUSION;
- INIT(GL_LINE_STRIP);
-
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- }
-
- for (j=start+1; j<count; j++ )
- RENDER_LINE( ELT(j-1), ELT(j) );
-
- POSTFIX;
-}
-
-
-static void TAG(render_line_loop)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint i;
- LOCAL_VARS;
-
- (void) flags;
-
- RESET_OCCLUSION;
- INIT(GL_LINE_LOOP);
-
- if (start+1 < count) {
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- RENDER_LINE( ELT(start), ELT(start+1) );
- }
-
- for ( i = start+2 ; i < count ; i++) {
- RENDER_LINE( ELT(i-1), ELT(i) );
- }
-
- if ( TEST_PRIM_END(flags)) {
- RENDER_LINE( ELT(count-1), ELT(start) );
- }
- }
-
- POSTFIX;
-}
-
-
-static void TAG(render_triangles)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_TRIANGLES);
- if (NEED_EDGEFLAG_SETUP) {
- for (j=start+2; j<count; j+=3) {
- /* Leave the edgeflags as supplied by the user.
- */
- RESET_STIPPLE;
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
- }
- } else {
- for (j=start+2; j<count; j+=3) {
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
- }
- }
- POSTFIX;
-}
-
-
-
-static void TAG(render_tri_strip)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- GLuint parity = 0;
- LOCAL_VARS;
-
- INIT(GL_TRIANGLE_STRIP);
- if (NEED_EDGEFLAG_SETUP) {
- for (j=start+2;j<count;j++,parity^=1) {
- GLuint ej2 = ELT(j-2+parity);
- GLuint ej1 = ELT(j-1-parity);
- GLuint ej = ELT(j);
- GLboolean ef2 = EDGEFLAG_GET( ej2 );
- GLboolean ef1 = EDGEFLAG_GET( ej1 );
- GLboolean ef = EDGEFLAG_GET( ej );
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- }
- EDGEFLAG_SET( ej2, GL_TRUE );
- EDGEFLAG_SET( ej1, GL_TRUE );
- EDGEFLAG_SET( ej, GL_TRUE );
- RENDER_TRI( ej2, ej1, ej );
- EDGEFLAG_SET( ej2, ef2 );
- EDGEFLAG_SET( ej1, ef1 );
- EDGEFLAG_SET( ej, ef );
- }
- } else {
- for (j=start+2; j<count ; j++, parity^=1) {
- RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
- }
- }
- POSTFIX;
-}
-
-
-static void TAG(render_tri_fan)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_TRIANGLE_FAN);
- if (NEED_EDGEFLAG_SETUP) {
- for (j=start+2;j<count;j++) {
- /* For trifans, all edges are boundary.
- */
- GLuint ejs = ELT(start);
- GLuint ej1 = ELT(j-1);
- GLuint ej = ELT(j);
- GLboolean efs = EDGEFLAG_GET( ejs );
- GLboolean ef1 = EDGEFLAG_GET( ej1 );
- GLboolean ef = EDGEFLAG_GET( ej );
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- }
- EDGEFLAG_SET( ejs, GL_TRUE );
- EDGEFLAG_SET( ej1, GL_TRUE );
- EDGEFLAG_SET( ej, GL_TRUE );
- RENDER_TRI( ejs, ej1, ej);
- EDGEFLAG_SET( ejs, efs );
- EDGEFLAG_SET( ej1, ef1 );
- EDGEFLAG_SET( ej, ef );
- }
- } else {
- for (j=start+2;j<count;j++) {
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
- }
- }
-
- POSTFIX;
-}
-
-
-static void TAG(render_poly)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j = start+2;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_POLYGON);
- if (NEED_EDGEFLAG_SETUP) {
- GLboolean efstart = EDGEFLAG_GET( ELT(start) );
- GLboolean efcount = EDGEFLAG_GET( ELT(count-1) );
-
- /* If the primitive does not begin here, the first edge
- * is non-boundary.
- */
- if (!TEST_PRIM_BEGIN(flags))
- EDGEFLAG_SET( ELT(start), GL_FALSE );
- else {
- RESET_STIPPLE;
- }
-
- /* If the primitive does not end here, the final edge is
- * non-boundary.
- */
- if (!TEST_PRIM_END(flags))
- EDGEFLAG_SET( ELT(count-1), GL_FALSE );
-
- /* Draw the first triangles (possibly zero)
- */
- if (j+1<count) {
- GLboolean ef = EDGEFLAG_GET( ELT(j) );
- EDGEFLAG_SET( ELT(j), GL_FALSE );
- RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
- EDGEFLAG_SET( ELT(j), ef );
- j++;
-
- /* Don't render the first edge again:
- */
- EDGEFLAG_SET( ELT(start), GL_FALSE );
-
- for (;j+1<count;j++) {
- GLboolean efj = EDGEFLAG_GET( ELT(j) );
- EDGEFLAG_SET( ELT(j), GL_FALSE );
- RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
- EDGEFLAG_SET( ELT(j), efj );
- }
- }
-
- /* Draw the last or only triangle
- */
- if (j < count)
- RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
-
- /* Restore the first and last edgeflags:
- */
- EDGEFLAG_SET( ELT(count-1), efcount );
- EDGEFLAG_SET( ELT(start), efstart );
-
- }
- else {
- for (j=start+2;j<count;j++) {
- RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
- }
- }
- POSTFIX;
-}
-
-static void TAG(render_quads)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_QUADS);
- if (NEED_EDGEFLAG_SETUP) {
- for (j=start+3; j<count; j+=4) {
- /* Use user-specified edgeflags for quads.
- */
- RESET_STIPPLE;
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
- }
- } else {
- for (j=start+3; j<count; j+=4) {
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
- }
- }
- POSTFIX;
-}
-
-static void TAG(render_quad_strip)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_QUAD_STRIP);
- if (NEED_EDGEFLAG_SETUP) {
- for (j=start+3;j<count;j+=2) {
- /* All edges are boundary. Set edgeflags to 1, draw the
- * quad, and restore them to the original values.
- */
- GLboolean ef3 = EDGEFLAG_GET( ELT(j-3) );
- GLboolean ef2 = EDGEFLAG_GET( ELT(j-2) );
- GLboolean ef1 = EDGEFLAG_GET( ELT(j-1) );
- GLboolean ef = EDGEFLAG_GET( ELT(j) );
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- }
- EDGEFLAG_SET( ELT(j-3), GL_TRUE );
- EDGEFLAG_SET( ELT(j-2), GL_TRUE );
- EDGEFLAG_SET( ELT(j-1), GL_TRUE );
- EDGEFLAG_SET( ELT(j), GL_TRUE );
- RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
- EDGEFLAG_SET( ELT(j-3), ef3 );
- EDGEFLAG_SET( ELT(j-2), ef2 );
- EDGEFLAG_SET( ELT(j-1), ef1 );
- EDGEFLAG_SET( ELT(j), ef );
- }
- } else {
- for (j=start+3;j<count;j+=2) {
- RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
- }
- }
- POSTFIX;
-}
-
-static void TAG(render_noop)( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- (void)(ctx && start && count && flags);
-}
-
-RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
- GLuint,
- GLuint,
- GLuint) =
-{
- TAG(render_points),
- TAG(render_lines),
- TAG(render_line_loop),
- TAG(render_line_strip),
- TAG(render_triangles),
- TAG(render_tri_strip),
- TAG(render_tri_fan),
- TAG(render_quads),
- TAG(render_quad_strip),
- TAG(render_poly),
- TAG(render_noop),
-};
-
-
-
-#ifndef PRESERVE_VB_DEFS
-#undef RENDER_TRI
-#undef RENDER_QUAD
-#undef RENDER_LINE
-#undef RENDER_POINTS
-#undef LOCAL_VARS
-#undef INIT
-#undef POSTFIX
-#undef RESET_STIPPLE
-#undef DBG
-#undef ELT
-#undef RENDER_TAB_QUALIFIER
-#endif
-
-#ifndef PRESERVE_TAG
-#undef TAG
-#endif
-
-#undef PRESERVE_VB_DEFS
-#undef PRESERVE_TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c
deleted file mode 100644
index 1af8e2ba4..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c
+++ /dev/null
@@ -1,611 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 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:
- * Brian Paul
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-/*
- * Regarding GL_NV_texgen_reflection:
- *
- * Portions of this software may use or implement intellectual
- * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
- * any and all warranties with respect to such intellectual property,
- * including any use thereof or modifications thereto.
- */
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-/***********************************************************************
- * Automatic texture coordinate generation (texgen) code.
- */
-
-
-struct texgen_stage_data;
-
-typedef void (*texgen_func)( GLcontext *ctx,
- struct texgen_stage_data *store,
- GLuint unit);
-
-
-struct texgen_stage_data {
-
- /* Per-texunit derived state.
- */
- GLuint TexgenSize[MAX_TEXTURE_COORD_UNITS];
- texgen_func TexgenFunc[MAX_TEXTURE_COORD_UNITS];
-
- /* Temporary values used in texgen.
- */
- GLfloat (*tmp_f)[3];
- GLfloat *tmp_m;
-
- /* Buffered outputs of the stage.
- */
- GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS];
-};
-
-
-#define TEXGEN_STAGE_DATA(stage) ((struct texgen_stage_data *)stage->privatePtr)
-
-
-
-static GLuint all_bits[5] = {
- 0,
- VEC_SIZE_1,
- VEC_SIZE_2,
- VEC_SIZE_3,
- VEC_SIZE_4,
-};
-
-#define VEC_SIZE_FLAGS (VEC_SIZE_1|VEC_SIZE_2|VEC_SIZE_3|VEC_SIZE_4)
-
-#define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP)
-#define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \
- TEXGEN_REFLECTION_MAP_NV)
-
-
-
-static void build_m3( GLfloat f[][3], GLfloat m[],
- const GLvector4f *normal,
- const GLvector4f *eye )
-{
- GLuint stride = eye->stride;
- GLfloat *coord = (GLfloat *)eye->start;
- GLuint count = eye->count;
- const GLfloat *norm = normal->start;
- GLuint i;
-
- for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(norm,normal->stride)) {
- GLfloat u[3], two_nu, fx, fy, fz;
- COPY_3V( u, coord );
- NORMALIZE_3FV( u );
- two_nu = 2.0F * DOT3(norm,u);
- fx = f[i][0] = u[0] - norm[0] * two_nu;
- fy = f[i][1] = u[1] - norm[1] * two_nu;
- fz = f[i][2] = u[2] - norm[2] * two_nu;
- m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
- if (m[i] != 0.0F) {
- m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
- }
- }
-}
-
-
-
-static void build_m2( GLfloat f[][3], GLfloat m[],
- const GLvector4f *normal,
- const GLvector4f *eye )
-{
- GLuint stride = eye->stride;
- GLfloat *coord = eye->start;
- GLuint count = eye->count;
-
- GLfloat *norm = normal->start;
- GLuint i;
-
- for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(norm,normal->stride)) {
- GLfloat u[3], two_nu, fx, fy, fz;
- COPY_2V( u, coord );
- u[2] = 0;
- NORMALIZE_3FV( u );
- two_nu = 2.0F * DOT3(norm,u);
- fx = f[i][0] = u[0] - norm[0] * two_nu;
- fy = f[i][1] = u[1] - norm[1] * two_nu;
- fz = f[i][2] = u[2] - norm[2] * two_nu;
- m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
- if (m[i] != 0.0F) {
- m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
- }
- }
-}
-
-
-
-typedef void (*build_m_func)( GLfloat f[][3],
- GLfloat m[],
- const GLvector4f *normal,
- const GLvector4f *eye );
-
-
-static build_m_func build_m_tab[5] = {
- NULL,
- NULL,
- build_m2,
- build_m3,
- build_m3
-};
-
-
-/* This is unusual in that we respect the stride of the output vector
- * (f). This allows us to pass in either a texcoord vector4f, or a
- * temporary vector3f.
- */
-static void build_f3( GLfloat *f,
- GLuint fstride,
- const GLvector4f *normal,
- const GLvector4f *eye )
-{
- GLuint stride = eye->stride;
- GLfloat *coord = eye->start;
- GLuint count = eye->count;
-
- GLfloat *norm = normal->start;
- GLuint i;
-
- for (i=0;i<count;i++) {
- GLfloat u[3], two_nu;
- COPY_3V( u, coord );
- NORMALIZE_3FV( u );
- two_nu = 2.0F * DOT3(norm,u);
- f[0] = u[0] - norm[0] * two_nu;
- f[1] = u[1] - norm[1] * two_nu;
- f[2] = u[2] - norm[2] * two_nu;
- STRIDE_F(coord,stride);
- STRIDE_F(f,fstride);
- STRIDE_F(norm, normal->stride);
- }
-}
-
-
-static void build_f2( GLfloat *f,
- GLuint fstride,
- const GLvector4f *normal,
- const GLvector4f *eye )
-{
- GLuint stride = eye->stride;
- GLfloat *coord = eye->start;
- GLuint count = eye->count;
- GLfloat *norm = normal->start;
- GLuint i;
-
- for (i=0;i<count;i++) {
-
- GLfloat u[3], two_nu;
- COPY_2V( u, coord );
- u[2] = 0;
- NORMALIZE_3FV( u );
- two_nu = 2.0F * DOT3(norm,u);
- f[0] = u[0] - norm[0] * two_nu;
- f[1] = u[1] - norm[1] * two_nu;
- f[2] = u[2] - norm[2] * two_nu;
-
- STRIDE_F(coord,stride);
- STRIDE_F(f,fstride);
- STRIDE_F(norm, normal->stride);
- }
-}
-
-typedef void (*build_f_func)( GLfloat *f,
- GLuint fstride,
- const GLvector4f *normal_vec,
- const GLvector4f *eye );
-
-
-
-/* Just treat 4-vectors as 3-vectors.
- */
-static build_f_func build_f_tab[5] = {
- NULL,
- NULL,
- build_f2,
- build_f3,
- build_f3
-};
-
-
-
-/* Special case texgen functions.
- */
-static void texgen_reflection_map_nv( GLcontext *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLvector4f *in = VB->TexCoordPtr[unit];
- GLvector4f *out = &store->texcoord[unit];
-
- build_f_tab[VB->EyePtr->size]( out->start,
- out->stride,
- VB->NormalPtr,
- VB->EyePtr );
-
- out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3;
- out->count = VB->Count;
- out->size = MAX2(in->size, 3);
- if (in->size == 4)
- _mesa_copy_tab[0x8]( out, in );
-}
-
-
-
-static void texgen_normal_map_nv( GLcontext *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLvector4f *in = VB->TexCoordPtr[unit];
- GLvector4f *out = &store->texcoord[unit];
- GLvector4f *normal = VB->NormalPtr;
- GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start;
- GLuint count = VB->Count;
- GLuint i;
- const GLfloat *norm = normal->start;
-
- for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) {
- texcoord[i][0] = norm[0];
- texcoord[i][1] = norm[1];
- texcoord[i][2] = norm[2];
- }
-
-
- out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3;
- out->count = count;
- out->size = MAX2(in->size, 3);
- if (in->size == 4)
- _mesa_copy_tab[0x8]( out, in );
-}
-
-
-static void texgen_sphere_map( GLcontext *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLvector4f *in = VB->TexCoordPtr[unit];
- GLvector4f *out = &store->texcoord[unit];
- GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start;
- GLuint count = VB->Count;
- GLuint i;
- GLfloat (*f)[3] = store->tmp_f;
- GLfloat *m = store->tmp_m;
-
- (build_m_tab[VB->EyePtr->size])( store->tmp_f,
- store->tmp_m,
- VB->NormalPtr,
- VB->EyePtr );
-
- out->size = MAX2(in->size,2);
-
- for (i=0;i<count;i++) {
- texcoord[i][0] = f[i][0] * m[i] + 0.5F;
- texcoord[i][1] = f[i][1] * m[i] + 0.5F;
- }
-
- out->count = count;
- out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_2;
- if (in->size > 2)
- _mesa_copy_tab[all_bits[in->size] & ~0x3]( out, in );
-}
-
-
-
-static void texgen( GLcontext *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLvector4f *in = VB->TexCoordPtr[unit];
- GLvector4f *out = &store->texcoord[unit];
- const 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 GLfloat *m = store->tmp_m;
- const GLuint count = VB->Count;
- GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data;
- GLfloat (*f)[3] = store->tmp_f;
- GLuint copy;
-
- if (texUnit->_GenFlags & TEXGEN_NEED_M) {
- build_m_tab[eye->size]( store->tmp_f, store->tmp_m, normal, eye );
- } else if (texUnit->_GenFlags & TEXGEN_NEED_F) {
- build_f_tab[eye->size]( (GLfloat *)store->tmp_f, 3, normal, eye );
- }
-
-
- out->size = MAX2(in->size, store->TexgenSize[unit]);
- out->flags |= (in->flags & VEC_SIZE_FLAGS) | texUnit->TexGenEnabled;
- out->count = count;
-
- copy = (all_bits[in->size] & ~texUnit->TexGenEnabled);
- if (copy)
- _mesa_copy_tab[copy]( out, in );
-
- if (texUnit->TexGenEnabled & S_BIT) {
- GLuint i;
- switch (texUnit->GenModeS) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data,
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlaneS );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data,
- sizeof(out->data[0]), eye,
- texUnit->EyePlaneS );
- break;
- case GL_SPHERE_MAP:
- for (i = 0; i < count; i++)
- texcoord[i][0] = f[i][0] * m[i] + 0.5F;
- break;
- case GL_REFLECTION_MAP_NV:
- for (i=0;i<count;i++)
- texcoord[i][0] = f[i][0];
- break;
- case GL_NORMAL_MAP_NV: {
- const GLfloat *norm = normal->start;
- for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) {
- texcoord[i][0] = norm[0];
- }
- break;
- }
- default:
- _mesa_problem(ctx, "Bad S texgen");
- }
- }
-
- if (texUnit->TexGenEnabled & T_BIT) {
- GLuint i;
- switch (texUnit->GenModeT) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( &(out->data[0][1]),
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlaneT );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( &(out->data[0][1]),
- sizeof(out->data[0]), eye,
- texUnit->EyePlaneT );
- break;
- case GL_SPHERE_MAP:
- for (i = 0; i < count; i++)
- texcoord[i][1] = f[i][1] * m[i] + 0.5F;
- break;
- case GL_REFLECTION_MAP_NV:
- for (i=0;i<count;i++)
- texcoord[i][1] = f[i][1];
- break;
- case GL_NORMAL_MAP_NV: {
- const GLfloat *norm = normal->start;
- for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) {
- texcoord[i][1] = norm[1];
- }
- break;
- }
- default:
- _mesa_problem(ctx, "Bad T texgen");
- }
- }
-
- if (texUnit->TexGenEnabled & R_BIT) {
- GLuint i;
- switch (texUnit->GenModeR) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( &(out->data[0][2]),
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlaneR );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( &(out->data[0][2]),
- sizeof(out->data[0]), eye,
- texUnit->EyePlaneR );
- break;
- case GL_REFLECTION_MAP_NV:
- for (i=0;i<count;i++)
- texcoord[i][2] = f[i][2];
- break;
- case GL_NORMAL_MAP_NV: {
- const GLfloat *norm = normal->start;
- for (i=0;i<count;i++,STRIDE_F(norm, normal->stride)) {
- texcoord[i][2] = norm[2];
- }
- break;
- }
- default:
- _mesa_problem(ctx, "Bad R texgen");
- }
- }
-
- if (texUnit->TexGenEnabled & Q_BIT) {
- switch (texUnit->GenModeQ) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( &(out->data[0][3]),
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlaneQ );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( &(out->data[0][3]),
- sizeof(out->data[0]), eye,
- texUnit->EyePlaneQ );
- break;
- default:
- _mesa_problem(ctx, "Bad Q texgen");
- }
- }
-}
-
-
-
-
-static GLboolean run_texgen_stage( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
- GLuint i;
-
- if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
- return GL_TRUE;
-
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
-
- if (texUnit->TexGenEnabled) {
-
- store->TexgenFunc[i]( ctx, store, i );
-
- VB->AttribPtr[VERT_ATTRIB_TEX0+i] =
- VB->TexCoordPtr[i] = &store->texcoord[i];
- }
- }
-
- return GL_TRUE;
-}
-
-
-static void validate_texgen_stage( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
- GLuint i;
-
- if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
- return;
-
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
-
- if (texUnit->TexGenEnabled) {
- GLuint sz;
-
- if (texUnit->TexGenEnabled & Q_BIT)
- sz = 4;
- else if (texUnit->TexGenEnabled & R_BIT)
- sz = 3;
- else if (texUnit->TexGenEnabled & T_BIT)
- sz = 2;
- else
- sz = 1;
-
- store->TexgenSize[i] = sz;
- store->TexgenFunc[i] = texgen; /* general solution */
-
- /* look for special texgen cases */
- if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) {
- if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) {
- store->TexgenFunc[i] = texgen_reflection_map_nv;
- }
- else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) {
- store->TexgenFunc[i] = texgen_normal_map_nv;
- }
- }
- else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) &&
- texUnit->_GenFlags == TEXGEN_SPHERE_MAP) {
- store->TexgenFunc[i] = texgen_sphere_map;
- }
- }
- }
-}
-
-
-
-
-
-/* Called the first time stage->run() is invoked.
- */
-static GLboolean alloc_texgen_data( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct texgen_stage_data *store;
- GLuint i;
-
- stage->privatePtr = CALLOC(sizeof(*store));
- store = TEXGEN_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
- _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
-
- store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3);
- store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat));
-
- return GL_TRUE;
-}
-
-
-static void free_texgen_data( struct tnl_pipeline_stage *stage )
-
-{
- struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
- GLuint i;
-
- if (store) {
- for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++)
- if (store->texcoord[i].data)
- _mesa_vector4f_free( &store->texcoord[i] );
-
-
- if (store->tmp_f) FREE( store->tmp_f );
- if (store->tmp_m) FREE( store->tmp_m );
- FREE( store );
- stage->privatePtr = NULL;
- }
-}
-
-
-
-const struct tnl_pipeline_stage _tnl_texgen_stage =
-{
- "texgen", /* name */
- NULL, /* private data */
- alloc_texgen_data, /* destructor */
- free_texgen_data, /* destructor */
- validate_texgen_stage, /* check */
- run_texgen_stage /* run -- initially set to alloc data */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c
deleted file mode 100644
index 234753038..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-/* Is there any real benefit seperating texmat from texgen? It means
- * we need two lots of intermediate storage. Any changes to
- * _NEW_TEXTURE will invalidate both sets -- it's only on changes to
- * *only* _NEW_TEXTURE_MATRIX that texgen survives but texmat doesn't.
- *
- * However, the seperation of this code from the complex texgen stuff
- * is very appealing.
- */
-struct texmat_stage_data {
- GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS];
-};
-
-#define TEXMAT_STAGE_DATA(stage) ((struct texmat_stage_data *)stage->privatePtr)
-
-
-
-static GLboolean run_texmat_stage( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLuint i;
-
- if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Enabled)
- return GL_TRUE;
-
- /* ENABLE_TEXMAT implies that the texture matrix is not the
- * identity, so we don't have to check that here.
- */
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
- if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) {
- (void) TransformRaw( &store->texcoord[i],
- ctx->TextureMatrixStack[i].Top,
- VB->TexCoordPtr[i]);
-
- VB->AttribPtr[VERT_ATTRIB_TEX0+i] =
- VB->TexCoordPtr[i] = &store->texcoord[i];
- }
- }
-
- return GL_TRUE;
-}
-
-
-/* Called the first time stage->run() is invoked.
- */
-static GLboolean alloc_texmat_data( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct texmat_stage_data *store;
- GLuint i;
-
- stage->privatePtr = CALLOC(sizeof(*store));
- store = TEXMAT_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
- _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
-
- return GL_TRUE;
-}
-
-
-static void free_texmat_data( struct tnl_pipeline_stage *stage )
-{
- struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
- GLuint i;
-
- if (store) {
- for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
- if (store->texcoord[i].data)
- _mesa_vector4f_free( &store->texcoord[i] );
- FREE( store );
- stage->privatePtr = NULL;
- }
-}
-
-
-
-const struct tnl_pipeline_stage _tnl_texture_transform_stage =
-{
- "texture transform", /* name */
- NULL, /* private data */
- alloc_texmat_data,
- free_texmat_data, /* destructor */
- NULL,
- run_texmat_stage,
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c
deleted file mode 100644
index b3defaad0..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-#include "glheader.h"
-#include "colormac.h"
-#include "context.h"
-#include "macros.h"
-#include "imports.h"
-#include "mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-
-
-
-struct vertex_stage_data {
- GLvector4f eye;
- GLvector4f clip;
- GLvector4f proj;
- GLubyte *clipmask;
- GLubyte ormask;
- GLubyte andmask;
-};
-
-#define VERTEX_STAGE_DATA(stage) ((struct vertex_stage_data *)stage->privatePtr)
-
-
-
-
-/* This function implements cliptesting for user-defined clip planes.
- * The clipping of primitives to these planes is implemented in
- * t_render_clip.h.
- */
-#define USER_CLIPTEST(NAME, SZ) \
-static void NAME( GLcontext *ctx, \
- GLvector4f *clip, \
- GLubyte *clipmask, \
- GLubyte *clipormask, \
- GLubyte *clipandmask ) \
-{ \
- GLuint p; \
- \
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) \
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { \
- GLuint nr, i; \
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; \
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; \
- GLfloat *coord = (GLfloat *)clip->data; \
- GLuint stride = clip->stride; \
- GLuint count = clip->count; \
- \
- for (nr = 0, i = 0 ; i < count ; i++) { \
- GLfloat dp = coord[0] * a + coord[1] * b; \
- if (SZ > 2) dp += coord[2] * c; \
- if (SZ > 3) dp += coord[3] * d; else dp += d; \
- \
- if (dp < 0) { \
- nr++; \
- clipmask[i] |= CLIP_USER_BIT; \
- } \
- \
- STRIDE_F(coord, stride); \
- } \
- \
- if (nr > 0) { \
- *clipormask |= CLIP_USER_BIT; \
- if (nr == count) { \
- *clipandmask |= CLIP_USER_BIT; \
- return; \
- } \
- } \
- } \
-}
-
-
-USER_CLIPTEST(userclip2, 2)
-USER_CLIPTEST(userclip3, 3)
-USER_CLIPTEST(userclip4, 4)
-
-static void (*(usercliptab[5]))( GLcontext *,
- GLvector4f *, GLubyte *,
- GLubyte *, GLubyte * ) =
-{
- NULL,
- NULL,
- userclip2,
- userclip3,
- userclip4
-};
-
-
-
-static GLboolean run_vertex_stage( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_stage_data *store = (struct vertex_stage_data *)stage->privatePtr;
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
-
- if (ctx->VertexProgram._Enabled)
- return GL_TRUE;
-
- if (ctx->_NeedEyeCoords) {
- /* Separate modelview transformation:
- * Use combined ModelProject to avoid some depth artifacts
- */
- if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
- VB->EyePtr = VB->ObjPtr;
- else
- VB->EyePtr = TransformRaw( &store->eye,
- ctx->ModelviewMatrixStack.Top,
- VB->ObjPtr);
- }
-
- VB->ClipPtr = TransformRaw( &store->clip,
- &ctx->_ModelProjectMatrix,
- VB->ObjPtr );
-
- /* Drivers expect this to be clean to element 4...
- */
- switch (VB->ClipPtr->size) {
- case 1:
- /* impossible */
- case 2:
- _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 );
- /* fall-through */
- case 3:
- _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 );
- /* fall-through */
- case 4:
- break;
- }
-
-
- /* Cliptest and perspective divide. Clip functions must clear
- * the clipmask.
- */
- store->ormask = 0;
- store->andmask = CLIP_ALL_BITS;
-
- if (tnl->NeedNdcCoords) {
- VB->NdcPtr =
- _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &store->proj,
- store->clipmask,
- &store->ormask,
- &store->andmask );
- }
- else {
- VB->NdcPtr = NULL;
- _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
- NULL,
- store->clipmask,
- &store->ormask,
- &store->andmask );
- }
-
- if (store->andmask)
- return GL_FALSE;
-
-
- /* Test userclip planes. This contributes to VB->ClipMask, so
- * is essentially required to be in this stage.
- */
- if (ctx->Transform.ClipPlanesEnabled) {
- usercliptab[VB->ClipPtr->size]( ctx,
- VB->ClipPtr,
- store->clipmask,
- &store->ormask,
- &store->andmask );
-
- if (store->andmask)
- return GL_FALSE;
- }
-
- VB->ClipAndMask = store->andmask;
- VB->ClipOrMask = store->ormask;
- VB->ClipMask = store->clipmask;
-
- return GL_TRUE;
-}
-
-
-static GLboolean init_vertex_stage( GLcontext *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct vertex_stage_data *store;
- GLuint size = VB->Size;
-
- stage->privatePtr = CALLOC(sizeof(*store));
- store = VERTEX_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- _mesa_vector4f_alloc( &store->eye, 0, size, 32 );
- _mesa_vector4f_alloc( &store->clip, 0, size, 32 );
- _mesa_vector4f_alloc( &store->proj, 0, size, 32 );
-
- store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
-
- if (!store->clipmask ||
- !store->eye.data ||
- !store->clip.data ||
- !store->proj.data)
- return GL_FALSE;
-
- return GL_TRUE;
-}
-
-static void dtr( struct tnl_pipeline_stage *stage )
-{
- struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage);
-
- if (store) {
- _mesa_vector4f_free( &store->eye );
- _mesa_vector4f_free( &store->clip );
- _mesa_vector4f_free( &store->proj );
- ALIGN_FREE( store->clipmask );
- FREE(store);
- stage->privatePtr = NULL;
- stage->run = init_vertex_stage;
- }
-}
-
-
-const struct tnl_pipeline_stage _tnl_vertex_transform_stage =
-{
- "modelview/project/cliptest/divide",
- NULL, /* private data */
- init_vertex_stage,
- dtr, /* destructor */
- NULL,
- run_vertex_stage /* run -- initially set to init */
-};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c
deleted file mode 100644
index ca3aad140..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c
+++ /dev/null
@@ -1,509 +0,0 @@
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * 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
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, 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 (including the next
- * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS 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@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "colormac.h"
-
-#include "t_context.h"
-#include "t_vertex.h"
-
-#define DBG 0
-
-/* Build and manage clipspace/ndc/window vertices.
- */
-
-static GLboolean match_fastpath( struct tnl_clipspace *vtx,
- const struct tnl_clipspace_fastpath *fp)
-{
- GLuint j;
-
- if (vtx->attr_count != fp->attr_count)
- return GL_FALSE;
-
- for (j = 0; j < vtx->attr_count; j++)
- if (vtx->attr[j].format != fp->attr[j].format ||
- vtx->attr[j].inputsize != fp->attr[j].size ||
- vtx->attr[j].vertoffset != fp->attr[j].offset)
- return GL_FALSE;
-
- if (fp->match_strides) {
- if (vtx->vertex_size != fp->vertex_size)
- return GL_FALSE;
-
- for (j = 0; j < vtx->attr_count; j++)
- if (vtx->attr[j].inputstride != fp->attr[j].stride)
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
-static GLboolean search_fastpath_emit( struct tnl_clipspace *vtx )
-{
- struct tnl_clipspace_fastpath *fp = vtx->fastpath;
-
- for ( ; fp ; fp = fp->next) {
- if (match_fastpath(vtx, fp)) {
- vtx->emit = fp->func;
- return GL_TRUE;
- }
- }
-
- return GL_FALSE;
-}
-
-void _tnl_register_fastpath( struct tnl_clipspace *vtx,
- GLboolean match_strides )
-{
- struct tnl_clipspace_fastpath *fastpath = CALLOC_STRUCT(tnl_clipspace_fastpath);
- GLuint i;
-
- fastpath->vertex_size = vtx->vertex_size;
- fastpath->attr_count = vtx->attr_count;
- fastpath->match_strides = match_strides;
- fastpath->func = vtx->emit;
- fastpath->attr = MALLOC(vtx->attr_count * sizeof(fastpath->attr[0]));
-
- for (i = 0; i < vtx->attr_count; i++) {
- fastpath->attr[i].format = vtx->attr[i].format;
- fastpath->attr[i].stride = vtx->attr[i].inputstride;
- fastpath->attr[i].size = vtx->attr[i].inputsize;
- fastpath->attr[i].offset = vtx->attr[i].vertoffset;
- }
-
- fastpath->next = vtx->fastpath;
- vtx->fastpath = fastpath;
-}
-
-
-
-/***********************************************************************
- * Build codegen functions or return generic ones:
- */
-static void choose_emit_func( GLcontext *ctx, GLuint count, GLubyte *dest)
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint attr_count = vtx->attr_count;
- GLuint j;
-
- for (j = 0; j < attr_count; j++) {
- GLvector4f *vptr = VB->AttribPtr[a[j].attrib];
- a[j].inputstride = vptr->stride;
- a[j].inputsize = vptr->size;
- a[j].emit = a[j].insert[vptr->size - 1]; /* not always used */
- }
-
- vtx->emit = NULL;
-
- /* Does this match an existing (hardwired, codegen or known-bad)
- * fastpath?
- */
- if (search_fastpath_emit(vtx)) {
- /* Use this result. If it is null, then it is already known
- * that the current state will fail for codegen and there is no
- * point trying again.
- */
- }
- else if (vtx->codegen_emit) {
- vtx->codegen_emit(ctx);
- }
-
- if (!vtx->emit) {
- _tnl_generate_hardwired_emit(ctx);
- }
-
- /* Otherwise use the generic version:
- */
- if (!vtx->emit)
- vtx->emit = _tnl_generic_emit;
-
- vtx->emit( ctx, count, dest );
-}
-
-
-
-static void choose_interp_func( GLcontext *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
-
- if (vtx->need_extras &&
- (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
- vtx->interp = _tnl_generic_interp_extras;
- } else {
- vtx->interp = _tnl_generic_interp;
- }
-
- vtx->interp( ctx, t, edst, eout, ein, force_boundary );
-}
-
-
-static void choose_copy_pv_func( GLcontext *ctx, GLuint edst, GLuint esrc )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
-
- if (vtx->need_extras &&
- (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
- vtx->copy_pv = _tnl_generic_copy_pv_extras;
- } else {
- vtx->copy_pv = _tnl_generic_copy_pv;
- }
-
- vtx->copy_pv( ctx, edst, esrc );
-}
-
-
-/***********************************************************************
- * Public entrypoints, mostly dispatch to the above:
- */
-
-
-/* Interpolate between two vertices to produce a third:
- */
-void _tnl_interp( GLcontext *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- vtx->interp( ctx, t, edst, eout, ein, force_boundary );
-}
-
-/* Copy colors from one vertex to another:
- */
-void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- vtx->copy_pv( ctx, edst, esrc );
-}
-
-
-/* Extract a named attribute from a hardware vertex. Will have to
- * reverse any viewport transformation, swizzling or other conversions
- * which may have been applied:
- */
-void _tnl_get_attr( GLcontext *ctx, const void *vin,
- GLenum attr, GLfloat *dest )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- const struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint attr_count = vtx->attr_count;
- GLuint j;
-
- for (j = 0; j < attr_count; j++) {
- if (a[j].attrib == attr) {
- a[j].extract( &a[j], dest, (GLubyte *)vin + a[j].vertoffset );
- return;
- }
- }
-
- /* Else return the value from ctx->Current.
- */
- _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat));
-}
-
-
-/* Complementary operation to the above.
- */
-void _tnl_set_attr( GLcontext *ctx, void *vout,
- GLenum attr, const GLfloat *src )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- const struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint attr_count = vtx->attr_count;
- GLuint j;
-
- for (j = 0; j < attr_count; j++) {
- if (a[j].attrib == attr) {
- a[j].insert[4-1]( &a[j], (GLubyte *)vout + a[j].vertoffset, src );
- return;
- }
- }
-}
-
-
-void *_tnl_get_vertex( GLcontext *ctx, GLuint nr )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
-
- return vtx->vertex_buf + nr * vtx->vertex_size;
-}
-
-void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state )
-{
- if (new_state & (_DD_NEW_TRI_LIGHT_TWOSIDE|_DD_NEW_TRI_UNFILLED) ) {
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- vtx->new_inputs = ~0;
- vtx->interp = choose_interp_func;
- vtx->copy_pv = choose_copy_pv_func;
- }
-}
-
-static void invalidate_funcs( struct tnl_clipspace *vtx )
-{
- vtx->emit = choose_emit_func;
- vtx->interp = choose_interp_func;
- vtx->copy_pv = choose_copy_pv_func;
- vtx->new_inputs = ~0;
-}
-
-GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map,
- GLuint nr, const GLfloat *vp,
- GLuint unpacked_size )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- GLuint offset = 0;
- GLuint i, j;
-
- assert(nr < _TNL_ATTRIB_MAX);
- assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS);
-
- vtx->new_inputs = ~0;
- vtx->need_viewport = GL_FALSE;
-
- if (vp) {
- vtx->need_viewport = GL_TRUE;
- }
-
- for (j = 0, i = 0; i < nr; i++) {
- const GLuint format = map[i].format;
- if (format == EMIT_PAD) {
- if (DBG)
- _mesa_printf("%d: pad %d, offset %d\n", i,
- map[i].offset, offset);
-
- offset += map[i].offset;
-
- }
- else {
- GLuint tmpoffset;
-
- if (unpacked_size)
- tmpoffset = map[i].offset;
- else
- tmpoffset = offset;
-
- if (vtx->attr_count != j ||
- vtx->attr[j].attrib != map[i].attrib ||
- vtx->attr[j].format != format ||
- vtx->attr[j].vertoffset != tmpoffset) {
- invalidate_funcs(vtx);
-
- vtx->attr[j].attrib = map[i].attrib;
- vtx->attr[j].format = format;
- vtx->attr[j].vp = vp;
- vtx->attr[j].insert = _tnl_format_info[format].insert;
- vtx->attr[j].extract = _tnl_format_info[format].extract;
- vtx->attr[j].vertattrsize = _tnl_format_info[format].attrsize;
- vtx->attr[j].vertoffset = tmpoffset;
- }
-
-
- if (DBG)
- _mesa_printf("%d: %s, vp %p, offset %d\n", i,
- _tnl_format_info[format].name, (void *)vp,
- vtx->attr[j].vertoffset);
-
- offset += _tnl_format_info[format].attrsize;
- j++;
- }
- }
-
- vtx->attr_count = j;
-
- if (unpacked_size)
- vtx->vertex_size = unpacked_size;
- else
- vtx->vertex_size = offset;
-
- assert(vtx->vertex_size <= vtx->max_vertex_size);
- return vtx->vertex_size;
-}
-
-
-
-void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- vtx->new_inputs |= newinputs;
-}
-
-
-/* This event has broader use beyond this file - will move elsewhere
- * and probably invoke a driver callback.
- */
-void _tnl_notify_pipeline_output_change( GLcontext *ctx )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- invalidate_funcs(vtx);
-}
-
-static void update_input_ptrs( GLcontext *ctx, GLuint start )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint count = vtx->attr_count;
- GLuint j;
-
- for (j = 0; j < count; j++) {
- GLvector4f *vptr = VB->AttribPtr[a[j].attrib];
-
- if (vtx->emit != choose_emit_func) {
- assert(a[j].inputstride == vptr->stride);
- assert(a[j].inputsize == vptr->size);
- }
-
- a[j].inputptr = ((GLubyte *)vptr->data) + start * vptr->stride;
- }
-
- if (a->vp) {
- vtx->vp_scale[0] = a->vp[MAT_SX];
- vtx->vp_scale[1] = a->vp[MAT_SY];
- vtx->vp_scale[2] = a->vp[MAT_SZ];
- vtx->vp_scale[3] = 1.0;
- vtx->vp_xlate[0] = a->vp[MAT_TX];
- vtx->vp_xlate[1] = a->vp[MAT_TY];
- vtx->vp_xlate[2] = a->vp[MAT_TZ];
- vtx->vp_xlate[3] = 0.0;
- }
-}
-
-
-void _tnl_build_vertices( GLcontext *ctx,
- GLuint start,
- GLuint end,
- GLuint newinputs )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- update_input_ptrs( ctx, start );
- vtx->emit( ctx, end - start,
- (GLubyte *)(vtx->vertex_buf +
- start * vtx->vertex_size));
-}
-
-/* Emit VB vertices start..end to dest. Note that VB vertex at
- * postion start will be emitted to dest at position zero.
- */
-void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
- GLuint start,
- GLuint end,
- void *dest )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
-
- update_input_ptrs(ctx, start);
-
- /* Note: dest should not be adjusted for non-zero 'start' values:
- */
- vtx->emit( ctx, end - start, dest );
- return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start));
-}
-
-
-void _tnl_init_vertices( GLcontext *ctx,
- GLuint vb_size,
- GLuint max_vertex_size )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
-
- _tnl_install_attrs( ctx, NULL, 0, NULL, 0 );
-
- vtx->need_extras = GL_TRUE;
- if (max_vertex_size > vtx->max_vertex_size) {
- _tnl_free_vertices( ctx );
- vtx->max_vertex_size = max_vertex_size;
- vtx->vertex_buf = (GLubyte *)ALIGN_CALLOC(vb_size * max_vertex_size, 32 );
- invalidate_funcs(vtx);
- }
-
- switch(CHAN_TYPE) {
- case GL_UNSIGNED_BYTE:
- vtx->chan_scale[0] = 255.0;
- vtx->chan_scale[1] = 255.0;
- vtx->chan_scale[2] = 255.0;
- vtx->chan_scale[3] = 255.0;
- break;
- case GL_UNSIGNED_SHORT:
- vtx->chan_scale[0] = 65535.0;
- vtx->chan_scale[1] = 65535.0;
- vtx->chan_scale[2] = 65535.0;
- vtx->chan_scale[3] = 65535.0;
- break;
- default:
- vtx->chan_scale[0] = 1.0;
- vtx->chan_scale[1] = 1.0;
- vtx->chan_scale[2] = 1.0;
- vtx->chan_scale[3] = 1.0;
- break;
- }
-
- vtx->identity[0] = 0.0;
- vtx->identity[1] = 0.0;
- vtx->identity[2] = 0.0;
- vtx->identity[3] = 1.0;
-
- vtx->codegen_emit = NULL;
-
-#ifdef USE_SSE_ASM
- if (!_mesa_getenv("MESA_NO_CODEGEN"))
- vtx->codegen_emit = _tnl_generate_sse_emit;
-#endif
-}
-
-
-void _tnl_free_vertices( GLcontext *ctx )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- struct tnl_clipspace_fastpath *fp, *tmp;
-
- if (vtx->vertex_buf) {
- ALIGN_FREE(vtx->vertex_buf);
- vtx->vertex_buf = NULL;
- }
-
- for (fp = vtx->fastpath ; fp ; fp = tmp) {
- tmp = fp->next;
- FREE(fp->attr);
-
- /* KW: At the moment, fp->func is constrained to be allocated by
- * _mesa_exec_alloc(), as the hardwired fastpaths in
- * t_vertex_generic.c are handled specially. It would be nice
- * to unify them, but this probably won't change until this
- * module gets another overhaul.
- */
- _mesa_exec_free((void *) fp->func);
- FREE(fp);
- }
-
- vtx->fastpath = NULL;
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h
deleted file mode 100644
index fda8f151d..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * 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
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, 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 (including the next
- * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS 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@tungstengraphics.com>
- */
-
-#ifndef _TNL_VERTEX_H
-#define _TNL_VERTEX_H
-
-#include "mtypes.h"
-#include "t_context.h"
-
-/* New mechanism to specify hardware vertices so that tnl can build
- * and manipulate them directly.
- */
-
-
-/* It will probably be necessary to allow drivers to specify new
- * emit-styles to cover all the wierd and wacky things out there.
- */
-enum tnl_attr_format {
- EMIT_1F,
- EMIT_2F,
- EMIT_3F,
- EMIT_4F,
- EMIT_2F_VIEWPORT, /* do viewport transform and emit */
- EMIT_3F_VIEWPORT, /* do viewport transform and emit */
- EMIT_4F_VIEWPORT, /* do viewport transform and emit */
- EMIT_3F_XYW, /* for projective texture */
- EMIT_1UB_1F, /* for fog coordinate */
- EMIT_3UB_3F_RGB, /* for specular color */
- EMIT_3UB_3F_BGR, /* for specular color */
- EMIT_4UB_4F_RGBA, /* for color */
- EMIT_4UB_4F_BGRA, /* for color */
- EMIT_4UB_4F_ARGB, /* for color */
- EMIT_4UB_4F_ABGR, /* for color */
- EMIT_4CHAN_4F_RGBA, /* for swrast color */
- EMIT_PAD, /* leave a hole of 'offset' bytes */
- EMIT_MAX
-};
-
-struct tnl_attr_map {
- GLuint attrib; /* _TNL_ATTRIB_ enum */
- enum tnl_attr_format format;
- GLuint offset;
-};
-
-struct tnl_format_info {
- const char *name;
- tnl_extract_func extract;
- tnl_insert_func insert[4];
- const GLuint attrsize;
-};
-
-extern const struct tnl_format_info _tnl_format_info[EMIT_MAX];
-
-
-/* Interpolate between two vertices to produce a third:
- */
-extern void _tnl_interp( GLcontext *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary );
-
-/* Copy colors from one vertex to another:
- */
-extern void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
-
-
-/* Extract a named attribute from a hardware vertex. Will have to
- * reverse any viewport transformation, swizzling or other conversions
- * which may have been applied:
- */
-extern void _tnl_get_attr( GLcontext *ctx, const void *vertex, GLenum attrib,
- GLfloat *dest );
-
-/* Complementary to the above.
- */
-extern void _tnl_set_attr( GLcontext *ctx, void *vout, GLenum attrib,
- const GLfloat *src );
-
-
-extern void *_tnl_get_vertex( GLcontext *ctx, GLuint nr );
-
-extern GLuint _tnl_install_attrs( GLcontext *ctx,
- const struct tnl_attr_map *map,
- GLuint nr, const GLfloat *vp,
- GLuint unpacked_size );
-
-extern void _tnl_free_vertices( GLcontext *ctx );
-
-extern void _tnl_init_vertices( GLcontext *ctx,
- GLuint vb_size,
- GLuint max_vertex_size );
-
-extern void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
- GLuint start,
- GLuint end,
- void *dest );
-
-extern void _tnl_build_vertices( GLcontext *ctx,
- GLuint start,
- GLuint end,
- GLuint newinputs );
-
-extern void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs );
-
-extern void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state );
-
-extern void _tnl_notify_pipeline_output_change( GLcontext *ctx );
-
-
-#define GET_VERTEX_STATE(ctx) &(TNL_CONTEXT(ctx)->clipspace)
-
-/* Internal function:
- */
-void _tnl_register_fastpath( struct tnl_clipspace *vtx,
- GLboolean match_strides );
-
-
-/* t_vertex_generic.c -- Internal functions for t_vertex.c
- */
-void _tnl_generic_copy_pv_extras( GLcontext *ctx,
- GLuint dst, GLuint src );
-
-void _tnl_generic_interp_extras( GLcontext *ctx,
- GLfloat t,
- GLuint dst, GLuint out, GLuint in,
- GLboolean force_boundary );
-
-void _tnl_generic_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
-
-void _tnl_generic_interp( GLcontext *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary );
-
-void _tnl_generic_emit( GLcontext *ctx,
- GLuint count,
- GLubyte *v );
-
-void _tnl_generate_hardwired_emit( GLcontext *ctx );
-
-/* t_vertex_sse.c -- Internal functions for t_vertex.c
- */
-void _tnl_generate_sse_emit( GLcontext *ctx );
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c
deleted file mode 100644
index 3f9445805..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c
+++ /dev/null
@@ -1,1119 +0,0 @@
-
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * 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
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, 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 (including the next
- * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS 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@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "colormac.h"
-#include "t_context.h"
-#include "t_vertex.h"
-#include "simple_list.h"
-
-
-
-/*
- * These functions take the NDC coordinates pointed to by 'in', apply the
- * NDC->Viewport mapping and store the results at 'v'.
- */
-
-static INLINE void insert_4f_viewport_4( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
- out[2] = vp[10] * in[2] + vp[14];
- out[3] = in[3];
-}
-
-static INLINE void insert_4f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
- out[2] = vp[10] * in[2] + vp[14];
- out[3] = 1;
-}
-
-static INLINE void insert_4f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
- out[2] = vp[14];
- out[3] = 1;
-}
-
-static INLINE void insert_4f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[13];
- out[2] = vp[14];
- out[3] = 1;
-}
-
-static INLINE void insert_3f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
- out[2] = vp[10] * in[2] + vp[14];
-}
-
-static INLINE void insert_3f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
- out[2] = vp[10] * in[2] + vp[14];
-}
-
-static INLINE void insert_3f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[13];
- out[2] = vp[14];
-}
-
-static INLINE void insert_2f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
-}
-
-static INLINE void insert_2f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[13];
-}
-
-
-/*
- * These functions do the same as above, except for the viewport mapping.
- */
-
-static INLINE void insert_4f_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = in[3];
-}
-
-static INLINE void insert_4f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = 1;
-}
-
-static INLINE void insert_4f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = 0;
- out[3] = 1;
-}
-
-static INLINE void insert_4f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
-}
-
-static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[3];
-}
-
-static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- (void) a; (void) v; (void) in;
- abort();
-}
-
-static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
-}
-
-static INLINE void insert_3f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = 0;
-}
-
-static INLINE void insert_3f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
- out[2] = 0;
-}
-
-
-static INLINE void insert_2f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
-}
-
-static INLINE void insert_2f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
-}
-
-static INLINE void insert_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
-
- out[0] = in[0];
-}
-
-static INLINE void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- (void) a; (void) v; (void) in;
-}
-
-static INLINE void insert_4chan_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLchan *c = (GLchan *)v;
- (void) a;
- UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
- UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
- UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);
- UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]);
-}
-
-static INLINE void insert_4chan_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLchan *c = (GLchan *)v;
- (void) a;
- UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
- UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
- UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);
- c[3] = CHAN_MAX;
-}
-
-static INLINE void insert_4chan_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLchan *c = (GLchan *)v;
- (void) a;
- UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
- UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
- c[2] = 0;
- c[3] = CHAN_MAX;
-}
-
-static INLINE void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- GLchan *c = (GLchan *)v;
- (void) a;
- UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
- c[1] = 0;
- c[2] = 0;
- c[3] = CHAN_MAX;
-}
-
-static INLINE void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
-}
-
-static INLINE void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[2] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- v[1] = 0;
- v[2] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
-}
-
-static INLINE void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[0] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- v[1] = 0;
- v[0] = 0;
- v[3] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
-}
-
-static INLINE void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- v[3] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
- v[2] = 0x00;
- v[3] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
-}
-
-static INLINE void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
- v[1] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
- v[2] = 0x00;
- v[1] = 0x00;
- v[0] = 0xff;
-}
-
-static INLINE void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
-}
-
-static INLINE void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[2] = 0;
-}
-
-static INLINE void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
- v[1] = 0;
- v[2] = 0;
-}
-
-static INLINE void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
-}
-
-static INLINE void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
- v[0] = 0;
-}
-
-static INLINE void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
- v[1] = 0;
- v[0] = 0;
-}
-
-
-static INLINE void insert_1ub_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v,
- const GLfloat *in )
-{
- (void) a;
- UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
-}
-
-
-/***********************************************************************
- * Functions to perform the reverse operations to the above, for
- * swrast translation and clip-interpolation.
- *
- * Currently always extracts a full 4 floats.
- */
-
-static void extract_4f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- /* Although included for completeness, the position coordinate is
- * usually handled differently during clipping.
- */
- out[0] = (in[0] - vp[12]) / vp[0];
- out[1] = (in[1] - vp[13]) / vp[5];
- out[2] = (in[2] - vp[14]) / vp[10];
- out[3] = in[3];
-}
-
-static void extract_3f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = (in[0] - vp[12]) / vp[0];
- out[1] = (in[1] - vp[13]) / vp[5];
- out[2] = (in[2] - vp[14]) / vp[10];
- out[3] = 1;
-}
-
-
-static void extract_2f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- const GLfloat * const vp = a->vp;
-
- out[0] = (in[0] - vp[12]) / vp[0];
- out[1] = (in[1] - vp[13]) / vp[5];
- out[2] = 0;
- out[3] = 1;
-}
-
-
-static void extract_4f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = in[3];
-}
-
-static void extract_3f_xyw( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = 0;
- out[3] = in[2];
-}
-
-
-static void extract_3f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = 1;
-}
-
-
-static void extract_2f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- (void) a;
-
- out[0] = in[0];
- out[1] = in[1];
- out[2] = 0;
- out[3] = 1;
-}
-
-static void extract_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
-{
- const GLfloat *in = (const GLfloat *)v;
- (void) a;
-
- out[0] = in[0];
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
-}
-
-static void extract_4chan_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- GLchan *c = (GLchan *)v;
- (void) a;
-
- out[0] = CHAN_TO_FLOAT(c[0]);
- out[1] = CHAN_TO_FLOAT(c[1]);
- out[2] = CHAN_TO_FLOAT(c[2]);
- out[3] = CHAN_TO_FLOAT(c[3]);
-}
-
-static void extract_4ub_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- (void) a;
- out[0] = UBYTE_TO_FLOAT(v[0]);
- out[1] = UBYTE_TO_FLOAT(v[1]);
- out[2] = UBYTE_TO_FLOAT(v[2]);
- out[3] = UBYTE_TO_FLOAT(v[3]);
-}
-
-static void extract_4ub_4f_bgra( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- (void) a;
- out[2] = UBYTE_TO_FLOAT(v[0]);
- out[1] = UBYTE_TO_FLOAT(v[1]);
- out[0] = UBYTE_TO_FLOAT(v[2]);
- out[3] = UBYTE_TO_FLOAT(v[3]);
-}
-
-static void extract_4ub_4f_argb( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- (void) a;
- out[3] = UBYTE_TO_FLOAT(v[0]);
- out[0] = UBYTE_TO_FLOAT(v[1]);
- out[1] = UBYTE_TO_FLOAT(v[2]);
- out[2] = UBYTE_TO_FLOAT(v[3]);
-}
-
-static void extract_4ub_4f_abgr( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- (void) a;
- out[3] = UBYTE_TO_FLOAT(v[0]);
- out[2] = UBYTE_TO_FLOAT(v[1]);
- out[1] = UBYTE_TO_FLOAT(v[2]);
- out[0] = UBYTE_TO_FLOAT(v[3]);
-}
-
-static void extract_3ub_3f_rgb( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- (void) a;
- out[0] = UBYTE_TO_FLOAT(v[0]);
- out[1] = UBYTE_TO_FLOAT(v[1]);
- out[2] = UBYTE_TO_FLOAT(v[2]);
- out[3] = 1;
-}
-
-static void extract_3ub_3f_bgr( const struct tnl_clipspace_attr *a, GLfloat *out,
- const GLubyte *v )
-{
- (void) a;
- out[2] = UBYTE_TO_FLOAT(v[0]);
- out[1] = UBYTE_TO_FLOAT(v[1]);
- out[0] = UBYTE_TO_FLOAT(v[2]);
- out[3] = 1;
-}
-
-static void extract_1ub_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
-{
- (void) a;
- out[0] = UBYTE_TO_FLOAT(v[0]);
- out[1] = 0;
- out[2] = 0;
- out[3] = 1;
-}
-
-
-const struct tnl_format_info _tnl_format_info[EMIT_MAX] =
-{
- { "1f",
- extract_1f,
- { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
- sizeof(GLfloat) },
-
- { "2f",
- extract_2f,
- { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
- 2 * sizeof(GLfloat) },
-
- { "3f",
- extract_3f,
- { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
- 3 * sizeof(GLfloat) },
-
- { "4f",
- extract_4f,
- { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
- 4 * sizeof(GLfloat) },
-
- { "2f_viewport",
- extract_2f_viewport,
- { insert_2f_viewport_1, insert_2f_viewport_2, insert_2f_viewport_2,
- insert_2f_viewport_2 },
- 2 * sizeof(GLfloat) },
-
- { "3f_viewport",
- extract_3f_viewport,
- { insert_3f_viewport_1, insert_3f_viewport_2, insert_3f_viewport_3,
- insert_3f_viewport_3 },
- 3 * sizeof(GLfloat) },
-
- { "4f_viewport",
- extract_4f_viewport,
- { insert_4f_viewport_1, insert_4f_viewport_2, insert_4f_viewport_3,
- insert_4f_viewport_4 },
- 4 * sizeof(GLfloat) },
-
- { "3f_xyw",
- extract_3f_xyw,
- { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err,
- insert_3f_xyw_4 },
- 3 * sizeof(GLfloat) },
-
- { "1ub_1f",
- extract_1ub_1f,
- { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 },
- sizeof(GLubyte) },
-
- { "3ub_3f_rgb",
- extract_3ub_3f_rgb,
- { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3,
- insert_3ub_3f_rgb_3 },
- 3 * sizeof(GLubyte) },
-
- { "3ub_3f_bgr",
- extract_3ub_3f_bgr,
- { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3,
- insert_3ub_3f_bgr_3 },
- 3 * sizeof(GLubyte) },
-
- { "4ub_4f_rgba",
- extract_4ub_4f_rgba,
- { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3,
- insert_4ub_4f_rgba_4 },
- 4 * sizeof(GLubyte) },
-
- { "4ub_4f_bgra",
- extract_4ub_4f_bgra,
- { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3,
- insert_4ub_4f_bgra_4 },
- 4 * sizeof(GLubyte) },
-
- { "4ub_4f_argb",
- extract_4ub_4f_argb,
- { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3,
- insert_4ub_4f_argb_4 },
- 4 * sizeof(GLubyte) },
-
- { "4ub_4f_abgr",
- extract_4ub_4f_abgr,
- { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3,
- insert_4ub_4f_abgr_4 },
- 4 * sizeof(GLubyte) },
-
- { "4chan_4f_rgba",
- extract_4chan_4f_rgba,
- { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3,
- insert_4chan_4f_rgba_4 },
- 4 * sizeof(GLchan) },
-
- { "pad",
- NULL,
- { NULL, NULL, NULL, NULL },
- 0 }
-
-};
-
-
-
-
-/***********************************************************************
- * Hardwired fastpaths for emitting whole vertices or groups of
- * vertices
- */
-#define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \
-static void NAME( GLcontext *ctx, \
- GLuint count, \
- GLubyte *v ) \
-{ \
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); \
- struct tnl_clipspace_attr *a = vtx->attr; \
- GLuint i; \
- \
- for (i = 0 ; i < count ; i++, v += vtx->vertex_size) { \
- if (NR > 0) { \
- F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr ); \
- a[0].inputptr += a[0].inputstride; \
- } \
- \
- if (NR > 1) { \
- F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr ); \
- a[1].inputptr += a[1].inputstride; \
- } \
- \
- if (NR > 2) { \
- F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr ); \
- a[2].inputptr += a[2].inputstride; \
- } \
- \
- if (NR > 3) { \
- F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr ); \
- a[3].inputptr += a[3].inputstride; \
- } \
- \
- if (NR > 4) { \
- F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr ); \
- a[4].inputptr += a[4].inputstride; \
- } \
- } \
-}
-
-
-#define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \
- insert_null, insert_null, NAME)
-
-#define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \
- insert_null, NAME)
-
-#define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \
- insert_null, NAME)
-
-
-EMIT2(insert_3f_viewport_3, insert_4ub_4f_rgba_4, emit_viewport3_rgba4)
-EMIT2(insert_3f_viewport_3, insert_4ub_4f_bgra_4, emit_viewport3_bgra4)
-EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4)
-
-EMIT3(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_viewport4_rgba4_st2)
-EMIT3(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, emit_viewport4_bgra4_st2)
-EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2)
-
-EMIT4(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_viewport4_rgba4_st2_st2)
-EMIT4(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, insert_2f_2, emit_viewport4_bgra4_st2_st2)
-EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2)
-
-
-/* Use the codegen paths to select one of a number of hardwired
- * fastpaths.
- */
-void _tnl_generate_hardwired_emit( GLcontext *ctx )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- tnl_emit_func func = NULL;
-
- /* Does it fit a hardwired fastpath? Help! this is growing out of
- * control!
- */
- switch (vtx->attr_count) {
- case 2:
- if (vtx->attr[0].emit == insert_3f_viewport_3) {
- if (vtx->attr[1].emit == insert_4ub_4f_bgra_4)
- func = emit_viewport3_bgra4;
- else if (vtx->attr[1].emit == insert_4ub_4f_rgba_4)
- func = emit_viewport3_rgba4;
- }
- else if (vtx->attr[0].emit == insert_3f_3 &&
- vtx->attr[1].emit == insert_4ub_4f_rgba_4) {
- func = emit_xyz3_rgba4;
- }
- break;
- case 3:
- if (vtx->attr[2].emit == insert_2f_2) {
- if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) {
- if (vtx->attr[0].emit == insert_4f_viewport_4)
- func = emit_viewport4_rgba4_st2;
- else if (vtx->attr[0].emit == insert_4f_4)
- func = emit_xyzw4_rgba4_st2;
- }
- else if (vtx->attr[1].emit == insert_4ub_4f_bgra_4 &&
- vtx->attr[0].emit == insert_4f_viewport_4)
- func = emit_viewport4_bgra4_st2;
- }
- break;
- case 4:
- if (vtx->attr[2].emit == insert_2f_2 &&
- vtx->attr[3].emit == insert_2f_2) {
- if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) {
- if (vtx->attr[0].emit == insert_4f_viewport_4)
- func = emit_viewport4_rgba4_st2_st2;
- else if (vtx->attr[0].emit == insert_4f_4)
- func = emit_xyzw4_rgba4_st2_st2;
- }
- else if (vtx->attr[1].emit == insert_4ub_4f_bgra_4 &&
- vtx->attr[0].emit == insert_4f_viewport_4)
- func = emit_viewport4_bgra4_st2_st2;
- }
- break;
- }
-
- vtx->emit = func;
-}
-
-/***********************************************************************
- * Generic (non-codegen) functions for whole vertices or groups of
- * vertices
- */
-
-void _tnl_generic_emit( GLcontext *ctx,
- GLuint count,
- GLubyte *v )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint attr_count = vtx->attr_count;
- const GLuint stride = vtx->vertex_size;
- GLuint i, j;
-
- for (i = 0 ; i < count ; i++, v += stride) {
- for (j = 0; j < attr_count; j++) {
- GLfloat *in = (GLfloat *)a[j].inputptr;
- a[j].inputptr += a[j].inputstride;
- a[j].emit( &a[j], v + a[j].vertoffset, in );
- }
- }
-}
-
-
-void _tnl_generic_interp( GLcontext *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- const GLubyte *vin = vtx->vertex_buf + ein * vtx->vertex_size;
- const GLubyte *vout = vtx->vertex_buf + eout * vtx->vertex_size;
- GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size;
- const struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint attr_count = vtx->attr_count;
- GLuint j;
- (void) force_boundary;
-
- if (tnl->NeedNdcCoords) {
- const GLfloat *dstclip = VB->ClipPtr->data[edst];
- if (dstclip[3] != 0.0) {
- const GLfloat w = 1.0f / dstclip[3];
- GLfloat pos[4];
-
- pos[0] = dstclip[0] * w;
- pos[1] = dstclip[1] * w;
- pos[2] = dstclip[2] * w;
- pos[3] = w;
-
- a[0].insert[4-1]( &a[0], vdst, pos );
- }
- }
- else {
- a[0].insert[4-1]( &a[0], vdst, VB->ClipPtr->data[edst] );
- }
-
-
- for (j = 1; j < attr_count; j++) {
- GLfloat fin[4], fout[4], fdst[4];
-
- a[j].extract( &a[j], fin, vin + a[j].vertoffset );
- a[j].extract( &a[j], fout, vout + a[j].vertoffset );
-
- INTERP_F( t, fdst[3], fout[3], fin[3] );
- INTERP_F( t, fdst[2], fout[2], fin[2] );
- INTERP_F( t, fdst[1], fout[1], fin[1] );
- INTERP_F( t, fdst[0], fout[0], fin[0] );
-
- a[j].insert[4-1]( &a[j], vdst + a[j].vertoffset, fdst );
- }
-}
-
-
-/* Extract color attributes from one vertex and insert them into
- * another. (Shortcircuit extract/insert with memcpy).
- */
-void _tnl_generic_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- GLubyte *vsrc = vtx->vertex_buf + esrc * vtx->vertex_size;
- GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size;
- const struct tnl_clipspace_attr *a = vtx->attr;
- const GLuint attr_count = vtx->attr_count;
- GLuint j;
-
- for (j = 0; j < attr_count; j++) {
- if (a[j].attrib == VERT_ATTRIB_COLOR0 ||
- a[j].attrib == VERT_ATTRIB_COLOR1) {
-
- _mesa_memcpy( vdst + a[j].vertoffset,
- vsrc + a[j].vertoffset,
- a[j].vertattrsize );
- }
- }
-}
-
-
-/* Helper functions for hardware which doesn't put back colors and/or
- * edgeflags into vertices.
- */
-void _tnl_generic_interp_extras( GLcontext *ctx,
- GLfloat t,
- GLuint dst, GLuint out, GLuint in,
- GLboolean force_boundary )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-
- /* If stride is zero, ColorPtr[1] is constant across the VB, so
- * there is no point interpolating between two values as they will
- * be identical. In all other cases, this value is generated by
- * t_vb_lighttmp.h and has a stride of 4 dwords.
- */
- if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) {
- assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
-
- INTERP_4F( t,
- VB->ColorPtr[1]->data[dst],
- VB->ColorPtr[1]->data[out],
- VB->ColorPtr[1]->data[in] );
- }
-
- if (VB->SecondaryColorPtr[1]) {
- assert(VB->SecondaryColorPtr[1]->stride == 4 * sizeof(GLfloat));
-
- INTERP_3F( t,
- VB->SecondaryColorPtr[1]->data[dst],
- VB->SecondaryColorPtr[1]->data[out],
- VB->SecondaryColorPtr[1]->data[in] );
- }
-
- if (VB->IndexPtr[1]) {
- VB->IndexPtr[1]->data[dst][0] = LINTERP( t,
- VB->IndexPtr[1]->data[out][0],
- VB->IndexPtr[1]->data[in][0] );
- }
-
- if (VB->EdgeFlag) {
- VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
- }
-
- _tnl_generic_interp(ctx, t, dst, out, in, force_boundary);
-}
-
-void _tnl_generic_copy_pv_extras( GLcontext *ctx,
- GLuint dst, GLuint src )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-
- /* See above comment:
- */
- if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) {
- COPY_4FV( VB->ColorPtr[1]->data[dst],
- VB->ColorPtr[1]->data[src] );
- }
-
- if (VB->SecondaryColorPtr[1]) {
- COPY_4FV( VB->SecondaryColorPtr[1]->data[dst],
- VB->SecondaryColorPtr[1]->data[src] );
- }
-
- if (VB->IndexPtr[1]) {
- VB->IndexPtr[1]->data[dst][0] = VB->IndexPtr[1]->data[src][0];
- }
-
- _tnl_generic_copy_pv(ctx, dst, src);
-}
-
-
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c
deleted file mode 100644
index 13dc2f4d5..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
- * Copyright 2003 Tungsten Graphics, inc.
- * 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
- * on the rights to use, copy, modify, merge, publish, distribute, sub
- * license, 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 (including the next
- * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
- * TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS 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@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "colormac.h"
-#include "t_context.h"
-#include "t_vertex.h"
-#include "simple_list.h"
-#include "enums.h"
-
-#if defined(USE_SSE_ASM)
-
-#include "x86/rtasm/x86sse.h"
-#include "x86/common_x86_asm.h"
-
-
-#define X 0
-#define Y 1
-#define Z 2
-#define W 3
-
-
-struct x86_program {
- struct x86_function func;
-
- GLcontext *ctx;
- GLboolean inputs_safe;
- GLboolean outputs_safe;
- GLboolean have_sse2;
-
- struct x86_reg identity;
- struct x86_reg chan0;
-};
-
-
-static struct x86_reg get_identity( struct x86_program *p )
-{
- return p->identity;
-}
-
-static void emit_load4f_4( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movups(&p->func, dest, arg0);
-}
-
-static void emit_load4f_3( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Have to jump through some hoops:
- *
- * c 0 0 0
- * c 0 0 1
- * 0 0 c 1
- * a b c 1
- */
- sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
- sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
- sse_shufps(&p->func, dest, dest, SHUF(Y,Z,X,W) );
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_load4f_2( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Initialize from identity, then pull in low two words:
- */
- sse_movups(&p->func, dest, get_identity(p));
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_load4f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Pull in low word, then swizzle in identity */
- sse_movss(&p->func, dest, arg0);
- sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
-}
-
-
-
-static void emit_load3f_3( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- /* Over-reads by 1 dword - potential SEGV if input is a vertex
- * array.
- */
- if (p->inputs_safe) {
- sse_movups(&p->func, dest, arg0);
- }
- else {
- /* c 0 0 0
- * c c c c
- * a b c c
- */
- sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
- sse_shufps(&p->func, dest, dest, SHUF(X,X,X,X));
- sse_movlps(&p->func, dest, arg0);
- }
-}
-
-static void emit_load3f_2( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- emit_load4f_2(p, dest, arg0);
-}
-
-static void emit_load3f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- emit_load4f_1(p, dest, arg0);
-}
-
-static void emit_load2f_2( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_load2f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- emit_load4f_1(p, dest, arg0);
-}
-
-static void emit_load1f_1( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movss(&p->func, dest, arg0);
-}
-
-static void (*load[4][4])( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 ) = {
- { emit_load1f_1,
- emit_load1f_1,
- emit_load1f_1,
- emit_load1f_1 },
-
- { emit_load2f_1,
- emit_load2f_2,
- emit_load2f_2,
- emit_load2f_2 },
-
- { emit_load3f_1,
- emit_load3f_2,
- emit_load3f_3,
- emit_load3f_3 },
-
- { emit_load4f_1,
- emit_load4f_2,
- emit_load4f_3,
- emit_load4f_4 }
-};
-
-static void emit_load( struct x86_program *p,
- struct x86_reg dest,
- GLuint sz,
- struct x86_reg src,
- GLuint src_sz)
-{
- load[sz-1][src_sz-1](p, dest, src);
-}
-
-static void emit_store4f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movups(&p->func, dest, arg0);
-}
-
-static void emit_store3f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- if (p->outputs_safe) {
- /* Emit the extra dword anyway. This may hurt writecombining,
- * may cause other problems.
- */
- sse_movups(&p->func, dest, arg0);
- }
- else {
- /* Alternate strategy - emit two, shuffle, emit one.
- */
- sse_movlps(&p->func, dest, arg0);
- sse_shufps(&p->func, arg0, arg0, SHUF(Z,Z,Z,Z) ); /* NOTE! destructive */
- sse_movss(&p->func, x86_make_disp(dest,8), arg0);
- }
-}
-
-static void emit_store2f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movlps(&p->func, dest, arg0);
-}
-
-static void emit_store1f( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 )
-{
- sse_movss(&p->func, dest, arg0);
-}
-
-
-static void (*store[4])( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg arg0 ) =
-{
- emit_store1f,
- emit_store2f,
- emit_store3f,
- emit_store4f
-};
-
-static void emit_store( struct x86_program *p,
- struct x86_reg dest,
- GLuint sz,
- struct x86_reg temp )
-
-{
- store[sz-1](p, dest, temp);
-}
-
-static void emit_pack_store_4ub( struct x86_program *p,
- struct x86_reg dest,
- struct x86_reg temp )
-{
- /* Scale by 255.0
- */
- sse_mulps(&p->func, temp, p->chan0);
-
- if (p->have_sse2) {
- sse2_cvtps2dq(&p->func, temp, temp);
- sse2_packssdw(&p->func, temp, temp);
- sse2_packuswb(&p->func, temp, temp);
- sse_movss(&p->func, dest, temp);
- }
- else {
- struct x86_reg mmx0 = x86_make_reg(file_MMX, 0);
- struct x86_reg mmx1 = x86_make_reg(file_MMX, 1);
- sse_cvtps2pi(&p->func, mmx0, temp);
- sse_movhlps(&p->func, temp, temp);
- sse_cvtps2pi(&p->func, mmx1, temp);
- mmx_packssdw(&p->func, mmx0, mmx1);
- mmx_packuswb(&p->func, mmx0, mmx0);
- mmx_movd(&p->func, dest, mmx0);
- }
-}
-
-static GLint get_offset( const void *a, const void *b )
-{
- return (const char *)b - (const char *)a;
-}
-
-/* Not much happens here. Eventually use this function to try and
- * avoid saving/reloading the source pointers each vertex (if some of
- * them can fit in registers).
- */
-static void get_src_ptr( struct x86_program *p,
- struct x86_reg srcREG,
- struct x86_reg vtxREG,
- struct tnl_clipspace_attr *a )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx);
- struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr));
-
- /* Load current a[j].inputptr
- */
- x86_mov(&p->func, srcREG, ptr_to_src);
-}
-
-static void update_src_ptr( struct x86_program *p,
- struct x86_reg srcREG,
- struct x86_reg vtxREG,
- struct tnl_clipspace_attr *a )
-{
- if (a->inputstride) {
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx);
- struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr));
-
- /* add a[j].inputstride (hardcoded value - could just as easily
- * pull the stride value from memory each time).
- */
- x86_lea(&p->func, srcREG, x86_make_disp(srcREG, a->inputstride));
-
- /* save new value of a[j].inputptr
- */
- x86_mov(&p->func, ptr_to_src, srcREG);
- }
-}
-
-
-/* Lots of hardcoding
- *
- * EAX -- pointer to current output vertex
- * ECX -- pointer to current attribute
- *
- */
-static GLboolean build_vertex_emit( struct x86_program *p )
-{
- GLcontext *ctx = p->ctx;
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- GLuint j = 0;
-
- struct x86_reg vertexEAX = x86_make_reg(file_REG32, reg_AX);
- struct x86_reg srcECX = x86_make_reg(file_REG32, reg_CX);
- struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP);
- struct x86_reg vtxESI = x86_make_reg(file_REG32, reg_SI);
- struct x86_reg temp = x86_make_reg(file_XMM, 0);
- struct x86_reg vp0 = x86_make_reg(file_XMM, 1);
- struct x86_reg vp1 = x86_make_reg(file_XMM, 2);
- GLubyte *fixup, *label;
-
- x86_init_func(&p->func);
-
- /* Push a few regs?
- */
- x86_push(&p->func, countEBP);
- x86_push(&p->func, vtxESI);
-
-
- /* Get vertex count, compare to zero
- */
- x86_xor(&p->func, srcECX, srcECX);
- x86_mov(&p->func, countEBP, x86_fn_arg(&p->func, 2));
- x86_cmp(&p->func, countEBP, srcECX);
- fixup = x86_jcc_forward(&p->func, cc_E);
-
- /* Initialize destination register.
- */
- x86_mov(&p->func, vertexEAX, x86_fn_arg(&p->func, 3));
-
- /* Dereference ctx to get tnl, then vtx:
- */
- x86_mov(&p->func, vtxESI, x86_fn_arg(&p->func, 1));
- x86_mov(&p->func, vtxESI, x86_make_disp(vtxESI, get_offset(ctx, &ctx->swtnl_context)));
- vtxESI = x86_make_disp(vtxESI, get_offset(tnl, &tnl->clipspace));
-
-
- /* Possibly load vp0, vp1 for viewport calcs:
- */
- if (vtx->need_viewport) {
- sse_movups(&p->func, vp0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_scale[0])));
- sse_movups(&p->func, vp1, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_xlate[0])));
- }
-
- /* always load, needed or not:
- */
- sse_movups(&p->func, p->chan0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->chan_scale[0])));
- sse_movups(&p->func, p->identity, x86_make_disp(vtxESI, get_offset(vtx, &vtx->identity[0])));
-
- /* Note address for loop jump */
- label = x86_get_label(&p->func);
-
- /* Emit code for each of the attributes. Currently routes
- * everything through SSE registers, even when it might be more
- * efficient to stick with regular old x86. No optimization or
- * other tricks - enough new ground to cover here just getting
- * things working.
- */
- while (j < vtx->attr_count) {
- struct tnl_clipspace_attr *a = &vtx->attr[j];
- struct x86_reg dest = x86_make_disp(vertexEAX, a->vertoffset);
-
- /* Now, load an XMM reg from src, perhaps transform, then save.
- * Could be shortcircuited in specific cases:
- */
- switch (a->format) {
- case EMIT_1F:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 1, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_2F:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 2, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_3F:
- /* Potentially the worst case - hardcode 2+1 copying:
- */
- if (0) {
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 3, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- }
- else {
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 2, temp);
- if (a->inputsize > 2) {
- emit_load(p, temp, 1, x86_make_disp(srcECX, 8), 1);
- emit_store(p, x86_make_disp(dest,8), 1, temp);
- }
- else {
- sse_movss(&p->func, x86_make_disp(dest,8), get_identity(p));
- }
- update_src_ptr(p, srcECX, vtxESI, a);
- }
- break;
- case EMIT_4F:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 4, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_2F_VIEWPORT:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
- sse_mulps(&p->func, temp, vp0);
- sse_addps(&p->func, temp, vp1);
- emit_store(p, dest, 2, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_3F_VIEWPORT:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- sse_mulps(&p->func, temp, vp0);
- sse_addps(&p->func, temp, vp1);
- emit_store(p, dest, 3, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_4F_VIEWPORT:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_mulps(&p->func, temp, vp0);
- sse_addps(&p->func, temp, vp1);
- emit_store(p, dest, 4, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_3F_XYW:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(X,Y,W,Z));
- emit_store(p, dest, 3, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
-
- case EMIT_1UB_1F:
- /* Test for PAD3 + 1UB:
- */
- if (j > 0 &&
- a[-1].vertoffset + a[-1].vertattrsize <= a->vertoffset - 3)
- {
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(X,X,X,X));
- emit_pack_store_4ub(p, x86_make_disp(dest, -3), temp); /* overkill! */
- update_src_ptr(p, srcECX, vtxESI, a);
- }
- else {
- _mesa_printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize );
- return GL_FALSE;
- }
- break;
- case EMIT_3UB_3F_RGB:
- case EMIT_3UB_3F_BGR:
- /* Test for 3UB + PAD1:
- */
- if (j == vtx->attr_count - 1 ||
- a[1].vertoffset >= a->vertoffset + 4) {
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- if (a->format == EMIT_3UB_3F_BGR)
- sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- }
- /* Test for 3UB + 1UB:
- */
- else if (j < vtx->attr_count - 1 &&
- a[1].format == EMIT_1UB_1F &&
- a[1].vertoffset == a->vertoffset + 3) {
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
- update_src_ptr(p, srcECX, vtxESI, a);
-
- /* Make room for incoming value:
- */
- sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
-
- get_src_ptr(p, srcECX, vtxESI, &a[1]);
- emit_load(p, temp, 1, x86_deref(srcECX), a[1].inputsize);
- update_src_ptr(p, srcECX, vtxESI, &a[1]);
-
- /* Rearrange and possibly do BGR conversion:
- */
- if (a->format == EMIT_3UB_3F_BGR)
- sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
- else
- sse_shufps(&p->func, temp, temp, SHUF(Y,Z,W,X));
-
- emit_pack_store_4ub(p, dest, temp);
- j++; /* NOTE: two attrs consumed */
- }
- else {
- _mesa_printf("Can't emit 3ub\n");
- }
- return GL_FALSE; /* add this later */
- break;
-
- case EMIT_4UB_4F_RGBA:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_4UB_4F_BGRA:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_4UB_4F_ARGB:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_4UB_4F_ABGR:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case EMIT_4CHAN_4F_RGBA:
- switch (CHAN_TYPE) {
- case GL_UNSIGNED_BYTE:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- emit_pack_store_4ub(p, dest, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case GL_FLOAT:
- get_src_ptr(p, srcECX, vtxESI, a);
- emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
- emit_store(p, dest, 4, temp);
- update_src_ptr(p, srcECX, vtxESI, a);
- break;
- case GL_UNSIGNED_SHORT:
- default:
- _mesa_printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE));
- return GL_FALSE;
- }
- break;
- default:
- _mesa_printf("unknown a[%d].format %d\n", j, a->format);
- return GL_FALSE; /* catch any new opcodes */
- }
-
- /* Increment j by at least 1 - may have been incremented above also:
- */
- j++;
- }
-
- /* Next vertex:
- */
- x86_lea(&p->func, vertexEAX, x86_make_disp(vertexEAX, vtx->vertex_size));
-
- /* decr count, loop if not zero
- */
- x86_dec(&p->func, countEBP);
- x86_test(&p->func, countEBP, countEBP);
- x86_jcc(&p->func, cc_NZ, label);
-
- /* Exit mmx state?
- */
- if (p->func.need_emms)
- mmx_emms(&p->func);
-
- /* Land forward jump here:
- */
- x86_fixup_fwd_jump(&p->func, fixup);
-
- /* Pop regs and return
- */
- x86_pop(&p->func, x86_get_base_reg(vtxESI));
- x86_pop(&p->func, countEBP);
- x86_ret(&p->func);
-
- vtx->emit = (tnl_emit_func)x86_get_func(&p->func);
- return GL_TRUE;
-}
-
-
-
-void _tnl_generate_sse_emit( GLcontext *ctx )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- struct x86_program p;
-
- if (!cpu_has_xmm) {
- vtx->codegen_emit = NULL;
- return;
- }
-
- memset(&p, 0, sizeof(p));
-
- p.ctx = ctx;
- p.inputs_safe = 0; /* for now */
- p.outputs_safe = 1; /* for now */
- p.have_sse2 = cpu_has_xmm2;
- p.identity = x86_make_reg(file_XMM, 6);
- p.chan0 = x86_make_reg(file_XMM, 7);
-
- x86_init_func(&p.func);
-
- if (build_vertex_emit(&p)) {
- _tnl_register_fastpath( vtx, GL_TRUE );
- }
- else {
- /* Note the failure so that we don't keep trying to codegen an
- * impossible state:
- */
- _tnl_register_fastpath( vtx, GL_FALSE );
- x86_release_func(&p.func);
- }
-}
-
-#else
-
-void _tnl_generate_sse_emit( GLcontext *ctx )
-{
- /* Dummy version for when USE_SSE_ASM not defined */
-}
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c
deleted file mode 100644
index e62c5b374..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c
+++ /dev/null
@@ -1,1497 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3.1
- *
- * Copyright (C) 2005 Tungsten Graphics 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
- * TUNGSTEN GRAPHICS 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 t_vp_build.c
- * Create a vertex program to execute the current fixed function T&L pipeline.
- * \author Keith Whitwell
- */
-
-
-#include "glheader.h"
-#include "macros.h"
-#include "enums.h"
-#include "t_context.h"
-#include "t_vp_build.h"
-
-#include "shader/program.h"
-#include "shader/nvvertprog.h"
-#include "shader/arbvertparse.h"
-
-struct state_key {
- unsigned light_global_enabled:1;
- unsigned light_local_viewer:1;
- unsigned light_twoside:1;
- unsigned light_color_material:1;
- unsigned light_color_material_mask:12;
- unsigned light_material_mask:12;
-
- unsigned normalize:1;
- unsigned rescale_normals:1;
- unsigned fog_source_is_depth:1;
- unsigned tnl_do_vertex_fog:1;
- unsigned separate_specular:1;
- unsigned fog_enabled:1;
- unsigned fog_mode:2;
- unsigned point_attenuated:1;
- unsigned texture_enabled_global:1;
-
- struct {
- unsigned light_enabled:1;
- unsigned light_eyepos3_is_zero:1;
- unsigned light_spotcutoff_is_180:1;
- unsigned light_attenuated:1;
- unsigned texunit_really_enabled:1;
- unsigned texmat_enabled:1;
- unsigned texgen_enabled:4;
- unsigned texgen_mode0:4;
- unsigned texgen_mode1:4;
- unsigned texgen_mode2:4;
- unsigned texgen_mode3:4;
- } unit[8];
-};
-
-
-
-#define FOG_LINEAR 0
-#define FOG_EXP 1
-#define FOG_EXP2 2
-#define FOG_UNKNOWN 3
-
-static GLuint translate_fog_mode( GLenum mode )
-{
- switch (mode) {
- case GL_LINEAR: return FOG_LINEAR;
- case GL_EXP: return FOG_EXP;
- case GL_EXP2: return FOG_EXP2;
- default: return FOG_UNKNOWN;
- }
-}
-
-#define TXG_NONE 0
-#define TXG_OBJ_LINEAR 1
-#define TXG_EYE_LINEAR 2
-#define TXG_SPHERE_MAP 3
-#define TXG_REFLECTION_MAP 4
-#define TXG_NORMAL_MAP 5
-
-static GLuint translate_texgen( GLboolean enabled, GLenum mode )
-{
- if (!enabled)
- return TXG_NONE;
-
- switch (mode) {
- case GL_OBJECT_LINEAR: return TXG_OBJ_LINEAR;
- case GL_EYE_LINEAR: return TXG_EYE_LINEAR;
- case GL_SPHERE_MAP: return TXG_SPHERE_MAP;
- case GL_REFLECTION_MAP_NV: return TXG_REFLECTION_MAP;
- case GL_NORMAL_MAP_NV: return TXG_NORMAL_MAP;
- default: return TXG_NONE;
- }
-}
-
-static struct state_key *make_state_key( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- struct state_key *key = CALLOC_STRUCT(state_key);
- GLuint i;
-
- key->separate_specular = (ctx->Light.Model.ColorControl ==
- GL_SEPARATE_SPECULAR_COLOR);
-
- if (ctx->Light.Enabled) {
- key->light_global_enabled = 1;
-
- if (ctx->Light.Model.LocalViewer)
- key->light_local_viewer = 1;
-
- if (ctx->Light.Model.TwoSide)
- key->light_twoside = 1;
-
- if (ctx->Light.ColorMaterialEnabled) {
- key->light_color_material = 1;
- key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
- }
-
- for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ; i < _TNL_ATTRIB_INDEX ; i++)
- if (VB->AttribPtr[i]->stride)
- key->light_material_mask |= 1<<(i-_TNL_ATTRIB_MAT_FRONT_AMBIENT);
-
- for (i = 0; i < MAX_LIGHTS; i++) {
- struct gl_light *light = &ctx->Light.Light[i];
-
- if (light->Enabled) {
- key->unit[i].light_enabled = 1;
-
- if (light->EyePosition[3] == 0.0)
- key->unit[i].light_eyepos3_is_zero = 1;
-
- if (light->SpotCutoff == 180.0)
- key->unit[i].light_spotcutoff_is_180 = 1;
-
- if (light->ConstantAttenuation != 1.0 ||
- light->LinearAttenuation != 0.0 ||
- light->QuadraticAttenuation != 0.0)
- key->unit[i].light_attenuated = 1;
- }
- }
- }
-
- if (ctx->Transform.Normalize)
- key->normalize = 1;
-
- if (ctx->Transform.RescaleNormals)
- key->rescale_normals = 1;
-
- if (ctx->Fog.Enabled)
- key->fog_enabled = 1;
-
- if (key->fog_enabled) {
- if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
- key->fog_source_is_depth = 1;
-
- if (tnl->_DoVertexFog)
- key->tnl_do_vertex_fog = 1;
-
- key->fog_mode = translate_fog_mode(ctx->Fog.Mode);
- }
-
- if (ctx->Point._Attenuated)
- key->point_attenuated = 1;
-
- if (ctx->Texture._TexGenEnabled ||
- ctx->Texture._TexMatEnabled ||
- ctx->Texture._EnabledUnits)
- key->texture_enabled_global = 1;
-
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
-
- if (texUnit->_ReallyEnabled)
- key->unit[i].texunit_really_enabled = 1;
-
- if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
- key->unit[i].texmat_enabled = 1;
-
- if (texUnit->TexGenEnabled) {
- key->unit[i].texgen_enabled = 1;
-
- key->unit[i].texgen_mode0 =
- translate_texgen( texUnit->TexGenEnabled & (1<<0),
- texUnit->GenModeS );
- key->unit[i].texgen_mode1 =
- translate_texgen( texUnit->TexGenEnabled & (1<<1),
- texUnit->GenModeT );
- key->unit[i].texgen_mode2 =
- translate_texgen( texUnit->TexGenEnabled & (1<<2),
- texUnit->GenModeR );
- key->unit[i].texgen_mode3 =
- translate_texgen( texUnit->TexGenEnabled & (1<<3),
- texUnit->GenModeQ );
- }
- }
-
- return key;
-}
-
-
-
-/* Very useful debugging tool - produces annotated listing of
- * generated program with line/function references for each
- * instruction back into this file:
- */
-#define DISASSEM (MESA_VERBOSE&VERBOSE_DISASSEM)
-
-/* Should be tunable by the driver - do we want to do matrix
- * multiplications with DP4's or with MUL/MAD's? SSE works better
- * with the latter, drivers may differ.
- */
-#define PREFER_DP4 0
-
-#define MAX_INSN 200
-
-/* Use uregs to represent registers internally, translate to Mesa's
- * expected formats on emit.
- *
- * NOTE: These are passed by value extensively in this file rather
- * than as usual by pointer reference. If this disturbs you, try
- * remembering they are just 32bits in size.
- *
- * GCC is smart enough to deal with these dword-sized structures in
- * much the same way as if I had defined them as dwords and was using
- * macros to access and set the fields. This is much nicer and easier
- * to evolve.
- */
-struct ureg {
- GLuint file:4;
- GLint idx:8; /* relative addressing may be negative */
- GLuint negate:1;
- GLuint swz:12;
- GLuint pad:7;
-};
-
-
-struct tnl_program {
- const struct state_key *state;
- struct vertex_program *program;
-
- GLuint temp_in_use;
- GLuint temp_reserved;
-
- struct ureg eye_position;
- struct ureg eye_position_normalized;
- struct ureg eye_normal;
- struct ureg identity;
-
- GLuint materials;
- GLuint color_materials;
-};
-
-
-const static struct ureg undef = {
- ~0,
- ~0,
- 0,
- 0,
- 0
-};
-
-/* Local shorthand:
- */
-#define X SWIZZLE_X
-#define Y SWIZZLE_Y
-#define Z SWIZZLE_Z
-#define W SWIZZLE_W
-
-
-/* Construct a ureg:
- */
-static struct ureg make_ureg(GLuint file, GLint idx)
-{
- struct ureg reg;
- reg.file = file;
- reg.idx = idx;
- reg.negate = 0;
- reg.swz = SWIZZLE_NOOP;
- reg.pad = 0;
- return reg;
-}
-
-
-
-static struct ureg negate( struct ureg reg )
-{
- reg.negate ^= 1;
- return reg;
-}
-
-
-static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
-{
- reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x),
- GET_SWZ(reg.swz, y),
- GET_SWZ(reg.swz, z),
- GET_SWZ(reg.swz, w));
-
- return reg;
-}
-
-static struct ureg swizzle1( struct ureg reg, int x )
-{
- return swizzle(reg, x, x, x, x);
-}
-
-static struct ureg get_temp( struct tnl_program *p )
-{
- int bit = ffs( ~p->temp_in_use );
- if (!bit) {
- fprintf(stderr, "%s: out of temporaries\n", __FILE__);
- exit(1);
- }
-
- p->temp_in_use |= 1<<(bit-1);
- return make_ureg(PROGRAM_TEMPORARY, bit-1);
-}
-
-static struct ureg reserve_temp( struct tnl_program *p )
-{
- struct ureg temp = get_temp( p );
- p->temp_reserved |= 1<<temp.idx;
- return temp;
-}
-
-static void release_temp( struct tnl_program *p, struct ureg reg )
-{
- if (reg.file == PROGRAM_TEMPORARY) {
- p->temp_in_use &= ~(1<<reg.idx);
- p->temp_in_use |= p->temp_reserved; /* can't release reserved temps */
- }
-}
-
-static void release_temps( struct tnl_program *p )
-{
- p->temp_in_use = p->temp_reserved;
-}
-
-
-
-static struct ureg register_input( struct tnl_program *p, GLuint input )
-{
- p->program->InputsRead |= (1<<input);
- return make_ureg(PROGRAM_INPUT, input);
-}
-
-static struct ureg register_output( struct tnl_program *p, GLuint output )
-{
- p->program->OutputsWritten |= (1<<output);
- return make_ureg(PROGRAM_OUTPUT, output);
-}
-
-static struct ureg register_const4f( struct tnl_program *p,
- GLfloat s0,
- GLfloat s1,
- GLfloat s2,
- GLfloat s3)
-{
- GLfloat values[4];
- GLint idx;
- values[0] = s0;
- values[1] = s1;
- values[2] = s2;
- values[3] = s3;
- idx = _mesa_add_unnamed_constant( p->program->Parameters, values );
- return make_ureg(PROGRAM_STATE_VAR, idx);
-}
-
-#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1)
-#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0)
-#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1)
-#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1)
-
-static GLboolean is_undef( struct ureg reg )
-{
- return reg.file == 0xf;
-}
-
-static struct ureg get_identity_param( struct tnl_program *p )
-{
- if (is_undef(p->identity))
- p->identity = register_const4f(p, 0,0,0,1);
-
- return p->identity;
-}
-
-static struct ureg register_param6( struct tnl_program *p,
- GLint s0,
- GLint s1,
- GLint s2,
- GLint s3,
- GLint s4,
- GLint s5)
-{
- GLint tokens[6];
- GLint idx;
- tokens[0] = s0;
- tokens[1] = s1;
- tokens[2] = s2;
- tokens[3] = s3;
- tokens[4] = s4;
- tokens[5] = s5;
- idx = _mesa_add_state_reference( p->program->Parameters, tokens );
- return make_ureg(PROGRAM_STATE_VAR, idx);
-}
-
-
-#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0)
-#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0)
-#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0)
-#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0)
-
-
-static void register_matrix_param6( struct tnl_program *p,
- GLint s0,
- GLint s1,
- GLint s2,
- GLint s3,
- GLint s4,
- GLint s5,
- struct ureg *matrix )
-{
- GLuint i;
-
- /* This is a bit sad as the support is there to pull the whole
- * matrix out in one go:
- */
- for (i = 0; i <= s4 - s3; i++)
- matrix[i] = register_param6( p, s0, s1, s2, i, i, s5 );
-}
-
-
-static void emit_arg( struct vp_src_register *src,
- struct ureg reg )
-{
- src->File = reg.file;
- src->Index = reg.idx;
- src->Swizzle = reg.swz;
- src->Negate = reg.negate;
- src->RelAddr = 0;
- src->pad = 0;
-}
-
-static void emit_dst( struct vp_dst_register *dst,
- struct ureg reg, GLuint mask )
-{
- dst->File = reg.file;
- dst->Index = reg.idx;
- /* allow zero as a shorthand for xyzw */
- dst->WriteMask = mask ? mask : WRITEMASK_XYZW;
- dst->pad = 0;
-}
-
-static void debug_insn( struct vp_instruction *inst, const char *fn,
- GLuint line )
-{
- if (DISASSEM) {
- static const char *last_fn;
-
- if (fn != last_fn) {
- last_fn = fn;
- _mesa_printf("%s:\n", fn);
- }
-
- _mesa_printf("%d:\t", line);
- _mesa_debug_vp_inst(1, inst);
- }
-}
-
-
-static void emit_op3fn(struct tnl_program *p,
- GLuint op,
- struct ureg dest,
- GLuint mask,
- struct ureg src0,
- struct ureg src1,
- struct ureg src2,
- const char *fn,
- GLuint line)
-{
- GLuint nr = p->program->Base.NumInstructions++;
- struct vp_instruction *inst = &p->program->Instructions[nr];
-
- if (p->program->Base.NumInstructions > MAX_INSN) {
- _mesa_problem(0, "Out of instructions in emit_op3fn\n");
- return;
- }
-
- inst->Opcode = op;
- inst->StringPos = 0;
- inst->Data = 0;
-
- emit_arg( &inst->SrcReg[0], src0 );
- emit_arg( &inst->SrcReg[1], src1 );
- emit_arg( &inst->SrcReg[2], src2 );
-
- emit_dst( &inst->DstReg, dest, mask );
-
- debug_insn(inst, fn, line);
-}
-
-
-#define emit_op3(p, op, dst, mask, src0, src1, src2) \
- emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__)
-
-#define emit_op2(p, op, dst, mask, src0, src1) \
- emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__)
-
-#define emit_op1(p, op, dst, mask, src0) \
- emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__)
-
-
-static struct ureg make_temp( struct tnl_program *p, struct ureg reg )
-{
- if (reg.file == PROGRAM_TEMPORARY &&
- !(p->temp_reserved & (1<<reg.idx)))
- return reg;
- else {
- struct ureg temp = get_temp(p);
- emit_op1(p, VP_OPCODE_MOV, temp, 0, reg);
- return temp;
- }
-}
-
-
-/* Currently no tracking performed of input/output/register size or
- * active elements. Could be used to reduce these operations, as
- * could the matrix type.
- */
-static void emit_matrix_transform_vec4( struct tnl_program *p,
- struct ureg dest,
- const struct ureg *mat,
- struct ureg src)
-{
- emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_X, src, mat[0]);
- emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_Y, src, mat[1]);
- emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_Z, src, mat[2]);
- emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_W, src, mat[3]);
-}
-
-/* This version is much easier to implement if writemasks are not
- * supported natively on the target or (like SSE), the target doesn't
- * have a clean/obvious dotproduct implementation.
- */
-static void emit_transpose_matrix_transform_vec4( struct tnl_program *p,
- struct ureg dest,
- const struct ureg *mat,
- struct ureg src)
-{
- struct ureg tmp;
-
- if (dest.file != PROGRAM_TEMPORARY)
- tmp = get_temp(p);
- else
- tmp = dest;
-
- emit_op2(p, VP_OPCODE_MUL, tmp, 0, swizzle1(src,X), mat[0]);
- emit_op3(p, VP_OPCODE_MAD, tmp, 0, swizzle1(src,Y), mat[1], tmp);
- emit_op3(p, VP_OPCODE_MAD, tmp, 0, swizzle1(src,Z), mat[2], tmp);
- emit_op3(p, VP_OPCODE_MAD, dest, 0, swizzle1(src,W), mat[3], tmp);
-
- if (dest.file != PROGRAM_TEMPORARY)
- release_temp(p, tmp);
-}
-
-static void emit_matrix_transform_vec3( struct tnl_program *p,
- struct ureg dest,
- const struct ureg *mat,
- struct ureg src)
-{
- emit_op2(p, VP_OPCODE_DP3, dest, WRITEMASK_X, src, mat[0]);
- emit_op2(p, VP_OPCODE_DP3, dest, WRITEMASK_Y, src, mat[1]);
- emit_op2(p, VP_OPCODE_DP3, dest, WRITEMASK_Z, src, mat[2]);
-}
-
-
-static void emit_normalize_vec3( struct tnl_program *p,
- struct ureg dest,
- struct ureg src )
-{
- struct ureg tmp = get_temp(p);
- emit_op2(p, VP_OPCODE_DP3, tmp, 0, src, src);
- emit_op1(p, VP_OPCODE_RSQ, tmp, 0, tmp);
- emit_op2(p, VP_OPCODE_MUL, dest, 0, src, tmp);
- release_temp(p, tmp);
-}
-
-static void emit_passthrough( struct tnl_program *p,
- GLuint input,
- GLuint output )
-{
- struct ureg out = register_output(p, output);
- emit_op1(p, VP_OPCODE_MOV, out, 0, register_input(p, input));
-}
-
-static struct ureg get_eye_position( struct tnl_program *p )
-{
- if (is_undef(p->eye_position)) {
- struct ureg pos = register_input( p, VERT_ATTRIB_POS );
- struct ureg modelview[4];
-
- p->eye_position = reserve_temp(p);
-
- if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX, modelview );
-
- emit_matrix_transform_vec4(p, p->eye_position, modelview, pos);
- }
- else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
- STATE_MATRIX_TRANSPOSE, modelview );
-
- emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
- }
- }
-
- return p->eye_position;
-}
-
-
-static struct ureg get_eye_position_normalized( struct tnl_program *p )
-{
- if (is_undef(p->eye_position_normalized)) {
- struct ureg eye = get_eye_position(p);
- p->eye_position_normalized = reserve_temp(p);
- emit_normalize_vec3(p, p->eye_position_normalized, eye);
- }
-
- return p->eye_position_normalized;
-}
-
-
-static struct ureg get_eye_normal( struct tnl_program *p )
-{
- if (is_undef(p->eye_normal)) {
- struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
- struct ureg mvinv[3];
-
- register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2,
- STATE_MATRIX_INVTRANS, mvinv );
-
- p->eye_normal = reserve_temp(p);
-
- /* Transform to eye space:
- */
- emit_matrix_transform_vec3( p, p->eye_normal, mvinv, normal );
-
- /* Normalize/Rescale:
- */
- if (p->state->normalize) {
- emit_normalize_vec3( p, p->eye_normal, p->eye_normal );
- }
- else if (p->state->rescale_normals) {
- struct ureg rescale = register_param2(p, STATE_INTERNAL,
- STATE_NORMAL_SCALE);
-
- emit_op2( p, VP_OPCODE_MUL, p->eye_normal, 0, normal,
- swizzle1(rescale, X));
- }
- }
-
- return p->eye_normal;
-}
-
-
-
-static void build_hpos( struct tnl_program *p )
-{
- struct ureg pos = register_input( p, VERT_ATTRIB_POS );
- struct ureg hpos = register_output( p, VERT_RESULT_HPOS );
- struct ureg mvp[4];
-
- if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX, mvp );
- emit_matrix_transform_vec4( p, hpos, mvp, pos );
- }
- else {
- register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
- STATE_MATRIX_TRANSPOSE, mvp );
- emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
- }
-}
-
-
-static GLuint material_attrib( GLuint side, GLuint property )
-{
- return ((property - STATE_AMBIENT) * 2 +
- side);
-}
-
-static void set_material_flags( struct tnl_program *p )
-{
- p->color_materials = 0;
- p->materials = 0;
-
- if (p->state->light_color_material) {
- p->materials =
- p->color_materials = p->state->light_color_material_mask;
- }
-
- p->materials |= p->state->light_material_mask;
-}
-
-
-static struct ureg get_material( struct tnl_program *p, GLuint side,
- GLuint property )
-{
- GLuint attrib = material_attrib(side, property);
-
- if (p->color_materials & (1<<attrib))
- return register_input(p, VERT_ATTRIB_COLOR0);
- else if (p->materials & (1<<attrib))
- return register_input( p, attrib + _TNL_ATTRIB_MAT_FRONT_AMBIENT );
- else
- return register_param3( p, STATE_MATERIAL, side, property );
-}
-
-#define SCENE_COLOR_BITS(side) (( MAT_BIT_FRONT_EMISSION | \
- MAT_BIT_FRONT_AMBIENT | \
- MAT_BIT_FRONT_DIFFUSE) << (side))
-
-/* Either return a precalculated constant value or emit code to
- * calculate these values dynamically in the case where material calls
- * are present between begin/end pairs.
- *
- * Probably want to shift this to the program compilation phase - if
- * we always emitted the calculation here, a smart compiler could
- * detect that it was constant (given a certain set of inputs), and
- * lift it out of the main loop. That way the programs created here
- * would be independent of the vertex_buffer details.
- */
-static struct ureg get_scenecolor( struct tnl_program *p, GLuint side )
-{
- if (p->materials & SCENE_COLOR_BITS(side)) {
- struct ureg lm_ambient = register_param1(p, STATE_LIGHTMODEL_AMBIENT);
- struct ureg material_emission = get_material(p, side, STATE_EMISSION);
- struct ureg material_ambient = get_material(p, side, STATE_AMBIENT);
- struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE);
- struct ureg tmp = make_temp(p, material_diffuse);
- emit_op3(p, VP_OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient,
- material_ambient, material_emission);
- return tmp;
- }
- else
- return register_param2( p, STATE_LIGHTMODEL_SCENECOLOR, side );
-}
-
-
-static struct ureg get_lightprod( struct tnl_program *p, GLuint light,
- GLuint side, GLuint property )
-{
- GLuint attrib = material_attrib(side, property);
- if (p->materials & (1<<attrib)) {
- struct ureg light_value =
- register_param3(p, STATE_LIGHT, light, property);
- struct ureg material_value = get_material(p, side, property);
- struct ureg tmp = get_temp(p);
- emit_op2(p, VP_OPCODE_MUL, tmp, 0, light_value, material_value);
- return tmp;
- }
- else
- return register_param4(p, STATE_LIGHTPROD, light, side, property);
-}
-
-static struct ureg calculate_light_attenuation( struct tnl_program *p,
- GLuint i,
- struct ureg VPpli,
- struct ureg dist )
-{
- struct ureg attenuation = register_param3(p, STATE_LIGHT, i,
- STATE_ATTENUATION);
- struct ureg att = get_temp(p);
-
- /* Calculate spot attenuation:
- */
- if (!p->state->unit[i].light_spotcutoff_is_180) {
- struct ureg spot_dir = register_param3(p, STATE_LIGHT, i,
- STATE_SPOT_DIRECTION);
- struct ureg spot = get_temp(p);
- struct ureg slt = get_temp(p);
-
- emit_normalize_vec3( p, spot, spot_dir ); /* XXX: precompute! */
- emit_op2(p, VP_OPCODE_DP3, spot, 0, negate(VPpli), spot);
- emit_op2(p, VP_OPCODE_SLT, slt, 0, swizzle1(spot_dir,W), spot);
- emit_op2(p, VP_OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W));
- emit_op2(p, VP_OPCODE_MUL, att, 0, slt, spot);
-
- release_temp(p, spot);
- release_temp(p, slt);
- }
-
- /* Calculate distance attenuation:
- */
- if (p->state->unit[i].light_attenuated) {
-
- /* 1/d,d,d,1/d */
- emit_op1(p, VP_OPCODE_RCP, dist, WRITEMASK_YZ, dist);
- /* 1,d,d*d,1/d */
- emit_op2(p, VP_OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y));
- /* 1/dist-atten */
- emit_op2(p, VP_OPCODE_DP3, dist, 0, attenuation, dist);
-
- if (!p->state->unit[i].light_spotcutoff_is_180) {
- /* dist-atten */
- emit_op1(p, VP_OPCODE_RCP, dist, 0, dist);
- /* spot-atten * dist-atten */
- emit_op2(p, VP_OPCODE_MUL, att, 0, dist, att);
- } else {
- /* dist-atten */
- emit_op1(p, VP_OPCODE_RCP, att, 0, dist);
- }
- }
-
- return att;
-}
-
-
-
-
-
-/* Need to add some addtional parameters to allow lighting in object
- * space - STATE_SPOT_DIRECTION and STATE_HALF implicitly assume eye
- * space lighting.
- */
-static void build_lighting( struct tnl_program *p )
-{
- const GLboolean twoside = p->state->light_twoside;
- const GLboolean separate = p->state->separate_specular;
- GLuint nr_lights = 0, count = 0;
- struct ureg normal = get_eye_normal(p);
- struct ureg lit = get_temp(p);
- struct ureg dots = get_temp(p);
- struct ureg _col0 = undef, _col1 = undef;
- struct ureg _bfc0 = undef, _bfc1 = undef;
- GLuint i;
-
- for (i = 0; i < MAX_LIGHTS; i++)
- if (p->state->unit[i].light_enabled)
- nr_lights++;
-
- set_material_flags(p);
-
- {
- struct ureg shininess = get_material(p, 0, STATE_SHININESS);
- emit_op1(p, VP_OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X));
- release_temp(p, shininess);
-
- _col0 = make_temp(p, get_scenecolor(p, 0));
- if (separate)
- _col1 = make_temp(p, get_identity_param(p));
- else
- _col1 = _col0;
-
- }
-
- if (twoside) {
- struct ureg shininess = get_material(p, 1, STATE_SHININESS);
- emit_op1(p, VP_OPCODE_MOV, dots, WRITEMASK_Z,
- negate(swizzle1(shininess,X)));
- release_temp(p, shininess);
-
- _bfc0 = make_temp(p, get_scenecolor(p, 1));
- if (separate)
- _bfc1 = make_temp(p, get_identity_param(p));
- else
- _bfc1 = _bfc0;
- }
-
-
- /* If no lights, still need to emit the scenecolor.
- */
- {
- struct ureg res0 = register_output( p, VERT_RESULT_COL0 );
- emit_op1(p, VP_OPCODE_MOV, res0, 0, _col0);
- }
-
- if (separate) {
- struct ureg res1 = register_output( p, VERT_RESULT_COL1 );
- emit_op1(p, VP_OPCODE_MOV, res1, 0, _col1);
- }
-
- if (twoside) {
- struct ureg res0 = register_output( p, VERT_RESULT_BFC0 );
- emit_op1(p, VP_OPCODE_MOV, res0, 0, _bfc0);
- }
-
- if (twoside && separate) {
- struct ureg res1 = register_output( p, VERT_RESULT_BFC1 );
- emit_op1(p, VP_OPCODE_MOV, res1, 0, _bfc1);
- }
-
- if (nr_lights == 0) {
- release_temps(p);
- return;
- }
-
-
- for (i = 0; i < MAX_LIGHTS; i++) {
- if (p->state->unit[i].light_enabled) {
- struct ureg half = undef;
- struct ureg att = undef, VPpli = undef;
-
- count++;
-
- if (p->state->unit[i].light_eyepos3_is_zero) {
- /* Can used precomputed constants in this case.
- * Attenuation never applies to infinite lights.
- */
- VPpli = register_param3(p, STATE_LIGHT, i,
- STATE_POSITION_NORMALIZED);
- half = register_param3(p, STATE_LIGHT, i, STATE_HALF);
- }
- else {
- struct ureg Ppli = register_param3(p, STATE_LIGHT, i,
- STATE_POSITION);
- struct ureg V = get_eye_position(p);
- struct ureg dist = get_temp(p);
-
- VPpli = get_temp(p);
- half = get_temp(p);
-
- /* Calulate VPpli vector
- */
- emit_op2(p, VP_OPCODE_SUB, VPpli, 0, Ppli, V);
-
- /* Normalize VPpli. The dist value also used in
- * attenuation below.
- */
- emit_op2(p, VP_OPCODE_DP3, dist, 0, VPpli, VPpli);
- emit_op1(p, VP_OPCODE_RSQ, dist, 0, dist);
- emit_op2(p, VP_OPCODE_MUL, VPpli, 0, VPpli, dist);
-
-
- /* Calculate attenuation:
- */
- if (!p->state->unit[i].light_spotcutoff_is_180 ||
- p->state->unit[i].light_attenuated) {
- att = calculate_light_attenuation(p, i, VPpli, dist);
- }
-
-
- /* Calculate viewer direction, or use infinite viewer:
- */
- if (p->state->light_local_viewer) {
- struct ureg eye_hat = get_eye_position_normalized(p);
- emit_op2(p, VP_OPCODE_SUB, half, 0, VPpli, eye_hat);
- }
- else {
- struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z);
- emit_op2(p, VP_OPCODE_ADD, half, 0, VPpli, z_dir);
- }
-
- emit_normalize_vec3(p, half, half);
-
- release_temp(p, dist);
- }
-
- /* Calculate dot products:
- */
- emit_op2(p, VP_OPCODE_DP3, dots, WRITEMASK_X, normal, VPpli);
- emit_op2(p, VP_OPCODE_DP3, dots, WRITEMASK_Y, normal, half);
-
-
- /* Front face lighting:
- */
- {
- struct ureg ambient = get_lightprod(p, i, 0, STATE_AMBIENT);
- struct ureg diffuse = get_lightprod(p, i, 0, STATE_DIFFUSE);
- struct ureg specular = get_lightprod(p, i, 0, STATE_SPECULAR);
- struct ureg res0, res1;
- GLuint mask0, mask1;
-
- emit_op1(p, VP_OPCODE_LIT, lit, 0, dots);
-
- if (!is_undef(att))
- emit_op2(p, VP_OPCODE_MUL, lit, 0, lit, att);
-
-
- if (count == nr_lights) {
- if (separate) {
- mask0 = WRITEMASK_XYZ;
- mask1 = WRITEMASK_XYZ;
- res0 = register_output( p, VERT_RESULT_COL0 );
- res1 = register_output( p, VERT_RESULT_COL1 );
- }
- else {
- mask0 = 0;
- mask1 = WRITEMASK_XYZ;
- res0 = _col0;
- res1 = register_output( p, VERT_RESULT_COL0 );
- }
- } else {
- mask0 = 0;
- mask1 = 0;
- res0 = _col0;
- res1 = _col1;
- }
-
- emit_op3(p, VP_OPCODE_MAD, _col0, 0, swizzle1(lit,X), ambient, _col0);
- emit_op3(p, VP_OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0);
- emit_op3(p, VP_OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1);
-
- release_temp(p, ambient);
- release_temp(p, diffuse);
- release_temp(p, specular);
- }
-
- /* Back face lighting:
- */
- if (twoside) {
- struct ureg ambient = get_lightprod(p, i, 1, STATE_AMBIENT);
- struct ureg diffuse = get_lightprod(p, i, 1, STATE_DIFFUSE);
- struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR);
- struct ureg res0, res1;
- GLuint mask0, mask1;
-
- emit_op1(p, VP_OPCODE_LIT, lit, 0, negate(swizzle(dots,X,Y,W,Z)));
-
- if (!is_undef(att))
- emit_op2(p, VP_OPCODE_MUL, lit, 0, lit, att);
-
- if (count == nr_lights) {
- if (separate) {
- mask0 = WRITEMASK_XYZ;
- mask1 = WRITEMASK_XYZ;
- res0 = register_output( p, VERT_RESULT_BFC0 );
- res1 = register_output( p, VERT_RESULT_BFC1 );
- }
- else {
- mask0 = 0;
- mask1 = WRITEMASK_XYZ;
- res0 = _bfc0;
- res1 = register_output( p, VERT_RESULT_BFC0 );
- }
- } else {
- res0 = _bfc0;
- res1 = _bfc1;
- mask0 = 0;
- mask1 = 0;
- }
-
- emit_op3(p, VP_OPCODE_MAD, _bfc0, 0, swizzle1(lit,X), ambient, _bfc0);
- emit_op3(p, VP_OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0);
- emit_op3(p, VP_OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1);
-
- release_temp(p, ambient);
- release_temp(p, diffuse);
- release_temp(p, specular);
- }
-
- release_temp(p, half);
- release_temp(p, VPpli);
- release_temp(p, att);
- }
- }
-
- release_temps( p );
-}
-
-
-static void build_fog( struct tnl_program *p )
-{
- struct ureg fog = register_output(p, VERT_RESULT_FOGC);
- struct ureg input;
-
- if (p->state->fog_source_is_depth) {
- input = swizzle1(get_eye_position(p), Z);
- }
- else {
- input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
- }
-
- if (p->state->tnl_do_vertex_fog) {
- struct ureg params = register_param1(p, STATE_FOG_PARAMS);
- struct ureg tmp = get_temp(p);
-
- switch (p->state->fog_mode) {
- case FOG_LINEAR: {
- struct ureg id = get_identity_param(p);
- emit_op2(p, VP_OPCODE_SUB, tmp, 0, swizzle1(params,Z), input);
- emit_op2(p, VP_OPCODE_MUL, tmp, 0, tmp, swizzle1(params,W));
- emit_op2(p, VP_OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
- emit_op2(p, VP_OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
- break;
- }
- case FOG_EXP:
- emit_op1(p, VP_OPCODE_ABS, tmp, 0, input);
- emit_op2(p, VP_OPCODE_MUL, tmp, 0, tmp, swizzle1(params,X));
- emit_op2(p, VP_OPCODE_POW, fog, WRITEMASK_X,
- register_const1f(p, M_E), negate(tmp));
- break;
- case FOG_EXP2:
- emit_op2(p, VP_OPCODE_MUL, tmp, 0, input, swizzle1(params,X));
- emit_op2(p, VP_OPCODE_MUL, tmp, 0, tmp, tmp);
- emit_op2(p, VP_OPCODE_POW, fog, WRITEMASK_X,
- register_const1f(p, M_E), negate(tmp));
- break;
- }
-
- release_temp(p, tmp);
- }
- else {
- /* results = incoming fog coords (compute fog per-fragment later)
- *
- * KW: Is it really necessary to do anything in this case?
- */
- emit_op1(p, VP_OPCODE_MOV, fog, WRITEMASK_X, input);
- }
-}
-
-static void build_reflect_texgen( struct tnl_program *p,
- struct ureg dest,
- GLuint writemask )
-{
- struct ureg normal = get_eye_normal(p);
- struct ureg eye_hat = get_eye_position_normalized(p);
- struct ureg tmp = get_temp(p);
-
- /* n.u */
- emit_op2(p, VP_OPCODE_DP3, tmp, 0, normal, eye_hat);
- /* 2n.u */
- emit_op2(p, VP_OPCODE_ADD, tmp, 0, tmp, tmp);
- /* (-2n.u)n + u */
- emit_op3(p, VP_OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat);
-}
-
-static void build_sphere_texgen( struct tnl_program *p,
- struct ureg dest,
- GLuint writemask )
-{
- struct ureg normal = get_eye_normal(p);
- struct ureg eye_hat = get_eye_position_normalized(p);
- struct ureg tmp = get_temp(p);
- struct ureg half = register_scalar_const(p, .5);
- struct ureg r = get_temp(p);
- struct ureg inv_m = get_temp(p);
- struct ureg id = get_identity_param(p);
-
- /* Could share the above calculations, but it would be
- * a fairly odd state for someone to set (both sphere and
- * reflection active for different texture coordinate
- * components. Of course - if two texture units enable
- * reflect and/or sphere, things start to tilt in favour
- * of seperating this out:
- */
-
- /* n.u */
- emit_op2(p, VP_OPCODE_DP3, tmp, 0, normal, eye_hat);
- /* 2n.u */
- emit_op2(p, VP_OPCODE_ADD, tmp, 0, tmp, tmp);
- /* (-2n.u)n + u */
- emit_op3(p, VP_OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat);
- /* r + 0,0,1 */
- emit_op2(p, VP_OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z));
- /* rx^2 + ry^2 + (rz+1)^2 */
- emit_op2(p, VP_OPCODE_DP3, tmp, 0, tmp, tmp);
- /* 2/m */
- emit_op1(p, VP_OPCODE_RSQ, tmp, 0, tmp);
- /* 1/m */
- emit_op2(p, VP_OPCODE_MUL, inv_m, 0, tmp, half);
- /* r/m + 1/2 */
- emit_op3(p, VP_OPCODE_MAD, dest, writemask, r, inv_m, half);
-
- release_temp(p, tmp);
- release_temp(p, r);
- release_temp(p, inv_m);
-}
-
-
-static void build_texture_transform( struct tnl_program *p )
-{
- GLuint i, j;
-
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- GLuint texmat_enabled = p->state->unit[i].texmat_enabled;
-
- if (p->state->unit[i].texgen_enabled || texmat_enabled) {
- struct ureg out = register_output(p, VERT_RESULT_TEX0 + i);
- struct ureg out_texgen = undef;
-
- if (p->state->unit[i].texgen_enabled) {
- GLuint copy_mask = 0;
- GLuint sphere_mask = 0;
- GLuint reflect_mask = 0;
- GLuint normal_mask = 0;
- GLuint modes[4];
-
- if (texmat_enabled)
- out_texgen = get_temp(p);
- else
- out_texgen = out;
-
- modes[0] = p->state->unit[i].texgen_mode0;
- modes[1] = p->state->unit[i].texgen_mode1;
- modes[2] = p->state->unit[i].texgen_mode2;
- modes[3] = p->state->unit[i].texgen_mode3;
-
- for (j = 0; j < 4; j++) {
- switch (modes[j]) {
- case TXG_OBJ_LINEAR: {
- struct ureg obj = register_input(p, VERT_ATTRIB_POS);
- struct ureg plane =
- register_param3(p, STATE_TEXGEN, i,
- STATE_TEXGEN_OBJECT_S + j);
-
- emit_op2(p, VP_OPCODE_DP4, out_texgen, WRITEMASK_X << j,
- obj, plane );
- break;
- }
- case TXG_EYE_LINEAR: {
- struct ureg eye = get_eye_position(p);
- struct ureg plane =
- register_param3(p, STATE_TEXGEN, i,
- STATE_TEXGEN_EYE_S + j);
-
- emit_op2(p, VP_OPCODE_DP4, out_texgen, WRITEMASK_X << j,
- eye, plane );
- break;
- }
- case TXG_SPHERE_MAP:
- sphere_mask |= WRITEMASK_X << j;
- break;
- case TXG_REFLECTION_MAP:
- reflect_mask |= WRITEMASK_X << j;
- break;
- case TXG_NORMAL_MAP:
- normal_mask |= WRITEMASK_X << j;
- break;
- case TXG_NONE:
- copy_mask |= WRITEMASK_X << j;
- }
-
- }
-
-
- if (sphere_mask) {
- build_sphere_texgen(p, out_texgen, sphere_mask);
- }
-
- if (reflect_mask) {
- build_reflect_texgen(p, out_texgen, reflect_mask);
- }
-
- if (normal_mask) {
- struct ureg normal = get_eye_normal(p);
- emit_op1(p, VP_OPCODE_MOV, out_texgen, normal_mask, normal );
- }
-
- if (copy_mask) {
- struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i);
- emit_op1(p, VP_OPCODE_MOV, out_texgen, copy_mask, in );
- }
- }
-
- if (texmat_enabled) {
- struct ureg texmat[4];
- struct ureg in = (!is_undef(out_texgen) ?
- out_texgen :
- register_input(p, VERT_ATTRIB_TEX0+i));
- if (PREFER_DP4) {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX, texmat );
- emit_matrix_transform_vec4( p, out, texmat, in );
- }
- else {
- register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
- 0, 3, STATE_MATRIX_TRANSPOSE, texmat );
- emit_transpose_matrix_transform_vec4( p, out, texmat, in );
- }
- }
-
- release_temps(p);
- }
- else if (p->state->unit[i].texunit_really_enabled) {
- /* KW: _ReallyEnabled isn't sufficient? Need to know whether
- * this texture unit is referenced by the fragment shader.
- */
- emit_passthrough(p, VERT_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i);
- }
- }
-}
-
-
-/* Seems like it could be tighter:
- */
-static void build_pointsize( struct tnl_program *p )
-{
- struct ureg eye = get_eye_position(p);
- struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
- struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
- struct ureg out = register_output(p, VERT_RESULT_PSIZ);
- struct ureg ut = get_temp(p);
-
- /* 1, -Z, Z * Z, 1 */
- emit_op1(p, VP_OPCODE_MOV, ut, 0, swizzle1(get_identity_param(p), W));
- emit_op2(p, VP_OPCODE_MUL, ut, WRITEMASK_YZ, ut, negate(swizzle1(eye, Z)));
- emit_op2(p, VP_OPCODE_MUL, ut, WRITEMASK_Z, ut, negate(swizzle1(eye, Z)));
-
-
- /* p1 + p2 * dist + p3 * dist * dist, 0 */
- emit_op2(p, VP_OPCODE_DP3, ut, 0, ut, state_attenuation);
-
- /* 1 / factor */
- emit_op1(p, VP_OPCODE_RCP, ut, 0, ut );
-
- /* out = pointSize / factor */
- emit_op2(p, VP_OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
-
- release_temp(p, ut);
-}
-
-static void build_tnl_program( struct tnl_program *p )
-{ /* Emit the program, starting with modelviewproject:
- */
- build_hpos(p);
-
- /* Lighting calculations:
- */
- if (p->state->light_global_enabled)
- build_lighting(p);
- else
- emit_passthrough(p, VERT_ATTRIB_COLOR0, VERT_RESULT_COL0);
-
- if (p->state->fog_enabled)
- build_fog(p);
-
- if (p->state->texture_enabled_global)
- build_texture_transform(p);
-
- if (p->state->point_attenuated)
- build_pointsize(p);
-
- /* Finish up:
- */
- emit_op1(p, VP_OPCODE_END, undef, 0, undef);
-
- /* Disassemble:
- */
- if (DISASSEM) {
- _mesa_printf ("\n");
- }
-}
-
-
-static void
-create_new_program( const struct state_key *key,
- struct vertex_program *program,
- GLuint max_temps)
-{
- struct tnl_program p;
-
- _mesa_memset(&p, 0, sizeof(p));
- p.state = key;
- p.program = program;
- p.eye_position = undef;
- p.eye_position_normalized = undef;
- p.eye_normal = undef;
- p.identity = undef;
- p.temp_in_use = 0;
-
- if (max_temps >= sizeof(int) * 8)
- p.temp_reserved = 0;
- else
- p.temp_reserved = ~((1<<max_temps)-1);
-
- p.program->Instructions = MALLOC(sizeof(struct vp_instruction) * MAX_INSN);
- p.program->Base.String = 0;
- p.program->Base.NumInstructions =
- p.program->Base.NumTemporaries =
- p.program->Base.NumParameters =
- p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0;
- p.program->Parameters = _mesa_new_parameter_list();
- p.program->InputsRead = 0;
- p.program->OutputsWritten = 0;
-
- build_tnl_program( &p );
-}
-
-static void *search_cache( struct tnl_cache *cache,
- GLuint hash,
- const void *key,
- GLuint keysize)
-{
- struct tnl_cache *c;
-
- for (c = cache; c; c = c->next) {
- if (c->hash == hash && memcmp(c->key, key, keysize) == 0)
- return c->data;
- }
-
- return NULL;
-}
-
-static void cache_item( struct tnl_cache **cache,
- GLuint hash,
- void *key,
- void *data )
-{
- struct tnl_cache *c = MALLOC(sizeof(*c));
- c->hash = hash;
- c->key = key;
- c->data = data;
- c->next = *cache;
- *cache = c;
-}
-
-static GLuint hash_key( struct state_key *key )
-{
- GLuint *ikey = (GLuint *)key;
- GLuint hash = 0, i;
-
- /* I'm sure this can be improved on, but speed is important:
- */
- for (i = 0; i < sizeof(*key)/sizeof(GLuint); i++)
- hash ^= ikey[i];
-
- return hash;
-}
-
-void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct state_key *key;
- GLuint hash;
-
- if (ctx->VertexProgram._Enabled)
- return;
-
- /* Grab all the relevent state and put it in a single structure:
- */
- key = make_state_key(ctx);
- hash = hash_key(key);
-
- /* Look for an already-prepared program for this state:
- */
- ctx->_TnlProgram = (struct vertex_program *)
- search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
-
- /* OK, we'll have to build a new one:
- */
- if (!ctx->_TnlProgram) {
- if (0)
- _mesa_printf("Build new TNL program\n");
-
- ctx->_TnlProgram = (struct vertex_program *)
- ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
-
- create_new_program( key, ctx->_TnlProgram,
- ctx->Const.MaxVertexProgramTemps );
-
- cache_item(&tnl->vp_cache, hash, key, ctx->_TnlProgram );
- }
- else {
- FREE(key);
- if (0)
- _mesa_printf("Found existing TNL program for key %x\n", hash);
- }
-
- /* Need a BindProgram callback for the driver?
- */
-}
-
-
-void _tnl_ProgramCacheDestroy( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_cache *a, *tmp;
-
- for (a = tnl->vp_cache ; a; a = tmp) {
- tmp = a->next;
- FREE(a->key);
- FREE(a->data);
- FREE(a);
- }
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h
deleted file mode 100644
index 83e685b1a..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.3
- *
- * Copyright (C) 2005 Tungsten Graphics 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
- * TUNGSTEN GRAPHICS 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_ARB_BUILD_H
-#define _T_ARB_BUILD_H
-
-#include "mtypes.h"
-
-extern void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx );
-
-extern void _tnl_ProgramCacheDestroy( GLcontext *ctx );
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c
deleted file mode 100644
index c86c160d2..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c
+++ /dev/null
@@ -1,995 +0,0 @@
-/* $XFree86$ */
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "vtxfmt.h"
-#include "dlist.h"
-#include "state.h"
-#include "light.h"
-#include "api_arrayelt.h"
-#include "api_noop.h"
-#include "t_vtx_api.h"
-#include "simple_list.h"
-
-#include "dispatch.h"
-
-static void reset_attrfv( TNLcontext *tnl );
-
-static tnl_attrfv_func choose[_TNL_MAX_ATTR_CODEGEN+1][4]; /* +1 for ERROR_ATTRIB */
-static tnl_attrfv_func generic_attr_func[_TNL_MAX_ATTR_CODEGEN][4];
-
-
-/* Close off the last primitive, execute the buffer, restart the
- * primitive.
- */
-static void _tnl_wrap_buffers( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
-
- if (tnl->vtx.prim_count == 0) {
- tnl->vtx.copied.nr = 0;
- tnl->vtx.counter = tnl->vtx.initial_counter;
- tnl->vtx.vbptr = tnl->vtx.buffer;
- }
- else {
- GLuint last_prim = tnl->vtx.prim[tnl->vtx.prim_count-1].mode;
- GLuint last_count;
-
- if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- GLint i = tnl->vtx.prim_count - 1;
- assert(i >= 0);
- tnl->vtx.prim[i].count = ((tnl->vtx.initial_counter -
- tnl->vtx.counter) -
- tnl->vtx.prim[i].start);
- }
-
- last_count = tnl->vtx.prim[tnl->vtx.prim_count-1].count;
-
- /* Execute the buffer and save copied vertices.
- */
- if (tnl->vtx.counter != tnl->vtx.initial_counter)
- _tnl_flush_vtx( ctx );
- else {
- tnl->vtx.prim_count = 0;
- tnl->vtx.copied.nr = 0;
- }
-
- /* Emit a glBegin to start the new list.
- */
- assert(tnl->vtx.prim_count == 0);
-
- if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- tnl->vtx.prim[0].mode = ctx->Driver.CurrentExecPrimitive;
- tnl->vtx.prim[0].start = 0;
- tnl->vtx.prim[0].count = 0;
- tnl->vtx.prim_count++;
-
- if (tnl->vtx.copied.nr == last_count)
- tnl->vtx.prim[0].mode |= last_prim & PRIM_BEGIN;
- }
- }
-}
-
-
-/* Deal with buffer wrapping where provoked by the vertex buffer
- * filling up, as opposed to upgrade_vertex().
- *
- * Make it GLAPIENTRY, so we can tail from the codegen'ed Vertex*fv
- */
-void GLAPIENTRY _tnl_wrap_filled_vertex( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLfloat *data = tnl->vtx.copied.buffer;
- GLuint i;
-
- /* Run pipeline on current vertices, copy wrapped vertices
- * to tnl->copied.
- */
- _tnl_wrap_buffers( ctx );
-
- /* Copy stored stored vertices to start of new list.
- */
- assert(tnl->vtx.counter > tnl->vtx.copied.nr);
-
- for (i = 0 ; i < tnl->vtx.copied.nr ; i++) {
- _mesa_memcpy( tnl->vtx.vbptr, data,
- tnl->vtx.vertex_size * sizeof(GLfloat));
- tnl->vtx.vbptr += tnl->vtx.vertex_size;
- data += tnl->vtx.vertex_size;
- tnl->vtx.counter--;
- }
-
- tnl->vtx.copied.nr = 0;
-}
-
-
-/*
- * Copy the active vertex's values to the ctx->Current fields.
- */
-static void _tnl_copy_to_current( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_INDEX ; i++) {
- if (tnl->vtx.attrsz[i]) {
- /* Note: the tnl->vtx.current[i] pointers points to
- * the ctx->Current fields. The first 16 or so, anyway.
- */
- COPY_CLEAN_4V(tnl->vtx.current[i],
- tnl->vtx.attrsz[i],
- tnl->vtx.attrptr[i]);
- }
- }
-
- /* color index is special (it's not a float[4] so COPY_CLEAN_4V above
- * will trash adjacent memory!)
- */
- if (tnl->vtx.attrsz[_TNL_ATTRIB_INDEX]) {
- ctx->Current.Index = tnl->vtx.attrptr[_TNL_ATTRIB_INDEX][0];
- }
-
- /* Edgeflag requires additional treatment:
- */
- if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- ctx->Current.EdgeFlag =
- (tnl->vtx.CurrentFloatEdgeFlag == 1.0);
- }
-
- /* Colormaterial -- this kindof sucks.
- */
- if (ctx->Light.ColorMaterialEnabled) {
- _mesa_update_color_material(ctx,
- ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
- }
-
- if (tnl->vtx.have_materials) {
- tnl->Driver.NotifyMaterialChange( ctx );
- }
-
- ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
-}
-
-
-static void _tnl_copy_from_current( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i;
-
- /* Edgeflag requires additional treatment:
- */
- tnl->vtx.CurrentFloatEdgeFlag =
- (GLfloat)ctx->Current.EdgeFlag;
-
- for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_MAX ; i++)
- switch (tnl->vtx.attrsz[i]) {
- case 4: tnl->vtx.attrptr[i][3] = tnl->vtx.current[i][3];
- case 3: tnl->vtx.attrptr[i][2] = tnl->vtx.current[i][2];
- case 2: tnl->vtx.attrptr[i][1] = tnl->vtx.current[i][1];
- case 1: tnl->vtx.attrptr[i][0] = tnl->vtx.current[i][0];
- break;
- }
-
- ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
-}
-
-
-/* Flush existing data, set new attrib size, replay copied vertices.
- */
-static void _tnl_wrap_upgrade_vertex( GLcontext *ctx,
- GLuint attr,
- GLuint newsz )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint oldsz;
- GLuint i;
- GLfloat *tmp;
- GLint lastcount = tnl->vtx.initial_counter - tnl->vtx.counter;
-
- /* Run pipeline on current vertices, copy wrapped vertices
- * to tnl->vtx.copied.
- */
- _tnl_wrap_buffers( ctx );
-
-
- /* Do a COPY_TO_CURRENT to ensure back-copying works for the case
- * when the attribute already exists in the vertex and is having
- * its size increased.
- */
- _tnl_copy_to_current( ctx );
-
-
- /* Heuristic: Attempt to isolate attributes received outside
- * begin/end so that they don't bloat the vertices.
- */
- if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END &&
- tnl->vtx.attrsz[attr] == 0 &&
- lastcount > 8 &&
- tnl->vtx.vertex_size) {
- reset_attrfv( tnl );
- }
-
- /* Fix up sizes:
- */
- oldsz = tnl->vtx.attrsz[attr];
- tnl->vtx.attrsz[attr] = newsz;
-
- tnl->vtx.vertex_size += newsz - oldsz;
- tnl->vtx.counter = MIN2( VERT_BUFFER_SIZE / tnl->vtx.vertex_size,
- ctx->Const.MaxArrayLockSize );
- tnl->vtx.initial_counter = tnl->vtx.counter;
- tnl->vtx.vbptr = tnl->vtx.buffer;
-
-
- /* Recalculate all the attrptr[] values
- */
- for (i = 0, tmp = tnl->vtx.vertex ; i < _TNL_ATTRIB_MAX ; i++) {
- if (tnl->vtx.attrsz[i]) {
- tnl->vtx.attrptr[i] = tmp;
- tmp += tnl->vtx.attrsz[i];
- }
- else
- tnl->vtx.attrptr[i] = NULL; /* will not be dereferenced */
- }
-
- /* Copy from current to repopulate the vertex with correct values.
- */
- _tnl_copy_from_current( ctx );
-
- /* Replay stored vertices to translate them
- * to new format here.
- *
- * -- No need to replay - just copy piecewise
- */
- if (tnl->vtx.copied.nr)
- {
- GLfloat *data = tnl->vtx.copied.buffer;
- GLfloat *dest = tnl->vtx.buffer;
- GLuint j;
-
- for (i = 0 ; i < tnl->vtx.copied.nr ; i++) {
- for (j = 0 ; j < _TNL_ATTRIB_MAX ; j++) {
- if (tnl->vtx.attrsz[j]) {
- if (j == attr) {
- if (oldsz) {
- COPY_CLEAN_4V( dest, oldsz, data );
- data += oldsz;
- dest += newsz;
- } else {
- COPY_SZ_4V( dest, newsz, tnl->vtx.current[j] );
- dest += newsz;
- }
- }
- else {
- GLuint sz = tnl->vtx.attrsz[j];
- COPY_SZ_4V( dest, sz, data );
- dest += sz;
- data += sz;
- }
- }
- }
- }
-
- tnl->vtx.vbptr = dest;
- tnl->vtx.counter -= tnl->vtx.copied.nr;
- tnl->vtx.copied.nr = 0;
- }
-
- /* For codegen - attrptr's may have changed, so need to redo
- * codegen. Might be a reasonable place to try & detect attributes
- * in the vertex which aren't being submitted any more.
- */
- for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
- if (tnl->vtx.attrsz[i]) {
- GLuint j = tnl->vtx.attrsz[i] - 1;
-
- if (i < _TNL_MAX_ATTR_CODEGEN)
- tnl->vtx.tabfv[i][j] = choose[i][j];
- }
-
-}
-
-
-static void _tnl_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- static const GLfloat id[4] = { 0, 0, 0, 1 };
- int i;
-
- if (tnl->vtx.attrsz[attr] < sz) {
- /* New size is larger. Need to flush existing vertices and get
- * an enlarged vertex format.
- */
- _tnl_wrap_upgrade_vertex( ctx, attr, sz );
- }
- else if (tnl->vtx.attrsz[attr] > sz) {
- /* New size is smaller - just need to fill in some
- * zeros. Don't need to flush or wrap.
- */
- for (i = sz ; i <= tnl->vtx.attrsz[attr] ; i++)
- tnl->vtx.attrptr[attr][i-1] = id[i-1];
- }
-
- /* Does setting NeedFlush belong here? Necessitates resetting
- * vtxfmt on each flush (otherwise flags won't get reset
- * afterwards).
- */
- if (attr == 0)
- ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
- else
- ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
-}
-
-#ifdef USE_X86_ASM
-
-static struct _tnl_dynfn *lookup( struct _tnl_dynfn *l, GLuint key )
-{
- struct _tnl_dynfn *f;
-
- foreach( f, l ) {
- if (f->key == key)
- return f;
- }
-
- return NULL;
-}
-
-
-static tnl_attrfv_func do_codegen( GLcontext *ctx, GLuint attr, GLuint sz )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct _tnl_dynfn *dfn = NULL;
-
- if (attr == 0) {
- GLuint key = tnl->vtx.vertex_size;
-
- dfn = lookup( &tnl->vtx.cache.Vertex[sz-1], key );
-
- if (!dfn)
- dfn = tnl->vtx.gen.Vertex[sz-1]( ctx, key );
- }
- else {
- GLuint key = (GLuint) tnl->vtx.attrptr[attr];
-
- dfn = lookup( &tnl->vtx.cache.Attribute[sz-1], key );
-
- if (!dfn)
- dfn = tnl->vtx.gen.Attribute[sz-1]( ctx, key );
- }
-
- if (dfn)
- return *(tnl_attrfv_func *) &dfn->code;
- else
- return NULL;
-}
-
-#endif /* USE_X86_ASM */
-
-/* Helper function for 'CHOOSE' macro. Do what's necessary when an
- * entrypoint is called for the first time.
- */
-
-static tnl_attrfv_func do_choose( GLuint attr, GLuint sz )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint oldsz = tnl->vtx.attrsz[attr];
-
- assert(attr < _TNL_MAX_ATTR_CODEGEN);
-
- if (oldsz != sz) {
- /* Reset any active pointers for this attribute
- */
- if (oldsz)
- tnl->vtx.tabfv[attr][oldsz-1] = choose[attr][oldsz-1];
-
- _tnl_fixup_vertex( ctx, attr, sz );
-
- }
-
-
- /* Try to use codegen:
- */
-#ifdef USE_X86_ASM
- if (tnl->AllowCodegen)
- tnl->vtx.tabfv[attr][sz-1] = do_codegen( ctx, attr, sz );
- else
-#endif
- tnl->vtx.tabfv[attr][sz-1] = NULL;
-
- /* Else use generic version:
- */
- if (!tnl->vtx.tabfv[attr][sz-1])
- tnl->vtx.tabfv[attr][sz-1] = generic_attr_func[attr][sz-1];
-
- return tnl->vtx.tabfv[attr][sz-1];
-}
-
-
-
-#define CHOOSE( ATTR, N ) \
-static void choose_##ATTR##_##N( const GLfloat *v ) \
-{ \
- tnl_attrfv_func f = do_choose(ATTR, N); \
- f( v ); \
-}
-
-#define CHOOSERS( ATTRIB ) \
- CHOOSE( ATTRIB, 1 ) \
- CHOOSE( ATTRIB, 2 ) \
- CHOOSE( ATTRIB, 3 ) \
- CHOOSE( ATTRIB, 4 ) \
-
-
-#define INIT_CHOOSERS(ATTR) \
- choose[ATTR][0] = choose_##ATTR##_1; \
- choose[ATTR][1] = choose_##ATTR##_2; \
- choose[ATTR][2] = choose_##ATTR##_3; \
- choose[ATTR][3] = choose_##ATTR##_4;
-
-CHOOSERS( 0 )
-CHOOSERS( 1 )
-CHOOSERS( 2 )
-CHOOSERS( 3 )
-CHOOSERS( 4 )
-CHOOSERS( 5 )
-CHOOSERS( 6 )
-CHOOSERS( 7 )
-CHOOSERS( 8 )
-CHOOSERS( 9 )
-CHOOSERS( 10 )
-CHOOSERS( 11 )
-CHOOSERS( 12 )
-CHOOSERS( 13 )
-CHOOSERS( 14 )
-CHOOSERS( 15 )
-
-static void error_attrib( const GLfloat *unused )
-{
- GET_CURRENT_CONTEXT( ctx );
- (void) unused;
- _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib" );
-}
-
-
-
-static void reset_attrfv( TNLcontext *tnl )
-{
- GLuint i;
-
- for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
- if (tnl->vtx.attrsz[i]) {
- GLint j = tnl->vtx.attrsz[i] - 1;
- tnl->vtx.attrsz[i] = 0;
-
- if (i < _TNL_MAX_ATTR_CODEGEN) {
- while (j >= 0) {
- tnl->vtx.tabfv[i][j] = choose[i][j];
- j--;
- }
- }
- }
-
- tnl->vtx.vertex_size = 0;
- tnl->vtx.have_materials = 0;
-}
-
-
-
-/* Materials:
- *
- * These are treated as per-vertex attributes, at indices above where
- * the NV_vertex_program leaves off. There are a lot of good things
- * about treating materials this way.
- *
- * However: I don't want to double the number of generated functions
- * just to cope with this, so I unroll the 'C' varients of CHOOSE and
- * ATTRF into this function, and dispense with codegen and
- * second-level dispatch.
- *
- * There is no aliasing of material attributes with other entrypoints.
- */
-#define OTHER_ATTR( A, N, params ) \
-do { \
- if (tnl->vtx.attrsz[A] != N) { \
- _tnl_fixup_vertex( ctx, A, N ); \
- } \
- \
- { \
- GLfloat *dest = tnl->vtx.attrptr[A]; \
- if (N>0) dest[0] = (params)[0]; \
- if (N>1) dest[1] = (params)[1]; \
- if (N>2) dest[2] = (params)[2]; \
- if (N>3) dest[3] = (params)[3]; \
- } \
-} while (0)
-
-
-#define MAT( ATTR, N, face, params ) \
-do { \
- if (face != GL_BACK) \
- OTHER_ATTR( ATTR, N, params ); /* front */ \
- if (face != GL_FRONT) \
- OTHER_ATTR( ATTR + 1, N, params ); /* back */ \
-} while (0)
-
-
-/* Colormaterial is dealt with later on.
- */
-static void GLAPIENTRY _tnl_Materialfv( GLenum face, GLenum pname,
- const GLfloat *params )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- switch (face) {
- case GL_FRONT:
- case GL_BACK:
- case GL_FRONT_AND_BACK:
- break;
-
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glMaterialfv" );
- return;
- }
-
- switch (pname) {
- case GL_EMISSION:
- MAT( _TNL_ATTRIB_MAT_FRONT_EMISSION, 4, face, params );
- break;
- case GL_AMBIENT:
- MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
- break;
- case GL_DIFFUSE:
- MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
- break;
- case GL_SPECULAR:
- MAT( _TNL_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params );
- break;
- case GL_SHININESS:
- MAT( _TNL_ATTRIB_MAT_FRONT_SHININESS, 1, face, params );
- break;
- case GL_COLOR_INDEXES:
- MAT( _TNL_ATTRIB_MAT_FRONT_INDEXES, 3, face, params );
- break;
- case GL_AMBIENT_AND_DIFFUSE:
- MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
- MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
- break;
- default:
- _mesa_error( ctx, GL_INVALID_ENUM, "glMaterialfv" );
- return;
- }
-
- tnl->vtx.have_materials = GL_TRUE;
-}
-
-
-static void GLAPIENTRY _tnl_EdgeFlag( GLboolean b )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLfloat f = (GLfloat)b;
-
- OTHER_ATTR( _TNL_ATTRIB_EDGEFLAG, 1, &f );
-}
-
-static void GLAPIENTRY _tnl_EdgeFlagv( const GLboolean *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLfloat f = (GLfloat)v[0];
-
- OTHER_ATTR( _TNL_ATTRIB_EDGEFLAG, 1, &f );
-}
-
-static void GLAPIENTRY _tnl_Indexf( GLfloat f )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- OTHER_ATTR( _TNL_ATTRIB_INDEX, 1, &f );
-}
-
-static void GLAPIENTRY _tnl_Indexfv( const GLfloat *v )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- OTHER_ATTR( _TNL_ATTRIB_INDEX, 1, v );
-}
-
-/* Eval
- */
-static void GLAPIENTRY _tnl_EvalCoord1f( GLfloat u )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /* TODO: use a CHOOSE() function for this: */
- {
- GLint i;
- if (tnl->vtx.eval.new_state)
- _tnl_update_eval( ctx );
-
- for (i = 0 ; i <= _TNL_ATTRIB_INDEX ; i++) {
- if (tnl->vtx.eval.map1[i].map)
- if (tnl->vtx.attrsz[i] != tnl->vtx.eval.map1[i].sz)
- _tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map1[i].sz );
- }
- }
-
-
- _mesa_memcpy( tnl->vtx.copied.buffer, tnl->vtx.vertex,
- tnl->vtx.vertex_size * sizeof(GLfloat));
-
- _tnl_do_EvalCoord1f( ctx, u );
-
- _mesa_memcpy( tnl->vtx.vertex, tnl->vtx.copied.buffer,
- tnl->vtx.vertex_size * sizeof(GLfloat));
-}
-
-static void GLAPIENTRY _tnl_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_CURRENT_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /* TODO: use a CHOOSE() function for this: */
- {
- GLint i;
- if (tnl->vtx.eval.new_state)
- _tnl_update_eval( ctx );
-
- for (i = 0 ; i <= _TNL_ATTRIB_INDEX ; i++) {
- if (tnl->vtx.eval.map2[i].map)
- if (tnl->vtx.attrsz[i] != tnl->vtx.eval.map2[i].sz)
- _tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map2[i].sz );
- }
-
- if (ctx->Eval.AutoNormal)
- if (tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL] != 3)
- _tnl_fixup_vertex( ctx, _TNL_ATTRIB_NORMAL, 3 );
- }
-
- _mesa_memcpy( tnl->vtx.copied.buffer, tnl->vtx.vertex,
- tnl->vtx.vertex_size * sizeof(GLfloat));
-
- _tnl_do_EvalCoord2f( ctx, u, v );
-
- _mesa_memcpy( tnl->vtx.vertex, tnl->vtx.copied.buffer,
- tnl->vtx.vertex_size * sizeof(GLfloat));
-}
-
-static void GLAPIENTRY _tnl_EvalCoord1fv( const GLfloat *u )
-{
- _tnl_EvalCoord1f( u[0] );
-}
-
-static void GLAPIENTRY _tnl_EvalCoord2fv( const GLfloat *u )
-{
- _tnl_EvalCoord2f( u[0], u[1] );
-}
-
-static void GLAPIENTRY _tnl_EvalPoint1( GLint i )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLfloat du = ((ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) /
- (GLfloat) ctx->Eval.MapGrid1un);
- GLfloat u = i * du + ctx->Eval.MapGrid1u1;
-
- _tnl_EvalCoord1f( u );
-}
-
-
-static void GLAPIENTRY _tnl_EvalPoint2( GLint i, GLint j )
-{
- GET_CURRENT_CONTEXT( ctx );
- GLfloat du = ((ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) /
- (GLfloat) ctx->Eval.MapGrid2un);
- GLfloat dv = ((ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) /
- (GLfloat) ctx->Eval.MapGrid2vn);
- GLfloat u = i * du + ctx->Eval.MapGrid2u1;
- GLfloat v = j * dv + ctx->Eval.MapGrid2v1;
-
- _tnl_EvalCoord2f( u, v );
-}
-
-
-/* Build a list of primitives on the fly. Keep
- * ctx->Driver.CurrentExecPrimitive uptodate as well.
- */
-static void GLAPIENTRY _tnl_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT( ctx );
-
- if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) {
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- if (ctx->NewState) {
- _mesa_update_state( ctx );
-
- if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
- (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBegin (invalid vertex/fragment program)");
- tnl->DiscardPrimitive = GL_TRUE;
- return;
- }
-
- if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
- _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
- "glBegin(incomplete framebuffer)");
- tnl->DiscardPrimitive = GL_TRUE;
- return;
- }
-
- tnl->DiscardPrimitive = GL_FALSE;
-
- if (!(tnl->Driver.NotifyBegin &&
- tnl->Driver.NotifyBegin( ctx, mode )))
- CALL_Begin(ctx->Exec, (mode));
- return;
- }
-
- /* Heuristic: attempt to isolate attributes occuring outside
- * begin/end pairs.
- */
- if (tnl->vtx.vertex_size && !tnl->vtx.attrsz[0])
- _tnl_FlushVertices( ctx, ~0 );
-
- i = tnl->vtx.prim_count++;
- tnl->vtx.prim[i].mode = mode | PRIM_BEGIN;
- tnl->vtx.prim[i].start = tnl->vtx.initial_counter - tnl->vtx.counter;
- tnl->vtx.prim[i].count = 0;
-
- ctx->Driver.CurrentExecPrimitive = mode;
- }
- else
- _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
-
-}
-
-static void GLAPIENTRY _tnl_End( void )
-{
- GET_CURRENT_CONTEXT( ctx );
-
- if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- int idx = tnl->vtx.initial_counter - tnl->vtx.counter;
- int i = tnl->vtx.prim_count - 1;
-
- tnl->vtx.prim[i].mode |= PRIM_END;
- tnl->vtx.prim[i].count = idx - tnl->vtx.prim[i].start;
-
- ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
-
- /* Two choices which effect the way vertex attributes are
- * carried over (or not) between adjacent primitives.
- */
-#if 0
- if (tnl->vtx.prim_count == TNL_MAX_PRIM)
- _tnl_FlushVertices( ctx, ~0 );
-#else
- if (tnl->vtx.prim_count == TNL_MAX_PRIM)
- _tnl_flush_vtx( ctx );
-#endif
-
- }
- else
- _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
-}
-
-
-static void _tnl_exec_vtxfmt_init( GLcontext *ctx )
-{
- GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
-
- vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
- vfmt->Begin = _tnl_Begin;
- vfmt->CallList = _mesa_CallList;
- vfmt->CallLists = _mesa_CallLists;
- 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->Indexf = _tnl_Indexf;
- vfmt->Indexfv = _tnl_Indexfv;
- vfmt->Materialfv = _tnl_Materialfv;
-
- vfmt->Rectf = _mesa_noop_Rectf;
- vfmt->EvalMesh1 = _mesa_noop_EvalMesh1;
- vfmt->EvalMesh2 = _mesa_noop_EvalMesh2;
-}
-
-
-
-void _tnl_FlushVertices( GLcontext *ctx, GLuint flags )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- (void) flags;
-
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
- /* still inside a glBegin/End pair. How'd we get here??? */
- return;
- }
-
- if (tnl->DiscardPrimitive) {
- /* discard any primitives */
- tnl->vtx.prim_count = 0;
- tnl->vtx.counter = tnl->vtx.initial_counter;
- tnl->vtx.vbptr = tnl->vtx.buffer;
- }
-
- if (tnl->vtx.counter != tnl->vtx.initial_counter) {
- _tnl_flush_vtx( ctx );
- }
-
- if (tnl->vtx.vertex_size) {
- _tnl_copy_to_current( ctx );
- reset_attrfv( tnl );
- }
-
- ctx->Driver.NeedFlush = 0;
-}
-
-
-static void _tnl_current_init( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLint i;
-
- /* setup the pointers for the typical 16 vertex attributes */
- for (i = 0; i < VERT_ATTRIB_MAX; i++)
- tnl->vtx.current[i] = ctx->Current.Attrib[i];
-
- /* setup pointers for the 12 material attributes */
- for (i = 0; i < MAT_ATTRIB_MAX; i++)
- tnl->vtx.current[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] =
- ctx->Light.Material.Attrib[i];
-
- tnl->vtx.current[_TNL_ATTRIB_INDEX] = &ctx->Current.Index;
- tnl->vtx.current[_TNL_ATTRIB_EDGEFLAG] = &tnl->vtx.CurrentFloatEdgeFlag;
-}
-
-static struct _tnl_dynfn *no_codegen( GLcontext *ctx, int key )
-{
- (void) ctx; (void) key;
- return NULL;
-}
-
-void _tnl_vtx_init( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_vertex_arrays *tmp = &tnl->vtx_inputs;
- GLuint i;
- static int firsttime = 1;
-
- if (firsttime) {
- firsttime = 0;
-
- INIT_CHOOSERS( 0 );
- INIT_CHOOSERS( 1 );
- INIT_CHOOSERS( 2 );
- INIT_CHOOSERS( 3 );
- INIT_CHOOSERS( 4 );
- INIT_CHOOSERS( 5 );
- INIT_CHOOSERS( 6 );
- INIT_CHOOSERS( 7 );
- INIT_CHOOSERS( 8 );
- INIT_CHOOSERS( 9 );
- INIT_CHOOSERS( 10 );
- INIT_CHOOSERS( 11 );
- INIT_CHOOSERS( 12 );
- INIT_CHOOSERS( 13 );
- INIT_CHOOSERS( 14 );
- INIT_CHOOSERS( 15 );
-
- choose[ERROR_ATTRIB][0] = error_attrib;
- choose[ERROR_ATTRIB][1] = error_attrib;
- choose[ERROR_ATTRIB][2] = error_attrib;
- choose[ERROR_ATTRIB][3] = error_attrib;
-
-#ifdef USE_X86_ASM
- if (tnl->AllowCodegen) {
- _tnl_x86choosers(choose, do_choose); /* x86 INIT_CHOOSERS */
- }
-#endif
-
- _tnl_generic_attr_table_init( generic_attr_func );
- }
-
- for (i = 0; i < _TNL_ATTRIB_INDEX; i++)
- _mesa_vector4f_init( &tmp->Attribs[i], 0, NULL);
-
- for (i = 0; i < 4; i++) {
- make_empty_list( &tnl->vtx.cache.Vertex[i] );
- make_empty_list( &tnl->vtx.cache.Attribute[i] );
- tnl->vtx.gen.Vertex[i] = no_codegen;
- tnl->vtx.gen.Attribute[i] = no_codegen;
- }
-
-#ifdef USE_X86_ASM
- _tnl_InitX86Codegen( &tnl->vtx.gen );
-#endif
-
- _tnl_current_init( ctx );
- _tnl_exec_vtxfmt_init( ctx );
- _tnl_generic_exec_vtxfmt_init( ctx );
-#ifdef USE_X86_ASM
- if (tnl->AllowCodegen) {
- _tnl_x86_exec_vtxfmt_init( ctx ); /* x86 DISPATCH_ATTRFV */
- }
-#endif
-
- _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
-
- memcpy( tnl->vtx.tabfv, choose, sizeof(choose) );
-
- for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
- tnl->vtx.attrsz[i] = 0;
-
- tnl->vtx.vertex_size = 0;
- tnl->vtx.have_materials = 0;
-}
-
-static void free_funcs( struct _tnl_dynfn *l )
-{
- struct _tnl_dynfn *f, *tmp;
- foreach_s (f, tmp, l) {
- remove_from_list( f );
- ALIGN_FREE( f->code );
- FREE( f );
- }
-}
-
-
-void _tnl_vtx_destroy( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- for (i = 0; i < 4; i++) {
- free_funcs( &tnl->vtx.cache.Vertex[i] );
- free_funcs( &tnl->vtx.cache.Attribute[i] );
- }
-}
-
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h
deleted file mode 100644
index 9818c082b..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* $XFree86$ */
-/**************************************************************************
-
-Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- *
- */
-
-#ifndef __T_VTX_API_H__
-#define __T_VTX_API_H__
-
-#include "t_context.h"
-
-#define ERROR_ATTRIB 16
-
-
-
-/* t_vtx_api.c:
- */
-extern void _tnl_vtx_init( GLcontext *ctx );
-extern void _tnl_vtx_destroy( GLcontext *ctx );
-
-extern void _tnl_FlushVertices( GLcontext *ctx, GLuint flags );
-extern void _tnl_flush_vtx( GLcontext *ctx );
-
-extern void GLAPIENTRY _tnl_wrap_filled_vertex( GLcontext *ctx );
-
-/* t_vtx_exec.c:
- */
-
-extern void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v );
-extern void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u);
-extern void _tnl_update_eval( GLcontext *ctx );
-
-extern GLboolean *_tnl_translate_edgeflag( GLcontext *ctx,
- const GLfloat *data,
- GLuint count,
- GLuint stride );
-
-extern GLboolean *_tnl_import_current_edgeflag( GLcontext *ctx,
- GLuint count );
-
-
-
-/* t_vtx_generic.c:
- */
-extern void _tnl_generic_exec_vtxfmt_init( GLcontext *ctx );
-
-extern void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] );
-
-/* t_vtx_x86.c:
- */
-extern void _tnl_InitX86Codegen( struct _tnl_dynfn_generators *gen );
-
-extern void _tnl_x86_exec_vtxfmt_init( GLcontext *ctx );
-
-extern void _tnl_x86choosers( tnl_attrfv_func (*choose)[4],
- tnl_attrfv_func (*do_choose)( GLuint attr,
- GLuint sz ));
-
-
-
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c
deleted file mode 100644
index d948e700b..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 6.1
- *
- * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "api_eval.h"
-#include "context.h"
-#include "macros.h"
-#include "math/m_eval.h"
-#include "t_vtx_api.h"
-#include "dispatch.h"
-
-
-static void clear_active_eval1( TNLcontext *tnl, GLuint attr )
-{
- tnl->vtx.eval.map1[attr].map = NULL;
-}
-
-static void clear_active_eval2( TNLcontext *tnl, GLuint attr )
-{
- tnl->vtx.eval.map2[attr].map = NULL;
-}
-
-static void set_active_eval1( TNLcontext *tnl, GLuint attr, GLuint dim,
- struct gl_1d_map *map )
-{
- if (!tnl->vtx.eval.map1[attr].map) {
- tnl->vtx.eval.map1[attr].map = map;
- tnl->vtx.eval.map1[attr].sz = dim;
- }
-}
-
-static void set_active_eval2( TNLcontext *tnl, GLuint attr, GLuint dim,
- struct gl_2d_map *map )
-{
- if (!tnl->vtx.eval.map2[attr].map) {
- tnl->vtx.eval.map2[attr].map = map;
- tnl->vtx.eval.map2[attr].sz = dim;
- }
-}
-
-void _tnl_update_eval( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint attr;
-
- /* Vertex program maps have priority over conventional attribs */
-
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- clear_active_eval1( tnl, attr );
- clear_active_eval2( tnl, attr );
- }
-
- if (ctx->VertexProgram._Enabled) {
- for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
- if (ctx->Eval.Map1Attrib[attr])
- set_active_eval1( tnl, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
-
- if (ctx->Eval.Map2Attrib[attr])
- set_active_eval2( tnl, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
- }
- }
-
- if (ctx->Eval.Map1Color4)
- set_active_eval1( tnl, VERT_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 );
-
- if (ctx->Eval.Map2Color4)
- set_active_eval2( tnl, VERT_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map2Color4 );
-
- if (ctx->Eval.Map1TextureCoord4)
- set_active_eval1( tnl, VERT_ATTRIB_TEX0, 4, &ctx->EvalMap.Map1Texture4 );
- else if (ctx->Eval.Map1TextureCoord3)
- set_active_eval1( tnl, VERT_ATTRIB_TEX0, 3, &ctx->EvalMap.Map1Texture3 );
- else if (ctx->Eval.Map1TextureCoord2)
- set_active_eval1( tnl, VERT_ATTRIB_TEX0, 2, &ctx->EvalMap.Map1Texture2 );
- else if (ctx->Eval.Map1TextureCoord1)
- set_active_eval1( tnl, VERT_ATTRIB_TEX0, 1, &ctx->EvalMap.Map1Texture1 );
-
- if (ctx->Eval.Map2TextureCoord4)
- set_active_eval2( tnl, VERT_ATTRIB_TEX0, 4, &ctx->EvalMap.Map2Texture4 );
- else if (ctx->Eval.Map2TextureCoord3)
- set_active_eval2( tnl, VERT_ATTRIB_TEX0, 3, &ctx->EvalMap.Map2Texture3 );
- else if (ctx->Eval.Map2TextureCoord2)
- set_active_eval2( tnl, VERT_ATTRIB_TEX0, 2, &ctx->EvalMap.Map2Texture2 );
- else if (ctx->Eval.Map2TextureCoord1)
- set_active_eval2( tnl, VERT_ATTRIB_TEX0, 1, &ctx->EvalMap.Map2Texture1 );
-
- if (ctx->Eval.Map1Normal)
- set_active_eval1( tnl, VERT_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal );
-
- if (ctx->Eval.Map2Normal)
- set_active_eval2( tnl, VERT_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map2Normal );
-
- if (ctx->Eval.Map1Vertex4)
- set_active_eval1( tnl, VERT_ATTRIB_POS, 4, &ctx->EvalMap.Map1Vertex4 );
- else if (ctx->Eval.Map1Vertex3)
- set_active_eval1( tnl, VERT_ATTRIB_POS, 3, &ctx->EvalMap.Map1Vertex3 );
-
- if (ctx->Eval.Map2Vertex4)
- set_active_eval2( tnl, VERT_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 );
- else if (ctx->Eval.Map2Vertex3)
- set_active_eval2( tnl, VERT_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
-
- tnl->vtx.eval.new_state = 0;
-}
-
-
-
-void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint attr;
-
- for (attr = 1; attr <= _TNL_ATTRIB_INDEX; attr++) {
- struct gl_1d_map *map = tnl->vtx.eval.map1[attr].map;
- if (map) {
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat data[4];
-
- ASSIGN_4V(data, 0, 0, 0, 1);
-
- _math_horner_bezier_curve(map->Points, data, uu,
- tnl->vtx.eval.map1[attr].sz,
- map->Order);
-
- COPY_SZ_4V( tnl->vtx.attrptr[attr],
- tnl->vtx.attrsz[attr],
- data );
- }
- }
-
- /** Vertex -- EvalCoord1f is a noop if this map not enabled:
- **/
- if (tnl->vtx.eval.map1[0].map) {
- struct gl_1d_map *map = tnl->vtx.eval.map1[0].map;
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat vertex[4];
-
- ASSIGN_4V(vertex, 0, 0, 0, 1);
-
- _math_horner_bezier_curve(map->Points, vertex, uu,
- tnl->vtx.eval.map1[0].sz,
- map->Order);
-
- if (tnl->vtx.eval.map1[0].sz == 4)
- CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
- else
- CALL_Vertex3fv(GET_DISPATCH(), ( vertex ));
- }
-}
-
-
-
-void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint attr;
-
- for (attr = 1; attr <= _TNL_ATTRIB_INDEX; attr++) {
- struct gl_2d_map *map = tnl->vtx.eval.map2[attr].map;
- if (map) {
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat vv = (v - map->v1) * map->dv;
- GLfloat data[4];
-
- ASSIGN_4V(data, 0, 0, 0, 1);
-
- _math_horner_bezier_surf(map->Points,
- data,
- uu, vv,
- tnl->vtx.eval.map2[attr].sz,
- map->Uorder, map->Vorder);
-
- COPY_SZ_4V( tnl->vtx.attrptr[attr],
- tnl->vtx.attrsz[attr],
- data );
- }
- }
-
- /** Vertex -- EvalCoord2f is a noop if this map not enabled:
- **/
- if (tnl->vtx.eval.map2[0].map) {
- struct gl_2d_map *map = tnl->vtx.eval.map2[0].map;
- GLfloat uu = (u - map->u1) * map->du;
- GLfloat vv = (v - map->v1) * map->dv;
- GLfloat vertex[4];
-
- ASSIGN_4V(vertex, 0, 0, 0, 1);
-
- if (ctx->Eval.AutoNormal) {
- GLfloat normal[4];
- GLfloat du[4], dv[4];
-
- _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv,
- tnl->vtx.eval.map2[0].sz,
- map->Uorder, map->Vorder);
-
- if (tnl->vtx.eval.map2[0].sz == 4) {
- du[0] = du[0]*vertex[3] - du[3]*vertex[0];
- du[1] = du[1]*vertex[3] - du[3]*vertex[1];
- du[2] = du[2]*vertex[3] - du[3]*vertex[2];
-
- dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0];
- dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1];
- dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2];
- }
-
-
- CROSS3(normal, du, dv);
- NORMALIZE_3FV(normal);
- normal[3] = 1.0;
-
- COPY_SZ_4V( tnl->vtx.attrptr[_TNL_ATTRIB_NORMAL],
- tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL],
- normal );
-
- }
- else {
- _math_horner_bezier_surf(map->Points, vertex, uu, vv,
- tnl->vtx.eval.map2[0].sz,
- map->Uorder, map->Vorder);
- }
-
- if (tnl->vtx.attrsz[0] == 4)
- CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
- else
- CALL_Vertex3fv(GET_DISPATCH(), ( vertex ));
- }
-}
-
-
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c
deleted file mode 100644
index ef609781c..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Mesa 3-D graphics library
- * Version: 5.1
- *
- * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "api_eval.h"
-#include "context.h"
-#include "enums.h"
-#include "state.h"
-#include "macros.h"
-#include "math/m_eval.h"
-#include "t_vtx_api.h"
-#include "t_pipeline.h"
-
-
-static void _tnl_print_vtx( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter;
- GLuint i;
-
- _mesa_debug(ctx, "_tnl_print_vtx: %u vertices %d primitives, %d vertsize\n",
- count,
- tnl->vtx.prim_count,
- tnl->vtx.vertex_size);
-
- for (i = 0 ; i < tnl->vtx.prim_count ; i++) {
- struct tnl_prim *prim = &tnl->vtx.prim[i];
- _mesa_debug(NULL, " prim %d: %s %d..%d %s %s\n",
- i,
- _mesa_lookup_enum_by_nr(prim->mode & PRIM_MODE_MASK),
- prim->start,
- prim->start + prim->count,
- (prim->mode & PRIM_BEGIN) ? "BEGIN" : "(wrap)",
- (prim->mode & PRIM_END) ? "END" : "(wrap)");
- }
-}
-
-GLboolean *_tnl_translate_edgeflag( GLcontext *ctx, const GLfloat *data,
- GLuint count, GLuint stride )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLboolean *ef = tnl->vtx.edgeflag_tmp;
- GLuint i;
-
- if (!ef)
- ef = tnl->vtx.edgeflag_tmp = (GLboolean *) MALLOC( tnl->vb.Size );
-
- for (i = 0 ; i < count ; i++, data += stride)
- ef[i] = (data[0] == 1.0);
-
- return ef;
-}
-
-
-GLboolean *_tnl_import_current_edgeflag( GLcontext *ctx,
- GLuint count )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLboolean *ef = tnl->vtx.edgeflag_tmp;
- GLboolean tmp = ctx->Current.EdgeFlag;
- GLuint i;
-
- if (!ef)
- ef = tnl->vtx.edgeflag_tmp = (GLboolean *) MALLOC( tnl->vb.Size );
-
- for (i = 0 ; i < count ; i++)
- ef[i] = tmp;
-
- return ef;
-}
-
-static INLINE GLint get_size( const GLfloat *f )
-{
- if (f[3] != 1.0) return 4;
- if (f[2] != 0.0) return 3;
- return 2;
-}
-
-/* Some nasty stuff still hanging on here.
- *
- * TODO - remove VB->NormalPtr, etc and just use the AttrPtr's.
- */
-static void _tnl_vb_bind_vtx( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- struct tnl_vertex_arrays *tmp = &tnl->vtx_inputs;
- GLfloat *data = tnl->vtx.buffer;
- GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter;
- GLuint attr, i;
-
- if (0) fprintf(stderr, "_tnl_vb_bind_vtx(): %d verts %d vertsize\n",
- count, tnl->vtx.vertex_size);
-
-
- /* Setup constant data in the VB.
- */
- VB->Count = count;
- VB->Primitive = tnl->vtx.prim;
- VB->PrimitiveCount = tnl->vtx.prim_count;
- VB->Elts = NULL;
- VB->NormalLengthPtr = NULL;
-
- for (attr = 0; attr <= _TNL_ATTRIB_INDEX ; attr++) {
- if (tnl->vtx.attrsz[attr]) {
- tmp->Attribs[attr].count = count;
- tmp->Attribs[attr].data = (GLfloat (*)[4]) data;
- tmp->Attribs[attr].start = data;
- tmp->Attribs[attr].size = tnl->vtx.attrsz[attr];
- tmp->Attribs[attr].stride = tnl->vtx.vertex_size * sizeof(GLfloat);
- VB->AttribPtr[attr] = &tmp->Attribs[attr];
- data += tnl->vtx.attrsz[attr];
- }
- else {
-/* VB->AttribPtr[attr] = &tnl->current.Attribs[attr]; */
-
-
- tmp->Attribs[attr].count = 1;
- tmp->Attribs[attr].data = (GLfloat (*)[4]) tnl->vtx.current[attr];
- tmp->Attribs[attr].start = tnl->vtx.current[attr];
- tmp->Attribs[attr].size = get_size( tnl->vtx.current[attr] );
- tmp->Attribs[attr].stride = 0;
- VB->AttribPtr[attr] = &tmp->Attribs[attr];
- }
- }
-
-
- /* Copy and translate EdgeFlag to a contiguous array of GLbooleans
- */
- if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) {
- if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data, count,
- tnl->vtx.vertex_size );
- data++;
- }
- else
- VB->EdgeFlag = _tnl_import_current_edgeflag( ctx, count );
- }
-
- /* Legacy pointers -- remove one day.
- */
- VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
- VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
- VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
- VB->ColorPtr[1] = NULL;
- VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX];
- VB->IndexPtr[1] = NULL;
- VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
- VB->SecondaryColorPtr[1] = NULL;
- VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
-
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
- }
-}
-
-
-/*
- * NOTE: Need to have calculated primitives by this point -- do it on the fly.
- * NOTE: Old 'parity' issue is gone.
- */
-static GLuint _tnl_copy_vertices( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT( ctx );
- GLuint nr = tnl->vtx.prim[tnl->vtx.prim_count-1].count;
- GLuint ovf, i;
- GLuint sz = tnl->vtx.vertex_size;
- GLfloat *dst = tnl->vtx.copied.buffer;
- GLfloat *src = (tnl->vtx.buffer +
- tnl->vtx.prim[tnl->vtx.prim_count-1].start *
- tnl->vtx.vertex_size);
-
-
- switch( ctx->Driver.CurrentExecPrimitive )
- {
- case GL_POINTS:
- return 0;
- case GL_LINES:
- ovf = nr&1;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_TRIANGLES:
- ovf = nr%3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_QUADS:
- ovf = nr&3;
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_LINE_STRIP:
- if (nr == 0)
- return 0;
- else {
- _mesa_memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) );
- return 1;
- }
- case GL_LINE_LOOP:
- case GL_TRIANGLE_FAN:
- case GL_POLYGON:
- if (nr == 0)
- return 0;
- else if (nr == 1) {
- _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
- return 1;
- } else {
- _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
- _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) );
- return 2;
- }
- case GL_TRIANGLE_STRIP:
- case GL_QUAD_STRIP:
- switch (nr) {
- case 0: ovf = 0; break;
- case 1: ovf = 1; break;
- default: ovf = 2 + (nr&1); break;
- }
- for (i = 0 ; i < ovf ; i++)
- _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
- return i;
- case GL_POLYGON+1:
- return 0;
- default:
- assert(0);
- return 0;
- }
-}
-
-
-/**
- * Execute the buffer and save copied verts.
- */
-void _tnl_flush_vtx( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint vertex_count = tnl->vtx.initial_counter - tnl->vtx.counter;
-
- if (0)
- _tnl_print_vtx( ctx );
-
- if (tnl->vtx.prim_count && vertex_count) {
-
- tnl->vtx.copied.nr = _tnl_copy_vertices( ctx );
-
- if (tnl->vtx.copied.nr != vertex_count) {
- if (ctx->NewState)
- _mesa_update_state( ctx );
-
- _tnl_vb_bind_vtx( ctx );
-
- tnl->Driver.RunPipeline( ctx );
- }
- }
-
- tnl->vtx.prim_count = 0;
- tnl->vtx.counter = tnl->vtx.initial_counter;
- tnl->vtx.vbptr = tnl->vtx.buffer;
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c
deleted file mode 100644
index 0422fcd45..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c
+++ /dev/null
@@ -1,538 +0,0 @@
-/**************************************************************************
-
-Copyright 2004 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "vtxfmt.h"
-#include "dlist.h"
-#include "state.h"
-#include "light.h"
-#include "api_arrayelt.h"
-#include "api_noop.h"
-#include "t_vtx_api.h"
-
-
-/* Versions of all the entrypoints for situations where codegen isn't
- * available.
- *
- * Note: Only one size for each attribute may be active at once.
- * Eg. if Color3f is installed/active, then Color4f may not be, even
- * if the vertex actually contains 4 color coordinates. This is
- * because the 3f version won't otherwise set color[3] to 1.0 -- this
- * is the job of the chooser function when switching between Color4f
- * and Color3f.
- */
-#define ATTRFV( ATTR, N ) \
-static void attrib_##ATTR##_##N( const GLfloat *v ) \
-{ \
- GET_CURRENT_CONTEXT( ctx ); \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- \
- if ((ATTR) == 0) { \
- GLuint i; \
- \
- if (N>0) tnl->vtx.vbptr[0] = v[0]; \
- if (N>1) tnl->vtx.vbptr[1] = v[1]; \
- if (N>2) tnl->vtx.vbptr[2] = v[2]; \
- if (N>3) tnl->vtx.vbptr[3] = v[3]; \
- \
- for (i = N; i < tnl->vtx.vertex_size; i++) \
- tnl->vtx.vbptr[i] = tnl->vtx.vertex[i]; \
- \
- tnl->vtx.vbptr += tnl->vtx.vertex_size; \
- \
- if (--tnl->vtx.counter == 0) \
- _tnl_wrap_filled_vertex( ctx ); \
- } \
- else { \
- GLfloat *dest = tnl->vtx.attrptr[ATTR]; \
- if (N>0) dest[0] = v[0]; \
- if (N>1) dest[1] = v[1]; \
- if (N>2) dest[2] = v[2]; \
- if (N>3) dest[3] = v[3]; \
- } \
-}
-
-#define INIT(TAB, ATTR) \
- TAB[ATTR][0] = attrib_##ATTR##_1; \
- TAB[ATTR][1] = attrib_##ATTR##_2; \
- TAB[ATTR][2] = attrib_##ATTR##_3; \
- TAB[ATTR][3] = attrib_##ATTR##_4;
-
-
-#define ATTRS( ATTRIB ) \
- ATTRFV( ATTRIB, 1 ) \
- ATTRFV( ATTRIB, 2 ) \
- ATTRFV( ATTRIB, 3 ) \
- ATTRFV( ATTRIB, 4 )
-
-ATTRS( 0 )
-ATTRS( 1 )
-ATTRS( 2 )
-ATTRS( 3 )
-ATTRS( 4 )
-ATTRS( 5 )
-ATTRS( 6 )
-ATTRS( 7 )
-ATTRS( 8 )
-ATTRS( 9 )
-ATTRS( 10 )
-ATTRS( 11 )
-ATTRS( 12 )
-ATTRS( 13 )
-ATTRS( 14 )
-ATTRS( 15 )
-
-void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] )
-{
- INIT( tab, 0 );
- INIT( tab, 1 );
- INIT( tab, 2 );
- INIT( tab, 3 );
- INIT( tab, 4 );
- INIT( tab, 5 );
- INIT( tab, 6 );
- INIT( tab, 7 );
- INIT( tab, 8 );
- INIT( tab, 9 );
- INIT( tab, 10 );
- INIT( tab, 11 );
- INIT( tab, 12 );
- INIT( tab, 13 );
- INIT( tab, 14 );
- INIT( tab, 15 );
-}
-
-/* These can be made efficient with codegen. Further, by adding more
- * logic to do_choose(), the double-dispatch for legacy entrypoints
- * like glVertex3f() can be removed.
- */
-#define DISPATCH_ATTRFV( ATTR, COUNT, P ) \
-do { \
- GET_CURRENT_CONTEXT( ctx ); \
- TNLcontext *tnl = TNL_CONTEXT(ctx); \
- tnl->vtx.tabfv[ATTR][COUNT-1]( P ); \
-} while (0)
-
-#define DISPATCH_ATTR1FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 1, V )
-#define DISPATCH_ATTR2FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 2, V )
-#define DISPATCH_ATTR3FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 3, V )
-#define DISPATCH_ATTR4FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 4, V )
-
-#define DISPATCH_ATTR1F( ATTR, S ) DISPATCH_ATTRFV( ATTR, 1, &(S) )
-
-#if defined(USE_X86_ASM) && 0 /* will break register calling convention */
-/* Naughty cheat:
- */
-#define DISPATCH_ATTR2F( ATTR, S,T ) DISPATCH_ATTRFV( ATTR, 2, &(S) )
-#define DISPATCH_ATTR3F( ATTR, S,T,R ) DISPATCH_ATTRFV( ATTR, 3, &(S) )
-#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) DISPATCH_ATTRFV( ATTR, 4, &(S) )
-#else
-/* Safe:
- */
-#define DISPATCH_ATTR2F( ATTR, S,T ) \
-do { \
- GLfloat v[2]; \
- v[0] = S; v[1] = T; \
- DISPATCH_ATTR2FV( ATTR, v ); \
-} while (0)
-#define DISPATCH_ATTR3F( ATTR, S,T,R ) \
-do { \
- GLfloat v[3]; \
- v[0] = S; v[1] = T; v[2] = R; \
- DISPATCH_ATTR3FV( ATTR, v ); \
-} while (0)
-#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) \
-do { \
- GLfloat v[4]; \
- v[0] = S; v[1] = T; v[2] = R; v[3] = Q; \
- DISPATCH_ATTR4FV( ATTR, v ); \
-} while (0)
-#endif
-
-
-static void GLAPIENTRY _tnl_Vertex2f( GLfloat x, GLfloat y )
-{
- DISPATCH_ATTR2F( _TNL_ATTRIB_POS, x, y );
-}
-
-static void GLAPIENTRY _tnl_Vertex2fv( const GLfloat *v )
-{
- DISPATCH_ATTR2FV( _TNL_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY _tnl_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_POS, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_Vertex3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY _tnl_Vertex4f( GLfloat x, GLfloat y, GLfloat z,
- GLfloat w )
-{
- DISPATCH_ATTR4F( _TNL_ATTRIB_POS, x, y, z, w );
-}
-
-static void GLAPIENTRY _tnl_Vertex4fv( const GLfloat *v )
-{
- DISPATCH_ATTR4FV( _TNL_ATTRIB_POS, v );
-}
-
-static void GLAPIENTRY _tnl_TexCoord1f( GLfloat x )
-{
- DISPATCH_ATTR1F( _TNL_ATTRIB_TEX0, x );
-}
-
-static void GLAPIENTRY _tnl_TexCoord1fv( const GLfloat *v )
-{
- DISPATCH_ATTR1FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _tnl_TexCoord2f( GLfloat x, GLfloat y )
-{
- DISPATCH_ATTR2F( _TNL_ATTRIB_TEX0, x, y );
-}
-
-static void GLAPIENTRY _tnl_TexCoord2fv( const GLfloat *v )
-{
- DISPATCH_ATTR2FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _tnl_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_TEX0, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_TexCoord3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _tnl_TexCoord4f( GLfloat x, GLfloat y, GLfloat z,
- GLfloat w )
-{
- DISPATCH_ATTR4F( _TNL_ATTRIB_TEX0, x, y, z, w );
-}
-
-static void GLAPIENTRY _tnl_TexCoord4fv( const GLfloat *v )
-{
- DISPATCH_ATTR4FV( _TNL_ATTRIB_TEX0, v );
-}
-
-static void GLAPIENTRY _tnl_Normal3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_NORMAL, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_Normal3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_NORMAL, v );
-}
-
-static void GLAPIENTRY _tnl_FogCoordfEXT( GLfloat x )
-{
- DISPATCH_ATTR1F( _TNL_ATTRIB_FOG, x );
-}
-
-static void GLAPIENTRY _tnl_FogCoordfvEXT( const GLfloat *v )
-{
- DISPATCH_ATTR1FV( _TNL_ATTRIB_FOG, v );
-}
-
-static void GLAPIENTRY _tnl_Color3f( GLfloat x, GLfloat y, GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR0, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_Color3fv( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY _tnl_Color4f( GLfloat x, GLfloat y, GLfloat z,
- GLfloat w )
-{
- DISPATCH_ATTR4F( _TNL_ATTRIB_COLOR0, x, y, z, w );
-}
-
-static void GLAPIENTRY _tnl_Color4fv( const GLfloat *v )
-{
- DISPATCH_ATTR4FV( _TNL_ATTRIB_COLOR0, v );
-}
-
-static void GLAPIENTRY _tnl_SecondaryColor3fEXT( GLfloat x, GLfloat y,
- GLfloat z )
-{
- DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR1, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_SecondaryColor3fvEXT( const GLfloat *v )
-{
- DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR1, v );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord1f( GLenum target, GLfloat x )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR1F( attr, x );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord1fv( GLenum target,
- const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR1FV( attr, v );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord2f( GLenum target, GLfloat x,
- GLfloat y )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR2F( attr, x, y );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord2fv( GLenum target,
- const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR2FV( attr, v );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord3f( GLenum target, GLfloat x,
- GLfloat y, GLfloat z)
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR3F( attr, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord3fv( GLenum target,
- const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR3FV( attr, v );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord4f( GLenum target, GLfloat x,
- GLfloat y, GLfloat z,
- GLfloat w )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR4F( attr, x, y, z, w );
-}
-
-static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target,
- const GLfloat *v )
-{
- GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
- DISPATCH_ATTR4FV( attr, v );
-}
-
-
-static void GLAPIENTRY _tnl_VertexAttrib1fNV( GLuint index, GLfloat x )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR1F( index, x );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib1fvNV( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR1FV( index, v );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib2fNV( GLuint index, GLfloat x,
- GLfloat y )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR2F( index, x, y );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib2fvNV( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR2FV( index, v );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib3fNV( GLuint index, GLfloat x,
- GLfloat y, GLfloat z )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR3F( index, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib3fvNV( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR3FV( index, v );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib4fNV( GLuint index, GLfloat x,
- GLfloat y, GLfloat z,
- GLfloat w )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR4F( index, x, y, z, w );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib4fvNV( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR4FV( index, v );
-}
-
-
-/*
- * XXX adjust index
- */
-
-static void GLAPIENTRY _tnl_VertexAttrib1fARB( GLuint index, GLfloat x )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR1F( index, x );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib1fvARB( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR1FV( index, v );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib2fARB( GLuint index, GLfloat x,
- GLfloat y )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR2F( index, x, y );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib2fvARB( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR2FV( index, v );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib3fARB( GLuint index, GLfloat x,
- GLfloat y, GLfloat z )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR3F( index, x, y, z );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib3fvARB( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR3FV( index, v );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib4fARB( GLuint index, GLfloat x,
- GLfloat y, GLfloat z,
- GLfloat w )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR4F( index, x, y, z, w );
-}
-
-static void GLAPIENTRY _tnl_VertexAttrib4fvARB( GLuint index,
- const GLfloat *v )
-{
- if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
- DISPATCH_ATTR4FV( index, v );
-}
-
-
-/* Install the generic versions of the 2nd level dispatch
- * functions. Some of these have a codegen alternative.
- */
-void _tnl_generic_exec_vtxfmt_init( GLcontext *ctx )
-{
- GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
-
- vfmt->Color3f = _tnl_Color3f;
- vfmt->Color3fv = _tnl_Color3fv;
- vfmt->Color4f = _tnl_Color4f;
- vfmt->Color4fv = _tnl_Color4fv;
- vfmt->FogCoordfEXT = _tnl_FogCoordfEXT;
- vfmt->FogCoordfvEXT = _tnl_FogCoordfvEXT;
- vfmt->MultiTexCoord1fARB = _tnl_MultiTexCoord1f;
- vfmt->MultiTexCoord1fvARB = _tnl_MultiTexCoord1fv;
- vfmt->MultiTexCoord2fARB = _tnl_MultiTexCoord2f;
- vfmt->MultiTexCoord2fvARB = _tnl_MultiTexCoord2fv;
- vfmt->MultiTexCoord3fARB = _tnl_MultiTexCoord3f;
- vfmt->MultiTexCoord3fvARB = _tnl_MultiTexCoord3fv;
- vfmt->MultiTexCoord4fARB = _tnl_MultiTexCoord4f;
- vfmt->MultiTexCoord4fvARB = _tnl_MultiTexCoord4fv;
- vfmt->Normal3f = _tnl_Normal3f;
- vfmt->Normal3fv = _tnl_Normal3fv;
- vfmt->SecondaryColor3fEXT = _tnl_SecondaryColor3fEXT;
- vfmt->SecondaryColor3fvEXT = _tnl_SecondaryColor3fvEXT;
- 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->VertexAttrib1fNV = _tnl_VertexAttrib1fNV;
- vfmt->VertexAttrib1fvNV = _tnl_VertexAttrib1fvNV;
- vfmt->VertexAttrib2fNV = _tnl_VertexAttrib2fNV;
- vfmt->VertexAttrib2fvNV = _tnl_VertexAttrib2fvNV;
- vfmt->VertexAttrib3fNV = _tnl_VertexAttrib3fNV;
- vfmt->VertexAttrib3fvNV = _tnl_VertexAttrib3fvNV;
- vfmt->VertexAttrib4fNV = _tnl_VertexAttrib4fNV;
- vfmt->VertexAttrib4fvNV = _tnl_VertexAttrib4fvNV;
- vfmt->VertexAttrib1fARB = _tnl_VertexAttrib1fARB;
- vfmt->VertexAttrib1fvARB = _tnl_VertexAttrib1fvARB;
- vfmt->VertexAttrib2fARB = _tnl_VertexAttrib2fARB;
- vfmt->VertexAttrib2fvARB = _tnl_VertexAttrib2fvARB;
- vfmt->VertexAttrib3fARB = _tnl_VertexAttrib3fARB;
- vfmt->VertexAttrib3fvARB = _tnl_VertexAttrib3fvARB;
- vfmt->VertexAttrib4fARB = _tnl_VertexAttrib4fARB;
- vfmt->VertexAttrib4fvARB = _tnl_VertexAttrib4fvARB;
-}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c
deleted file mode 100644
index 38cdad451..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/**************************************************************************
-
-Copyright 2004 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Daniel Borca <dborca@yahoo.com>
- */
-
-
-#include "glheader.h"
-#include "context.h"
-#include "macros.h"
-#include "vtxfmt.h"
-#include "dlist.h"
-#include "state.h"
-#include "light.h"
-#include "api_arrayelt.h"
-#include "api_noop.h"
-#include "t_vtx_api.h"
-#include "simple_list.h"
-
-
-#if defined(USE_X86_ASM) && !defined(HAVE_NONSTANDARD_GLAPIENTRY)
-
-#define EXTERN( FUNC ) \
-extern const char FUNC[]; \
-extern const char FUNC##_end[]
-
-EXTERN( _tnl_x86_Attribute1fv );
-EXTERN( _tnl_x86_Attribute2fv );
-EXTERN( _tnl_x86_Attribute3fv );
-EXTERN( _tnl_x86_Attribute4fv );
-EXTERN( _tnl_x86_Vertex1fv );
-EXTERN( _tnl_x86_Vertex2fv );
-EXTERN( _tnl_x86_Vertex3fv );
-EXTERN( _tnl_x86_Vertex4fv );
-
-EXTERN( _tnl_x86_dispatch_attrf1 );
-EXTERN( _tnl_x86_dispatch_attrf2 );
-EXTERN( _tnl_x86_dispatch_attrf3 );
-EXTERN( _tnl_x86_dispatch_attrf4 );
-EXTERN( _tnl_x86_dispatch_attrfv );
-EXTERN( _tnl_x86_dispatch_multitexcoordf1 );
-EXTERN( _tnl_x86_dispatch_multitexcoordf2 );
-EXTERN( _tnl_x86_dispatch_multitexcoordf3 );
-EXTERN( _tnl_x86_dispatch_multitexcoordf4 );
-EXTERN( _tnl_x86_dispatch_multitexcoordfv );
-EXTERN( _tnl_x86_dispatch_vertexattribf1 );
-EXTERN( _tnl_x86_dispatch_vertexattribf2 );
-EXTERN( _tnl_x86_dispatch_vertexattribf3 );
-EXTERN( _tnl_x86_dispatch_vertexattribf4 );
-EXTERN( _tnl_x86_dispatch_vertexattribfv );
-
-EXTERN( _tnl_x86_choose_fv );
-
-
-#define DONT_KNOW_OFFSETS 1
-
-
-#define DFN( FUNC, CACHE, KEY ) \
- struct _tnl_dynfn *dfn = MALLOC_STRUCT( _tnl_dynfn );\
- const char *start = FUNC; \
- const char *end = FUNC##_end; \
- int offset = 0; \
- insert_at_head( &CACHE, dfn ); \
- dfn->key = KEY; \
- dfn->code = ALIGN_MALLOC( end - start, 16 ); \
- memcpy (dfn->code, start, end - start)
-
-
-
-#define FIXUP( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL ) \
-do { \
- GLint subst = 0x10101010 + CHECKVAL; \
- \
- if (DONT_KNOW_OFFSETS) { \
- while (*(int *)(CODE+offset) != subst) offset++; \
- *(int *)(CODE+offset) = (int)(NEWVAL); \
- if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL)); \
- offset += 4; \
- } \
- else { \
- int *icode = (int *)(CODE+KNOWN_OFFSET); \
- assert (*icode == subst); \
- *icode = (int)NEWVAL; \
- } \
-} while (0)
-
-
-
-#define FIXUPREL( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL )\
-do { \
- GLint subst = 0x10101010 + CHECKVAL; \
- \
- if (DONT_KNOW_OFFSETS) { \
- while (*(int *)(CODE+offset) != subst) offset++; \
- *(int *)(CODE+offset) = (int)(NEWVAL) - ((int)(CODE)+offset) - 4; \
- if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4); \
- offset += 4; \
- } \
- else { \
- int *icode = (int *)(CODE+KNOWN_OFFSET); \
- assert (*icode == subst); \
- *icode = (int)(NEWVAL) - (int)(icode) - 4; \
- } \
-} while (0)
-
-
-
-
-/* Build specialized versions of the immediate calls on the fly for
- * the current state. Generic x86 versions.
- */
-
-static struct _tnl_dynfn *makeX86Vertex1fv( GLcontext *ctx, int vertex_size )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Vertex1fv, tnl->vtx.cache.Vertex[1-1], vertex_size );
-
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 1, vertex_size - 1);
- FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[1]);
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 4, (int)ctx);
- FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
-
- return dfn;
-}
-
-static struct _tnl_dynfn *makeX86Vertex2fv( GLcontext *ctx, int vertex_size )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Vertex2fv, tnl->vtx.cache.Vertex[2-1], vertex_size );
-
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 1, vertex_size - 2);
- FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[2]);
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 4, (int)ctx);
- FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
-
- return dfn;
-}
-
-static struct _tnl_dynfn *makeX86Vertex3fv( GLcontext *ctx, int vertex_size )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- switch (vertex_size) {
- default: {
- DFN ( _tnl_x86_Vertex3fv, tnl->vtx.cache.Vertex[3-1], vertex_size );
-
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 1, vertex_size - 3);
- FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[3]);
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 4, (int)ctx);
- FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
- return dfn;
- }
- }
-}
-
-static struct _tnl_dynfn *makeX86Vertex4fv( GLcontext *ctx, int vertex_size )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Vertex4fv, tnl->vtx.cache.Vertex[4-1], vertex_size );
-
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 1, vertex_size - 4);
- FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[4]);
- FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
- FIXUP(dfn->code, 0, 4, (int)ctx);
- FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
-
- return dfn;
-}
-
-
-static struct _tnl_dynfn *makeX86Attribute1fv( GLcontext *ctx, int dest )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Attribute1fv, tnl->vtx.cache.Attribute[1-1], dest );
-
- FIXUP(dfn->code, 0, 0, dest);
-
- return dfn;
-}
-
-static struct _tnl_dynfn *makeX86Attribute2fv( GLcontext *ctx, int dest )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Attribute2fv, tnl->vtx.cache.Attribute[2-1], dest );
-
- FIXUP(dfn->code, 0, 0, dest);
- FIXUP(dfn->code, 0, 1, 4+dest);
-
- return dfn;
-}
-
-static struct _tnl_dynfn *makeX86Attribute3fv( GLcontext *ctx, int dest )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Attribute3fv, tnl->vtx.cache.Attribute[3-1], dest );
-
- FIXUP(dfn->code, 0, 0, dest);
- FIXUP(dfn->code, 0, 1, 4+dest);
- FIXUP(dfn->code, 0, 2, 8+dest);
-
- return dfn;
-}
-
-static struct _tnl_dynfn *makeX86Attribute4fv( GLcontext *ctx, int dest )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- DFN ( _tnl_x86_Attribute4fv, tnl->vtx.cache.Attribute[4-1], dest );
-
- FIXUP(dfn->code, 0, 0, dest);
- FIXUP(dfn->code, 0, 1, 4+dest);
- FIXUP(dfn->code, 0, 2, 8+dest);
- FIXUP(dfn->code, 0, 3, 12+dest);
-
- return dfn;
-}
-
-
-void _tnl_InitX86Codegen( struct _tnl_dynfn_generators *gen )
-{
- gen->Vertex[0] = makeX86Vertex1fv;
- gen->Vertex[1] = makeX86Vertex2fv;
- gen->Vertex[2] = makeX86Vertex3fv;
- gen->Vertex[3] = makeX86Vertex4fv;
- gen->Attribute[0] = makeX86Attribute1fv;
- gen->Attribute[1] = makeX86Attribute2fv;
- gen->Attribute[2] = makeX86Attribute3fv;
- gen->Attribute[3] = makeX86Attribute4fv;
-}
-
-
-#define MKDISP(FUNC, SIZE, ATTR, WARP) \
-do { \
- char *code; \
- const char *start = WARP; \
- const char *end = WARP##_end; \
- int offset = 0; \
- code = ALIGN_MALLOC( end - start, 16 ); \
- memcpy (code, start, end - start); \
- FIXUP(code, 0, 0, (int)&(TNL_CONTEXT(ctx)->vtx.tabfv[ATTR][SIZE-1]));\
- *(void **)&vfmt->FUNC = code; \
-} while (0)
-
-
-/* Install the codegen'ed versions of the 2nd level dispatch
- * functions. We should keep a list and free them in the end...
- */
-void _tnl_x86_exec_vtxfmt_init( GLcontext *ctx )
-{
- GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
-
- MKDISP(Color3f, 3, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrf3);
- MKDISP(Color3fv, 3, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrfv);
- MKDISP(Color4f, 4, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrf4);
- MKDISP(Color4fv, 4, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrfv);
- MKDISP(FogCoordfEXT, 1, _TNL_ATTRIB_FOG, _tnl_x86_dispatch_attrf1);
- MKDISP(FogCoordfvEXT, 1, _TNL_ATTRIB_FOG, _tnl_x86_dispatch_attrfv);
- MKDISP(Normal3f, 3, _TNL_ATTRIB_NORMAL, _tnl_x86_dispatch_attrf3);
- MKDISP(Normal3fv, 3, _TNL_ATTRIB_NORMAL, _tnl_x86_dispatch_attrfv);
- MKDISP(SecondaryColor3fEXT, 3, _TNL_ATTRIB_COLOR1, _tnl_x86_dispatch_attrf3);
- MKDISP(SecondaryColor3fvEXT,3, _TNL_ATTRIB_COLOR1, _tnl_x86_dispatch_attrfv);
- MKDISP(TexCoord1f, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf1);
- MKDISP(TexCoord1fv, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
- MKDISP(TexCoord2f, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf2);
- MKDISP(TexCoord2fv, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
- MKDISP(TexCoord3f, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf3);
- MKDISP(TexCoord3fv, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
- MKDISP(TexCoord4f, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf4);
- MKDISP(TexCoord4fv, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
- MKDISP(Vertex2f, 2, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrf2);
- MKDISP(Vertex2fv, 2, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrfv);
- MKDISP(Vertex3f, 3, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrf3);
- MKDISP(Vertex3fv, 3, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrfv);
- MKDISP(Vertex4f, 4, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrf4);
- MKDISP(Vertex4fv, 4, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrfv);
-
- MKDISP(MultiTexCoord1fARB, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf1);
- MKDISP(MultiTexCoord1fvARB, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
- MKDISP(MultiTexCoord2fARB, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf2);
- MKDISP(MultiTexCoord2fvARB, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
- MKDISP(MultiTexCoord3fARB, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf3);
- MKDISP(MultiTexCoord3fvARB, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
- MKDISP(MultiTexCoord4fARB, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf4);
- MKDISP(MultiTexCoord4fvARB, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
-
- MKDISP(VertexAttrib1fNV, 1, 0, _tnl_x86_dispatch_vertexattribf1);
- MKDISP(VertexAttrib1fvNV, 1, 0, _tnl_x86_dispatch_vertexattribfv);
- MKDISP(VertexAttrib2fNV, 2, 0, _tnl_x86_dispatch_vertexattribf2);
- MKDISP(VertexAttrib2fvNV, 2, 0, _tnl_x86_dispatch_vertexattribfv);
- MKDISP(VertexAttrib3fNV, 3, 0, _tnl_x86_dispatch_vertexattribf3);
- MKDISP(VertexAttrib3fvNV, 3, 0, _tnl_x86_dispatch_vertexattribfv);
- MKDISP(VertexAttrib4fNV, 4, 0, _tnl_x86_dispatch_vertexattribf4);
- MKDISP(VertexAttrib4fvNV, 4, 0, _tnl_x86_dispatch_vertexattribfv);
-}
-
-
-/* Install the codegen'ed choosers.
- * We should keep a list and free them in the end...
- */
-void _tnl_x86choosers( tnl_attrfv_func (*choose)[4],
- tnl_attrfv_func (*do_choose)( GLuint attr,
- GLuint sz ))
-{
- int attr, size;
-
- for (attr = 0; attr < _TNL_MAX_ATTR_CODEGEN; attr++) {
- for (size = 0; size < 4; size++) {
- char *code;
- const char *start = _tnl_x86_choose_fv;
- const char *end = _tnl_x86_choose_fv_end;
- int offset = 0;
- code = ALIGN_MALLOC( end - start, 16 );
- memcpy (code, start, end - start);
- FIXUP(code, 0, 0, attr);
- FIXUP(code, 0, 1, size + 1);
- FIXUPREL(code, 0, 2, do_choose);
- choose[attr][size] = (tnl_attrfv_func)code;
- }
- }
-}
-
-#else
-
-void _tnl_InitX86Codegen( struct _tnl_dynfn_generators *gen )
-{
- (void) gen;
-}
-
-
-void _tnl_x86_exec_vtxfmt_init( GLcontext *ctx )
-{
- (void) ctx;
-}
-
-
-void _tnl_x86choosers( tnl_attrfv_func (*choose)[4],
- tnl_attrfv_func (*do_choose)( GLuint attr,
- GLuint sz ))
-{
- (void) choose;
- (void) do_choose;
-}
-
-#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S
deleted file mode 100644
index 5f79197f7..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S
+++ /dev/null
@@ -1,557 +0,0 @@
-/**************************************************************************
-
-Copyright 2004 Tungsten Graphics Inc., Cedar Park, Texas.
-
-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
-on the rights to use, copy, modify, merge, publish, distribute, sub
-license, 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 (including the next
-paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL
-ATI, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
-DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
-USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Daniel Borca <dborca@yahoo.com>
- */
-
-#if defined (__DJGPP__) || defined (__MINGW32__) || defined (__CYGWIN__)
-#define GLOBL( x ) \
-.globl _##x; \
-_##x:
-#else /* !defined (__DJGPP__) && !defined (__MINGW32__) && !defined (__CYGWIN__) */
-#define GLOBL( x ) \
-.globl x; \
-x:
-#endif /* !defined (__DJGPP__) && !defined (__MINGW32__) && !defined (__CYGWIN__) */
-
-
-#if !defined (STDCALL_API)
-#define RETCLEAN( x ) ret
-#else
-#define RETCLEAN( x ) ret $x
-#endif
-
-
-#define _JMP(x) \
-.byte 0xe9; \
-.long x
-
-#define _CALL(x) \
-.byte 0xe8; \
-.long x
-
-
-/* Someone who knew a lot about this sort of thing would use this
- * macro to note current offsets, etc in a special region of the
- * object file & just make everything work out neat. I don't know
- * enough to do that...
- */
-
-#define SUBST( x ) (0x10101010 + x)
-
-
-.data
-
-
-/* [dBorca] TODO
- * Unfold functions for each vertex size?
- * Build super-specialized SSE versions?
- *
- * There is a trick in Vertex*fv: under certain conditions,
- * we tail to _tnl_wrap_filled_vertex(ctx). This means that
- * if Vertex*fv is STDCALL, then _tnl_wrap_filled_vertex must
- * be STDCALL as well, because (GLcontext *) and (GLfloat *)
- * have the same size.
- */
-.align 4
-GLOBL ( _tnl_x86_Vertex1fv )
- movl 4(%esp), %ecx
- push %edi
- push %esi
- movl SUBST(0), %edi /* 0x0 --> tnl->vtx.vbptr */
- movl (%ecx), %edx /* load v[0] */
- movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
- addl $4, %edi /* tnl->vtx.vbptr += 1 */
- movl $SUBST(1), %ecx /* 0x1 --> (tnl->vtx.vertex_size - 1) */
- movl $SUBST(2), %esi /* 0x2 --> (tnl->vtx.vertex + 1) */
- repz
- movsl %ds:(%esi), %es:(%edi)
- movl %edi, SUBST(0) /* 0x0 --> tnl->vtx.vbptr */
- movl SUBST(3), %edx /* 0x3 --> counter */
- pop %esi
- pop %edi
- dec %edx /* counter-- */
- movl %edx, SUBST(3) /* 0x3 --> counter */
- je .0 /* if (counter == 0) goto .0 */
- RETCLEAN(4) /* return */
- .balign 16
-.0:
- movl $SUBST(4), %eax /* load ctx */
- movl %eax, 4(%esp) /* push ctx */
- _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
-GLOBL ( _tnl_x86_Vertex1fv_end )
-
-.align 4
-GLOBL ( _tnl_x86_Vertex2fv )
- movl 4(%esp), %ecx
- push %edi
- push %esi
- movl SUBST(0), %edi /* load tnl->vtx.vbptr */
- movl (%ecx), %edx /* load v[0] */
- movl 4(%ecx), %eax /* load v[1] */
- movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
- movl %eax, 4(%edi) /* tnl->vtx.vbptr[1] = v[1] */
- addl $8, %edi /* tnl->vtx.vbptr += 2 */
- movl $SUBST(1), %ecx /* vertex_size - 2 */
- movl $SUBST(2), %esi /* tnl->vtx.vertex + 2 */
- repz
- movsl %ds:(%esi), %es:(%edi)
- movl %edi, SUBST(0) /* save tnl->vtx.vbptr */
- movl SUBST(3), %edx /* load counter */
- pop %esi
- pop %edi
- dec %edx /* counter-- */
- movl %edx, SUBST(3) /* save counter */
- je .1 /* if (counter == 0) goto .1 */
- RETCLEAN(4) /* return */
- .balign 16
-.1:
- movl $SUBST(4), %eax /* load ctx */
- movl %eax, 4(%esp) /* push ctx */
- _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
-GLOBL ( _tnl_x86_Vertex2fv_end )
-
-.align 4
-GLOBL ( _tnl_x86_Vertex3fv )
- movl 4(%esp), %ecx
- push %edi
- push %esi
- movl SUBST(0), %edi /* load tnl->vtx.vbptr */
- movl (%ecx), %edx /* load v[0] */
- movl 4(%ecx), %eax /* load v[1] */
- movl 8(%ecx), %esi /* load v[2] */
- movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
- movl %eax, 4(%edi) /* tnl->vtx.vbptr[1] = v[1] */
- movl %esi, 8(%edi) /* tnl->vtx.vbptr[2] = v[2] */
- addl $12, %edi /* tnl->vtx.vbptr += 3 */
- movl $SUBST(1), %ecx /* vertex_size - 3 */
- movl $SUBST(2), %esi /* tnl->vtx.vertex + 3 */
- repz
- movsl %ds:(%esi), %es:(%edi)
- movl %edi, SUBST(0) /* save tnl->vtx.vbptr */
- movl SUBST(3), %edx /* load counter */
- pop %esi
- pop %edi
- dec %edx /* counter-- */
- movl %edx, SUBST(3) /* save counter */
- je .2 /* if (counter == 0) goto .2 */
- RETCLEAN(4) /* return */
- .balign 16
-.2:
- movl $SUBST(4), %eax /* load ctx */
- movl %eax, 4(%esp) /* push ctx */
- _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
-GLOBL ( _tnl_x86_Vertex3fv_end )
-
-.align 4
-GLOBL ( _tnl_x86_Vertex4fv )
- movl 4(%esp), %ecx
- push %edi
- push %esi
- movl SUBST(0), %edi /* load tnl->vtx.vbptr */
- movl (%ecx), %edx /* load v[0] */
- movl 4(%ecx), %eax /* load v[1] */
- movl 8(%ecx), %esi /* load v[2] */
- movl 12(%ecx), %ecx /* load v[3] */
- movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
- movl %eax, 4(%edi) /* tnl->vtx.vbptr[1] = v[1] */
- movl %esi, 8(%edi) /* tnl->vtx.vbptr[2] = v[2] */
- movl %ecx, 12(%edi) /* tnl->vtx.vbptr[3] = v[3] */
- addl $16, %edi /* tnl->vtx.vbptr += 4 */
- movl $SUBST(1), %ecx /* vertex_size - 4 */
- movl $SUBST(2), %esi /* tnl->vtx.vertex + 4 */
- repz
- movsl %ds:(%esi), %es:(%edi)
- movl %edi, SUBST(0) /* save tnl->vtx.vbptr */
- movl SUBST(3), %edx /* load counter */
- pop %esi
- pop %edi
- dec %edx /* counter-- */
- movl %edx, SUBST(3) /* save counter */
- je .3 /* if (counter == 0) goto .3 */
- RETCLEAN(4) /* return */
- .balign 16
-.3:
- movl $SUBST(4), %eax /* load ctx */
- movl %eax, 4(%esp) /* push ctx */
- _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
-GLOBL ( _tnl_x86_Vertex4fv_end )
-
-
-/**
- * Generic handlers for vector format data.
- */
-GLOBL( _tnl_x86_Attribute1fv )
- movl 4(%esp), %ecx
- movl (%ecx), %eax /* load v[0] */
- movl %eax, SUBST(0) /* store v[0] to current vertex */
- RETCLEAN(4)
-GLOBL ( _tnl_x86_Attribute1fv_end )
-
-GLOBL( _tnl_x86_Attribute2fv )
- movl 4(%esp), %ecx
- movl (%ecx), %eax /* load v[0] */
- movl 4(%ecx), %edx /* load v[1] */
- movl %eax, SUBST(0) /* store v[0] to current vertex */
- movl %edx, SUBST(1) /* store v[1] to current vertex */
- RETCLEAN(4)
-GLOBL ( _tnl_x86_Attribute2fv_end )
-
-GLOBL( _tnl_x86_Attribute3fv )
- movl 4(%esp), %ecx
- movl (%ecx), %eax /* load v[0] */
- movl 4(%ecx), %edx /* load v[1] */
- movl 8(%ecx), %ecx /* load v[2] */
- movl %eax, SUBST(0) /* store v[0] to current vertex */
- movl %edx, SUBST(1) /* store v[1] to current vertex */
- movl %ecx, SUBST(2) /* store v[2] to current vertex */
- RETCLEAN(4)
-GLOBL ( _tnl_x86_Attribute3fv_end )
-
-GLOBL( _tnl_x86_Attribute4fv )
- movl 4(%esp), %ecx
- movl (%ecx), %eax /* load v[0] */
- movl 4(%ecx), %edx /* load v[1] */
- movl %eax, SUBST(0) /* store v[0] to current vertex */
- movl %edx, SUBST(1) /* store v[1] to current vertex */
- movl 8(%ecx), %eax /* load v[2] */
- movl 12(%ecx), %edx /* load v[3] */
- movl %eax, SUBST(2) /* store v[2] to current vertex */
- movl %edx, SUBST(3) /* store v[3] to current vertex */
- RETCLEAN(4)
-GLOBL ( _tnl_x86_Attribute4fv_end )
-
-
-/* Choosers:
- *
- * Must generate all of these ahead of first usage. Generate at
- * compile-time?
- */
-GLOBL( _tnl_x86_choose_fv )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl $SUBST(0), (%esp) /* arg 0 - attrib */
- movl $SUBST(1), 4(%esp) /* arg 1 - N */
- _CALL (SUBST(2)) /* call do_choose */
- add $12, %esp /* tear down stack frame */
- jmp *%eax /* jump to new func */
-GLOBL ( _tnl_x86_choose_fv_end )
-
-
-/* FIRST LEVEL FUNCTIONS -- these are plugged directly into GL dispatch.
- *
- * In the 1st level dispatch functions, switch to a different
- * calling convention -- (const GLfloat *v) in %ecx.
- *
- * As with regular (x86) dispatch, don't create a new stack frame -
- * just let the 'ret' in the dispatched function return straight
- * back to the original caller.
- *
- * Vertex/Normal/Color, etc: the address of the function pointer
- * is known at codegen time.
- */
-
-/* Unfortunately, have to play with the stack in the non-fv case:
- */
-#if !defined (STDCALL_API)
-GLOBL( _tnl_x86_dispatch_attrf1 )
-GLOBL( _tnl_x86_dispatch_attrf2 )
-GLOBL( _tnl_x86_dispatch_attrf3 )
-GLOBL( _tnl_x86_dispatch_attrf4 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- leal 16(%esp), %edx /* address of first float on stack */
- movl %edx, (%esp) /* save as 'v' */
- call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
- addl $12, %esp /* tear down frame */
- ret /* return */
-GLOBL( _tnl_x86_dispatch_attrf4_end )
-GLOBL( _tnl_x86_dispatch_attrf3_end )
-GLOBL( _tnl_x86_dispatch_attrf2_end )
-GLOBL( _tnl_x86_dispatch_attrf1_end )
-
-#else /* defined(STDCALL_API) */
-
-GLOBL( _tnl_x86_dispatch_attrf1 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- leal 16(%esp), %edx /* address of first float on stack */
- movl %edx, (%esp) /* save as 'v' */
- call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $4 /* return */
-GLOBL( _tnl_x86_dispatch_attrf1_end )
-
-GLOBL( _tnl_x86_dispatch_attrf2 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- leal 16(%esp), %edx /* address of first float on stack */
- movl %edx, (%esp) /* save as 'v' */
- call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $8 /* return */
-GLOBL( _tnl_x86_dispatch_attrf2_end )
-
-GLOBL( _tnl_x86_dispatch_attrf3 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- leal 16(%esp), %edx /* address of first float on stack */
- movl %edx, (%esp) /* save as 'v' */
- call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $12 /* return */
-GLOBL( _tnl_x86_dispatch_attrf3_end )
-
-GLOBL( _tnl_x86_dispatch_attrf4 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- leal 16(%esp), %edx /* address of first float on stack */
- movl %edx, (%esp) /* save as 'v' */
- call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $16 /* return */
-GLOBL( _tnl_x86_dispatch_attrf4_end )
-#endif /* defined(STDCALL_API) */
-
-/* The fv case is simpler:
- */
-GLOBL( _tnl_x86_dispatch_attrfv )
- jmp *SUBST(0) /* 0x0 --> tabfv[attr][n] */
-GLOBL( _tnl_x86_dispatch_attrfv_end )
-
-
-/* MultiTexcoord: the address of the function pointer must be
- * calculated, but can use the index argument slot to hold 'v', and
- * avoid setting up a new stack frame.
- *
- * [dBorca]
- * right, this would be the preferred approach, but gcc does not
- * clean up the stack after each function call when optimizing (-fdefer-pop);
- * can it make assumptions about what's already on the stack? I dunno,
- * but in this case, we can't mess with the caller's stack frame, and
- * we must use a model like `_x86_dispatch_attrfv' above. Caveat emptor!
- */
-
-/* Also, will only need a maximum of four of each of these per context:
- */
-#if !defined (STDCALL_API)
-GLOBL( _tnl_x86_dispatch_multitexcoordf1 )
-GLOBL( _tnl_x86_dispatch_multitexcoordf2 )
-GLOBL( _tnl_x86_dispatch_multitexcoordf3 )
-GLOBL( _tnl_x86_dispatch_multitexcoordf4 )
- movl 4(%esp), %ecx
- leal 8(%esp), %edx
- andl $7, %ecx
- movl %edx, 4(%esp)
- sall $4, %ecx
- jmp *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
-GLOBL( _tnl_x86_dispatch_multitexcoordf4_end )
-GLOBL( _tnl_x86_dispatch_multitexcoordf3_end )
-GLOBL( _tnl_x86_dispatch_multitexcoordf2_end )
-GLOBL( _tnl_x86_dispatch_multitexcoordf1_end )
-
-GLOBL( _tnl_x86_dispatch_multitexcoordfv )
- movl 4(%esp), %ecx
- movl 8(%esp), %edx
- andl $7, %ecx
- movl %edx, 4(%esp)
- sall $4, %ecx
- jmp *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
-GLOBL( _tnl_x86_dispatch_multitexcoordfv_end )
-
-#else /* defined (STDCALL_API) */
-
-GLOBL( _tnl_x86_dispatch_multitexcoordf1 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %ecx
- leal 20(%esp), %edx
- andl $7, %ecx
- movl %edx, (%esp)
- sall $4, %ecx
- call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $8 /* return */
-GLOBL( _tnl_x86_dispatch_multitexcoordf1_end )
-
-GLOBL( _tnl_x86_dispatch_multitexcoordf2 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %ecx
- leal 20(%esp), %edx
- andl $7, %ecx
- movl %edx, (%esp)
- sall $4, %ecx
- call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $12 /* return */
-GLOBL( _tnl_x86_dispatch_multitexcoordf2_end )
-
-GLOBL( _tnl_x86_dispatch_multitexcoordf3 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %ecx
- leal 20(%esp), %edx
- andl $7, %ecx
- movl %edx, (%esp)
- sall $4, %ecx
- call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $16 /* return */
-GLOBL( _tnl_x86_dispatch_multitexcoordf3_end )
-
-GLOBL( _tnl_x86_dispatch_multitexcoordf4 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %ecx
- leal 20(%esp), %edx
- andl $7, %ecx
- movl %edx, (%esp)
- sall $4, %ecx
- call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $20 /* return */
-GLOBL( _tnl_x86_dispatch_multitexcoordf4_end )
-
-GLOBL( _tnl_x86_dispatch_multitexcoordfv )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %ecx
- movl 20(%esp), %edx
- andl $7, %ecx
- movl %edx, (%esp)
- sall $4, %ecx
- call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $8 /* return */
-GLOBL( _tnl_x86_dispatch_multitexcoordfv_end )
-#endif /* defined (STDCALL_API) */
-
-
-/* VertexAttrib: the address of the function pointer must be
- * calculated.
- */
-#if !defined (STDCALL_API)
-GLOBL( _tnl_x86_dispatch_vertexattribf1 )
-GLOBL( _tnl_x86_dispatch_vertexattribf2 )
-GLOBL( _tnl_x86_dispatch_vertexattribf3 )
-GLOBL( _tnl_x86_dispatch_vertexattribf4 )
- movl 4(%esp), %eax
- cmpl $16, %eax
- jb .8 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.8:
- leal 8(%esp), %ecx /* calculate 'v' */
- movl %ecx, 4(%esp) /* save in 1st arg slot */
- sall $4, %eax
- jmp *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
-GLOBL( _tnl_x86_dispatch_vertexattribf4_end )
-GLOBL( _tnl_x86_dispatch_vertexattribf3_end )
-GLOBL( _tnl_x86_dispatch_vertexattribf2_end )
-GLOBL( _tnl_x86_dispatch_vertexattribf1_end )
-
-GLOBL( _tnl_x86_dispatch_vertexattribfv )
- movl 4(%esp), %eax
- cmpl $16, %eax
- jb .9 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.9:
- movl 8(%esp), %ecx /* load 'v' */
- movl %ecx, 4(%esp) /* save in 1st arg slot */
- sall $4, %eax
- jmp *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
-GLOBL( _tnl_x86_dispatch_vertexattribfv_end )
-
-#else /* defined (STDCALL_API) */
-
-GLOBL( _tnl_x86_dispatch_vertexattribf1 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %eax
- cmpl $16, %eax
- jb .81 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.81:
- leal 20(%esp), %ecx /* load 'v' */
- movl %ecx, (%esp) /* save in 1st arg slot */
- sall $4, %eax
- call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $8 /* return */
-GLOBL( _tnl_x86_dispatch_vertexattribf1_end )
-
-GLOBL( _tnl_x86_dispatch_vertexattribf2 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %eax
- cmpl $16, %eax
- jb .82 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.82:
- leal 20(%esp), %ecx /* load 'v' */
- movl %ecx, (%esp) /* save in 1st arg slot */
- sall $4, %eax
- call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $12 /* return */
-GLOBL( _tnl_x86_dispatch_vertexattribf2_end )
-
-GLOBL( _tnl_x86_dispatch_vertexattribf3 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %eax
- cmpl $16, %eax
- jb .83 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.83:
- leal 20(%esp), %ecx /* load 'v' */
- movl %ecx, (%esp) /* save in 1st arg slot */
- sall $4, %eax
- call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $16 /* return */
-GLOBL( _tnl_x86_dispatch_vertexattribf3_end )
-
-GLOBL( _tnl_x86_dispatch_vertexattribf4 )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %eax
- cmpl $16, %eax
- jb .84 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.84:
- leal 20(%esp), %ecx /* load 'v' */
- movl %ecx, (%esp) /* save in 1st arg slot */
- sall $4, %eax
- call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $20 /* return */
-GLOBL( _tnl_x86_dispatch_vertexattribf4_end )
-
-GLOBL( _tnl_x86_dispatch_vertexattribfv )
- subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
- movl 16(%esp), %eax
- cmpl $16, %eax
- jb .9 /* "cmovge" is not supported on all CPUs */
- movl $16, %eax
-.9:
- movl 20(%esp), %ecx /* load 'v' */
- movl %ecx, (%esp) /* save in 1st arg slot */
- sall $4, %eax
- call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
- addl $8, %esp /* tear down frame (4 shaved off by the callee) */
- ret $8 /* return */
-GLOBL( _tnl_x86_dispatch_vertexattribfv_end )
-#endif /* defined (STDCALL_API) */
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/tnl.h b/nx-X11/extras/Mesa/src/mesa/tnl/tnl.h
deleted file mode 100644
index 428fe1278..000000000
--- a/nx-X11/extras/Mesa/src/mesa/tnl/tnl.h
+++ /dev/null
@@ -1,89 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- * Version: 3.5
- *
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#ifndef _TNL_H
-#define _TNL_H
-
-#include "mtypes.h"
-
-
-
-/* These are the public-access functions exported from tnl. (A few
- * more are currently hooked into dispatch directly by the module
- * itself.)
- */
-extern GLboolean
-_tnl_CreateContext( GLcontext *ctx );
-
-extern void
-_tnl_DestroyContext( GLcontext *ctx );
-
-extern void
-_tnl_InvalidateState( GLcontext *ctx, GLuint new_state );
-
-/* Functions to revive the tnl module after being unhooked from
- * dispatch and/or driver callbacks.
- */
-
-/* Restore just the ctx->Exec table:
- */
-extern void
-_tnl_wakeup_exec( GLcontext *ctx );
-
-/* Restore both ctx->Exec and ctx->Save:
- */
-extern void
-_tnl_wakeup_save_exec( GLcontext *ctx );
-
-/* Driver configuration options:
- */
-extern void
-_tnl_need_projected_coords( GLcontext *ctx, GLboolean flag );
-
-extern void
-_tnl_need_dlist_loopback( GLcontext *ctx, GLboolean flag );
-
-extern void
-_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean flag );
-
-extern void
-_tnl_isolate_materials( GLcontext *ctx, GLboolean flag );
-
-
-/* Control whether T&L does per-vertex fog
- */
-extern void
-_tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value );
-
-extern void
-_tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value );
-
-extern void
-_tnl_program_string(GLcontext *ctx, GLenum target, struct program *program);
-
-#endif