#include "i830_tris.h"
#include "i830_state.h"
-#include "i830_vb.h"
#include "i830_ioctl.h"
#include "i830_span.h"
if (0)
fprintf(stderr, "\n%s\n", __FUNCTION__);
- i830_translate_vertex( ctx, v0, &v[0] );
- i830_translate_vertex( ctx, v1, &v[1] );
- i830_translate_vertex( ctx, v2, &v[2] );
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
i830SpanRenderStart( ctx );
_swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
i830SpanRenderFinish( ctx );
if (0)
fprintf(stderr, "\n%s\n", __FUNCTION__);
- i830_translate_vertex( ctx, v0, &v[0] );
- i830_translate_vertex( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
i830SpanRenderStart( ctx );
_swrast_Line( ctx, &v[0], &v[1] );
i830SpanRenderFinish( ctx );
if (0)
fprintf(stderr, "\n%s\n", __FUNCTION__);
- i830_translate_vertex( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v0, &v[0] );
i830SpanRenderStart( ctx );
_swrast_Point( ctx, &v[0] );
i830SpanRenderFinish( ctx );
}
if (!imesa->Fallback) {
- if (imesa->NewGLState & _I830_NEW_VERTEX)
- i830ChooseVertexState( ctx );
-
if (imesa->NewGLState & _I830_NEW_RENDERSTATE)
i830ChooseRenderState( ctx );
}
_tnl_run_pipeline( ctx );
}
+
+#define TEXCOORDTYPE_MASK (3<<11)
+
+
+
+static void set_projective_texturing( i830ContextPtr imesa,
+ GLuint i,
+ GLuint sz)
+{
+ GLuint mcs = (imesa->CurrentTexObj[i]->Setup[I830_TEXREG_MCS] &
+ ~TEXCOORDTYPE_MASK);
+
+ if (sz == 4) {
+ mcs |= TEXCOORDTYPE_HOMOGENEOUS;
+ } else {
+ mcs |= TEXCOORDTYPE_CARTESIAN;
+ }
+
+ if (mcs != imesa->CurrentTexObj[i]->Setup[I830_TEXREG_MCS]) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_TEX_N(i));
+ imesa->CurrentTexObj[i]->Setup[I830_TEXREG_MCS] = mcs;
+ }
+}
+
+
+#define SZ_TO_HW(sz) ((sz-2)&0x3)
+#define EMIT_SZ(sz) (EMIT_1F + (sz) - 1)
+#define EMIT_ATTR( ATTR, STYLE, V0 ) \
+do { \
+ imesa->vertex_attrs[imesa->vertex_attr_count].attrib = (ATTR); \
+ imesa->vertex_attrs[imesa->vertex_attr_count].format = (STYLE); \
+ imesa->vertex_attr_count++; \
+ v0 |= V0; \
+} while (0)
+
+
+#define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2))
+
+/* Make sure hardware vertex format is appropriate for VB state.
+ */
static void i830RenderStart( GLcontext *ctx )
{
- /* Check for projective textureing. Make sure all texcoord
- * pointers point to something. (fix in mesa?)
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint v0 = STATE3D_VERTEX_FORMAT_CMD;
+ GLuint v2 = STATE3D_VERTEX_FORMAT_2_CMD;
+
+ /* Important:
*/
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ imesa->vertex_attr_count = 0;
- i830CheckTexSizes( ctx );
+ /* 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) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VRTX_HAS_XYZW );
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VRTX_HAS_XYZ );
+ }
+
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, VRTX_HAS_DIFFUSE );
+
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, VRTX_HAS_SPEC );
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VRTX_HAS_SPEC );
+ }
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ int i, last_stage = 0;
+
+ /* Still using 2 as max tex units, but this code is fine for all
+ * 8 units supported by mesa:
+ */
+ for (i = 0; i < 2 ; i++)
+ if (index & _TNL_BIT_TEX(i))
+ last_stage = i+1;
+
+
+ for (i = 0; i < last_stage; i++) {
+ GLuint sz = VB->TexCoordPtr[i]->size;
+
+ v2 |= VRTX_TEX_SET_FMT(i, SZ_TO_HW(sz));
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0 );
+
+ if (imesa->CurrentTexObj[i])
+ set_projective_texturing( imesa, i, sz );
+ }
+
+ v0 |= VRTX_TEX_COORD_COUNT(last_stage);
+ }
+
+ /* Only need to change the vertex emit code if there has been a
+ * statechange to a new hardware vertex format:
+ */
+ if (v0 != imesa->Setup[I830_CTXREG_VF] ||
+ v2 != imesa->Setup[I830_CTXREG_VF2] ) {
+
+ I830_STATECHANGE( imesa, I830_UPLOAD_CTX );
+
+ /* Must do this *after* statechange, so as not to affect
+ * buffered vertices reliant on the old state:
+ */
+ imesa->vertex_size =
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->ViewportMatrix.m, 0 );
+
+ imesa->vertex_size >>= 2;
+
+ imesa->Setup[I830_CTXREG_VF] = v0;
+ imesa->Setup[I830_CTXREG_VF2] = v2;
+ }
}
+
static void i830RenderFinish( GLcontext *ctx )
{
if (I830_CONTEXT(ctx)->RenderIndex & I830_FALLBACK_BIT)
tnl->Driver.Render.Start = i830RenderStart;
tnl->Driver.Render.PrimitiveNotify = i830RenderPrimitive;
tnl->Driver.Render.Finish = i830RenderFinish;
- tnl->Driver.Render.BuildVertices = i830BuildVertices;
- imesa->NewGLState |= (_I830_NEW_RENDERSTATE|_I830_NEW_VERTEX);
+
+ 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->ViewportMatrix.m, 0 );
+
+ imesa->NewGLState |= _I830_NEW_RENDERSTATE;
}
}
}
tnl->Driver.Render.Finish = i830RenderFinish;
tnl->Driver.Render.PrimitiveNotify = i830RenderPrimitive;
tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
- tnl->Driver.Render.BuildVertices = i830BuildVertices;
+ 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) );
+
+ I830_CONTEXT(ctx)->verts = (char *)tnl->clipspace.vertex_buf;
}
+++ /dev/null
-/*
- * GLX Hardware Device Driver for Intel i810
- * Copyright (C) 1999 Keith Whitwell
- *
- * 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
- * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
- *
- * Adapted for use on the I830M:
- * Jeff Hartmann <jhartmann@2d3d.com>
- */
-/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_vb.c,v 1.5 2002/12/10 01:26:54 dawes Exp $ */
-
-#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 "i830_screen.h"
-#include "i830_dri.h"
-
-#include "i830_context.h"
-#include "i830_vb.h"
-#include "i830_ioctl.h"
-#include "i830_tris.h"
-#include "i830_state.h"
-
-#define I830_TEX1_BIT 0x1
-#define I830_TEX0_BIT 0x2
-#define I830_RGBA_BIT 0x4
-#define I830_SPEC_BIT 0x8
-#define I830_FOG_BIT 0x10
-#define I830_XYZW_BIT 0x20
-#define I830_PTEX_BIT 0x40
-#define I830_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[I830_MAX_SETUP];
-
-#define TINY_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
- VRTX_TEX_COORD_COUNT(0) | \
- VRTX_HAS_DIFFUSE | \
- VRTX_HAS_XYZ)
-
-#define NOTEX_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
- VRTX_TEX_COORD_COUNT(0) | \
- VRTX_HAS_DIFFUSE | \
- VRTX_HAS_SPEC | \
- VRTX_HAS_XYZW)
-
-#define TEX0_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
- VRTX_TEX_COORD_COUNT(1) | \
- VRTX_HAS_DIFFUSE | \
- VRTX_HAS_SPEC | \
- VRTX_HAS_XYZW)
-
-#define TEX1_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
- VRTX_TEX_COORD_COUNT(2) | \
- VRTX_HAS_DIFFUSE | \
- VRTX_HAS_SPEC | \
- VRTX_HAS_XYZW)
-
-
-/* I'm cheating here hardcore : if bit 31 is set I know to emit
- * a vf2 state == TEXCOORDFMT_3D. We never mix 2d/3d texcoords,
- * so this solution works for now.
- */
-
-#define PROJ_TEX1_VERTEX_FORMAT ((1<<31) | \
- STATE3D_VERTEX_FORMAT_CMD | \
- VRTX_TEX_COORD_COUNT(2) | \
- VRTX_HAS_DIFFUSE | \
- VRTX_HAS_SPEC | \
- VRTX_HAS_XYZW)
-
-/* Might want to do these later */
-#define TEX2_VERTEX_FORMAT 0
-#define TEX3_VERTEX_FORMAT 0
-#define PROJ_TEX3_VERTEX_FORMAT 0
-
-#define DO_XYZW (IND & I830_XYZW_BIT)
-#define DO_RGBA (IND & I830_RGBA_BIT)
-#define DO_SPEC (IND & I830_SPEC_BIT)
-#define DO_FOG (IND & I830_FOG_BIT)
-#define DO_TEX0 (IND & I830_TEX0_BIT)
-#define DO_TEX1 (IND & I830_TEX1_BIT)
-#define DO_TEX2 0
-#define DO_TEX3 0
-#define DO_PTEX (IND & I830_PTEX_BIT)
-
-#define VERTEX i830Vertex
-#define VERTEX_COLOR i830_color_t
-#define GET_VIEWPORT_MAT() I830_CONTEXT(ctx)->ViewportMatrix.m
-#define GET_TEXSOURCE(n) n
-#define GET_VERTEX_FORMAT() I830_CONTEXT(ctx)->vertex_format
-#define GET_VERTEX_STORE() ((GLubyte *)I830_CONTEXT(ctx)->verts)
-#define GET_VERTEX_SIZE() I830_CONTEXT(ctx)->vertex_size * sizeof(int)
-#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 1
-
-#define UNVIEWPORT_VARS GLfloat h = I830_CONTEXT(ctx)->driDrawable->h
-#define UNVIEWPORT_X(x) x - SUBPIXEL_X
-#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
-#define UNVIEWPORT_Z(z) z * (float)I830_CONTEXT(ctx)->ClearDepth
-
-#define PTEX_FALLBACK() FALLBACK(I830_CONTEXT(ctx), I830_FALLBACK_TEXTURE, 1)
-
-#define INTERP_VERTEX setup_tab[I830_CONTEXT(ctx)->SetupIndex].interp
-#define COPY_PV_VERTEX setup_tab[I830_CONTEXT(ctx)->SetupIndex].copy_pv
-
-
-/***********************************************************************
- * Generate pv-copying and translation functions *
- ***********************************************************************/
-
-#define TAG(x) i830_##x
-#include "tnl_dd/t_dd_vb.c"
-
-/***********************************************************************
- * Generate vertex emit and interp functions *
- ***********************************************************************/
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT)
-#define TAG(x) x##_wg
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_SPEC_BIT)
-#define TAG(x) x##_wgs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_wgt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_wgt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_TEX0_BIT|I830_PTEX_BIT)
-#define TAG(x) x##_wgpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_SPEC_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_wgst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_SPEC_BIT|I830_TEX0_BIT|\
- I830_TEX1_BIT)
-#define TAG(x) x##_wgst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_SPEC_BIT|I830_TEX0_BIT|\
- I830_PTEX_BIT)
-#define TAG(x) x##_wgspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT)
-#define TAG(x) x##_wgf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT)
-#define TAG(x) x##_wgfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_wgft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_TEX0_BIT|\
- I830_TEX1_BIT)
-#define TAG(x) x##_wgft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_TEX0_BIT|\
- I830_PTEX_BIT)
-#define TAG(x) x##_wgfpt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT|\
- I830_TEX0_BIT)
-#define TAG(x) x##_wgfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT|\
- I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_wgfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT|\
- I830_TEX0_BIT|I830_PTEX_BIT)
-#define TAG(x) x##_wgfspt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_TEX0_BIT)
-#define TAG(x) x##_t0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_t0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_FOG_BIT)
-#define TAG(x) x##_f
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_FOG_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_ft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_FOG_BIT|I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_ft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT)
-#define TAG(x) x##_g
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_SPEC_BIT)
-#define TAG(x) x##_gs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_gt0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_gt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_SPEC_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_gst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_SPEC_BIT|I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_gst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_FOG_BIT)
-#define TAG(x) x##_gf
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT)
-#define TAG(x) x##_gfs
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_FOG_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_gft0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_FOG_BIT|I830_TEX0_BIT|I830_TEX1_BIT)
-#define TAG(x) x##_gft0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT|I830_TEX0_BIT)
-#define TAG(x) x##_gfst0
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT|I830_TEX0_BIT|\
- I830_TEX1_BIT)
-#define TAG(x) x##_gfst0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-/* Add functions for proj texturing for t0 and t1 */
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_TEX0_BIT|I830_TEX1_BIT|\
- I830_PTEX_BIT)
-#define TAG(x) x##_wgpt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_SPEC_BIT|I830_TEX0_BIT|\
- I830_TEX1_BIT|I830_PTEX_BIT)
-#define TAG(x) x##_wgspt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_TEX0_BIT|\
- I830_TEX1_BIT|I830_PTEX_BIT)
-#define TAG(x) x##_wgfpt0t1
-#include "tnl_dd/t_dd_vbtmp.h"
-
-#define IND (I830_XYZW_BIT|I830_RGBA_BIT|I830_FOG_BIT|I830_SPEC_BIT|\
- I830_TEX1_BIT|I830_TEX0_BIT|I830_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_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();
- /* Add proj texturing on t1 */
- init_wgpt0t1();
- init_wgspt0t1();
- init_wgfpt0t1();
- init_wgfspt0t1();
-}
-
-
-
-void i830PrintSetupFlags(char *msg, GLuint flags )
-{
- fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s\n",
- msg,
- (int)flags,
- (flags & I830_XYZW_BIT) ? " xyzw," : "",
- (flags & I830_RGBA_BIT) ? " rgba," : "",
- (flags & I830_SPEC_BIT) ? " spec," : "",
- (flags & I830_FOG_BIT) ? " fog," : "",
- (flags & I830_TEX0_BIT) ? " tex-0," : "",
- (flags & I830_TEX1_BIT) ? " tex-1," : "",
- (flags & I830_PTEX_BIT) ? " ptex," : "");
-}
-
-void i830CheckTexSizes( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- i830ContextPtr imesa = I830_CONTEXT( ctx );
-
- if (!setup_tab[imesa->SetupIndex].check_tex_sizes(ctx)) {
- int ind = imesa->SetupIndex |= I830_PTEX_BIT;
-
- if(setup_tab[ind].vertex_format != imesa->vertex_format) {
- int vfmt = setup_tab[ind].vertex_format;
-
- I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
- imesa->Setup[I830_CTXREG_VF] = ~(1<<31) & vfmt;
-
- if (vfmt & (1<<31)) {
- /* Proj texturing */
- imesa->Setup[I830_CTXREG_VF2] = (STATE3D_VERTEX_FORMAT_2_CMD |
- VRTX_TEX_SET_0_FMT(TEXCOORDFMT_3D) |
- VRTX_TEX_SET_1_FMT(TEXCOORDFMT_3D) |
- VRTX_TEX_SET_2_FMT(TEXCOORDFMT_3D) |
- VRTX_TEX_SET_3_FMT(TEXCOORDFMT_3D));
- i830UpdateTexUnitProj( ctx, 0, GL_TRUE );
- i830UpdateTexUnitProj( ctx, 1, GL_TRUE );
-
- } else {
- /* Normal texturing */
- imesa->Setup[I830_CTXREG_VF2] = (STATE3D_VERTEX_FORMAT_2_CMD |
- VRTX_TEX_SET_0_FMT(TEXCOORDFMT_2D) |
- VRTX_TEX_SET_1_FMT(TEXCOORDFMT_2D) |
- VRTX_TEX_SET_2_FMT(TEXCOORDFMT_2D) |
- VRTX_TEX_SET_3_FMT(TEXCOORDFMT_2D));
- i830UpdateTexUnitProj( ctx, 0, GL_FALSE );
- i830UpdateTexUnitProj( ctx, 1, GL_FALSE );
- }
- imesa->vertex_format = vfmt;
- imesa->vertex_size = setup_tab[ind].vertex_size;
- }
-
- 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;
- }
- }
-}
-
-void i830BuildVertices( GLcontext *ctx,
- GLuint start,
- GLuint count,
- GLuint newinputs )
-{
- i830ContextPtr imesa = I830_CONTEXT( ctx );
- GLuint stride = imesa->vertex_size * sizeof(int);
- GLubyte *v = ((GLubyte *) imesa->verts + (start * stride));
-
- if (0) fprintf(stderr, "%s\n", __FUNCTION__);
-
- 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 |= I830_RGBA_BIT;
-
- if (newinputs & VERT_BIT_COLOR1)
- ind |= I830_SPEC_BIT;
-
- if (newinputs & VERT_BIT_TEX0)
- ind |= I830_TEX0_BIT;
-
- if (newinputs & VERT_BIT_TEX1)
- ind |= I830_TEX1_BIT;
-
- if (newinputs & VERT_BIT_FOG)
- ind |= I830_FOG_BIT;
-
-#if 0
- if (imesa->SetupIndex & I830_PTEX_BIT)
- ind = ~0;
-#endif
-
- ind &= imesa->SetupIndex;
-
- if (ind) {
- setup_tab[ind].emit( ctx, start, count, v, stride );
- }
- }
-}
-
-void i830ChooseVertexState( GLcontext *ctx )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- i830ContextPtr imesa = I830_CONTEXT( ctx );
- GLuint ind = I830_XYZW_BIT|I830_RGBA_BIT;
-
- if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
- ind |= I830_SPEC_BIT;
-
- if (ctx->Fog.Enabled)
- ind |= I830_FOG_BIT;
-
- if (ctx->Texture._EnabledUnits & 0x2)
- /* unit 1 enabled */
- ind |= I830_TEX1_BIT|I830_TEX0_BIT;
- else if (ctx->Texture._EnabledUnits & 0x1)
- /* unit 0 enabled */
- ind |= I830_TEX0_BIT;
-
- imesa->SetupIndex = ind;
-
- if (I830_DEBUG & (DEBUG_VERTS|DEBUG_STATE))
- i830PrintSetupFlags( __FUNCTION__, ind );
-
- if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
- tnl->Driver.Render.Interp = i830_interp_extras;
- tnl->Driver.Render.CopyPV = i830_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 != imesa->vertex_format) {
- int vfmt = setup_tab[ind].vertex_format;
-
- I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
- imesa->Setup[I830_CTXREG_VF] = ~(1<<31) & vfmt;
-
- if (vfmt & (1<<31)) {
- /* Proj texturing */
- imesa->Setup[I830_CTXREG_VF2] = (STATE3D_VERTEX_FORMAT_2_CMD |
- VRTX_TEX_SET_0_FMT(TEXCOORDFMT_3D) |
- VRTX_TEX_SET_1_FMT(TEXCOORDFMT_3D) |
- VRTX_TEX_SET_2_FMT(TEXCOORDFMT_3D) |
- VRTX_TEX_SET_3_FMT(TEXCOORDFMT_3D));
- i830UpdateTexUnitProj( ctx, 0, GL_TRUE );
- i830UpdateTexUnitProj( ctx, 1, GL_TRUE );
- } else {
- /* Normal texturing */
- imesa->Setup[I830_CTXREG_VF2] = (STATE3D_VERTEX_FORMAT_2_CMD |
- VRTX_TEX_SET_0_FMT(TEXCOORDFMT_2D) |
- VRTX_TEX_SET_1_FMT(TEXCOORDFMT_2D) |
- VRTX_TEX_SET_2_FMT(TEXCOORDFMT_2D) |
- VRTX_TEX_SET_3_FMT(TEXCOORDFMT_2D));
- i830UpdateTexUnitProj( ctx, 0, GL_FALSE );
- i830UpdateTexUnitProj( ctx, 1, GL_FALSE );
- }
- imesa->vertex_format = vfmt;
- imesa->vertex_size = setup_tab[ind].vertex_size;
- }
-}
-
-
-
-void *i830_emit_contiguous_verts( GLcontext *ctx,
- GLuint start,
- GLuint count,
- void *dest)
-{
- i830ContextPtr imesa = I830_CONTEXT(ctx);
- GLuint stride = imesa->vertex_size * 4;
- setup_tab[imesa->SetupIndex].emit( ctx, start, count, dest, stride );
- return (void *)((char *)dest + stride * (count - start));
-}
-
-
-
-void i830InitVB( GLcontext *ctx )
-{
- i830ContextPtr imesa = I830_CONTEXT(ctx);
- GLuint size = TNL_CONTEXT(ctx)->vb.Size;
-
- imesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
-
- {
- static int firsttime = 1;
- if (firsttime) {
- init_setup_tab();
- firsttime = 0;
- }
- }
-}
-
-
-void i830FreeVB( GLcontext *ctx )
-{
- i830ContextPtr imesa = I830_CONTEXT(ctx);
- if (imesa->verts) {
- ALIGN_FREE(imesa->verts);
- imesa->verts = 0;
- }
-}