summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/savage
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/savage')
-rw-r--r--src/mesa/drivers/dri/savage/savage_bci.h5
-rw-r--r--src/mesa/drivers/dri/savage/savage_xmesa.c5
-rw-r--r--src/mesa/drivers/dri/savage/savagecontext.h12
-rw-r--r--src/mesa/drivers/dri/savage/savagedd.c3
-rw-r--r--src/mesa/drivers/dri/savage/savagestate.c1
-rw-r--r--src/mesa/drivers/dri/savage/savagetris.c128
-rw-r--r--src/mesa/drivers/dri/savage/savagevb.c470
7 files changed, 121 insertions, 503 deletions
diff --git a/src/mesa/drivers/dri/savage/savage_bci.h b/src/mesa/drivers/dri/savage/savage_bci.h
index adaf579a91c..9b3ca2e25d7 100644
--- a/src/mesa/drivers/dri/savage/savage_bci.h
+++ b/src/mesa/drivers/dri/savage/savage_bci.h
@@ -628,8 +628,13 @@ typedef union {
#define SAVAGE_HW_NO_W (1<<1)
#define SAVAGE_HW_NO_CD (1<<2)
#define SAVAGE_HW_NO_CS (1<<3)
+#define SAVAGE_HW_NO_U0 (1<<4)
+#define SAVAGE_HW_NO_V0 (1<<5)
#define SAVAGE_HW_NO_UV0 ((1<<4) | (1<<5))
+#define SAVAGE_HW_NO_U1 (1<<6)
+#define SAVAGE_HW_NO_V1 (1<<7)
#define SAVAGE_HW_NO_UV1 ((1<<6) | (1<<7))
+#define SAVAGE_HW_SKIPFLAGS 0x000000ff
#define SAVAGE_HW_TRIANGLE_TYPE (3UL<<25)
#define SAVAGE_HW_TRIANGLE_CONT (1UL<<24)
diff --git a/src/mesa/drivers/dri/savage/savage_xmesa.c b/src/mesa/drivers/dri/savage/savage_xmesa.c
index 43613b067fd..990689cfc96 100644
--- a/src/mesa/drivers/dri/savage/savage_xmesa.c
+++ b/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -48,7 +48,6 @@
#include "savagetex.h"
#include "savagespan.h"
#include "savagetris.h"
-#include "savagevb.h"
#include "savageioctl.h"
#include "savage_bci.h"
@@ -412,7 +411,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
imesa->new_state = ~0;
imesa->RenderIndex = ~0;
imesa->dirty = ~0;
- imesa->vertex_format = 0;
imesa->TextureMode = ctx->Texture.Unit[0].EnvMode;
imesa->CurrentTexObj[0] = 0;
imesa->CurrentTexObj[1] = 0;
@@ -454,7 +452,6 @@ savageCreateContext( const __GLcontextModes *mesaVis,
savageDDInitIoctlFuncs( ctx );
savageInitTriFuncs( ctx );
- savageInitVB( ctx );
savageDDInitState( imesa );
driContextPriv->driverPrivate = (void *) imesa;
@@ -487,8 +484,6 @@ savageDestroyContext(__DRIcontextPrivate *driContextPriv)
_ac_DestroyContext( imesa->glCtx );
_swrast_DestroyContext( imesa->glCtx );
- savageFreeVB( imesa->glCtx );
-
/* free the Mesa context */
imesa->glCtx->DriverCtx = NULL;
_mesa_destroy_context(imesa->glCtx);
diff --git a/src/mesa/drivers/dri/savage/savagecontext.h b/src/mesa/drivers/dri/savage/savagecontext.h
index 6eaf58eca56..af8952200e3 100644
--- a/src/mesa/drivers/dri/savage/savagecontext.h
+++ b/src/mesa/drivers/dri/savage/savagecontext.h
@@ -40,6 +40,7 @@ typedef struct savage_texture_object_t *savageTextureObjectPtr;
#include "savage_sarea.h"
#include "savage_init.h"
#include "mm.h"
+#include "tnl/t_vertex.h"
#include "savagetex.h"
#include "savagedma.h"
@@ -157,6 +158,13 @@ struct savage_context_t {
*/
GLuint LcsCullMode;
+ /* Vertex state
+ */
+ GLuint vertex_size;
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+ char *verts; /* points to tnl->clipspace.vertex_buf */
+
/* Rasterization state
*/
GLuint SetupNewInputs;
@@ -167,11 +175,7 @@ struct savage_context_t {
GLenum raster_primitive;
GLenum render_primitive;
- GLubyte *verts;
- GLuint vertex_format;
- GLuint vertex_size;
GLuint DrawPrimitiveCmd;
- GLuint DrawPrimitiveMask;
/* Fallback rasterization functions
*/
diff --git a/src/mesa/drivers/dri/savage/savagedd.c b/src/mesa/drivers/dri/savage/savagedd.c
index 96773e5a711..90acab86be8 100644
--- a/src/mesa/drivers/dri/savage/savagedd.c
+++ b/src/mesa/drivers/dri/savage/savagedd.c
@@ -28,12 +28,13 @@
#include <stdio.h>
#include "mm.h"
+#include "swrast/swrast.h"
+
#include "savagedd.h"
#include "savagestate.h"
#include "savagespan.h"
#include "savagetex.h"
#include "savagetris.h"
-#include "savagevb.h"
#include "savagecontext.h"
#include "extensions.h"
diff --git a/src/mesa/drivers/dri/savage/savagestate.c b/src/mesa/drivers/dri/savage/savagestate.c
index 622e4362ab5..7c724eb7598 100644
--- a/src/mesa/drivers/dri/savage/savagestate.c
+++ b/src/mesa/drivers/dri/savage/savagestate.c
@@ -36,7 +36,6 @@
#include "savagestate.h"
#include "savagetex.h"
-#include "savagevb.h"
#include "savagetris.h"
#include "savageioctl.h"
#include "savage_bci.h"
diff --git a/src/mesa/drivers/dri/savage/savagetris.c b/src/mesa/drivers/dri/savage/savagetris.c
index db061d9d393..025c469a55f 100644
--- a/src/mesa/drivers/dri/savage/savagetris.c
+++ b/src/mesa/drivers/dri/savage/savagetris.c
@@ -51,7 +51,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "savagetris.h"
#include "savagestate.h"
#include "savagetex.h"
-#include "savagevb.h"
#include "savageioctl.h"
#include "savage_bci.h"
@@ -86,7 +85,7 @@ static void __inline__ savage_draw_triangle( savageContextPtr imesa,
imesa->DrawPrimitiveCmd &=
~(SAVAGE_HW_TRIANGLE_TYPE| SAVAGE_HW_TRIANGLE_CONT);
- WRITE_CMD(vb,SAVAGE_DRAW_PRIMITIVE(3, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
+ WRITE_CMD(vb,SAVAGE_DRAW_PRIMITIVE(3, imesa->DrawPrimitiveCmd, 0),GLuint);
vb = savage_send_one_vertex(imesa, v0, vb, 0, vertsize);
vb = savage_send_one_vertex(imesa, v1, vb, 0, vertsize);
@@ -130,7 +129,7 @@ static __inline__ void savage_draw_point( savageContextPtr imesa,
~(SAVAGE_HW_TRIANGLE_TYPE | SAVAGE_HW_TRIANGLE_CONT);
imesa->DrawPrimitiveCmd |= SAVAGE_HW_TRIANGLE_FAN;
- WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(4, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
+ WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(4, imesa->DrawPrimitiveCmd, 0),GLuint);
WRITE_CMD(vb, x - sz, GLfloat);
WRITE_CMD(vb, y - sz, GLfloat);
@@ -164,7 +163,7 @@ static __inline__ void savage_draw_line( savageContextPtr imesa,
imesa->DrawPrimitiveCmd &=
~(SAVAGE_HW_TRIANGLE_TYPE | SAVAGE_HW_TRIANGLE_CONT);
imesa->DrawPrimitiveCmd |= SAVAGE_HW_TRIANGLE_FAN;
- WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(4, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
+ WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(4, imesa->DrawPrimitiveCmd, 0),GLuint);
dx = v0->v.x - v1->v.x;
dy = v0->v.y - v1->v.y;
@@ -204,7 +203,7 @@ static void __inline__ savage_draw_quad( savageContextPtr imesa,
imesa->DrawPrimitiveCmd &=
~(SAVAGE_HW_TRIANGLE_TYPE | SAVAGE_HW_TRIANGLE_CONT);
- WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(6, imesa->DrawPrimitiveCmd&imesa->DrawPrimitiveMask, 0),GLuint);
+ WRITE_CMD(vb, SAVAGE_DRAW_PRIMITIVE(6, imesa->DrawPrimitiveCmd, 0),GLuint);
vb = savage_send_one_vertex(imesa, v0, vb, 0, vertsize);
vb = savage_send_one_vertex(imesa, v1, vb, 0, vertsize);
@@ -454,9 +453,9 @@ savage_fallback_tri( savageContextPtr imesa,
{
GLcontext *ctx = imesa->glCtx;
SWvertex v[3];
- savage_translate_vertex( ctx, v0, &v[0] );
- savage_translate_vertex( ctx, v1, &v[1] );
- savage_translate_vertex( ctx, v2, &v[2] );
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
_swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
}
@@ -468,8 +467,8 @@ savage_fallback_line( savageContextPtr imesa,
{
GLcontext *ctx = imesa->glCtx;
SWvertex v[2];
- savage_translate_vertex( ctx, v0, &v[0] );
- savage_translate_vertex( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
_swrast_Line( ctx, &v[0], &v[1] );
}
@@ -480,7 +479,7 @@ savage_fallback_point( savageContextPtr imesa,
{
GLcontext *ctx = imesa->glCtx;
SWvertex v[1];
- savage_translate_vertex( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v0, &v[0] );
_swrast_Point( ctx, &v[0] );
}
@@ -656,9 +655,6 @@ static void savageRunPipeline( GLcontext *ctx )
savageDDUpdateHwState( ctx );
if (!imesa->Fallback && imesa->new_gl_state) {
- if (imesa->new_gl_state & _SAVAGE_NEW_VERTEX_STATE)
- savageChooseVertexState( ctx );
-
if (imesa->new_gl_state & _SAVAGE_NEW_RENDER_STATE)
savageChooseRenderState( ctx );
@@ -732,16 +728,88 @@ static void savageRenderPrimitive( GLcontext *ctx, GLenum prim )
}
+#define EMIT_ATTR( ATTR, STYLE, SKIP ) \
+do { \
+ imesa->vertex_attrs[imesa->vertex_attr_count].attrib = (ATTR); \
+ imesa->vertex_attrs[imesa->vertex_attr_count].format = (STYLE); \
+ imesa->vertex_attr_count++; \
+ drawCmd &= ~SKIP; \
+} while (0)
+
static void savageRenderStart( GLcontext *ctx )
{
- /* Check for projective texturing. Make sure all texcoord
- * pointers point to something. (fix in mesa?)
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint drawCmd = SAVAGE_HW_SKIPFLAGS;
+ if (imesa->savageScreen->chipset < S3_SAVAGE4)
+ drawCmd &= ~SAVAGE_HW_NO_UV1;
+ drawCmd &= ~SAVAGE_HW_NO_Z; /* all mesa vertices have a z coordinate */
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ imesa->vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
*/
- savageCheckTexSizes( ctx );
+ if (index & _TNL_BITS_TEX_ANY) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, SAVAGE_HW_NO_W );
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0 );
+ }
+
+ /* t_context.c always includes a diffuse color */
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, SAVAGE_HW_NO_CD );
+
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, SAVAGE_HW_NO_CS );
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_HW_NO_CS );
+ }
+
+ if (index & _TNL_BIT_TEX(0)) {
+ if (VB->TexCoordPtr[0]->size > 2) {
+ /* projective textures are not supported by the hardware */
+ FALLBACK(ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ }
+ if (VB->TexCoordPtr[0]->size == 2)
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_HW_NO_UV0 );
+ else
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_HW_NO_U0 );
+ }
+ if (index & _TNL_BIT_TEX(1)) {
+ if (VB->TexCoordPtr[1]->size > 2) {
+ /* projective textures are not supported by the hardware */
+ FALLBACK(ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ }
+ if (VB->TexCoordPtr[1]->size == 2)
+ EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, SAVAGE_HW_NO_UV1 );
+ else
+ EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_1F, SAVAGE_HW_NO_U1 );
+ }
+
+ /* Only need to change the vertex emit code if there has been a
+ * statechange to a new hardware vertex format:
+ */
+ if (drawCmd != (imesa->DrawPrimitiveCmd & SAVAGE_HW_SKIPFLAGS)) {
+ imesa->vertex_size =
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->hw_viewport, 0 );
+ imesa->vertex_size >>= 2;
+
+ imesa->DrawPrimitiveCmd = drawCmd;
+ }
if (!SAVAGE_CONTEXT(ctx)->Fallback) {
/* Update hardware state and get the lock */
savageDDRenderStart( ctx );
+ } else {
+ tnl->Driver.Render.Start(ctx);
}
}
@@ -784,9 +852,19 @@ void savageFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
tnl->Driver.Render.Start = savageRenderStart;
tnl->Driver.Render.PrimitiveNotify = savageRenderPrimitive;
tnl->Driver.Render.Finish = savageRenderFinish;
- tnl->Driver.Render.BuildVertices = savageBuildVertices;
- imesa->new_gl_state |= (_SAVAGE_NEW_RENDER_STATE|
- _SAVAGE_NEW_VERTEX_STATE);
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->hw_viewport, 0 );
+
+ imesa->new_gl_state |= _SAVAGE_NEW_RENDER_STATE;
}
}
}
@@ -811,7 +889,13 @@ void savageInitTriFuncs( GLcontext *ctx )
tnl->Driver.Render.Finish = savageRenderFinish;
tnl->Driver.Render.PrimitiveNotify = savageRenderPrimitive;
tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
- tnl->Driver.Render.BuildVertices = savageBuildVertices;
-/* r128Fallback( ctx, 0x100000, 1 ); */
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ 22 * sizeof(GLfloat) );
+
+ SAVAGE_CONTEXT(ctx)->verts = (char *)tnl->clipspace.vertex_buf;
}
diff --git a/src/mesa/drivers/dri/savage/savagevb.c b/src/mesa/drivers/dri/savage/savagevb.c
deleted file mode 100644
index f0f4f4c43d8..00000000000
--- a/src/mesa/drivers/dri/savage/savagevb.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * Copyright 2000-2001 VA Linux Systems, 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
- * VA LINUX SYSTEMS AND/OR ITS 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 <[email protected]>
- * Felix Kuehling <[email protected]>
- */
-/* $XFree86$ */
-
-#include "savagecontext.h"
-#include "savagevb.h"
-#include "savagetris.h"
-#include "savageioctl.h"
-#include "savagecontext.h"
-#include "savage_bci.h"
-
-#include "glheader.h"
-#include "mtypes.h"
-#include "macros.h"
-#include "colormac.h"
-
-#include "tnl/t_context.h"
-#include "swrast_setup/swrast_setup.h"
-#include "swrast/swrast.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-
-#define SAVAGE_TEX1_BIT 0x1
-#define SAVAGE_TEX0_BIT 0x2
-#define SAVAGE_RGBA_BIT 0x4
-#define SAVAGE_SPEC_BIT 0x8
-#define SAVAGE_FOG_BIT 0x10
-#define SAVAGE_XYZW_BIT 0x20
-#define SAVAGE_PTEX_BIT 0x40
-#define SAVAGE_MAX_SETUP 0x80
-
-static struct {
- void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
- interp_func interp;
- copy_pv_func copy_pv;
- GLboolean (*check_tex_sizes)( GLcontext *ctx );
- GLuint vertex_size;
- GLuint vertex_format;
-} setup_tab[SAVAGE_MAX_SETUP];
-
-/* savage supports vertices without specular color, but this is not supported
- * by the vbtmp. have to check if/how tiny vertices work. */
-#define TINY_VERTEX_FORMAT 0
-#define NOTEX_VERTEX_FORMAT (SAVAGE_HW_NO_UV0|SAVAGE_HW_NO_UV1)
-#define TEX0_VERTEX_FORMAT (SAVAGE_HW_NO_UV1)
-#define TEX1_VERTEX_FORMAT (0)
-#define PROJ_TEX1_VERTEX_FORMAT 0
-#define TEX2_VERTEX_FORMAT 0
-#define TEX3_VERTEX_FORMAT 0
-#define PROJ_TEX3_VERTEX_FORMAT 0
-
-#define DO_XYZW (IND & SAVAGE_XYZW_BIT)
-#define DO_RGBA (IND & SAVAGE_RGBA_BIT)
-#define DO_SPEC (IND & SAVAGE_SPEC_BIT)
-#define DO_FOG (IND & SAVAGE_FOG_BIT)
-#define DO_TEX0 (IND & SAVAGE_TEX0_BIT)
-#define DO_TEX1 (IND & SAVAGE_TEX1_BIT)
-#define DO_TEX2 0
-#define DO_TEX3 0
-#define DO_PTEX (IND & SAVAGE_PTEX_BIT)
-
-
-#define VERTEX savageVertex
-#define LOCALVARS savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
-#define GET_VIEWPORT_MAT() imesa->hw_viewport
-#define GET_TEXSOURCE(n) n
-#define GET_VERTEX_FORMAT() (imesa->DrawPrimitiveCmd & \
- (SAVAGE_HW_NO_UV0|SAVAGE_HW_NO_UV1))
-#define GET_VERTEX_STORE() imesa->verts
-#define GET_VERTEX_SIZE() (imesa->vertex_size * sizeof(int))
-
-#define HAVE_HW_VIEWPORT 0
-#define HAVE_HW_DIVIDE 0
-#define HAVE_RGBA_COLOR 0
-#define HAVE_TINY_VERTICES 0
-#define HAVE_NOTEX_VERTICES 1
-#define HAVE_TEX0_VERTICES 1
-#define HAVE_TEX1_VERTICES 1
-#define HAVE_TEX2_VERTICES 0
-#define HAVE_TEX3_VERTICES 0
-#define HAVE_PTEX_VERTICES 0
-
-#define UNVIEWPORT_VARS \
- const GLfloat dx = - imesa->drawX - SUBPIXEL_X; \
- const GLfloat dy = (imesa->driDrawable->h + \
- imesa->drawY + SUBPIXEL_Y); \
- const GLfloat sz = 1.0 / imesa->depth_scale
-
-#define UNVIEWPORT_X(x) x + dx;
-#define UNVIEWPORT_Y(y) - y + dy;
-#define UNVIEWPORT_Z(z) z * sz;
-
-#define PTEX_FALLBACK() (void)imesa, FALLBACK(ctx, SAVAGE_FALLBACK_TEXTURE, 1)
-
-
-#define INTERP_VERTEX (void)imesa, setup_tab[SAVAGE_CONTEXT(ctx)->SetupIndex].interp
-#define COPY_PV_VERTEX (void)imesa, setup_tab[SAVAGE_CONTEXT(ctx)->SetupIndex].copy_pv
-
-
-/***********************************************************************
- * Generate pv-copying and translation functions *
- ***********************************************************************/
-
-#define TAG(x) savage_##x
-#include "tnl_dd/t_dd_vb.c"
-
-/***********************************************************************
- * Generate vertex emit and interp functions *
- ***********************************************************************/
-
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT)
-#define TAG(x) x##_wg
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT)
-#define TAG(x) x##_wgs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_wgt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_wgt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
-#define TAG(x) x##_wgpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_wgst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_wgst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
-#define TAG(x) x##_wgspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT)
-#define TAG(x) x##_wgf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT)
-#define TAG(x) x##_wgfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_wgft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_wgft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
-#define TAG(x) x##_wgfpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_wgfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_wgfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_PTEX_BIT)
-#define TAG(x) x##_wgfspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_TEX0_BIT)
-#define TAG(x) x##_t0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_t0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_FOG_BIT)
-#define TAG(x) x##_f
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_ft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_ft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT)
-#define TAG(x) x##_g
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT)
-#define TAG(x) x##_gs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_gt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_gt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_gst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_gst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT)
-#define TAG(x) x##_gf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT)
-#define TAG(x) x##_gfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_gft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_gft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT)
-#define TAG(x) x##_gfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (SAVAGE_RGBA_BIT|SAVAGE_FOG_BIT|SAVAGE_SPEC_BIT|SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT)
-#define TAG(x) x##_gfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-
-static void init_setup_tab( void )
-{
- init_wg();
- init_wgs();
- init_wgt0();
- init_wgt0t1();
- init_wgpt0();
- init_wgst0();
- init_wgst0t1();
- init_wgspt0();
- init_wgf();
- init_wgfs();
- init_wgft0();
- init_wgft0t1();
- init_wgfpt0();
- init_wgfst0();
- init_wgfst0t1();
- init_wgfspt0();
- init_t0();
- init_t0t1();
- init_f();
- init_ft0();
- init_ft0t1();
- init_g();
- init_gs();
- init_gt0();
- init_gt0t1();
- init_gst0();
- init_gst0t1();
- init_gf();
- init_gfs();
- init_gft0();
- init_gft0t1();
- init_gfst0();
- init_gfst0t1();
-}
-
-
-
-
-void savagePrintSetupFlags(char *msg, GLuint flags )
-{
- fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & SAVAGE_XYZW_BIT) ? " xyzw," : "",
- (flags & SAVAGE_RGBA_BIT) ? " rgba," : "",
- (flags & SAVAGE_SPEC_BIT) ? " spec," : "",
- (flags & SAVAGE_FOG_BIT) ? " fog," : "",
- (flags & SAVAGE_TEX0_BIT) ? " tex-0," : "",
- (flags & SAVAGE_TEX1_BIT) ? " tex-1," : "");
-}
-
-
-void savageCheckTexSizes( GLcontext *ctx )
-{
- savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
- /*fprintf(stderr, "%s\n", __FUNCTION__);*/
-
- if (!setup_tab[imesa->SetupIndex].check_tex_sizes(ctx)) {
- imesa->SetupIndex |= SAVAGE_PTEX_BIT;
- imesa->SetupNewInputs = ~0;
-
- if (!imesa->Fallback &&
- !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
- tnl->Driver.Render.Interp = setup_tab[imesa->SetupIndex].interp;
- tnl->Driver.Render.CopyPV = setup_tab[imesa->SetupIndex].copy_pv;
- }
- if (imesa->Fallback)
- tnl->Driver.Render.Start(ctx);
- }
-}
-
-
-void savageBuildVertices( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint newinputs )
-{
- savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
- GLuint stride = imesa->vertex_size * sizeof(int);
- GLubyte *v = ((GLubyte *)imesa->verts + (start * stride));
-
- newinputs |= imesa->SetupNewInputs;
- imesa->SetupNewInputs = 0;
-
- if (!newinputs)
- return;
-
- if (newinputs & VERT_BIT_POS) {
- setup_tab[imesa->SetupIndex].emit( ctx, start, count, v, stride );
- } else {
- GLuint ind = 0;
-
- if (newinputs & VERT_BIT_COLOR0)
- ind |= SAVAGE_RGBA_BIT;
-
- if (newinputs & VERT_BIT_COLOR1)
- ind |= SAVAGE_SPEC_BIT;
-
- if (newinputs & VERT_BIT_TEX0)
- ind |= SAVAGE_TEX0_BIT;
-
- if (newinputs & VERT_BIT_TEX1)
- ind |= SAVAGE_TEX0_BIT|SAVAGE_TEX1_BIT;
-
- if (newinputs & VERT_BIT_FOG)
- ind |= SAVAGE_FOG_BIT;
-
- if (imesa->SetupIndex & SAVAGE_PTEX_BIT)
- ind = ~0;
-
- ind &= imesa->SetupIndex;
-
- if (ind) {
- setup_tab[ind].emit( ctx, start, count, v, stride );
- }
- }
-}
-
-
-void savageChooseVertexState( GLcontext *ctx )
-{
- savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint ind = SAVAGE_XYZW_BIT|SAVAGE_RGBA_BIT;
-
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
- ind |= SAVAGE_SPEC_BIT;
-
- if (ctx->Fog.Enabled)
- ind |= SAVAGE_FOG_BIT;
-
- if (ctx->Texture._EnabledUnits & 0x2) {
- if (ctx->Texture._EnabledUnits & 0x1) {
- ind |= SAVAGE_TEX1_BIT|SAVAGE_TEX0_BIT;
- }
- else {
- ind |= SAVAGE_TEX0_BIT;
- }
- }
- else if (ctx->Texture._EnabledUnits & 0x1) {
- ind |= SAVAGE_TEX0_BIT;
- }
-
- imesa->SetupIndex = ind;
-
- if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
- tnl->Driver.Render.Interp = savage_interp_extras;
- tnl->Driver.Render.CopyPV = savage_copy_pv_extras;
- } else {
- tnl->Driver.Render.Interp = setup_tab[ind].interp;
- tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
- }
-
- if (setup_tab[ind].vertex_format != GET_VERTEX_FORMAT()) {
- imesa->DrawPrimitiveCmd = setup_tab[ind].vertex_format;
- imesa->vertex_size = setup_tab[ind].vertex_size;
- }
-}
-
-
-
-void savageInitVB( GLcontext *ctx )
-{
- savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
- GLuint size = TNL_CONTEXT(ctx)->vb.Size;
-
- imesa->verts = (GLubyte *)ALIGN_MALLOC(size * sizeof(savageVertex), 32);
-
- {
- static int firsttime = 1;
- if (firsttime) {
- init_setup_tab();
- firsttime = 0;
- }
- }
-
- imesa->DrawPrimitiveCmd = setup_tab[0].vertex_format;
- imesa->vertex_size = setup_tab[0].vertex_size;
-
- if (imesa->savageScreen->chipset >= S3_SAVAGE4)
- imesa->DrawPrimitiveMask = ~0;
- else
- imesa->DrawPrimitiveMask = ~SAVAGE_HW_NO_UV1;
-}
-
-
-void savageFreeVB( GLcontext *ctx )
-{
- savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
- if (imesa->verts) {
- ALIGN_FREE(imesa->verts);
- imesa->verts = 0;
- }
-}
-