summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2005-01-04 12:18:05 +0000
committerKeith Whitwell <[email protected]>2005-01-04 12:18:05 +0000
commitb6ab7a1bf1b6d4c6e44c4b167e072c4169e6923c (patch)
tree429f9cfd517ddbaf8e5478808222a357c3b930ed /src
parentf72e4424d960b1751845d9e0579e8fdcca93b3d0 (diff)
Change to use the t_vertex.c mechanisms for building vertices,
including Felix's ptex code. Re-enable some assembly for performance.
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/unichrome/Makefile1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.c6
-rw-r--r--src/mesa/drivers/dri/unichrome/via_context.h24
-rw-r--r--src/mesa/drivers/dri/unichrome/via_ioctl.c12
-rw-r--r--src/mesa/drivers/dri/unichrome/via_render.c44
-rw-r--r--src/mesa/drivers/dri/unichrome/via_state.c37
-rw-r--r--src/mesa/drivers/dri/unichrome/via_texcombine.c1
-rw-r--r--src/mesa/drivers/dri/unichrome/via_tris.c484
-rw-r--r--src/mesa/drivers/dri/unichrome/via_vb.c380
-rw-r--r--src/mesa/drivers/dri/unichrome/via_vb.h70
10 files changed, 381 insertions, 678 deletions
diff --git a/src/mesa/drivers/dri/unichrome/Makefile b/src/mesa/drivers/dri/unichrome/Makefile
index baf1fe47b7e..b08a239e083 100644
--- a/src/mesa/drivers/dri/unichrome/Makefile
+++ b/src/mesa/drivers/dri/unichrome/Makefile
@@ -29,7 +29,6 @@ DRIVER_SOURCES = \
via_texmem.c \
via_texstate.c \
via_tris.c \
- via_vb.c \
via_texcombine.c \
xf86drmVIA.c
diff --git a/src/mesa/drivers/dri/unichrome/via_context.c b/src/mesa/drivers/dri/unichrome/via_context.c
index 2fa1eb4f9cc..acc2cca3826 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.c
+++ b/src/mesa/drivers/dri/unichrome/via_context.c
@@ -52,7 +52,6 @@
#include "via_tex.h"
#include "via_span.h"
#include "via_tris.h"
-#include "via_vb.h"
#include "via_ioctl.h"
#include "via_fb.h"
#include "via_regs.h"
@@ -288,7 +287,7 @@ AllocateDmaBuffer(const GLvisual *visual, viaContextPtr vmesa)
return GL_FALSE;
vmesa->dmaLow = 0;
- vmesa->dmaCliprectAddr = 0;
+ vmesa->dmaCliprectAddr = ~0;
return GL_TRUE;
}
@@ -468,6 +467,7 @@ viaCreateContext(const __GLcontextModes *mesaVis,
vmesa->texHeap = mmInit(0, viaScreen->textureSize);
vmesa->renderIndex = ~0;
+ vmesa->setupIndex = ~0;
make_empty_list(&vmesa->TexObjList);
make_empty_list(&vmesa->SwappedOut);
@@ -492,7 +492,6 @@ viaCreateContext(const __GLcontextModes *mesaVis,
viaInitTriFuncs(ctx);
viaInitSpanFuncs(ctx);
viaInitIoctlFuncs(ctx);
- viaInitVB(ctx);
viaInitState(ctx);
#ifdef DEBUG
@@ -555,7 +554,6 @@ viaDestroyContext(__DRIcontextPrivate *driContextPriv)
_tnl_DestroyContext(vmesa->glCtx);
_ac_DestroyContext(vmesa->glCtx);
_swrast_DestroyContext(vmesa->glCtx);
- viaFreeVB(vmesa->glCtx);
FreeBuffer(vmesa);
/* free the Mesa context */
_mesa_destroy_context(vmesa->glCtx);
diff --git a/src/mesa/drivers/dri/unichrome/via_context.h b/src/mesa/drivers/dri/unichrome/via_context.h
index a409b8c6b72..84367847eaa 100644
--- a/src/mesa/drivers/dri/unichrome/via_context.h
+++ b/src/mesa/drivers/dri/unichrome/via_context.h
@@ -35,11 +35,13 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
#include "mtypes.h"
#include "drm.h"
#include "mm.h"
+#include "tnl/t_vertex.h"
#include "via_screen.h"
#include "via_tex.h"
#include "via_common.h"
#include "xf86drmVIA.h"
+
#define VIA_FALLBACK_TEXTURE 0x1
#define VIA_FALLBACK_DRAW_BUFFER 0x2
#define VIA_FALLBACK_READ_BUFFER 0x4
@@ -51,9 +53,10 @@ typedef struct via_texture_object_t *viaTextureObjectPtr;
#define VIA_FALLBACK_BLEND_EQ 0x200
#define VIA_FALLBACK_BLEND_FUNC 0x400
#define VIA_FALLBACK_USER_DISABLE 0x800
+#define VIA_FALLBACK_PROJ_TEXTURE 0x1000
-#define VIA_DMA_BUFSIZ 5000
-#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 256)
+#define VIA_DMA_BUFSIZ 4096
+#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 128)
#define VIA_NO_CLIPRECTS 0x1
@@ -121,11 +124,15 @@ struct via_context_t {
*/
GLuint Fallback;
- /* State for via_vb.c and via_tris.c.
+ /* State for via_tris.c.
*/
GLuint newState; /* _NEW_* flags */
GLuint newEmitState; /* _NEW_* flags */
- GLuint setupNewInputs;
+ GLuint newRenderState; /* _NEW_* flags */
+
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+
GLuint setupIndex;
GLuint renderIndex;
GLmatrix ViewportMatrix;
@@ -204,11 +211,12 @@ struct via_context_t {
GLuint regHTXnTBLRAa_1;
GLuint regHTXnTBLRFog_1;
- /* Hardware state
- */
- GLuint dirty;
int vertexSize;
- int vertexFormat;
+ int hwVertexSize;
+ GLboolean ptexHack;
+ int coloroffset;
+ int specoffset;
+
GLint lastStamp;
GLenum TexEnvImageFmt[2];
diff --git a/src/mesa/drivers/dri/unichrome/via_ioctl.c b/src/mesa/drivers/dri/unichrome/via_ioctl.c
index d3d4041b99f..15f3991caea 100644
--- a/src/mesa/drivers/dri/unichrome/via_ioctl.c
+++ b/src/mesa/drivers/dri/unichrome/via_ioctl.c
@@ -3,7 +3,7 @@
* Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
-v * copy of this software and associated documentation files (the "Software"),
+ * 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, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
@@ -629,10 +629,10 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
if (flags & VIA_NO_CLIPRECTS) {
if (0) fprintf(stderr, "%s VIA_NO_CLIPRECTS\n", __FUNCTION__);
- assert(vmesa->dmaCliprectAddr == 0);
+ assert(vmesa->dmaCliprectAddr == ~0);
fire_buffer( vmesa );
}
- else if (!vmesa->dmaCliprectAddr) {
+ else if (vmesa->dmaCliprectAddr == ~0) {
/* Contains only state. Could just dump the packet?
*/
if (0) fprintf(stderr, "%s: no dmaCliprectAddr\n", __FUNCTION__);
@@ -673,7 +673,7 @@ void viaFlushDmaLocked(viaContextPtr vmesa, GLuint flags)
/* Reset vmesa vars:
*/
vmesa->dmaLow = 0;
- vmesa->dmaCliprectAddr = 0;
+ vmesa->dmaCliprectAddr = ~0;
vmesa->newEmitState = ~0;
}
@@ -747,6 +747,8 @@ GLuint *viaAllocDmaFunc(viaContextPtr vmesa, int bytes, const char *func, int li
{
GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
+ if (0)
+ fprintf(stderr, "%s %04x 0x%x bytes\n", func, vmesa->dmaLow, bytes);
vmesa->dmaLow += bytes;
return start;
}
@@ -765,6 +767,8 @@ GLuint *viaExtendPrimitive(viaContextPtr vmesa, int bytes)
{
GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
+ if (0)
+ fprintf(stderr, "%s %04x 0x%x bytes\n", __FUNCTION__, vmesa->dmaLow, bytes);
vmesa->dmaLow += bytes;
return start;
}
diff --git a/src/mesa/drivers/dri/unichrome/via_render.c b/src/mesa/drivers/dri/unichrome/via_render.c
index 8e4efd220f9..fc4c9e09f7e 100644
--- a/src/mesa/drivers/dri/unichrome/via_render.c
+++ b/src/mesa/drivers/dri/unichrome/via_render.c
@@ -38,7 +38,6 @@
#include "via_context.h"
#include "via_tris.h"
#include "via_state.h"
-#include "via_vb.h"
#include "via_ioctl.h"
/*
@@ -52,7 +51,7 @@
#define HAVE_LINE_LOOP 1
#define HAVE_TRIANGLES 1
#define HAVE_TRI_STRIPS 1
-#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
+#define HAVE_TRI_STRIP_1 0
#define HAVE_TRI_FANS 1
#define HAVE_POLYGONS 1
#define HAVE_QUADS 0
@@ -73,7 +72,7 @@
viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
#define EMIT_VERTS(ctx, j, nr, buf) \
- via_emit_contiguous_verts(ctx, j, (j) + (nr), buf)
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )
#define FLUSH() VIA_FINISH_PRIM( vmesa )
@@ -94,24 +93,18 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
struct vertex_buffer *VB = &tnl->vb;
GLuint i;
- /* Don't handle clipping or indexed vertices.
- */
+
+ tnl->Driver.Render.Start(ctx);
+
if (VB->ClipOrMask ||
vmesa->renderIndex != 0 ||
!via_fastvalidate_render( ctx, VB )) {
- if (VIA_DEBUG) {
- fprintf(stderr, "slow path\n");
- fprintf(stderr, "ClipOrMask = %08x\n", VB->ClipOrMask);
- fprintf(stderr, "renderIndex = %08x\n", vmesa->renderIndex);
- fprintf(stderr, "Elts = %08x\n", (GLuint)VB->Elts);
- }
+ tnl->Driver.Render.Finish(ctx);
return GL_TRUE;
}
- if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
- vmesa->setupNewInputs = VERT_BIT_CLIP;
- tnl->Driver.Render.Start(ctx);
-
+ tnl->clipspace.new_inputs |= VERT_BIT_POS;
+
for (i = 0; i < VB->PrimitiveCount; ++i) {
GLuint mode = VB->Primitive[i].mode;
GLuint start = VB->Primitive[i].start;
@@ -121,31 +114,14 @@ static GLboolean via_run_fastrender(GLcontext *ctx,
}
tnl->Driver.Render.Finish(ctx);
-
- if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
+
return GL_FALSE; /* finished the pipe */
}
static void via_check_fastrender(GLcontext *ctx, struct tnl_pipeline_stage *stage)
{
- GLuint inputs = VERT_BIT_CLIP | VERT_BIT_COLOR0;
-
- if (ctx->RenderMode == GL_RENDER) {
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
- inputs |= VERT_BIT_COLOR1;
-
- if (ctx->Texture.Unit[0]._ReallyEnabled)
- inputs |= VERT_BIT_TEX0;
-
- if (ctx->Texture.Unit[1]._ReallyEnabled)
- inputs |= VERT_BIT_TEX1;
-
- if (ctx->Fog.Enabled)
- inputs |= VERT_BIT_FOG;
- }
-
- stage->inputs = inputs;
+ stage->inputs = TNL_CONTEXT(ctx)->render_inputs;
}
diff --git a/src/mesa/drivers/dri/unichrome/via_state.c b/src/mesa/drivers/dri/unichrome/via_state.c
index dc22d2ceccd..07d03d495f7 100644
--- a/src/mesa/drivers/dri/unichrome/via_state.c
+++ b/src/mesa/drivers/dri/unichrome/via_state.c
@@ -36,7 +36,6 @@
#include "via_context.h"
#include "via_state.h"
#include "via_tex.h"
-#include "via_vb.h"
#include "via_tris.h"
#include "via_ioctl.h"
@@ -764,7 +763,7 @@ void viaInitState(GLcontext *ctx)
viaContextPtr vmesa = VIA_CONTEXT(ctx);
vmesa->regCmdA = HC_ACMD_HCmdA;
- vmesa->regCmdB = HC_ACMD_HCmdB | HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z;
+ vmesa->regCmdB = HC_ACMD_HCmdB;
vmesa->regEnable = HC_HenCW_MASK;
/* Mesa should do this for us:
@@ -862,7 +861,7 @@ static void viaChooseTextureState(GLcontext *ctx)
FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, GL_TRUE);
return;
}
- vmesa->regCmdB |= HC_HVPMSK_S | HC_HVPMSK_T | HC_HVPMSK_W | HC_HVPMSK_Cs;
+
vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK;
switch (texObj->MinFilter) {
@@ -919,9 +918,6 @@ static void viaChooseTextureState(GLcontext *ctx)
viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 );
}
- else {
- /* Should turn Cs off if actually no Cs */
- }
if (texUnit1->_ReallyEnabled) {
struct gl_texture_object *texObj = texUnit1->_Current;
@@ -999,10 +995,6 @@ static void viaChooseTextureState(GLcontext *ctx)
}
}
else {
- if (ctx->Fog.Enabled)
- vmesa->regCmdB &= (~(HC_HVPMSK_S | HC_HVPMSK_T));
- else
- vmesa->regCmdB &= (~(HC_HVPMSK_S | HC_HVPMSK_T | HC_HVPMSK_W));
vmesa->regEnable &= (~(HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK));
}
if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
@@ -1307,7 +1299,6 @@ static void viaChooseFogState(GLcontext *ctx)
if (ctx->Fog.Enabled) {
GLubyte r, g, b, a;
- vmesa->regCmdB |= (HC_HVPMSK_Cd | HC_HVPMSK_Cs | HC_HVPMSK_W);
vmesa->regEnable |= HC_HenFOG_MASK;
/* Use fog equation 0 (OpenGL's default) & local fog.
@@ -1322,10 +1313,6 @@ static void viaChooseFogState(GLcontext *ctx)
vmesa->regHFogCH = a;
}
else {
- if (!ctx->Texture._EnabledUnits) {
- vmesa->regCmdB &= ~ HC_HVPMSK_W;
- vmesa->regCmdB &= ~ HC_HVPMSK_Cs;
- }
vmesa->regEnable &= ~HC_HenFOG_MASK;
}
}
@@ -1334,7 +1321,6 @@ static void viaChooseDepthState(GLcontext *ctx)
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
if (ctx->Depth.Test) {
- vmesa->regCmdB |= HC_HVPMSK_Z;
vmesa->regEnable |= HC_HenZT_MASK;
if (ctx->Depth.Mask)
vmesa->regEnable |= HC_HenZW_MASK;
@@ -1344,10 +1330,6 @@ static void viaChooseDepthState(GLcontext *ctx)
}
else {
- /* Still need to send parameter Z.
- */
-
- vmesa->regCmdB |= HC_HVPMSK_Z;
vmesa->regEnable &= ~HC_HenZT_MASK;
/*=* [DBG] racer : can't display cars in car selection menu *=*/
@@ -1365,11 +1347,9 @@ static void viaChooseLightState(GLcontext *ctx)
if (ctx->Light.ShadeModel == GL_SMOOTH) {
vmesa->regCmdA |= HC_HShading_Gouraud;
- vmesa->regCmdB |= HC_HVPMSK_Cd;
}
else {
vmesa->regCmdA &= ~HC_HShading_Gouraud;
- vmesa->regCmdB |= HC_HVPMSK_Cd;
}
}
@@ -1550,17 +1530,6 @@ static void viaChooseTriangle(GLcontext *ctx)
void viaValidateState( GLcontext *ctx )
{
viaContextPtr vmesa = VIA_CONTEXT(ctx);
- struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0];
- struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1];
- if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
-
-
- if (texUnit0->_ReallyEnabled || texUnit1->_ReallyEnabled || ctx->Fog.Enabled) {
- vmesa->regCmdB |= HC_HVPMSK_Cs;
- }
- else {
- vmesa->regCmdB &= ~ HC_HVPMSK_Cs;
- }
if (vmesa->newState & _NEW_TEXTURE) {
viaChooseTextureState(ctx);
@@ -1592,8 +1561,6 @@ void viaValidateState( GLcontext *ctx )
vmesa->newEmitState |= vmesa->newState;
vmesa->newState = 0;
-
- if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
}
static void viaInvalidateState(GLcontext *ctx, GLuint newState)
diff --git a/src/mesa/drivers/dri/unichrome/via_texcombine.c b/src/mesa/drivers/dri/unichrome/via_texcombine.c
index ea4849f90d6..6e48123610b 100644
--- a/src/mesa/drivers/dri/unichrome/via_texcombine.c
+++ b/src/mesa/drivers/dri/unichrome/via_texcombine.c
@@ -42,7 +42,6 @@
#include "via_context.h"
#include "via_state.h"
#include "via_tex.h"
-#include "via_vb.h"
#include "via_tris.h"
#include "via_ioctl.h"
diff --git a/src/mesa/drivers/dri/unichrome/via_tris.c b/src/mesa/drivers/dri/unichrome/via_tris.c
index 5f801748e38..e7d2750b57b 100644
--- a/src/mesa/drivers/dri/unichrome/via_tris.c
+++ b/src/mesa/drivers/dri/unichrome/via_tris.c
@@ -41,14 +41,13 @@
#include "via_tris.h"
#include "via_state.h"
#include "via_span.h"
-#include "via_vb.h"
#include "via_ioctl.h"
/***********************************************************************
* Emit primitives as inline vertices *
***********************************************************************/
-#if 0
+#if 1
#define COPY_DWORDS(vb, vertsize, v) \
do { \
int j; \
@@ -69,58 +68,108 @@
} while (0)
#endif
-static void __inline__ via_draw_triangle(viaContextPtr vmesa,
- viaVertexPtr v0,
- viaVertexPtr v1,
- viaVertexPtr v2)
+static void via_draw_triangle(viaContextPtr vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1,
+ viaVertexPtr v2)
{
- GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize);
-/* fprintf(stderr, "%s: %p %p %p\n", __FUNCTION__, v0, v1, v2); */
- COPY_DWORDS(vb, vertsize, v0);
- COPY_DWORDS(vb, vertsize, v1);
- COPY_DWORDS(vb, vertsize, v2);
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize);
+
+ COPY_DWORDS(vb, vertsize, v0);
+ COPY_DWORDS(vb, vertsize, v1);
+ COPY_DWORDS(vb, vertsize, v2);
}
-static void __inline__ via_draw_quad(viaContextPtr vmesa,
- viaVertexPtr v0,
- viaVertexPtr v1,
- viaVertexPtr v2,
- viaVertexPtr v3)
+static void via_draw_quad(viaContextPtr vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1,
+ viaVertexPtr v2,
+ viaVertexPtr v3)
{
- GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize);
-
-/* fprintf(stderr, "%s: %p %p %p %p\n", __FUNCTION__, v0, v1, v2, v3); */
- COPY_DWORDS(vb, vertsize, v0);
- COPY_DWORDS(vb, vertsize, v1);
- COPY_DWORDS(vb, vertsize, v3);
- COPY_DWORDS(vb, vertsize, v1);
- COPY_DWORDS(vb, vertsize, v2);
- COPY_DWORDS(vb, vertsize, v3);
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize);
+
+ COPY_DWORDS(vb, vertsize, v0);
+ COPY_DWORDS(vb, vertsize, v1);
+ COPY_DWORDS(vb, vertsize, v3);
+ COPY_DWORDS(vb, vertsize, v1);
+ COPY_DWORDS(vb, vertsize, v2);
+ COPY_DWORDS(vb, vertsize, v3);
}
-static __inline__ void via_draw_line(viaContextPtr vmesa,
- viaVertexPtr v0,
- viaVertexPtr v1)
+static void via_draw_line(viaContextPtr vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1)
{
- GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize);
- COPY_DWORDS(vb, vertsize, v0);
- COPY_DWORDS(vb, vertsize, v1);
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize);
+ COPY_DWORDS(vb, vertsize, v0);
+ COPY_DWORDS(vb, vertsize, v1);
}
-static __inline__ void via_draw_point(viaContextPtr vmesa,
- viaVertexPtr v0)
+static void via_draw_point(viaContextPtr vmesa,
+ viaVertexPtr v0)
{
- GLuint vertsize = vmesa->vertexSize;
- GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
- COPY_DWORDS(vb, vertsize, v0);
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
+ COPY_DWORDS(vb, vertsize, v0);
}
+/* Fallback drawing functions for the ptex hack.
+ */
+#define PTEX_VERTEX( tmp, vertex_size, v) \
+do { \
+ GLuint j; \
+ GLfloat rhw = 1.0 / v->f[vertex_size]; \
+ for ( j = 0 ; j < vertex_size ; j++ ) \
+ tmp.f[j] = v->f[j]; \
+ tmp.f[3] *= v->f[vertex_size]; \
+ tmp.f[vertex_size-2] *= rhw; \
+ tmp.f[vertex_size-1] *= rhw; \
+} while (0)
+
+static void via_ptex_tri (viaContextPtr vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1,
+ viaVertexPtr v2)
+{
+ GLuint vertsize = vmesa->hwVertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 3*4*vertsize);
+ viaVertex tmp;
+
+ PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
+ PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
+ PTEX_VERTEX(tmp, vertsize, v2); COPY_DWORDS(vb, vertsize, &tmp);
+}
+
+static void via_ptex_line (viaContextPtr vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1)
+{
+ GLuint vertsize = vmesa->hwVertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 2*4*vertsize);
+ viaVertex tmp;
+
+ PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
+ PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
+}
+
+static void via_ptex_point (viaContextPtr vmesa,
+ viaVertexPtr v0)
+{
+ GLuint vertsize = vmesa->hwVertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 1*4*vertsize);
+ viaVertex tmp;
+
+ PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
+}
+
+
+
/***********************************************************************
@@ -129,7 +178,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define TRI(a, b, c) \
do { \
- if (VIA_DEBUG) fprintf(stderr, "hw TRI\n"); \
if (DO_FALLBACK) \
vmesa->drawTri(vmesa, a, b, c); \
else \
@@ -138,7 +186,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define QUAD(a, b, c, d) \
do { \
- if (VIA_DEBUG) fprintf(stderr, "hw QUAD\n");\
if (DO_FALLBACK) { \
vmesa->drawTri(vmesa, a, b, d); \
vmesa->drawTri(vmesa, b, c, d); \
@@ -149,7 +196,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define LINE(v0, v1) \
do { \
- if(VIA_DEBUG) fprintf(stderr, "hw LINE\n");\
if (DO_FALLBACK) \
vmesa->drawLine(vmesa, v0, v1); \
else \
@@ -158,7 +204,6 @@ static __inline__ void via_draw_point(viaContextPtr vmesa,
#define POINT(v0) \
do { \
- if (VIA_DEBUG) fprintf(stderr, "hw POINT\n");\
if (DO_FALLBACK) \
vmesa->drawPoint(vmesa, v0); \
else \
@@ -244,7 +289,7 @@ do { \
#define VERT_SET_SPEC( v0, c ) \
do { \
- if (havespec) { \
+ if (specoffset) { \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
@@ -252,7 +297,7 @@ do { \
} while (0)
#define VERT_COPY_SPEC( v0, v1 ) \
do { \
- if (havespec) { \
+ if (specoffset) { \
v0->v.specular.red = v1->v.specular.red; \
v0->v.specular.green = v1->v.specular.green; \
v0->v.specular.blue = v1->v.specular.blue; \
@@ -262,16 +307,16 @@ do { \
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
-#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
-#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
#define LOCAL_VARS(n) \
viaContextPtr vmesa = VIA_CONTEXT(ctx); \
GLuint color[n], spec[n]; \
- GLuint coloroffset = (vmesa->vertexSize == 4 ? 3 : 4); \
- GLboolean havespec = (vmesa->vertexSize > 4); \
- (void)color; (void)spec; (void)coloroffset; (void)havespec;
+ GLuint coloroffset = vmesa->coloroffset; \
+ GLuint specoffset = vmesa->specoffset; \
+ (void)color; (void)spec; (void)coloroffset; (void)specoffset;
/***********************************************************************
@@ -409,9 +454,9 @@ via_fallback_tri(viaContextPtr vmesa,
{
GLcontext *ctx = vmesa->glCtx;
SWvertex v[3];
- via_translate_vertex(ctx, v0, &v[0]);
- via_translate_vertex(ctx, v1, &v[1]);
- via_translate_vertex(ctx, v2, &v[2]);
+ _swsetup_Translate(ctx, v0, &v[0]);
+ _swsetup_Translate(ctx, v1, &v[1]);
+ _swsetup_Translate(ctx, v2, &v[2]);
viaSpanRenderStart( ctx );
_swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
viaSpanRenderFinish( ctx );
@@ -425,8 +470,8 @@ via_fallback_line(viaContextPtr vmesa,
{
GLcontext *ctx = vmesa->glCtx;
SWvertex v[2];
- via_translate_vertex(ctx, v0, &v[0]);
- via_translate_vertex(ctx, v1, &v[1]);
+ _swsetup_Translate(ctx, v0, &v[0]);
+ _swsetup_Translate(ctx, v1, &v[1]);
viaSpanRenderStart( ctx );
_swrast_Line(ctx, &v[0], &v[1]);
viaSpanRenderFinish( ctx );
@@ -439,7 +484,7 @@ via_fallback_point(viaContextPtr vmesa,
{
GLcontext *ctx = vmesa->glCtx;
SWvertex v[1];
- via_translate_vertex(ctx, v0, &v[0]);
+ _swsetup_Translate(ctx, v0, &v[0]);
viaSpanRenderStart( ctx );
_swrast_Point(ctx, &v[0]);
viaSpanRenderFinish( ctx );
@@ -540,6 +585,13 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
+
+#define _VIA_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
+
#define _VIA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
_DD_NEW_TRI_UNFILLED | \
_DD_NEW_TRI_LIGHT_TWOSIDE | \
@@ -556,99 +608,231 @@ static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
-void viaChooseRenderState(GLcontext *ctx)
+static void viaChooseRenderState(GLcontext *ctx)
{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
- GLuint flags = ctx->_TriangleCaps;
- GLuint index = 0;
- if (VIA_DEBUG) fprintf(stderr, "%s - in\n", __FUNCTION__);
-
- if (VIA_DEBUG) fprintf(stderr, "_TriangleCaps = %x\n", flags);
- if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
- if (flags & ANY_RASTER_FLAGS) {
- if (flags & DD_TRI_LIGHT_TWOSIDE) index |= VIA_TWOSIDE_BIT;
- if (flags & DD_TRI_OFFSET) index |= VIA_OFFSET_BIT;
- if (flags & DD_TRI_UNFILLED) index |= VIA_UNFILLED_BIT;
- }
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ viaContextPtr vmesa = VIA_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (vmesa->ptexHack) {
+ vmesa->drawPoint = via_ptex_point;
+ vmesa->drawLine = via_ptex_line;
+ vmesa->drawTri = via_ptex_tri;
+ index |= VIA_FALLBACK_BIT;
+ }
+ else {
+ vmesa->drawPoint = via_draw_point;
+ vmesa->drawLine = via_draw_line;
+ vmesa->drawTri = via_draw_triangle;
+ }
- vmesa->drawPoint = via_draw_point;
- vmesa->drawLine = via_draw_line;
- vmesa->drawTri = via_draw_triangle;
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= VIA_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= VIA_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= VIA_UNFILLED_BIT;
+ if (flags & ANY_FALLBACK_FLAGS) index |= VIA_FALLBACK_BIT;
- /* Hook in fallbacks for specific primitives.
- */
- if (flags & ANY_FALLBACK_FLAGS) {
- if (flags & POINT_FALLBACK)
- vmesa->drawPoint = via_fallback_point;
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & POINT_FALLBACK)
+ vmesa->drawPoint = via_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ vmesa->drawLine = via_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ vmesa->drawTri = via_fallback_tri;
+ }
- if (flags & LINE_FALLBACK)
- vmesa->drawLine = via_fallback_line;
+ if (vmesa->renderIndex != index) {
+ vmesa->renderIndex = index;
- if (flags & TRI_FALLBACK)
- vmesa->drawTri = via_fallback_tri;
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
- index |= VIA_FALLBACK_BIT;
- }
- }
- if (VIA_DEBUG) {
- fprintf(stderr, "index = %x\n", index);
- fprintf(stderr, "renderIndex = %x\n", vmesa->renderIndex);
- }
- if (vmesa->renderIndex != index) {
- vmesa->renderIndex = index;
-
- tnl->Driver.Render.Points = rast_tab[index].points;
- tnl->Driver.Render.Line = rast_tab[index].line;
- tnl->Driver.Render.Triangle = rast_tab[index].triangle;
-
- tnl->Driver.Render.Quad = rast_tab[index].quad;
-
- if (index == 0) {
- tnl->Driver.Render.PrimTabVerts = via_fastrender_tab_verts;
- tnl->Driver.Render.PrimTabElts = via_fastrender_tab_elts;
- tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
- tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly;
- }
- else {
- tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
- tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
- tnl->Driver.Render.ClippedLine = viaRenderClippedLine;
- tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly;
- }
- }
- if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = via_fastrender_tab_verts;
+ tnl->Driver.Render.PrimTabElts = via_fastrender_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly;
+ }
+ else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = viaRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly;
+ }
+ }
}
+#define VIA_EMIT_TEX1 0x01
+#define VIA_EMIT_TEX0 0x02
+#define VIA_EMIT_PTEX0 0x04
+#define VIA_EMIT_RGBA 0x08
+#define VIA_EMIT_SPEC 0x10
+#define VIA_EMIT_FOG 0x20
+#define VIA_EMIT_W 0x40
+
+#define EMIT_ATTR( ATTR, STYLE, INDEX, REGB ) \
+do { \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = (ATTR); \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].format = (STYLE); \
+ vmesa->vertex_attr_count++; \
+ setupIndex |= (INDEX); \
+ regCmdB |= (REGB); \
+} while (0)
+#define EMIT_PAD( N ) \
+do { \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = 0; \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].format = EMIT_PAD; \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].offset = (N); \
+ vmesa->vertex_attr_count++; \
+} while (0)
-/**********************************************************************/
-/* High level hooks for t_vb_render.c */
-/**********************************************************************/
-static void viaRunPipeline(GLcontext *ctx)
+static void viaChooseVertexState( GLcontext *ctx )
{
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
-
- if (vmesa->newState) {
- viaValidateState( ctx );
- if (!vmesa->Fallback) {
- viaChooseVertexState(ctx);
- viaChooseRenderState(ctx);
- }
- }
+ viaContextPtr vmesa = VIA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint index = tnl->render_inputs;
+ GLuint regCmdB = HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z;
+ GLuint setupIndex = 0;
+
+ vmesa->vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if (index & (_TNL_BITS_TEX_ANY|_TNL_BIT_FOG)) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VIA_EMIT_W, HC_HVPMSK_W );
+ vmesa->coloroffset = 4;
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
+ vmesa->coloroffset = 3;
+ }
- _tnl_run_pipeline(ctx);
+ /* t_context.c always includes a diffuse color */
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VIA_EMIT_RGBA, HC_HVPMSK_Cd );
+
+ vmesa->specoffset = 0;
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ if ((index & _TNL_BIT_COLOR1)) {
+ vmesa->specoffset = vmesa->coloroffset + 1;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VIA_EMIT_SPEC, HC_HVPMSK_Cs );
+ }
+ else
+ EMIT_PAD( 3 );
+
+ if ((index & _TNL_BIT_FOG))
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VIA_EMIT_FOG, HC_HVPMSK_Cs );
+ else
+ EMIT_PAD( 1 );
+ }
+
+ if (index & _TNL_BIT_TEX(0)) {
+ if (vmesa->ptexHack)
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, VIA_EMIT_PTEX0, (HC_HVPMSK_S | HC_HVPMSK_T) );
+ else
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, VIA_EMIT_TEX0, (HC_HVPMSK_S | HC_HVPMSK_T) );
+ }
+
+ if (index & _TNL_BIT_TEX(1)) {
+ EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, VIA_EMIT_TEX1, 0 ); /* how does the hardware find out about this? */
+ }
+
+ if (setupIndex != vmesa->setupIndex) {
+ vmesa->vertexSize = _tnl_install_attrs( ctx,
+ vmesa->vertex_attrs,
+ vmesa->vertex_attr_count,
+ vmesa->ViewportMatrix.m, 0 );
+ vmesa->vertexSize >>= 2;
+ vmesa->setupIndex = setupIndex;
+ vmesa->regCmdB &= ~HC_HVPMSK_MASK;
+ vmesa->regCmdB |= regCmdB;
+
+ if (vmesa->ptexHack)
+ vmesa->hwVertexSize = vmesa->vertexSize - 1;
+ else
+ vmesa->hwVertexSize = vmesa->vertexSize;
+ }
}
+
+
+
+/* Check if projective texture coordinates are used and if we can fake
+ * them. Fallback to swrast we can't. Returns GL_TRUE if projective
+ * texture coordinates must be faked, GL_FALSE otherwise.
+ */
+static GLboolean viaCheckPTexHack( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLboolean fallback = GL_FALSE;
+ GLboolean ptexHack = GL_FALSE;
+
+ if (index & _TNL_BIT_TEX(0) && VB->TexCoordPtr[0]->size == 4) {
+ if ((index & _TNL_BITS_TEX_ANY) == _TNL_BIT_TEX(0))
+ ptexHack = GL_TRUE;
+ else
+ fallback = GL_TRUE;
+ }
+ if ((index & _TNL_BIT_TEX(1)) && VB->TexCoordPtr[1]->size == 4)
+ fallback = GL_TRUE;
+
+ FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_PROJ_TEXTURE, fallback);
+ return ptexHack;
+}
+
+
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
static void viaRenderStart(GLcontext *ctx)
{
- /* Check for projective texturing. Make sure all texcoord
- * pointers point to something. (fix in mesa?)
- */
- viaCheckTexSizes(ctx);
+ viaContextPtr vmesa = VIA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ {
+ GLboolean ptexHack = viaCheckPTexHack( ctx );
+ if (ptexHack != vmesa->ptexHack) {
+ vmesa->ptexHack = ptexHack;
+ vmesa->newRenderState |= _VIA_NEW_RENDERSTATE;
+ }
+ }
+
+ if (vmesa->newState) {
+ vmesa->newRenderState |= vmesa->newState;
+ viaValidateState( ctx );
+ }
+
+ if (vmesa->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ return;
+ }
+
+ if (vmesa->newRenderState) {
+ viaChooseVertexState(ctx);
+ viaChooseRenderState(ctx);
+ vmesa->newRenderState = 0;
+ }
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
}
static void viaRenderFinish(GLcontext *ctx)
@@ -745,9 +929,8 @@ void viaRasterPrimitive(GLcontext *ctx,
/* assert((vmesa->dmaLow & 0x4) == 0); */
- if (vmesa->dmaCliprectAddr == 0) {
+ if (vmesa->dmaCliprectAddr == ~0) {
if (VIA_DEBUG) fprintf(stderr, "reserve cliprect space at %x\n", vmesa->dmaLow);
- assert(vmesa->dmaLow);
vmesa->dmaCliprectAddr = vmesa->dmaLow;
BEGIN_RING(8);
OUT_RING( HC_HEADER2 );
@@ -793,7 +976,7 @@ void viaFinishPrimitive(viaContextPtr vmesa)
if (VIA_DEBUG)
fprintf(stderr, "%s\n", __FUNCTION__);
- if (!vmesa->dmaLastPrim || !vmesa->dmaCliprectAddr) {
+ if (!vmesa->dmaLastPrim || vmesa->dmaCliprectAddr == ~0) {
assert(0);
}
else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
@@ -832,7 +1015,7 @@ void viaFinishPrimitive(viaContextPtr vmesa)
*/
if (vmesa->dmaCliprectAddr == vmesa->dmaLow - 8 * sizeof(GLuint)) {
vmesa->dmaLow -= 8 * sizeof(GLuint);
- vmesa->dmaCliprectAddr = 0;
+ vmesa->dmaCliprectAddr = ~0;
}
}
@@ -858,7 +1041,6 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
if (mode) {
vmesa->Fallback |= bit;
if (oldfallback == 0) {
- if (VIA_DEBUG) fprintf(stderr, "ENTER FALLBACK\n");
VIA_FLUSH_DMA(vmesa);
_swsetup_Wakeup(ctx);
vmesa->renderIndex = ~0;
@@ -867,15 +1049,26 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
else {
vmesa->Fallback &= ~bit;
if (oldfallback == bit) {
- if (VIA_DEBUG) fprintf(stderr, "LEAVE FALLBACK\n");
+ _swrast_flush( ctx );
+
tnl->Driver.Render.Start = viaRenderStart;
tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
tnl->Driver.Render.Finish = viaRenderFinish;
- tnl->Driver.Render.BuildVertices = viaBuildVertices;
+
+ 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,
+ vmesa->vertex_attrs,
+ vmesa->vertex_attr_count,
+ vmesa->ViewportMatrix.m, 0 );
+
vmesa->newState |= (_VIA_NEW_RENDERSTATE|_VIA_NEW_VERTEX);
}
- }
-
+ }
}
@@ -886,6 +1079,7 @@ void viaFallback(viaContextPtr vmesa, GLuint bit, GLboolean mode)
void viaInitTriFuncs(GLcontext *ctx)
{
+ viaContextPtr vmesa = VIA_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
static int firsttime = 1;
@@ -894,10 +1088,18 @@ void viaInitTriFuncs(GLcontext *ctx)
firsttime = 0;
}
- tnl->Driver.RunPipeline = viaRunPipeline;
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
tnl->Driver.Render.Start = viaRenderStart;
tnl->Driver.Render.Finish = viaRenderFinish;
tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
- tnl->Driver.Render.BuildVertices = viaBuildVertices;
+ 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,
+ (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) );
+
+ vmesa->verts = (char *)tnl->clipspace.vertex_buf;
+
}
diff --git a/src/mesa/drivers/dri/unichrome/via_vb.c b/src/mesa/drivers/dri/unichrome/via_vb.c
deleted file mode 100644
index 0b6830a6bfb..00000000000
--- a/src/mesa/drivers/dri/unichrome/via_vb.c
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
- * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * 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
- * VIA, S3 GRAPHICS, 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.
- */
-
-#include "glheader.h"
-#include "mtypes.h"
-#include "imports.h"
-#include "macros.h"
-#include "colormac.h"
-
-#include "swrast_setup/swrast_setup.h"
-#include "tnl/t_context.h"
-
-#include "via_context.h"
-#include "via_vb.h"
-#include "via_ioctl.h"
-#include "via_tris.h"
-#include "via_state.h"
-
-static struct {
- void (*emit)(GLcontext *, GLuint, GLuint, void *, GLuint);
- tnl_interp_func interp;
- tnl_copy_pv_func copy_pv;
- GLboolean (*check_tex_sizes)(GLcontext *ctx);
- GLuint vertex_size;
- GLuint vertex_format;
-} setup_tab[VIA_MAX_SETUP];
-
-#define TINY_VERTEX_FORMAT 1
-#define NOTEX_VERTEX_FORMAT 2
-#define TEX0_VERTEX_FORMAT 3
-#define TEX1_VERTEX_FORMAT 4
-
-#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 & VIA_XYZW_BIT)
-#define DO_RGBA (IND & VIA_RGBA_BIT)
-#define DO_SPEC (IND & VIA_SPEC_BIT)
-#define DO_FOG (IND & VIA_FOG_BIT)
-#define DO_TEX0 (IND & VIA_TEX0_BIT)
-#define DO_TEX1 (IND & VIA_TEX1_BIT)
-#define DO_TEX2 0
-#define DO_TEX3 0
-#define DO_PTEX (IND & VIA_PTEX_BIT)
-
-#define VERTEX viaVertex
-#define VERTEX_COLOR via_color_t
-#define GET_VIEWPORT_MAT() VIA_CONTEXT(ctx)->ViewportMatrix.m
-#define GET_TEXSOURCE(n) n
-#define GET_VERTEX_FORMAT() VIA_CONTEXT(ctx)->vertexFormat
-#define GET_VERTEX_SIZE() VIA_CONTEXT(ctx)->vertexSize * sizeof(GLuint)
-#define GET_VERTEX_STORE() VIA_CONTEXT(ctx)->verts
-#define INVALIDATE_STORED_VERTICES()
-
-#define HAVE_HW_VIEWPORT 0
-#define HAVE_HW_DIVIDE 0
-#define HAVE_RGBA_COLOR 0
-#define HAVE_TINY_VERTICES 1
-#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 \
- viaContextPtr vmesa = VIA_CONTEXT(ctx); \
- GLfloat h = vmesa->driDrawable->h, depth_max = vmesa->depth_max, xoff = vmesa->drawXoff;
-
-#define UNVIEWPORT_X(x) x - (SUBPIXEL_X + xoff)
-#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
-#define UNVIEWPORT_Z(z) z * (float)depth_max
-
-#define PTEX_FALLBACK() FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_TEXTURE, 1)
-
-#define INTERP_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].interp
-#define COPY_PV_VERTEX setup_tab[VIA_CONTEXT(ctx)->setupIndex].copy_pv
-
-
-/***********************************************************************
- * Generate pv-copying and translation functions *
- ***********************************************************************/
-
-#define TAG(x) via_##x
-#include "tnl_dd/t_dd_vb.c"
-
-/***********************************************************************
- * Generate vertex emit and interp functions *
- ***********************************************************************/
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT)
-#define TAG(x) x##_wg
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT)
-#define TAG(x) x##_wgs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT)
-#define TAG(x) x##_wgt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_TEX1_BIT)
-#define TAG(x) x##_wgt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_PTEX_BIT)
-#define TAG(x) x##_wgpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_TEX0_BIT | VIA_TEX1_BIT |\
- VIA_PTEX_BIT)
-#define TAG(x) x##_wgpt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT)
-#define TAG(x) x##_wgst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
- VIA_TEX1_BIT)
-#define TAG(x) x##_wgst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
- VIA_PTEX_BIT)
-#define TAG(x) x##_wgspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_SPEC_BIT | VIA_TEX0_BIT |\
- VIA_TEX1_BIT | VIA_PTEX_BIT)
-#define TAG(x) x##_wgspt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT)
-#define TAG(x) x##_wgf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT)
-#define TAG(x) x##_wgfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT)
-#define TAG(x) x##_wgft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
- VIA_TEX1_BIT)
-#define TAG(x) x##_wgft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
- VIA_PTEX_BIT)
-#define TAG(x) x##_wgfpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_TEX0_BIT |\
- VIA_TEX1_BIT | VIA_PTEX_BIT)
-#define TAG(x) x##_wgfpt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
- VIA_TEX0_BIT)
-#define TAG(x) x##_wgfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
- VIA_TEX0_BIT | VIA_TEX1_BIT)
-#define TAG(x) x##_wgfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
- VIA_TEX0_BIT | VIA_PTEX_BIT)
-#define TAG(x) x##_wgfspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (VIA_XYZW_BIT | VIA_RGBA_BIT | VIA_FOG_BIT | VIA_SPEC_BIT |\
- VIA_TEX0_BIT | VIA_TEX1_BIT | VIA_PTEX_BIT)
-#define TAG(x) x##_wgfspt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-static void init_setup_tab(void) {
-
- init_wg();
- init_wgs();
- init_wgt0();
- init_wgt0t1();
- init_wgpt0();
- init_wgpt0t1();
- init_wgst0();
- init_wgst0t1();
- init_wgspt0();
- init_wgspt0t1();
- init_wgf();
- init_wgfs();
- init_wgft0();
- init_wgft0t1();
- init_wgfpt0();
- init_wgfpt0t1();
- init_wgfst0();
- init_wgfst0t1();
- init_wgfspt0();
- init_wgfspt0t1();
-}
-
-void viaPrintSetupFlags(char *msg, GLuint flags) {
- if (VIA_DEBUG) fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & VIA_XYZW_BIT) ? " xyzw," : "",
- (flags & VIA_RGBA_BIT) ? " rgba," : "",
- (flags & VIA_SPEC_BIT) ? " spec," : "",
- (flags & VIA_FOG_BIT) ? " fog," : "",
- (flags & VIA_TEX0_BIT) ? " tex-0," : "",
- (flags & VIA_TEX1_BIT) ? " tex-1," : "");
-}
-
-void viaCheckTexSizes(GLcontext *ctx)
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
-
- if (!setup_tab[vmesa->setupIndex].check_tex_sizes(ctx)) {
- /* Invalidate stored verts
- */
- vmesa->setupNewInputs = ~0;
- vmesa->setupIndex |= VIA_PTEX_BIT;
-
- if (!vmesa->Fallback &&
- !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
- tnl->Driver.Render.Interp = setup_tab[vmesa->setupIndex].interp;
- tnl->Driver.Render.CopyPV = setup_tab[vmesa->setupIndex].copy_pv;
- }
-
- if (vmesa->Fallback)
- tnl->Driver.Render.Start(ctx);
- }
- if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__);
-}
-
-void viaBuildVertices(GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint newinputs)
-{
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
- GLuint stride = vmesa->vertexSize * sizeof(GLuint);
- GLubyte *v = (GLubyte *)vmesa->verts + start * stride;
-
- newinputs |= vmesa->setupNewInputs;
- vmesa->setupNewInputs = 0;
-
- if (!newinputs)
- return;
-
- if (newinputs & VERT_BIT_POS) {
- setup_tab[vmesa->setupIndex].emit(ctx, start, count, v, stride);
- }
- else {
- GLuint ind = 0;
-
- if (newinputs & VERT_BIT_COLOR0)
- ind |= VIA_RGBA_BIT;
-
- if (newinputs & VERT_BIT_COLOR1)
- ind |= VIA_SPEC_BIT;
-
- if (newinputs & VERT_BIT_TEX0)
- ind |= VIA_TEX0_BIT;
-
- if (newinputs & VERT_BIT_TEX1)
- ind |= VIA_TEX1_BIT;
-
- if (newinputs & VERT_BIT_FOG)
- ind |= VIA_FOG_BIT;
-
- if (vmesa->setupIndex & VIA_PTEX_BIT)
- ind = ~0;
-
- ind &= vmesa->setupIndex;
- ind |= VIA_XYZW_BIT;
-
- if (ind) {
- setup_tab[ind].emit(ctx, start, count, v, stride);
- }
- }
-}
-
-void viaChooseVertexState(GLcontext *ctx) {
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
- GLuint ind = VIA_XYZW_BIT | VIA_RGBA_BIT;
-
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
- ind |= VIA_SPEC_BIT;
-
- if (ctx->Fog.Enabled)
- ind |= VIA_FOG_BIT;
-
- if (ctx->Texture._EnabledUnits > 1)
- ind |= VIA_TEX1_BIT | VIA_TEX0_BIT;
- else if (ctx->Texture._EnabledUnits == 1)
- ind |= VIA_TEX0_BIT;
-
- vmesa->setupIndex = ind;
- viaPrintSetupFlags(__FUNCTION__, ind);
-
- if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
- tnl->Driver.Render.Interp = via_interp_extras;
- tnl->Driver.Render.CopyPV = via_copy_pv_extras;
- }
- else {
- tnl->Driver.Render.Interp = setup_tab[ind].interp;
- tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
- }
-
- vmesa->vertexSize = setup_tab[ind].vertex_size;
- vmesa->vertexFormat = setup_tab[ind].vertex_format;
-
- if (VIA_DEBUG) fprintf(stderr, "%s, size %d\n", __FUNCTION__, vmesa->vertexSize);
-}
-
-void *via_emit_contiguous_verts(GLcontext *ctx,
- GLuint start,
- GLuint count,
- void *dest)
-{
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
- GLuint stride = vmesa->vertexSize * 4;
- setup_tab[vmesa->setupIndex].emit(ctx, start, count, dest, stride);
- return (void *)((char *)dest + (count - start) * stride);
-}
-
-
-void viaInitVB(GLcontext *ctx)
-{
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
- GLuint size = TNL_CONTEXT(ctx)->vb.Size;
-
- vmesa->verts = ALIGN_MALLOC(size * 4 * 16, 32);
-
- {
- static int firsttime = 1;
- if (firsttime) {
- init_setup_tab();
- firsttime = 0;
- }
- }
-}
-
-void viaFreeVB(GLcontext *ctx) {
- viaContextPtr vmesa = VIA_CONTEXT(ctx);
-
- if (vmesa->verts) {
- ALIGN_FREE(vmesa->verts);
- vmesa->verts = 0;
- }
-}
diff --git a/src/mesa/drivers/dri/unichrome/via_vb.h b/src/mesa/drivers/dri/unichrome/via_vb.h
deleted file mode 100644
index 37397ecc52f..00000000000
--- a/src/mesa/drivers/dri/unichrome/via_vb.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
- * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * 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
- * VIA, S3 GRAPHICS, 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.
- */
-
-#ifndef _VIAVB_H
-#define _VIAVB_H
-
-#include "mtypes.h"
-#include "swrast/swrast.h"
-
-#define VIA_TEX1_BIT 0x0001
-#define VIA_TEX0_BIT 0x0002
-#define VIA_RGBA_BIT 0x0004
-#define VIA_SPEC_BIT 0x0008
-#define VIA_FOG_BIT 0x0010
-#define VIA_XYZW_BIT 0x0020
-#define VIA_PTEX_BIT 0x0040
-#define VIA_MAX_SETUP 0x0080
-
-#define _VIA_NEW_VERTEX (_NEW_TEXTURE | \
- _DD_NEW_SEPARATE_SPECULAR | \
- _DD_NEW_TRI_UNFILLED | \
- _DD_NEW_TRI_LIGHT_TWOSIDE | \
- _NEW_FOG)
-
-
-extern void viaChooseVertexState(GLcontext *ctx);
-extern void viaCheckTexSizes(GLcontext *ctx);
-extern void viaBuildVertices(GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint newinputs);
-
-
-extern void *via_emit_contiguous_verts(GLcontext *ctx,
- GLuint start,
- GLuint count,
- void *dest);
-
-extern void via_translate_vertex(GLcontext *ctx,
- const viaVertex *src,
- SWvertex *dst);
-
-extern void viaInitVB(GLcontext *ctx);
-extern void viaFreeVB(GLcontext *ctx);
-
-extern void via_print_vertex(GLcontext *ctx, const viaVertex *v);
-extern void viaPrintSetupFlags(char *msg, GLuint flags);
-
-#endif