summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/NOTES100
-rw-r--r--src/mesa/tnl/t_context.c253
-rw-r--r--src/mesa/tnl/t_context.h594
-rw-r--r--src/mesa/tnl/t_draw.c657
-rw-r--r--src/mesa/tnl/t_pipeline.c300
-rw-r--r--src/mesa/tnl/t_pipeline.h73
-rw-r--r--src/mesa/tnl/t_rebase.c267
-rw-r--r--src/mesa/tnl/t_rebase.h41
-rw-r--r--src/mesa/tnl/t_split.c162
-rw-r--r--src/mesa/tnl/t_split.h74
-rw-r--r--src/mesa/tnl/t_split_copy.c637
-rw-r--r--src/mesa/tnl/t_split_inplace.c296
-rw-r--r--src/mesa/tnl/t_vb_cliptmp.h317
-rw-r--r--src/mesa/tnl/t_vb_fog.c277
-rw-r--r--src/mesa/tnl/t_vb_light.c477
-rw-r--r--src/mesa/tnl/t_vb_lighttmp.h641
-rw-r--r--src/mesa/tnl/t_vb_normals.c186
-rw-r--r--src/mesa/tnl/t_vb_points.c115
-rw-r--r--src/mesa/tnl/t_vb_program.c539
-rw-r--r--src/mesa/tnl/t_vb_render.c350
-rw-r--r--src/mesa/tnl/t_vb_rendertmp.h487
-rw-r--r--src/mesa/tnl/t_vb_texgen.c610
-rw-r--r--src/mesa/tnl/t_vb_texmat.c127
-rw-r--r--src/mesa/tnl/t_vb_vertex.c288
-rw-r--r--src/mesa/tnl/t_vertex.c580
-rw-r--r--src/mesa/tnl/t_vertex.h184
-rw-r--r--src/mesa/tnl/t_vertex_generic.c1152
-rw-r--r--src/mesa/tnl/t_vertex_sse.c685
-rw-r--r--src/mesa/tnl/t_vp_build.c49
-rw-r--r--src/mesa/tnl/t_vp_build.h41
-rw-r--r--src/mesa/tnl/tnl.h208
31 files changed, 0 insertions, 10767 deletions
diff --git a/src/mesa/tnl/NOTES b/src/mesa/tnl/NOTES
deleted file mode 100644
index 43c469201ad..00000000000
--- a/src/mesa/tnl/NOTES
+++ /dev/null
@@ -1,100 +0,0 @@
-INTRODUCTION
-
-A generic, configurable software implementation of GL transformation &
-lighting.
-
-This module provides an implementation of the routines required by the
-'vtxfmt' mechanism of core mesa for tnl functionality in all
-combinations of compile and execute modes.
-
-Most current drivers use the tnl module exclusively to provide this
-functionality.
-
-
-STATE
-
-To create and destroy the module:
-
- GLboolean _tnl_CreateContext( struct gl_context *ctx );
- void _tnl_DestroyContext( struct gl_context *ctx );
-
-The module is not active by default, and must be installed by calling
-_tnl_Wakeup(). This function installs internal tnl functions into all
-the vtxfmt dispatch hooks, thus taking over the task of transformation
-and lighting entirely:
-
- void _tnl_wakeup_exec( struct gl_context *ctx );
- void _tnl_wakeup_save_exec( struct gl_context *ctx );
-
-
-This module tracks state changes internally and maintains derived
-values based on the current state. For this to work, the driver
-ensure the following funciton is called whenever the state changes and
-the swsetup module is 'awake':
-
- void _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state );
-
-There is no explicit call to put the tnl module to sleep. Simply
-install other function pointers into all the vtxfmt dispatch slots,
-and (optionally) cease calling _tnl_InvalidateState().
-
-CUSTOMIZATION
-
-The module provides customizability through several mechanisms. The
-most important is by allowing drivers to specify the pipeline through
-which vertex data is passed, including its eventual transfer to
-rasterization hardware (or software).
-
-The default pipeline is specified in t_pipeline.c, and is usually a
-starting point for driver pipelines. Some drivers will remove a stage
-where hardware provides support for the implemented operation (for
-instance fog where per-pixel hardware fog is available),
-or add stages to shortcircuit latter operations (for
-example taking advantage of hardware support for strips and other
-higher-level primitives (for example the radeon driver).
-
-In addition, the following functions provide further tweaks:
-
-extern void
-_tnl_need_projected_coords( struct gl_context *ctx, GLboolean flag );
-
- - Direct the default vertex transformation stage to
- produce/not produce projected clip coordinates.
-
-extern void
-_tnl_need_dlist_loopback( struct gl_context *ctx, GLboolean flag );
-
- - Direct the display list component of the tnl module to
- replay display lists as 'glVertex' type calls, rather than
- passing the display list data directly into the tnl pipeline
- mechanism.
-
- This allows display lists to be replayed by the tnl module
- even when the module is not strictly active.
-
-
-extern void
-_tnl_need_dlist_norm_lengths( struct gl_context *ctx, GLboolean flag );
-
- - Direct the display list component to enable/disable caching
- 1/length values for display list normals. Doing so is
- ususally helpful when lighting is performed in software, but
- wasteful otherwise.
-
-
-DRIVER INTERFACE
-
-The module itself offers a minimal driver interface:
-
- void (*RunPipeline)( struct gl_context *ctx );
-
-Normally this is set to _tnl_RunPipeline(), however the driver can use
-this hook to wrap checks or other code around this call.
-
-In addition, the driver interface for the default render pipeline
-stage is housed in the tnl context struct (this could be cleaner).
-
-
-RENDER DRIVER INTERFACE
-
-See t_context.h for the definition and explanation of this. \ No newline at end of file
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
deleted file mode 100644
index 0c5ce824bc6..00000000000
--- a/src/mesa/tnl/t_context.c
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#include "main/glheader.h"
-
-#include "main/context.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "main/light.h"
-#include "math/m_translate.h"
-#include "math/m_xform.h"
-#include "main/state.h"
-#include "main/viewport.h"
-#include "util/simple_list.h"
-#include "util/u_memory.h"
-
-#include "tnl.h"
-#include "t_context.h"
-#include "t_pipeline.h"
-
-#include "vbo/vbo.h"
-
-GLboolean
-_tnl_CreateContext( struct gl_context *ctx )
-{
- TNLcontext *tnl;
- GLuint i;
-
- /* Create the TNLcontext structure
- */
- ctx->swtnl_context = tnl = calloc(1, sizeof(TNLcontext));
-
- if (!tnl) {
- return GL_FALSE;
- }
-
- /* Initialize the VB.
- */
- tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
-
-
- /* Initialize tnl state.
- */
- if (ctx->VertexProgram._MaintainTnlProgram) {
- _tnl_install_pipeline( ctx, _tnl_vp_pipeline );
- } else {
- _tnl_install_pipeline( ctx, _tnl_default_pipeline );
- }
-
- _math_matrix_ctr(&tnl->_WindowMap);
-
- tnl->NeedNdcCoords = GL_TRUE;
- tnl->AllowVertexFog = GL_TRUE;
- tnl->AllowPixelFog = GL_TRUE;
-
- /* Set a few default values in the driver struct.
- */
- tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
- tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
- tnl->Driver.NotifyMaterialChange = _tnl_validate_shine_tables;
-
- tnl->nr_blocks = 0;
-
- /* Lighting miscellaneous */
- tnl->_ShineTabList = MALLOC_STRUCT( tnl_shine_tab );
- make_empty_list( tnl->_ShineTabList );
- /* Allocate 10 (arbitrary) shininess lookup tables */
- for (i = 0 ; i < 10 ; i++) {
- struct tnl_shine_tab *s = MALLOC_STRUCT( tnl_shine_tab );
- s->shininess = -1;
- s->refcount = 0;
- insert_at_tail( tnl->_ShineTabList, s );
- }
-
- _math_init_transformation();
- _math_init_translate();
-
- /* Keep our list of tnl_vertex_array inputs */
- _tnl_init_inputs(&tnl->draw_arrays);
-
- return GL_TRUE;
-}
-
-
-void
-_tnl_DestroyContext( struct gl_context *ctx )
-{
- struct tnl_shine_tab *s, *tmps;
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /* Free lighting shininess exponentiation table */
- foreach_s( s, tmps, tnl->_ShineTabList ) {
- free( s );
- }
- free( tnl->_ShineTabList );
-
- _tnl_destroy_pipeline( ctx );
-
- free(tnl);
- ctx->swtnl_context = NULL;
-}
-
-
-void
-_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- const struct gl_program *vp = ctx->VertexProgram._Current;
- const struct gl_program *fp = ctx->FragmentProgram._Current;
- GLuint i;
-
- if (new_state & (_NEW_LIGHT_CONSTANTS | _NEW_MATERIAL))
- _mesa_update_light_materials(ctx);
-
- if (new_state & (_NEW_HINT | _NEW_PROGRAM)) {
- assert(tnl->AllowVertexFog || tnl->AllowPixelFog);
- tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
- || !tnl->AllowPixelFog) && !fp;
- }
-
- tnl->pipeline.new_state |= new_state;
-
- /* Calculate tnl->render_inputs. This bitmask indicates which vertex
- * attributes need to be emitted to the rasterizer.
- */
- tnl->render_inputs_bitset = BITFIELD64_BIT(_TNL_ATTRIB_POS);
-
- if (!fp || (fp->info.inputs_read & VARYING_BIT_COL0)) {
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR0);
- }
-
- if (_mesa_need_secondary_color(ctx))
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR1);
-
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- if (ctx->Texture._EnabledCoordUnits & (1 << i) ||
- (fp && fp->info.inputs_read & VARYING_BIT_TEX(i)) ||
- _mesa_ati_fragment_shader_enabled(ctx)) {
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX(i));
- }
- }
-
- if (ctx->Fog.Enabled
- || (fp != NULL && (fp->info.inputs_read & VARYING_BIT_FOGC) != 0)) {
- /* Either fixed-function fog or a fragment program needs fog coord.
- */
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_FOG);
- }
-
- if (ctx->Polygon.FrontMode != GL_FILL ||
- ctx->Polygon.BackMode != GL_FILL)
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_EDGEFLAG);
-
- if (ctx->RenderMode == GL_FEEDBACK)
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX0);
-
- if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled)
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE);
-
- /* check for varying vars which are written by the vertex program */
- if (vp) {
- GLuint i;
- for (i = 0; i < MAX_VARYING; i++) {
- if (vp->info.outputs_written &
- BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
- tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i));
- }
- }
- }
-
- if (new_state & (_NEW_VIEWPORT | _NEW_BUFFERS)) {
- float scale[3], translate[3];
- _mesa_get_viewport_xform(ctx, 0, scale, translate);
- _math_matrix_viewport(&tnl->_WindowMap, scale, translate,
- ctx->DrawBuffer->_DepthMaxF);
- }
-}
-
-
-void
-_tnl_wakeup( struct gl_context *ctx )
-{
- /* Assume we haven't been getting state updates either:
- */
- _tnl_InvalidateState( ctx, ~0 );
-
-#if 0
- if (ctx->Light.ColorMaterialEnabled) {
- _mesa_update_color_material( ctx,
- ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
- }
-#endif
-}
-
-
-
-
-/**
- * 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( struct gl_context *ctx, GLboolean mode )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->NeedNdcCoords = mode;
-}
-
-void
-_tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->AllowVertexFog = value;
- tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
- || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current;
-
-}
-
-void
-_tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- tnl->AllowPixelFog = value;
- tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
- || !tnl->AllowPixelFog) && !ctx->FragmentProgram._Current;
-}
-
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
deleted file mode 100644
index e675639e34a..00000000000
--- a/src/mesa/tnl/t_context.h
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- * mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \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.
- *
- */
-
-
-#ifndef _T_CONTEXT_H
-#define _T_CONTEXT_H
-
-#include "main/glheader.h"
-
-#include "main/mtypes.h"
-
-#include "math/m_vector.h"
-
-#include "vbo/vbo.h"
-
-#include "tnl.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.
- */
-/* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for
- * GLSL vertex shader which cannot be aliased with conventional vertex attribs.
- * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give
- * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE*
- * attribs want (16).
- */
-enum {
- _TNL_ATTRIB_POS,
- _TNL_ATTRIB_NORMAL,
- _TNL_ATTRIB_COLOR0,
- _TNL_ATTRIB_COLOR1,
- _TNL_ATTRIB_FOG,
- _TNL_ATTRIB_COLOR_INDEX,
- _TNL_ATTRIB_TEX0,
- _TNL_ATTRIB_TEX1,
- _TNL_ATTRIB_TEX2,
- _TNL_ATTRIB_TEX3,
- _TNL_ATTRIB_TEX4,
- _TNL_ATTRIB_TEX5,
- _TNL_ATTRIB_TEX6,
- _TNL_ATTRIB_TEX7,
-
- /* This is really a VARYING_SLOT, not an attrib. Need to fix
- * tnl to understand the difference.
- */
- _TNL_ATTRIB_POINTSIZE,
-
- _TNL_ATTRIB_GENERIC0, /* doesn't really exist! */
- _TNL_ATTRIB_GENERIC1,
- _TNL_ATTRIB_GENERIC2,
- _TNL_ATTRIB_GENERIC3,
- _TNL_ATTRIB_GENERIC4,
- _TNL_ATTRIB_GENERIC5,
- _TNL_ATTRIB_GENERIC6,
- _TNL_ATTRIB_GENERIC7,
- _TNL_ATTRIB_GENERIC8,
- _TNL_ATTRIB_GENERIC9,
- _TNL_ATTRIB_GENERIC10,
- _TNL_ATTRIB_GENERIC11,
- _TNL_ATTRIB_GENERIC12,
- _TNL_ATTRIB_GENERIC13,
- _TNL_ATTRIB_GENERIC14,
- _TNL_ATTRIB_GENERIC15,
- _TNL_ATTRIB_EDGEFLAG,
-
- _TNL_ATTRIB_MAX,
-
- /* These alias with the generics, but they are not active
- * concurrently, so it's not a problem. The TNL module
- * doesn't have to do anything about this as this is how they
- * are passed into the _draw_prims callback.
- *
- * When we generate fixed-function replacement programs (in
- * t_vp_build.c currently), they refer to the appropriate
- * generic attribute in order to pick up per-vertex material
- * data.
- */
- _TNL_ATTRIB_MAT_FRONT_AMBIENT=VERT_ATTRIB_MAT(MAT_ATTRIB_FRONT_AMBIENT),
- _TNL_ATTRIB_MAT_BACK_AMBIENT,
- _TNL_ATTRIB_MAT_FRONT_DIFFUSE,
- _TNL_ATTRIB_MAT_BACK_DIFFUSE,
- _TNL_ATTRIB_MAT_FRONT_SPECULAR,
- _TNL_ATTRIB_MAT_BACK_SPECULAR,
- _TNL_ATTRIB_MAT_FRONT_EMISSION,
- _TNL_ATTRIB_MAT_BACK_EMISSION,
- _TNL_ATTRIB_MAT_FRONT_SHININESS,
- _TNL_ATTRIB_MAT_BACK_SHININESS,
- _TNL_ATTRIB_MAT_FRONT_INDEXES,
- _TNL_ATTRIB_MAT_BACK_INDEXES,
-};
-
-#define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u))
-#define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n))
-
-/* special index used for handing invalid glVertexAttribute() indices */
-#define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_GENERIC15 + 1)
-
-/**
- * Handy attribute ranges:
- */
-#define _TNL_FIRST_PROG _TNL_ATTRIB_NORMAL
-#define _TNL_LAST_PROG _TNL_ATTRIB_TEX7
-
-#define _TNL_FIRST_TEX _TNL_ATTRIB_TEX0
-#define _TNL_LAST_TEX _TNL_ATTRIB_TEX7
-
-#define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0
-#define _TNL_LAST_GENERIC _TNL_ATTRIB_GENERIC15
-
-#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC4 */
-#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* GENERIC15 */
-
-/* Number of available texture attributes */
-#define _TNL_NUM_TEX 8
-
-/* Number of available generic attributes */
-#define _TNL_NUM_GENERIC 16
-
-/* Number of attributes used for evaluators */
-#define _TNL_NUM_EVAL 16
-
-
-#define PRIM_BEGIN 0x10
-#define PRIM_END 0x20
-#define PRIM_MODE_MASK 0x0f
-
-static inline GLuint _tnl_translate_prim( const struct _mesa_prim *prim )
-{
- GLuint flag;
- flag = prim->mode;
- if (prim->begin) flag |= PRIM_BEGIN;
- if (prim->end) flag |= PRIM_END;
- return flag;
-}
-
-
-
-
-/**
- * Contains the current state of a running pipeline.
- */
-struct vertex_buffer
-{
- GLuint Size; /**< Max vertices per vertex buffer, constant */
-
- /* Constant over the pipeline.
- */
- GLuint Count; /**< Number of vertices currently in buffer */
-
- /* Pointers to current data. Most of the data is in AttribPtr -- all of
- * it that is one of VERT_ATTRIB_X. For things only produced by TNL,
- * such as backface color or eye-space coordinates, they are stored
- * here.
- */
- GLuint *Elts;
- 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 */
- GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */
- GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */
- GLvector4f *BackfaceIndexPtr;
- GLvector4f *BackfaceColorPtr;
- GLvector4f *BackfaceSecondaryColorPtr;
-
- const struct _mesa_prim *Primitive;
- GLuint PrimitiveCount;
-
- /* Inputs to the vertex program stage */
- GLvector4f *AttribPtr[_TNL_ATTRIB_MAX];
-};
-
-
-/**
- * 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)( struct gl_context *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)( struct gl_context *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)( struct gl_context *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)( struct gl_context *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)( struct gl_context *ctx, GLuint first, GLuint last );
-typedef void (*tnl_line_func)( struct gl_context *ctx, GLuint v1, GLuint v2 );
-typedef void (*tnl_triangle_func)( struct gl_context *ctx,
- GLuint v1, GLuint v2, GLuint v3 );
-typedef void (*tnl_quad_func)( struct gl_context *ctx, GLuint v1, GLuint v2,
- GLuint v3, GLuint v4 );
-typedef void (*tnl_render_func)( struct gl_context *ctx, GLuint start, GLuint count,
- GLuint flags );
-typedef void (*tnl_interp_func)( struct gl_context *ctx,
- GLfloat t, GLuint dst, GLuint out, GLuint in,
- GLboolean force_boundary );
-typedef void (*tnl_copy_pv_func)( struct gl_context *ctx, GLuint dst, GLuint src );
-typedef void (*tnl_setup_func)( struct gl_context *ctx,
- GLuint start, GLuint end,
- GLuint new_inputs);
-
-
-struct tnl_attr_type {
- GLuint format;
- GLuint size;
- GLuint stride;
- GLuint offset;
-};
-
-struct tnl_clipspace_fastpath {
- GLuint vertex_size;
- GLuint attr_count;
- GLboolean match_strides;
-
- struct tnl_attr_type *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)( struct gl_context *ctx );
-};
-
-
-#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
-
-/**
- * Material shininess lookup table.
- */
-struct tnl_shine_tab
-{
- struct tnl_shine_tab *next, *prev;
- GLfloat tab[SHINE_TABLE_SIZE+1];
- GLfloat shininess;
- GLuint refcount;
-};
-
-
-struct tnl_device_driver
-{
- /***
- *** TNL Pipeline
- ***/
-
- void (*RunPipeline)(struct gl_context *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)(struct gl_context *ctx);
- /* Alert tnl-aware drivers of changes to material.
- */
-
- /***
- *** Rendering -- These functions called only from t_vb_render.c
- ***/
- struct
- {
- void (*Start)(struct gl_context *ctx);
- void (*Finish)(struct gl_context *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)(struct gl_context *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)( struct gl_context *ctx, const GLuint *elts, GLuint n );
- /* Render a polygon with <n> vertices whose indexes are in the <elts>
- * array.
- */
-
- void (*ClippedLine)( struct gl_context *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)( struct gl_context *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)( struct gl_context *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;
-};
-
-
-/**
- * Utility that tracks and updates the current array entries.
- */
-struct tnl_inputs
-{
- /**
- * Array of inputs to be set to the _DrawArrays pointer.
- * The array contains pointers into the _DrawVAO and to the vbo modules
- * current values. The array of pointers is updated incrementally
- * based on the current and vertex_processing_mode values below.
- */
- struct tnl_vertex_array inputs[VERT_ATTRIB_MAX];
- /** Those VERT_BIT_'s where the inputs array point to current values. */
- GLbitfield current;
- /** Store which aliasing current values - generics or materials - are set. */
- gl_vertex_processing_mode vertex_processing_mode;
-};
-
-
-/**
- * Initialize inputs.
- */
-void
-_tnl_init_inputs(struct tnl_inputs *inputs);
-
-
-/**
- * Update the tnl_vertex_array array inside the tnl_inputs structure
- * provided the current _VPMode, the provided vao and
- * the vao's enabled arrays filtered by the filter bitmask.
- */
-void
-_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs);
-
-
-/**
- * Context state for T&L context.
- */
-typedef struct
-{
- /* Driver interface.
- */
- struct tnl_device_driver Driver;
-
- /* Pipeline
- */
- struct tnl_pipeline pipeline;
- struct vertex_buffer vb;
-
- /* Clipspace/ndc/window vertex managment:
- */
- struct tnl_clipspace clipspace;
- GLmatrix _WindowMap;
-
- /* Probably need a better configuration mechanism:
- */
- GLboolean NeedNdcCoords;
- GLboolean AllowVertexFog;
- GLboolean AllowPixelFog;
- GLboolean _DoVertexFog; /* eval fog function at each vertex? */
-
- GLbitfield64 render_inputs_bitset;
-
- GLvector4f tmp_inputs[VERT_ATTRIB_MAX];
-
- /* Temp storage for t_draw.c:
- */
- GLubyte *block[VERT_ATTRIB_MAX];
- GLuint nr_blocks;
-
- GLuint CurInstance;
-
- struct tnl_shine_tab *_ShineTable[2]; /**< Active shine tables */
- struct tnl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
- /**@}*/
-
- /* The list of tnl_vertex_array inputs. */
- struct tnl_inputs draw_arrays;
-} 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_clip_prepare(struct gl_context *ctx);
-
-
-#endif
diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c
deleted file mode 100644
index d48687e1db9..00000000000
--- a/src/mesa/tnl/t_draw.c
+++ /dev/null
@@ -1,657 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/arrayobj.h"
-#include "main/bufferobj.h"
-#include "main/condrender.h"
-#include "main/context.h"
-
-#include "main/mtypes.h"
-#include "main/macros.h"
-#include "main/enums.h"
-#include "main/varray.h"
-#include "util/half_float.h"
-
-#include "t_context.h"
-#include "t_rebase.h"
-#include "tnl.h"
-
-
-static GLubyte *get_space(struct gl_context *ctx, GLuint bytes)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLubyte *space = malloc(bytes);
-
- tnl->block[tnl->nr_blocks++] = space;
- return space;
-}
-
-
-static void free_space(struct gl_context *ctx)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- for (GLuint i = 0; i < tnl->nr_blocks; i++)
- free(tnl->block[i]);
-
- tnl->nr_blocks = 0;
-}
-
-
-/* Convert the incoming array to GLfloats. Understands the
- * array->Normalized flag and selects the correct conversion method.
- */
-#define CONVERT( TYPE, MACRO ) do { \
- GLuint i, j; \
- if (attrib->Format.Normalized) { \
- for (i = 0; i < count; i++) { \
- const TYPE *in = (TYPE *)ptr; \
- for (j = 0; j < sz; j++) { \
- *fptr++ = MACRO(*in); \
- in++; \
- } \
- ptr += binding->Stride; \
- } \
- } else { \
- for (i = 0; i < count; i++) { \
- const TYPE *in = (TYPE *)ptr; \
- for (j = 0; j < sz; j++) { \
- *fptr++ = (GLfloat)(*in); \
- in++; \
- } \
- ptr += binding->Stride; \
- } \
- } \
-} while (0)
-
-
-/**
- * Convert array of BGRA/GLubyte[4] values to RGBA/float[4]
- * \param ptr input/ubyte array
- * \param fptr output/float array
- */
-static void
-convert_bgra_to_float(const struct gl_vertex_buffer_binding *binding,
- const struct gl_array_attributes *attrib,
- const GLubyte *ptr, GLfloat *fptr,
- GLuint count)
-{
- GLuint i;
- assert(attrib->Format.Normalized);
- assert(attrib->Format.Size == 4);
- for (i = 0; i < count; i++) {
- const GLubyte *in = (GLubyte *) ptr; /* in is in BGRA order */
- *fptr++ = UBYTE_TO_FLOAT(in[2]); /* red */
- *fptr++ = UBYTE_TO_FLOAT(in[1]); /* green */
- *fptr++ = UBYTE_TO_FLOAT(in[0]); /* blue */
- *fptr++ = UBYTE_TO_FLOAT(in[3]); /* alpha */
- ptr += binding->Stride;
- }
-}
-
-static void
-convert_half_to_float(const struct gl_vertex_buffer_binding *binding,
- const GLubyte *ptr, GLfloat *fptr,
- GLuint count, GLuint sz)
-{
- GLuint i, j;
-
- for (i = 0; i < count; i++) {
- GLhalfARB *in = (GLhalfARB *)ptr;
-
- for (j = 0; j < sz; j++)
- *fptr++ = _mesa_half_to_float(in[j]);
-
- ptr += binding->Stride;
- }
-}
-
-/**
- * \brief Convert fixed-point to floating-point.
- *
- * In OpenGL, a fixed-point number is a "signed 2's complement 16.16 scaled
- * integer" (Table 2.2 of the OpenGL ES 2.0 spec).
- *
- * If the buffer has the \c normalized flag set, the formula
- * \code normalize(x) := (2*x + 1) / (2^16 - 1) \endcode
- * is used to map the fixed-point numbers into the range [-1, 1].
- */
-static void
-convert_fixed_to_float(const struct gl_vertex_buffer_binding *binding,
- const struct gl_array_attributes *attrib,
- const GLubyte *ptr, GLfloat *fptr,
- GLuint count)
-{
- GLuint i;
- GLint j;
- const GLint size = attrib->Format.Size;
-
- if (attrib->Format.Normalized) {
- for (i = 0; i < count; ++i) {
- const GLfixed *in = (GLfixed *) ptr;
- for (j = 0; j < size; ++j) {
- *fptr++ = (GLfloat) (2 * in[j] + 1) / (GLfloat) ((1 << 16) - 1);
- }
- ptr += binding->Stride;
- }
- } else {
- for (i = 0; i < count; ++i) {
- const GLfixed *in = (GLfixed *) ptr;
- for (j = 0; j < size; ++j) {
- *fptr++ = in[j] / (GLfloat) (1 << 16);
- }
- ptr += binding->Stride;
- }
- }
-}
-
-/* Adjust pointer to point at first requested element, convert to
- * floating point, populate VB->AttribPtr[].
- */
-static void _tnl_import_array(struct gl_context *ctx,
- GLuint attr,
- GLuint count,
- const struct gl_vertex_buffer_binding *binding,
- const struct gl_array_attributes *attrib,
- const GLubyte *ptr)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLuint stride = binding->Stride;
-
- if (attrib->Format.Type != GL_FLOAT) {
- const GLuint sz = attrib->Format.Size;
- GLubyte *buf = get_space(ctx, count * sz * sizeof(GLfloat));
- GLfloat *fptr = (GLfloat *)buf;
-
- switch (attrib->Format.Type) {
- case GL_BYTE:
- CONVERT(GLbyte, BYTE_TO_FLOAT);
- break;
- case GL_UNSIGNED_BYTE:
- if (attrib->Format.Format == GL_BGRA) {
- /* See GL_EXT_vertex_array_bgra */
- convert_bgra_to_float(binding, attrib, ptr, fptr, count);
- }
- else {
- CONVERT(GLubyte, UBYTE_TO_FLOAT);
- }
- break;
- case GL_SHORT:
- CONVERT(GLshort, SHORT_TO_FLOAT);
- break;
- case GL_UNSIGNED_SHORT:
- CONVERT(GLushort, USHORT_TO_FLOAT);
- break;
- case GL_INT:
- CONVERT(GLint, INT_TO_FLOAT);
- break;
- case GL_UNSIGNED_INT:
- CONVERT(GLuint, UINT_TO_FLOAT);
- break;
- case GL_DOUBLE:
- CONVERT(GLdouble, (GLfloat));
- break;
- case GL_HALF_FLOAT:
- convert_half_to_float(binding, ptr, fptr, count, sz);
- break;
- case GL_FIXED:
- convert_fixed_to_float(binding, attrib, ptr, fptr, count);
- break;
- default:
- unreachable("Invalid type.");
- }
-
- ptr = buf;
- stride = sz * sizeof(GLfloat);
- }
-
- VB->AttribPtr[attr] = &tnl->tmp_inputs[attr];
- VB->AttribPtr[attr]->data = (GLfloat (*)[4])ptr;
- VB->AttribPtr[attr]->start = (GLfloat *)ptr;
- VB->AttribPtr[attr]->count = count;
- VB->AttribPtr[attr]->stride = stride;
- VB->AttribPtr[attr]->size = attrib->Format.Size;
-
- /* This should die, but so should the whole GLvector4f concept:
- */
- VB->AttribPtr[attr]->flags = (((1<<attrib->Format.Size)-1) |
- VEC_NOT_WRITEABLE |
- (stride == 4*sizeof(GLfloat) ? 0 : VEC_BAD_STRIDE));
-
- VB->AttribPtr[attr]->storage = NULL;
-}
-
-#define CLIPVERTS ((6 + MAX_CLIP_PLANES) * 2)
-
-
-static GLboolean *_tnl_import_edgeflag(struct gl_context *ctx,
- const GLvector4f *input,
- GLuint count)
-{
- const GLubyte *ptr = (const GLubyte *)input->data;
- const GLuint stride = input->stride;
- GLboolean *space = (GLboolean *)get_space(ctx, count + CLIPVERTS);
- GLboolean *bptr = space;
-
- for (GLuint i = 0; i < count; i++) {
- *bptr++ = ((GLfloat *)ptr)[0] == 1.0F;
- ptr += stride;
- }
-
- return space;
-}
-
-
-static void bind_inputs(struct gl_context *ctx,
- const struct tnl_vertex_array *inputs,
- GLint count,
- struct gl_buffer_object **bo,
- GLuint *nr_bo)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
-
- /* Map all the VBOs
- */
- for (unsigned i = 0; i < VERT_ATTRIB_MAX; i++) {
- const struct tnl_vertex_array *array = &inputs[i];
- const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
- const struct gl_array_attributes *attrib = array->VertexAttrib;
- const void *ptr;
-
- if (binding->BufferObj) {
- if (!binding->BufferObj->Mappings[MAP_INTERNAL].Pointer) {
- bo[*nr_bo] = binding->BufferObj;
- (*nr_bo)++;
- ctx->Driver.MapBufferRange(ctx, 0, binding->BufferObj->Size,
- GL_MAP_READ_BIT,
- binding->BufferObj,
- MAP_INTERNAL);
-
- assert(binding->BufferObj->Mappings[MAP_INTERNAL].Pointer);
- }
-
- ptr = ADD_POINTERS(binding->BufferObj->Mappings[MAP_INTERNAL].Pointer,
- binding->Offset + attrib->RelativeOffset);
- } else
- ptr = attrib->Ptr;
-
- /* Just make sure the array is floating point, otherwise convert to
- * temporary storage.
- *
- * XXX: remove the GLvector4f type at some stage and just use
- * client arrays.
- */
- _tnl_import_array(ctx, i, count, binding, attrib, ptr);
- }
-
- /* We process only the vertices between min & max index:
- */
- VB->Count = count;
-
- /* These should perhaps be part of _TNL_ATTRIB_* */
- VB->BackfaceColorPtr = NULL;
- VB->BackfaceIndexPtr = NULL;
- VB->BackfaceSecondaryColorPtr = NULL;
-
- /* Clipping and drawing code still requires this to be a packed
- * array of ubytes which can be written into. TODO: Fix and
- * remove.
- */
- if (ctx->Polygon.FrontMode != GL_FILL ||
- ctx->Polygon.BackMode != GL_FILL) {
- VB->EdgeFlag = _tnl_import_edgeflag(ctx,
- VB->AttribPtr[_TNL_ATTRIB_EDGEFLAG],
- VB->Count);
- } else {
- /* the data previously pointed to by EdgeFlag may have been freed */
- VB->EdgeFlag = NULL;
- }
-}
-
-
-/* Translate indices to GLuints and store in VB->Elts.
- */
-static void bind_indices(struct gl_context *ctx,
- unsigned start,
- const struct _mesa_index_buffer *ib,
- struct gl_buffer_object **bo,
- GLuint *nr_bo)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLuint i;
- const void *ptr;
-
- if (!ib) {
- VB->Elts = NULL;
- return;
- }
-
- if (ib->obj) {
- if (!_mesa_bufferobj_mapped(ib->obj, MAP_INTERNAL)) {
- /* if the buffer object isn't mapped yet, map it now */
- bo[*nr_bo] = ib->obj;
- (*nr_bo)++;
- ptr = ctx->Driver.MapBufferRange(ctx, (GLsizeiptr) ib->ptr,
- ib->count << ib->index_size_shift,
- GL_MAP_READ_BIT, ib->obj,
- MAP_INTERNAL);
- assert(ib->obj->Mappings[MAP_INTERNAL].Pointer);
- } else {
- /* user-space elements, or buffer already mapped */
- ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
- }
- } else
- ptr = ib->ptr;
-
- if (ib->index_size_shift == 2 && VB->Primitive[0].basevertex == 0) {
- VB->Elts = (GLuint *) ptr;
- }
- else {
- GLuint *elts = (GLuint *)get_space(ctx, (start + ib->count) * sizeof(GLuint));
- VB->Elts = elts;
-
- elts += start;
-
- if (ib->index_size_shift == 2) {
- const GLuint *in = (GLuint *)ptr + start;
- for (i = 0; i < ib->count; i++)
- *elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
- }
- else if (ib->index_size_shift == 1) {
- const GLushort *in = (GLushort *)ptr + start;
- for (i = 0; i < ib->count; i++)
- *elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
- }
- else {
- const GLubyte *in = (GLubyte *)ptr + start;
- for (i = 0; i < ib->count; i++)
- *elts++ = (GLuint)(*in++) + VB->Primitive[0].basevertex;
- }
- }
-}
-
-static void bind_prims(struct gl_context *ctx,
- const struct _mesa_prim *prim,
- GLuint nr_prims)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
-
- VB->Primitive = prim;
- VB->PrimitiveCount = nr_prims;
-}
-
-static void unmap_vbos(struct gl_context *ctx,
- struct gl_buffer_object **bo,
- GLuint nr_bo)
-{
- for (GLuint i = 0; i < nr_bo; i++) {
- ctx->Driver.UnmapBuffer(ctx, bo[i], MAP_INTERNAL);
- }
-}
-
-
-/* This is the main workhorse doing all the rendering work.
- */
-void _tnl_draw_prims(struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLboolean index_bounds_valid,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- const GLuint TEST_SPLIT = 0;
- const GLint max = TEST_SPLIT ? 8 : tnl->vb.Size - MAX_CLIPPED_VERTICES;
- GLint max_basevertex = prim->basevertex;
- GLuint i;
-
- if (!index_bounds_valid)
- vbo_get_minmax_indices(ctx, prim, ib, &min_index, &max_index, nr_prims,
- false, 0);
-
- /* Mesa core state should have been validated already */
- assert(ctx->NewState == 0x0);
-
- if (!_mesa_check_conditional_render(ctx))
- return; /* don't draw */
-
- for (i = 1; i < nr_prims; i++)
- max_basevertex = MAX2(max_basevertex, prim[i].basevertex);
-
- if (0) {
- printf("%s %d..%d\n", __func__, min_index, max_index);
- for (i = 0; i < nr_prims; i++)
- printf("prim %d: %s start %d count %d\n", i,
- _mesa_enum_to_string(prim[i].mode),
- prim[i].start,
- prim[i].count);
- }
-
- if (min_index) {
- /* We always translate away calls with min_index != 0.
- */
- t_rebase_prims(ctx, arrays, prim, nr_prims, ib,
- min_index, max_index, num_instances, base_instance,
- _tnl_draw_prims);
- return;
- }
- else if ((GLint)max_index + max_basevertex > max) {
- /* The software TNL pipeline has a fixed amount of storage for
- * vertices and it is necessary to split incoming drawing commands
- * if they exceed that limit.
- */
- struct split_limits limits;
- limits.max_verts = max;
- limits.max_vb_size = ~0;
- limits.max_indices = ~0;
-
- /* This will split the buffers one way or another and
- * recursively call back into this function.
- */
- _tnl_split_prims(ctx, arrays, prim, nr_prims, ib,
- 0, max_index + prim->basevertex,
- num_instances, base_instance,
- _tnl_draw_prims,
- &limits);
- }
- else {
- /* May need to map a vertex buffer object for every attribute plus
- * one for the index buffer.
- */
- struct gl_buffer_object *bo[VERT_ATTRIB_MAX + 1];
- GLuint nr_bo;
- GLuint inst;
-
- assert(num_instances > 0);
-
- for (i = 0; i < nr_prims;) {
- GLuint this_nr_prims;
-
- /* Our SW TNL pipeline doesn't handle basevertex yet, so bind_indices
- * will rebase the elements to the basevertex, and we'll only
- * emit strings of prims with the same basevertex in one draw call.
- */
- for (this_nr_prims = 1; i + this_nr_prims < nr_prims;
- this_nr_prims++) {
- if (prim[i].basevertex != prim[i + this_nr_prims].basevertex ||
- prim[i].start != prim[i + this_nr_prims].start)
- break;
- }
-
- /* Binding inputs may imply mapping some vertex buffer objects.
- * They will need to be unmapped below.
- */
- for (inst = 0; inst < num_instances; inst++) {
- nr_bo = 0;
-
- bind_prims(ctx, &prim[i], this_nr_prims);
- bind_inputs(ctx, arrays, max_index + prim[i].basevertex + 1,
- bo, &nr_bo);
- bind_indices(ctx, prim[i].start, ib, bo, &nr_bo);
-
- tnl->CurInstance = inst;
- TNL_CONTEXT(ctx)->Driver.RunPipeline(ctx);
-
- unmap_vbos(ctx, bo, nr_bo);
- free_space(ctx);
- }
-
- i += this_nr_prims;
- }
- }
-}
-
-
-void
-_tnl_init_inputs(struct tnl_inputs *inputs)
-{
- inputs->current = 0;
- inputs->vertex_processing_mode = VP_MODE_FF;
-}
-
-
-/**
- * Update the tnl_inputs's arrays to point to the vao->_VertexArray arrays
- * according to the 'enable' bitmask.
- * \param enable bitfield of VERT_BIT_x flags.
- */
-static inline void
-update_vao_inputs(struct gl_context *ctx,
- struct tnl_inputs *inputs, GLbitfield enable)
-{
- const struct gl_vertex_array_object *vao = ctx->Array._DrawVAO;
-
- /* Make sure we process only arrays enabled in the VAO */
- assert((enable & ~vao->_EnabledWithMapMode) == 0);
-
- /* Fill in the client arrays from the VAO */
- const struct gl_vertex_buffer_binding *bindings = &vao->BufferBinding[0];
- while (enable) {
- const int attr = u_bit_scan(&enable);
- struct tnl_vertex_array *input = &inputs->inputs[attr];
- const struct gl_array_attributes *attrib;
- attrib = _mesa_draw_array_attrib(vao, attr);
- input->VertexAttrib = attrib;
- input->BufferBinding = &bindings[attrib->BufferBindingIndex];
- }
-}
-
-
-/**
- * Update the tnl_inputs's arrays to point to the vbo->currval arrays
- * according to the 'current' bitmask.
- * \param current bitfield of VERT_BIT_x flags.
- */
-static inline void
-update_current_inputs(struct gl_context *ctx,
- struct tnl_inputs *inputs, GLbitfield current)
-{
- gl_vertex_processing_mode mode = ctx->VertexProgram._VPMode;
-
- /* All previously non current array pointers need update. */
- GLbitfield mask = current & ~inputs->current;
- /* On mode change, the slots aliasing with materials need update too */
- if (mode != inputs->vertex_processing_mode)
- mask |= current & VERT_BIT_MAT_ALL;
-
- while (mask) {
- const int attr = u_bit_scan(&mask);
- struct tnl_vertex_array *input = &inputs->inputs[attr];
- input->VertexAttrib = _vbo_current_attrib(ctx, attr);
- input->BufferBinding = _vbo_current_binding(ctx);
- }
-
- inputs->current = current;
- inputs->vertex_processing_mode = mode;
-}
-
-
-/**
- * Update the tnl_inputs's arrays to point to the vao->_VertexArray and
- * vbo->currval arrays according to Array._DrawVAO and
- * Array._DrawVAOEnableAttribs.
- */
-void
-_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs)
-{
- const GLbitfield enable = ctx->Array._DrawVAOEnabledAttribs;
-
- /* Update array input pointers */
- update_vao_inputs(ctx, inputs, enable);
-
- /* The rest must be current inputs. */
- update_current_inputs(ctx, inputs, ~enable & VERT_BIT_ALL);
-}
-
-
-const struct tnl_vertex_array *
-_tnl_bind_inputs(struct gl_context *ctx)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- _tnl_update_inputs(ctx, &tnl->draw_arrays);
- return tnl->draw_arrays.inputs;
-}
-
-
-/* This is the main entrypoint into the slimmed-down software tnl
- * module. In a regular swtnl driver, this can be plugged straight
- * into the ctx->Driver.Draw() callback.
- */
-void
-_tnl_draw(struct gl_context *ctx,
- const struct _mesa_prim *prim, unsigned nr_prims,
- const struct _mesa_index_buffer *ib,
- bool index_bounds_valid, bool primitive_restart,
- unsigned restart_index, unsigned min_index, unsigned max_index,
- unsigned num_instances, unsigned base_instance)
-{
- /* Update TNLcontext::draw_arrays and return that pointer.
- */
- const struct tnl_vertex_array* arrays = _tnl_bind_inputs(ctx);
-
- _tnl_draw_prims(ctx, arrays, prim, nr_prims, ib,
- index_bounds_valid, min_index, max_index,
- num_instances, base_instance);
-}
-
-
-void
-_tnl_init_driver_draw_function(struct dd_function_table *functions)
-{
- functions->Draw = _tnl_draw;
-}
diff --git a/src/mesa/tnl/t_pipeline.c b/src/mesa/tnl/t_pipeline.c
deleted file mode 100644
index 760e69dba9d..00000000000
--- a/src/mesa/tnl/t_pipeline.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-#include "main/glheader.h"
-#include "main/context.h"
-
-#include "main/mtypes.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-#include "t_vp_build.h"
-#include "t_vertex.h"
-
-void _tnl_install_pipeline( struct gl_context *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( struct gl_context *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( struct gl_context *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- for (i = 0; i <= _TNL_LAST_MAT; 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( struct gl_context *ctx )
-{
-#if 0
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- for (i = 0; i < VARYING_SLOT_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
-}
-
-/**
- * START/END_FAST_MATH macros:
- *
- * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
- * original mode to a temporary).
- * END_FAST_MATH: Restore x86 FPU to original mode.
- */
-#if defined(__GNUC__) && defined(__i386__)
-/*
- * Set the x86 FPU control word to guarentee only 32 bits of precision
- * are stored in registers. Allowing the FPU to store more introduces
- * differences between situations where numbers are pulled out of memory
- * vs. situations where the compiler is able to optimize register usage.
- *
- * In the worst case, we force the compiler to use a memory access to
- * truncate the float, by specifying the 'volatile' keyword.
- */
-/* Hardware default: All exceptions masked, extended double precision,
- * round to nearest (IEEE compliant):
- */
-#define DEFAULT_X86_FPU 0x037f
-/* All exceptions masked, single precision, round to nearest:
- */
-#define FAST_X86_FPU 0x003f
-/* The fldcw instruction will cause any pending FP exceptions to be
- * raised prior to entering the block, and we clear any pending
- * exceptions before exiting the block. Hence, asm code has free
- * reign over the FPU while in the fast math block.
- */
-#if defined(NO_FAST_MATH)
-#define START_FAST_MATH(x) \
-do { \
- static GLuint mask = DEFAULT_X86_FPU; \
- __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
- __asm__ ( "fldcw %0" : : "m" (mask) ); \
-} while (0)
-#else
-#define START_FAST_MATH(x) \
-do { \
- static GLuint mask = FAST_X86_FPU; \
- __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
- __asm__ ( "fldcw %0" : : "m" (mask) ); \
-} while (0)
-#endif
-/* Restore original FPU mode, and clear any exceptions that may have
- * occurred in the FAST_MATH block.
- */
-#define END_FAST_MATH(x) \
-do { \
- __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
-} while (0)
-
-#elif defined(_MSC_VER) && defined(_M_IX86)
-#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
-#define FAST_X86_FPU 0x003f /* See GCC comments above */
-#if defined(NO_FAST_MATH)
-#define START_FAST_MATH(x) do {\
- static GLuint mask = DEFAULT_X86_FPU;\
- __asm fnstcw word ptr [x]\
- __asm fldcw word ptr [mask]\
-} while(0)
-#else
-#define START_FAST_MATH(x) do {\
- static GLuint mask = FAST_X86_FPU;\
- __asm fnstcw word ptr [x]\
- __asm fldcw word ptr [mask]\
-} while(0)
-#endif
-#define END_FAST_MATH(x) do {\
- __asm fnclex\
- __asm fldcw word ptr [x]\
-} while(0)
-
-#else
-#define START_FAST_MATH(x) x = 0
-#define END_FAST_MATH(x) (void)(x)
-#endif
-
-
-void _tnl_run_pipeline( struct gl_context *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->VertexProgram._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 );
- }
-
-#ifndef _OPENMP
- /* Don't adjust FPU precision mode in case multiple threads are to be used.
- * This would require that the additional threads also changed the FPU mode
- * which is quite a mess as this had to be done in all parallelized sections;
- * otherwise the master thread and all other threads are running in different
- * modes, producing inconsistent results.
- * Note that all x64 implementations don't define/use START_FAST_MATH, so
- * this is "hack" is only used in i386 mode
- */
- START_FAST_MATH(__tmp);
-#endif
-
- for (i = 0; i < tnl->pipeline.nr_stages ; i++) {
- struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
- if (!s->run( ctx, s ))
- break;
- }
-
-#ifndef _OPENMP
- END_FAST_MATH(__tmp);
-#endif
-}
-
-
-
-/* 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_texgen_stage,
- &_tnl_texture_transform_stage,
- &_tnl_point_attenuation_stage,
- &_tnl_vertex_program_stage,
- &_tnl_fog_coordinate_stage,
- &_tnl_render_stage,
- NULL
-};
-
-const struct tnl_pipeline_stage *_tnl_vp_pipeline[] = {
- &_tnl_vertex_program_stage,
- &_tnl_render_stage,
- NULL
-};
diff --git a/src/mesa/tnl/t_pipeline.h b/src/mesa/tnl/t_pipeline.h
deleted file mode 100644
index 48963df0623..00000000000
--- a/src/mesa/tnl/t_pipeline.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-
-#ifndef _T_PIPELINE_H_
-#define _T_PIPELINE_H_
-
-#include "main/mtypes.h"
-#include "t_context.h"
-
-extern void _tnl_run_pipeline( struct gl_context *ctx );
-
-extern void _tnl_destroy_pipeline( struct gl_context *ctx );
-
-extern void _tnl_install_pipeline( struct gl_context *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_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_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( struct gl_context *ctx,
- const GLuint *elts, GLuint n );
-
-extern void _tnl_RenderClippedLine( struct gl_context *ctx, GLuint ii, GLuint jj );
-
-
-#endif
diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c
deleted file mode 100644
index 0471895641e..00000000000
--- a/src/mesa/tnl/t_rebase.c
+++ /dev/null
@@ -1,267 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-/* Helper for drivers which find themselves rendering a range of
- * indices starting somewhere above zero. Typically the application
- * is issuing multiple DrawArrays() or DrawElements() to draw
- * successive primitives layed out linearly in the vertex arrays.
- * Unless the vertex arrays are all in a VBO, the OpenGL semantics
- * imply that we need to re-upload the vertex data on each draw call.
- * In that case, we want to avoid starting the upload at zero, as it
- * will mean every draw call uploads an increasing amount of not-used
- * vertex data. Worse - in the software tnl module, all those
- * vertices will be transformed and lit.
- *
- * If we just upload the new data, however, the indices will be
- * incorrect as we tend to upload each set of vertex data to a new
- * region.
- *
- * This file provides a helper to adjust the arrays, primitives and
- * indices of a draw call so that it can be re-issued with a min_index
- * of zero.
- */
-
-#include <stdio.h>
-#include "main/bufferobj.h"
-#include "main/errors.h"
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "vbo/vbo.h"
-
-#include "t_rebase.h"
-
-
-#define REBASE(TYPE) \
-static void *rebase_##TYPE(const void *ptr, \
- unsigned start, \
- unsigned count, \
- TYPE min_index) \
-{ \
- const TYPE *in = (TYPE *)ptr; \
- TYPE *tmp_indices = malloc((start + count) * sizeof(TYPE)); \
- \
- if (tmp_indices == NULL) { \
- _mesa_error_no_memory(__func__); \
- return NULL; \
- } \
- \
- for (unsigned i = 0; i < count; i++) \
- tmp_indices[start + i] = in[start + i] - min_index; \
- \
- return (void *)tmp_indices; \
-}
-
-REBASE(GLuint)
-REBASE(GLushort)
-REBASE(GLubyte)
-
-
-/* Adjust primitives, indices and vertex definitions so that min_index
- * becomes zero. There are lots of reasons for wanting to do this, eg:
- *
- * Software tnl:
- * - any time min_index != 0, otherwise unused vertices lower than
- * min_index will be transformed.
- *
- * Hardware tnl:
- * - if ib != NULL and min_index != 0, otherwise vertices lower than
- * min_index will be uploaded. Requires adjusting index values.
- *
- * - if ib == NULL and min_index != 0, just for convenience so this doesn't
- * have to be handled within the driver.
- *
- * Hardware tnl with VBO support:
- * - as above, but only when vertices are not (all?) in VBO's.
- * - can't save time by trying to upload half a vbo - typically it is
- * all or nothing.
- */
-void t_rebase_prims(struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance,
- tnl_draw_func draw)
-{
- struct gl_array_attributes tmp_attribs[VERT_ATTRIB_MAX];
- struct tnl_vertex_array tmp_arrays[VERT_ATTRIB_MAX];
-
- struct _mesa_index_buffer tmp_ib;
- struct _mesa_prim *tmp_prims = NULL;
- void *tmp_indices = NULL;
- GLuint i;
-
- assert(min_index != 0);
-
- if (0)
- printf("%s %d..%d\n", __func__, min_index, max_index);
-
- /* XXX this path is disabled for now.
- * There's rendering corruption in some apps when it's enabled.
- */
- if (0 && ib && ctx->Extensions.ARB_draw_elements_base_vertex) {
- /* If we can just tell the hardware or the TNL to interpret our indices
- * with a different base, do so.
- */
- tmp_prims = malloc(sizeof(*prim) * nr_prims);
-
- if (tmp_prims == NULL) {
- _mesa_error_no_memory(__func__);
- return;
- }
-
- for (i = 0; i < nr_prims; i++) {
- tmp_prims[i] = prim[i];
- tmp_prims[i].basevertex -= min_index;
- }
-
- prim = tmp_prims;
- } else if (ib) {
- unsigned start = prim[0].start;
- for (i = 1; i < nr_prims; i++) {
- if (prim[i].start != start) {
- if (0) {
- printf("%s recursing due to mismatched start "
- "(prim[0].start = %u vs. prim[%u].start = %u)\n",
- __func__, start, i, prim[i].start);
- }
-
- t_rebase_prims(ctx, arrays, &prim[0], i, ib, min_index,
- max_index, num_instances, base_instance, draw);
- t_rebase_prims(ctx, arrays, &prim[i], nr_prims - i, ib, min_index,
- max_index, num_instances, base_instance, draw);
- return;
- }
- }
-
- /* Unfortunately need to adjust each index individually.
- */
- bool map_ib = false;
- const void *ptr;
-
- if (ib->obj) {
- if (!ib->obj->Mappings[MAP_INTERNAL].Pointer) {
- ctx->Driver.MapBufferRange(ctx, 0, ib->obj->Size, GL_MAP_READ_BIT,
- ib->obj, MAP_INTERNAL);
- map_ib = true;
- }
-
- ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr);
- } else
- ptr = ib->ptr;
-
- /* Some users might prefer it if we translated elements to GLuints here.
- * Others wouldn't...
- */
- switch (ib->index_size_shift) {
- case 2:
- tmp_indices = rebase_GLuint(ptr, start, ib->count, min_index);
- break;
- case 1:
- tmp_indices = rebase_GLushort(ptr, start, ib->count, min_index);
- break;
- case 0:
- tmp_indices = rebase_GLubyte(ptr, start, ib->count, min_index);
- break;
- }
-
- if (map_ib)
- ctx->Driver.UnmapBuffer(ctx, ib->obj, MAP_INTERNAL);
-
- if (tmp_indices == NULL)
- return;
-
- tmp_ib.obj = NULL;
- tmp_ib.ptr = tmp_indices;
- tmp_ib.count = ib->count;
- tmp_ib.index_size_shift = ib->index_size_shift;
-
- ib = &tmp_ib;
- }
- else {
- /* Otherwise the primitives need adjustment. */
- tmp_prims = malloc(sizeof(*prim) * nr_prims);
-
- if (tmp_prims == NULL) {
- _mesa_error_no_memory(__func__);
- return;
- }
-
- for (i = 0; i < nr_prims; i++) {
- /* If this fails, it could indicate an application error: */
- assert(prim[i].start >= min_index);
-
- tmp_prims[i] = prim[i];
- tmp_prims[i].start -= min_index;
- }
-
- prim = tmp_prims;
- }
-
- /* Just need to adjust the pointer values on each incoming array.
- * This works for VBO and non-vbo rendering and shouldn't pesimize
- * VBO-based upload schemes. However this may still not be a fast
- * path for hardware tnl for VBO based rendering as most machines
- * will be happier if you just specify a starting vertex value in
- * each primitive.
- *
- * For drivers with hardware tnl, you only want to do this if you
- * are forced to, eg non-VBO indexed rendering with start != 0.
- */
- for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- tmp_attribs[i] = *(arrays[i].VertexAttrib);
- tmp_arrays[i].BufferBinding = arrays[i].BufferBinding;
- tmp_arrays[i].VertexAttrib = &tmp_attribs[i];
- if (arrays[i].BufferBinding->BufferObj)
- tmp_attribs[i].RelativeOffset +=
- min_index * arrays[i].BufferBinding->Stride;
- else
- tmp_attribs[i].Ptr += min_index * arrays[i].BufferBinding->Stride;
- }
-
- /* Re-issue the draw call. */
- draw(ctx,
- tmp_arrays,
- prim,
- nr_prims,
- ib,
- GL_TRUE,
- 0,
- max_index - min_index,
- num_instances, base_instance);
-
- free(tmp_indices);
- free(tmp_prims);
-}
-
-
-
diff --git a/src/mesa/tnl/t_rebase.h b/src/mesa/tnl/t_rebase.h
deleted file mode 100644
index b596d93995b..00000000000
--- a/src/mesa/tnl/t_rebase.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _T_REBASE_H_
-#define _T_REBASE_H_
-
-#include "tnl.h"
-
-void t_rebase_prims( struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance,
- tnl_draw_func draw );
-
-#endif
diff --git a/src/mesa/tnl/t_split.c b/src/mesa/tnl/t_split.c
deleted file mode 100644
index 3959e11d236..00000000000
--- a/src/mesa/tnl/t_split.c
+++ /dev/null
@@ -1,162 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-/* Deal with hardware and/or swtnl maximums:
- * - maximum number of vertices in buffer
- * - maximum number of elements (maybe zero)
- *
- * The maximums may vary with opengl state (eg if a larger hardware
- * vertex is required in this state, the maximum number of vertices
- * may be smaller than in another state).
- *
- * We want buffer splitting to be a convenience function for the code
- * actually drawing the primitives rather than a system-wide maximum,
- * otherwise it is hard to avoid pessimism.
- *
- * For instance, if a driver has no hardware limits on vertex buffer
- * dimensions, it would not ordinarily want to split vbos. But if
- * there is an unexpected fallback, eg memory manager fails to upload
- * textures, it will want to pass the drawing commands onto swtnl,
- * which does have limitations. A convenience function allows swtnl
- * to split the drawing and vbos internally without imposing its
- * limitations on drivers which want to use it as a fallback path.
- */
-
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "vbo/vbo.h"
-
-#include "t_split.h"
-
-
-/* True if a primitive can be split without copying of vertices, false
- * otherwise.
- */
-GLboolean
-_tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr)
-{
- switch (mode) {
- case GL_POINTS:
- *first = 1;
- *incr = 1;
- return GL_TRUE;
- case GL_LINES:
- *first = 2;
- *incr = 2;
- return GL_TRUE;
- case GL_LINE_STRIP:
- *first = 2;
- *incr = 1;
- return GL_TRUE;
- case GL_TRIANGLES:
- *first = 3;
- *incr = 3;
- return GL_TRUE;
- case GL_TRIANGLE_STRIP:
- *first = 3;
- *incr = 1;
- return GL_TRUE;
- case GL_QUADS:
- *first = 4;
- *incr = 4;
- return GL_TRUE;
- case GL_QUAD_STRIP:
- *first = 4;
- *incr = 2;
- return GL_TRUE;
- default:
- *first = 0;
- *incr = 1; /* so that count % incr works */
- return GL_FALSE;
- }
-}
-
-
-
-void
-_tnl_split_prims(struct gl_context *ctx,
- const struct tnl_vertex_array arrays[],
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance,
- tnl_draw_func draw,
- const struct split_limits *limits)
-{
- if (ib) {
- if (limits->max_indices == 0) {
- /* Could traverse the indices, re-emitting vertices in turn.
- * But it's hard to see why this case would be needed - for
- * software tnl, it is better to convert to non-indexed
- * rendering after transformation is complete. Are there any devices
- * with hardware tnl that cannot do indexed rendering?
- *
- * For now, this path is disabled.
- */
- assert(0);
- }
- else if (max_index - min_index >= limits->max_verts) {
- /* The vertex buffers are too large for hardware (or the
- * swtnl module). Traverse the indices, re-emitting vertices
- * in turn. Use a vertex cache to preserve some of the
- * sharing from the original index list.
- */
- _tnl_split_copy(ctx, arrays, prim, nr_prims, ib, draw, limits);
- }
- else if (ib->count > limits->max_indices) {
- /* The index buffer is too large for hardware. Try to split
- * on whole-primitive boundaries, otherwise try to split the
- * individual primitives.
- */
- _tnl_split_inplace(ctx, arrays, prim, nr_prims, ib,
- num_instances, base_instance, draw, limits);
- }
- else {
- /* Why were we called? */
- assert(0);
- }
- }
- else {
- if (max_index - min_index >= limits->max_verts) {
- /* The vertex buffer is too large for hardware (or the swtnl
- * module). Try to split on whole-primitive boundaries,
- * otherwise try to split the individual primitives.
- */
- _tnl_split_inplace(ctx, arrays, prim, nr_prims, ib,
- num_instances, base_instance, draw, limits);
- }
- else {
- /* Why were we called? */
- assert(0);
- }
- }
-}
-
diff --git a/src/mesa/tnl/t_split.h b/src/mesa/tnl/t_split.h
deleted file mode 100644
index 8f2d1baa53c..00000000000
--- a/src/mesa/tnl/t_split.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/**
- * \brief VBO builder module datatypes and definitions.
- * \author Keith Whitwell
- */
-
-
-/**
- * \mainpage The TNL splitter
- *
- * This is the private data used internally to the _tnl_split_prims()
- * helper function. Nobody outside the _tnl_split* files needs to
- * include or know about this structure.
- */
-
-
-#ifndef _TNL_SPLIT_H
-#define _TNL_SPLIT_H
-
-#include "tnl.h"
-
-
-/* True if a primitive can be split without copying of vertices, false
- * otherwise.
- */
-GLboolean
-_tnl_split_prim_inplace(GLenum mode, GLuint *first, GLuint *incr);
-
-void
-_tnl_split_inplace(struct gl_context *ctx,
- const struct tnl_vertex_array arrays[],
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint num_instances,
- GLuint base_instance,
- tnl_draw_func draw,
- const struct split_limits *limits);
-
-/* Requires ib != NULL:
- */
-void
-_tnl_split_copy(struct gl_context *ctx,
- const struct tnl_vertex_array arrays[],
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- tnl_draw_func draw,
- const struct split_limits *limits);
-
-#endif
diff --git a/src/mesa/tnl/t_split_copy.c b/src/mesa/tnl/t_split_copy.c
deleted file mode 100644
index cee50fc9605..00000000000
--- a/src/mesa/tnl/t_split_copy.c
+++ /dev/null
@@ -1,637 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-/* Split indexed primitives with per-vertex copying.
- */
-
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/bufferobj.h"
-
-#include "main/glformats.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-#include "main/varray.h"
-#include "vbo/vbo.h"
-
-#include "t_split.h"
-#include "tnl.h"
-
-
-#define ELT_TABLE_SIZE 16
-
-/**
- * Used for vertex-level splitting of indexed buffers. Note that
- * non-indexed primitives may be converted to indexed in some cases
- * (eg loops, fans) in order to use this splitting path.
- */
-struct copy_context {
- struct gl_context *ctx;
- const struct tnl_vertex_array *array;
- const struct _mesa_prim *prim;
- GLuint nr_prims;
- const struct _mesa_index_buffer *ib;
- tnl_draw_func draw;
-
- const struct split_limits *limits;
-
- struct {
- GLuint attr;
- GLuint size;
- const struct tnl_vertex_array *array;
- const GLubyte *src_ptr;
-
- struct gl_vertex_buffer_binding dstbinding;
- struct gl_array_attributes dstattribs;
-
- } varying[VERT_ATTRIB_MAX];
- GLuint nr_varying;
-
- struct tnl_vertex_array dstarray[VERT_ATTRIB_MAX];
- struct _mesa_index_buffer dstib;
-
- GLuint *translated_elt_buf;
- const GLuint *srcelt;
-
- /** A baby hash table to avoid re-emitting (some) duplicate
- * vertices when splitting indexed primitives.
- */
- struct {
- GLuint in;
- GLuint out;
- } vert_cache[ELT_TABLE_SIZE];
-
- GLuint vertex_size;
- GLubyte *dstbuf;
- GLubyte *dstptr; /**< dstptr == dstbuf + dstelt_max * vertsize */
- GLuint dstbuf_size; /**< in vertices */
- GLuint dstbuf_nr; /**< count of emitted vertices, also the largest value
- * in dstelt. Our MaxIndex.
- */
-
- GLuint *dstelt;
- GLuint dstelt_nr;
- GLuint dstelt_size;
-
-#define MAX_PRIM 32
- struct _mesa_prim dstprim[MAX_PRIM];
- GLuint dstprim_nr;
-};
-
-
-/**
- * Shallow copy one vertex array to another.
- */
-static inline void
-copy_vertex_array(struct tnl_vertex_array *dst,
- const struct tnl_vertex_array *src)
-{
- dst->VertexAttrib = src->VertexAttrib;
- dst->BufferBinding = src->BufferBinding;
-}
-
-
-/**
- * Starts returning true slightly before the buffer fills, to ensure
- * that there is sufficient room for any remaining vertices to finish
- * off the prim:
- */
-static GLboolean
-check_flush(struct copy_context *copy)
-{
- GLenum mode = copy->dstprim[copy->dstprim_nr].mode;
-
- if (GL_TRIANGLE_STRIP == mode &&
- copy->dstelt_nr & 1) { /* see bug9962 */
- return GL_FALSE;
- }
-
- if (copy->dstbuf_nr + 4 > copy->dstbuf_size)
- return GL_TRUE;
-
- if (copy->dstelt_nr + 4 > copy->dstelt_size)
- return GL_TRUE;
-
- return GL_FALSE;
-}
-
-
-/**
- * Dump the parameters/info for a vbo->draw() call.
- */
-static void
-dump_draw_info(const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prims,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib)
-{
- GLuint i, j;
-
- printf("VBO Draw:\n");
- for (i = 0; i < nr_prims; i++) {
- printf("Prim %u of %u\n", i, nr_prims);
- printf(" Prim mode 0x%x\n", prims[i].mode);
- printf(" IB: %p\n", (void*) ib);
- for (j = 0; j < VERT_ATTRIB_MAX; j++) {
- const struct tnl_vertex_array *array = &arrays[j];
- const struct gl_vertex_buffer_binding *binding
- = array->BufferBinding;
- const struct gl_array_attributes *attrib = array->VertexAttrib;
- const GLubyte *ptr = _mesa_vertex_attrib_address(attrib, binding);
- printf(" array %d at %p:\n", j, (void*) &arrays[j]);
- printf(" ptr %p, size %d, type 0x%x, stride %d\n",
- ptr, attrib->Format.Size, attrib->Format.Type, binding->Stride);
- if (0) {
- GLint k = prims[i].start + prims[i].count - 1;
- GLfloat *last = (GLfloat *) (ptr + binding->Stride * k);
- printf(" last: %f %f %f\n",
- last[0], last[1], last[2]);
- }
- }
- }
-}
-
-
-static void
-flush(struct copy_context *copy)
-{
- struct gl_context *ctx = copy->ctx;
- GLuint i;
-
- /* Set some counters:
- */
- copy->dstib.count = copy->dstelt_nr;
-
-#if 0
- dump_draw_info(copy->dstarray,
- copy->dstprim,
- copy->dstprim_nr,
- &copy->dstib);
-#else
- (void) dump_draw_info;
-#endif
-
- copy->draw(ctx,
- copy->dstarray,
- copy->dstprim,
- copy->dstprim_nr,
- &copy->dstib,
- GL_TRUE,
- 0,
- copy->dstbuf_nr - 1,
- 1,
- 0);
-
- /* Reset all pointers:
- */
- copy->dstprim_nr = 0;
- copy->dstelt_nr = 0;
- copy->dstbuf_nr = 0;
- copy->dstptr = copy->dstbuf;
-
- /* Clear the vertex cache:
- */
- for (i = 0; i < ELT_TABLE_SIZE; i++)
- copy->vert_cache[i].in = ~0;
-}
-
-
-/**
- * Called at begin of each primitive during replay.
- */
-static void
-begin(struct copy_context *copy, GLenum mode, GLboolean begin_flag)
-{
- struct _mesa_prim *prim = &copy->dstprim[copy->dstprim_nr];
-
- prim->mode = mode;
- prim->begin = begin_flag;
-}
-
-
-/**
- * Use a hashtable to attempt to identify recently-emitted vertices
- * and avoid re-emitting them.
- */
-static GLuint
-elt(struct copy_context *copy, GLuint elt_idx)
-{
- GLuint elt = copy->srcelt[elt_idx] + copy->prim->basevertex;
- GLuint slot = elt & (ELT_TABLE_SIZE-1);
-
- /* Look up the incoming element in the vertex cache. Re-emit if
- * necessary.
- */
- if (copy->vert_cache[slot].in != elt) {
- GLubyte *csr = copy->dstptr;
- GLuint i;
-
- for (i = 0; i < copy->nr_varying; i++) {
- const struct tnl_vertex_array *srcarray = copy->varying[i].array;
- const struct gl_vertex_buffer_binding* srcbinding
- = srcarray->BufferBinding;
- const GLubyte *srcptr
- = copy->varying[i].src_ptr + elt * srcbinding->Stride;
-
- memcpy(csr, srcptr, copy->varying[i].size);
- csr += copy->varying[i].size;
-
-#ifdef NAN_CHECK
- if (srcarray->Format.Type == GL_FLOAT) {
- GLuint k;
- GLfloat *f = (GLfloat *) srcptr;
- for (k = 0; k < srcarray->Size; k++) {
- assert(!util_is_inf_or_nan(f[k]));
- assert(f[k] <= 1.0e20 && f[k] >= -1.0e20);
- }
- }
-#endif
-
- if (0) {
- const GLuint *f = (const GLuint *)srcptr;
- GLuint j;
- printf(" varying %d: ", i);
- for (j = 0; j < copy->varying[i].size / 4; j++)
- printf("%x ", f[j]);
- printf("\n");
- }
- }
-
- copy->vert_cache[slot].in = elt;
- copy->vert_cache[slot].out = copy->dstbuf_nr++;
- copy->dstptr += copy->vertex_size;
-
- assert(csr == copy->dstptr);
- assert(copy->dstptr == (copy->dstbuf +
- copy->dstbuf_nr * copy->vertex_size));
- }
-
- copy->dstelt[copy->dstelt_nr++] = copy->vert_cache[slot].out;
- return check_flush(copy);
-}
-
-
-/**
- * Called at end of each primitive during replay.
- */
-static void
-end(struct copy_context *copy, GLboolean end_flag)
-{
- struct _mesa_prim *prim = &copy->dstprim[copy->dstprim_nr];
-
- prim->end = end_flag;
- prim->count = copy->dstelt_nr - prim->start;
-
- if (++copy->dstprim_nr == MAX_PRIM || check_flush(copy)) {
- flush(copy);
- }
-}
-
-
-static void
-replay_elts(struct copy_context *copy)
-{
- GLuint i, j, k;
- GLboolean split;
-
- for (i = 0; i < copy->nr_prims; i++) {
- const struct _mesa_prim *prim = &copy->prim[i];
- const GLuint start = prim->start;
- GLuint first, incr;
-
- switch (prim->mode) {
- case GL_LINE_LOOP:
- /* Convert to linestrip and emit the final vertex explicitly,
- * but only in the resultant strip that requires it.
- */
- j = 0;
- while (j != prim->count) {
- begin(copy, GL_LINE_STRIP, prim->begin && j == 0);
-
- for (split = GL_FALSE; j != prim->count && !split; j++)
- split = elt(copy, start + j);
-
- if (j == prim->count) {
- /* Done, emit final line. Split doesn't matter as
- * it is always raised a bit early so we can emit
- * the last verts if necessary!
- */
- if (prim->end)
- (void)elt(copy, start + 0);
-
- end(copy, prim->end);
- }
- else {
- /* Wrap
- */
- assert(split);
- end(copy, 0);
- j--;
- }
- }
- break;
-
- case GL_TRIANGLE_FAN:
- case GL_POLYGON:
- j = 2;
- while (j != prim->count) {
- begin(copy, prim->mode, prim->begin && j == 0);
-
- split = elt(copy, start+0);
- assert(!split);
-
- split = elt(copy, start+j-1);
- assert(!split);
-
- for (; j != prim->count && !split; j++)
- split = elt(copy, start+j);
-
- end(copy, prim->end && j == prim->count);
-
- if (j != prim->count) {
- /* Wrapped the primitive, need to repeat some vertices:
- */
- j -= 1;
- }
- }
- break;
-
- default:
- (void)_tnl_split_prim_inplace(prim->mode, &first, &incr);
-
- j = 0;
- while (j != prim->count) {
-
- begin(copy, prim->mode, prim->begin && j == 0);
-
- split = 0;
- for (k = 0; k < first; k++, j++)
- split |= elt(copy, start+j);
-
- assert(!split);
-
- for (; j != prim->count && !split;)
- for (k = 0; k < incr; k++, j++)
- split |= elt(copy, start+j);
-
- end(copy, prim->end && j == prim->count);
-
- if (j != prim->count) {
- /* Wrapped the primitive, need to repeat some vertices:
- */
- assert(j > first - incr);
- j -= (first - incr);
- }
- }
- break;
- }
- }
-
- if (copy->dstprim_nr)
- flush(copy);
-}
-
-
-static void
-replay_init(struct copy_context *copy)
-{
- struct gl_context *ctx = copy->ctx;
- GLuint i;
- GLuint offset;
- const GLvoid *srcptr;
-
- /* Make a list of varying attributes and their vbo's. Also
- * calculate vertex size.
- */
- copy->vertex_size = 0;
- for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- const struct tnl_vertex_array *array = &copy->array[i];
- const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
-
- if (binding->Stride == 0) {
- copy_vertex_array(&copy->dstarray[i], array);
- }
- else {
- const struct gl_array_attributes *attrib = array->VertexAttrib;
- struct gl_buffer_object *vbo = binding->BufferObj;
- const GLubyte *ptr = _mesa_vertex_attrib_address(attrib, binding);
- GLuint j = copy->nr_varying++;
-
- copy->varying[j].attr = i;
- copy->varying[j].array = &copy->array[i];
- copy->varying[j].size = attrib->Format._ElementSize;
- copy->vertex_size += attrib->Format._ElementSize;
-
- if (vbo) {
- if (!_mesa_bufferobj_mapped(vbo, MAP_INTERNAL)) {
- ctx->Driver.MapBufferRange(ctx, 0, vbo->Size, GL_MAP_READ_BIT, vbo,
- MAP_INTERNAL);
- }
-
- copy->varying[j].src_ptr =
- ADD_POINTERS(vbo->Mappings[MAP_INTERNAL].Pointer, ptr);
- } else {
- copy->varying[j].src_ptr = ptr;
- }
-
- copy->dstarray[i].VertexAttrib = &copy->varying[j].dstattribs;
- copy->dstarray[i].BufferBinding = &copy->varying[j].dstbinding;
- }
- }
-
- /* There must always be an index buffer. Currently require the
- * caller convert non-indexed prims to indexed. Could alternately
- * do it internally.
- */
- if (copy->ib->obj) {
- if (!_mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL))
- ctx->Driver.MapBufferRange(ctx, 0, copy->ib->obj->Size, GL_MAP_READ_BIT,
- copy->ib->obj, MAP_INTERNAL);
-
- srcptr = (const GLubyte *)
- ADD_POINTERS(copy->ib->obj->Mappings[MAP_INTERNAL].Pointer,
- copy->ib->ptr);
- } else
- srcptr = copy->ib->ptr;
-
- switch (copy->ib->index_size_shift) {
- case 0:
- copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count);
- copy->srcelt = copy->translated_elt_buf;
-
- for (i = 0; i < copy->ib->count; i++)
- copy->translated_elt_buf[i] = ((const GLubyte *)srcptr)[i];
- break;
-
- case 1:
- copy->translated_elt_buf = malloc(sizeof(GLuint) * copy->ib->count);
- copy->srcelt = copy->translated_elt_buf;
-
- for (i = 0; i < copy->ib->count; i++)
- copy->translated_elt_buf[i] = ((const GLushort *)srcptr)[i];
- break;
-
- case 2:
- copy->translated_elt_buf = NULL;
- copy->srcelt = (const GLuint *)srcptr;
- break;
- }
-
- /* Figure out the maximum allowed vertex buffer size:
- */
- if (copy->vertex_size * copy->limits->max_verts <= copy->limits->max_vb_size) {
- copy->dstbuf_size = copy->limits->max_verts;
- }
- else {
- copy->dstbuf_size = copy->limits->max_vb_size / copy->vertex_size;
- }
-
- /* Allocate an output vertex buffer:
- *
- * XXX: This should be a VBO!
- */
- copy->dstbuf = malloc(copy->dstbuf_size * copy->vertex_size);
- copy->dstptr = copy->dstbuf;
-
- /* Setup new vertex arrays to point into the output buffer:
- */
- for (offset = 0, i = 0; i < copy->nr_varying; i++) {
- const struct tnl_vertex_array *src = copy->varying[i].array;
- const struct gl_array_attributes *srcattr = src->VertexAttrib;
- struct tnl_vertex_array *dst = &copy->dstarray[copy->varying[i].attr];
- struct gl_vertex_buffer_binding *dstbind = &copy->varying[i].dstbinding;
- struct gl_array_attributes *dstattr = &copy->varying[i].dstattribs;
-
- dstattr->Format = srcattr->Format;
- dstattr->Ptr = copy->dstbuf + offset;
- dstbind->Stride = copy->vertex_size;
- dstbind->BufferObj = NULL;
- dst->BufferBinding = dstbind;
- dst->VertexAttrib = dstattr;
-
- offset += copy->varying[i].size;
- }
-
- /* Allocate an output element list:
- */
- copy->dstelt_size = MIN2(65536, copy->ib->count * 2 + 3);
- copy->dstelt_size = MIN2(copy->dstelt_size, copy->limits->max_indices);
- copy->dstelt = malloc(sizeof(GLuint) * copy->dstelt_size);
- copy->dstelt_nr = 0;
-
- /* Setup the new index buffer to point to the allocated element
- * list:
- */
- copy->dstib.count = 0; /* duplicates dstelt_nr */
- copy->dstib.index_size_shift = 2;
- copy->dstib.obj = NULL;
- copy->dstib.ptr = copy->dstelt;
-}
-
-
-/**
- * Free up everything allocated during split/replay.
- */
-static void
-replay_finish(struct copy_context *copy)
-{
- struct gl_context *ctx = copy->ctx;
- GLuint i;
-
- /* Free our vertex and index buffers */
- free(copy->translated_elt_buf);
- free(copy->dstbuf);
- free(copy->dstelt);
-
- /* Unmap VBO's */
- for (i = 0; i < copy->nr_varying; i++) {
- struct gl_buffer_object *vbo =
- copy->varying[i].array->BufferBinding->BufferObj;
- if (vbo && _mesa_bufferobj_mapped(vbo, MAP_INTERNAL))
- ctx->Driver.UnmapBuffer(ctx, vbo, MAP_INTERNAL);
- }
-
- /* Unmap index buffer */
- if (copy->ib->obj &&
- _mesa_bufferobj_mapped(copy->ib->obj, MAP_INTERNAL)) {
- ctx->Driver.UnmapBuffer(ctx, copy->ib->obj, MAP_INTERNAL);
- }
-}
-
-
-/**
- * Split VBO into smaller pieces, draw the pieces.
- */
-void
-_tnl_split_copy(struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- tnl_draw_func draw,
- const struct split_limits *limits)
-{
- struct copy_context copy;
- GLuint i, this_nr_prims;
-
- for (i = 0; i < nr_prims;) {
- /* Our SW TNL pipeline doesn't handle basevertex yet, so bind_indices
- * will rebase the elements to the basevertex, and we'll only
- * emit strings of prims with the same basevertex in one draw call.
- */
- for (this_nr_prims = 1; i + this_nr_prims < nr_prims;
- this_nr_prims++) {
- if (prim[i].basevertex != prim[i + this_nr_prims].basevertex)
- break;
- }
-
- memset(&copy, 0, sizeof(copy));
-
- /* Require indexed primitives:
- */
- assert(ib);
-
- copy.ctx = ctx;
- copy.array = arrays;
- copy.prim = &prim[i];
- copy.nr_prims = this_nr_prims;
- copy.ib = ib;
- copy.draw = draw;
- copy.limits = limits;
-
- /* Clear the vertex cache:
- */
- for (i = 0; i < ELT_TABLE_SIZE; i++)
- copy.vert_cache[i].in = ~0;
-
- replay_init(&copy);
- replay_elts(&copy);
- replay_finish(&copy);
- }
-}
diff --git a/src/mesa/tnl/t_split_inplace.c b/src/mesa/tnl/t_split_inplace.c
deleted file mode 100644
index 126f6fddfdf..00000000000
--- a/src/mesa/tnl/t_split_inplace.c
+++ /dev/null
@@ -1,296 +0,0 @@
-
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#include "main/mtypes.h"
-#include "main/macros.h"
-#include "main/enums.h"
-#include "vbo/vbo.h"
-
-#include "t_split.h"
-
-
-#define MAX_PRIM 32
-
-/* Used for splitting without copying. No attempt is made to handle
- * too large indexed vertex buffers: In general you need to copy to do
- * that.
- */
-struct split_context {
- struct gl_context *ctx;
- const struct tnl_vertex_array *array;
- const struct _mesa_prim *prim;
- GLuint nr_prims;
- const struct _mesa_index_buffer *ib;
- GLuint min_index;
- GLuint max_index;
- GLuint num_instances;
- GLuint base_instance;
- tnl_draw_func draw;
-
- const struct split_limits *limits;
- GLuint limit;
-
- struct _mesa_prim dstprim[MAX_PRIM];
- GLuint dstprim_nr;
-};
-
-
-
-
-static void
-flush_vertex( struct split_context *split)
-{
- struct gl_context *ctx = split->ctx;
- struct _mesa_index_buffer ib;
- GLuint i;
-
- if (!split->dstprim_nr)
- return;
-
- if (split->ib) {
- ib = *split->ib;
-
- ib.count = split->max_index - split->min_index + 1;
- ib.ptr = (const void *)((const char *)ib.ptr +
- (split->min_index << ib.index_size_shift));
-
- /* Rebase the primitives to save index buffer entries. */
- for (i = 0; i < split->dstprim_nr; i++)
- split->dstprim[i].start -= split->min_index;
- }
-
- assert(split->max_index >= split->min_index);
-
- split->draw(ctx,
- split->array,
- split->dstprim,
- split->dstprim_nr,
- split->ib ? &ib : NULL,
- !split->ib,
- split->min_index,
- split->max_index,
- split->num_instances,
- split->base_instance);
-
- split->dstprim_nr = 0;
- split->min_index = ~0;
- split->max_index = 0;
-}
-
-
-static struct _mesa_prim *
-next_outprim(struct split_context *split)
-{
- if (split->dstprim_nr == MAX_PRIM-1) {
- flush_vertex(split);
- }
-
- {
- struct _mesa_prim *prim = &split->dstprim[split->dstprim_nr++];
- memset(prim, 0, sizeof(*prim));
- return prim;
- }
-}
-
-
-static void
-update_index_bounds(struct split_context *split,
- const struct _mesa_prim *prim)
-{
- split->min_index = MIN2(split->min_index, prim->start);
- split->max_index = MAX2(split->max_index, prim->start + prim->count - 1);
-}
-
-
-/* Return the maximum amount of vertices that can be emitted for a
- * primitive starting at 'prim->start', depending on the previous
- * index bounds.
- */
-static GLuint
-get_max_vertices(struct split_context *split,
- const struct _mesa_prim *prim)
-{
- if ((prim->start > split->min_index &&
- prim->start - split->min_index >= split->limit) ||
- (prim->start < split->max_index &&
- split->max_index - prim->start >= split->limit))
- /* "prim" starts too far away from the old range. */
- return 0;
-
- return MIN2(split->min_index, prim->start) + split->limit - prim->start;
-}
-
-
-/* Break large primitives into smaller ones. If not possible, convert
- * the primitive to indexed and pass to split_elts().
- */
-static void
-split_prims(struct split_context *split)
-{
- GLuint i;
-
- for (i = 0; i < split->nr_prims; i++) {
- const struct _mesa_prim *prim = &split->prim[i];
- GLuint first, incr;
- GLboolean split_inplace =
- _tnl_split_prim_inplace(prim->mode, &first, &incr);
- GLuint available = get_max_vertices(split, prim);
- GLuint count = prim->count - (prim->count - first) % incr;
-
- if (prim->count < first)
- continue;
-
- if ((available < count && !split_inplace) ||
- (available < first && split_inplace)) {
- flush_vertex(split);
- available = get_max_vertices(split, prim);
- }
-
- if (available >= count) {
- struct _mesa_prim *outprim = next_outprim(split);
-
- *outprim = *prim;
- update_index_bounds(split, outprim);
- }
- else if (split_inplace) {
- GLuint j, nr;
-
- for (j = 0 ; j < count ;) {
- GLuint remaining = count - j;
- struct _mesa_prim *outprim = next_outprim(split);
-
- nr = MIN2(available, remaining);
- nr -= (nr - first) % incr;
-
- outprim->mode = prim->mode;
- outprim->begin = (j == 0 && prim->begin);
- outprim->end = (nr == remaining && prim->end);
- outprim->start = prim->start + j;
- outprim->count = nr;
-
- update_index_bounds(split, outprim);
-
- if (nr == remaining) {
- /* Finished */
- j += nr;
- }
- else {
- /* Wrapped the primitive */
- j += nr - (first - incr);
- flush_vertex(split);
- available = get_max_vertices(split, prim);
- }
- }
- }
- else if (split->ib == NULL) {
- /* XXX: could at least send the first max_verts off from the
- * inplace buffers.
- */
-
- /* else convert to indexed primitive and pass to split_elts,
- * which will do the necessary copying and turn it back into a
- * vertex primitive for rendering...
- */
- struct _mesa_index_buffer ib;
- struct _mesa_prim tmpprim;
- GLuint *elts = malloc(count * sizeof(GLuint));
- GLuint j;
-
- for (j = 0; j < count; j++)
- elts[j] = prim->start + j;
-
- ib.count = count;
- ib.index_size_shift = 2;
- ib.obj = NULL;
- ib.ptr = elts;
-
- tmpprim = *prim;
- tmpprim.start = 0;
- tmpprim.count = count;
-
- flush_vertex(split);
-
- _tnl_split_copy(split->ctx,
- split->array,
- &tmpprim, 1,
- &ib,
- split->draw,
- split->limits);
-
- free(elts);
- }
- else {
- flush_vertex(split);
-
- _tnl_split_copy(split->ctx,
- split->array,
- prim, 1,
- split->ib,
- split->draw,
- split->limits);
- }
- }
-
- flush_vertex(split);
-}
-
-
-void
-_tnl_split_inplace(struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint num_instances,
- GLuint base_instance,
- tnl_draw_func draw,
- const struct split_limits *limits)
-{
- struct split_context split;
-
- memset(&split, 0, sizeof(split));
-
- split.ctx = ctx;
- split.array = arrays;
- split.prim = prim;
- split.nr_prims = nr_prims;
- split.ib = ib;
-
- /* Empty interval, makes calculations simpler. */
- split.min_index = ~0;
- split.max_index = 0;
- split.num_instances = num_instances;
- split.base_instance = base_instance;
-
- split.draw = draw;
- split.limits = limits;
- split.limit = ib ? limits->max_indices : limits->max_verts;
-
- split_prims(&split);
-}
diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h
deleted file mode 100644
index 9f2d5161d99..00000000000
--- a/src/mesa/tnl/t_vb_cliptmp.h
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#define CLIP_DOTPROD(K, A, B, C, D) X(K)*A + Y(K)*B + Z(K)*C + W(K)*D
-
-#define POLY_CLIP( PLANE_BIT, A, B, C, D ) \
-do { \
- if (mask & PLANE_BIT) { \
- 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 ); \
- \
- if (dpPrev >= 0.0f) { \
- outlist[outcount++] = idxPrev; \
- } \
- \
- if (DIFFERENT_SIGNS(dp, dpPrev)) { \
- if (dp < 0.0f) { \
- /* 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 ); \
- } \
- outlist[outcount++] = newvert++; \
- } \
- \
- idxPrev = idx; \
- dpPrev = dp; \
- } \
- \
- if (outcount < 3) \
- return; \
- \
- { \
- GLuint *tmp = inlist; \
- inlist = outlist; \
- outlist = tmp; \
- n = outcount; \
- } \
- } \
-} while (0)
-
-
-#define LINE_CLIP(PLANE_BIT, A, B, C, D ) \
-do { \
- if (mask & PLANE_BIT) { \
- const GLfloat dp0 = CLIP_DOTPROD( v0, A, B, C, D ); \
- const GLfloat dp1 = CLIP_DOTPROD( v1, A, B, C, D ); \
- const GLboolean neg_dp0 = dp0 < 0.0f; \
- const GLboolean neg_dp1 = dp1 < 0.0f; \
- \
- /* For regular clipping, we know from the clipmask that one \
- * (or both) of these must be negative (otherwise we wouldn't \
- * be here). \
- * For userclip, there is only a single bit for all active \
- * planes, so we can end up here when there is nothing to do, \
- * hence the second < 0.0f test: \
- */ \
- if (neg_dp0 && neg_dp1) \
- return; /* both vertices outside clip plane: discard */ \
- \
- if (neg_dp1) { \
- GLfloat t = dp1 / (dp1 - dp0); \
- if (t > t1) t1 = t; \
- } else if (neg_dp0) { \
- GLfloat t = dp0 / (dp0 - dp1); \
- if (t > t0) t0 = t; \
- } \
- if (t0 + t1 >= 1.0) \
- return; /* discard */ \
- } \
-} while (0)
-
-
-
-/* Clip a line against the viewport and user clip planes.
- */
-static inline void
-TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, 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 newvert = VB->Count;
- GLfloat t0 = 0;
- GLfloat t1 = 0;
- const GLuint v0_orig = v0;
-
- if (mask & CLIP_FRUSTUM_BITS) {
- 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) {
- GLbitfield enabled = ctx->Transform.ClipPlanesEnabled;
- while (enabled) {
- const int p = u_bit_scan(&enabled);
- 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 (VB->ClipMask[v0]) {
- INTERP_4F( t0, coord[newvert], coord[v0], coord[v1] );
- interp( ctx, t0, newvert, v0, v1, GL_FALSE );
- v0 = newvert;
- newvert++;
- }
- else {
- assert(t0 == 0.0);
- }
-
- /* Note: we need to use vertex v0_orig when computing the new
- * interpolated/clipped vertex position, not the current v0 which
- * may have got set when we clipped the other end of the line!
- */
- if (VB->ClipMask[v1]) {
- INTERP_4F( t1, coord[newvert], coord[v1], coord[v0_orig] );
- interp( ctx, t1, newvert, v1, v0_orig, GL_FALSE );
-
- if (ctx->Light.ShadeModel == GL_FLAT)
- tnl->Driver.Render.CopyPV( ctx, newvert, v1 );
-
- v1 = newvert;
-
- newvert++;
- }
- else {
- assert(t1 == 0.0);
- }
-
- tnl->Driver.Render.ClippedLine( ctx, v0, v1 );
-}
-
-
-/* Clip a triangle against the viewport and user clip planes.
- */
-static inline void
-TAG(clip_tri)( struct gl_context *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;
- GLuint newvert = VB->Count;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint pv = v2;
- GLuint vlist[2][MAX_CLIPPED_VERTICES];
- GLuint *inlist = vlist[0], *outlist = vlist[1];
- GLuint n = 3;
-
- ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
-
- if (0) {
- /* print pre-clip vertex coords */
- GLuint i, j;
- printf("pre clip:\n");
- for (i = 0; i < n; i++) {
- j = inlist[i];
- printf(" %u: %u: %f, %f, %f, %f\n",
- i, j,
- coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
- assert(!util_is_inf_or_nan(coord[j][0]));
- assert(!util_is_inf_or_nan(coord[j][1]));
- assert(!util_is_inf_or_nan(coord[j][2]));
- assert(!util_is_inf_or_nan(coord[j][3]));
- }
- }
-
-
- if (mask & CLIP_FRUSTUM_BITS) {
- 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) {
- GLbitfield enabled = ctx->Transform.ClipPlanesEnabled;
- while (enabled) {
- const int p = u_bit_scan(&enabled);
- 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->Light.ShadeModel == GL_FLAT) {
- if (pv != inlist[0]) {
- assert( inlist[0] >= VB->Count );
- tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
- }
- }
-
- if (0) {
- /* print post-clip vertex coords */
- GLuint i, j;
- printf("post clip:\n");
- for (i = 0; i < n; i++) {
- j = inlist[i];
- printf(" %u: %u: %f, %f, %f, %f\n",
- i, j,
- coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
- }
- }
-
- tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
-}
-
-
-/* Clip a quad against the viewport and user clip planes.
- */
-static inline void
-TAG(clip_quad)( struct gl_context *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;
- GLuint newvert = VB->Count;
- GLfloat (*coord)[4] = VB->ClipPtr->data;
- GLuint pv = v3;
- GLuint vlist[2][MAX_CLIPPED_VERTICES];
- GLuint *inlist = vlist[0], *outlist = vlist[1];
- GLuint n = 4;
-
- ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */
-
- if (mask & CLIP_FRUSTUM_BITS) {
- 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) {
- GLbitfield enabled = ctx->Transform.ClipPlanesEnabled;
- while (enabled) {
- const int p = u_bit_scan(&enabled);
- 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->Light.ShadeModel == GL_FLAT) {
- 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/src/mesa/tnl/t_vb_fog.c b/src/mesa/tnl/t_vb_fog.c
deleted file mode 100644
index 6c95006f551..00000000000
--- a/src/mesa/tnl/t_vb_fog.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#include "c99_math.h"
-#include "main/errors.h"
-#include "main/glheader.h"
-#include "main/macros.h"
-
-#include "main/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 */
-};
-
-#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr)
-
-#define FOG_EXP_TABLE_SIZE 256
-#define FOG_MAX (10.0F)
-#define EXP_FOG_MAX .0006595F
-#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.0F / 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 that fogcoords may be negative, if eye z is source absolute
- * value must be taken earlier.
- * Fog blend factors are in the range [0,1].
- */
-static void
-compute_fog_blend_factors(struct gl_context *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 = *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 = *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 = *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(struct gl_context *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)
- return GL_TRUE;
-
- if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT && !ctx->VertexProgram._Current) {
- GLuint i;
- GLfloat *coord;
- /* Fog is computed from vertex or fragment Z values */
- /* source = VB->AttribPtr[_TNL_ATTRIB_POS] or VB->EyePtr coords */
- /* dest = VB->AttribPtr[_TNL_ATTRIB_FOG] = fog stage private storage */
- VB->AttribPtr[_TNL_ATTRIB_FOG] = &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;
-
- 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->AttribPtr[_TNL_ATTRIB_POS]->size]
- ( (GLfloat *) input->data,
- 4 * sizeof(GLfloat),
- VB->AttribPtr[_TNL_ATTRIB_POS], plane );
-
- input->count = VB->AttribPtr[_TNL_ATTRIB_POS]->count;
-
- /* make sure coords are really positive
- NOTE should avoid going through array twice */
- coord = input->start;
- for (i = 0; i < input->count; i++) {
- *coord = fabsf(*coord);
- STRIDE_F(coord, input->stride);
- }
- }
- else {
- /* fog coordinates = eye Z coordinates - need to copy for ABS */
- input = &store->fogcoord;
-
- if (VB->EyePtr->size < 2)
- _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 );
-
- input->stride = 4 * sizeof(GLfloat);
- input->count = VB->EyePtr->count;
- coord = VB->EyePtr->start;
- for (i = 0 ; i < VB->EyePtr->count; i++) {
- input->data[i][0] = fabsf(coord[2]);
- STRIDE_F(coord, VB->EyePtr->stride);
- }
- }
- }
- else {
- /* use glFogCoord() coordinates */
- input = VB->AttribPtr[_TNL_ATTRIB_FOG]; /* 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->AttribPtr[_TNL_ATTRIB_POS]->count;
-
- VB->AttribPtr[_TNL_ATTRIB_FOG] = &store->fogcoord; /* dest data */
- }
-
- if (tnl->_DoVertexFog) {
- /* compute blend factors from fog coordinates */
- compute_fog_blend_factors( ctx, VB->AttribPtr[_TNL_ATTRIB_FOG], input );
- }
- else {
- /* results = incoming fog coords (compute fog per-fragment later) */
- VB->AttribPtr[_TNL_ATTRIB_FOG] = input;
- }
-
- return GL_TRUE;
-}
-
-
-
-/* Called the first time stage->run() is invoked.
- */
-static GLboolean
-alloc_fog_data(struct gl_context *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 );
-
- 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/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
deleted file mode 100644
index 15c8b0ebccf..00000000000
--- a/src/mesa/tnl/t_vb_light.c
+++ /dev/null
@@ -1,477 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-#include "c99_math.h"
-#include "main/glheader.h"
-#include "main/light.h"
-#include "main/macros.h"
-
-#include "util/simple_list.h"
-#include "main/mtypes.h"
-
-#include "math/m_translate.h"
-
-#include "util/bitscan.h"
-
-#include "t_context.h"
-#include "t_pipeline.h"
-#include "tnl.h"
-
-#define LIGHT_TWOSIDE 0x1
-#define LIGHT_MATERIAL 0x2
-#define MAX_LIGHT_FUNC 0x4
-
-typedef void (*light_func)( struct gl_context *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];
- 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))
-
-
-
-/**********************************************************************/
-/***** Lighting computation *****/
-/**********************************************************************/
-
-
-/*
- * Notes:
- * When two-sided lighting is enabled we compute the color (or index)
- * for both the front and back side of the primitive. Then, when the
- * orientation of the facet is later learned, we can determine which
- * color (or index) to use for rendering.
- *
- * KW: We now know orientation in advance and only shade for
- * the side or sides which are actually required.
- *
- * Variables:
- * n = normal vector
- * V = vertex position
- * P = light source position
- * Pe = (0,0,0,1)
- *
- * Precomputed:
- * IF P[3]==0 THEN
- * // light at infinity
- * IF local_viewer THEN
- * _VP_inf_norm = unit vector from V to P // Precompute
- * ELSE
- * // eye at infinity
- * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
- * ENDIF
- * ENDIF
- *
- * Functions:
- * Normalize( v ) = normalized vector v
- * Magnitude( v ) = length of vector v
- */
-
-
-
-static void
-validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct tnl_shine_tab *list = tnl->_ShineTabList;
- struct tnl_shine_tab *s;
-
- assert(side < 2);
-
- foreach(s, list)
- if ( s->shininess == shininess )
- break;
-
- if (s == list) {
- GLint j;
- GLfloat *m;
-
- foreach(s, list)
- if (s->refcount == 0)
- break;
-
- m = s->tab;
- m[0] = 0.0F;
- if (shininess == 0.0F) {
- for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++)
- m[j] = 1.0F;
- }
- else {
- for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) {
- GLfloat t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1);
- if (x < 0.005F) /* underflow check */
- x = 0.005F;
- t = powf(x, shininess);
- if (t > 1e-20F)
- m[j] = t;
- else
- m[j] = 0.0F;
- }
- m[SHINE_TABLE_SIZE] = 1.0F;
- }
-
- s->shininess = shininess;
- }
-
- if (tnl->_ShineTable[side])
- tnl->_ShineTable[side]->refcount--;
-
- tnl->_ShineTable[side] = s;
- move_to_tail( list, s );
- s->refcount++;
-}
-
-
-void
-_tnl_validate_shine_tables( struct gl_context *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLfloat shininess;
-
- shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0];
- if (!tnl->_ShineTable[0] || tnl->_ShineTable[0]->shininess != shininess)
- validate_shine_table( ctx, 0, shininess );
-
- shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0];
- if (!tnl->_ShineTable[1] || tnl->_ShineTable[1]->shininess != shininess)
- validate_shine_table( ctx, 1, shininess );
-}
-
-
-/**
- * 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(struct gl_context *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.
- */
- _tnl_validate_shine_tables( ctx );
-}
-
-
-/**
- * Prepare things prior to running the lighting stage.
- * Return number of material attributes which will track vertex color.
- */
-static GLuint
-prepare_materials(struct gl_context *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) {
- GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
- while (bitmask) {
- const int i = u_bit_scan(&bitmask);
- VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] =
- VB->AttribPtr[_TNL_ATTRIB_COLOR0];
- }
- }
-
- /* 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_FIRST_MAT; i <= _TNL_LAST_MAT; 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 );
-
- _tnl_validate_shine_tables( ctx );
-
- return store->mat_count;
-}
-
-/*
- * Compute dp ^ SpecularExponent.
- * Lerp between adjacent values in the f(x) lookup table, giving a
- * continuous function, with adequate overall accuracy. (Though still
- * pretty good compared to a straight lookup).
- */
-static inline GLfloat
-lookup_shininess(const struct gl_context *ctx, GLuint face, GLfloat dp)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- const struct tnl_shine_tab *tab = tnl->_ShineTable[face];
- float f = dp * (SHINE_TABLE_SIZE - 1);
- int k = (int) f;
- if (k < 0 /* gcc may cast an overflow float value to negative int value */
- || k > SHINE_TABLE_SIZE - 2)
- return powf(dp, tab->shininess);
- else
- return tab->tab[k] + (f - k) * (tab->tab[k+1] - tab->tab[k]);
-}
-
-/* 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];
-
-#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( struct gl_context *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->AttribPtr[_TNL_ATTRIB_POS];
- GLuint idx;
-
- if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
- return GL_TRUE;
-
- /* Make sure we can talk about position x,y and z:
- */
- if (input->size <= 2 && input == VB->AttribPtr[_TNL_ATTRIB_POS]) {
-
- _math_trans_4f( store->Input.data,
- VB->AttribPtr[_TNL_ATTRIB_POS]->data,
- VB->AttribPtr[_TNL_ATTRIB_POS]->stride,
- GL_FLOAT,
- VB->AttribPtr[_TNL_ATTRIB_POS]->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 );
-
- return GL_TRUE;
-}
-
-
-/* Called in place of do_lighting when the light table may have changed.
- */
-static void validate_lighting( struct gl_context *ctx,
- struct tnl_pipeline_stage *stage )
-{
- light_func *tab;
-
- if (!ctx->Light.Enabled || ctx->VertexProgram._Current)
- return;
-
- if (ctx->Light._NeedVertices) {
- if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
- tab = _tnl_light_spec_tab;
- else
- tab = _tnl_light_tab;
- }
- else {
- /* Power of two means only a single active light. */
- if (util_is_power_of_two_or_zero(ctx->Light._EnabledLights))
- tab = _tnl_light_fast_single_tab;
- else
- tab = _tnl_light_fast_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( struct gl_context *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 );
-
- store->LitColor[0].size = 4;
- store->LitColor[1].size = 4;
- store->LitSecondary[0].size = 3;
- store->LitSecondary[1].size = 3;
-
- 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] );
- 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/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h
deleted file mode 100644
index 1d0ed8ffe9a..00000000000
--- a/src/mesa/tnl/t_vb_lighttmp.h
+++ /dev/null
@@ -1,641 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * 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
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- *
- * Authors:
- * Brian Paul Keith Whitwell <keithw@vmware.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)( struct gl_context *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->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
- const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->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", __func__ );
-#endif
-
- VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
- VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &store->LitSecondary[0];
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-
-#if IDX & LIGHT_TWOSIDE
- VB->BackfaceColorPtr = &store->LitColor[1];
- VB->BackfaceSecondaryColorPtr = &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];
- GLbitfield mask;
-
-#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 */
- mask = ctx->Light._EnabledLights;
- while (mask) {
- const int l = u_bit_scan(&mask);
- struct gl_light *light = &ctx->Light.Light[l];
- struct gl_light_uniforms *lu = &ctx->Light.LightSource[l];
- 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-6F) {
- GLfloat invd = 1.0F / d;
- SELF_SCALE_SCALAR_3V(VP, invd);
- }
-
- attenuation = 1.0F / (lu->ConstantAttenuation + d *
- (lu->LinearAttenuation + d *
- lu->QuadraticAttenuation));
-
- /* spotlight attenuation */
- if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
-
- if (PV_dot_dir<lu->_CosCutoff) {
- continue; /* this light makes no contribution */
- }
- else {
- GLfloat spot = powf(PV_dot_dir, lu->SpotExponent);
- attenuation *= spot;
- }
- }
- }
-
- if (attenuation < 1e-3F)
- 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 = lookup_shininess(ctx, side, n_dot_h);
- if (spec_coef > 1.0e-10F) {
- 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)( struct gl_context *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->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
- const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->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", __func__ );
-#endif
-
- VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
- sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
-
-#if IDX & LIGHT_TWOSIDE
- VB->BackfaceColorPtr = &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];
- GLbitfield mask;
-
-#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 */
- mask = ctx->Light._EnabledLights;
- while (mask) {
- const int l = u_bit_scan(&mask);
- struct gl_light *light = &ctx->Light.Light[l];
- struct gl_light_uniforms *lu = &ctx->Light.LightSource[l];
- 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-6F) {
- GLfloat invd = 1.0F / d;
- SELF_SCALE_SCALAR_3V(VP, invd);
- }
-
- attenuation = 1.0F / (lu->ConstantAttenuation + d *
- (lu->LinearAttenuation + d *
- lu->QuadraticAttenuation));
-
- /* spotlight attenuation */
- if (light->_Flags & LIGHT_SPOT) {
- GLfloat PV_dot_dir = - DOT3(VP, light->_NormSpotDirection);
-
- if (PV_dot_dir<lu->_CosCutoff) {
- continue; /* this light makes no contribution */
- }
- else {
- GLfloat spot = powf(PV_dot_dir, lu->SpotExponent);
- attenuation *= spot;
- }
- }
- }
-
- if (attenuation < 1e-3F)
- 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 = lookup_shininess(ctx, side, n_dot_h);
- 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)( struct gl_context *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->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
- const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->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.Light[ffs(ctx->Light._EnabledLights) - 1];
- GLuint j = 0;
- GLfloat base[2][4];
-#if IDX & LIGHT_MATERIAL
- const GLuint nr = VB->Count;
-#else
- const GLuint nr = VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
-#endif
-
-#ifdef TRACE
- fprintf(stderr, "%s\n", __func__ );
-#endif
-
- (void) input; /* doesn't refer to Eye or Obj */
-
- VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
-#if IDX & LIGHT_TWOSIDE
- VB->BackfaceColorPtr = &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 = lookup_shininess(ctx, 1, n_dot_h);
- 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 = lookup_shininess(ctx, 0, n_dot_h);
- 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)( struct gl_context *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->AttribPtr[_TNL_ATTRIB_NORMAL]->stride;
- const GLfloat *normal = (GLfloat *)VB->AttribPtr[_TNL_ATTRIB_NORMAL]->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->AttribPtr[_TNL_ATTRIB_NORMAL]->count;
-#endif
-
-#ifdef TRACE
- fprintf(stderr, "%s %d\n", __func__, 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->AttribPtr[_TNL_ATTRIB_COLOR0] = &store->LitColor[0];
-#if IDX & LIGHT_TWOSIDE
- VB->BackfaceColorPtr = &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];
- GLbitfield mask;
-
-#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
-
- mask = ctx->Light._EnabledLights;
- while (mask) {
- const int l = u_bit_scan(&mask);
- const struct gl_light *light = &ctx->Light.Light[l];
- 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) {
- spec = lookup_shininess(ctx, 0, n_dot_h);
- 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) {
- spec = lookup_shininess(ctx, 1, n_dot_h);
- 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
- }
-}
-
-
-
-
-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);
-}
-
-
-#undef TAG
-#undef IDX
-#undef NR_SIDES
diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c
deleted file mode 100644
index ca753317d67..00000000000
--- a/src/mesa/tnl/t_vb_normals.c
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#include "main/glheader.h"
-#include "main/macros.h"
-
-#include "main/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(struct gl_context *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->AttribPtr[_TNL_ATTRIB_NORMAL], /* input normals */
- lengths,
- &store->normal ); /* resulting normals */
-
- if (VB->AttribPtr[_TNL_ATTRIB_NORMAL]->count > 1) {
- store->normal.stride = 4 * sizeof(GLfloat);
- }
- else {
- store->normal.stride = 0;
- }
-
- VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &store->normal;
-
- 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(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
-{
- struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
-
- if (ctx->VertexProgram._Current ||
- (!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.0F) {
- 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.0F) {
- 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(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct normal_stage_data *store;
-
- stage->privatePtr = 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 );
- 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/src/mesa/tnl/t_vb_points.c b/src/mesa/tnl/t_vb_points.c
deleted file mode 100644
index 4e7801b2d10..00000000000
--- a/src/mesa/tnl/t_vb_points.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Brian Paul
- */
-
-#include "c99_math.h"
-#include "main/glheader.h"
-#include "main/mtypes.h"
-#include "main/dd.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(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
-{
- if (ctx->Point._Attenuated && !ctx->VertexProgram._Current) {
- struct point_stage_data *store = POINT_STAGE_DATA(stage);
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- const GLfloat *eyeCoord = (GLfloat *) VB->EyePtr->data + 2;
- const GLint eyeCoordStride = VB->EyePtr->stride / sizeof(GLfloat);
- 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(*eyeCoord);
- const GLfloat q = p0 + dist * (p1 + dist * p2);
- const GLfloat atten = (q != 0.0F) ? (1.0f / sqrtf(q)) : 1.0F;
- size[i][0] = pointSize * atten; /* clamping done in rasterization */
- eyeCoord += eyeCoordStride;
- }
-
- VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->PointSize;
- }
-
- return GL_TRUE;
-}
-
-
-static GLboolean
-alloc_point_data(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct point_stage_data *store;
- stage->privatePtr = 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 );
- 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/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c
deleted file mode 100644
index 3b17ba90d93..00000000000
--- a/src/mesa/tnl/t_vb_program.c
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
- * Copyright (C) 2009 VMware, 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
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-
-/**
- * \file tnl/t_vb_program.c
- * \brief Pipeline stage for executing vertex programs.
- * \author Brian Paul, Keith Whitwell
- */
-
-
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/samplerobj.h"
-#include "main/state.h"
-#include "math/m_xform.h"
-#include "program/prog_instruction.h"
-#include "program/prog_statevars.h"
-#include "program/prog_execute.h"
-#include "swrast/s_context.h"
-#include "util/bitscan.h"
-#include "util/u_memory.h"
-
-#include "tnl/tnl.h"
-#include "tnl/t_context.h"
-#include "tnl/t_pipeline.h"
-
-
-#ifdef NAN_CHECK
-/** Check for NaNs and very large values */
-static inline void
-check_float(float x)
-{
- assert(!util_is_inf_or_nan(x));
- assert(1.0e-15 <= x && x <= 1.0e15);
-}
-#endif
-
-
-/*!
- * Private storage for the vertex program pipeline stage.
- */
-struct vp_stage_data {
- /** The results of running the vertex program go into these arrays. */
- GLvector4f results[VARYING_SLOT_MAX];
-
- GLvector4f ndcCoords; /**< normalized device coords */
- GLubyte *clipmask; /**< clip flags */
- GLubyte ormask, andmask; /**< for clipping */
-
- GLboolean vertex_textures;
-
- struct gl_program_machine machine;
-};
-
-
-#define VP_STAGE_DATA(stage) ((struct vp_stage_data *)(stage->privatePtr))
-
-
-static void
-userclip( struct gl_context *ctx,
- GLvector4f *clip,
- GLubyte *clipmask,
- GLubyte *clipormask,
- GLubyte *clipandmask )
-{
- GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
- while (mask) {
- const int p = u_bit_scan(&mask);
- 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 gl_context *ctx, struct vp_stage_data *store)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- /* Cliptest and perspective divide. Clip functions must clear
- * the clipmask.
- */
- store->ormask = 0;
- store->andmask = CLIP_FRUSTUM_BITS;
-
- tnl_clip_prepare(ctx);
-
- if (tnl->NeedNdcCoords) {
- VB->NdcPtr =
- _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &store->ndcCoords,
- store->clipmask,
- &store->ormask,
- &store->andmask,
- !(ctx->Transform.DepthClampNear &&
- ctx->Transform.DepthClampFar) );
- }
- else {
- VB->NdcPtr = NULL;
- _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
- NULL,
- store->clipmask,
- &store->ormask,
- &store->andmask,
- !(ctx->Transform.DepthClampNear &&
- ctx->Transform.DepthClampFar) );
- }
-
- if (store->andmask) {
- /* All vertices are outside the frustum */
- return GL_FALSE;
- }
-
- /* Test userclip planes. This contributes to VB->ClipMask.
- */
- /** XXX NEW_SLANG _Enabled ??? */
- if (ctx->Transform.ClipPlanesEnabled &&
- (!_mesa_arb_vertex_program_enabled(ctx) ||
- ctx->VertexProgram.Current->arb.IsPositionInvariant)) {
- userclip( 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;
-}
-
-
-/**
- * XXX the texture sampling code in this module is a bit of a hack.
- * The texture sampling code is in swrast, though it doesn't have any
- * real dependencies on the rest of swrast. It should probably be
- * moved into main/ someday.
- */
-static void
-vp_fetch_texel(struct gl_context *ctx, const GLfloat texcoord[4], GLfloat lambda,
- GLuint unit, GLfloat color[4])
-{
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
-
- /* XXX use a float-valued TextureSample routine here!!! */
- swrast->TextureSample[unit](ctx, _mesa_get_samplerobj(ctx, unit),
- ctx->Texture.Unit[unit]._Current,
- 1, (const GLfloat (*)[4]) texcoord,
- &lambda, (GLfloat (*)[4]) color);
-}
-
-
-/**
- * Called via ctx->Driver.ProgramStringNotify() after a new vertex program
- * string has been parsed.
- */
-GLboolean
-_tnl_program_string(struct gl_context *ctx, GLenum target, struct gl_program *program)
-{
- /* No-op.
- * If we had derived anything from the program that was private to this
- * stage we'd recompute/validate it here.
- */
- return GL_TRUE;
-}
-
-
-/**
- * Initialize virtual machine state prior to executing vertex program.
- */
-static void
-init_machine(struct gl_context *ctx, struct gl_program_machine *machine,
- GLuint instID)
-{
- /* Input registers get initialized from the current vertex attribs */
- memcpy(machine->VertAttribs, ctx->Current.Attrib,
- MAX_VERTEX_GENERIC_ATTRIBS * 4 * sizeof(GLfloat));
-
- machine->NumDeriv = 0;
-
- /* init call stack */
- machine->StackDepth = 0;
-
- machine->FetchTexelLod = vp_fetch_texel;
- machine->FetchTexelDeriv = NULL; /* not used by vertex programs */
-
- machine->Samplers = ctx->VertexProgram._Current->SamplerUnits;
-
- machine->SystemValues[SYSTEM_VALUE_INSTANCE_ID][0] = (GLfloat) instID;
-}
-
-
-/**
- * Map the texture images which the vertex program will access (if any).
- */
-static void
-map_textures(struct gl_context *ctx, const struct gl_program *vp)
-{
- GLuint u;
-
- for (u = 0; u < ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits; u++) {
- if (vp->TexturesUsed[u]) {
- /* Note: _Current *should* correspond to the target indicated
- * in TexturesUsed[u].
- */
- _swrast_map_texture(ctx, ctx->Texture.Unit[u]._Current);
- }
- }
-}
-
-
-/**
- * Unmap the texture images which were used by the vertex program (if any).
- */
-static void
-unmap_textures(struct gl_context *ctx, const struct gl_program *vp)
-{
- GLuint u;
-
- for (u = 0; u < ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits; u++) {
- if (vp->TexturesUsed[u]) {
- /* Note: _Current *should* correspond to the target indicated
- * in TexturesUsed[u].
- */
- _swrast_unmap_texture(ctx, ctx->Texture.Unit[u]._Current);
- }
- }
-}
-
-
-/**
- * This function executes vertex programs
- */
-static GLboolean
-run_vp( struct gl_context *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 gl_program *program = ctx->VertexProgram._Current;
- struct gl_program_machine *machine = &store->machine;
- GLuint outputs[VARYING_SLOT_MAX], numOutputs;
- GLuint i, j;
-
- if (!program)
- return GL_TRUE;
-
- /* ARB program or vertex shader */
- _mesa_load_state_parameters(ctx, program->Parameters);
-
- /* make list of outputs to save some time below */
- numOutputs = 0;
- for (i = 0; i < VARYING_SLOT_MAX; i++) {
- if (program->info.outputs_written & BITFIELD64_BIT(i)) {
- outputs[numOutputs++] = i;
- }
- }
-
- /* Allocate result vectors. We delay this until now to avoid allocating
- * memory that would never be used if we don't run the software tnl pipeline.
- */
- if (!store->results[0].storage) {
- for (i = 0; i < VARYING_SLOT_MAX; i++) {
- assert(!store->results[i].storage);
- _mesa_vector4f_alloc( &store->results[i], 0, VB->Size, 32 );
- store->results[i].size = 4;
- }
- }
-
- map_textures(ctx, program);
-
- for (i = 0; i < VB->Count; i++) {
- GLuint attr;
-
- init_machine(ctx, machine, tnl->CurInstance);
-
-#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->info.inputs_read & BITFIELD64_BIT(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);
-#ifdef NAN_CHECK
- check_float(data[0]);
- check_float(data[1]);
- check_float(data[2]);
- check_float(data[3]);
-#endif
- COPY_CLEAN_4V(machine->VertAttribs[attr], size, data);
- }
- }
-
- /* execute the program */
- _mesa_execute_program(ctx, program, machine);
-
- /* copy the output registers into the VB->attribs arrays */
- for (j = 0; j < numOutputs; j++) {
- const GLuint attr = outputs[j];
-#ifdef NAN_CHECK
- check_float(machine->Outputs[attr][0]);
- check_float(machine->Outputs[attr][1]);
- check_float(machine->Outputs[attr][2]);
- check_float(machine->Outputs[attr][3]);
-#endif
- COPY_4V(store->results[attr].data[i], machine->Outputs[attr]);
- }
-
- /* FOGC is a special case. Fragment shader expects (f,0,0,1) */
- if (program->info.outputs_written & BITFIELD64_BIT(VARYING_SLOT_FOGC)) {
- store->results[VARYING_SLOT_FOGC].data[i][1] = 0.0;
- store->results[VARYING_SLOT_FOGC].data[i][2] = 0.0;
- store->results[VARYING_SLOT_FOGC].data[i][3] = 1.0;
- }
-#ifdef NAN_CHECK
- assert(machine->Outputs[0][3] != 0.0F);
-#endif
-#if 0
- printf("HPOS: %f %f %f %f\n",
- machine->Outputs[0][0],
- machine->Outputs[0][1],
- machine->Outputs[0][2],
- machine->Outputs[0][3]);
-#endif
- }
-
- unmap_textures(ctx, program);
-
- if (program->arb.IsPositionInvariant) {
- /* make sure the inverse is up to date */
- _math_matrix_analyse(&ctx->_ModelProjectMatrix);
-
- /* We need the exact same transform as in the fixed function path here
- * to guarantee invariance, depending on compiler optimization flags
- * results could be different otherwise.
- */
- VB->ClipPtr = TransformRaw( &store->results[0],
- &ctx->_ModelProjectMatrix,
- VB->AttribPtr[0] );
-
- /* 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 );
- FALLTHROUGH;
- case 3:
- _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 );
- FALLTHROUGH;
- case 4:
- break;
- }
- }
- else {
- /* Setup the VB pointers so that the next pipeline stages get
- * their data from the right place (the program output arrays).
- */
- VB->ClipPtr = &store->results[VARYING_SLOT_POS];
- VB->ClipPtr->size = 4;
- VB->ClipPtr->count = VB->Count;
- }
-
- VB->AttribPtr[VERT_ATTRIB_COLOR0] = &store->results[VARYING_SLOT_COL0];
- VB->AttribPtr[VERT_ATTRIB_COLOR1] = &store->results[VARYING_SLOT_COL1];
- VB->AttribPtr[VERT_ATTRIB_FOG] = &store->results[VARYING_SLOT_FOGC];
- VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->results[VARYING_SLOT_PSIZ];
- VB->BackfaceColorPtr = &store->results[VARYING_SLOT_BFC0];
- VB->BackfaceSecondaryColorPtr = &store->results[VARYING_SLOT_BFC1];
-
- for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- VB->AttribPtr[_TNL_ATTRIB_TEX0 + i]
- = &store->results[VARYING_SLOT_TEX0 + i];
- }
-
- for (i = 0; i < ctx->Const.MaxVarying; i++) {
- if (program->info.outputs_written &
- BITFIELD64_BIT(VARYING_SLOT_VAR0 + i)) {
- /* Note: varying results get put into the generic attributes */
- VB->AttribPtr[VERT_ATTRIB_GENERIC0+i]
- = &store->results[VARYING_SLOT_VAR0 + i];
- }
- }
-
-
- /* Perform NDC and cliptest operations:
- */
- return do_ndc_cliptest(ctx, store);
-}
-
-
-/**
- * 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(struct gl_context *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;
-
- stage->privatePtr = calloc(1, sizeof(*store));
- store = VP_STAGE_DATA(stage);
- if (!store)
- return GL_FALSE;
-
- /* a few other misc allocations */
- _mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
- store->clipmask = 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 < VARYING_SLOT_MAX; i++)
- _mesa_vector4f_free( &store->results[i] );
-
- /* free misc arrays */
- _mesa_vector4f_free( &store->ndcCoords );
- align_free( store->clipmask );
-
- free( store );
- stage->privatePtr = NULL;
- }
-}
-
-
-static void
-validate_vp_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage)
-{
- if (ctx->VertexProgram._Current) {
- _swrast_update_texture_samplers(ctx);
- }
-}
-
-
-
-/**
- * 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 */
- validate_vp_stage, /* validate */
- run_vp /* run -- initially set to ctr */
-};
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
deleted file mode 100644
index 02f521c7fb3..00000000000
--- a/src/mesa/tnl/t_vb_render.c
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-/*
- * 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 <stdio.h>
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/enums.h"
-#include "main/macros.h"
-
-#include "main/mtypes.h"
-#include "math/m_xform.h"
-#include "util/bitscan.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
-
-
-/* This does NOT include the CLIP_USER_BIT! */
-#define CLIPMASK (CLIP_FRUSTUM_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 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( struct gl_context *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 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( struct gl_context *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( struct gl_context *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( struct gl_context *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 = _tnl_translate_prim(&VB->Primitive[i]);
- GLuint start = VB->Primitive[i].start;
- GLuint length = VB->Primitive[i].count;
-
- assert((prim & PRIM_MODE_MASK) <= GL_POLYGON);
-
- if (MESA_VERBOSE & VERBOSE_PRIMS)
- _mesa_debug(NULL, "MESA prim %s %d..%d\n",
- _mesa_enum_to_string(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/src/mesa/tnl/t_vb_rendertmp.h b/src/mesa/tnl/t_vb_rendertmp.h
deleted file mode 100644
index 4bfc6b15d3b..00000000000
--- a/src/mesa/tnl/t_vb_rendertmp.h
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#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 TEST_PRIM_END
-#define TEST_PRIM_END(prim) (flags & PRIM_END)
-#define TEST_PRIM_BEGIN(prim) (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)( struct gl_context *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_POINTS);
- RENDER_POINTS( start, count );
- POSTFIX;
-}
-
-static void TAG(render_lines)( struct gl_context *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_LINES);
- for (j=start+1; j<count; j+=2 ) {
- RESET_STIPPLE;
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_LINE( ELT(j-1), ELT(j) );
- else
- RENDER_LINE( ELT(j), ELT(j-1) );
- }
- POSTFIX;
-}
-
-
-static void TAG(render_line_strip)( struct gl_context *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint j;
- LOCAL_VARS;
- (void) flags;
-
- INIT(GL_LINE_STRIP);
-
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- }
-
- for (j=start+1; j<count; j++ ) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_LINE( ELT(j-1), ELT(j) );
- else
- RENDER_LINE( ELT(j), ELT(j-1) );
- }
- POSTFIX;
-}
-
-
-static void TAG(render_line_loop)( struct gl_context *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- GLuint i;
- LOCAL_VARS;
-
- INIT(GL_LINE_LOOP);
-
- if (start+1 < count) {
- if (TEST_PRIM_BEGIN(flags)) {
- RESET_STIPPLE;
- /* draw the first line from v[0] to v[1] */
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_LINE( ELT(start), ELT(start+1) );
- else
- RENDER_LINE( ELT(start+1), ELT(start) );
- }
-
- /* draw lines from v[1] to v[n-1] */
- for ( i = start+2 ; i < count ; i++) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_LINE( ELT(i-1), ELT(i) );
- else
- RENDER_LINE( ELT(i), ELT(i-1) );
- }
-
- if ( TEST_PRIM_END(flags)) {
- /* draw final line from v[n-1] to v[0] (the very first vertex) */
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_LINE( ELT(count-1), ELT(start) );
- else
- RENDER_LINE( ELT(start), ELT(count-1) );
- }
- }
-
- POSTFIX;
-}
-
-
-static void TAG(render_triangles)( struct gl_context *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;
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
- else
- RENDER_TRI( ELT(j-1), ELT(j), ELT(j-2) );
- }
- } else {
- for (j=start+2; j<count; j+=3) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
- else
- RENDER_TRI( ELT(j-1), ELT(j), ELT(j-2) );
- }
- }
- POSTFIX;
-}
-
-
-
-static void TAG(render_tri_strip)( struct gl_context *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, ej1, ej;
- GLboolean ef2, ef1, ef;
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT) {
- ej2 = ELT(j-2+parity);
- ej1 = ELT(j-1-parity);
- ej = ELT(j);
- }
- else {
- ej2 = ELT(j-1+parity);
- ej1 = ELT(j-parity);
- ej = ELT(j-2);
- }
- ef2 = EDGEFLAG_GET( ej2 );
- ef1 = EDGEFLAG_GET( ej1 );
- 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) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
- else
- RENDER_TRI( ELT(j-1+parity), ELT(j-parity), ELT(j-2) );
- }
- }
- POSTFIX;
-}
-
-
-static void TAG(render_tri_fan)( struct gl_context *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 );
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_TRI( ejs, ej1, ej);
- else
- RENDER_TRI( ej, ejs, ej1);
- EDGEFLAG_SET( ejs, efs );
- EDGEFLAG_SET( ej1, ef1 );
- EDGEFLAG_SET( ej, ef );
- }
- } else {
- for (j=start+2;j<count;j++) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT)
- RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
- else
- RENDER_TRI( ELT(j), ELT(start), ELT(j-1) );
- }
- }
-
- POSTFIX;
-}
-
-
-static void TAG(render_poly)( struct gl_context *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)( struct gl_context *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;
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT ||
- !ctx->Const.QuadsFollowProvokingVertexConvention)
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
- else
- RENDER_QUAD( ELT(j-2), ELT(j-1), ELT(j), ELT(j-3) );
- }
- } else {
- for (j=start+3; j<count; j+=4) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT ||
- !ctx->Const.QuadsFollowProvokingVertexConvention)
- RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
- else
- RENDER_QUAD( ELT(j-2), ELT(j-1), ELT(j), ELT(j-3) );
- }
- }
- POSTFIX;
-}
-
-static void TAG(render_quad_strip)( struct gl_context *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 );
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT ||
- !ctx->Const.QuadsFollowProvokingVertexConvention)
- RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
- else
- RENDER_QUAD( ELT(j-2), ELT(j), ELT(j-1), ELT(j-3) );
- 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) {
- if (ctx->Light.ProvokingVertex == GL_LAST_VERTEX_CONVENTION_EXT ||
- !ctx->Const.QuadsFollowProvokingVertexConvention)
- RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
- else
- RENDER_QUAD( ELT(j-2), ELT(j), ELT(j-1), ELT(j-3) );
- }
- }
- POSTFIX;
-}
-
-static void TAG(render_noop)( struct gl_context *ctx,
- GLuint start,
- GLuint count,
- GLuint flags )
-{
- (void)(ctx && start && count && flags);
-}
-
-RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(struct gl_context *,
- 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/src/mesa/tnl/t_vb_texgen.c b/src/mesa/tnl/t_vb_texgen.c
deleted file mode 100644
index 6a86f5e0310..00000000000
--- a/src/mesa/tnl/t_vb_texgen.c
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Brian Paul Keith Whitwell <keithw@vmware.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 "main/errors.h"
-#include "main/glheader.h"
-#include "main/macros.h"
-
-#include "main/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)( struct gl_context *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 * (1.0f / 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 * (1.0f / 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( struct gl_context *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
- GLvector4f *out = &store->texcoord[unit];
-
- build_f_tab[VB->EyePtr->size]( out->start,
- out->stride,
- VB->AttribPtr[_TNL_ATTRIB_NORMAL],
- 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( struct gl_context *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
- GLvector4f *out = &store->texcoord[unit];
- GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
- 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( struct gl_context *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + 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->AttribPtr[_TNL_ATTRIB_NORMAL],
- 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( struct gl_context *ctx,
- struct texgen_stage_data *store,
- GLuint unit )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- struct vertex_buffer *VB = &tnl->vb;
- GLvector4f *in = VB->AttribPtr[VERT_ATTRIB_TEX0 + unit];
- GLvector4f *out = &store->texcoord[unit];
- const struct gl_fixedfunc_texture_unit *texUnit =
- &ctx->Texture.FixedFuncUnit[unit];
- const GLvector4f *obj = VB->AttribPtr[_TNL_ATTRIB_POS];
- const GLvector4f *eye = VB->EyePtr;
- const GLvector4f *normal = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
- 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->GenS.Mode) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data,
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlane[GEN_S] );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data,
- sizeof(out->data[0]), eye,
- texUnit->EyePlane[GEN_S] );
- 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->GenT.Mode) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( &(out->data[0][1]),
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlane[GEN_T] );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( &(out->data[0][1]),
- sizeof(out->data[0]), eye,
- texUnit->EyePlane[GEN_T] );
- 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->GenR.Mode) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( &(out->data[0][2]),
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlane[GEN_R] );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( &(out->data[0][2]),
- sizeof(out->data[0]), eye,
- texUnit->EyePlane[GEN_R] );
- 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->GenQ.Mode) {
- case GL_OBJECT_LINEAR:
- _mesa_dotprod_tab[obj->size]( &(out->data[0][3]),
- sizeof(out->data[0]), obj,
- texUnit->ObjectPlane[GEN_Q] );
- break;
- case GL_EYE_LINEAR:
- _mesa_dotprod_tab[eye->size]( &(out->data[0][3]),
- sizeof(out->data[0]), eye,
- texUnit->EyePlane[GEN_Q] );
- break;
- default:
- _mesa_problem(ctx, "Bad Q texgen");
- }
- }
-}
-
-
-
-
-static GLboolean run_texgen_stage( struct gl_context *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._Current)
- return GL_TRUE;
-
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
- struct gl_fixedfunc_texture_unit *texUnit =
- &ctx->Texture.FixedFuncUnit[i];
-
- if (texUnit->TexGenEnabled) {
- store->TexgenFunc[i]( ctx, store, i );
-
- VB->AttribPtr[VERT_ATTRIB_TEX0 + i] = &store->texcoord[i];
- }
- }
-
- return GL_TRUE;
-}
-
-
-static void validate_texgen_stage( struct gl_context *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
- GLuint i;
-
- if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Current)
- return;
-
- for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
- struct gl_fixedfunc_texture_unit *texUnit =
- &ctx->Texture.FixedFuncUnit[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( struct gl_context *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct texgen_stage_data *store;
- GLuint i;
-
- stage->privatePtr = calloc(1, 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 = malloc(VB->Size * sizeof(GLfloat) * 3);
- store->tmp_m = 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] );
-
-
- free( store->tmp_f );
- 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/src/mesa/tnl/t_vb_texmat.c b/src/mesa/tnl/t_vb_texmat.c
deleted file mode 100644
index cf8099509dc..00000000000
--- a/src/mesa/tnl/t_vb_texmat.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#include "main/glheader.h"
-#include "main/macros.h"
-
-#include "main/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( struct gl_context *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._Current)
- 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->AttribPtr[_TNL_ATTRIB_TEX0 + i]);
-
- VB->AttribPtr[VERT_ATTRIB_TEX0+i] = &store->texcoord[i];
- }
- }
-
- return GL_TRUE;
-}
-
-
-/* Called the first time stage->run() is invoked.
- */
-static GLboolean alloc_texmat_data( struct gl_context *ctx,
- struct tnl_pipeline_stage *stage )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
- struct texmat_stage_data *store;
- GLuint i;
-
- stage->privatePtr = calloc(1, 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/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
deleted file mode 100644
index 053900e0033..00000000000
--- a/src/mesa/tnl/t_vb_vertex.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-
-#include "main/glheader.h"
-#include "main/macros.h"
-#include "main/mtypes.h"
-
-#include "math/m_xform.h"
-
-#include "util/bitscan.h"
-#include "util/u_memory.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( struct gl_context *ctx, \
- GLvector4f *clip, \
- GLubyte *clipmask, \
- GLubyte *clipormask, \
- GLubyte *clipandmask ) \
-{ \
- GLbitfield mask = ctx->Transform.ClipPlanesEnabled; \
- while (mask) { \
- const int p = u_bit_scan(&mask); \
- 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]))( struct gl_context *,
- GLvector4f *, GLubyte *,
- GLubyte *, GLubyte * ) =
-{
- NULL,
- NULL,
- userclip2,
- userclip3,
- userclip4
-};
-
-
-void
-tnl_clip_prepare(struct gl_context *ctx)
-{
- /* Neither the x86 nor sparc asm cliptest functions have been updated
- * for ARB_depth_clamp, so force the C paths.
- */
- if (ctx->Transform.DepthClampNear && ctx->Transform.DepthClampFar) {
- static GLboolean c_funcs_installed = GL_FALSE;
- if (!c_funcs_installed) {
- init_c_cliptest();
- c_funcs_installed = GL_TRUE;
- }
- }
-}
-
-
-
-static GLboolean run_vertex_stage( struct gl_context *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._Current)
- return GL_TRUE;
-
- tnl_clip_prepare(ctx);
-
- if (ctx->_NeedEyeCoords) {
- /* Separate modelview transformation:
- * Use combined ModelProject to avoid some depth artifacts
- */
- if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
- VB->EyePtr = VB->AttribPtr[_TNL_ATTRIB_POS];
- else
- VB->EyePtr = TransformRaw( &store->eye,
- ctx->ModelviewMatrixStack.Top,
- VB->AttribPtr[_TNL_ATTRIB_POS]);
- }
-
- /* make sure the inverse is up to date */
- _math_matrix_analyse(&ctx->_ModelProjectMatrix);
-
- VB->ClipPtr = TransformRaw( &store->clip,
- &ctx->_ModelProjectMatrix,
- VB->AttribPtr[_TNL_ATTRIB_POS] );
-
- /* 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 );
- FALLTHROUGH;
- case 3:
- _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 );
- FALLTHROUGH;
- case 4:
- break;
- }
-
-
- /* Cliptest and perspective divide. Clip functions must clear
- * the clipmask.
- */
- store->ormask = 0;
- store->andmask = CLIP_FRUSTUM_BITS;
-
- if (tnl->NeedNdcCoords) {
- VB->NdcPtr =
- _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
- &store->proj,
- store->clipmask,
- &store->ormask,
- &store->andmask,
- !(ctx->Transform.DepthClampNear &&
- ctx->Transform.DepthClampFar) );
- }
- else {
- VB->NdcPtr = NULL;
- _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
- NULL,
- store->clipmask,
- &store->ormask,
- &store->andmask,
- !(ctx->Transform.DepthClampNear &&
- ctx->Transform.DepthClampFar) );
- }
-
- 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( struct gl_context *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(1, 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 = 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/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
deleted file mode 100644
index 0d29403a846..00000000000
--- a/src/mesa/tnl/t_vertex.c
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * Copyright 2003 VMware, 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
- * VMWARE 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@vmware.com>
- */
-
-#include <stdio.h>
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/execmem.h"
-#include "util/u_memory.h"
-#include "swrast/s_chan.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;
-
- if (fastpath == NULL) {
- _mesa_error_no_memory(__func__);
- return;
- }
-
- 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]));
-
- if (fastpath->attr == NULL) {
- free(fastpath);
- _mesa_error_no_memory(__func__);
- return;
- }
-
- 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( struct gl_context *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( struct gl_context *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
- ctx->Polygon.BackMode != GL_FILL);
- GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
-
- if (vtx->need_extras && (twosided || 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( struct gl_context *ctx, GLuint edst, GLuint esrc )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
- ctx->Polygon.BackMode != GL_FILL);
-
- GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
-
- if (vtx->need_extras && (twosided || 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( struct gl_context *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( struct gl_context *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( struct gl_context *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.
- */
- if (attr == _TNL_ATTRIB_POINTSIZE) {
- /* If the hardware vertex doesn't have point size then use size from
- * struct gl_context. XXX this will be wrong if drawing attenuated points!
- */
- dest[0] = ctx->Point.Size;
- }
- else {
- memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat));
- }
-}
-
-
-/* Complementary operation to the above.
- */
-void _tnl_set_attr( struct gl_context *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( struct gl_context *ctx, GLuint nr )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
-
- return vtx->vertex_buf + nr * vtx->vertex_size;
-}
-
-void _tnl_invalidate_vertex_state( struct gl_context *ctx, GLuint new_state )
-{
- /* if two-sided lighting changes or filled/unfilled polygon state changes */
- if (new_state & (_NEW_LIGHT | _NEW_POLYGON) ) {
- 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( struct gl_context *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)
- 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)
- 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( struct gl_context *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( struct gl_context *ctx )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- invalidate_funcs(vtx);
-}
-
-
-static void adjust_input_ptrs( struct gl_context *ctx, GLint diff)
-{
- 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;
-
- diff -= 1;
- for (j=0; j<count; ++j) {
- register GLvector4f *vptr = VB->AttribPtr[a->attrib];
- (a++)->inputptr += diff*vptr->stride;
- }
-}
-
-static void update_input_ptrs( struct gl_context *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( struct gl_context *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( struct gl_context *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, (GLubyte*) dest );
- return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start));
-}
-
-/* Emit indexed VB vertices start..end to dest. Note that VB vertex at
- * postion start will be emitted to dest at position zero.
- */
-
-void *_tnl_emit_indexed_vertices_to_buffer( struct gl_context *ctx,
- const GLuint *elts,
- GLuint start,
- GLuint end,
- void *dest )
-{
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- GLuint oldIndex;
- GLubyte *cdest = dest;
-
- update_input_ptrs(ctx, oldIndex = elts[start++]);
- vtx->emit( ctx, 1, cdest );
- cdest += vtx->vertex_size;
-
- for (; start < end; ++start) {
- adjust_input_ptrs(ctx, elts[start] - oldIndex);
- oldIndex = elts[start];
- vtx->emit( ctx, 1, cdest);
- cdest += vtx->vertex_size;
- }
-
- return (void *) cdest;
-}
-
-
-void _tnl_init_vertices( struct gl_context *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 = 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 (!getenv("MESA_NO_CODEGEN"))
- vtx->codegen_emit = _tnl_generate_sse_emit;
-#endif
-}
-
-
-void _tnl_free_vertices( struct gl_context *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- if (tnl) {
- struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
- struct tnl_clipspace_fastpath *fp, *tmp;
-
- 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/src/mesa/tnl/t_vertex.h b/src/mesa/tnl/t_vertex.h
deleted file mode 100644
index a84b299e518..00000000000
--- a/src/mesa/tnl/t_vertex.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright 2003 VMware, 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
- * VMWARE 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@vmware.com>
- */
-
-#ifndef _TNL_VERTEX_H
-#define _TNL_VERTEX_H
-
-#include "main/glheader.h"
-#include "t_context.h"
-
-struct gl_context;
-struct tnl_clipspace;
-
-/* 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 weird 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( struct gl_context *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary );
-
-/* Copy colors from one vertex to another:
- */
-extern void _tnl_copy_pv( struct gl_context *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( struct gl_context *ctx, const void *vertex, GLenum attrib,
- GLfloat *dest );
-
-/* Complementary to the above.
- */
-extern void _tnl_set_attr( struct gl_context *ctx, void *vout, GLenum attrib,
- const GLfloat *src );
-
-
-extern void *_tnl_get_vertex( struct gl_context *ctx, GLuint nr );
-
-extern GLuint _tnl_install_attrs( struct gl_context *ctx,
- const struct tnl_attr_map *map,
- GLuint nr, const GLfloat *vp,
- GLuint unpacked_size );
-
-extern void _tnl_free_vertices( struct gl_context *ctx );
-
-extern void _tnl_init_vertices( struct gl_context *ctx,
- GLuint vb_size,
- GLuint max_vertex_size );
-
-extern void *_tnl_emit_vertices_to_buffer( struct gl_context *ctx,
- GLuint start,
- GLuint end,
- void *dest );
-
-/* This function isn't optimal. Check out
- * gallium/auxilary/translate for a more comprehensive implementation of
- * the same functionality.
- */
-
-extern void *_tnl_emit_indexed_vertices_to_buffer( struct gl_context *ctx,
- const GLuint *elts,
- GLuint start,
- GLuint end,
- void *dest );
-
-
-extern void _tnl_build_vertices( struct gl_context *ctx,
- GLuint start,
- GLuint end,
- GLuint newinputs );
-
-extern void _tnl_invalidate_vertices( struct gl_context *ctx, GLuint newinputs );
-
-extern void _tnl_invalidate_vertex_state( struct gl_context *ctx, GLuint new_state );
-
-extern void _tnl_notify_pipeline_output_change( struct gl_context *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( struct gl_context *ctx,
- GLuint dst, GLuint src );
-
-void _tnl_generic_interp_extras( struct gl_context *ctx,
- GLfloat t,
- GLuint dst, GLuint out, GLuint in,
- GLboolean force_boundary );
-
-void _tnl_generic_copy_pv( struct gl_context *ctx, GLuint edst, GLuint esrc );
-
-void _tnl_generic_interp( struct gl_context *ctx,
- GLfloat t,
- GLuint edst, GLuint eout, GLuint ein,
- GLboolean force_boundary );
-
-void _tnl_generic_emit( struct gl_context *ctx,
- GLuint count,
- GLubyte *v );
-
-void _tnl_generate_hardwired_emit( struct gl_context *ctx );
-
-/* t_vertex_sse.c -- Internal functions for t_vertex.c
- */
-void _tnl_generate_sse_emit( struct gl_context *ctx );
-
-#endif
diff --git a/src/mesa/tnl/t_vertex_generic.c b/src/mesa/tnl/t_vertex_generic.c
deleted file mode 100644
index 7f871a4f686..00000000000
--- a/src/mesa/tnl/t_vertex_generic.c
+++ /dev/null
@@ -1,1152 +0,0 @@
-
-/*
- * Copyright 2003 VMware, 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
- * VMWARE 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@vmware.com>
- */
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/macros.h"
-#include "swrast/s_chan.h"
-#include "t_context.h"
-#include "t_vertex.h"
-
-
-#if 0
-#define DEBUG_INSERT printf("%s\n", __func__)
-#else
-#define DEBUG_INSERT
-#endif
-
-
-/*
- * 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- out[0] = vp[0] * in[0] + vp[12];
- out[1] = vp[5] * in[1] + vp[13];
- out[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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- exit(1);
-}
-
-static inline void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- GLfloat *out = (GLfloat *)(v);
- (void) a;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- out[0] = in[0];
-}
-
-static inline void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
-{
- DEBUG_INSERT;
- (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;
- DEBUG_INSERT;
- (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;
- DEBUG_INSERT;
- (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;
- DEBUG_INSERT;
- (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;
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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 )
-{
- DEBUG_INSERT;
- (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.
- */
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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;
- DEBUG_INSERT;
- 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( struct gl_context *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( struct gl_context *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( struct gl_context *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( struct gl_context *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.0f) {
- 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_4F(t, fdst, fout, fin);
-
- 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( struct gl_context *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) {
-
- 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( struct gl_context *ctx,
- GLfloat t,
- GLuint dst, GLuint out, GLuint in,
- GLboolean force_boundary )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-
- /* If stride is zero, BackfaceColorPtr 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->BackfaceColorPtr && VB->BackfaceColorPtr->stride) {
- assert(VB->BackfaceColorPtr->stride == 4 * sizeof(GLfloat));
-
- INTERP_4F( t,
- VB->BackfaceColorPtr->data[dst],
- VB->BackfaceColorPtr->data[out],
- VB->BackfaceColorPtr->data[in] );
- }
-
- if (VB->BackfaceSecondaryColorPtr) {
- assert(VB->BackfaceSecondaryColorPtr->stride == 4 * sizeof(GLfloat));
-
- INTERP_3F( t,
- VB->BackfaceSecondaryColorPtr->data[dst],
- VB->BackfaceSecondaryColorPtr->data[out],
- VB->BackfaceSecondaryColorPtr->data[in] );
- }
-
- if (VB->BackfaceIndexPtr) {
- VB->BackfaceIndexPtr->data[dst][0] = LINTERP( t,
- VB->BackfaceIndexPtr->data[out][0],
- VB->BackfaceIndexPtr->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( struct gl_context *ctx,
- GLuint dst, GLuint src )
-{
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
-
- /* See above comment:
- */
- if (VB->BackfaceColorPtr && VB->BackfaceColorPtr->stride) {
- COPY_4FV( VB->BackfaceColorPtr->data[dst],
- VB->BackfaceColorPtr->data[src] );
- }
-
- if (VB->BackfaceSecondaryColorPtr) {
- COPY_4FV( VB->BackfaceSecondaryColorPtr->data[dst],
- VB->BackfaceSecondaryColorPtr->data[src] );
- }
-
- if (VB->BackfaceIndexPtr) {
- VB->BackfaceIndexPtr->data[dst][0] = VB->BackfaceIndexPtr->data[src][0];
- }
-
- _tnl_generic_copy_pv(ctx, dst, src);
-}
-
-
diff --git a/src/mesa/tnl/t_vertex_sse.c b/src/mesa/tnl/t_vertex_sse.c
deleted file mode 100644
index 191a68d7e6d..00000000000
--- a/src/mesa/tnl/t_vertex_sse.c
+++ /dev/null
@@ -1,685 +0,0 @@
-/*
- * Copyright 2003 VMware, 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
- * VMWARE 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@vmware.com>
- */
-
-#include <stdio.h>
-
-#include "main/glheader.h"
-#include "main/context.h"
-#include "main/enums.h"
-#include "swrast/s_chan.h"
-#include "t_context.h"
-#include "t_vertex.h"
-
-#if defined(USE_SSE_ASM)
-
-#include "x86/rtasm/x86sse.h"
-#include "x86/common_x86_asm.h"
-
-
-/**
- * Number of bytes to allocate for generated SSE functions
- */
-#define MAX_SSE_CODE_SIZE 1024
-
-
-#define X 0
-#define Y 1
-#define Z 2
-#define W 3
-
-
-struct x86_program {
- struct x86_function func;
-
- struct gl_context *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 )
-{
- /* Loading from memory erases the upper bits. */
- sse_movss(&p->func, 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 )
-{
- /* Loading from memory erases the upper bits. */
- sse_movss(&p->func, 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 )
-{
- struct gl_context *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);
- struct x86_reg temp2 = x86_make_reg(file_XMM, 3);
- GLubyte *fixup, *label;
-
- /* 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 {
- 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, temp2, 1, x86_deref(srcECX), a[1].inputsize);
- sse_movss(&p->func, temp, temp2);
- 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 {
- 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:
- printf("unknown CHAN_TYPE %s\n", _mesa_enum_to_string(CHAN_TYPE));
- return GL_FALSE;
- }
- break;
- default:
- 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);
-
- assert(!vtx->emit);
- vtx->emit = (tnl_emit_func)x86_get_func(&p->func);
-
- assert( (char *) p->func.csr - (char *) p->func.store <= MAX_SSE_CODE_SIZE );
- return GL_TRUE;
-}
-
-
-
-void _tnl_generate_sse_emit( struct gl_context *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 = 0; /* for now */
- p.have_sse2 = cpu_has_xmm2;
- p.identity = x86_make_reg(file_XMM, 6);
- p.chan0 = x86_make_reg(file_XMM, 7);
-
- if (!x86_init_func_size(&p.func, MAX_SSE_CODE_SIZE)) {
- vtx->emit = NULL;
- return;
- }
-
- 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( struct gl_context *ctx )
-{
- /* Dummy version for when USE_SSE_ASM not defined */
-}
-
-#endif
diff --git a/src/mesa/tnl/t_vp_build.c b/src/mesa/tnl/t_vp_build.c
deleted file mode 100644
index 7de2105d326..00000000000
--- a/src/mesa/tnl/t_vp_build.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2007 VMware, 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
- * 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
- * VMWARE 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 "main/glheader.h"
-#include "main/ffvertex_prog.h"
-#include "main/mtypes.h"
-#include "t_vp_build.h"
-
-
-/**
- * XXX This should go away someday, but still referenced by some drivers...
- */
-void _tnl_UpdateFixedFunctionProgram( struct gl_context *ctx )
-{
- if (!ctx->VertexProgram._Current ||
- ctx->VertexProgram._Current == ctx->VertexProgram._TnlProgram) {
- ctx->VertexProgram._Current
- = ctx->VertexProgram._TnlProgram
- = _mesa_get_fixed_func_vertex_program(ctx);
- }
-}
diff --git a/src/mesa/tnl/t_vp_build.h b/src/mesa/tnl/t_vp_build.h
deleted file mode 100644
index 5bc7b339e47..00000000000
--- a/src/mesa/tnl/t_vp_build.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 2005 VMware, 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
- * 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
- * VMWARE 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_VP_BUILD_H
-#define T_VP_BUILD_H
-
-struct gl_context;
-
-#define TNL_FIXED_FUNCTION_STATE_FLAGS (_NEW_PROGRAM | \
- _NEW_LIGHT | \
- _NEW_TEXTURE | \
- _NEW_TEXTURE_MATRIX | \
- _NEW_TRANSFORM | \
- _NEW_FOG | \
- _NEW_POINT)
-
-extern void _tnl_UpdateFixedFunctionProgram( struct gl_context *ctx );
-
-#endif
diff --git a/src/mesa/tnl/tnl.h b/src/mesa/tnl/tnl.h
deleted file mode 100644
index 7f47dd3f223..00000000000
--- a/src/mesa/tnl/tnl.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Mesa 3-D graphics library
- *
- * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Keith Whitwell <keithw@vmware.com>
- */
-
-#ifndef _TNL_H
-#define _TNL_H
-
-#include "main/glheader.h"
-
-struct gl_context;
-struct gl_program;
-struct gl_buffer_object;
-struct gl_transform_feedback_object;
-struct dd_function_table;
-
-
-/* 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( struct gl_context *ctx );
-
-extern void
-_tnl_DestroyContext( struct gl_context *ctx );
-
-extern void
-_tnl_InvalidateState( struct gl_context *ctx, GLuint new_state );
-
-extern void
-_tnl_init_driver_draw_function(struct dd_function_table *functions);
-
-/* Functions to revive the tnl module after being unhooked from
- * dispatch and/or driver callbacks.
- */
-
-extern void
-_tnl_wakeup( struct gl_context *ctx );
-
-/* Driver configuration options:
- */
-extern void
-_tnl_need_projected_coords( struct gl_context *ctx, GLboolean flag );
-
-
-/**
- * Vertex array information which is derived from gl_array_attributes
- * and gl_vertex_buffer_binding information. Used by the TNL module and
- * device drivers.
- */
-struct tnl_vertex_array
-{
- /** Vertex attribute array */
- const struct gl_array_attributes *VertexAttrib;
- /** Vertex buffer binding */
- const struct gl_vertex_buffer_binding *BufferBinding;
-};
-
-
-extern const struct tnl_vertex_array*
-_tnl_bind_inputs( struct gl_context *ctx );
-
-
-/* Control whether T&L does per-vertex fog
- */
-extern void
-_tnl_allow_vertex_fog( struct gl_context *ctx, GLboolean value );
-
-extern void
-_tnl_allow_pixel_fog( struct gl_context *ctx, GLboolean value );
-
-extern GLboolean
-_tnl_program_string(struct gl_context *ctx, GLenum target, struct gl_program *program);
-
-struct _mesa_prim;
-struct _mesa_index_buffer;
-
-void
-_tnl_draw_prims(struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLboolean index_bounds_valid,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance);
-
-void
-_tnl_draw(struct gl_context *ctx,
- const struct _mesa_prim *prim, unsigned nr_prims,
- const struct _mesa_index_buffer *ib,
- bool index_bounds_valid, bool primitive_restart,
- unsigned restart_index, unsigned min_index, unsigned max_index,
- unsigned num_instances, unsigned base_instance);
-
-extern void
-_tnl_RasterPos(struct gl_context *ctx, const GLfloat vObj[4]);
-
-extern void
-_tnl_validate_shine_tables( struct gl_context *ctx );
-
-
-
-/**
- * For indirect array drawing:
- *
- * typedef struct {
- * GLuint count;
- * GLuint primCount;
- * GLuint first;
- * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
- * } DrawArraysIndirectCommand;
- *
- * For indirect indexed drawing:
- *
- * typedef struct {
- * GLuint count;
- * GLuint primCount;
- * GLuint firstIndex;
- * GLint baseVertex;
- * GLuint baseInstance; // in GL 4.2 and later, must be zero otherwise
- * } DrawElementsIndirectCommand;
- */
-
-
-/**
- * Draw a number of primitives.
- * \param prims array [nr_prims] describing what to draw (prim type,
- * vertex count, first index, instance count, etc).
- * \param arrays array of vertex arrays for draw
- * \param ib index buffer for indexed drawing, NULL for array drawing
- * \param index_bounds_valid are min_index and max_index valid?
- * \param min_index lowest vertex index used
- * \param max_index highest vertex index used
- * \param tfb_vertcount if non-null, indicates which transform feedback
- * object has the vertex count.
- * \param tfb_stream If called via DrawTransformFeedbackStream, specifies the
- * vertex stream buffer from which to get the vertex count.
- * \param indirect If any prims are indirect, this specifies the buffer
- * to find the "DrawArrays/ElementsIndirectCommand" data.
- * This may be deprecated in the future
- */
-typedef void (*tnl_draw_func)(struct gl_context *ctx,
- const struct tnl_vertex_array* arrays,
- const struct _mesa_prim *prims,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLboolean index_bounds_valid,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance);
-
-
-/* Utility function to cope with various constraints on tnl modules or
- * hardware. This can be used to split an incoming set of arrays and
- * primitives against the following constraints:
- * - Maximum number of indices in index buffer.
- * - Maximum number of vertices referenced by index buffer.
- * - Maximum hardware vertex buffer size.
- */
-struct split_limits
-{
- GLuint max_verts;
- GLuint max_indices;
- GLuint max_vb_size; /* bytes */
-};
-
-void
-_tnl_split_prims(struct gl_context *ctx,
- const struct tnl_vertex_array *arrays,
- const struct _mesa_prim *prim,
- GLuint nr_prims,
- const struct _mesa_index_buffer *ib,
- GLuint min_index,
- GLuint max_index,
- GLuint num_instances,
- GLuint base_instance,
- tnl_draw_func draw,
- const struct split_limits *limits);
-
-
-#endif