summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2000-11-16 21:05:34 +0000
committerKeith Whitwell <[email protected]>2000-11-16 21:05:34 +0000
commit23caf20169ac38436ee9c13914f1d6aa7cf6bb5e (patch)
tree21307f7bbcaf9ee1e841d7e7bee130570a7b5b95 /src/mesa/main
parent179516673211a2350e479d5321840291f339f5dd (diff)
Move the transform and lighting code to two new directories
math: Provides basic matrix and vector functionality that might be useful to multiple software t&l implementations, and is used by core mesa to manage the Model, Project, etc matrices. tnl: The real transform & lighting code from core mesa, including everything from glVertex3f through vertex buffer handling, transformation, clipping, lighting and handoff to a driver for rasterization. The interfaces of these can be further tightened up, but the basic splitting up of state and code move is done.
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/Makefile.X1151
-rw-r--r--src/mesa/main/attrib.c6
-rw-r--r--src/mesa/main/clip.c417
-rw-r--r--src/mesa/main/clip.h57
-rw-r--r--src/mesa/main/colormac.h5
-rw-r--r--src/mesa/main/context.c250
-rw-r--r--src/mesa/main/context.h21
-rw-r--r--src/mesa/main/dd.h127
-rw-r--r--src/mesa/main/debug.c89
-rw-r--r--src/mesa/main/debug.h8
-rw-r--r--src/mesa/main/dlist.c869
-rw-r--r--src/mesa/main/dlist.h14
-rw-r--r--src/mesa/main/drawpix.c8
-rw-r--r--src/mesa/main/enable.c24
-rw-r--r--src/mesa/main/eval.c1397
-rw-r--r--src/mesa/main/eval.h39
-rw-r--r--src/mesa/main/fog.c104
-rw-r--r--src/mesa/main/fog.h6
-rw-r--r--src/mesa/main/get.c66
-rw-r--r--src/mesa/main/light.c150
-rw-r--r--src/mesa/main/light.h28
-rw-r--r--src/mesa/main/lines.c3
-rw-r--r--src/mesa/main/macros.h4
-rw-r--r--src/mesa/main/matrix.c1151
-rw-r--r--src/mesa/main/matrix.h33
-rw-r--r--src/mesa/main/points.c3
-rw-r--r--src/mesa/main/rastpos.c203
-rw-r--r--src/mesa/main/state.c204
-rw-r--r--src/mesa/main/texstate.c29
-rw-r--r--src/mesa/main/texstate.h4
-rw-r--r--src/mesa/main/varray.c745
-rw-r--r--src/mesa/main/varray.h46
32 files changed, 1179 insertions, 4982 deletions
diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11
index 533e0c32d95..acec47b09ca 100644
--- a/src/mesa/main/Makefile.X11
+++ b/src/mesa/main/Makefile.X11
@@ -1,4 +1,4 @@
-# $Id: Makefile.X11,v 1.32 2000/11/11 19:09:29 brianp Exp $
+# $Id: Makefile.X11,v 1.33 2000/11/16 21:05:34 keithw Exp $
# Mesa 3-D graphics library
# Version: 3.5
@@ -21,10 +21,31 @@ LIBDIR = ../lib
CORE_SOURCES = \
+ tnl/t_bbox.c \
+ tnl/t_clip.c \
+ tnl/t_context.c \
+ tnl/t_cva.c \
+ tnl/t_debug.c \
+ tnl/t_dlist.c \
+ tnl/t_eval.c \
+ tnl/t_fog.c \
+ tnl/t_light.c \
+ tnl/t_pipeline.c \
+ tnl/t_rect.c \
+ tnl/t_shade.c \
+ tnl/t_stages.c \
+ tnl/t_texture.c \
+ tnl/t_trans_elt.c \
+ tnl/t_varray.c \
+ tnl/t_vb.c \
+ tnl/t_vbcull.c \
+ tnl/t_vbfill.c \
+ tnl/t_vbindirect.c \
+ tnl/t_vbrender.c \
+ tnl/t_vbxform.c \
accum.c \
alpha.c \
attrib.c \
- bbox.c \
bitmap.c \
blend.c \
buffers.c \
@@ -34,8 +55,7 @@ CORE_SOURCES = \
context.c \
convolve.c \
copypix.c \
- cva.c \
- debug_xform.c \
+ debug.c \
depth.c \
dispatch.c \
dlist.c \
@@ -64,7 +84,6 @@ CORE_SOURCES = \
matrix.c \
mem.c \
mmath.c \
- pipeline.c \
pixel.c \
pixeltex.c \
points.c \
@@ -73,8 +92,6 @@ CORE_SOURCES = \
readpix.c \
rect.c \
scissor.c \
- shade.c \
- stages.c \
state.c \
stencil.c \
teximage.c \
@@ -82,18 +99,8 @@ CORE_SOURCES = \
texstate.c \
texture.c \
texutil.c \
- translate.c \
varray.c \
- vb.c \
- vbcull.c \
- vbfill.c \
- vbindirect.c \
- vbrender.c \
- vbxform.c \
- vector.c \
- vertices.c \
winpos.c \
- xform.c \
X86/x86.c \
X86/common_x86.c \
X86/3dnow.c \
@@ -129,9 +136,13 @@ CORE_SOURCES = \
swrast/s_zoom.c \
swrast_setup/ss_context.c \
swrast_setup/ss_triangle.c \
- swrast_setup/ss_vb.c
-
-
+ swrast_setup/ss_vb.c \
+ math/m_debug_xform.c \
+ math/m_matrix.c \
+ math/m_translate.c \
+ math/m_vector.c \
+ math/m_vertices.c \
+ math/m_xform.c
diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 66557b1066b..b6c5174def7 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1,4 +1,4 @@
-/* $Id: attrib.c,v 1.33 2000/11/05 18:40:57 keithw Exp $ */
+/* $Id: attrib.c,v 1.34 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -136,6 +136,9 @@ _mesa_PushAttrib(GLbitfield mask)
if (mask & GL_CURRENT_BIT) {
struct gl_current_attrib *attr;
+
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
+
attr = MALLOC_STRUCT( gl_current_attrib );
MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) );
newnode = new_attrib_node( GL_CURRENT_BIT );
@@ -612,6 +615,7 @@ _mesa_PopAttrib(void)
}
break;
case GL_CURRENT_BIT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
MEMCPY( &ctx->Current, attr->data,
sizeof(struct gl_current_attrib) );
break;
diff --git a/src/mesa/main/clip.c b/src/mesa/main/clip.c
index 244753020b1..77d12814055 100644
--- a/src/mesa/main/clip.c
+++ b/src/mesa/main/clip.c
@@ -1,4 +1,4 @@
-/* $Id: clip.c,v 1.14 2000/11/13 20:02:56 keithw Exp $ */
+/* $Id: clip.c,v 1.15 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -30,133 +30,16 @@
#else
#include "glheader.h"
#include "clip.h"
-#include "colormac.h"
#include "context.h"
#include "macros.h"
-#include "matrix.h"
#include "mmath.h"
#include "types.h"
-#include "vb.h"
-#include "xform.h"
-#endif
-
-
-
-
-#define CLIP_RGBA0 0x1
-#define CLIP_RGBA1 0x2
-#define CLIP_TEX0 0x4
-#define CLIP_TEX1 0x8
-#define CLIP_INDEX0 0x10
-#define CLIP_INDEX1 0x20
-#define CLIP_FOG_COORD 0x40
-
-
-/* Linear interpolation between A and B: */
-#define LINTERP( T, A, B ) ( (A) + (T) * ( (B) - (A) ) )
-
-
-
-#define INTERP_SZ( t, vec, to, a, b, sz ) \
-do { \
- switch (sz) { \
- case 4: vec[to][3] = LINTERP( t, vec[a][3], vec[b][3] ); \
- case 3: vec[to][2] = LINTERP( t, vec[a][2], vec[b][2] ); \
- case 2: vec[to][1] = LINTERP( t, vec[a][1], vec[b][1] ); \
- case 1: vec[to][0] = LINTERP( t, vec[a][0], vec[b][0] ); \
- } \
-} while(0)
-
-
-static clip_interp_func clip_interp_tab[0x80];
-
-#define IND 0
-#define NAME clip_nil
-#include "interp_tmp.h"
-
-#define IND (CLIP_RGBA0)
-#define NAME clipRGBA0
-#include "interp_tmp.h"
-
-#define IND (CLIP_RGBA0|CLIP_RGBA1)
-#define NAME clipRGBA0_RGBA1
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX0|CLIP_RGBA0)
-#define NAME clipTEX0_RGBA0
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1)
-#define NAME clipTEX0_RGBA0_RGBA1
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0)
-#define NAME clipTEX1_TEX0_RGBA0
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX0)
-#define NAME clipTEX0
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX1|CLIP_TEX0)
-#define NAME clipTEX1_TEX0
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1)
-#define NAME clipTEX1_TEX0_RGBA0_RGBA1
-#include "interp_tmp.h"
-
-#define IND (CLIP_INDEX0)
-#define NAME clipINDEX0
-#include "interp_tmp.h"
-
-#define IND (CLIP_INDEX0|CLIP_INDEX1)
-#define NAME clipINDEX0_INDEX1
-#include "interp_tmp.h"
-
-#define IND (CLIP_FOG_COORD)
-#define NAME clip_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_RGBA0|CLIP_FOG_COORD)
-#define NAME clipRGBA0_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
-#define NAME clipRGBA0_RGBA1_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
-#define NAME clipTEX0_RGBA0_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
-#define NAME clipTEX0_RGBA0_RGBA1_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD)
-#define NAME clipTEX1_TEX0_RGBA0_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX0|CLIP_FOG_COORD)
-#define NAME clipTEX0_FOG
-#include "interp_tmp.h"
-#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD)
-#define NAME clipTEX1_TEX0_FOG
-#include "interp_tmp.h"
-
-#define IND (CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD)
-#define NAME clipTEX1_TEX0_RGBA0_RGBA1_FOG
-#include "interp_tmp.h"
+#include "math/m_xform.h"
+#include "math/m_matrix.h"
+#endif
-#define IND (CLIP_INDEX0|CLIP_FOG_COORD)
-#define NAME clipINDEX0_FOG
-#include "interp_tmp.h"
-#define IND (CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD)
-#define NAME clipINDEX0_INDEX1_FOG
-#include "interp_tmp.h"
@@ -173,12 +56,6 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
GET_CURRENT_CONTEXT(ctx);
GLint p;
GLfloat equation[4];
-
- equation[0] = eq[0];
- equation[1] = eq[1];
- equation[2] = eq[2];
- equation[3] = eq[3];
-
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glClipPlane");
p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
@@ -187,6 +64,11 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
return;
}
+ equation[0] = eq[0];
+ equation[1] = eq[1];
+ equation[2] = eq[2];
+ equation[3] = eq[3];
+
/*
* The equation is transformed by the transpose of the inverse of the
* current modelview matrix and stored in the resulting eye coordinates.
@@ -195,17 +77,21 @@ _mesa_ClipPlane( GLenum plane, const GLdouble *eq )
* clipping now takes place. The clip-space equations are recalculated
* whenever the projection matrix changes.
*/
- if (ctx->ModelView.flags & MAT_DIRTY_ALL_OVER) {
- gl_matrix_analyze( &ctx->ModelView );
- }
+ if (ctx->ModelView.flags & MAT_DIRTY)
+ _math_matrix_analyze( &ctx->ModelView );
+
gl_transform_vector( ctx->Transform.EyeUserPlane[p], equation,
ctx->ModelView.inv );
+ /* Update derived state. This state also depends on the projection
+ * matrix, and is recalculated on changes to the projection matrix by
+ * code in gl_update_state().
+ */
if (ctx->Transform.ClipEnabled[p]) {
- if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
- gl_matrix_analyze( &ctx->ProjectionMatrix );
- }
+ if (ctx->ProjectionMatrix.flags & MAT_DIRTY)
+ _math_matrix_analyze( &ctx->ProjectionMatrix );
+
gl_transform_vector( ctx->Transform._ClipUserPlane[p],
ctx->Transform.EyeUserPlane[p],
ctx->ProjectionMatrix.inv );
@@ -235,268 +121,3 @@ _mesa_GetClipPlane( GLenum plane, GLdouble *equation )
equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2];
equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3];
}
-
-
-
-
-/**********************************************************************/
-/* View volume clipping. */
-/**********************************************************************/
-
-
-/*
- * Clip a point against the view volume.
- * Input: v - vertex-vector describing the point to clip
- * Return: 0 = outside view volume
- * 1 = inside view volume
- */
-GLuint gl_viewclip_point( const GLfloat v[] )
-{
- if ( v[0] > v[3] || v[0] < -v[3]
- || v[1] > v[3] || v[1] < -v[3]
- || v[2] > v[3] || v[2] < -v[3] ) {
- return 0;
- }
- else {
- return 1;
- }
-}
-
-/*
- * Clip a point against the user clipping planes.
- * Input: v - vertex-vector describing the point to clip.
- * Return: 0 = point was clipped
- * 1 = point not clipped
- */
-GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] )
-{
- GLuint p;
-
- for (p=0;p<MAX_CLIP_PLANES;p++) {
- if (ctx->Transform.ClipEnabled[p]) {
- GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
- + v[1] * ctx->Transform._ClipUserPlane[p][1]
- + v[2] * ctx->Transform._ClipUserPlane[p][2]
- + v[3] * ctx->Transform._ClipUserPlane[p][3];
- if (dot < 0.0F) {
- return 0;
- }
- }
- }
-
- return 1;
-}
-
-
-
-
-#if 0
-#define NEGATIVE(x) ((*(int *)&x)<0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#else
-#define NEGATIVE(x) (x < 0)
-#define DIFFERENT_SIGNS(a,b) ((a*b) < 0)
-#endif
-
-
-static clip_poly_func gl_poly_clip_tab[2][5];
-static clip_line_func gl_line_clip_tab[2][5];
-
-#define W(i) coord[i][3]
-#define Z(i) coord[i][2]
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 4
-#define IND 0
-#define TAG(x) x##_4
-#include "clip_funcs.h"
-
-#define W(i) 1.0
-#define Z(i) coord[i][2]
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 3
-#define IND 0
-#define TAG(x) x##_3
-#include "clip_funcs.h"
-
-#define W(i) 1.0
-#define Z(i) 0.0
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 2
-#define IND 0
-#define TAG(x) x##_2
-#include "clip_funcs.h"
-
-#define W(i) coord[i][3]
-#define Z(i) coord[i][2]
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 4
-#define IND CLIP_TAB_EDGEFLAG
-#define TAG(x) x##_4_edgeflag
-#include "clip_funcs.h"
-
-#define W(i) 1.0
-#define Z(i) coord[i][2]
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 3
-#define IND CLIP_TAB_EDGEFLAG
-#define TAG(x) x##_3_edgeflag
-#include "clip_funcs.h"
-
-#define W(i) 1.0
-#define Z(i) 0.0
-#define Y(i) coord[i][1]
-#define X(i) coord[i][0]
-#define SIZE 2
-#define IND CLIP_TAB_EDGEFLAG
-#define TAG(x) x##_2_edgeflag
-#include "clip_funcs.h"
-
-
-
-
-void gl_update_clipmask( GLcontext *ctx )
-{
- GLuint mask = 0;
-
- if (ctx->Visual.RGBAflag)
- {
- mask |= CLIP_RGBA0;
-
- if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_SEPERATE_SPECULAR))
- mask |= CLIP_RGBA1;
-
- if (ctx->Texture._ReallyEnabled & 0xf0)
- mask |= CLIP_TEX1|CLIP_TEX0;
-
- if (ctx->Texture._ReallyEnabled & 0xf)
- mask |= CLIP_TEX0;
- }
- else if (ctx->Light.ShadeModel==GL_SMOOTH)
- {
- mask |= CLIP_INDEX0;
-
- if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
- mask |= CLIP_INDEX1;
- }
-
- if (ctx->Fog.Enabled)
- mask |= CLIP_FOG_COORD;
-
- ctx->_ClipInterpFunc = clip_interp_tab[mask];
- ctx->_poly_clip_tab = gl_poly_clip_tab[0];
- ctx->_line_clip_tab = gl_line_clip_tab[0];
-
- if (ctx->_TriangleCaps & DD_TRI_UNFILLED) {
- ctx->_poly_clip_tab = gl_poly_clip_tab[1];
- ctx->_line_clip_tab = gl_line_clip_tab[0];
- }
-}
-
-
-#define USER_CLIPTEST(NAME, SZ) \
-static void NAME( struct vertex_buffer *VB ) \
-{ \
- GLcontext *ctx = VB->ctx; \
- GLubyte *clipMask = VB->ClipMask; \
- GLubyte *userClipMask = VB->UserClipMask; \
- GLuint start = VB->Start; \
- GLuint count = VB->Count; \
- GLuint p, i; \
- GLubyte bit; \
- \
- \
- for (bit = 1, p = 0; p < MAX_CLIP_PLANES ; p++, bit *=2) \
- if (ctx->Transform.ClipEnabled[p]) { \
- GLuint nr = 0; \
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; \
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; \
- GLfloat *coord = VB->ClipPtr->start; \
- GLuint stride = VB->ClipPtr->stride; \
- \
- for (i = start ; i < count ; i++, STRIDE_F(coord, stride)) { \
- GLfloat dp = coord[0] * a + coord[1] * b; \
- if (SZ > 2) dp += coord[2] * c; \
- if (SZ > 3) dp += coord[3] * d; else dp += d; \
- \
- if (dp < 0) { \
- clipMask[i] |= CLIP_USER_BIT; \
- userClipMask[i] |= bit; \
- nr++; \
- } \
- } \
- \
- if (nr > 0) { \
- VB->ClipOrMask |= CLIP_USER_BIT; \
- VB->CullMode |= CLIP_MASK_ACTIVE; \
- if (nr == count - start) { \
- VB->ClipAndMask |= CLIP_USER_BIT; \
- VB->Culled = 1; \
- return; \
- } \
- } \
- } \
-}
-
-
-USER_CLIPTEST(userclip2, 2)
-USER_CLIPTEST(userclip3, 3)
-USER_CLIPTEST(userclip4, 4)
-
-static void (*(usercliptab[5]))( struct vertex_buffer * ) = {
- 0,
- 0,
- userclip2,
- userclip3,
- userclip4
-};
-
-void gl_user_cliptest( struct vertex_buffer *VB )
-{
- usercliptab[VB->ClipPtr->size]( VB );
-}
-
-
-void gl_init_clip(void)
-{
- init_clip_funcs_4();
- init_clip_funcs_3();
- init_clip_funcs_2();
-
- init_clip_funcs_4_edgeflag();
- init_clip_funcs_3_edgeflag();
- init_clip_funcs_2_edgeflag();
-
- clip_interp_tab[0] = clip_nil;
- clip_interp_tab[CLIP_RGBA0] = clipRGBA0;
- clip_interp_tab[CLIP_RGBA0|CLIP_RGBA1] = clipRGBA0_RGBA1;
- clip_interp_tab[CLIP_TEX0|CLIP_RGBA0] = clipTEX0_RGBA0;
- clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1] = clipTEX0_RGBA0_RGBA1;
- clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0] = clipTEX1_TEX0_RGBA0;
- clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1] =
- clipTEX1_TEX0_RGBA0_RGBA1;
- clip_interp_tab[CLIP_TEX0] = clipTEX0;
- clip_interp_tab[CLIP_TEX1|CLIP_TEX0] = clipTEX1_TEX0;
- clip_interp_tab[CLIP_INDEX0] = clipINDEX0;
- clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1] = clipINDEX0_INDEX1;
-
- clip_interp_tab[CLIP_FOG_COORD] = clip_FOG;
- clip_interp_tab[CLIP_RGBA0|CLIP_FOG_COORD] = clipRGBA0_FOG;
- clip_interp_tab[CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipRGBA0_RGBA1_FOG;
- clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX0_RGBA0_FOG;
- clip_interp_tab[CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] = clipTEX0_RGBA0_RGBA1_FOG;
- clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_FOG_COORD] = clipTEX1_TEX0_RGBA0_FOG;
- clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_RGBA0|CLIP_RGBA1|CLIP_FOG_COORD] =
- clipTEX1_TEX0_RGBA0_RGBA1_FOG;
- clip_interp_tab[CLIP_TEX0|CLIP_FOG_COORD] = clipTEX0_FOG;
- clip_interp_tab[CLIP_TEX1|CLIP_TEX0|CLIP_FOG_COORD] = clipTEX1_TEX0_FOG;
- clip_interp_tab[CLIP_INDEX0|CLIP_FOG_COORD] = clipINDEX0_FOG;
- clip_interp_tab[CLIP_INDEX0|CLIP_INDEX1|CLIP_FOG_COORD] = clipINDEX0_INDEX1_FOG;
-}
-
diff --git a/src/mesa/main/clip.h b/src/mesa/main/clip.h
index abf2f7e9ce0..a44d6d0fe12 100644
--- a/src/mesa/main/clip.h
+++ b/src/mesa/main/clip.h
@@ -1,4 +1,4 @@
-/* $Id: clip.h,v 1.3 1999/11/11 01:22:25 brianp Exp $ */
+/* $Id: clip.h,v 1.4 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,65 +31,10 @@
#ifndef CLIP_H
#define CLIP_H
-
#include "types.h"
-
-
-#ifdef DEBUG
-# define GL_VIEWCLIP_POINT( V ) gl_viewclip_point( V )
-#else
-# define GL_VIEWCLIP_POINT( V ) \
- ( (V)[0] <= (V)[3] && (V)[0] >= -(V)[3] \
- && (V)[1] <= (V)[3] && (V)[1] >= -(V)[3] \
- && (V)[2] <= (V)[3] && (V)[2] >= -(V)[3] )
-#endif
-
-
-
-
-#define CLIP_TAB_EDGEFLAG 1
-
-extern void gl_init_clip(void);
-
-
-extern GLuint gl_viewclip_point( const GLfloat v[] );
-
-
-
-extern GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] );
-
-
-extern void gl_user_cliptest( struct vertex_buffer *VB );
-
-
extern void _mesa_ClipPlane( GLenum plane, const GLdouble *equation );
extern void _mesa_GetClipPlane( GLenum plane, GLdouble *equation );
-
-/*
- * Clipping interpolation functions
- */
-
-extern void gl_clip_interp_all( struct vertex_buffer *VB,
- GLuint dst, GLfloat t, GLuint in, GLuint out );
-
-extern void gl_clip_interp_color_tex( struct vertex_buffer *VB,
- GLuint dst, GLfloat t, GLuint in, GLuint out );
-
-extern void gl_clip_interp_tex( struct vertex_buffer *VB,
- GLuint dst, GLfloat t, GLuint in, GLuint out );
-
-extern void gl_clip_interp_color( struct vertex_buffer *VB,
- GLuint dst, GLfloat t, GLuint in, GLuint out );
-
-extern void gl_clip_interp_none( struct vertex_buffer *VB,
- GLuint dst, GLfloat t, GLuint in, GLuint out );
-
-
-extern void gl_update_userclip( GLcontext *ctx );
-
-extern void gl_update_clipmask( GLcontext *ctx );
-
#endif
diff --git a/src/mesa/main/colormac.h b/src/mesa/main/colormac.h
index b69f52fbbbf..57d4350cc49 100644
--- a/src/mesa/main/colormac.h
+++ b/src/mesa/main/colormac.h
@@ -1,4 +1,4 @@
-/* $Id: colormac.h,v 1.2 2000/10/29 18:12:14 brianp Exp $ */
+/* $Id: colormac.h,v 1.3 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -38,7 +38,8 @@
#include "config.h"
#include "macros.h"
#include "mmath.h"
-
+/* Do not reference types.h from this file.
+ */
/*
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index aff60fb5073..c0e75e92984 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1,4 +1,4 @@
-/* $Id: context.c,v 1.105 2000/11/15 16:38:40 brianp Exp $ */
+/* $Id: context.c,v 1.106 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,7 +33,6 @@
#include "clip.h"
#include "colortab.h"
#include "context.h"
-#include "cva.h"
#include "dlist.h"
#include "eval.h"
#include "enums.h"
@@ -46,25 +45,21 @@
#include "imports.h"
#include "light.h"
#include "macros.h"
-#include "matrix.h"
#include "mem.h"
#include "mmath.h"
-#include "pipeline.h"
-#include "shade.h"
#include "simple_list.h"
-#include "stages.h"
#include "state.h"
-#include "translate.h"
#include "teximage.h"
#include "texobj.h"
#include "texture.h"
#include "types.h"
#include "varray.h"
-#include "vb.h"
-#include "vbrender.h"
-#include "vbxform.h"
-#include "vertices.h"
-#include "xform.h"
+
+#include "math/m_translate.h"
+#include "math/m_vertices.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+#include "math/math.h"
#endif
#if defined(MESA_TRACE)
@@ -73,6 +68,25 @@
#endif
+#ifndef MESA_VERBOSE
+int MESA_VERBOSE = 0
+/* | VERBOSE_PIPELINE */
+/* | VERBOSE_IMMEDIATE */
+/* | VERBOSE_VARRAY */
+/* | VERBOSE_TEXTURE */
+/* | VERBOSE_API */
+/* | VERBOSE_DRIVER */
+/* | VERBOSE_STATE */
+/* | VERBOSE_CULL */
+/* | VERBOSE_DISPLAY_LIST */
+;
+#endif
+
+#ifndef MESA_DEBUG_FLAGS
+int MESA_DEBUG_FLAGS = 0
+/* | DEBUG_ALWAYS_FLUSH */
+;
+#endif
/**********************************************************************/
/***** OpenGL SI-style interface (new in Mesa 3.5) *****/
@@ -145,12 +159,6 @@ __glCoreNopDispatch(void)
/**********************************************************************/
-#if !defined(THREADS)
-
-struct immediate *_mesa_CurrentInput = NULL;
-
-#endif
-
/**********************************************************************/
/***** GL Visual allocation/destruction *****/
@@ -442,17 +450,10 @@ one_time_init( void )
assert( sizeof(GLushort) >= 2 );
assert( sizeof(GLuint) >= 4 );
- gl_init_clip();
- gl_init_eval();
- _mesa_init_math();
gl_init_lists();
- gl_init_shade();
- gl_init_texture();
- gl_init_transformation();
- gl_init_translate();
- gl_init_vbrender();
- gl_init_vbxform();
- gl_init_vertices();
+
+ _mesa_init_math();
+ _math_init();
if (getenv("MESA_DEBUG")) {
_glapi_noop_enable_warnings(GL_TRUE);
@@ -809,45 +810,43 @@ init_attrib_groups( GLcontext *ctx )
ctx->Const.NumCompressedTextureFormats = 0;
/* Modelview matrix */
- gl_matrix_ctr( &ctx->ModelView );
- gl_matrix_alloc_inv( &ctx->ModelView );
+ _math_matrix_ctr( &ctx->ModelView );
+ _math_matrix_alloc_inv( &ctx->ModelView );
ctx->ModelViewStackDepth = 0;
for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
- gl_matrix_ctr( &ctx->ModelViewStack[i] );
- gl_matrix_alloc_inv( &ctx->ModelViewStack[i] );
+ _math_matrix_ctr( &ctx->ModelViewStack[i] );
+ _math_matrix_alloc_inv( &ctx->ModelViewStack[i] );
}
/* Projection matrix - need inv for user clipping in clip space*/
- gl_matrix_ctr( &ctx->ProjectionMatrix );
- gl_matrix_alloc_inv( &ctx->ProjectionMatrix );
-
- gl_matrix_ctr( &ctx->_ModelProjectMatrix );
+ _math_matrix_ctr( &ctx->ProjectionMatrix );
+ _math_matrix_alloc_inv( &ctx->ProjectionMatrix );
ctx->ProjectionStackDepth = 0;
- ctx->NearFarStack[0][0] = 1.0; /* These values seem weird by make */
- ctx->NearFarStack[0][1] = 0.0; /* sense mathematically. */
-
for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
- gl_matrix_ctr( &ctx->ProjectionStack[i] );
- gl_matrix_alloc_inv( &ctx->ProjectionStack[i] );
+ _math_matrix_ctr( &ctx->ProjectionStack[i] );
+ _math_matrix_alloc_inv( &ctx->ProjectionStack[i] );
}
+ /* Derived ModelProject matrix */
+ _math_matrix_ctr( &ctx->_ModelProjectMatrix );
+
/* Texture matrix */
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- gl_matrix_ctr( &ctx->TextureMatrix[i] );
+ _math_matrix_ctr( &ctx->TextureMatrix[i] );
ctx->TextureStackDepth[i] = 0;
for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
- gl_matrix_ctr( &ctx->TextureStack[i][j] );
+ _math_matrix_ctr( &ctx->TextureStack[i][j] );
ctx->TextureStack[i][j].inv = 0;
}
}
/* Color matrix */
- gl_matrix_ctr(&ctx->ColorMatrix);
+ _math_matrix_ctr(&ctx->ColorMatrix);
ctx->ColorStackDepth = 0;
for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) {
- gl_matrix_ctr(&ctx->ColorStack[j]);
+ _math_matrix_ctr(&ctx->ColorStack[j]);
}
/* Accumulate buffer group */
@@ -893,19 +892,6 @@ init_attrib_groups( GLcontext *ctx )
ctx->Current.RasterPosValid = GL_TRUE;
ctx->Current.EdgeFlag = GL_TRUE;
ASSIGN_3V( ctx->Current.Normal, 0.0, 0.0, 1.0 );
- ctx->Current.Primitive = (GLenum) (GL_POLYGON + 1);
-
- ctx->Current.Flag = (VERT_NORM |
- VERT_INDEX |
- VERT_RGBA |
- VERT_SPEC_RGB |
- VERT_FOG_COORD |
- VERT_EDGE |
- VERT_TEX0_12 |
- VERT_TEX1_12 |
- VERT_TEX2_12 |
- VERT_TEX3_12 |
- VERT_MATERIAL);
init_fallback_arrays( ctx );
@@ -1023,15 +1009,9 @@ init_attrib_groups( GLcontext *ctx )
ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000;
ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000;
- /* Pipeline */
- gl_pipeline_init( ctx );
- gl_cva_init( ctx );
-
/* Extensions */
gl_extensions_ctr( ctx );
- ctx->AllowVertexCull = CLIP_CULLED_BIT;
-
/* Lighting group */
for (i=0;i<MAX_LIGHTS;i++) {
init_light( &ctx->Light.Light[i], i );
@@ -1227,7 +1207,7 @@ init_attrib_groups( GLcontext *ctx )
ctx->Viewport.Height = 0;
ctx->Viewport.Near = 0.0;
ctx->Viewport.Far = 1.0;
- gl_matrix_ctr(&ctx->Viewport._WindowMap);
+ _math_matrix_ctr(&ctx->Viewport._WindowMap);
#define Sz 10
#define Tz 14
@@ -1454,12 +1434,6 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Visual = *visual;
ctx->DrawBuffer = NULL;
ctx->ReadBuffer = NULL;
-
- ctx->VB = gl_vb_create_for_immediate( ctx );
- if (!ctx->VB) {
- return GL_FALSE;
- }
- ctx->input = ctx->VB->IM;
if (share_list) {
/* share the group of display lists of another context */
@@ -1469,7 +1443,6 @@ _mesa_initialize_context( GLcontext *ctx,
/* allocate new group of display lists */
ctx->Shared = alloc_shared_state();
if (!ctx->Shared) {
- ALIGN_FREE( ctx->VB );
return GL_FALSE;
}
}
@@ -1479,9 +1452,6 @@ _mesa_initialize_context( GLcontext *ctx,
init_attrib_groups( ctx );
- gl_reset_vb( ctx->VB );
- gl_reset_input( ctx );
-
if (visual->DBflag) {
ctx->Color.DrawBuffer = GL_BACK;
ctx->Color.DriverDrawBuffer = GL_BACK_LEFT;
@@ -1499,7 +1469,6 @@ _mesa_initialize_context( GLcontext *ctx,
if (!alloc_proxy_textures(ctx)) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
return GL_FALSE;
}
@@ -1526,7 +1495,6 @@ _mesa_initialize_context( GLcontext *ctx,
ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*));
if (!ctx->Exec || !ctx->Save) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
if (ctx->Exec)
FREE( ctx->Exec );
}
@@ -1541,7 +1509,6 @@ _mesa_initialize_context( GLcontext *ctx,
or should we just trap in NewTrace (currently done)? */
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
FREE( ctx->Exec );
FREE( ctx->Save );
return GL_FALSE;
@@ -1554,7 +1521,6 @@ _mesa_initialize_context( GLcontext *ctx,
#if 0
if (!(ctx->TraceCtx)) {
free_shared_state(ctx, ctx->Shared);
- ALIGN_FREE( ctx->VB );
FREE( ctx->Exec );
FREE( ctx->Save );
FREE( ctx->TraceCtx );
@@ -1613,26 +1579,21 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_make_current(NULL, NULL);
}
- gl_matrix_dtr( &ctx->ModelView );
+ _math_matrix_dtr( &ctx->ModelView );
for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) {
- gl_matrix_dtr( &ctx->ModelViewStack[i] );
+ _math_matrix_dtr( &ctx->ModelViewStack[i] );
}
- gl_matrix_dtr( &ctx->ProjectionMatrix );
+ _math_matrix_dtr( &ctx->ProjectionMatrix );
for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) {
- gl_matrix_dtr( &ctx->ProjectionStack[i] );
+ _math_matrix_dtr( &ctx->ProjectionStack[i] );
}
for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- gl_matrix_dtr( &ctx->TextureMatrix[i] );
+ _math_matrix_dtr( &ctx->TextureMatrix[i] );
for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) {
- gl_matrix_dtr( &ctx->TextureStack[i][j] );
+ _math_matrix_dtr( &ctx->TextureStack[i][j] );
}
}
- if (ctx->input != ctx->VB->IM)
- gl_immediate_free( ctx->input );
-
- gl_vb_free( ctx->VB );
-
_glthread_LOCK_MUTEX(ctx->Shared->Mutex);
ctx->Shared->RefCount--;
assert(ctx->Shared->RefCount >= 0);
@@ -1696,12 +1657,6 @@ _mesa_free_context_data( GLcontext *ctx )
_mesa_free_colortable_data( &ctx->PostColorMatrixColorTable );
_mesa_free_colortable_data( &ctx->Texture.Palette );
- /* Free cache of immediate buffers. */
- while (ctx->nr_im_queued-- > 0) {
- struct immediate * next = ctx->freed_im_queue->next;
- ALIGN_FREE( ctx->freed_im_queue );
- ctx->freed_im_queue = next;
- }
gl_extensions_dtr(ctx);
FREE(ctx->Exec);
@@ -1828,6 +1783,29 @@ _mesa_make_current( GLcontext *newCtx, GLframebuffer *buffer )
}
+static void print_info( void )
+{
+ fprintf(stderr, "Mesa GL_VERSION = %s\n",
+ (char *) _mesa_GetString(GL_VERSION));
+ fprintf(stderr, "Mesa GL_RENDERER = %s\n",
+ (char *) _mesa_GetString(GL_RENDERER));
+ fprintf(stderr, "Mesa GL_VENDOR = %s\n",
+ (char *) _mesa_GetString(GL_VENDOR));
+ fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n",
+ (char *) _mesa_GetString(GL_EXTENSIONS));
+#if defined(THREADS)
+ fprintf(stderr, "Mesa thread-safe: YES\n");
+#else
+ fprintf(stderr, "Mesa thread-safe: NO\n");
+#endif
+#if defined(USE_X86_ASM)
+ fprintf(stderr, "Mesa x86-optimized: YES\n");
+#else
+ fprintf(stderr, "Mesa x86-optimized: NO\n");
+#endif
+}
+
+
/*
* Bind the given context to the given draw-buffer and read-buffer
* and make it the current context for this thread.
@@ -1836,23 +1814,8 @@ void
_mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
GLframebuffer *readBuffer )
{
-#if 0
- GLcontext *oldCtx = gl_get_context();
-
- /* Flush the old context
- */
- if (oldCtx) {
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(oldCtx, "_mesa_make_current");
-
- /* unbind frame buffers from context */
- if (oldCtx->DrawBuffer) {
- oldCtx->DrawBuffer = NULL;
- }
- if (oldCtx->ReadBuffer) {
- oldCtx->ReadBuffer = NULL;
- }
- }
-#endif
+ if (MESA_VERBOSE)
+ fprintf(stderr, "_mesa_make_current2()\n");
/* We call this function periodically (just here for now) in
* order to detect when multithreading has begun.
@@ -1861,47 +1824,36 @@ _mesa_make_current2( GLcontext *newCtx, GLframebuffer *drawBuffer,
_glapi_set_context((void *) newCtx);
ASSERT(_mesa_get_current_context() == newCtx);
- if (newCtx) {
- SET_IMMEDIATE(newCtx, newCtx->input);
- _glapi_set_dispatch(newCtx->CurrentDispatch);
- }
- else {
+
+
+ if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
}
+ else {
+ _glapi_set_dispatch(newCtx->CurrentDispatch);
- if (MESA_VERBOSE) fprintf(stderr, "_mesa_make_current()\n");
+ if (drawBuffer && readBuffer) {
+ /* TODO: check if newCtx and buffer's visual match??? */
+ newCtx->DrawBuffer = drawBuffer;
+ newCtx->ReadBuffer = readBuffer;
+ newCtx->NewState |= _NEW_BUFFERS;
+ /* gl_update_state( newCtx ); */
+ }
- if (newCtx && drawBuffer && readBuffer) {
- /* TODO: check if newCtx and buffer's visual match??? */
- newCtx->DrawBuffer = drawBuffer;
- newCtx->ReadBuffer = readBuffer;
- newCtx->NewState |= _NEW_BUFFERS;
- gl_update_state( newCtx );
- }
+ if (newCtx->Driver.MakeCurrent)
+ newCtx->Driver.MakeCurrent( newCtx, drawBuffer, readBuffer );
- /* We can use this to help debug user's problems. Tell the to set
- * the MESA_INFO env variable before running their app. Then the
- * first time each context is made current we'll print some useful
- * information.
- */
- if (newCtx && newCtx->FirstTimeCurrent) {
- if (getenv("MESA_INFO")) {
- fprintf(stderr, "Mesa GL_VERSION = %s\n", (char *) _mesa_GetString(GL_VERSION));
- fprintf(stderr, "Mesa GL_RENDERER = %s\n", (char *) _mesa_GetString(GL_RENDERER));
- fprintf(stderr, "Mesa GL_VENDOR = %s\n", (char *) _mesa_GetString(GL_VENDOR));
- fprintf(stderr, "Mesa GL_EXTENSIONS = %s\n", (char *) _mesa_GetString(GL_EXTENSIONS));
-#if defined(THREADS)
- fprintf(stderr, "Mesa thread-safe: YES\n");
-#else
- fprintf(stderr, "Mesa thread-safe: NO\n");
-#endif
-#if defined(USE_X86_ASM)
- fprintf(stderr, "Mesa x86-optimized: YES\n");
-#else
- fprintf(stderr, "Mesa x86-optimized: NO\n");
-#endif
+ /* We can use this to help debug user's problems. Tell them to set
+ * the MESA_INFO env variable before running their app. Then the
+ * first time each context is made current we'll print some useful
+ * information.
+ */
+ if (newCtx->FirstTimeCurrent) {
+ if (getenv("MESA_INFO")) {
+ print_info();
+ }
+ newCtx->FirstTimeCurrent = GL_FALSE;
}
- newCtx->FirstTimeCurrent = GL_FALSE;
}
}
@@ -1927,7 +1879,7 @@ _mesa_get_current_context( void )
void
_mesa_swapbuffers(GLcontext *ctx)
{
- FLUSH_VB( ctx, "swap buffers" );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
}
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index fe058c69d36..71ed19119ce 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -1,4 +1,4 @@
-/* $Id: context.h,v 1.20 2000/10/29 18:12:14 brianp Exp $ */
+/* $Id: context.h,v 1.21 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -169,33 +169,16 @@ _mesa_get_current_context(void);
/*
- * Macros for fetching current context, input buffer, etc.
+ * Macros for fetching current context.
*/
#ifdef THREADS
#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
-#define GET_IMMEDIATE struct immediate *IM = ((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))->input
-
-#define SET_IMMEDIATE(ctx, im) \
-do { \
- ctx->input = im; \
-} while (0)
-
#else
-extern struct immediate *_mesa_CurrentInput;
-
#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
-#define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput
-
-#define SET_IMMEDIATE(ctx, im) \
-do { \
- ctx->input = im; \
- _mesa_CurrentInput = im; \
-} while (0)
-
#endif
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 9452a0e86c0..2c9a024842c 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1,4 +1,4 @@
-/* $Id: dd.h,v 1.41 2000/11/14 17:40:13 brianp Exp $ */
+/* $Id: dd.h,v 1.42 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,7 +34,6 @@
struct gl_pixelstore_attrib;
struct vertex_buffer;
-struct immediate;
struct gl_pipeline;
struct gl_pipeline_stage;
@@ -122,6 +121,30 @@ struct gl_pipeline_stage;
+
+
+
+
+/* Point, line, triangle, quadrilateral and rectangle rasterizer
+ * functions. These are specific to the tnl module and will shortly
+ * move to a driver interface specific to that module.
+ */
+typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
+
+typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv );
+
+typedef void (*triangle_func)( GLcontext *ctx,
+ GLuint v1, GLuint v2, GLuint v3, GLuint pv );
+
+typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
+ GLuint v3, GLuint v4, GLuint pv );
+
+typedef void (*render_func)( struct vertex_buffer *VB,
+ GLuint start,
+ GLuint count,
+ GLuint parity );
+
+
/*
* Device Driver function table.
*/
@@ -138,12 +161,6 @@ struct dd_function_table {
* NULL can be returned.
*/
- GLuint UpdateStateNotify;
- /*
- * Tell mesa exactly when to call UpdateState. This is a bitwise
- * or of the _NEW_* flags defined in types.h.
- */
-
void (*UpdateState)( GLcontext *ctx );
/*
* UpdateState() is called whenver Mesa thinks the device driver should
@@ -327,13 +344,6 @@ struct dd_function_table {
* the error value.
*/
- void (*NearFar)( GLcontext *ctx, GLfloat nearVal, GLfloat farVal );
- /*
- * Called from glFrustum and glOrtho to tell device driver the
- * near and far clipping plane Z values. The 3Dfx driver, for example,
- * uses this.
- */
-
/***
*** For supporting hardware Z buffers:
@@ -744,14 +754,13 @@ struct dd_function_table {
/***
- *** Accelerated point, line, polygon, quad and rect functions:
+ *** Accelerated point, line, polygon and quad functions:
***/
points_func PointsFunc;
line_func LineFunc;
triangle_func TriangleFunc;
quad_func QuadFunc;
- rect_func RectFunc;
/***
@@ -798,12 +807,7 @@ struct dd_function_table {
/***
*** NEW in Mesa 3.x
***/
- void (*LightingSpaceChange)( GLcontext *ctx );
- /* Notify driver that the special derived value _NeedEyeCoords has
- * changed.
- */
-
void (*RegisterVB)( struct vertex_buffer *VB );
void (*UnregisterVB)( struct vertex_buffer *VB );
/* When Mesa creates a new vertex buffer it calls Driver.RegisterVB()
@@ -814,35 +818,57 @@ struct dd_function_table {
*/
- void (*ResetVB)( struct vertex_buffer *VB );
- void (*ResetCvaVB)( struct vertex_buffer *VB, GLuint stages );
- /* Do any reset operations necessary to the driver data associated
- * with these vertex buffers.
- */
- GLuint RenderVectorFlags;
- /* What do the render tables require of the vectors they deal
- * with?
+ GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx );
+ GLboolean (*BuildEltPipeline)( GLcontext *ctx );
+ /* Perform the full pipeline build, or return false.
*/
- GLuint (*RegisterPipelineStages)( struct gl_pipeline_stage *out,
- const struct gl_pipeline_stage *in,
- GLuint nr );
- /* Register new pipeline stages, or modify existing ones. See also
- * the OptimizePipeline() functions.
+
+ /***
+ *** Support for multiple t&l engines
+ ***/
+
+#define FLUSH_INSIDE_BEGIN_END 0x1
+#define FLUSH_STORED_VERTICES 0x2
+#define FLUSH_UPDATE_CURRENT 0x4
+
+ GLuint NeedFlush;
+ /* Set by the driver-supplied t&l engine.
+ * Bitflags defined above are set whenever
+ * - the engine *might* be inside a begin/end object.
+ * - there *might* be buffered vertices to be flushed.
+ * - the ctx->Current values *might* not be uptodate.
+ *
+ * The FlushVertices() call below may be used to resolve
+ * these conditions.
*/
+ GLboolean (*FlushVertices)( GLcontext *ctx, GLuint flags );
+ /* If inside begin/end, returns GL_FALSE.
+ * Otherwise,
+ * if (flags & FLUSH_STORED_VERTICES) flushes any buffered vertices,
+ * if (flags & FLUSH_UPDATE_CURRENT) updates ctx->Current,
+ * returns GL_TRUE.
+ *
+ * Note that the default t&l engine never clears the
+ * FLUSH_UPDATE_CURRENT bit, even after performing the update.
+ */
- GLboolean (*BuildPrecalcPipeline)( GLcontext *ctx );
- GLboolean (*BuildEltPipeline)( GLcontext *ctx );
- /* Perform the full pipeline build, or return false.
+ void (*LightingSpaceChange)( GLcontext *ctx );
+ /* Notify driver that the special derived value _NeedEyeCoords has
+ * changed.
*/
+ void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
+ void (*EndList)( GLcontext *ctx );
+ /* Let the t&l component know what is going on with display lists
+ * in time to make changes to dispatch tables, etc.
+ */
- void (*OptimizePrecalcPipeline)( GLcontext *ctx, struct gl_pipeline *pipe );
- void (*OptimizeImmediatePipeline)( GLcontext *ctx, struct gl_pipeline *pipe);
- /* Check to see if a fast path exists for this combination of stages
- * in the precalc and immediate (elt) pipelines.
+ void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
+ /* Let the t&l component know when the context becomes current.
*/
@@ -898,6 +924,23 @@ struct dd_function_table {
GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
+
+
+ void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*NormalPointer)(GLcontext *ctx, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*IndexPointer)(GLcontext *ctx, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
};
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
new file mode 100644
index 00000000000..b467499816f
--- /dev/null
+++ b/src/mesa/main/debug.c
@@ -0,0 +1,89 @@
+#include "types.h"
+#include "debug.h"
+
+void gl_print_state( const char *msg, GLuint state )
+{
+ fprintf(stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ state,
+ (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
+ (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
+ (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
+ (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "",
+ (state & _NEW_ACCUM) ? "ctx->Accum, " : "",
+ (state & _NEW_COLOR) ? "ctx->Color, " : "",
+ (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
+ (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
+ (state & _NEW_FOG) ? "ctx->Fog, " : "",
+ (state & _NEW_HINT) ? "ctx->Hint, " : "",
+ (state & _NEW_LIGHT) ? "ctx->Light, " : "",
+ (state & _NEW_LINE) ? "ctx->Line, " : "",
+ (state & _NEW_FEEDBACK_SELECT) ? "ctx->Feedback/Select, " : "",
+ (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
+ (state & _NEW_POINT) ? "ctx->Point, " : "",
+ (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
+ (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
+ (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
+ (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
+ (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
+ (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
+ (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
+ (state & _NEW_ARRAY) ? "ctx->Array, " : "",
+ (state & _NEW_COLORTABLE) ? "ctx->{*}ColorTable, " : "",
+ (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
+ (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
+}
+
+
+void gl_print_enable_flags( const char *msg, GLuint flags )
+{
+ fprintf(stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ flags,
+ (flags & ENABLE_TEX0) ? "tex-0, " : "",
+ (flags & ENABLE_TEX1) ? "tex-1, " : "",
+ (flags & ENABLE_LIGHT) ? "light, " : "",
+ (flags & ENABLE_FOG) ? "fog, " : "",
+ (flags & ENABLE_USERCLIP) ? "userclip, " : "",
+ (flags & ENABLE_TEXGEN0) ? "tex-gen-0, " : "",
+ (flags & ENABLE_TEXGEN1) ? "tex-gen-1, " : "",
+ (flags & ENABLE_TEXGEN2) ? "tex-gen-2, " : "",
+ (flags & ENABLE_TEXGEN3) ? "tex-gen-3, " : "",
+ (flags & ENABLE_TEXMAT0) ? "tex-mat-0, " : "",
+ (flags & ENABLE_TEXMAT1) ? "tex-mat-1, " : "",
+ (flags & ENABLE_TEXMAT2) ? "tex-mat-2, " : "",
+ (flags & ENABLE_TEXMAT3) ? "tex-mat-3, " : "",
+ (flags & ENABLE_NORMALIZE) ? "normalize, " : "",
+ (flags & ENABLE_RESCALE) ? "rescale, " : "");
+}
+
+void gl_print_tri_caps( const char *name, GLuint flags )
+{
+ fprintf(stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ name,
+ flags,
+ (flags & DD_FEEDBACK) ? "feedback, " : "",
+ (flags & DD_SELECT) ? "select, " : "",
+ (flags & DD_FLATSHADE) ? "flat-shade, " : "",
+ (flags & DD_MULTIDRAW) ? "multidraw, " : "",
+ (flags & DD_SEPERATE_SPECULAR) ? "seperate-specular, " : "",
+ (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
+ (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
+ (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
+ (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
+ (flags & DD_TRI_CULL) ? "tri-bf-cull, " : "",
+ (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
+ (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
+ (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
+ (flags & DD_LINE_WIDTH) ? "line-wide, " : "",
+ (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
+ (flags & DD_POINT_SIZE) ? "point-size, " : "",
+ (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
+ (flags & DD_LIGHTING_CULL) ? "lighting-cull, " : "",
+ (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : "",
+ (flags & DD_STENCIL) ? "stencil, " : ""
+ );
+}
diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h
new file mode 100644
index 00000000000..1fff95411e9
--- /dev/null
+++ b/src/mesa/main/debug.h
@@ -0,0 +1,8 @@
+#ifndef _DEBUG_H
+#define _DEBUG_H
+
+void gl_print_tri_caps( const char *name, GLuint flags );
+void gl_print_enable_flags( const char *msg, GLuint flags );
+void gl_print_state( const char *msg, GLuint state );
+
+#endif
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index e3475bb5cb1..d66c0745a86 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.50 2000/11/10 18:06:14 brianp Exp $ */
+/* $Id: dlist.c,v 1.51 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -32,7 +32,6 @@
#include "accum.h"
#include "attrib.h"
#include "bitmap.h"
-#include "bbox.h"
#include "blend.h"
#include "buffers.h"
#include "clip.h"
@@ -41,7 +40,6 @@
#include "context.h"
#include "convolve.h"
#include "copypix.h"
-#include "cva.h"
#include "depth.h"
#include "enable.h"
#include "enums.h"
@@ -59,7 +57,6 @@
#include "macros.h"
#include "matrix.h"
#include "mem.h"
-#include "pipeline.h"
#include "pixel.h"
#include "pixeltex.h"
#include "points.h"
@@ -72,10 +69,13 @@
#include "texstate.h"
#include "types.h"
#include "varray.h"
-#include "vb.h"
-#include "vbfill.h"
-#include "vbxform.h"
-#include "xform.h"
+
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+
+#include "tnl/t_vbfill.h"
+#include "tnl/t_eval.h"
+#include "tnl/t_varray.h"
#endif
@@ -121,7 +121,6 @@ Functions which cause errors if called while compiling a display list:
* The fact that these identifiers are assigned consecutive
* integer values starting at 0 is very important, see InstSize array usage)
*
- * KW: Commented out opcodes now handled by vertex-cassettes.
*/
typedef enum {
OPCODE_ACCUM,
@@ -221,6 +220,7 @@ typedef enum {
OPCODE_READ_BUFFER,
OPCODE_RESET_HISTOGRAM,
OPCODE_RESET_MIN_MAX,
+ OPCODE_ROTATE,
OPCODE_SCALE,
OPCODE_SCISSOR,
OPCODE_SELECT_TEXTURE_SGIS,
@@ -256,9 +256,9 @@ typedef enum {
OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D,
/* The following three are meta instructions */
OPCODE_ERROR, /* raise compiled-in error */
- OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */
OPCODE_CONTINUE,
- OPCODE_END_OF_LIST
+ OPCODE_END_OF_LIST,
+ OPCODE_DRV_0
} OpCode;
@@ -284,7 +284,9 @@ union node {
-/* Number of nodes of storage needed for each instruction: */
+/* Number of nodes of storage needed for each instruction. Sizes for
+ * dynamically allocated opcodes are stored in the context struct.
+ */
static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
void mesa_print_display_list( GLuint list );
@@ -295,40 +297,6 @@ void mesa_print_display_list( GLuint list );
/**********************************************************************/
-/*
- * Allocate space for a display list instruction.
- * Input: opcode - type of instruction
- * argcount - number of arguments following the instruction
- * Return: pointer to first node in the instruction
- */
-static Node *alloc_instruction( GLcontext *ctx, OpCode opcode, GLint argcount )
-{
- Node *n, *newblock;
- GLuint count = InstSize[opcode];
-
- assert( (GLint) count == argcount+1 );
-
- if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
- /* This block is full. Allocate a new block and chain to it */
- n = ctx->CurrentBlock + ctx->CurrentPos;
- n[0].opcode = OPCODE_CONTINUE;
- newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
- if (!newblock) {
- gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
- return NULL;
- }
- n[1].next = (Node *) newblock;
- ctx->CurrentBlock = newblock;
- ctx->CurrentPos = 0;
- }
-
- n = ctx->CurrentBlock + ctx->CurrentPos;
- ctx->CurrentPos += count;
-
- n[0].opcode = opcode;
-
- return n;
-}
@@ -362,13 +330,16 @@ void gl_destroy_list( GLcontext *ctx, GLuint list )
done = block ? GL_FALSE : GL_TRUE;
while (!done) {
- switch (n[0].opcode) {
- /* special cases first */
- case OPCODE_VERTEX_CASSETTE:
- if ( ! -- ((struct immediate *) n[1].data)->ref_count )
- gl_immediate_free( (struct immediate *) n[1].data );
- n += InstSize[n[0].opcode];
- break;
+
+ /* check for extension opcodes first */
+
+ int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+ if (i >= 0 && i < ctx->listext.nr_opcodes) {
+ ctx->listext.opcode[i].destroy(ctx, &n[1]);
+ n += ctx->listext.opcode[i].size;
+ }
+ else {
+ switch (n[0].opcode) {
case OPCODE_MAP1:
FREE(n[6].data);
n += InstSize[n[0].opcode];
@@ -466,9 +437,10 @@ void gl_destroy_list( GLcontext *ctx, GLuint list )
/* Most frequent case */
n += InstSize[n[0].opcode];
break;
+ }
}
}
-
+
_mesa_HashRemove(ctx->Shared->DisplayList, list);
}
@@ -637,6 +609,7 @@ void gl_init_lists( void )
InstSize[OPCODE_READ_BUFFER] = 2;
InstSize[OPCODE_RESET_HISTOGRAM] = 2;
InstSize[OPCODE_RESET_MIN_MAX] = 2;
+ InstSize[OPCODE_ROTATE] = 5;
InstSize[OPCODE_SCALE] = 4;
InstSize[OPCODE_SCISSOR] = 5;
InstSize[OPCODE_STENCIL_FUNC] = 4;
@@ -657,7 +630,6 @@ void gl_init_lists( void )
InstSize[OPCODE_WINDOW_POS] = 5;
InstSize[OPCODE_CONTINUE] = 2;
InstSize[OPCODE_ERROR] = 3;
- InstSize[OPCODE_VERTEX_CASSETTE] = 9;
InstSize[OPCODE_END_OF_LIST] = 1;
/* GL_SGIX/SGIS_pixel_texture */
InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2;
@@ -678,17 +650,88 @@ void gl_init_lists( void )
/*
- * Display List compilation functions
+ * Allocate space for a display list instruction.
+ * Input: opcode - type of instruction
+ * argcount - size in bytes of data required.
+ * Return: pointer to the usable data area (not including the internal
+ * opcode).
*/
+void *
+_mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
+{
+ Node *n, *newblock;
+ GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
+#ifdef DEBUG
+ if (opcode < (int) OPCODE_DRV_0) {
+ assert( (GLint) count == InstSize[opcode] );
+ }
+#endif
+ if (ctx->CurrentPos + count + 2 > BLOCK_SIZE) {
+ /* This block is full. Allocate a new block and chain to it */
+ n = ctx->CurrentBlock + ctx->CurrentPos;
+ n[0].opcode = OPCODE_CONTINUE;
+ newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
+ if (!newblock) {
+ gl_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
+ return NULL;
+ }
+ n[1].next = (Node *) newblock;
+ ctx->CurrentBlock = newblock;
+ ctx->CurrentPos = 0;
+ }
+ n = ctx->CurrentBlock + ctx->CurrentPos;
+ ctx->CurrentPos += count;
+
+ n[0].opcode = (OpCode) opcode;
+
+ return (void *)&n[1];
+}
+
+
+/* Allow modules and drivers to get their own opcodes.
+ */
+int
+_mesa_alloc_opcode( GLcontext *ctx,
+ GLuint sz,
+ void (*execute)( GLcontext *, void * ),
+ void (*destroy)( GLcontext *, void * ),
+ void (*print)( GLcontext *, void * ) )
+{
+ if (ctx->listext.nr_opcodes < GL_MAX_EXT_OPCODES) {
+ GLuint i = ctx->listext.nr_opcodes++;
+ ctx->listext.opcode[i].size = 1 + (sz + sizeof(Node) - 1)/sizeof(Node);
+ ctx->listext.opcode[i].execute = execute;
+ ctx->listext.opcode[i].destroy = destroy;
+ ctx->listext.opcode[i].print = print;
+ return i + OPCODE_DRV_0;
+ }
+ return -1;
+}
+
+
+
+/* Mimic the old behaviour of alloc_instruction:
+ * - sz is in units of sizeof(Node)
+ * - return value a pointer to sizeof(Node) before the actual
+ * usable data area.
+ */
+#define ALLOC_INSTRUCTION(ctx, opcode, sz) \
+ ((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
+
+
+
+/*
+ * Display List compilation functions
+ */
static void save_Accum( GLenum op, GLfloat value )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_ACCUM, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
if (n) {
n[1].e = op;
n[2].f = value;
@@ -703,8 +746,8 @@ static void save_AlphaFunc( GLenum func, GLclampf ref )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_ALPHA_FUNC, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
if (n) {
n[1].e = func;
n[2].f = (GLfloat) ref;
@@ -715,18 +758,12 @@ static void save_AlphaFunc( GLenum func, GLclampf ref )
}
-static void save_Begin( GLenum mode )
-{
- _mesa_Begin(mode); /* special case */
-}
-
-
static void save_BindTexture( GLenum target, GLuint texture )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_BIND_TEXTURE, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
if (n) {
n[1].e = target;
n[2].ui = texture;
@@ -745,8 +782,8 @@ static void save_Bitmap( GLsizei width, GLsizei height,
GET_CURRENT_CONTEXT(ctx);
GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_BITMAP, 7 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
if (n) {
n[1].i = (GLint) width;
n[2].i = (GLint) height;
@@ -770,8 +807,8 @@ static void save_BlendEquation( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_BLEND_EQUATION, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
if (n) {
n[1].e = mode;
}
@@ -785,8 +822,8 @@ static void save_BlendFunc( GLenum sfactor, GLenum dfactor )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_BLEND_FUNC, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC, 2 );
if (n) {
n[1].e = sfactor;
n[2].e = dfactor;
@@ -802,8 +839,8 @@ static void save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
if (n) {
n[1].e = sfactorRGB;
n[2].e = dfactorRGB;
@@ -822,8 +859,8 @@ static void save_BlendColor( GLfloat red, GLfloat green,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_BLEND_COLOR, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
if (n) {
n[1].f = red;
n[2].f = green;
@@ -840,8 +877,8 @@ static void save_CallList( GLuint list )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CALL_LIST, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
if (n) {
n[1].ui = list;
}
@@ -855,11 +892,11 @@ static void save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
for (i=0;i<n;i++) {
GLuint list = translate_id( i, type, lists );
- Node *n = alloc_instruction( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
+ Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 1 );
if (n) {
n[1].ui = list;
}
@@ -874,8 +911,8 @@ static void save_Clear( GLbitfield mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLEAR, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR, 1 );
if (n) {
n[1].bf = mask;
}
@@ -890,8 +927,8 @@ static void save_ClearAccum( GLfloat red, GLfloat green,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLEAR_ACCUM, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_ACCUM, 4 );
if (n) {
n[1].f = red;
n[2].f = green;
@@ -909,8 +946,8 @@ static void save_ClearColor( GLclampf red, GLclampf green,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLEAR_COLOR, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_COLOR, 4 );
if (n) {
n[1].f = red;
n[2].f = green;
@@ -927,8 +964,8 @@ static void save_ClearDepth( GLclampd depth )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLEAR_DEPTH, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_DEPTH, 1 );
if (n) {
n[1].f = (GLfloat) depth;
}
@@ -942,8 +979,8 @@ static void save_ClearIndex( GLfloat c )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLEAR_INDEX, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_INDEX, 1 );
if (n) {
n[1].f = c;
}
@@ -957,8 +994,8 @@ static void save_ClearStencil( GLint s )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLEAR_STENCIL, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_STENCIL, 1 );
if (n) {
n[1].i = s;
}
@@ -972,8 +1009,8 @@ static void save_ClipPlane( GLenum plane, const GLdouble *equ )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLIP_PLANE, 5 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
if (n) {
n[1].e = plane;
n[2].f = equ[0];
@@ -993,8 +1030,8 @@ static void save_ColorMask( GLboolean red, GLboolean green,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COLOR_MASK, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MASK, 4 );
if (n) {
n[1].b = red;
n[2].b = green;
@@ -1011,8 +1048,8 @@ static void save_ColorMaterial( GLenum face, GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COLOR_MATERIAL, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
if (n) {
n[1].e = face;
n[2].e = mode;
@@ -1039,8 +1076,8 @@ static void save_ColorTable( GLenum target, GLenum internalFormat,
GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, table,
&ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COLOR_TABLE, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 6 );
if (n) {
n[1].e = target;
n[2].e = internalFormat;
@@ -1068,9 +1105,9 @@ save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
Node *n;
ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv");
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
- n = alloc_instruction( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -1097,9 +1134,9 @@ save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
Node *n;
ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv");
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
- n = alloc_instruction( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -1128,8 +1165,8 @@ static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
GLvoid *image = _mesa_unpack_image(count, 1, 1, format, type, table,
&ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
if (n) {
n[1].e = target;
n[2].i = start;
@@ -1154,8 +1191,8 @@ save_CopyColorSubTable(GLenum target, GLsizei start,
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 );
if (n) {
n[1].e = target;
n[2].i = start;
@@ -1176,8 +1213,8 @@ save_CopyColorTable(GLenum target, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_COLOR_TABLE, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 6 );
if (n) {
n[1].e = target;
n[2].e = internalformat;
@@ -1199,8 +1236,8 @@ save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter,
&ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 );
if (n) {
n[1].e = target;
n[2].e = internalFormat;
@@ -1228,8 +1265,8 @@ save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter,
&ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 );
if (n) {
n[1].e = target;
n[2].e = internalFormat;
@@ -1254,8 +1291,8 @@ save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -1272,8 +1309,8 @@ save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -1300,8 +1337,8 @@ save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -1318,8 +1355,8 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -1346,8 +1383,8 @@ static void save_CopyPixels( GLint x, GLint y,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_PIXELS, 5 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_PIXELS, 5 );
if (n) {
n[1].i = x;
n[2].i = y;
@@ -1368,8 +1405,8 @@ save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -1394,8 +1431,8 @@ save_CopyTexImage2D( GLenum target, GLint level,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -1421,8 +1458,8 @@ save_CopyTexSubImage1D( GLenum target, GLint level,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -1445,8 +1482,8 @@ save_CopyTexSubImage2D( GLenum target, GLint level,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -1472,8 +1509,8 @@ save_CopyTexSubImage3D( GLenum target, GLint level,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -1497,8 +1534,8 @@ static void save_CullFace( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CULL_FACE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CULL_FACE, 1 );
if (n) {
n[1].e = mode;
}
@@ -1512,8 +1549,8 @@ static void save_DepthFunc( GLenum func )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_DEPTH_FUNC, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_FUNC, 1 );
if (n) {
n[1].e = func;
}
@@ -1527,8 +1564,8 @@ static void save_DepthMask( GLboolean mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_DEPTH_MASK, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_MASK, 1 );
if (n) {
n[1].b = mask;
}
@@ -1542,8 +1579,8 @@ static void save_DepthRange( GLclampd nearval, GLclampd farval )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_DEPTH_RANGE, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_RANGE, 2 );
if (n) {
n[1].f = (GLfloat) nearval;
n[2].f = (GLfloat) farval;
@@ -1558,8 +1595,8 @@ static void save_Disable( GLenum cap )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_DISABLE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DISABLE, 1 );
if (n) {
n[1].e = cap;
}
@@ -1573,8 +1610,8 @@ static void save_DrawBuffer( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_DRAW_BUFFER, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFER, 1 );
if (n) {
n[1].e = mode;
}
@@ -1592,8 +1629,8 @@ static void save_DrawPixels( GLsizei width, GLsizei height,
GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
pixels, &ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_DRAW_PIXELS, 5 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
if (n) {
n[1].i = width;
n[2].i = height;
@@ -1615,8 +1652,8 @@ static void save_Enable( GLenum cap )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_ENABLE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ENABLE, 1 );
if (n) {
n[1].e = cap;
}
@@ -1631,8 +1668,8 @@ static void save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_EVALMESH1, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH1, 3 );
if (n) {
n[1].e = mode;
n[2].i = i1;
@@ -1649,8 +1686,8 @@ static void save_EvalMesh2(
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_EVALMESH2, 5 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH2, 5 );
if (n) {
n[1].e = mode;
n[2].i = i1;
@@ -1670,8 +1707,8 @@ static void save_Fogfv( GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_FOG, 5 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_FOG, 5 );
if (n) {
n[1].e = pname;
n[2].f = params[0];
@@ -1726,8 +1763,8 @@ static void save_FrontFace( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_FRONT_FACE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_FRONT_FACE, 1 );
if (n) {
n[1].e = mode;
}
@@ -1743,8 +1780,8 @@ static void save_Frustum( GLdouble left, GLdouble right,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_FRUSTUM, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
if (n) {
n[1].f = left;
n[2].f = right;
@@ -1763,8 +1800,8 @@ static void save_Hint( GLenum target, GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_HINT, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT, 2 );
if (n) {
n[1].e = target;
n[2].e = mode;
@@ -1780,8 +1817,8 @@ static void save_HintPGI( GLenum target, GLint mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_HINT_PGI, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT_PGI, 2 );
if (n) {
n[1].e = target;
n[2].i = mode;
@@ -1798,8 +1835,8 @@ save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean si
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_HISTOGRAM, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_HISTOGRAM, 4 );
if (n) {
n[1].e = target;
n[2].i = width;
@@ -1816,8 +1853,8 @@ static void save_IndexMask( GLuint mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_INDEX_MASK, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX_MASK, 1 );
if (n) {
n[1].ui = mask;
}
@@ -1830,8 +1867,8 @@ static void save_IndexMask( GLuint mask )
static void save_InitNames( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
- (void) alloc_instruction( ctx, OPCODE_INIT_NAMES, 0 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_INIT_NAMES, 0 );
if (ctx->ExecuteFlag) {
(*ctx->Exec->InitNames)();
}
@@ -1842,8 +1879,8 @@ static void save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LIGHT, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT, 6 );
if (OPCODE_LIGHT) {
GLint i, nParams;
n[1].e = light;
@@ -1946,8 +1983,8 @@ static void save_LightModelfv( GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LIGHT_MODEL, 5 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT_MODEL, 5 );
if (n) {
n[1].e = pname;
n[2].f = params[0];
@@ -2000,8 +2037,8 @@ static void save_LineStipple( GLint factor, GLushort pattern )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LINE_STIPPLE, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_STIPPLE, 2 );
if (n) {
n[1].i = factor;
n[2].us = pattern;
@@ -2016,8 +2053,8 @@ static void save_LineWidth( GLfloat width )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LINE_WIDTH, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_WIDTH, 1 );
if (n) {
n[1].f = width;
}
@@ -2031,8 +2068,8 @@ static void save_ListBase( GLuint base )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LIST_BASE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LIST_BASE, 1 );
if (n) {
n[1].ui = base;
}
@@ -2045,8 +2082,8 @@ static void save_ListBase( GLuint base )
static void save_LoadIdentity( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
- (void) alloc_instruction( ctx, OPCODE_LOAD_IDENTITY, 0 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_IDENTITY, 0 );
if (ctx->ExecuteFlag) {
(*ctx->Exec->LoadIdentity)();
}
@@ -2057,8 +2094,8 @@ static void save_LoadMatrixf( const GLfloat *m )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LOAD_MATRIX, 16 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_MATRIX, 16 );
if (n) {
GLuint i;
for (i=0;i<16;i++) {
@@ -2086,8 +2123,8 @@ static void save_LoadName( GLuint name )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LOAD_NAME, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_NAME, 1 );
if (n) {
n[1].ui = name;
}
@@ -2101,8 +2138,8 @@ static void save_LogicOp( GLenum opcode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_LOGIC_OP, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOGIC_OP, 1 );
if (n) {
n[1].e = opcode;
}
@@ -2117,8 +2154,8 @@ static void save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
if (n) {
GLfloat *pnts = gl_copy_map_points1d( target, stride, order, points );
n[1].e = target;
@@ -2138,8 +2175,8 @@ static void save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MAP1, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
if (n) {
GLfloat *pnts = gl_copy_map_points1f( target, stride, order, points );
n[1].e = target;
@@ -2162,8 +2199,8 @@ static void save_Map2d( GLenum target,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
if (n) {
GLfloat *pnts = gl_copy_map_points2d( target, ustride, uorder,
vstride, vorder, points );
@@ -2194,8 +2231,8 @@ static void save_Map2f( GLenum target,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MAP2, 10 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
if (n) {
GLfloat *pnts = gl_copy_map_points2f( target, ustride, uorder,
vstride, vorder, points );
@@ -2222,8 +2259,8 @@ static void save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MAPGRID1, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID1, 3 );
if (n) {
n[1].i = un;
n[2].f = u1;
@@ -2246,8 +2283,8 @@ static void save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MAPGRID2, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID2, 6 );
if (n) {
n[1].i = un;
n[2].f = u1;
@@ -2274,8 +2311,8 @@ static void save_MatrixMode( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MATRIX_MODE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MATRIX_MODE, 1 );
if (n) {
n[1].e = mode;
}
@@ -2291,8 +2328,8 @@ save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MIN_MAX, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MIN_MAX, 3 );
if (n) {
n[1].e = target;
n[2].e = internalFormat;
@@ -2308,8 +2345,8 @@ static void save_MultMatrixf( const GLfloat *m )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_MULT_MATRIX, 16 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MULT_MATRIX, 16 );
if (n) {
GLuint i;
for (i=0;i<16;i++) {
@@ -2350,8 +2387,8 @@ static void save_Ortho( GLdouble left, GLdouble right,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_ORTHO, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
if (n) {
n[1].f = left;
n[2].f = right;
@@ -2370,8 +2407,8 @@ static void save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PIXEL_MAP, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
if (n) {
n[1].e = map;
n[2].i = mapsize;
@@ -2424,8 +2461,8 @@ static void save_PixelTransferf( GLenum pname, GLfloat param )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PIXEL_TRANSFER, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
if (n) {
n[1].e = pname;
n[2].f = param;
@@ -2446,8 +2483,8 @@ static void save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PIXEL_ZOOM, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
if (n) {
n[1].f = xfactor;
n[2].f = yfactor;
@@ -2462,8 +2499,8 @@ static void save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_POINT_PARAMETERS, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
if (n) {
n[1].e = pname;
n[2].f = params[0];
@@ -2486,8 +2523,8 @@ static void save_PointSize( GLfloat size )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_POINT_SIZE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
if (n) {
n[1].f = size;
}
@@ -2501,8 +2538,8 @@ static void save_PolygonMode( GLenum face, GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_POLYGON_MODE, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
if (n) {
n[1].e = face;
n[2].e = mode;
@@ -2520,8 +2557,8 @@ static void save_PolygonStipple( const GLubyte *pattern )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_POLYGON_STIPPLE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
if (n) {
void *data;
n[1].data = MALLOC( 32 * 4 );
@@ -2538,8 +2575,8 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_POLYGON_OFFSET, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
if (n) {
n[1].f = factor;
n[2].f = units;
@@ -2560,8 +2597,8 @@ static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
static void save_PopAttrib( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
- (void) alloc_instruction( ctx, OPCODE_POP_ATTRIB, 0 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
if (ctx->ExecuteFlag) {
(*ctx->Exec->PopAttrib)();
}
@@ -2571,8 +2608,8 @@ static void save_PopAttrib( void )
static void save_PopMatrix( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
- (void) alloc_instruction( ctx, OPCODE_POP_MATRIX, 0 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
if (ctx->ExecuteFlag) {
(*ctx->Exec->PopMatrix)();
}
@@ -2582,8 +2619,8 @@ static void save_PopMatrix( void )
static void save_PopName( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
- (void) alloc_instruction( ctx, OPCODE_POP_NAME, 0 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
if (ctx->ExecuteFlag) {
(*ctx->Exec->PopName)();
}
@@ -2595,11 +2632,11 @@ static void save_PrioritizeTextures( GLsizei num, const GLuint *textures,
{
GET_CURRENT_CONTEXT(ctx);
GLint i;
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
for (i=0;i<num;i++) {
Node *n;
- n = alloc_instruction( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
if (n) {
n[1].ui = textures[i];
n[2].f = priorities[i];
@@ -2615,8 +2652,8 @@ static void save_PushAttrib( GLbitfield mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PUSH_ATTRIB, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
if (n) {
n[1].bf = mask;
}
@@ -2629,8 +2666,8 @@ static void save_PushAttrib( GLbitfield mask )
static void save_PushMatrix( void )
{
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
- (void) alloc_instruction( ctx, OPCODE_PUSH_MATRIX, 0 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
if (ctx->ExecuteFlag) {
(*ctx->Exec->PushMatrix)();
}
@@ -2641,8 +2678,8 @@ static void save_PushName( GLuint name )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PUSH_NAME, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
if (n) {
n[1].ui = name;
}
@@ -2656,8 +2693,8 @@ static void save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_RASTER_POS, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
if (n) {
n[1].f = x;
n[2].f = y;
@@ -2789,8 +2826,8 @@ static void save_PassThrough( GLfloat token )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PASSTHROUGH, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
if (n) {
n[1].f = token;
}
@@ -2804,8 +2841,8 @@ static void save_ReadBuffer( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_READ_BUFFER, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
if (n) {
n[1].e = mode;
}
@@ -2819,8 +2856,8 @@ static void save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_RECTF, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RECTF, 4 );
if (n) {
n[1].f = x1;
n[2].f = y1;
@@ -2873,8 +2910,8 @@ save_ResetHistogram(GLenum target)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_RESET_HISTOGRAM, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
if (n) {
n[1].e = target;
}
@@ -2889,8 +2926,8 @@ save_ResetMinmax(GLenum target)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_RESET_MIN_MAX, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
if (n) {
n[1].e = target;
}
@@ -2902,9 +2939,19 @@ save_ResetMinmax(GLenum target)
static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
{
- GLfloat m[16];
- gl_rotation_matrix( angle, x, y, z, m );
- save_MultMatrixf( m ); /* save and maybe execute */
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
+ if (n) {
+ n[1].f = angle;
+ n[2].f = x;
+ n[3].f = y;
+ n[4].f = z;
+ }
+ if (ctx->ExecuteFlag) {
+ (*ctx->Exec->Rotatef)( angle, x, y, z );
+ }
}
@@ -2918,8 +2965,8 @@ static void save_Scalef( GLfloat x, GLfloat y, GLfloat z )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_SCALE, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
if (n) {
n[1].f = x;
n[2].f = y;
@@ -2941,8 +2988,8 @@ static void save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_SCISSOR, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
if (n) {
n[1].i = x;
n[2].i = y;
@@ -2959,8 +3006,8 @@ static void save_ShadeModel( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_SHADE_MODEL, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
if (n) {
n[1].e = mode;
}
@@ -2974,8 +3021,8 @@ static void save_StencilFunc( GLenum func, GLint ref, GLuint mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_STENCIL_FUNC, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
if (n) {
n[1].e = func;
n[2].i = ref;
@@ -2991,8 +3038,8 @@ static void save_StencilMask( GLuint mask )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_STENCIL_MASK, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
if (n) {
n[1].ui = mask;
}
@@ -3006,8 +3053,8 @@ static void save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_STENCIL_OP, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
if (n) {
n[1].e = fail;
n[2].e = zfail;
@@ -3023,8 +3070,8 @@ static void save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEXENV, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -3069,8 +3116,8 @@ static void save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEXGEN, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
if (n) {
n[1].e = coord;
n[2].e = pname;
@@ -3131,8 +3178,8 @@ static void save_TexParameterfv( GLenum target,
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEXPARAMETER, 6 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
if (n) {
n[1].e = target;
n[2].e = pname;
@@ -3187,8 +3234,8 @@ static void save_TexImage1D( GLenum target,
GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
pixels, &ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEX_IMAGE1D, 8 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3226,8 +3273,8 @@ static void save_TexImage2D( GLenum target,
GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
pixels, &ctx->Unpack);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEX_IMAGE2D, 9 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3267,8 +3314,8 @@ static void save_TexImage3D( GLenum target,
Node *n;
GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
pixels, &ctx->Unpack);
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEX_IMAGE3D, 10 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3300,8 +3347,8 @@ static void save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
Node *n;
GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type,
pixels, &ctx->Unpack);
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3331,8 +3378,8 @@ static void save_TexSubImage2D( GLenum target, GLint level,
Node *n;
GLvoid *image = _mesa_unpack_image(width, height, 1, format, type,
pixels, &ctx->Unpack);
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3364,8 +3411,8 @@ static void save_TexSubImage3D( GLenum target, GLint level,
Node *n;
GLvoid *image = _mesa_unpack_image(width, height, depth, format, type,
pixels, &ctx->Unpack);
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3394,8 +3441,8 @@ static void save_Translatef( GLfloat x, GLfloat y, GLfloat z )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_TRANSLATE, 3 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TRANSLATE, 3 );
if (n) {
n[1].f = x;
n[2].f = y;
@@ -3418,8 +3465,8 @@ static void save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_VIEWPORT, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_VIEWPORT, 4 );
if (n) {
n[1].i = x;
n[2].i = y;
@@ -3436,8 +3483,8 @@ static void save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_WINDOW_POS, 4 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_WINDOW_POS, 4 );
if (n) {
n[1].f = x;
n[2].f = y;
@@ -3571,8 +3618,8 @@ static void save_ActiveTextureARB( GLenum target )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
if (n) {
n[1].e = target;
}
@@ -3587,8 +3634,8 @@ static void save_ClientActiveTextureARB( GLenum target )
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIENT_ACTIVE_TEXTURE, 1 );
if (n) {
n[1].e = target;
}
@@ -3603,32 +3650,32 @@ static void save_ClientActiveTextureARB( GLenum target )
static void save_LoadTransposeMatrixdARB( const GLdouble m[16] )
{
- GLdouble tm[16];
- gl_matrix_transposed(tm, m);
- save_LoadMatrixd(tm);
+ GLfloat tm[16];
+ _math_transposefd(tm, m);
+ save_LoadMatrixf(tm);
}
static void save_LoadTransposeMatrixfARB( const GLfloat m[16] )
{
GLfloat tm[16];
- gl_matrix_transposef(tm, m);
+ _math_transposef(tm, m);
save_LoadMatrixf(tm);
}
static void save_MultTransposeMatrixdARB( const GLdouble m[16] )
{
- GLdouble tm[16];
- gl_matrix_transposed(tm, m);
- save_MultMatrixd(tm);
+ GLfloat tm[16];
+ _math_transposefd(tm, m);
+ save_MultMatrixf(tm);
}
static void save_MultTransposeMatrixfARB( const GLfloat m[16] )
{
GLfloat tm[16];
- gl_matrix_transposef(tm, m);
+ _math_transposef(tm, m);
save_MultMatrixf(tm);
}
@@ -3637,8 +3684,8 @@ static void save_PixelTexGenSGIX(GLenum mode)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
if (n) {
n[1].e = mode;
}
@@ -3664,7 +3711,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
else {
Node *n;
GLvoid *image;
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
/* make copy of image */
image = MALLOC(imageSize);
if (!image) {
@@ -3672,7 +3719,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
return;
}
MEMCPY(image, data, imageSize);
- n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3708,7 +3755,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
else {
Node *n;
GLvoid *image;
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
/* make copy of image */
image = MALLOC(imageSize);
if (!image) {
@@ -3716,7 +3763,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
return;
}
MEMCPY(image, data, imageSize);
- n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3753,7 +3800,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
else {
Node *n;
GLvoid *image;
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
/* make copy of image */
image = MALLOC(imageSize);
if (!image) {
@@ -3761,7 +3808,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
return;
}
MEMCPY(image, data, imageSize);
- n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3793,7 +3840,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
GLvoid *image;
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
/* make copy of image */
image = MALLOC(imageSize);
@@ -3802,7 +3849,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
return;
}
MEMCPY(image, data, imageSize);
- n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3832,7 +3879,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
GLvoid *image;
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
/* make copy of image */
image = MALLOC(imageSize);
@@ -3841,7 +3888,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
return;
}
MEMCPY(image, data, imageSize);
- n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3873,7 +3920,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
GLvoid *image;
GET_CURRENT_CONTEXT(ctx);
- FLUSH_VB(ctx, "dlist");
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
/* make copy of image */
image = MALLOC(imageSize);
@@ -3882,7 +3929,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
return;
}
MEMCPY(image, data, imageSize);
- n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
if (n) {
n[1].e = target;
n[2].i = level;
@@ -3912,8 +3959,8 @@ static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
{
GET_CURRENT_CONTEXT(ctx);
Node *n;
- FLUSH_VB(ctx, "dlist");
- n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
if (n) {
n[1].e = target;
n[2].i = value;
@@ -3941,56 +3988,6 @@ static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
save_PixelTexGenParameteriSGIS(target, (GLint) *value);
}
-void gl_compile_cassette( GLcontext *ctx )
-{
- Node *n = alloc_instruction( ctx, OPCODE_VERTEX_CASSETTE, 8 );
- struct immediate *im = ctx->input;
-
- if (!n)
- return;
-
-
- /* Do some easy optimizations of the cassette.
- */
-#if 0
- if (0 && im->v.Obj.size < 4 && im->Count > 15) {
- im->Bounds = (GLfloat (*)[3]) MALLOC(6 * sizeof(GLfloat));
- (gl_calc_bound_tab[im->v.Obj.size])( im->Bounds, &im->v.Obj );
- }
-#endif
-
- n[1].data = (void *)im;
- n[2].ui = im->Start;
- n[3].ui = im->Count;
- n[4].ui = im->BeginState;
- n[5].ui = im->OrFlag;
- n[6].ui = im->AndFlag;
- n[7].ui = im->LastData;
- n[8].ui = im->LastPrimitive;
-
- if (im->Count > VB_MAX - 4) {
-
- struct immediate *new_im = gl_immediate_alloc(ctx);
- if (!new_im) return;
- SET_IMMEDIATE( ctx, new_im );
- gl_reset_input( ctx );
-
- } else {
- im->Count++;;
- im->Start = im->Count; /* don't clear anything in reset_input */
- im->ref_count++;
-
- im->Primitive[im->Start] = ctx->Current.Primitive;
- im->LastPrimitive = im->Start;
- im->BeginState = VERT_BEGIN_0;
- im->OrFlag = 0;
- im->AndFlag = ~0;
-
- if (0)
- fprintf(stderr, "in compile_cassette, BeginState is %x\n",
- im->BeginState);
- }
-}
/* KW: Compile commands
*
@@ -4000,7 +3997,7 @@ void gl_compile_cassette( GLcontext *ctx )
void gl_save_error( GLcontext *ctx, GLenum error, const char *s )
{
Node *n;
- n = alloc_instruction( ctx, OPCODE_ERROR, 2 );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
if (n) {
n[1].e = error;
n[2].data = (void *) s;
@@ -4037,12 +4034,11 @@ static void execute_list( GLcontext *ctx, GLuint list )
{
Node *n;
GLboolean done;
- OpCode opcode;
if (!islist(ctx,list))
return;
-/* mesa_print_display_list( list ); */
+/* mesa_print_display_list( list ); */
ctx->CallDepth++;
@@ -4050,49 +4046,18 @@ static void execute_list( GLcontext *ctx, GLuint list )
done = GL_FALSE;
while (!done) {
- opcode = n[0].opcode;
+ OpCode opcode = n[0].opcode;
+ int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
- switch (opcode) {
- case OPCODE_ERROR:
- gl_error( ctx, n[1].e, (const char *) n[2].data );
- break;
- case OPCODE_VERTEX_CASSETTE: {
- struct immediate *IM;
-
- if (ctx->NewState)
- gl_update_state(ctx);
- if (ctx->CompileCVAFlag) {
- ctx->CompileCVAFlag = 0;
- ctx->CVA.elt.pipeline_valid = 0;
- }
- if (!ctx->CVA.elt.pipeline_valid)
- gl_build_immediate_pipeline( ctx );
-
-
- IM = (struct immediate *) n[1].data;
- IM->Start = n[2].ui;
- IM->Count = n[3].ui;
- IM->BeginState = n[4].ui;
- IM->OrFlag = n[5].ui;
- IM->AndFlag = n[6].ui;
- IM->LastData = n[7].ui;
- IM->LastPrimitive = n[8].ui;
-
- if ((MESA_VERBOSE & VERBOSE_DISPLAY_LIST) &&
- (MESA_VERBOSE & VERBOSE_IMMEDIATE))
- gl_print_cassette( (struct immediate *) n[1].data );
-
- if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) {
- fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ",
- IM->id,
- IM->Start, IM->Count, IM->BeginState);
- gl_print_vert_flags("orflag", IM->OrFlag);
- }
-
- gl_fixup_cassette( ctx, (struct immediate *) n[1].data );
- gl_execute_cassette( ctx, (struct immediate *) n[1].data );
- break;
- }
+ if (i >= 0 && i < ctx->listext.nr_opcodes) {
+ ctx->listext.opcode[i].execute(ctx, &n[1]);
+ n += ctx->listext.opcode[i].size;
+ }
+ else {
+ switch (opcode) {
+ case OPCODE_ERROR:
+ gl_error( ctx, n[1].e, (const char *) n[2].data );
+ break;
case OPCODE_ACCUM:
(*ctx->Exec->Accum)( n[1].e, n[2].f );
break;
@@ -4518,7 +4483,7 @@ static void execute_list( GLcontext *ctx, GLuint list )
break;
case OPCODE_RECTF:
(*ctx->Exec->Rectf)( n[1].f, n[2].f, n[3].f, n[4].f );
- FLUSH_VB( ctx, "dlist rectf" );
+ FLUSH_TNL( ctx, FLUSH_STORED_VERTICES );
break;
case OPCODE_RESET_HISTOGRAM:
(*ctx->Exec->ResetHistogram)( n[1].e );
@@ -4526,6 +4491,9 @@ static void execute_list( GLcontext *ctx, GLuint list )
case OPCODE_RESET_MIN_MAX:
(*ctx->Exec->ResetMinmax)( n[1].e );
break;
+ case OPCODE_ROTATE:
+ (*ctx->Exec->Rotatef)( n[1].f, n[2].f, n[3].f, n[4].f );
+ break;
case OPCODE_SCALE:
(*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f );
break;
@@ -4716,13 +4684,13 @@ static void execute_list( GLcontext *ctx, GLuint list )
gl_problem( ctx, msg );
}
done = GL_TRUE;
- }
+ }
- /* increment n to point to next compiled command */
- if (opcode!=OPCODE_CONTINUE) {
- n += InstSize[opcode];
+ /* increment n to point to next compiled command */
+ if (opcode!=OPCODE_CONTINUE) {
+ n += InstSize[opcode];
+ }
}
-
}
ctx->CallDepth--;
}
@@ -4817,8 +4785,8 @@ void
_mesa_NewList( GLuint list, GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
- struct immediate *IM;
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glNewList");
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
if (MESA_VERBOSE&VERBOSE_API)
fprintf(stderr, "glNewList %u %s\n", list, gl_lookup_enum_by_nr(mode));
@@ -4844,15 +4812,11 @@ _mesa_NewList( GLuint list, GLenum mode )
ctx->CurrentBlock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
ctx->CurrentListPtr = ctx->CurrentBlock;
ctx->CurrentPos = 0;
-
- IM = gl_immediate_alloc( ctx );
- SET_IMMEDIATE( ctx, IM );
- gl_reset_input( ctx );
-
ctx->CompileFlag = GL_TRUE;
- ctx->CompileCVAFlag = GL_FALSE;
ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
+ ctx->Driver.NewList( ctx, list, mode );
+
ctx->CurrentDispatch = ctx->Save;
_glapi_set_dispatch( ctx->CurrentDispatch );
}
@@ -4870,6 +4834,8 @@ _mesa_EndList( void )
fprintf(stderr, "glEndList\n");
ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glEndList" );
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
+
/* Check that a list is under construction */
if (!ctx->CurrentListPtr) {
@@ -4877,7 +4843,7 @@ _mesa_EndList( void )
return;
}
- (void) alloc_instruction( ctx, OPCODE_END_OF_LIST, 0 );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
/* Destroy old list, if any */
gl_destroy_list(ctx, ctx->CurrentListNum);
@@ -4892,15 +4858,8 @@ _mesa_EndList( void )
ctx->CurrentListPtr = NULL;
ctx->ExecuteFlag = GL_TRUE;
ctx->CompileFlag = GL_FALSE;
- /* ctx->CompileCVAFlag = ...; */
- /* KW: Put back the old input pointer.
- */
- if (--ctx->input->ref_count == 0)
- gl_immediate_free( ctx->input );
-
- SET_IMMEDIATE( ctx, ctx->VB->IM );
- gl_reset_input( ctx );
+ ctx->Driver.EndList( ctx );
/* Haven't tracked down why this is needed.
*/
@@ -4928,7 +4887,7 @@ _mesa_CallList( GLuint list )
save_compile_flag = ctx->CompileFlag;
ctx->CompileFlag = GL_FALSE;
- FLUSH_VB( ctx, "call list" );
+ FLUSH_TNL( ctx, (FLUSH_STORED_VERTICES | FLUSH_UPDATE_CURRENT) );
execute_list( ctx, list );
ctx->CompileFlag = save_compile_flag;
@@ -4958,7 +4917,7 @@ _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
save_compile_flag = ctx->CompileFlag;
ctx->CompileFlag = GL_FALSE;
- FLUSH_VB( ctx, "call lists" );
+ FLUSH_TNL( ctx, (FLUSH_STORED_VERTICES | FLUSH_UPDATE_CURRENT) );
for (i=0;i<n;i++) {
list = translate_id( i, type, lists );
@@ -5002,7 +4961,7 @@ _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize )
/* GL 1.0 */
table->Accum = save_Accum;
table->AlphaFunc = save_AlphaFunc;
- table->Begin = save_Begin;
+ table->Begin = _mesa_Begin;
table->Bitmap = save_Bitmap;
table->BlendFunc = save_BlendFunc;
table->CallList = save_CallList;
@@ -5565,7 +5524,6 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
{
Node *n;
GLboolean done;
- OpCode opcode;
if (!glIsList(list)) {
fprintf(f,"%u is not a display list ID\n",list);
@@ -5578,9 +5536,14 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
done = n ? GL_FALSE : GL_TRUE;
while (!done) {
- opcode = n[0].opcode;
-
- switch (opcode) {
+ OpCode opcode = n[0].opcode;
+ int i = (int)n[0].opcode - (int)OPCODE_DRV_0;
+
+ if (i >= 0 && i < ctx->listext.nr_opcodes) {
+ ctx->listext.opcode[i].print(ctx, &n[1]);
+ n += ctx->listext.opcode[i].size;
+ } else {
+ switch (opcode) {
case OPCODE_ACCUM:
fprintf(f,"accum %s %g\n", enum_string(n[1].e), n[2].f );
break;
@@ -5663,6 +5626,9 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
case OPCODE_RECTF:
fprintf( f, "Rectf %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f);
break;
+ case OPCODE_ROTATE:
+ fprintf(f,"Rotate %g %g %g %g\n", n[1].f, n[2].f, n[3].f, n[4].f );
+ break;
case OPCODE_SCALE:
fprintf(f,"Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
break;
@@ -5683,13 +5649,6 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
case OPCODE_ERROR:
fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
break;
- case OPCODE_VERTEX_CASSETTE:
- fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n",
- ((struct immediate *) n[1].data)->id,
- n[2].ui,
- n[3].ui);
- gl_print_cassette( (struct immediate *) n[1].data );
- break;
case OPCODE_CONTINUE:
fprintf(f,"DISPLAY-LIST-CONTINUE\n");
n = (Node *) n[1].next;
@@ -5707,11 +5666,11 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
else {
fprintf(f,"command %d, %u operands\n",opcode,InstSize[opcode]);
}
- }
-
- /* increment n to point to next compiled command */
- if (opcode!=OPCODE_CONTINUE) {
- n += InstSize[opcode];
+ }
+ /* increment n to point to next compiled command */
+ if (opcode!=OPCODE_CONTINUE) {
+ n += InstSize[opcode];
+ }
}
}
}
diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h
index e24ce6fe738..cbe8a4b47c2 100644
--- a/src/mesa/main/dlist.h
+++ b/src/mesa/main/dlist.h
@@ -1,4 +1,4 @@
-/* $Id: dlist.h,v 1.6 2000/09/24 16:11:55 brianp Exp $ */
+/* $Id: dlist.h,v 1.7 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -54,9 +54,17 @@ extern void _mesa_NewList( GLuint list, GLenum mode );
extern void _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize );
-extern void gl_compile_cassette( GLcontext *ctx );
-
extern void gl_save_error( GLcontext *ctx, GLenum error, const char *s );
+void *
+_mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz );
+
+int
+_mesa_alloc_opcode( GLcontext *ctx, GLuint sz,
+ void (*execute)( GLcontext *, void * ),
+ void (*destroy)( GLcontext *, void * ),
+ void (*print)( GLcontext *, void * ) );
+
+
#endif
diff --git a/src/mesa/main/drawpix.c b/src/mesa/main/drawpix.c
index afdc5952734..34e1dcf991b 100644
--- a/src/mesa/main/drawpix.c
+++ b/src/mesa/main/drawpix.c
@@ -1,4 +1,4 @@
-/* $Id: drawpix.c,v 1.44 2000/10/31 18:09:44 keithw Exp $ */
+/* $Id: drawpix.c,v 1.45 2000/11/16 21:05:34 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,6 +31,7 @@
#include "glheader.h"
#include "colormac.h"
#include "context.h"
+#include "drawpix.h"
#include "feedback.h"
#include "macros.h"
#include "mem.h"
@@ -52,7 +53,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels )
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDrawPixels");
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "_mesa_DrawPixels" );
if (ctx->RenderMode==GL_RENDER) {
GLint x, y;
@@ -86,6 +87,9 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
if (ctx->Current.RasterPosValid) {
GLfloat color[4];
GLfloat texcoord[4], invq;
+
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
+
color[0] = CHAN_TO_FLOAT(ctx->Current.Color[0]);
color[1] = CHAN_TO_FLOAT(ctx->Current.Color[1]);
color[2] = CHAN_TO_FLOAT(ctx->Current.Color[2]);
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 3d21f95bea1..afcb916fe8a 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -1,4 +1,4 @@
-/* $Id: enable.c,v 1.31 2000/11/05 18:40:57 keithw Exp $ */
+/* $Id: enable.c,v 1.32 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,13 +33,14 @@
#include "enable.h"
#include "light.h"
#include "macros.h"
-#include "matrix.h"
#include "mmath.h"
#include "simple_list.h"
#include "types.h"
-#include "vbfill.h"
-#include "xform.h"
#include "enums.h"
+
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+
#endif
@@ -98,10 +99,14 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
ctx->_Enabled |= ENABLE_USERCLIP;
ctx->Transform._AnyClip++;
- if (ctx->ProjectionMatrix.flags & MAT_DIRTY_ALL_OVER) {
- gl_matrix_analyze( &ctx->ProjectionMatrix );
+ if (ctx->ProjectionMatrix.flags & MAT_DIRTY) {
+ _math_matrix_analyze( &ctx->ProjectionMatrix );
}
+ /* This derived state also calculated in clip.c and
+ * from gl_update_state() on changes to EyeUserPlane
+ * and ctx->ProjectionMatrix respectively.
+ */
gl_transform_vector( ctx->Transform._ClipUserPlane[p],
ctx->Transform.EyeUserPlane[p],
ctx->ProjectionMatrix.inv );
@@ -113,10 +118,13 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
break;
case GL_COLOR_MATERIAL:
if (ctx->Light.ColorMaterialEnabled!=state) {
- ctx->Light.ColorMaterialEnabled = state;
+ ctx->Light.ColorMaterialEnabled = state;
ctx->NewState |= _NEW_LIGHT;
- if (state)
+
+ if (state) {
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
gl_update_color_material( ctx, ctx->Current.Color );
+ }
}
break;
case GL_CULL_FACE:
diff --git a/src/mesa/main/eval.c b/src/mesa/main/eval.c
index 1c779eb5e32..1cb8e26d1ac 100644
--- a/src/mesa/main/eval.c
+++ b/src/mesa/main/eval.c
@@ -1,4 +1,4 @@
-/* $Id: eval.c,v 1.14 2000/10/30 13:32:00 keithw Exp $ */
+/* $Id: eval.c,v 1.15 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,479 +49,9 @@
#include "mem.h"
#include "mmath.h"
#include "types.h"
-#include "vb.h"
-#include "vbcull.h"
-#include "vbfill.h"
-#include "vbxform.h"
#endif
-static GLfloat inv_tab[MAX_EVAL_ORDER];
-
-/*
- * Do one-time initialization for evaluators.
- */
-void gl_init_eval( void )
-{
- static int init_flag = 0;
- GLuint i;
-
- /* Compute a table of nCr (combination) values used by the
- * Bernstein polynomial generator.
- */
-
- /* KW: precompute 1/x for useful x.
- */
- if (init_flag==0)
- {
- for (i = 1 ; i < MAX_EVAL_ORDER ; i++)
- inv_tab[i] = 1.0 / i;
- }
-
- init_flag = 1;
-}
-
-
-
-/*
- * Horner scheme for Bezier curves
- *
- * Bezier curves can be computed via a Horner scheme.
- * Horner is numerically less stable than the de Casteljau
- * algorithm, but it is faster. For curves of degree n
- * the complexity of Horner is O(n) and de Casteljau is O(n^2).
- * Since stability is not important for displaying curve
- * points I decided to use the Horner scheme.
- *
- * A cubic Bezier curve with control points b0, b1, b2, b3 can be
- * written as
- *
- * (([3] [3] ) [3] ) [3]
- * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
- *
- * [n]
- * where s=1-t and the binomial coefficients [i]. These can
- * be computed iteratively using the identity:
- *
- * [n] [n ] [n]
- * [i] = (n-i+1)/i * [i-1] and [0] = 1
- */
-
-
-static void
-horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t,
- GLuint dim, GLuint order)
-{
- GLfloat s, powert;
- GLuint i, k, bincoeff;
-
- if(order >= 2)
- {
- bincoeff = order-1;
- s = 1.0-t;
-
- for(k=0; k<dim; k++)
- out[k] = s*cp[k] + bincoeff*t*cp[dim+k];
-
- for(i=2, cp+=2*dim, powert=t*t; i<order; i++, powert*=t, cp +=dim)
- {
- bincoeff *= order-i;
- bincoeff *= inv_tab[i];
-
- for(k=0; k<dim; k++)
- out[k] = s*out[k] + bincoeff*powert*cp[k];
- }
- }
- else /* order=1 -> constant curve */
- {
- for(k=0; k<dim; k++)
- out[k] = cp[k];
- }
-}
-
-/*
- * Tensor product Bezier surfaces
- *
- * Again the Horner scheme is used to compute a point on a
- * TP Bezier surface. First a control polygon for a curve
- * on the surface in one parameter direction is computed,
- * then the point on the curve for the other parameter
- * direction is evaluated.
- *
- * To store the curve control polygon additional storage
- * for max(uorder,vorder) points is needed in the
- * control net cn.
- */
-
-static void
-horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v,
- GLuint dim, GLuint uorder, GLuint vorder)
-{
- GLfloat *cp = cn + uorder*vorder*dim;
- GLuint i, uinc = vorder*dim;
-
- if(vorder > uorder)
- {
- if(uorder >= 2)
- {
- GLfloat s, poweru;
- GLuint j, k, bincoeff;
-
- /* Compute the control polygon for the surface-curve in u-direction */
- for(j=0; j<vorder; j++)
- {
- GLfloat *ucp = &cn[j*dim];
-
- /* Each control point is the point for parameter u on a */
- /* curve defined by the control polygons in u-direction */
- bincoeff = uorder-1;
- s = 1.0-u;
-
- for(k=0; k<dim; k++)
- cp[j*dim+k] = s*ucp[k] + bincoeff*u*ucp[uinc+k];
-
- for(i=2, ucp+=2*uinc, poweru=u*u; i<uorder;
- i++, poweru*=u, ucp +=uinc)
- {
- bincoeff *= uorder-i;
- bincoeff *= inv_tab[i];
-
- for(k=0; k<dim; k++)
- cp[j*dim+k] = s*cp[j*dim+k] + bincoeff*poweru*ucp[k];
- }
- }
-
- /* Evaluate curve point in v */
- horner_bezier_curve(cp, out, v, dim, vorder);
- }
- else /* uorder=1 -> cn defines a curve in v */
- horner_bezier_curve(cn, out, v, dim, vorder);
- }
- else /* vorder <= uorder */
- {
- if(vorder > 1)
- {
- GLuint i;
-
- /* Compute the control polygon for the surface-curve in u-direction */
- for(i=0; i<uorder; i++, cn += uinc)
- {
- /* For constant i all cn[i][j] (j=0..vorder) are located */
- /* on consecutive memory locations, so we can use */
- /* horner_bezier_curve to compute the control points */
-
- horner_bezier_curve(cn, &cp[i*dim], v, dim, vorder);
- }
-
- /* Evaluate curve point in u */
- horner_bezier_curve(cp, out, u, dim, uorder);
- }
- else /* vorder=1 -> cn defines a curve in u */
- horner_bezier_curve(cn, out, u, dim, uorder);
- }
-}
-
-/*
- * The direct de Casteljau algorithm is used when a point on the
- * surface and the tangent directions spanning the tangent plane
- * should be computed (this is needed to compute normals to the
- * surface). In this case the de Casteljau algorithm approach is
- * nicer because a point and the partial derivatives can be computed
- * at the same time. To get the correct tangent length du and dv
- * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
- * Since only the directions are needed, this scaling step is omitted.
- *
- * De Casteljau needs additional storage for uorder*vorder
- * values in the control net cn.
- */
-
-static void
-de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
- GLfloat u, GLfloat v, GLuint dim,
- GLuint uorder, GLuint vorder)
-{
- GLfloat *dcn = cn + uorder*vorder*dim;
- GLfloat us = 1.0-u, vs = 1.0-v;
- GLuint h, i, j, k;
- GLuint minorder = uorder < vorder ? uorder : vorder;
- GLuint uinc = vorder*dim;
- GLuint dcuinc = vorder;
-
- /* Each component is evaluated separately to save buffer space */
- /* This does not drasticaly decrease the performance of the */
- /* algorithm. If additional storage for (uorder-1)*(vorder-1) */
- /* points would be available, the components could be accessed */
- /* in the innermost loop which could lead to less cache misses. */
-
-#define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)]
-#define DCN(I, J) dcn[(I)*dcuinc+(J)]
- if(minorder < 3)
- {
- if(uorder==vorder)
- {
- for(k=0; k<dim; k++)
- {
- /* Derivative direction in u */
- du[k] = vs*(CN(1,0,k) - CN(0,0,k)) +
- v*(CN(1,1,k) - CN(0,1,k));
-
- /* Derivative direction in v */
- dv[k] = us*(CN(0,1,k) - CN(0,0,k)) +
- u*(CN(1,1,k) - CN(1,0,k));
-
- /* bilinear de Casteljau step */
- out[k] = us*(vs*CN(0,0,k) + v*CN(0,1,k)) +
- u*(vs*CN(1,0,k) + v*CN(1,1,k));
- }
- }
- else if(minorder == uorder)
- {
- for(k=0; k<dim; k++)
- {
- /* bilinear de Casteljau step */
- DCN(1,0) = CN(1,0,k) - CN(0,0,k);
- DCN(0,0) = us*CN(0,0,k) + u*CN(1,0,k);
-
- for(j=0; j<vorder-1; j++)
- {
- /* for the derivative in u */
- DCN(1,j+1) = CN(1,j+1,k) - CN(0,j+1,k);
- DCN(1,j) = vs*DCN(1,j) + v*DCN(1,j+1);
-
- /* for the `point' */
- DCN(0,j+1) = us*CN(0,j+1,k) + u*CN(1,j+1,k);
- DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
- }
-
- /* remaining linear de Casteljau steps until the second last step */
- for(h=minorder; h<vorder-1; h++)
- for(j=0; j<vorder-h; j++)
- {
- /* for the derivative in u */
- DCN(1,j) = vs*DCN(1,j) + v*DCN(1,j+1);
-
- /* for the `point' */
- DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
- }
-
- /* derivative direction in v */
- dv[k] = DCN(0,1) - DCN(0,0);
-
- /* derivative direction in u */
- du[k] = vs*DCN(1,0) + v*DCN(1,1);
-
- /* last linear de Casteljau step */
- out[k] = vs*DCN(0,0) + v*DCN(0,1);
- }
- }
- else /* minorder == vorder */
- {
- for(k=0; k<dim; k++)
- {
- /* bilinear de Casteljau step */
- DCN(0,1) = CN(0,1,k) - CN(0,0,k);
- DCN(0,0) = vs*CN(0,0,k) + v*CN(0,1,k);
- for(i=0; i<uorder-1; i++)
- {
- /* for the derivative in v */
- DCN(i+1,1) = CN(i+1,1,k) - CN(i+1,0,k);
- DCN(i,1) = us*DCN(i,1) + u*DCN(i+1,1);
-
- /* for the `point' */
- DCN(i+1,0) = vs*CN(i+1,0,k) + v*CN(i+1,1,k);
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- }
-
- /* remaining linear de Casteljau steps until the second last step */
- for(h=minorder; h<uorder-1; h++)
- for(i=0; i<uorder-h; i++)
- {
- /* for the derivative in v */
- DCN(i,1) = us*DCN(i,1) + u*DCN(i+1,1);
-
- /* for the `point' */
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- }
-
- /* derivative direction in u */
- du[k] = DCN(1,0) - DCN(0,0);
-
- /* derivative direction in v */
- dv[k] = us*DCN(0,1) + u*DCN(1,1);
-
- /* last linear de Casteljau step */
- out[k] = us*DCN(0,0) + u*DCN(1,0);
- }
- }
- }
- else if(uorder == vorder)
- {
- for(k=0; k<dim; k++)
- {
- /* first bilinear de Casteljau step */
- for(i=0; i<uorder-1; i++)
- {
- DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
- for(j=0; j<vorder-1; j++)
- {
- DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
- DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
- }
- }
-
- /* remaining bilinear de Casteljau steps until the second last step */
- for(h=2; h<minorder-1; h++)
- for(i=0; i<uorder-h; i++)
- {
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- for(j=0; j<vorder-h; j++)
- {
- DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
- DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
- }
- }
-
- /* derivative direction in u */
- du[k] = vs*(DCN(1,0) - DCN(0,0)) +
- v*(DCN(1,1) - DCN(0,1));
-
- /* derivative direction in v */
- dv[k] = us*(DCN(0,1) - DCN(0,0)) +
- u*(DCN(1,1) - DCN(1,0));
-
- /* last bilinear de Casteljau step */
- out[k] = us*(vs*DCN(0,0) + v*DCN(0,1)) +
- u*(vs*DCN(1,0) + v*DCN(1,1));
- }
- }
- else if(minorder == uorder)
- {
- for(k=0; k<dim; k++)
- {
- /* first bilinear de Casteljau step */
- for(i=0; i<uorder-1; i++)
- {
- DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
- for(j=0; j<vorder-1; j++)
- {
- DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
- DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
- }
- }
-
- /* remaining bilinear de Casteljau steps until the second last step */
- for(h=2; h<minorder-1; h++)
- for(i=0; i<uorder-h; i++)
- {
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- for(j=0; j<vorder-h; j++)
- {
- DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
- DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
- }
- }
-
- /* last bilinear de Casteljau step */
- DCN(2,0) = DCN(1,0) - DCN(0,0);
- DCN(0,0) = us*DCN(0,0) + u*DCN(1,0);
- for(j=0; j<vorder-1; j++)
- {
- /* for the derivative in u */
- DCN(2,j+1) = DCN(1,j+1) - DCN(0,j+1);
- DCN(2,j) = vs*DCN(2,j) + v*DCN(2,j+1);
-
- /* for the `point' */
- DCN(0,j+1) = us*DCN(0,j+1 ) + u*DCN(1,j+1);
- DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
- }
-
- /* remaining linear de Casteljau steps until the second last step */
- for(h=minorder; h<vorder-1; h++)
- for(j=0; j<vorder-h; j++)
- {
- /* for the derivative in u */
- DCN(2,j) = vs*DCN(2,j) + v*DCN(2,j+1);
-
- /* for the `point' */
- DCN(0,j) = vs*DCN(0,j) + v*DCN(0,j+1);
- }
-
- /* derivative direction in v */
- dv[k] = DCN(0,1) - DCN(0,0);
-
- /* derivative direction in u */
- du[k] = vs*DCN(2,0) + v*DCN(2,1);
-
- /* last linear de Casteljau step */
- out[k] = vs*DCN(0,0) + v*DCN(0,1);
- }
- }
- else /* minorder == vorder */
- {
- for(k=0; k<dim; k++)
- {
- /* first bilinear de Casteljau step */
- for(i=0; i<uorder-1; i++)
- {
- DCN(i,0) = us*CN(i,0,k) + u*CN(i+1,0,k);
- for(j=0; j<vorder-1; j++)
- {
- DCN(i,j+1) = us*CN(i,j+1,k) + u*CN(i+1,j+1,k);
- DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
- }
- }
-
- /* remaining bilinear de Casteljau steps until the second last step */
- for(h=2; h<minorder-1; h++)
- for(i=0; i<uorder-h; i++)
- {
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- for(j=0; j<vorder-h; j++)
- {
- DCN(i,j+1) = us*DCN(i,j+1) + u*DCN(i+1,j+1);
- DCN(i,j) = vs*DCN(i,j) + v*DCN(i,j+1);
- }
- }
-
- /* last bilinear de Casteljau step */
- DCN(0,2) = DCN(0,1) - DCN(0,0);
- DCN(0,0) = vs*DCN(0,0) + v*DCN(0,1);
- for(i=0; i<uorder-1; i++)
- {
- /* for the derivative in v */
- DCN(i+1,2) = DCN(i+1,1) - DCN(i+1,0);
- DCN(i,2) = us*DCN(i,2) + u*DCN(i+1,2);
-
- /* for the `point' */
- DCN(i+1,0) = vs*DCN(i+1,0) + v*DCN(i+1,1);
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- }
-
- /* remaining linear de Casteljau steps until the second last step */
- for(h=minorder; h<uorder-1; h++)
- for(i=0; i<uorder-h; i++)
- {
- /* for the derivative in v */
- DCN(i,2) = us*DCN(i,2) + u*DCN(i+1,2);
-
- /* for the `point' */
- DCN(i,0) = us*DCN(i,0) + u*DCN(i+1,0);
- }
-
- /* derivative direction in u */
- du[k] = DCN(1,0) - DCN(0,0);
-
- /* derivative direction in v */
- dv[k] = us*DCN(0,2) + u*DCN(1,2);
-
- /* last linear de Casteljau step */
- out[k] = us*DCN(0,0) + u*DCN(1,0);
- }
- }
-#undef DCN
-#undef CN
-}
-
/*
* Return the number of components per control point for any type of
* evaluator. Return 0 if bad target.
@@ -1982,656 +1512,6 @@ _mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
-static void eval_points1( GLfloat outcoord[][4],
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint start,
- GLfloat du, GLfloat u1 )
-{
- GLuint i;
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & VERT_EVAL_P1)
- outcoord[i][0] = coord[i][0] * du + u1;
- else if (flags[i] & VERT_EVAL_ANY) {
- outcoord[i][0] = coord[i][0];
- outcoord[i][1] = coord[i][1];
- }
-}
-
-static void eval_points2( GLfloat outcoord[][4],
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint start,
- GLfloat du, GLfloat u1,
- GLfloat dv, GLfloat v1 )
-{
- GLuint i;
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & VERT_EVAL_P2) {
- outcoord[i][0] = coord[i][0] * du + u1;
- outcoord[i][1] = coord[i][1] * dv + v1;
- } else if (flags[i] & VERT_EVAL_ANY) {
- outcoord[i][0] = coord[i][0];
- outcoord[i][1] = coord[i][1];
- }
-}
-
-
-static const GLubyte dirty_flags[5] = {
- 0, /* not possible */
- VEC_DIRTY_0,
- VEC_DIRTY_1,
- VEC_DIRTY_2,
- VEC_DIRTY_3
-};
-
-
-static GLvector4f *eval1_4f( GLvector4f *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint start,
- GLuint dimension,
- struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLfloat (*to)[4] = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- ASSIGN_4V(to[i], 0,0,0,1);
- horner_bezier_curve(map->Points, to[i], u, dimension, map->Order);
- }
-
- dest->count = i;
- dest->start = VEC_ELT(dest, GLfloat, start);
- dest->size = MAX2(dest->size, dimension);
- dest->flags |= dirty_flags[dimension];
- return dest;
-}
-
-
-static GLvector1ui *eval1_1ui( GLvector1ui *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint start,
- struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLuint *to = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat tmp;
- horner_bezier_curve(map->Points, &tmp, u, 1, map->Order);
- to[i] = (GLuint) (GLint) tmp;
- }
-
- dest->start = VEC_ELT(dest, GLuint, start);
- dest->count = i;
- return dest;
-}
-
-static GLvector3f *eval1_norm( GLvector3f *dest,
- GLfloat coord[][4],
- GLuint *flags, /* not const */
- GLuint start,
- struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLfloat (*to)[3] = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- horner_bezier_curve(map->Points, to[i], u, 3, map->Order);
- flags[i+1] |= VERT_NORM; /* reset */
- }
-
- dest->start = VEC_ELT(dest, GLfloat, start);
- dest->count = i;
- return dest;
-}
-
-static GLvector4ub *eval1_color( GLvector4ub *dest,
- GLfloat coord[][4],
- GLuint *flags, /* not const */
- GLuint start,
- struct gl_1d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- GLubyte (*to)[4] = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C1|VERT_EVAL_P1)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat fcolor[4];
- horner_bezier_curve(map->Points, fcolor, u, 4, map->Order);
- FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
- flags[i+1] |= VERT_RGBA; /* reset */
- }
-
- dest->start = VEC_ELT(dest, GLubyte, start);
- dest->count = i;
- return dest;
-}
-
-
-
-
-static GLvector4f *eval2_obj_norm( GLvector4f *obj_ptr,
- GLvector3f *norm_ptr,
- GLfloat coord[][4],
- GLuint *flags,
- GLuint start,
- GLuint dimension,
- struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLfloat (*obj)[4] = obj_ptr->data;
- GLfloat (*normal)[3] = norm_ptr->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- GLfloat du[4], dv[4];
-
- ASSIGN_4V(obj[i], 0,0,0,1);
- de_casteljau_surf(map->Points, obj[i], du, dv, u, v, dimension,
- map->Uorder, map->Vorder);
-
- CROSS3(normal[i], du, dv);
- NORMALIZE_3FV(normal[i]);
- flags[i+1] |= VERT_NORM;
- }
-
- obj_ptr->start = VEC_ELT(obj_ptr, GLfloat, start);
- obj_ptr->count = i;
- obj_ptr->size = MAX2(obj_ptr->size, dimension);
- obj_ptr->flags |= dirty_flags[dimension];
- return obj_ptr;
-}
-
-
-static GLvector4f *eval2_4f( GLvector4f *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint start,
- GLuint dimension,
- struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLfloat (*to)[4] = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- horner_bezier_surf(map->Points, to[i], u, v, dimension,
- map->Uorder, map->Vorder);
- }
-
- dest->start = VEC_ELT(dest, GLfloat, start);
- dest->count = i;
- dest->size = MAX2(dest->size, dimension);
- dest->flags |= dirty_flags[dimension];
- return dest;
-}
-
-
-static GLvector3f *eval2_norm( GLvector3f *dest,
- GLfloat coord[][4],
- GLuint *flags,
- GLuint start,
- struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLfloat (*to)[3] = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- horner_bezier_surf(map->Points, to[i], u, v, 3,
- map->Uorder, map->Vorder);
- flags[i+1] |= VERT_NORM; /* reset */
- }
-
- dest->start = VEC_ELT(dest, GLfloat, start);
- dest->count = i;
- return dest;
-}
-
-
-static GLvector1ui *eval2_1ui( GLvector1ui *dest,
- GLfloat coord[][4],
- const GLuint *flags,
- GLuint start,
- struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLuint *to = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- GLfloat tmp;
- horner_bezier_surf(map->Points, &tmp, u, v, 1,
- map->Uorder, map->Vorder);
-
- to[i] = (GLuint) (GLint) tmp;
- }
-
- dest->start = VEC_ELT(dest, GLuint, start);
- dest->count = i;
- return dest;
-}
-
-
-
-static GLvector4ub *eval2_color( GLvector4ub *dest,
- GLfloat coord[][4],
- GLuint *flags,
- GLuint start,
- struct gl_2d_map *map )
-{
- const GLfloat u1 = map->u1;
- const GLfloat du = map->du;
- const GLfloat v1 = map->v1;
- const GLfloat dv = map->dv;
- GLubyte (*to)[4] = dest->data;
- GLuint i;
-
- for (i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (flags[i] & (VERT_EVAL_C2|VERT_EVAL_P2)) {
- GLfloat u = (coord[i][0] - u1) * du;
- GLfloat v = (coord[i][1] - v1) * dv;
- GLfloat fcolor[4];
- horner_bezier_surf(map->Points, fcolor, u, v, 4,
- map->Uorder, map->Vorder);
- FLOAT_RGBA_TO_CHAN_RGBA(to[i], fcolor);
- flags[i+1] |= VERT_RGBA; /* reset */
- }
-
- dest->start = VEC_ELT(dest, GLubyte, start);
- dest->count = i;
- return dest;
-}
-
-
-static GLvector4f *copy_4f( GLvector4f *out, CONST GLvector4f *in,
- const GLuint *flags,
- GLuint start )
-{
- GLfloat (*to)[4] = out->data;
- GLfloat (*from)[4] = in->data;
- GLuint i;
-
- for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (!(flags[i] & VERT_EVAL_ANY))
- COPY_4FV( to[i], from[i] );
-
- out->start = VEC_ELT(out, GLfloat, start);
- return out;
-}
-
-static GLvector3f *copy_3f( GLvector3f *out, CONST GLvector3f *in,
- const GLuint *flags,
- GLuint start )
-{
- GLfloat (*to)[3] = out->data;
- GLfloat (*from)[3] = in->data;
- GLuint i;
-
- for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (!(flags[i] & VERT_EVAL_ANY))
- COPY_3V( to[i], from[i] );
-
- out->start = VEC_ELT(out, GLfloat, start);
- return out;
-}
-
-static GLvector4ub *copy_4ub( GLvector4ub *out,
- CONST GLvector4ub *in,
- const GLuint *flags,
- GLuint start )
-{
- GLubyte (*to)[4] = out->data;
- GLubyte (*from)[4] = in->data;
- GLuint i;
-
- for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (!(flags[i] & VERT_EVAL_ANY))
- COPY_4UBV( to[i], from[i] );
-
- out->start = VEC_ELT(out, GLubyte, start);
- return out;
-}
-
-static GLvector1ui *copy_1ui( GLvector1ui *out,
- CONST GLvector1ui *in,
- const GLuint *flags,
- GLuint start )
-{
- GLuint *to = out->data;
- CONST GLuint *from = in->data;
- GLuint i;
-
- for ( i = start ; !(flags[i] & VERT_END_VB) ; i++)
- if (!(flags[i] & VERT_EVAL_ANY))
- to[i] = from[i];
-
- out->start = VEC_ELT(out, GLuint, start);
- return out;
-}
-
-
-/* KW: Rewrote this to perform eval on a whole buffer at once.
- * Only evaluates active data items, and avoids scribbling
- * the source buffer if we are running from a display list.
- *
- * If the user (in this case looser) sends eval coordinates
- * or runs a display list containing eval coords with no
- * vertex maps enabled, we have to either copy all non-eval
- * data to a new buffer, or find a way of working around
- * the eval data. I choose the second option.
- *
- * KW: This code not reached by cva - use IM to access storage.
- */
-void gl_eval_vb( struct vertex_buffer *VB )
-{
- struct immediate *IM = VB->IM;
- GLcontext *ctx = VB->ctx;
- GLuint req = ctx->CVA.elt.inputs;
- GLfloat (*coord)[4] = VB->ObjPtr->data;
- GLuint *flags = VB->Flag;
- GLuint new_flags = 0;
-
-
- GLuint any_eval1 = VB->OrFlag & (VERT_EVAL_C1|VERT_EVAL_P1);
- GLuint any_eval2 = VB->OrFlag & (VERT_EVAL_C2|VERT_EVAL_P2);
- GLuint all_eval = IM->AndFlag & VERT_EVAL_ANY;
-
- /* Handle the degenerate cases.
- */
- if (any_eval1 && !ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3) {
- VB->PurgeFlags |= (VERT_EVAL_C1|VERT_EVAL_P1);
- VB->EarlyCull = 0;
- any_eval1 = GL_FALSE;
- }
-
- if (any_eval2 && !ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3) {
- VB->PurgeFlags |= (VERT_EVAL_C2|VERT_EVAL_P2);
- VB->EarlyCull = 0;
- any_eval2 = GL_FALSE;
- }
-
- /* KW: This really is a degenerate case - doing this disables
- * culling, and causes dummy values for the missing vertices to be
- * transformed and clip tested. It also forces the individual
- * cliptesting of each primitive in vb_render. I wish there was a
- * nice alternative, but I can't say I want to put effort into
- * optimizing such a bad usage of the library - I'd much rather
- * work on useful changes.
- */
- if (VB->PurgeFlags) {
- if (!any_eval1 && !any_eval2 && all_eval) VB->Count = VB->Start;
- gl_purge_vertices( VB );
- if (!any_eval1 && !any_eval2) return;
- } else
- VB->IndirectCount = VB->Count;
-
- /* Translate points into coords.
- */
- if (any_eval1 && (VB->OrFlag & VERT_EVAL_P1))
- {
- eval_points1( IM->Obj, coord, flags, IM->Start,
- ctx->Eval.MapGrid1du,
- ctx->Eval.MapGrid1u1);
-
- coord = IM->Obj;
- }
-
- if (any_eval2 && (VB->OrFlag & VERT_EVAL_P2))
- {
- eval_points2( IM->Obj, coord, flags, IM->Start,
- ctx->Eval.MapGrid2du,
- ctx->Eval.MapGrid2u1,
- ctx->Eval.MapGrid2dv,
- ctx->Eval.MapGrid2v1 );
-
- coord = IM->Obj;
- }
-
- /* Perform the evaluations on active data elements.
- */
- if (req & VERT_INDEX)
- {
- GLvector1ui *in_index = VB->IndexPtr;
- GLvector1ui *out_index = &IM->v.Index;
-
- if (ctx->Eval.Map1Index && any_eval1)
- VB->IndexPtr = eval1_1ui( out_index, coord, flags, IM->Start,
- &ctx->EvalMap.Map1Index );
-
- if (ctx->Eval.Map2Index && any_eval2)
- VB->IndexPtr = eval2_1ui( out_index, coord, flags, IM->Start,
- &ctx->EvalMap.Map2Index );
-
- if (VB->IndexPtr != in_index) {
- new_flags |= VERT_INDEX;
- if (!all_eval)
- VB->IndexPtr = copy_1ui( out_index, in_index, flags, IM->Start );
- }
- }
-
- if (req & VERT_RGBA)
- {
- GLvector4ub *in_color = VB->ColorPtr;
- GLvector4ub *out_color = &IM->v.Color;
-
- if (ctx->Eval.Map1Color4 && any_eval1)
- VB->ColorPtr = eval1_color( out_color, coord, flags, IM->Start,
- &ctx->EvalMap.Map1Color4 );
-
- if (ctx->Eval.Map2Color4 && any_eval2)
- VB->ColorPtr = eval2_color( out_color, coord, flags, IM->Start,
- &ctx->EvalMap.Map2Color4 );
-
- if (VB->ColorPtr != in_color) {
- new_flags |= VERT_RGBA;
- if (!all_eval)
- VB->ColorPtr = copy_4ub( out_color, in_color, flags, IM->Start );
- }
-
- VB->Color[0] = VB->Color[1] = VB->ColorPtr;
- }
-
-
- if (req & VERT_NORM)
- {
- GLvector3f *in_normal = VB->NormalPtr;
- GLvector3f *out_normal = &IM->v.Normal;
-
- if (ctx->Eval.Map1Normal && any_eval1)
- VB->NormalPtr = eval1_norm( out_normal, coord, flags, IM->Start,
- &ctx->EvalMap.Map1Normal );
-
- if (ctx->Eval.Map2Normal && any_eval2)
- VB->NormalPtr = eval2_norm( out_normal, coord, flags, IM->Start,
- &ctx->EvalMap.Map2Normal );
-
- new_flags |= VERT_NORM;
-
- if (VB->NormalPtr != in_normal) {
- if (!all_eval)
- VB->NormalPtr = copy_3f( out_normal, in_normal, flags, IM->Start );
- }
- }
-
-
- if (req & VERT_TEX_ANY(0))
- {
- GLvector4f *tc = VB->TexCoordPtr[0];
- GLvector4f *in = tc;
- GLvector4f *out = &IM->v.TexCoord[0];
-
- if (any_eval1) {
- if (ctx->Eval.Map1TextureCoord4)
- tc = eval1_4f( out, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map1Texture4);
- else if (ctx->Eval.Map1TextureCoord3)
- tc = eval1_4f( out, coord, flags, IM->Start, 3,
- &ctx->EvalMap.Map1Texture3);
- else if (ctx->Eval.Map1TextureCoord2)
- tc = eval1_4f( out, coord, flags, IM->Start, 2,
- &ctx->EvalMap.Map1Texture2);
- else if (ctx->Eval.Map1TextureCoord1)
- tc = eval1_4f( out, coord, flags, IM->Start, 1,
- &ctx->EvalMap.Map1Texture1);
- }
-
- if (any_eval2) {
- if (ctx->Eval.Map2TextureCoord4)
- tc = eval2_4f( out, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map2Texture4);
- else if (ctx->Eval.Map2TextureCoord3)
- tc = eval2_4f( out, coord, flags, IM->Start,
- 3, &ctx->EvalMap.Map2Texture3);
- else if (ctx->Eval.Map2TextureCoord2)
- tc = eval2_4f( out, coord, flags, IM->Start,
- 2, &ctx->EvalMap.Map2Texture2);
- else if (ctx->Eval.Map2TextureCoord1)
- tc = eval2_4f( out, coord, flags, IM->Start,
- 1, &ctx->EvalMap.Map2Texture1);
- }
-
- if (tc != in) {
- new_flags |= VERT_TEX_ANY(0); /* fix for sizes.. */
- if (!all_eval)
- tc = copy_4f( out, in, flags, IM->Start );
- }
-
- VB->TexCoordPtr[0] = tc;
- }
-
-
- {
- GLvector4f *in = VB->ObjPtr;
- GLvector4f *out = &IM->v.Obj;
- GLvector4f *obj = in;
-
- if (any_eval1) {
- if (ctx->Eval.Map1Vertex4)
- obj = eval1_4f( out, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map1Vertex4);
- else
- obj = eval1_4f( out, coord, flags, IM->Start,
- 3, &ctx->EvalMap.Map1Vertex3);
- }
-
- if (any_eval2) {
- GLvector3f *in_normal = VB->NormalPtr;
- GLvector3f *out_normal = &IM->v.Normal;
-
- if (ctx->Eval.Map2Vertex4)
- {
- if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
- obj = eval2_obj_norm( out, out_normal, coord, flags,
- IM->Start, 4, &ctx->EvalMap.Map2Vertex4 );
- VB->NormalPtr = out_normal;
- new_flags |= VERT_NORM;
- }
- else
- obj = eval2_4f( out, coord, flags, IM->Start,
- 4, &ctx->EvalMap.Map2Vertex4 );
- }
- else if (ctx->Eval.Map2Vertex3)
- {
- if (ctx->Eval.AutoNormal && (req & VERT_NORM)) {
- obj = eval2_obj_norm( out, out_normal, coord, flags,
- IM->Start, 3, &ctx->EvalMap.Map2Vertex3 );
- VB->NormalPtr = out_normal;
- new_flags |= VERT_NORM;
- }
- else
- obj = eval2_4f( out, coord, flags, IM->Start,
- 3, &ctx->EvalMap.Map2Vertex3 );
- }
-
-
- if (VB->NormalPtr != in_normal) {
- if (!all_eval)
- VB->NormalPtr = copy_3f( out_normal, in_normal, flags,
- IM->Start );
- }
- }
-
- if (obj != in && !all_eval)
- obj = copy_4f( out, in, flags, IM->Start );
-
- VB->ObjPtr = obj;
- }
-
- if (new_flags) {
- GLuint *oldflags = VB->Flag;
- GLuint *flags = VB->Flag = VB->EvaluatedFlags;
- GLuint i;
- GLuint count = VB->Count;
- GLuint andflag = VB->IM->AndFlag;
-
- if (!flags) {
- VB->EvaluatedFlags = (GLuint *) MALLOC(VB->Size * sizeof(GLuint));
- flags = VB->Flag = VB->EvaluatedFlags;
- }
-
- if (all_eval) {
- for (i = 0 ; i <= count ; i++)
- flags[i] = oldflags[i] | new_flags;
- andflag |= new_flags;
- } else {
- andflag = ~0;
- for (i = 0 ; i <= count ; i++) {
- flags[i] = oldflags[i];
- if (flags[i] & VERT_EVAL_ANY)
- flags[i] |= new_flags;
- andflag &= flags[i];
- }
- }
-
- VB->OrFlag |= new_flags;
- VB->CullMode = (GLubyte) ((andflag & VERT_NORM) ? 0 : COMPACTED_NORMALS);
- }
-}
-
-
void
_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
{
@@ -2694,279 +1574,4 @@ _mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
-/* KW: If are compiling, we don't know whether eval will produce a
- * vertex when it is run in the future. If this is pure immediate
- * mode, eval is a noop if neither vertex map is enabled.
- *
- * Thus we need to have a check in the display list code or
- * elsewhere for eval(1,2) vertices in the case where
- * map(1,2)_vertex is disabled, and to purge those vertices from
- * the vb. This is currently done
- * via modifications to the cull_vb and render_vb operations, and
- * by using the existing cullmask mechanism for all other operations.
- */
-
-
-/* KW: Because the eval values don't become 'current', fixup will flow
- * through these vertices, and then evaluation will write on top
- * of the fixup results.
- *
- * This is a little inefficient, but at least it is correct. This
- * could be short-circuited in the case where all vertices are
- * eval-vertices, or more generally by a cullmask in fixup.
- *
- * Note: using Obj to hold eval coord data. This data is actually
- * transformed if eval is disabled. But disabling eval & sending
- * eval coords is stupid, right?
- */
-
-
-#define EVALCOORD1(IM, x) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_C1; \
- ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
- if (count == VB_MAX-1) \
- _mesa_maybe_transform_vb( IM ); \
-}
-
-#define EVALCOORD2(IM, x, y) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_C2; \
- ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
- if (count == VB_MAX-1) \
- _mesa_maybe_transform_vb( IM ); \
-}
-
-#define EVALPOINT1(IM, x) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_P1; \
- ASSIGN_4V(IM->Obj[count], x, 0, 0, 1); \
- if (count == VB_MAX-1) \
- _mesa_maybe_transform_vb( IM ); \
-}
-
-#define EVALPOINT2(IM, x, y) \
-{ \
- GLuint count = IM->Count++; \
- IM->Flag[count] |= VERT_EVAL_P2; \
- ASSIGN_4V(IM->Obj[count], x, y, 0, 1); \
- if (count == VB_MAX-1) \
- _mesa_maybe_transform_vb( IM ); \
-}
-
-
-/* Lame internal function:
- */
-static void
-eval_coord1f( GLcontext *CC, GLfloat u )
-{
- struct immediate *i = CC->input;
- EVALCOORD1( i, u );
-}
-
-
-void
-_mesa_EvalCoord1d( GLdouble u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) u );
-}
-
-
-void
-_mesa_EvalCoord1f( GLfloat u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, u );
-}
-
-
-void
-_mesa_EvalCoord1dv( const GLdouble *u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) *u );
-}
-
-
-void
-_mesa_EvalCoord1fv( const GLfloat *u )
-{
- GET_IMMEDIATE;
- EVALCOORD1( IM, (GLfloat) *u );
-}
-
-
-void
-_mesa_EvalCoord2d( GLdouble u, GLdouble v )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, (GLfloat) u, (GLfloat) v );
-}
-
-
-void
-_mesa_EvalCoord2f( GLfloat u, GLfloat v )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, u, v );
-}
-
-
-/* Lame internal function:
- */
-static void
-eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v )
-{
- struct immediate *i = CC->input;
- EVALCOORD2( i, u, v );
-}
-
-
-void
-_mesa_EvalCoord2dv( const GLdouble *u )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, (GLfloat) u[0], (GLfloat) u[1] );
-}
-
-
-void
-_mesa_EvalCoord2fv( const GLfloat *u )
-{
- GET_IMMEDIATE;
- EVALCOORD2( IM, u[0], u[1] );
-}
-
-
-void
-_mesa_EvalPoint1( GLint i )
-{
- GET_IMMEDIATE;
- EVALPOINT1( IM, i );
-}
-
-
-void
-_mesa_EvalPoint2( GLint i, GLint j )
-{
- GET_IMMEDIATE;
- EVALPOINT2( IM, i, j );
-}
-
-
-
-
-void
-_mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i;
- GLfloat u, du;
- GLenum prim;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glEvalMesh1");
-
- switch (mode) {
- case GL_POINT:
- prim = GL_POINTS;
- break;
- case GL_LINE:
- prim = GL_LINE_STRIP;
- break;
- default:
- gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
- return;
- }
-
- /* No effect if vertex maps disabled.
- */
- if (!ctx->Eval.Map1Vertex4 && !ctx->Eval.Map1Vertex3)
- return;
-
- du = ctx->Eval.MapGrid1du;
- u = ctx->Eval.MapGrid1u1 + i1 * du;
-
- /* KW: Could short-circuit this to avoid the immediate mechanism.
- */
- RESET_IMMEDIATE(ctx);
-
- gl_Begin( ctx, prim );
- for (i=i1;i<=i2;i++,u+=du) {
- eval_coord1f( ctx, u );
- }
- gl_End(ctx);
-}
-
-
-
-void
-_mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
-{
- GET_CURRENT_CONTEXT(ctx);
- GLint i, j;
- GLfloat u, du, v, dv, v1, u1;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glEvalMesh2");
-
- /* No effect if vertex maps disabled.
- */
- if (!ctx->Eval.Map2Vertex4 && !ctx->Eval.Map2Vertex3)
- return;
-
- du = ctx->Eval.MapGrid2du;
- dv = ctx->Eval.MapGrid2dv;
- v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
- u1 = ctx->Eval.MapGrid2u1 + i1 * du;
-
- RESET_IMMEDIATE(ctx);
-
- switch (mode) {
- case GL_POINT:
- gl_Begin( ctx, GL_POINTS );
- for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- eval_coord2f( ctx, u, v );
- }
- }
- gl_End(ctx);
- break;
- case GL_LINE:
- for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- gl_Begin( ctx, GL_LINE_STRIP );
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- eval_coord2f( ctx, u, v );
- }
- gl_End(ctx);
- }
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- gl_Begin( ctx, GL_LINE_STRIP );
- for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- eval_coord2f( ctx, u, v );
- }
- gl_End(ctx);
- }
- break;
- case GL_FILL:
- for (v=v1,j=j1;j<j2;j++,v+=dv) {
- /* NOTE: a quad strip can't be used because the four */
- /* can't be guaranteed to be coplanar! */
- gl_Begin( ctx, GL_TRIANGLE_STRIP );
- for (u=u1,i=i1;i<=i2;i++,u+=du) {
- eval_coord2f( ctx, u, v );
- eval_coord2f( ctx, u, v+dv );
- }
- gl_End(ctx);
- }
- break;
- default:
- gl_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
- return;
- }
-}
-
-
diff --git a/src/mesa/main/eval.h b/src/mesa/main/eval.h
index 0b87be3d5fe..e2c61657af8 100644
--- a/src/mesa/main/eval.h
+++ b/src/mesa/main/eval.h
@@ -1,4 +1,4 @@
-/* $Id: eval.h,v 1.2 1999/11/11 01:22:26 brianp Exp $ */
+/* $Id: eval.h,v 1.3 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -61,8 +61,6 @@ extern GLfloat *gl_copy_map_points2d(GLenum target,
const GLdouble *points );
-extern void gl_eval_vb( struct vertex_buffer *VB );
-
extern void
_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
@@ -107,40 +105,5 @@ _mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v );
extern void
_mesa_GetMapiv( GLenum target, GLenum query, GLint *v );
-extern void
-_mesa_EvalMesh1( GLenum mode, GLint i1, GLint i2 );
-
-extern void
-_mesa_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
-
-extern void
-_mesa_EvalCoord1d( GLdouble u );
-
-extern void
-_mesa_EvalCoord1f( GLfloat u );
-
-extern void
-_mesa_EvalCoord1dv( const GLdouble *u );
-
-extern void
-_mesa_EvalCoord1fv( const GLfloat *u );
-
-extern void
-_mesa_EvalCoord2d( GLdouble u, GLdouble v );
-
-extern void
-_mesa_EvalCoord2f( GLfloat u, GLfloat v );
-
-extern void
-_mesa_EvalCoord2dv( const GLdouble *u );
-
-extern void
-_mesa_EvalCoord2fv( const GLfloat *u );
-
-extern void
-_mesa_EvalPoint1( GLint i );
-
-extern void
-_mesa_EvalPoint2( GLint i, GLint j );
#endif
diff --git a/src/mesa/main/fog.c b/src/mesa/main/fog.c
index 97bf52fc998..9593fa2a976 100644
--- a/src/mesa/main/fog.c
+++ b/src/mesa/main/fog.c
@@ -1,4 +1,4 @@
-/* $Id: fog.c,v 1.28 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: fog.c,v 1.29 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -32,10 +32,7 @@
#include "colormac.h"
#include "context.h"
#include "fog.h"
-#include "macros.h"
-#include "mmath.h"
#include "types.h"
-#include "xform.h"
#endif
@@ -146,102 +143,3 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params )
}
-
-
-
-static GLvector1f *get_fogcoord_ptr( GLcontext *ctx, GLvector1f *tmp )
-{
- struct vertex_buffer *VB = ctx->VB;
-
- if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
- if (!ctx->_NeedEyeCoords) {
- GLfloat *m = ctx->ModelView.m;
- GLfloat plane[4];
-
- plane[0] = m[2];
- plane[1] = m[6];
- plane[2] = m[10];
- plane[3] = m[14];
-
- /* Full eye coords weren't required, just calculate the
- * eye Z values.
- */
- gl_dotprod_tab[0][VB->ObjPtr->size](&VB->Eye, 2,
- VB->ObjPtr, plane, 0 );
-
- tmp->data = &(VB->Eye.data[0][2]);
- tmp->start = VB->Eye.start+2;
- tmp->stride = VB->Eye.stride;
- return tmp;
- }
- else
- {
- if (VB->EyePtr->size < 2)
- gl_vector4f_clean_elem( &VB->Eye, VB->Count, 2 );
-
- tmp->data = &(VB->EyePtr->data[0][2]);
- tmp->start = VB->EyePtr->start+2;
- tmp->stride = VB->EyePtr->stride;
- return tmp;
- }
- } else
- return VB->FogCoordPtr;
-}
-
-
-/* Use lookup table & interpolation?
- */
-static void
-make_win_fog_coords( struct vertex_buffer *VB,
- GLvector1f *fogcoord)
-{
- const GLcontext *ctx = VB->ctx;
- GLfloat end = ctx->Fog.End;
- GLfloat *v = fogcoord->start;
- GLuint stride = fogcoord->stride;
- GLuint n = VB->Count - VB->Start;
- GLfloat *out;
- GLfloat d;
- GLuint i;
-
- VB->FogCoordPtr = VB->store.FogCoord;
- out = VB->FogCoordPtr->data + VB->Start;
-
- switch (ctx->Fog.Mode) {
- case GL_LINEAR:
- d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
- for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- out[i] = (end - ABSF(*v)) * d;
- if (0) fprintf(stderr, "z %f out %f\n", *v, out[i]);
- }
- break;
- case GL_EXP:
- d = -ctx->Fog.Density;
- for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
- out[i] = exp( d*ABSF(*v) );
- if (0) fprintf(stderr, "z %f out %f\n", *v, out[i]);
- }
- break;
- case GL_EXP2:
- d = -(ctx->Fog.Density*ctx->Fog.Density);
- for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
- GLfloat z = *v;
- out[i] = exp( d*z*z );
- if (0) fprintf(stderr, "z %f out %f\n", *v, out[i]);
- }
- break;
- default:
- gl_problem(ctx, "Bad fog mode in make_fog_coord");
- return;
- }
-}
-
-
-void
-_mesa_make_win_fog_coords( struct vertex_buffer *VB )
-{
- GLvector1f tmp;
-
- make_win_fog_coords( VB, get_fogcoord_ptr( VB->ctx, &tmp ) );
-}
-
diff --git a/src/mesa/main/fog.h b/src/mesa/main/fog.h
index 15ccbc9966c..371fb80d8bf 100644
--- a/src/mesa/main/fog.h
+++ b/src/mesa/main/fog.h
@@ -1,4 +1,4 @@
-/* $Id: fog.h,v 1.9 2000/10/31 18:09:44 keithw Exp $ */
+/* $Id: fog.h,v 1.10 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -49,8 +49,4 @@ extern void
_mesa_Fogiv(GLenum pname, const GLint *params );
-extern void
-_mesa_make_win_fog_coords( struct vertex_buffer *VB );
-
-
#endif
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 434e2e54005..980269d8544 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1,4 +1,4 @@
-/* $Id: get.c,v 1.40 2000/11/15 16:38:40 brianp Exp $ */
+/* $Id: get.c,v 1.41 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,10 +36,10 @@
#include "extensions.h"
#include "get.h"
#include "macros.h"
-#include "matrix.h"
#include "mmath.h"
#include "types.h"
-#include "vb.h"
+
+#include "math/m_matrix.h"
#endif
@@ -228,15 +228,18 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
*params = ENUM_TO_BOOL(ctx->Polygon.CullFaceMode);
break;
case GL_CURRENT_COLOR:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = INT_TO_BOOL(ctx->Current.Color[0]);
params[1] = INT_TO_BOOL(ctx->Current.Color[1]);
params[2] = INT_TO_BOOL(ctx->Current.Color[2]);
params[3] = INT_TO_BOOL(ctx->Current.Color[3]);
break;
case GL_CURRENT_INDEX:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = INT_TO_BOOL(ctx->Current.Index);
break;
case GL_CURRENT_NORMAL:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = FLOAT_TO_BOOL(ctx->Current.Normal[0]);
params[1] = FLOAT_TO_BOOL(ctx->Current.Normal[1]);
params[2] = FLOAT_TO_BOOL(ctx->Current.Normal[2]);
@@ -269,6 +272,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
*params = ctx->Current.RasterPosValid;
break;
case GL_CURRENT_TEXTURE_COORDS:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = FLOAT_TO_BOOL(ctx->Current.Texcoord[texTransformUnit][0]);
params[1] = FLOAT_TO_BOOL(ctx->Current.Texcoord[texTransformUnit][1]);
params[2] = FLOAT_TO_BOOL(ctx->Current.Texcoord[texTransformUnit][2]);
@@ -309,6 +313,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
*params = ENUM_TO_BOOL(ctx->Color.DrawBuffer);
break;
case GL_EDGE_FLAG:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = ctx->Current.EdgeFlag;
break;
case GL_FEEDBACK_BUFFER_SIZE:
@@ -1077,7 +1082,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ColorMatrix.m);
+ _math_transposef(tm, ctx->ColorMatrix.m);
for (i=0;i<16;i++) {
params[i] = FLOAT_TO_BOOL(tm[i]);
}
@@ -1087,7 +1092,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ModelView.m);
+ _math_transposef(tm, ctx->ModelView.m);
for (i=0;i<16;i++) {
params[i] = FLOAT_TO_BOOL(tm[i]);
}
@@ -1097,7 +1102,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ProjectionMatrix.m);
+ _math_transposef(tm, ctx->ProjectionMatrix.m);
for (i=0;i<16;i++) {
params[i] = FLOAT_TO_BOOL(tm[i]);
}
@@ -1107,7 +1112,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->TextureMatrix[texTransformUnit].m);
+ _math_transposef(tm, ctx->TextureMatrix[texTransformUnit].m);
for (i=0;i<16;i++) {
params[i] = FLOAT_TO_BOOL(tm[i]);
}
@@ -1236,6 +1241,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
*params = ctx->Fog.ColorSumEnabled;
break;
case GL_CURRENT_SECONDARY_COLOR_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = INT_TO_BOOL(ctx->Current.SecondaryColor[0]);
params[1] = INT_TO_BOOL(ctx->Current.SecondaryColor[1]);
params[2] = INT_TO_BOOL(ctx->Current.SecondaryColor[2]);
@@ -1255,6 +1261,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
/* GL_EXT_fog_coord */
case GL_CURRENT_FOG_COORDINATE_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = FLOAT_TO_BOOL(ctx->Current.FogCoord);
break;
case GL_FOG_COORDINATE_ARRAY_EXT:
@@ -1419,15 +1426,18 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
*params = ENUM_TO_DOUBLE(ctx->Polygon.CullFaceMode);
break;
case GL_CURRENT_COLOR:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = CHAN_TO_FLOAT(ctx->Current.Color[0]);
params[1] = CHAN_TO_FLOAT(ctx->Current.Color[1]);
params[2] = CHAN_TO_FLOAT(ctx->Current.Color[2]);
params[3] = CHAN_TO_FLOAT(ctx->Current.Color[3]);
break;
case GL_CURRENT_INDEX:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLdouble) ctx->Current.Index;
break;
case GL_CURRENT_NORMAL:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = (GLdouble) ctx->Current.Normal[0];
params[1] = (GLdouble) ctx->Current.Normal[1];
params[2] = (GLdouble) ctx->Current.Normal[2];
@@ -1460,6 +1470,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
*params = (GLdouble) ctx->Current.RasterPosValid;
break;
case GL_CURRENT_TEXTURE_COORDS:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = (GLdouble) ctx->Current.Texcoord[texTransformUnit][0];
params[1] = (GLdouble) ctx->Current.Texcoord[texTransformUnit][1];
params[2] = (GLdouble) ctx->Current.Texcoord[texTransformUnit][2];
@@ -1500,6 +1511,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
*params = ENUM_TO_DOUBLE(ctx->Color.DrawBuffer);
break;
case GL_EDGE_FLAG:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLdouble) ctx->Current.EdgeFlag;
break;
case GL_FEEDBACK_BUFFER_SIZE:
@@ -2268,7 +2280,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ColorMatrix.m);
+ _math_transposef(tm, ctx->ColorMatrix.m);
for (i=0;i<16;i++) {
params[i] = (GLdouble) tm[i];
}
@@ -2278,7 +2290,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ModelView.m);
+ _math_transposef(tm, ctx->ModelView.m);
for (i=0;i<16;i++) {
params[i] = (GLdouble) tm[i];
}
@@ -2288,7 +2300,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ProjectionMatrix.m);
+ _math_transposef(tm, ctx->ProjectionMatrix.m);
for (i=0;i<16;i++) {
params[i] = (GLdouble) tm[i];
}
@@ -2298,7 +2310,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->TextureMatrix[texTransformUnit].m);
+ _math_transposef(tm, ctx->TextureMatrix[texTransformUnit].m);
for (i=0;i<16;i++) {
params[i] = (GLdouble) tm[i];
}
@@ -2427,6 +2439,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
*params = (GLdouble) ctx->Fog.ColorSumEnabled;
break;
case GL_CURRENT_SECONDARY_COLOR_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[0]);
params[1] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[1]);
params[2] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[2]);
@@ -2446,6 +2459,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params )
/* GL_EXT_fog_coord */
case GL_CURRENT_FOG_COORDINATE_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLdouble) ctx->Current.FogCoord;
break;
case GL_FOG_COORDINATE_ARRAY_EXT:
@@ -2611,15 +2625,18 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
*params = ENUM_TO_FLOAT(ctx->Polygon.CullFaceMode);
break;
case GL_CURRENT_COLOR:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = CHAN_TO_FLOAT(ctx->Current.Color[0]);
params[1] = CHAN_TO_FLOAT(ctx->Current.Color[1]);
params[2] = CHAN_TO_FLOAT(ctx->Current.Color[2]);
params[3] = CHAN_TO_FLOAT(ctx->Current.Color[3]);
break;
case GL_CURRENT_INDEX:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLfloat) ctx->Current.Index;
break;
case GL_CURRENT_NORMAL:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = ctx->Current.Normal[0];
params[1] = ctx->Current.Normal[1];
params[2] = ctx->Current.Normal[2];
@@ -2652,6 +2669,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
*params = (GLfloat) ctx->Current.RasterPosValid;
break;
case GL_CURRENT_TEXTURE_COORDS:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = (GLfloat) ctx->Current.Texcoord[texTransformUnit][0];
params[1] = (GLfloat) ctx->Current.Texcoord[texTransformUnit][1];
params[2] = (GLfloat) ctx->Current.Texcoord[texTransformUnit][2];
@@ -2692,6 +2710,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
*params = ENUM_TO_FLOAT(ctx->Color.DrawBuffer);
break;
case GL_EDGE_FLAG:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLfloat) ctx->Current.EdgeFlag;
break;
case GL_FEEDBACK_BUFFER_SIZE:
@@ -3459,16 +3478,16 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
/* GL_ARB_transpose_matrix */
case GL_TRANSPOSE_COLOR_MATRIX_ARB:
- gl_matrix_transposef(params, ctx->ColorMatrix.m);
+ _math_transposef(params, ctx->ColorMatrix.m);
break;
case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
- gl_matrix_transposef(params, ctx->ModelView.m);
+ _math_transposef(params, ctx->ModelView.m);
break;
case GL_TRANSPOSE_PROJECTION_MATRIX_ARB:
- gl_matrix_transposef(params, ctx->ProjectionMatrix.m);
+ _math_transposef(params, ctx->ProjectionMatrix.m);
break;
case GL_TRANSPOSE_TEXTURE_MATRIX_ARB:
- gl_matrix_transposef(params, ctx->TextureMatrix[texTransformUnit].m);
+ _math_transposef(params, ctx->TextureMatrix[texTransformUnit].m);
break;
/* GL_HP_occlusion_test */
@@ -3593,6 +3612,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
*params = (GLfloat) ctx->Fog.ColorSumEnabled;
break;
case GL_CURRENT_SECONDARY_COLOR_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[0]);
params[1] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[1]);
params[2] = UBYTE_COLOR_TO_FLOAT_COLOR(ctx->Current.SecondaryColor[2]);
@@ -3612,6 +3632,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
/* GL_EXT_fog_coord */
case GL_CURRENT_FOG_COORDINATE_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLfloat) ctx->Current.FogCoord;
break;
case GL_FOG_COORDINATE_ARRAY_EXT:
@@ -3779,15 +3800,18 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
*params = (GLint) ctx->Polygon.CullFaceMode;
break;
case GL_CURRENT_COLOR:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = FLOAT_TO_INT( CHAN_TO_FLOAT( ctx->Current.Color[0] ) );
params[1] = FLOAT_TO_INT( CHAN_TO_FLOAT( ctx->Current.Color[1] ) );
params[2] = FLOAT_TO_INT( CHAN_TO_FLOAT( ctx->Current.Color[2] ) );
params[3] = FLOAT_TO_INT( CHAN_TO_FLOAT( ctx->Current.Color[3] ) );
break;
case GL_CURRENT_INDEX:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLint) ctx->Current.Index;
break;
case GL_CURRENT_NORMAL:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = FLOAT_TO_INT( ctx->Current.Normal[0] );
params[1] = FLOAT_TO_INT( ctx->Current.Normal[1] );
params[2] = FLOAT_TO_INT( ctx->Current.Normal[2] );
@@ -3820,6 +3844,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
*params = (GLint) ctx->Current.RasterPosValid;
break;
case GL_CURRENT_TEXTURE_COORDS:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = (GLint) ctx->Current.Texcoord[texTransformUnit][0];
params[1] = (GLint) ctx->Current.Texcoord[texTransformUnit][1];
params[2] = (GLint) ctx->Current.Texcoord[texTransformUnit][2];
@@ -3860,6 +3885,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
*params = (GLint) ctx->Color.DrawBuffer;
break;
case GL_EDGE_FLAG:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLint) ctx->Current.EdgeFlag;
break;
case GL_FEEDBACK_BUFFER_SIZE:
@@ -4628,7 +4654,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ColorMatrix.m);
+ _math_transposef(tm, ctx->ColorMatrix.m);
for (i=0;i<16;i++) {
params[i] = (GLint) tm[i];
}
@@ -4638,7 +4664,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ModelView.m);
+ _math_transposef(tm, ctx->ModelView.m);
for (i=0;i<16;i++) {
params[i] = (GLint) tm[i];
}
@@ -4648,7 +4674,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->ProjectionMatrix.m);
+ _math_transposef(tm, ctx->ProjectionMatrix.m);
for (i=0;i<16;i++) {
params[i] = (GLint) tm[i];
}
@@ -4658,7 +4684,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
{
GLfloat tm[16];
GLuint i;
- gl_matrix_transposef(tm, ctx->TextureMatrix[texTransformUnit].m);
+ _math_transposef(tm, ctx->TextureMatrix[texTransformUnit].m);
for (i=0;i<16;i++) {
params[i] = (GLint) tm[i];
}
@@ -4788,6 +4814,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
*params = (GLint) ctx->Fog.ColorSumEnabled;
break;
case GL_CURRENT_SECONDARY_COLOR_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
params[0] = FLOAT_TO_INT( UBYTE_COLOR_TO_FLOAT_COLOR( ctx->Current.SecondaryColor[0] ) );
params[1] = FLOAT_TO_INT( UBYTE_COLOR_TO_FLOAT_COLOR( ctx->Current.SecondaryColor[1] ) );
params[2] = FLOAT_TO_INT( UBYTE_COLOR_TO_FLOAT_COLOR( ctx->Current.SecondaryColor[2] ) );
@@ -4807,6 +4834,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
/* GL_EXT_fog_coord */
case GL_CURRENT_FOG_COORDINATE_EXT:
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
*params = (GLint) ctx->Current.FogCoord;
break;
case GL_FOG_COORDINATE_ARRAY_EXT:
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index 1c4f6982d93..ef31c561ba6 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -1,4 +1,4 @@
-/* $Id: light.c,v 1.25 2000/11/15 16:38:59 brianp Exp $ */
+/* $Id: light.c,v 1.26 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,14 +34,13 @@
#include "enums.h"
#include "light.h"
#include "macros.h"
-#include "matrix.h"
#include "mem.h"
#include "mmath.h"
-#include "shade.h"
#include "simple_list.h"
#include "types.h"
-#include "vb.h"
-#include "xform.h"
+
+#include "math/m_xform.h"
+#include "math/m_matrix.h"
#endif
@@ -123,7 +122,7 @@ _mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
case GL_SPOT_DIRECTION:
/* transform direction by inverse modelview */
if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
- gl_matrix_analyze( &ctx->ModelView );
+ _math_matrix_analyze( &ctx->ModelView );
}
TRANSFORM_NORMAL( l->EyeDirection, params, ctx->ModelView.inv );
break;
@@ -533,7 +532,7 @@ void gl_update_material( GLcontext *ctx,
if (ctx->Light.ColorMaterialEnabled)
bitmask &= ~ctx->Light.ColorMaterialBitmask;
- if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
+ if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
fprintf(stderr, "gl_update_material, mask 0x%x\n", bitmask);
if (!bitmask)
@@ -829,8 +828,10 @@ _mesa_ColorMaterial( GLenum face, GLenum mode )
ctx->Light.ColorMaterialMode = mode;
}
- if (ctx->Light.ColorMaterialEnabled)
+ if (ctx->Light.ColorMaterialEnabled) {
+ FLUSH_TNL( ctx, FLUSH_UPDATE_CURRENT );
gl_update_color_material( ctx, ctx->Current.Color );
+ }
ctx->NewState |= _NEW_LIGHT;
}
@@ -845,86 +846,6 @@ _mesa_Materialf( GLenum face, GLenum pname, GLfloat param )
}
-/* KW: This is now called directly (ie by name) from the glMaterial*
- * API functions.
- */
-void
-_mesa_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
-{
- GET_CURRENT_CONTEXT(ctx);
- struct immediate *IM;
- struct gl_material *mat;
- GLuint bitmask;
- GLuint count;
-
- bitmask = gl_material_bitmask( ctx, face, pname, ~0, "gl_Materialfv" );
- if (bitmask == 0)
- return;
-
- IM = ctx->input;
- count = IM->Count;
-
- if (!IM->Material) {
- IM->Material =
- (struct gl_material (*)[2]) MALLOC( sizeof(struct gl_material) *
- VB_SIZE * 2 );
- IM->MaterialMask = (GLuint *) MALLOC( sizeof(GLuint) * VB_SIZE );
- }
-
-
- if (!(IM->Flag[count] & VERT_MATERIAL)) {
- IM->Flag[count] |= VERT_MATERIAL;
- IM->MaterialMask[count] = 0;
- }
-
-
- IM->MaterialMask[count] |= bitmask;
- mat = IM->Material[count];
-
- if (bitmask & FRONT_AMBIENT_BIT) {
- COPY_4FV( mat[0].Ambient, params );
- }
- if (bitmask & BACK_AMBIENT_BIT) {
- COPY_4FV( mat[1].Ambient, params );
- }
- if (bitmask & FRONT_DIFFUSE_BIT) {
- COPY_4FV( mat[0].Diffuse, params );
- }
- if (bitmask & BACK_DIFFUSE_BIT) {
- COPY_4FV( mat[1].Diffuse, params );
- }
- if (bitmask & FRONT_SPECULAR_BIT) {
- COPY_4FV( mat[0].Specular, params );
- }
- if (bitmask & BACK_SPECULAR_BIT) {
- COPY_4FV( mat[1].Specular, params );
- }
- if (bitmask & FRONT_EMISSION_BIT) {
- COPY_4FV( mat[0].Emission, params );
- }
- if (bitmask & BACK_EMISSION_BIT) {
- COPY_4FV( mat[1].Emission, params );
- }
- if (bitmask & FRONT_SHININESS_BIT) {
- GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F );
- mat[0].Shininess = shininess;
- }
- if (bitmask & BACK_SHININESS_BIT) {
- GLfloat shininess = CLAMP( params[0], 0.0F, 128.0F );
- mat[1].Shininess = shininess;
- }
- if (bitmask & FRONT_INDEXES_BIT) {
- mat[0].AmbientIndex = params[0];
- mat[0].DiffuseIndex = params[1];
- mat[0].SpecularIndex = params[2];
- }
- if (bitmask & BACK_INDEXES_BIT) {
- mat[1].AmbientIndex = params[0];
- mat[1].DiffuseIndex = params[1];
- mat[1].SpecularIndex = params[2];
- }
-}
-
void
_mesa_Materiali(GLenum face, GLenum pname, GLint param )
@@ -1281,8 +1202,6 @@ gl_update_lighting( GLcontext *ctx )
light->_sli = DOT3(ci, light->Specular);
}
}
-
- gl_update_lighting_function(ctx);
}
@@ -1364,54 +1283,3 @@ gl_compute_light_positions( GLcontext *ctx )
}
-/* _NEW_TRANSFORM
- * _NEW_MODELVIEW
- * _TNL_NEW_NEED_NORMALS
- * _TNL_NEW_NEED_EYE_COORDS
- *
- * Update on (_NEW_TRANSFORM|_NEW_MODELVIEW)
- * And also on NewLightingSpaces() callback.
- */
-void
-gl_update_normal_transform( GLcontext *ctx )
-{
-
- if (!ctx->_NeedNormals) {
- ctx->_NormalTransform = 0;
- return;
- }
-
- if (ctx->_NeedEyeCoords) {
- GLuint transform = NORM_TRANSFORM_NO_ROT;
-
- if (ctx->ModelView.flags & (MAT_FLAG_GENERAL |
- MAT_FLAG_ROTATION |
- MAT_FLAG_GENERAL_3D |
- MAT_FLAG_PERSPECTIVE))
- transform = NORM_TRANSFORM;
-
-
- if (ctx->Transform.Normalize) {
- ctx->_NormalTransform = gl_normal_tab[transform | NORM_NORMALIZE];
- }
- else if (ctx->Transform.RescaleNormals &&
- ctx->_ModelViewInvScale != 1.0) {
- ctx->_NormalTransform = gl_normal_tab[transform | NORM_RESCALE];
- }
- else {
- ctx->_NormalTransform = gl_normal_tab[transform];
- }
- }
- else {
- if (ctx->Transform.Normalize) {
- ctx->_NormalTransform = gl_normal_tab[NORM_NORMALIZE];
- }
- else if (!ctx->Transform.RescaleNormals &&
- ctx->_ModelViewInvScale != 1.0) {
- ctx->_NormalTransform = gl_normal_tab[NORM_RESCALE];
- }
- else {
- ctx->_NormalTransform = 0;
- }
- }
-}
diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h
index 78178f982b8..4c2589fbf47 100644
--- a/src/mesa/main/light.h
+++ b/src/mesa/main/light.h
@@ -1,4 +1,4 @@
-/* $Id: light.h,v 1.4 2000/10/28 18:34:48 brianp Exp $ */
+/* $Id: light.h,v 1.5 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -31,13 +31,6 @@
#include "types.h"
-struct gl_shine_tab {
- struct gl_shine_tab *next, *prev;
- GLfloat tab[SHINE_TABLE_SIZE+1];
- GLfloat shininess;
- GLuint refcount;
-};
-
extern void
_mesa_ShadeModel( GLenum mode );
@@ -94,6 +87,23 @@ extern void
_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params );
+/* Lerp between adjacent values in the f(x) lookup table, giving a
+ * continuous function, with adequeate overall accuracy. (Though
+ * still pretty good compared to a straight lookup).
+ */
+#define GET_SHINE_TAB_ENTRY( table, dp, result ) \
+do { \
+ struct gl_shine_tab *_tab = table; \
+ if (dp>1.0) \
+ result = pow( dp, _tab->shininess ); \
+ else { \
+ float f = (dp * (SHINE_TABLE_SIZE-1)); \
+ int k = (int) f; \
+ result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
+ } \
+} while (0)
+
+
extern GLuint gl_material_bitmask( GLcontext *ctx,
GLenum face, GLenum pname,
@@ -112,8 +122,6 @@ extern void gl_update_lighting( GLcontext *ctx );
extern void gl_compute_light_positions( GLcontext *ctx );
-extern void gl_update_normal_transform( GLcontext *ctx );
-
extern void gl_update_material( GLcontext *ctx,
const struct gl_material src[2],
GLuint bitmask );
diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
index 2a86e09a54f..3d9aad52b71 100644
--- a/src/mesa/main/lines.c
+++ b/src/mesa/main/lines.c
@@ -1,4 +1,4 @@
-/* $Id: lines.c,v 1.21 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: lines.c,v 1.22 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -37,7 +37,6 @@
#include "mmath.h"
#include "texstate.h"
#include "types.h"
-#include "vb.h"
#endif
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index d84d2edd7c8..d5d9e42e7f7 100644
--- a/src/mesa/main/macros.h
+++ b/src/mesa/main/macros.h
@@ -1,4 +1,4 @@
-/* $Id: macros.h,v 1.13 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: macros.h,v 1.14 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,6 +35,8 @@
#include "glheader.h"
+/* Do not reference types.h from this file.
+ */
/* Limits: */
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 7cf464e07bf..227f54b73d5 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -1,4 +1,4 @@
-/* $Id: matrix.c,v 1.25 2000/11/13 20:02:56 keithw Exp $ */
+/* $Id: matrix.c,v 1.26 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -47,936 +47,9 @@
#include "mem.h"
#include "mmath.h"
#include "types.h"
-#endif
-
-
-static const char *types[] = {
- "MATRIX_GENERAL",
- "MATRIX_IDENTITY",
- "MATRIX_3D_NO_ROT",
- "MATRIX_PERSPECTIVE",
- "MATRIX_2D",
- "MATRIX_2D_NO_ROT",
- "MATRIX_3D"
-};
-
-
-static GLfloat Identity[16] = {
- 1.0, 0.0, 0.0, 0.0,
- 0.0, 1.0, 0.0, 0.0,
- 0.0, 0.0, 1.0, 0.0,
- 0.0, 0.0, 0.0, 1.0
-};
-
-
-
-static void matmul4( GLfloat *product, const GLfloat *a, const GLfloat *b );
-
-
-static void print_matrix_floats( const GLfloat m[16] )
-{
- int i;
- for (i=0;i<4;i++) {
- fprintf(stderr,"\t%f %f %f %f\n", m[i], m[4+i], m[8+i], m[12+i] );
- }
-}
-
-void gl_print_matrix( const GLmatrix *m )
-{
- fprintf(stderr, "Matrix type: %s, flags: %x\n", types[m->type], m->flags);
- print_matrix_floats(m->m);
- fprintf(stderr, "Inverse: \n");
- if (m->inv) {
- GLfloat prod[16];
- print_matrix_floats(m->inv);
- matmul4(prod, m->m, m->inv);
- fprintf(stderr, "Mat * Inverse:\n");
- print_matrix_floats(prod);
- }
- else {
- fprintf(stderr, " - not available\n");
- }
-}
-
-
-
-/*
- * This matmul was contributed by Thomas Malik
- *
- * Perform a 4x4 matrix multiplication (product = a x b).
- * Input: a, b - matrices to multiply
- * Output: product - product of a and b
- * WARNING: (product != b) assumed
- * NOTE: (product == a) allowed
- *
- * KW: 4*16 = 64 muls
- */
-#define A(row,col) a[(col<<2)+row]
-#define B(row,col) b[(col<<2)+row]
-#define P(row,col) product[(col<<2)+row]
-
-static void matmul4( GLfloat *product, const GLfloat *a, const GLfloat *b )
-{
- GLint i;
- for (i = 0; i < 4; i++) {
- const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
- P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
- P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
- P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
- P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
- }
-}
-
-
-/* Multiply two matrices known to occupy only the top three rows,
- * such as typical modelling matrices, and ortho matrices.
- */
-static void matmul34( GLfloat *product, const GLfloat *a, const GLfloat *b )
-{
- GLint i;
- for (i = 0; i < 3; i++) {
- const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
- P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0);
- P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1);
- P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2);
- P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3;
- }
- P(3,0) = 0;
- P(3,1) = 0;
- P(3,2) = 0;
- P(3,3) = 1;
-}
-
-static void matmul4fd( GLfloat *product, const GLfloat *a, const GLdouble *b )
-{
- GLint i;
- for (i = 0; i < 4; i++) {
- const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
- P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
- P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
- P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
- P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
- }
-}
-
-#undef A
-#undef B
-#undef P
-
-
-#define SWAP_ROWS(a, b) { GLfloat *_tmp = a; (a)=(b); (b)=_tmp; }
-#define MAT(m,r,c) (m)[(c)*4+(r)]
-
-/*
- * Compute inverse of 4x4 transformation matrix.
- * Code contributed by Jacques Leroy [email protected]
- * Return GL_TRUE for success, GL_FALSE for failure (singular matrix)
- */
-static GLboolean invert_matrix_general( GLmatrix *mat )
-{
- const GLfloat *m = mat->m;
- GLfloat *out = mat->inv;
- GLfloat wtmp[4][8];
- GLfloat m0, m1, m2, m3, s;
- GLfloat *r0, *r1, *r2, *r3;
-
- r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
-
- r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
- r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
- r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
-
- r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
- r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
- r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
-
- r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
- r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
- r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
-
- r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
- r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
- r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
-
- /* choose pivot - or die */
- if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
- if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
- if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
- if (0.0 == r0[0]) return GL_FALSE;
-
- /* eliminate first variable */
- m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
- s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
- s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
- s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
- s = r0[4];
- if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
- s = r0[5];
- if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
- s = r0[6];
- if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
- s = r0[7];
- if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
-
- /* choose pivot - or die */
- if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
- if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
- if (0.0 == r1[1]) return GL_FALSE;
-
- /* eliminate second variable */
- m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
- r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
- r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
- s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
- s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
- s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
- s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
-
- /* choose pivot - or die */
- if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
- if (0.0 == r2[2]) return GL_FALSE;
-
- /* eliminate third variable */
- m3 = r3[2]/r2[2];
- r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
- r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
- r3[7] -= m3 * r2[7];
-
- /* last check */
- if (0.0 == r3[3]) return GL_FALSE;
-
- s = 1.0/r3[3]; /* now back substitute row 3 */
- r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
-
- m2 = r2[3]; /* now back substitute row 2 */
- s = 1.0/r2[2];
- r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
- r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
- m1 = r1[3];
- r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
- r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
- m0 = r0[3];
- r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
- r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
-
- m1 = r1[2]; /* now back substitute row 1 */
- s = 1.0/r1[1];
- r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
- r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
- m0 = r0[2];
- r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
- r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
-
- m0 = r0[1]; /* now back substitute row 0 */
- s = 1.0/r0[0];
- r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
- r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
-
- MAT(out,0,0) = r0[4]; MAT(out,0,1) = r0[5],
- MAT(out,0,2) = r0[6]; MAT(out,0,3) = r0[7],
- MAT(out,1,0) = r1[4]; MAT(out,1,1) = r1[5],
- MAT(out,1,2) = r1[6]; MAT(out,1,3) = r1[7],
- MAT(out,2,0) = r2[4]; MAT(out,2,1) = r2[5],
- MAT(out,2,2) = r2[6]; MAT(out,2,3) = r2[7],
- MAT(out,3,0) = r3[4]; MAT(out,3,1) = r3[5],
- MAT(out,3,2) = r3[6]; MAT(out,3,3) = r3[7];
-
- return GL_TRUE;
-}
-#undef SWAP_ROWS
-
-
-/* Adapted from graphics gems II.
- */
-static GLboolean invert_matrix_3d_general( GLmatrix *mat )
-{
- const GLfloat *in = mat->m;
- GLfloat *out = mat->inv;
- GLfloat pos, neg, t;
- GLfloat det;
-
- /* Calculate the determinant of upper left 3x3 submatrix and
- * determine if the matrix is singular.
- */
- pos = neg = 0.0;
- t = MAT(in,0,0) * MAT(in,1,1) * MAT(in,2,2);
- if (t >= 0.0) pos += t; else neg += t;
-
- t = MAT(in,1,0) * MAT(in,2,1) * MAT(in,0,2);
- if (t >= 0.0) pos += t; else neg += t;
-
- t = MAT(in,2,0) * MAT(in,0,1) * MAT(in,1,2);
- if (t >= 0.0) pos += t; else neg += t;
-
- t = -MAT(in,2,0) * MAT(in,1,1) * MAT(in,0,2);
- if (t >= 0.0) pos += t; else neg += t;
-
- t = -MAT(in,1,0) * MAT(in,0,1) * MAT(in,2,2);
- if (t >= 0.0) pos += t; else neg += t;
-
- t = -MAT(in,0,0) * MAT(in,2,1) * MAT(in,1,2);
- if (t >= 0.0) pos += t; else neg += t;
-
- det = pos + neg;
-
- if (det*det < 1e-25)
- return GL_FALSE;
-
- det = 1.0 / det;
- MAT(out,0,0) = ( (MAT(in,1,1)*MAT(in,2,2) - MAT(in,2,1)*MAT(in,1,2) )*det);
- MAT(out,0,1) = (- (MAT(in,0,1)*MAT(in,2,2) - MAT(in,2,1)*MAT(in,0,2) )*det);
- MAT(out,0,2) = ( (MAT(in,0,1)*MAT(in,1,2) - MAT(in,1,1)*MAT(in,0,2) )*det);
- MAT(out,1,0) = (- (MAT(in,1,0)*MAT(in,2,2) - MAT(in,2,0)*MAT(in,1,2) )*det);
- MAT(out,1,1) = ( (MAT(in,0,0)*MAT(in,2,2) - MAT(in,2,0)*MAT(in,0,2) )*det);
- MAT(out,1,2) = (- (MAT(in,0,0)*MAT(in,1,2) - MAT(in,1,0)*MAT(in,0,2) )*det);
- MAT(out,2,0) = ( (MAT(in,1,0)*MAT(in,2,1) - MAT(in,2,0)*MAT(in,1,1) )*det);
- MAT(out,2,1) = (- (MAT(in,0,0)*MAT(in,2,1) - MAT(in,2,0)*MAT(in,0,1) )*det);
- MAT(out,2,2) = ( (MAT(in,0,0)*MAT(in,1,1) - MAT(in,1,0)*MAT(in,0,1) )*det);
-
- /* Do the translation part */
- MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) +
- MAT(in,1,3) * MAT(out,0,1) +
- MAT(in,2,3) * MAT(out,0,2) );
- MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) +
- MAT(in,1,3) * MAT(out,1,1) +
- MAT(in,2,3) * MAT(out,1,2) );
- MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) +
- MAT(in,1,3) * MAT(out,2,1) +
- MAT(in,2,3) * MAT(out,2,2) );
-
- return GL_TRUE;
-}
-
-
-static GLboolean invert_matrix_3d( GLmatrix *mat )
-{
- const GLfloat *in = mat->m;
- GLfloat *out = mat->inv;
-
- if (!TEST_MAT_FLAGS(mat, MAT_FLAGS_ANGLE_PRESERVING)) {
- return invert_matrix_3d_general( mat );
- }
-
- if (mat->flags & MAT_FLAG_UNIFORM_SCALE) {
- GLfloat scale = (MAT(in,0,0) * MAT(in,0,0) +
- MAT(in,0,1) * MAT(in,0,1) +
- MAT(in,0,2) * MAT(in,0,2));
-
- if (scale == 0.0)
- return GL_FALSE;
-
- scale = 1.0 / scale;
-
- /* Transpose and scale the 3 by 3 upper-left submatrix. */
- MAT(out,0,0) = scale * MAT(in,0,0);
- MAT(out,1,0) = scale * MAT(in,0,1);
- MAT(out,2,0) = scale * MAT(in,0,2);
- MAT(out,0,1) = scale * MAT(in,1,0);
- MAT(out,1,1) = scale * MAT(in,1,1);
- MAT(out,2,1) = scale * MAT(in,1,2);
- MAT(out,0,2) = scale * MAT(in,2,0);
- MAT(out,1,2) = scale * MAT(in,2,1);
- MAT(out,2,2) = scale * MAT(in,2,2);
- }
- else if (mat->flags & MAT_FLAG_ROTATION) {
- /* Transpose the 3 by 3 upper-left submatrix. */
- MAT(out,0,0) = MAT(in,0,0);
- MAT(out,1,0) = MAT(in,0,1);
- MAT(out,2,0) = MAT(in,0,2);
- MAT(out,0,1) = MAT(in,1,0);
- MAT(out,1,1) = MAT(in,1,1);
- MAT(out,2,1) = MAT(in,1,2);
- MAT(out,0,2) = MAT(in,2,0);
- MAT(out,1,2) = MAT(in,2,1);
- MAT(out,2,2) = MAT(in,2,2);
- }
- else {
- /* pure translation */
- MEMCPY( out, Identity, sizeof(Identity) );
- MAT(out,0,3) = - MAT(in,0,3);
- MAT(out,1,3) = - MAT(in,1,3);
- MAT(out,2,3) = - MAT(in,2,3);
- return GL_TRUE;
- }
-
- if (mat->flags & MAT_FLAG_TRANSLATION) {
- /* Do the translation part */
- MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) +
- MAT(in,1,3) * MAT(out,0,1) +
- MAT(in,2,3) * MAT(out,0,2) );
- MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) +
- MAT(in,1,3) * MAT(out,1,1) +
- MAT(in,2,3) * MAT(out,1,2) );
- MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) +
- MAT(in,1,3) * MAT(out,2,1) +
- MAT(in,2,3) * MAT(out,2,2) );
- }
- else {
- MAT(out,0,3) = MAT(out,1,3) = MAT(out,2,3) = 0.0;
- }
-
- return GL_TRUE;
-}
-
-
-
-static GLboolean invert_matrix_identity( GLmatrix *mat )
-{
- MEMCPY( mat->inv, Identity, sizeof(Identity) );
- return GL_TRUE;
-}
-
-
-static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat )
-{
- const GLfloat *in = mat->m;
- GLfloat *out = mat->inv;
-
- if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0 || MAT(in,2,2) == 0 )
- return GL_FALSE;
-
- MEMCPY( out, Identity, 16 * sizeof(GLfloat) );
- MAT(out,0,0) = 1.0 / MAT(in,0,0);
- MAT(out,1,1) = 1.0 / MAT(in,1,1);
- MAT(out,2,2) = 1.0 / MAT(in,2,2);
-
- if (mat->flags & MAT_FLAG_TRANSLATION) {
- MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0));
- MAT(out,1,3) = - (MAT(in,1,3) * MAT(out,1,1));
- MAT(out,2,3) = - (MAT(in,2,3) * MAT(out,2,2));
- }
-
- return GL_TRUE;
-}
-
-
-static GLboolean invert_matrix_2d_no_rot( GLmatrix *mat )
-{
- const GLfloat *in = mat->m;
- GLfloat *out = mat->inv;
-
- if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0)
- return GL_FALSE;
-
- MEMCPY( out, Identity, 16 * sizeof(GLfloat) );
- MAT(out,0,0) = 1.0 / MAT(in,0,0);
- MAT(out,1,1) = 1.0 / MAT(in,1,1);
-
- if (mat->flags & MAT_FLAG_TRANSLATION) {
- MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0));
- MAT(out,1,3) = - (MAT(in,1,3) * MAT(out,1,1));
- }
-
- return GL_TRUE;
-}
-
-
-static GLboolean invert_matrix_perspective( GLmatrix *mat )
-{
- const GLfloat *in = mat->m;
- GLfloat *out = mat->inv;
-
- if (MAT(in,2,3) == 0)
- return GL_FALSE;
-
- MEMCPY( out, Identity, 16 * sizeof(GLfloat) );
-
- MAT(out,0,0) = 1.0 / MAT(in,0,0);
- MAT(out,1,1) = 1.0 / MAT(in,1,1);
-
- MAT(out,0,3) = MAT(in,0,2);
- MAT(out,1,3) = MAT(in,1,2);
-
- MAT(out,2,2) = 0;
- MAT(out,2,3) = -1;
-
- MAT(out,3,2) = 1.0 / MAT(in,2,3);
- MAT(out,3,3) = MAT(in,2,2) * MAT(out,3,2);
-
- return GL_TRUE;
-}
-
-
-typedef GLboolean (*inv_mat_func)( GLmatrix *mat );
-
-
-static inv_mat_func inv_mat_tab[7] = {
- invert_matrix_general,
- invert_matrix_identity,
- invert_matrix_3d_no_rot,
- invert_matrix_perspective,
- invert_matrix_3d, /* lazy! */
- invert_matrix_2d_no_rot,
- invert_matrix_3d
-};
-
-
-static GLboolean matrix_invert( GLmatrix *mat )
-{
- if (inv_mat_tab[mat->type](mat)) {
- mat->flags &= ~MAT_FLAG_SINGULAR;
- return GL_TRUE;
- } else {
- mat->flags |= MAT_FLAG_SINGULAR;
- MEMCPY( mat->inv, Identity, sizeof(Identity) );
- return GL_FALSE;
- }
-}
-
-
-
-void gl_matrix_transposef( GLfloat to[16], const GLfloat from[16] )
-{
- to[0] = from[0];
- to[1] = from[4];
- to[2] = from[8];
- to[3] = from[12];
- to[4] = from[1];
- to[5] = from[5];
- to[6] = from[9];
- to[7] = from[13];
- to[8] = from[2];
- to[9] = from[6];
- to[10] = from[10];
- to[11] = from[14];
- to[12] = from[3];
- to[13] = from[7];
- to[14] = from[11];
- to[15] = from[15];
-}
-
-
-
-void gl_matrix_transposed( GLdouble to[16], const GLdouble from[16] )
-{
- to[0] = from[0];
- to[1] = from[4];
- to[2] = from[8];
- to[3] = from[12];
- to[4] = from[1];
- to[5] = from[5];
- to[6] = from[9];
- to[7] = from[13];
- to[8] = from[2];
- to[9] = from[6];
- to[10] = from[10];
- to[11] = from[14];
- to[12] = from[3];
- to[13] = from[7];
- to[14] = from[11];
- to[15] = from[15];
-}
-
-
-
-/*
- * Generate a 4x4 transformation matrix from glRotate parameters.
- */
-void gl_rotation_matrix( GLfloat angle, GLfloat x, GLfloat y, GLfloat z,
- GLfloat m[] )
-{
- /* This function contributed by Erich Boleyn ([email protected]) */
- GLfloat mag, s, c;
- GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c;
-
- s = sin( angle * DEG2RAD );
- c = cos( angle * DEG2RAD );
-
- mag = GL_SQRT( x*x + y*y + z*z );
-
- if (mag <= 1.0e-4) {
- /* generate an identity matrix and return */
- MEMCPY(m, Identity, sizeof(GLfloat)*16);
- return;
- }
-
- x /= mag;
- y /= mag;
- z /= mag;
-
-#define M(row,col) m[col*4+row]
-
- /*
- * Arbitrary axis rotation matrix.
- *
- * This is composed of 5 matrices, Rz, Ry, T, Ry', Rz', multiplied
- * like so: Rz * Ry * T * Ry' * Rz'. T is the final rotation
- * (which is about the X-axis), and the two composite transforms
- * Ry' * Rz' and Rz * Ry are (respectively) the rotations necessary
- * from the arbitrary axis to the X-axis then back. They are
- * all elementary rotations.
- *
- * Rz' is a rotation about the Z-axis, to bring the axis vector
- * into the x-z plane. Then Ry' is applied, rotating about the
- * Y-axis to bring the axis vector parallel with the X-axis. The
- * rotation about the X-axis is then performed. Ry and Rz are
- * simply the respective inverse transforms to bring the arbitrary
- * axis back to it's original orientation. The first transforms
- * Rz' and Ry' are considered inverses, since the data from the
- * arbitrary axis gives you info on how to get to it, not how
- * to get away from it, and an inverse must be applied.
- *
- * The basic calculation used is to recognize that the arbitrary
- * axis vector (x, y, z), since it is of unit length, actually
- * represents the sines and cosines of the angles to rotate the
- * X-axis to the same orientation, with theta being the angle about
- * Z and phi the angle about Y (in the order described above)
- * as follows:
- *
- * cos ( theta ) = x / sqrt ( 1 - z^2 )
- * sin ( theta ) = y / sqrt ( 1 - z^2 )
- *
- * cos ( phi ) = sqrt ( 1 - z^2 )
- * sin ( phi ) = z
- *
- * Note that cos ( phi ) can further be inserted to the above
- * formulas:
- *
- * cos ( theta ) = x / cos ( phi )
- * sin ( theta ) = y / sin ( phi )
- *
- * ...etc. Because of those relations and the standard trigonometric
- * relations, it is pssible to reduce the transforms down to what
- * is used below. It may be that any primary axis chosen will give the
- * same results (modulo a sign convention) using thie method.
- *
- * Particularly nice is to notice that all divisions that might
- * have caused trouble when parallel to certain planes or
- * axis go away with care paid to reducing the expressions.
- * After checking, it does perform correctly under all cases, since
- * in all the cases of division where the denominator would have
- * been zero, the numerator would have been zero as well, giving
- * the expected result.
- */
-
- xx = x * x;
- yy = y * y;
- zz = z * z;
- xy = x * y;
- yz = y * z;
- zx = z * x;
- xs = x * s;
- ys = y * s;
- zs = z * s;
- one_c = 1.0F - c;
-
- M(0,0) = (one_c * xx) + c;
- M(0,1) = (one_c * xy) - zs;
- M(0,2) = (one_c * zx) + ys;
- M(0,3) = 0.0F;
-
- M(1,0) = (one_c * xy) + zs;
- M(1,1) = (one_c * yy) + c;
- M(1,2) = (one_c * yz) - xs;
- M(1,3) = 0.0F;
-
- M(2,0) = (one_c * zx) - ys;
- M(2,1) = (one_c * yz) + xs;
- M(2,2) = (one_c * zz) + c;
- M(2,3) = 0.0F;
-
- M(3,0) = 0.0F;
- M(3,1) = 0.0F;
- M(3,2) = 0.0F;
- M(3,3) = 1.0F;
-
-#undef M
-}
-
-#define ZERO(x) (1<<x)
-#define ONE(x) (1<<(x+16))
-
-#define MASK_NO_TRX (ZERO(12) | ZERO(13) | ZERO(14))
-#define MASK_NO_2D_SCALE ( ONE(0) | ONE(5))
-
-#define MASK_IDENTITY ( ONE(0) | ZERO(4) | ZERO(8) | ZERO(12) |\
- ZERO(1) | ONE(5) | ZERO(9) | ZERO(13) |\
- ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\
- ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
-
-#define MASK_2D_NO_ROT ( ZERO(4) | ZERO(8) | \
- ZERO(1) | ZERO(9) | \
- ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\
- ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
-
-#define MASK_2D ( ZERO(8) | \
- ZERO(9) | \
- ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\
- ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
-
-
-#define MASK_3D_NO_ROT ( ZERO(4) | ZERO(8) | \
- ZERO(1) | ZERO(9) | \
- ZERO(2) | ZERO(6) | \
- ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
-
-#define MASK_3D ( \
- \
- \
- ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
-
-
-#define MASK_PERSPECTIVE ( ZERO(4) | ZERO(12) |\
- ZERO(1) | ZERO(13) |\
- ZERO(2) | ZERO(6) | \
- ZERO(3) | ZERO(7) | ZERO(15) )
-
-#define SQ(x) ((x)*(x))
-
-/* Determine type and flags from scratch. This is expensive enough to
- * only want to do it once.
- */
-static void analyze_from_scratch( GLmatrix *mat )
-{
- const GLfloat *m = mat->m;
- GLuint mask = 0;
- GLuint i;
-
- for (i = 0 ; i < 16 ; i++) {
- if (m[i] == 0.0) mask |= (1<<i);
- }
-
- if (m[0] == 1.0F) mask |= (1<<16);
- if (m[5] == 1.0F) mask |= (1<<21);
- if (m[10] == 1.0F) mask |= (1<<26);
- if (m[15] == 1.0F) mask |= (1<<31);
-
- mat->flags &= ~MAT_FLAGS_GEOMETRY;
-
- /* Check for translation - no-one really cares
- */
- if ((mask & MASK_NO_TRX) != MASK_NO_TRX)
- mat->flags |= MAT_FLAG_TRANSLATION;
-
- /* Do the real work
- */
- if (mask == MASK_IDENTITY) {
- mat->type = MATRIX_IDENTITY;
- }
- else if ((mask & MASK_2D_NO_ROT) == MASK_2D_NO_ROT) {
- mat->type = MATRIX_2D_NO_ROT;
-
- if ((mask & MASK_NO_2D_SCALE) != MASK_NO_2D_SCALE)
- mat->flags = MAT_FLAG_GENERAL_SCALE;
- }
- else if ((mask & MASK_2D) == MASK_2D) {
- GLfloat mm = DOT2(m, m);
- GLfloat m4m4 = DOT2(m+4,m+4);
- GLfloat mm4 = DOT2(m,m+4);
-
- mat->type = MATRIX_2D;
-
- /* Check for scale */
- if (SQ(mm-1) > SQ(1e-6) ||
- SQ(m4m4-1) > SQ(1e-6))
- mat->flags |= MAT_FLAG_GENERAL_SCALE;
-
- /* Check for rotation */
- if (SQ(mm4) > SQ(1e-6))
- mat->flags |= MAT_FLAG_GENERAL_3D;
- else
- mat->flags |= MAT_FLAG_ROTATION;
-
- }
- else if ((mask & MASK_3D_NO_ROT) == MASK_3D_NO_ROT) {
- mat->type = MATRIX_3D_NO_ROT;
-
- /* Check for scale */
- if (SQ(m[0]-m[5]) < SQ(1e-6) &&
- SQ(m[0]-m[10]) < SQ(1e-6)) {
- if (SQ(m[0]-1.0) > SQ(1e-6)) {
- mat->flags |= MAT_FLAG_UNIFORM_SCALE;
- }
- }
- else {
- mat->flags |= MAT_FLAG_GENERAL_SCALE;
- }
- }
- else if ((mask & MASK_3D) == MASK_3D) {
- GLfloat c1 = DOT3(m,m);
- GLfloat c2 = DOT3(m+4,m+4);
- GLfloat c3 = DOT3(m+8,m+8);
- GLfloat d1 = DOT3(m, m+4);
- GLfloat cp[3];
-
- mat->type = MATRIX_3D;
-
- /* Check for scale */
- if (SQ(c1-c2) < SQ(1e-6) && SQ(c1-c3) < SQ(1e-6)) {
- if (SQ(c1-1.0) > SQ(1e-6))
- mat->flags |= MAT_FLAG_UNIFORM_SCALE;
- /* else no scale at all */
- }
- else {
- mat->flags |= MAT_FLAG_GENERAL_SCALE;
- }
-
- /* Check for rotation */
- if (SQ(d1) < SQ(1e-6)) {
- CROSS3( cp, m, m+4 );
- SUB_3V( cp, cp, (m+8) );
- if (LEN_SQUARED_3FV(cp) < SQ(1e-6))
- mat->flags |= MAT_FLAG_ROTATION;
- else
- mat->flags |= MAT_FLAG_GENERAL_3D;
- }
- else {
- mat->flags |= MAT_FLAG_GENERAL_3D; /* shear, etc */
- }
- }
- else if ((mask & MASK_PERSPECTIVE) == MASK_PERSPECTIVE && m[11]==-1.0F) {
- mat->type = MATRIX_PERSPECTIVE;
- mat->flags |= MAT_FLAG_GENERAL;
- }
- else {
- mat->type = MATRIX_GENERAL;
- mat->flags |= MAT_FLAG_GENERAL;
- }
-}
-
-
-/* Analyse a matrix given that its flags are accurate - this is the
- * more common operation, hopefully.
- */
-static void analyze_from_flags( GLmatrix *mat )
-{
- const GLfloat *m = mat->m;
-
- if (TEST_MAT_FLAGS(mat, 0)) {
- mat->type = MATRIX_IDENTITY;
- }
- else if (TEST_MAT_FLAGS(mat, (MAT_FLAG_TRANSLATION |
- MAT_FLAG_UNIFORM_SCALE |
- MAT_FLAG_GENERAL_SCALE))) {
- if ( m[10]==1.0F && m[14]==0.0F ) {
- mat->type = MATRIX_2D_NO_ROT;
- }
- else {
- mat->type = MATRIX_3D_NO_ROT;
- }
- }
- else if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) {
- if ( m[ 8]==0.0F
- && m[ 9]==0.0F
- && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F) {
- mat->type = MATRIX_2D;
- }
- else {
- mat->type = MATRIX_3D;
- }
- }
- else if ( m[4]==0.0F && m[12]==0.0F
- && m[1]==0.0F && m[13]==0.0F
- && m[2]==0.0F && m[6]==0.0F
- && m[3]==0.0F && m[7]==0.0F && m[11]==-1.0F && m[15]==0.0F) {
- mat->type = MATRIX_PERSPECTIVE;
- }
- else {
- mat->type = MATRIX_GENERAL;
- }
-}
-
-
-void gl_matrix_analyze( GLmatrix *mat )
-{
- if (mat->flags & MAT_DIRTY_TYPE) {
- if (mat->flags & MAT_DIRTY_FLAGS)
- analyze_from_scratch( mat );
- else
- analyze_from_flags( mat );
- }
-
- if (mat->inv && (mat->flags & MAT_DIRTY_INVERSE)) {
- matrix_invert( mat );
- }
-
- mat->flags &= ~(MAT_DIRTY_FLAGS|
- MAT_DIRTY_TYPE|
- MAT_DIRTY_INVERSE);
-}
-
-
-static void matrix_copy( GLmatrix *to, const GLmatrix *from )
-{
- MEMCPY( to->m, from->m, sizeof(Identity) );
- to->flags = from->flags | MAT_DIRTY_DEPENDENTS;
- to->type = from->type;
-
- if (to->inv != 0) {
- if (from->inv == 0) {
- matrix_invert( to );
- }
- else {
- MEMCPY(to->inv, from->inv, sizeof(GLfloat)*16);
- }
- }
-}
-
-/*
- * Multiply a matrix by an array of floats with known properties.
- */
-static void mat_mul_floats( GLmatrix *mat, const GLfloat *m, GLuint flags )
-{
- mat->flags |= (flags |
- MAT_DIRTY_TYPE |
- MAT_DIRTY_INVERSE |
- MAT_DIRTY_DEPENDENTS);
-
- if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D))
- matmul34( mat->m, mat->m, m );
- else
- matmul4( mat->m, mat->m, m );
-
-}
-
-
-void gl_matrix_ctr( GLmatrix *m )
-{
- if ( m->m == 0 ) {
- m->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
- }
- MEMCPY( m->m, Identity, sizeof(Identity) );
- m->inv = 0;
- m->type = MATRIX_IDENTITY;
- m->flags = MAT_DIRTY_DEPENDENTS;
-}
-
-void gl_matrix_dtr( GLmatrix *m )
-{
- if ( m->m != 0 ) {
- ALIGN_FREE( m->m );
- m->m = 0;
- }
- if ( m->inv != 0 ) {
- ALIGN_FREE( m->inv );
- m->inv = 0;
- }
-}
-
-
-void gl_matrix_alloc_inv( GLmatrix *m )
-{
- if ( m->inv == 0 ) {
- m->inv = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
- MEMCPY( m->inv, Identity, 16 * sizeof(GLfloat) );
- }
-}
-
-
-void gl_matrix_mul( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b )
-{
- dest->flags = (a->flags |
- b->flags |
- MAT_DIRTY_TYPE |
- MAT_DIRTY_INVERSE |
- MAT_DIRTY_DEPENDENTS);
-
- if (TEST_MAT_FLAGS(dest, MAT_FLAGS_3D))
- matmul34( dest->m, a->m, b->m );
- else
- matmul4( dest->m, a->m, b->m );
-}
+#include "math/m_matrix.h"
+#endif
/**********************************************************************/
@@ -1017,45 +90,21 @@ _mesa_Frustum( GLdouble left, GLdouble right,
GLdouble nearval, GLdouble farval )
{
GET_CURRENT_CONTEXT(ctx);
- GLfloat x, y, a, b, c, d;
- GLfloat m[16];
GLmatrix *mat = 0;
GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glFrustrum" );
- if ((nearval<=0.0 || farval<=0.0) || (nearval == farval) || (left == right) || (top == bottom)) {
- gl_error( ctx, GL_INVALID_VALUE, "glFrustum(near or far)" );
+ if (nearval <= 0.0 ||
+ farval <= 0.0 ||
+ nearval == farval ||
+ left == right ||
+ top == bottom)
+ {
+ gl_error( ctx, GL_INVALID_VALUE, "glFrustum" );
return;
}
-
- x = (2.0*nearval) / (right-left);
- y = (2.0*nearval) / (top-bottom);
- a = (right+left) / (right-left);
- b = (top+bottom) / (top-bottom);
- c = -(farval+nearval) / ( farval-nearval);
- d = -(2.0*farval*nearval) / (farval-nearval); /* error? */
-
-#define M(row,col) m[col*4+row]
- M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
- M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
- M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
- M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
-#undef M
-
- mat_mul_floats( mat, m, MAT_FLAG_PERSPECTIVE );
-
- if (ctx->Transform.MatrixMode == GL_PROJECTION) {
- /* Need to keep a stack of near/far values in case the user push/pops
- * the projection matrix stack so that we can call Driver.NearFar()
- * after a pop.
- */
- ctx->NearFarStack[ctx->ProjectionStackDepth][0] = nearval;
- ctx->NearFarStack[ctx->ProjectionStackDepth][1] = farval;
-
- if (ctx->Driver.NearFar) {
- (*ctx->Driver.NearFar)( ctx, nearval, farval );
- }
- }
+
+ _math_matrix_frustrum( mat, left, right, bottom, top, nearval, farval );
}
@@ -1065,38 +114,19 @@ _mesa_Ortho( GLdouble left, GLdouble right,
GLdouble nearval, GLdouble farval )
{
GET_CURRENT_CONTEXT(ctx);
- GLfloat x, y, z;
- GLfloat tx, ty, tz;
- GLfloat m[16];
GLmatrix *mat = 0;
GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glOrtho" );
- if ((left == right) || (bottom == top) || (nearval == farval)) {
- gl_error( ctx, GL_INVALID_VALUE,
- "gl_Ortho((l = r) or (b = top) or (n=f)" );
+ if (left == right ||
+ bottom == top ||
+ nearval == farval)
+ {
+ gl_error( ctx, GL_INVALID_VALUE, "gl_Ortho" );
return;
}
- x = 2.0 / (right-left);
- y = 2.0 / (top-bottom);
- z = -2.0 / (farval-nearval);
- tx = -(right+left) / (right-left);
- ty = -(top+bottom) / (top-bottom);
- tz = -(farval+nearval) / (farval-nearval);
-
-#define M(row,col) m[col*4+row]
- M(0,0) = x; M(0,1) = 0.0F; M(0,2) = 0.0F; M(0,3) = tx;
- M(1,0) = 0.0F; M(1,1) = y; M(1,2) = 0.0F; M(1,3) = ty;
- M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = z; M(2,3) = tz;
- M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = 0.0F; M(3,3) = 1.0F;
-#undef M
-
- mat_mul_floats( mat, m, (MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION));
-
- if (ctx->Driver.NearFar) {
- (*ctx->Driver.NearFar)( ctx, nearval, farval );
- }
+ _math_matrix_ortho( mat, left, right, bottom, top, nearval, farval );
}
@@ -1135,7 +165,7 @@ _mesa_PushMatrix( void )
gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
- matrix_copy( &ctx->ModelViewStack[ctx->ModelViewStackDepth++],
+ _math_matrix_copy( &ctx->ModelViewStack[ctx->ModelViewStackDepth++],
&ctx->ModelView );
break;
case GL_PROJECTION:
@@ -1143,14 +173,8 @@ _mesa_PushMatrix( void )
gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
- matrix_copy( &ctx->ProjectionStack[ctx->ProjectionStackDepth++],
+ _math_matrix_copy( &ctx->ProjectionStack[ctx->ProjectionStackDepth++],
&ctx->ProjectionMatrix );
-
- /* Save near and far projection values */
- ctx->NearFarStack[ctx->ProjectionStackDepth][0]
- = ctx->NearFarStack[ctx->ProjectionStackDepth-1][0];
- ctx->NearFarStack[ctx->ProjectionStackDepth][1]
- = ctx->NearFarStack[ctx->ProjectionStackDepth-1][1];
break;
case GL_TEXTURE:
{
@@ -1159,7 +183,7 @@ _mesa_PushMatrix( void )
gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
- matrix_copy( &ctx->TextureStack[t][ctx->TextureStackDepth[t]++],
+ _math_matrix_copy( &ctx->TextureStack[t][ctx->TextureStackDepth[t]++],
&ctx->TextureMatrix[t] );
}
break;
@@ -1168,7 +192,7 @@ _mesa_PushMatrix( void )
gl_error( ctx, GL_STACK_OVERFLOW, "glPushMatrix");
return;
}
- matrix_copy( &ctx->ColorStack[ctx->ColorStackDepth++],
+ _math_matrix_copy( &ctx->ColorStack[ctx->ColorStackDepth++],
&ctx->ColorMatrix );
break;
default:
@@ -1194,8 +218,8 @@ _mesa_PopMatrix( void )
gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
- matrix_copy( &ctx->ModelView,
- &ctx->ModelViewStack[--ctx->ModelViewStackDepth] );
+ _math_matrix_copy( &ctx->ModelView,
+ &ctx->ModelViewStack[--ctx->ModelViewStackDepth] );
ctx->NewState |= _NEW_MODELVIEW;
break;
case GL_PROJECTION:
@@ -1204,18 +228,9 @@ _mesa_PopMatrix( void )
return;
}
- matrix_copy( &ctx->ProjectionMatrix,
- &ctx->ProjectionStack[--ctx->ProjectionStackDepth] );
+ _math_matrix_copy( &ctx->ProjectionMatrix,
+ &ctx->ProjectionStack[--ctx->ProjectionStackDepth] );
ctx->NewState |= _NEW_PROJECTION;
-
- /* Device driver near/far values */
- {
- GLfloat nearVal = ctx->NearFarStack[ctx->ProjectionStackDepth][0];
- GLfloat farVal = ctx->NearFarStack[ctx->ProjectionStackDepth][1];
- if (ctx->Driver.NearFar) {
- (*ctx->Driver.NearFar)( ctx, nearVal, farVal );
- }
- }
break;
case GL_TEXTURE:
{
@@ -1224,8 +239,8 @@ _mesa_PopMatrix( void )
gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
- matrix_copy(&ctx->TextureMatrix[t],
- &ctx->TextureStack[t][--ctx->TextureStackDepth[t]]);
+ _math_matrix_copy(&ctx->TextureMatrix[t],
+ &ctx->TextureStack[t][--ctx->TextureStackDepth[t]]);
ctx->NewState |= _NEW_TEXTURE_MATRIX;
}
break;
@@ -1234,8 +249,8 @@ _mesa_PopMatrix( void )
gl_error( ctx, GL_STACK_UNDERFLOW, "glPopMatrix");
return;
}
- matrix_copy(&ctx->ColorMatrix,
- &ctx->ColorStack[--ctx->ColorStackDepth]);
+ _math_matrix_copy(&ctx->ColorMatrix,
+ &ctx->ColorStack[--ctx->ColorStackDepth]);
ctx->NewState |= _NEW_COLOR_MATRIX;
break;
default:
@@ -1251,19 +266,7 @@ _mesa_LoadIdentity( void )
GET_CURRENT_CONTEXT(ctx);
GLmatrix *mat = 0;
GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glLoadIdentity");
-
- MEMCPY( mat->m, Identity, 16*sizeof(GLfloat) );
-
- if (mat->inv)
- MEMCPY( mat->inv, Identity, 16*sizeof(GLfloat) );
-
- mat->type = MATRIX_IDENTITY;
-
- /* Have to set this to dirty to make sure we recalculate the
- * combined matrix later. The update_matrix in this case is a
- * shortcircuit anyway...
- */
- mat->flags = MAT_DIRTY_DEPENDENTS;
+ _math_matrix_set_identity( mat );
}
@@ -1273,38 +276,15 @@ _mesa_LoadMatrixf( const GLfloat *m )
GET_CURRENT_CONTEXT(ctx);
GLmatrix *mat = 0;
GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glLoadMatrix");
-
- MEMCPY( mat->m, m, 16*sizeof(GLfloat) );
- mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL_OVER);
-
- if (ctx->Transform.MatrixMode == GL_PROJECTION) {
-
-#define M(row,col) m[col*4+row]
- GLfloat c = M(2,2);
- GLfloat d = M(2,3);
-#undef M
- GLfloat n = (c == 1.0 ? 0.0 : d / (c - 1.0));
- GLfloat f = (c == -1.0 ? 1.0 : d / (c + 1.0));
-
- /* Need to keep a stack of near/far values in case the user
- * push/pops the projection matrix stack so that we can call
- * Driver.NearFar() after a pop.
- */
- ctx->NearFarStack[ctx->ProjectionStackDepth][0] = n;
- ctx->NearFarStack[ctx->ProjectionStackDepth][1] = f;
-
- if (ctx->Driver.NearFar) {
- (*ctx->Driver.NearFar)( ctx, n, f );
- }
- }
+ _math_matrix_loadf( mat, m );
}
void
_mesa_LoadMatrixd( const GLdouble *m )
{
- GLfloat f[16];
GLint i;
+ GLfloat f[16];
for (i = 0; i < 16; i++)
f[i] = m[i];
_mesa_LoadMatrixf(f);
@@ -1321,8 +301,7 @@ _mesa_MultMatrixf( const GLfloat *m )
GET_CURRENT_CONTEXT(ctx);
GLmatrix *mat = 0;
GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glMultMatrix" );
- matmul4( mat->m, mat->m, m );
- mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL_OVER);
+ _math_matrix_mul_floats( mat, m );
}
@@ -1332,11 +311,11 @@ _mesa_MultMatrixf( const GLfloat *m )
void
_mesa_MultMatrixd( const GLdouble *m )
{
- GET_CURRENT_CONTEXT(ctx);
- GLmatrix *mat = 0;
- GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glMultMatrix" );
- matmul4fd( mat->m, mat->m, m );
- mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY_ALL_OVER);
+ GLint i;
+ GLfloat f[16];
+ for (i = 0; i < 16; i++)
+ f[i] = m[i];
+ _mesa_MultMatrixf( f );
}
@@ -1349,13 +328,10 @@ void
_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
{
GET_CURRENT_CONTEXT(ctx);
- GLfloat m[16];
if (angle != 0.0F) {
GLmatrix *mat = 0;
GET_ACTIVE_MATRIX( ctx, mat, ctx->NewState, "glRotate" );
-
- gl_rotation_matrix( angle, x, y, z, m );
- mat_mul_floats( mat, m, MAT_FLAG_ROTATION );
+ _math_matrix_rotate( mat, angle, x, y, z );
}
}
@@ -1374,23 +350,8 @@ _mesa_Scalef( GLfloat x, GLfloat y, GLfloat z )
{
GET_CURRENT_CONTEXT(ctx);
GLmatrix *mat = 0;
- GLfloat *m;
GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glScale");
-
- m = mat->m;
- m[0] *= x; m[4] *= y; m[8] *= z;
- m[1] *= x; m[5] *= y; m[9] *= z;
- m[2] *= x; m[6] *= y; m[10] *= z;
- m[3] *= x; m[7] *= y; m[11] *= z;
-
- if (fabs(x - y) < 1e-8 && fabs(x - z) < 1e-8)
- mat->flags |= MAT_FLAG_UNIFORM_SCALE;
- else
- mat->flags |= MAT_FLAG_GENERAL_SCALE;
-
- mat->flags |= (MAT_DIRTY_TYPE |
- MAT_DIRTY_INVERSE |
- MAT_DIRTY_DEPENDENTS);
+ _math_matrix_scale( mat, x, y, z );
}
@@ -1409,18 +370,8 @@ _mesa_Translatef( GLfloat x, GLfloat y, GLfloat z )
{
GET_CURRENT_CONTEXT(ctx);
GLmatrix *mat = 0;
- GLfloat *m;
GET_ACTIVE_MATRIX(ctx, mat, ctx->NewState, "glTranslate");
- m = mat->m;
- m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
- m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
- m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
- m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
-
- mat->flags |= (MAT_FLAG_TRANSLATION |
- MAT_DIRTY_TYPE |
- MAT_DIRTY_INVERSE |
- MAT_DIRTY_DEPENDENTS);
+ _math_matrix_translate( mat, x, y, z );
}
@@ -1431,12 +382,11 @@ _mesa_Translated( GLdouble x, GLdouble y, GLdouble z )
}
-
void
_mesa_LoadTransposeMatrixfARB( const GLfloat *m )
{
GLfloat tm[16];
- gl_matrix_transposef(tm, m);
+ _math_transposef(tm, m);
_mesa_LoadMatrixf(tm);
}
@@ -1444,9 +394,9 @@ _mesa_LoadTransposeMatrixfARB( const GLfloat *m )
void
_mesa_LoadTransposeMatrixdARB( const GLdouble *m )
{
- GLdouble tm[16];
- gl_matrix_transposed(tm, m);
- _mesa_LoadMatrixd(tm);
+ GLfloat tm[16];
+ _math_transposefd(tm, m);
+ _mesa_LoadMatrixf(tm);
}
@@ -1454,7 +404,7 @@ void
_mesa_MultTransposeMatrixfARB( const GLfloat *m )
{
GLfloat tm[16];
- gl_matrix_transposef(tm, m);
+ _math_transposef(tm, m);
_mesa_MultMatrixf(tm);
}
@@ -1462,9 +412,9 @@ _mesa_MultTransposeMatrixfARB( const GLfloat *m )
void
_mesa_MultTransposeMatrixdARB( const GLdouble *m )
{
- GLdouble tm[16];
- gl_matrix_transposed(tm, m);
- _mesa_MultMatrixd(tm);
+ GLfloat tm[16];
+ _math_transposefd(tm, m);
+ _mesa_MultMatrixf(tm);
}
@@ -1518,7 +468,6 @@ gl_Viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height )
ctx->Viewport._WindowMap.m[MAT_TY] = ctx->Viewport._WindowMap.m[MAT_SY] + y;
ctx->Viewport._WindowMap.m[MAT_SZ] = 0.5 * ctx->Visual.DepthMaxF;
ctx->Viewport._WindowMap.m[MAT_TZ] = 0.5 * ctx->Visual.DepthMaxF;
-
ctx->Viewport._WindowMap.flags = MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION;
ctx->Viewport._WindowMap.type = MATRIX_3D_NO_ROT;
ctx->NewState |= _NEW_VIEWPORT;
diff --git a/src/mesa/main/matrix.h b/src/mesa/main/matrix.h
index db88b2857cf..fce9dace657 100644
--- a/src/mesa/main/matrix.h
+++ b/src/mesa/main/matrix.h
@@ -1,4 +1,4 @@
-/* $Id: matrix.h,v 1.8 2000/10/29 18:12:15 brianp Exp $ */
+/* $Id: matrix.h,v 1.9 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -38,39 +38,8 @@
extern void
-gl_matrix_transposef( GLfloat to[16], const GLfloat from[16] );
-
-extern void
-gl_matrix_transposed( GLdouble to[16], const GLdouble from[16] );
-
-
-extern void
-gl_rotation_matrix( GLfloat angle, GLfloat x, GLfloat y, GLfloat z,
- GLfloat m[] );
-
-
-extern void
gl_calculate_model_project_matrix( GLcontext *ctx );
-extern void
-gl_matrix_ctr( GLmatrix *m );
-
-extern void
-gl_matrix_dtr( GLmatrix *m );
-
-extern void
-gl_matrix_alloc_inv( GLmatrix *m );
-
-extern void
-gl_matrix_mul( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
-
-extern void
-gl_matrix_analyze( GLmatrix *mat );
-
-extern void
-gl_print_matrix( const GLmatrix *m );
-
-
extern void
_mesa_Frustum( GLdouble left, GLdouble right,
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index b4de245e9f6..26c4d5efab4 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -1,4 +1,4 @@
-/* $Id: points.c,v 1.22 2000/11/15 16:38:40 brianp Exp $ */
+/* $Id: points.c,v 1.23 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -36,7 +36,6 @@
#include "points.h"
#include "texstate.h"
#include "types.h"
-#include "vb.h"
#endif
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index e8d36a3ba00..a59e22a36a1 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -1,4 +1,4 @@
-/* $Id: rastpos.c,v 1.13 2000/11/13 20:02:56 keithw Exp $ */
+/* $Id: rastpos.c,v 1.14 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -35,17 +35,206 @@
#include "feedback.h"
#include "light.h"
#include "macros.h"
-#include "matrix.h"
#include "mmath.h"
#include "rastpos.h"
-#include "shade.h"
#include "state.h"
+#include "simple_list.h"
#include "types.h"
-#include "xform.h"
+
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
#endif
/*
+ * Clip a point against the view volume.
+ * Input: v - vertex-vector describing the point to clip
+ * Return: 0 = outside view volume
+ * 1 = inside view volume
+ */
+static GLuint gl_viewclip_point( const GLfloat v[] )
+{
+ if ( v[0] > v[3] || v[0] < -v[3]
+ || v[1] > v[3] || v[1] < -v[3]
+ || v[2] > v[3] || v[2] < -v[3] ) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+/*
+ * Clip a point against the user clipping planes.
+ * Input: v - vertex-vector describing the point to clip.
+ * Return: 0 = point was clipped
+ * 1 = point not clipped
+ */
+static GLuint gl_userclip_point( GLcontext* ctx, const GLfloat v[] )
+{
+ GLuint p;
+
+ for (p=0;p<MAX_CLIP_PLANES;p++) {
+ if (ctx->Transform.ClipEnabled[p]) {
+ GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
+ + v[1] * ctx->Transform._ClipUserPlane[p][1]
+ + v[2] * ctx->Transform._ClipUserPlane[p][2]
+ + v[3] * ctx->Transform._ClipUserPlane[p][3];
+ if (dot < 0.0F) {
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+
+/* This has been split off to allow the normal shade routines to
+ * get a little closer to the vertex buffer, and to use the
+ * GLvector objects directly.
+ */
+static void gl_shade_rastpos( GLcontext *ctx,
+ GLfloat vertex[4],
+ GLfloat normal[3],
+ GLfloat Rcolor[4],
+ GLuint *index )
+{
+ GLfloat (*base)[3] = ctx->Light._BaseColor;
+ const GLchan *sumA = ctx->Light._BaseAlpha;
+ struct gl_light *light;
+ GLfloat color[4];
+ GLfloat diffuse = 0, specular = 0;
+
+ COPY_3V(color, base[0]);
+ color[3] = CHAN_TO_FLOAT( sumA[0] );
+
+ foreach (light, &ctx->Light.EnabledList) {
+ GLfloat n_dot_h;
+ GLfloat attenuation = 1.0;
+ GLfloat VP[3];
+ GLfloat n_dot_VP;
+ GLfloat *h;
+ GLfloat contrib[3];
+ GLboolean normalized;
+
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ COPY_3V(VP, light->_VP_inf_norm);
+ attenuation = light->_VP_inf_spot_attenuation;
+ }
+ else {
+ GLfloat d;
+
+ SUB_3V(VP, light->_Position, vertex);
+ d = LEN_3FV( VP );
+
+ if ( d > 1e-6) {
+ GLfloat invd = 1.0F / d;
+ SELF_SCALE_SCALAR_3V(VP, invd);
+ }
+ attenuation = 1.0F / (light->ConstantAttenuation + d *
+ (light->LinearAttenuation + d *
+ light->QuadraticAttenuation));
+
+ if (light->_Flags & LIGHT_SPOT)
+ {
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+
+ if (PV_dot_dir<light->_CosCutoff) {
+ continue;
+ }
+ else
+ {
+ double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
+ int k = (int) x;
+ GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
+ + (x-k)*light->_SpotExpTable[k][1]);
+ attenuation *= spot;
+ }
+ }
+ }
+
+ if (attenuation < 1e-3)
+ continue;
+
+ n_dot_VP = DOT3( normal, VP );
+
+ if (n_dot_VP < 0.0F) {
+ ACC_SCALE_SCALAR_3V(color, attenuation, light->_MatAmbient[0]);
+ continue;
+ }
+
+ COPY_3V(contrib, light->_MatAmbient[0]);
+ ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[0]);
+ diffuse += n_dot_VP * light->_dli * attenuation;
+
+ if (light->_IsMatSpecular[0]) {
+ if (ctx->Light.Model.LocalViewer) {
+ GLfloat v[3];
+ COPY_3V(v, vertex);
+ NORMALIZE_3FV(v);
+ SUB_3V(VP, VP, v);
+ h = VP;
+ normalized = 0;
+ }
+ else if (light->_Flags & LIGHT_POSITIONAL) {
+ h = VP;
+ ACC_3V(h, ctx->_EyeZDir);
+ normalized = 0;
+ }
+ else {
+ h = light->_h_inf_norm;
+ normalized = 1;
+ }
+
+ n_dot_h = DOT3(normal, h);
+
+ if (n_dot_h > 0.0F) {
+ struct gl_material *mat = &ctx->Light.Material[0];
+ GLfloat spec_coef;
+ GLfloat shininess = mat->Shininess;
+
+ if (!normalized) {
+ n_dot_h *= n_dot_h;
+ n_dot_h /= LEN_SQUARED_3FV( h );
+ shininess *= .5;
+ }
+
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef );
+
+ if (spec_coef > 1.0e-10) {
+ ACC_SCALE_SCALAR_3V( contrib, spec_coef,
+ light->_MatSpecular[0]);
+ specular += spec_coef * light->_sli * attenuation;
+ }
+ }
+ }
+
+ ACC_SCALE_SCALAR_3V( color, attenuation, contrib );
+ }
+
+ if (ctx->Visual.RGBAflag) {
+ Rcolor[0] = CLAMP(color[0], 0.0F, 1.0F);
+ Rcolor[1] = CLAMP(color[1], 0.0F, 1.0F);
+ Rcolor[2] = CLAMP(color[2], 0.0F, 1.0F);
+ Rcolor[3] = CLAMP(color[3], 0.0F, 1.0F);
+ }
+ else {
+ struct gl_material *mat = &ctx->Light.Material[0];
+ GLfloat d_a = mat->DiffuseIndex - mat->AmbientIndex;
+ GLfloat s_a = mat->SpecularIndex - mat->AmbientIndex;
+ GLfloat ind = mat->AmbientIndex
+ + diffuse * (1.0F-specular) * d_a
+ + specular * s_a;
+ if (ind > mat->SpecularIndex) {
+ ind = mat->SpecularIndex;
+ }
+ *index = (GLuint) (GLint) ind;
+ }
+
+}
+
+/*
* Caller: context->API.RasterPos4f
*/
static void raster_pos4f( GLcontext *ctx,
@@ -54,10 +243,12 @@ static void raster_pos4f( GLcontext *ctx,
GLfloat v[4], eye[4], clip[4], ndc[3], d;
/* KW: Added this test, which is in the spec. We can't do this
- * outside begin/end any more because the ctx->Current values
+ * inside begin/end any more because the ctx->Current values
* aren't uptodate during that period.
*/
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx, "glRasterPos" );
+ FLUSH_TNL_RETURN(ctx, (FLUSH_INSIDE_BEGIN_END|
+ FLUSH_STORED_VERTICES|
+ FLUSH_UPDATE_CURRENT), "raster_pos4f");
if (ctx->NewState)
gl_update_state( ctx );
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index eb68bf70a5f..d1dde8c88ed 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,4 +1,4 @@
-/* $Id: state.c,v 1.44 2000/11/15 16:38:59 brianp Exp $ */
+/* $Id: state.c,v 1.45 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -46,7 +46,6 @@
#include "context.h"
#include "convolve.h"
#include "copypix.h"
-#include "cva.h"
#include "depth.h"
#include "dlist.h"
#include "drawpix.h"
@@ -63,7 +62,6 @@
#include "masking.h"
#include "matrix.h"
#include "mmath.h"
-#include "pipeline.h"
#include "pixel.h"
#include "pixeltex.h"
#include "points.h"
@@ -72,7 +70,6 @@
#include "readpix.h"
#include "rect.h"
#include "scissor.h"
-#include "shade.h"
#include "state.h"
#include "stencil.h"
#include "teximage.h"
@@ -81,11 +78,15 @@
#include "texture.h"
#include "types.h"
#include "varray.h"
-#include "vbfill.h"
-#include "vbrender.h"
#include "winpos.h"
-#include "xform.h"
+
#include "swrast/swrast.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+#include "tnl/t_eval.h"
+#include "tnl/t_vbfill.h"
+#include "tnl/t_varray.h"
+#include "tnl/t_rect.h"
#endif
@@ -690,150 +691,6 @@ _mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize)
/**********************************************************************/
-
-
-
-void gl_print_state( const char *msg, GLuint state )
-{
- fprintf(stderr,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- msg,
- state,
- (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
- (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
- (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
- (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "",
- (state & _NEW_ACCUM) ? "ctx->Accum, " : "",
- (state & _NEW_COLOR) ? "ctx->Color, " : "",
- (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
- (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
- (state & _NEW_FOG) ? "ctx->Fog, " : "",
- (state & _NEW_HINT) ? "ctx->Hint, " : "",
- (state & _NEW_LIGHT) ? "ctx->Light, " : "",
- (state & _NEW_LINE) ? "ctx->Line, " : "",
- (state & _NEW_FEEDBACK_SELECT) ? "ctx->Feedback/Select, " : "",
- (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
- (state & _NEW_POINT) ? "ctx->Point, " : "",
- (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
- (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
- (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
- (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
- (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
- (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
- (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
- (state & _NEW_ARRAY) ? "ctx->Array, " : "",
- (state & _NEW_COLORTABLE) ? "ctx->{*}ColorTable, " : "",
- (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
- (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
-}
-
-
-void gl_print_enable_flags( const char *msg, GLuint flags )
-{
- fprintf(stderr,
- "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s\n",
- msg,
- flags,
- (flags & ENABLE_TEX0) ? "tex-0, " : "",
- (flags & ENABLE_TEX1) ? "tex-1, " : "",
- (flags & ENABLE_LIGHT) ? "light, " : "",
- (flags & ENABLE_FOG) ? "fog, " : "",
- (flags & ENABLE_USERCLIP) ? "userclip, " : "",
- (flags & ENABLE_TEXGEN0) ? "tex-gen-0, " : "",
- (flags & ENABLE_TEXGEN1) ? "tex-gen-1, " : "",
- (flags & ENABLE_TEXMAT0) ? "tex-mat-0, " : "",
- (flags & ENABLE_TEXMAT1) ? "tex-mat-1, " : "",
- (flags & ENABLE_NORMALIZE) ? "normalize, " : "",
- (flags & ENABLE_RESCALE) ? "rescale, " : "");
-}
-
-
-/* Note: This routine refers to derived texture attribute values to
- * compute the ENABLE_TEXMAT flags, but is only called on
- * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
- * flags are updated by _mesa_update_textures(), below.
- *
- * If both TEXTURE and TEXTURE_MATRIX change at once, these values
- * will be computed twice.
- */
-static void
-_mesa_update_texture_matrices( GLcontext *ctx )
-{
- GLuint i;
-
- ctx->_Enabled &= ~(ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | ENABLE_TEXMAT2);
-
- for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) {
- gl_matrix_analyze( &ctx->TextureMatrix[i] );
- ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS;
-
- if (ctx->Texture.Unit[i]._ReallyEnabled &&
- ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
- ctx->_Enabled |= ENABLE_TEXMAT0 << i;
- }
- }
-}
-
-
-/* Note: This routine refers to derived texture matrix values to
- * compute the ENABLE_TEXMAT flags, but is only called on
- * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
- * flags are updated by _mesa_update_texture_matrices, above.
- *
- * If both TEXTURE and TEXTURE_MATRIX change at once, these values
- * will be computed twice.
- */
-static void
-_mesa_update_textures( GLcontext *ctx )
-{
- GLuint i;
-
- ctx->Texture._ReallyEnabled = 0;
- ctx->_Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1 | ENABLE_TEXGEN2 |
- ENABLE_TEXMAT0 | ENABLE_TEXMAT1 | ENABLE_TEXMAT2 |
- ENABLE_TEX0 | ENABLE_TEX1 | ENABLE_TEX2);
-
- gl_update_dirty_texobjs(ctx);
-
- for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
-
- ctx->Texture.Unit[i]._ReallyEnabled = 0;
-
- if (ctx->Texture.Unit[i].Enabled) {
-
- gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] );
-
- if (ctx->Texture.Unit[i]._ReallyEnabled) {
- GLuint flag = ctx->Texture.Unit[i]._ReallyEnabled << (i * 4);
-
- ctx->Texture._ReallyEnabled |= flag;
- ctx->_Enabled |= flag;
-
- if (ctx->Texture.Unit[i]._GenFlags) {
- ctx->_Enabled |= ENABLE_TEXGEN0 << i;
- ctx->Texture._GenFlags |= ctx->Texture.Unit[i]._GenFlags;
- }
-
- if (ctx->TextureMatrix[i].type != MATRIX_IDENTITY)
- ctx->_Enabled |= ENABLE_TEXMAT0 << i;
- }
- }
- }
-
- ctx->_NeedNormals &= ~NEED_NORMALS_TEXGEN;
- ctx->_NeedEyeCoords &= ~NEED_EYE_TEXGEN;
-
- if (ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS) {
- ctx->_NeedNormals |= NEED_NORMALS_TEXGEN;
- ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN;
- }
-
- if (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) {
- ctx->_NeedEyeCoords |= NEED_EYE_TEXGEN;
- }
-}
-
static void
_mesa_update_polygon( GLcontext *ctx )
{
@@ -872,11 +729,11 @@ static void
_mesa_calculate_model_project_matrix( GLcontext *ctx )
{
if (!ctx->_NeedEyeCoords) {
- gl_matrix_mul( &ctx->_ModelProjectMatrix,
- &ctx->ProjectionMatrix,
- &ctx->ModelView );
+ _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix,
+ &ctx->ProjectionMatrix,
+ &ctx->ModelView );
- gl_matrix_analyze( &ctx->_ModelProjectMatrix );
+ _math_matrix_analyze( &ctx->_ModelProjectMatrix );
}
}
@@ -913,7 +770,6 @@ _mesa_update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords )
*/
_mesa_update_modelview_scale(ctx);
_mesa_calculate_model_project_matrix(ctx);
- gl_update_normal_transform( ctx );
gl_compute_light_positions( ctx );
if (ctx->Driver.LightingSpaceChange)
@@ -932,9 +788,6 @@ _mesa_update_tnl_spaces( GLcontext *ctx, GLuint oldneedeyecoords )
if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
_mesa_calculate_model_project_matrix(ctx);
- if (new_state & _TNL_NEW_NORMAL_TRANSFORM)
- gl_update_normal_transform( ctx ); /* references _ModelViewInvScale */
-
if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW))
gl_compute_light_positions( ctx );
}
@@ -973,7 +826,7 @@ _mesa_update_drawbuffer( GLcontext *ctx )
static void
_mesa_update_projection( GLcontext *ctx )
{
- gl_matrix_analyze( &ctx->ProjectionMatrix );
+ _math_matrix_analyze( &ctx->ProjectionMatrix );
/* Recompute clip plane positions in clipspace. This is also done
* in _mesa_ClipPlane().
@@ -1015,7 +868,7 @@ void gl_update_state( GLcontext *ctx )
gl_print_state("", new_state);
if (new_state & _NEW_MODELVIEW)
- gl_matrix_analyze( &ctx->ModelView );
+ _math_matrix_analyze( &ctx->ModelView );
if (new_state & _NEW_PROJECTION)
_mesa_update_projection( ctx );
@@ -1024,16 +877,13 @@ void gl_update_state( GLcontext *ctx )
_mesa_update_texture_matrices( ctx );
if (new_state & _NEW_COLOR_MATRIX)
- gl_matrix_analyze( &ctx->ColorMatrix );
+ _math_matrix_analyze( &ctx->ColorMatrix );
/* References ColorMatrix.type (derived above).
*/
if (new_state & (_NEW_PIXEL|_NEW_COLOR_MATRIX))
_mesa_update_image_transfer_state(ctx);
- if (new_state & _NEW_ARRAY)
- gl_update_client_state( ctx );
-
/* Contributes to NeedEyeCoords, NeedNormals.
*/
if (new_state & _NEW_TEXTURE)
@@ -1050,12 +900,6 @@ void gl_update_state( GLcontext *ctx )
if (new_state & _NEW_LIGHT)
gl_update_lighting( ctx );
- if (new_state & (_NEW_LIGHT|_NEW_TEXTURE|_NEW_FOG|
- _DD_NEW_TRI_LIGHT_TWOSIDE |
- _DD_NEW_SEPERATE_SPECULAR |
- _DD_NEW_TRI_UNFILLED ))
- gl_update_clipmask(ctx);
-
/* We can light in object space if the modelview matrix preserves
* lengths and relative angles.
*/
@@ -1082,17 +926,13 @@ void gl_update_state( GLcontext *ctx )
_TNL_NEW_NEED_EYE_COORDS))
_mesa_update_tnl_spaces( ctx, oldneedeyecoords );
- if (new_state & ctx->Driver.UpdateStateNotify)
- {
- /*
- * Here the driver sets up all the ctx->Driver function pointers to
- * it's specific, private functions.
- */
- ctx->Driver.UpdateState(ctx);
- gl_set_render_vb_function(ctx); /* XXX: remove this mechanism */
- }
-
- gl_update_pipelines(ctx);
+ /*
+ * Here the driver sets up all the ctx->Driver function pointers
+ * to it's specific, private functions, and performs any
+ * internal state management necessary, including invalidating
+ * state of active modules.
+ */
+ ctx->Driver.UpdateState(ctx);
ctx->NewState = 0;
}
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 45a39f61620..0e33e683de1 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.21 2000/11/05 18:40:58 keithw Exp $ */
+/* $Id: texstate.c,v 1.22 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -34,13 +34,13 @@
#include "enums.h"
#include "extensions.h"
#include "macros.h"
-#include "matrix.h"
#include "texobj.h"
#include "teximage.h"
#include "texstate.h"
#include "texture.h"
#include "types.h"
-#include "xform.h"
+#include "math/m_xform.h"
+#include "math/m_matrix.h"
#include "swrast/swrast.h"
#endif
@@ -1116,7 +1116,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
else if (pname==GL_EYE_PLANE) {
/* Transform plane equation by the inverse modelview matrix */
if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
- gl_matrix_analyze( &ctx->ModelView );
+ _math_matrix_analyze( &ctx->ModelView );
}
gl_transform_vector( texUnit->EyePlaneS, params,
ctx->ModelView.inv );
@@ -1164,7 +1164,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
else if (pname==GL_EYE_PLANE) {
/* Transform plane equation by the inverse modelview matrix */
if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
- gl_matrix_analyze( &ctx->ModelView );
+ _math_matrix_analyze( &ctx->ModelView );
}
gl_transform_vector( texUnit->EyePlaneT, params,
ctx->ModelView.inv );
@@ -1208,7 +1208,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
else if (pname==GL_EYE_PLANE) {
/* Transform plane equation by the inverse modelview matrix */
if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
- gl_matrix_analyze( &ctx->ModelView );
+ _math_matrix_analyze( &ctx->ModelView );
}
gl_transform_vector( texUnit->EyePlaneR, params,
ctx->ModelView.inv );
@@ -1244,7 +1244,7 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
else if (pname==GL_EYE_PLANE) {
/* Transform plane equation by the inverse modelview matrix */
if (ctx->ModelView.flags & MAT_DIRTY_INVERSE) {
- gl_matrix_analyze( &ctx->ModelView );
+ _math_matrix_analyze( &ctx->ModelView );
}
gl_transform_vector( texUnit->EyePlaneQ, params,
ctx->ModelView.inv );
@@ -1674,18 +1674,3 @@ void gl_remove_texobj_from_dirty_list( struct gl_shared_state *shared,
}
-/*
- * This is called by gl_update_state() if the _NEW_TEXTURE bit in
- * ctx->NewState is set.
- */
-void gl_update_dirty_texobjs( GLcontext *ctx )
-{
- struct gl_texture_object *t, *next;
- for (t = ctx->Shared->DirtyTexObjList; t; t = next) {
- next = t->NextDirty;
- _mesa_test_texobj_completeness(ctx, t);
- t->NextDirty = NULL;
- t->Dirty = GL_FALSE;
- }
- ctx->Shared->DirtyTexObjList = NULL;
-}
diff --git a/src/mesa/main/texstate.h b/src/mesa/main/texstate.h
index d3111f02e3f..9954a0a126d 100644
--- a/src/mesa/main/texstate.h
+++ b/src/mesa/main/texstate.h
@@ -1,4 +1,4 @@
-/* $Id: texstate.h,v 1.2 1999/11/11 01:22:28 brianp Exp $ */
+/* $Id: texstate.h,v 1.3 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -140,8 +140,6 @@ extern void
gl_remove_texobj_from_dirty_list( struct gl_shared_state *shared,
struct gl_texture_object *tObj );
-extern void
-gl_update_dirty_texobjs( GLcontext *ctx );
#endif
diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c
index d604beb9dde..3cd368779c0 100644
--- a/src/mesa/main/varray.c
+++ b/src/mesa/main/varray.c
@@ -1,4 +1,4 @@
-/* $Id: varray.c,v 1.30 2000/11/05 18:40:59 keithw Exp $ */
+/* $Id: varray.c,v 1.31 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -29,25 +29,17 @@
#else
#include "glheader.h"
#include "context.h"
-#include "cva.h"
#include "enable.h"
#include "enums.h"
#include "dlist.h"
#include "light.h"
#include "macros.h"
#include "mmath.h"
-#include "pipeline.h"
#include "state.h"
#include "texstate.h"
-#include "translate.h"
#include "types.h"
#include "varray.h"
-#include "vb.h"
-#include "vbfill.h"
-#include "vbrender.h"
-#include "vbindirect.h"
-#include "vbxform.h"
-#include "xform.h"
+#include "math/m_translate.h"
#endif
@@ -96,9 +88,10 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
ctx->Array.Vertex.Stride = stride;
ctx->Array.Vertex.Ptr = (void *) ptr;
ctx->Array._VertexFunc = gl_trans_4f_tab[size][TYPE_IDX(type)];
- ctx->Array._VertexEltFunc = gl_trans_elt_4f_tab[size][TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_OBJ_ANY;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.VertexPointer)
+ ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
}
@@ -146,9 +139,10 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
ctx->Array.Normal.Stride = stride;
ctx->Array.Normal.Ptr = (void *) ptr;
ctx->Array._NormalFunc = gl_trans_3f_tab[TYPE_IDX(type)];
- ctx->Array._NormalEltFunc = gl_trans_elt_3f_tab[TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_NORM;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.NormalPointer)
+ ctx->Driver.NormalPointer( ctx, type, stride, ptr );
}
@@ -209,9 +203,10 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
ctx->Array.Color.Stride = stride;
ctx->Array.Color.Ptr = (void *) ptr;
ctx->Array._ColorFunc = gl_trans_4ub_tab[size][TYPE_IDX(type)];
- ctx->Array._ColorEltFunc = gl_trans_elt_4ub_tab[size][TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_RGBA;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.ColorPointer)
+ ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
}
@@ -244,9 +239,10 @@ _mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
ctx->Array.FogCoord.Stride = stride;
ctx->Array.FogCoord.Ptr = (void *) ptr;
ctx->Array._FogCoordFunc = gl_trans_1f_tab[TYPE_IDX(type)];
- ctx->Array._FogCoordEltFunc = gl_trans_elt_1f_tab[TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_FOG_COORD;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.FogCoordPointer)
+ ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
}
@@ -287,9 +283,10 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
ctx->Array.Index.Stride = stride;
ctx->Array.Index.Ptr = (void *) ptr;
ctx->Array._IndexFunc = gl_trans_1ui_tab[TYPE_IDX(type)];
- ctx->Array._IndexEltFunc = gl_trans_elt_1ui_tab[TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_INDEX;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.IndexPointer)
+ ctx->Driver.IndexPointer( ctx, type, stride, ptr );
}
@@ -350,9 +347,10 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
ctx->Array.SecondaryColor.Stride = stride;
ctx->Array.SecondaryColor.Ptr = (void *) ptr;
ctx->Array._SecondaryColorFunc = gl_trans_4ub_tab[size][TYPE_IDX(type)];
- ctx->Array._SecondaryColorEltFunc = gl_trans_elt_4ub_tab[size][TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_SPEC_RGB;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.SecondaryColorPointer)
+ ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
}
@@ -405,11 +403,11 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr
ctx->Array.TexCoord[texUnit].Type = type;
ctx->Array.TexCoord[texUnit].Stride = stride;
ctx->Array.TexCoord[texUnit].Ptr = (void *) ptr;
-
ctx->Array._TexCoordFunc[texUnit] = gl_trans_4f_tab[size][TYPE_IDX(type)];
- ctx->Array._TexCoordEltFunc[texUnit] = gl_trans_elt_4f_tab[size][TYPE_IDX(type)];
- ctx->Array._NewArrayState |= VERT_TEX_ANY(texUnit);
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.TexCoordPointer)
+ ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
}
@@ -433,9 +431,10 @@ _mesa_EdgeFlagPointer(GLsizei stride, const void *vptr)
} else {
ctx->Array._EdgeFlagFunc = 0;
}
- ctx->Array._EdgeFlagEltFunc = gl_trans_elt_1ub_tab[TYPE_IDX(GL_UNSIGNED_BYTE)];
- ctx->Array._NewArrayState |= VERT_EDGE;
ctx->NewState |= _NEW_ARRAY;
+
+ if (ctx->Driver.EdgeFlagPointer)
+ ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
}
@@ -498,620 +497,6 @@ _mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
-/* KW: Batch function to exec all the array elements in the input
- * buffer prior to transform. Done only the first time a vertex
- * buffer is executed or compiled.
- *
- * KW: Have to do this after each glEnd if cva isn't active. (also
- * have to do it after each full buffer)
- */
-void gl_exec_array_elements( GLcontext *ctx, struct immediate *IM,
- GLuint start,
- GLuint count)
-{
- GLuint *flags = IM->Flag;
- GLuint *elts = IM->Elt;
- GLuint translate = ctx->Array._Flags;
- GLuint i;
-
- if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
- fprintf(stderr, "exec_array_elements %d .. %d\n", start, count);
-
- if (translate & VERT_OBJ_ANY)
- (ctx->Array._VertexEltFunc)( IM->Obj,
- &ctx->Array.Vertex,
- flags, elts, (VERT_ELT|VERT_OBJ_ANY),
- start, count);
-
- if (translate & VERT_NORM)
- (ctx->Array._NormalEltFunc)( IM->Normal,
- &ctx->Array.Normal,
- flags, elts, (VERT_ELT|VERT_NORM),
- start, count);
-
- if (translate & VERT_EDGE)
- (ctx->Array._EdgeFlagEltFunc)( IM->EdgeFlag,
- &ctx->Array.EdgeFlag,
- flags, elts, (VERT_ELT|VERT_EDGE),
- start, count);
-
- if (translate & VERT_RGBA)
- (ctx->Array._ColorEltFunc)( IM->Color,
- &ctx->Array.Color,
- flags, elts, (VERT_ELT|VERT_RGBA),
- start, count);
-
-
- if (translate & VERT_SPEC_RGB)
- (ctx->Array._SecondaryColorEltFunc)( IM->SecondaryColor,
- &ctx->Array.SecondaryColor,
- flags, elts, (VERT_ELT|VERT_SPEC_RGB),
- start, count);
-
- if (translate & VERT_FOG_COORD)
- (ctx->Array._FogCoordEltFunc)( IM->FogCoord,
- &ctx->Array.FogCoord,
- flags, elts, (VERT_ELT|VERT_FOG_COORD),
- start, count);
-
- if (translate & VERT_INDEX)
- (ctx->Array._IndexEltFunc)( IM->Index,
- &ctx->Array.Index,
- flags, elts, (VERT_ELT|VERT_INDEX),
- start, count);
-
- if (translate & VERT_TEX0_ANY)
- (ctx->Array._TexCoordEltFunc[0])( IM->TexCoord[0],
- &ctx->Array.TexCoord[0],
- flags, elts, (VERT_ELT|VERT_TEX0_ANY),
- start, count);
-
- if (translate & VERT_TEX1_ANY)
- (ctx->Array._TexCoordEltFunc[1])( IM->TexCoord[1],
- &ctx->Array.TexCoord[1],
- flags, elts, (VERT_ELT|VERT_TEX1_ANY),
- start, count);
-
-#if MAX_TEXTURE_UNITS > 2
- if (translate & VERT_TEX2_ANY)
- (ctx->Array._TexCoordEltFunc[2])( IM->TexCoord[2],
- &ctx->Array.TexCoord[2],
- flags, elts, (VERT_ELT|VERT_TEX2_ANY),
- start, count);
-#endif
-#if MAX_TEXTURE_UNITS > 3
- if (translate & VERT_TEX3_ANY)
- (ctx->Array._TexCoordEltFunc[3])( IM->TexCoord[3],
- &ctx->Array.TexCoord[3],
- flags, elts, (VERT_ELT|VERT_TEX3_ANY),
- start, count);
-#endif
-
- for (i = start ; i < count ; i++)
- if (flags[i] & VERT_ELT)
- flags[i] |= translate;
-
-}
-
-
-
-/* Enough funny business going on in here it might be quicker to use a
- * function pointer.
- */
-#define ARRAY_ELT( IM, i ) \
-{ \
- GLuint count = IM->Count; \
- IM->Elt[count] = i; \
- IM->Flag[count] = ((IM->Flag[count] & IM->ArrayAndFlags) | \
- VERT_ELT); \
- IM->FlushElt |= IM->ArrayEltFlush; \
- IM->Count = count += IM->ArrayIncr; \
- if (count == VB_MAX) \
- _mesa_maybe_transform_vb( IM ); \
-}
-
-
-void
-_mesa_ArrayElement( GLint i )
-{
- GET_IMMEDIATE;
- ARRAY_ELT( IM, i );
-}
-
-
-static void
-gl_ArrayElement( GLcontext *CC, GLint i )
-{
- struct immediate *im = CC->input;
- ARRAY_ELT( im, i );
-}
-
-
-
-void
-_mesa_DrawArrays(GLenum mode, GLint start, GLsizei count)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct vertex_buffer *VB = ctx->VB;
- GLint i;
-
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDrawArrays");
-
- if (count<0) {
- gl_error( ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
- return;
- }
-
- if (!ctx->CompileFlag && ctx->Array.Vertex.Enabled) {
- GLint remaining = count;
- GLint i;
- struct gl_client_array *Normal;
- struct gl_client_array *Color;
- struct gl_client_array *SecondaryColor;
- struct gl_client_array *FogCoord;
- struct gl_client_array *Index;
- struct gl_client_array *TexCoord[MAX_TEXTURE_UNITS];
- struct gl_client_array *EdgeFlag;
- struct immediate *IM = VB->IM;
- struct gl_pipeline *elt = &ctx->CVA.elt;
- GLboolean relock;
- GLuint fallback, required;
-
- if (ctx->NewState)
- gl_update_state( ctx );
-
- /* Just turn off cva on this path. Could be useful for multipass
- * rendering to keep it turned on.
- */
- relock = ctx->CompileCVAFlag;
-
- if (relock) {
- ctx->CompileCVAFlag = 0;
- elt->pipeline_valid = 0;
- }
-
- if (!elt->pipeline_valid)
- gl_build_immediate_pipeline( ctx );
-
- required = elt->inputs;
- fallback = (elt->inputs & ~ctx->Array._Summary);
-
- /* The translate function doesn't do anything about size. It
- * just ensures that type and stride come out right.
- */
- IM->v.Obj.size = ctx->Array.Vertex.Size;
-
- if (required & VERT_RGBA) {
- Color = &ctx->Array.Color;
- if (fallback & VERT_RGBA) {
- Color = &ctx->Fallback.Color;
- ctx->Array._ColorFunc =
- gl_trans_4ub_tab[4][TYPE_IDX(GL_UNSIGNED_BYTE)];
- }
- }
-
- if (required & VERT_SPEC_RGB)
- {
- SecondaryColor = &ctx->Array.SecondaryColor;
- if (fallback & VERT_SPEC_RGB) {
- SecondaryColor = &ctx->Fallback.SecondaryColor;
- ctx->Array._SecondaryColorFunc =
- gl_trans_4ub_tab[4][TYPE_IDX(GL_UNSIGNED_BYTE)];
- }
- }
-
- if (required & VERT_FOG_COORD)
- {
- FogCoord = &ctx->Array.FogCoord;
- if (fallback & VERT_FOG_COORD) {
- FogCoord = &ctx->Fallback.FogCoord;
- ctx->Array._FogCoordFunc =
- gl_trans_1f_tab[TYPE_IDX(GL_FLOAT)];
- }
- }
-
- if (required & VERT_INDEX) {
- Index = &ctx->Array.Index;
- if (fallback & VERT_INDEX) {
- Index = &ctx->Fallback.Index;
- ctx->Array._IndexFunc = gl_trans_1ui_tab[TYPE_IDX(GL_UNSIGNED_INT)];
- }
- }
-
- for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++) {
- GLuint flag = VERT_TEX_ANY(i);
-
- if (required & flag) {
- TexCoord[i] = &ctx->Array.TexCoord[i];
-
- if (fallback & flag) {
- TexCoord[i] = &ctx->Fallback.TexCoord[i];
- TexCoord[i]->Size = gl_texcoord_size( ctx->Current.Flag, i );
-
- ctx->Array._TexCoordFunc[i] =
- gl_trans_4f_tab[TexCoord[i]->Size][TYPE_IDX(GL_FLOAT)];
- }
- }
- }
-
- if (ctx->Array._Flags != ctx->Array._Flag[0]) {
- for (i = 0 ; i < VB_MAX ; i++)
- ctx->Array._Flag[i] = ctx->Array._Flags;
- }
-
- if (required & VERT_NORM) {
- Normal = &ctx->Array.Normal;
- if (fallback & VERT_NORM) {
- Normal = &ctx->Fallback.Normal;
- ctx->Array._NormalFunc = gl_trans_3f_tab[TYPE_IDX(GL_FLOAT)];
- }
- }
-
- if ( required & VERT_EDGE ) {
- if (mode == GL_TRIANGLES ||
- mode == GL_QUADS ||
- mode == GL_POLYGON) {
- EdgeFlag = &ctx->Array.EdgeFlag;
- if (fallback & VERT_EDGE) {
- EdgeFlag = &ctx->Fallback.EdgeFlag;
- ctx->Array._EdgeFlagFunc =
- gl_trans_1ub_tab[TYPE_IDX(GL_UNSIGNED_BYTE)];
- }
- }
- else
- required &= ~VERT_EDGE;
- }
-
- VB->Primitive = IM->Primitive;
- VB->NextPrimitive = IM->NextPrimitive;
- VB->MaterialMask = IM->MaterialMask;
- VB->Material = IM->Material;
- VB->BoundsPtr = 0;
-
- while (remaining > 0) {
- GLint vbspace = VB_MAX - VB_START;
- GLuint count, n;
-
- if (vbspace >= remaining) {
- n = remaining;
- VB->LastPrimitive = VB_START + n;
- }
- else {
- n = vbspace;
- VB->LastPrimitive = VB_START;
- }
-
- VB->CullMode = 0;
-
- ctx->Array._VertexFunc( IM->Obj + VB_START,
- &ctx->Array.Vertex, start, n );
-
- if (required & VERT_NORM) {
- ctx->Array._NormalFunc( IM->Normal + VB_START,
- Normal, start, n );
- }
-
- if (required & VERT_EDGE) {
- ctx->Array._EdgeFlagFunc( IM->EdgeFlag + VB_START,
- EdgeFlag, start, n );
- }
-
- if (required & VERT_RGBA) {
- ctx->Array._ColorFunc( IM->Color + VB_START,
- Color, start, n );
- }
-
- if (required & VERT_SPEC_RGB) {
- ctx->Array._SecondaryColorFunc( IM->SecondaryColor + VB_START,
- SecondaryColor, start, n );
- }
-
- if (required & VERT_FOG_COORD) {
- ctx->Array._FogCoordFunc( IM->FogCoord + VB_START,
- FogCoord, start, n );
- }
-
- if (required & VERT_INDEX) {
- ctx->Array._IndexFunc( IM->Index + VB_START,
- Index, start, n );
- }
-
- if (required & VERT_TEX0_ANY) {
- IM->v.TexCoord[0].size = TexCoord[0]->Size;
- ctx->Array._TexCoordFunc[0]( IM->TexCoord[0] + VB_START,
- TexCoord[0], start, n );
- }
-
- if (required & VERT_TEX1_ANY) {
- IM->v.TexCoord[1].size = TexCoord[1]->Size;
- ctx->Array._TexCoordFunc[1]( IM->TexCoord[1] + VB_START,
- TexCoord[1], start, n );
- }
-#if MAX_TEXTURE_UNITS > 2
- if (required & VERT_TEX2_ANY) {
- IM->v.TexCoord[2].size = TexCoord[2]->Size;
- ctx->Array._TexCoordFunc[2]( IM->TexCoord[2] + VB_START,
- TexCoord[2], start, n );
- }
-#endif
-#if MAX_TEXTURE_UNITS > 3
- if (required & VERT_TEX3_ANY) {
- IM->v.TexCoord[3].size = TexCoord[3]->Size;
- ctx->Array._TexCoordFunc[3]( IM->TexCoord[3] + VB_START,
- TexCoord[3], start, n );
- }
-#endif
-
- VB->ObjPtr = &IM->v.Obj;
- VB->NormalPtr = &IM->v.Normal;
- VB->ColorPtr = &IM->v.Color;
- VB->Color[0] = VB->Color[1] = VB->ColorPtr;
- VB->IndexPtr = &IM->v.Index;
- VB->EdgeFlagPtr = &IM->v.EdgeFlag;
- VB->SecondaryColorPtr = &IM->v.SecondaryColor;
- VB->FogCoordPtr = &IM->v.FogCoord;
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- VB->TexCoordPtr[i] = &IM->v.TexCoord[i];
- }
-
- VB->Flag = ctx->Array._Flag;
- VB->OrFlag = ctx->Array._Flags;
-
- VB->Start = IM->Start = VB_START;
- count = VB->Count = IM->Count = VB_START + n;
-
-#define RESET_VEC(v, t, s, c) (v.start = t v.data[s], v.count = c)
-
- RESET_VEC(IM->v.Obj, (GLfloat *), VB_START, count);
- RESET_VEC(IM->v.Normal, (GLfloat *), VB_START, count);
- for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
- RESET_VEC(IM->v.TexCoord[i], (GLfloat *), VB_START, count);
- }
- RESET_VEC(IM->v.Index, &, VB_START, count);
- RESET_VEC(IM->v.Elt, &, VB_START, count);
- RESET_VEC(IM->v.EdgeFlag, &, VB_START, count);
- RESET_VEC(IM->v.Color, (GLubyte *), VB_START, count);
- RESET_VEC(VB->Clip, (GLfloat *), VB_START, count);
- RESET_VEC(VB->Eye, (GLfloat *), VB_START, count);
- RESET_VEC(VB->Win, (GLfloat *), VB_START, count);
- RESET_VEC(VB->BColor, (GLubyte *), VB_START, count);
- RESET_VEC(VB->BIndex, &, VB_START, count);
-
- VB->NextPrimitive[VB->CopyStart] = VB->Count;
- VB->Primitive[VB->CopyStart] = mode;
- ctx->Array._Flag[count] |= VERT_END_VB;
-
- /* Transform and render.
- */
- gl_run_pipeline( VB );
- gl_reset_vb( VB );
-
- /* Restore values:
- */
- ctx->Array._Flag[count] = ctx->Array._Flags;
- ctx->Array._Flag[VB_START] = ctx->Array._Flags;
-
- start += n;
- remaining -= n;
- }
-
- gl_reset_input( ctx );
-
- if (relock) {
- ctx->CompileCVAFlag = relock;
- elt->pipeline_valid = 0;
- }
- }
- else if (ctx->Array.Vertex.Enabled)
- {
- /* The GL_COMPILE and GL_COMPILE_AND_EXECUTE cases. These
- * could be handled by the above code, but it gets a little
- * complex. The generated list is still of good quality
- * this way.
- */
- gl_Begin( ctx, mode );
- for (i=0;i<count;i++) {
- gl_ArrayElement( ctx, start+i );
- }
- gl_End( ctx );
- }
- else
- {
- /* The degenerate case where vertices are not enabled - only
- * need to process the very final array element, as all of the
- * preceding ones would be overwritten anyway.
- */
- gl_Begin( ctx, mode );
- gl_ArrayElement( ctx, start+count );
- gl_End( ctx );
- }
-}
-
-
-
-/* KW: Exactly fakes the effects of calling glArrayElement multiple times.
- */
-#if 1
-#define DRAW_ELT(FUNC, TYPE) \
-static void FUNC( GLcontext *ctx, GLenum mode, \
- TYPE *indices, GLuint count ) \
-{ \
- GLuint i,j; \
- \
- gl_Begin( ctx, mode ); \
- \
- for (j = 0 ; j < count ; ) { \
- struct immediate *IM = ctx->input; \
- GLuint start = IM->Start; \
- GLuint nr = MIN2( VB_MAX, count - j + start ); \
- GLuint sf = IM->Flag[start]; \
- IM->FlushElt |= IM->ArrayEltFlush; \
- \
- for (i = start ; i < nr ; i++) { \
- IM->Elt[i] = (GLuint) *indices++; \
- IM->Flag[i] = VERT_ELT; \
- } \
- \
- if (j == 0) IM->Flag[start] |= sf; \
- \
- IM->Count = nr; \
- j += nr - start; \
- \
- if (j == count) \
- gl_End( ctx ); \
- _mesa_maybe_transform_vb( IM ); \
- } \
-}
-#else
-#define DRAW_ELT(FUNC, TYPE) \
-static void FUNC( GLcontext *ctx, GLenum mode, \
- TYPE *indices, GLuint count ) \
-{ \
- int i; \
- glBegin(mode); \
- for (i = 0 ; i < count ; i++) \
- glArrayElement( indices[i] ); \
- glEnd(); \
-}
-#endif
-
-
-DRAW_ELT( draw_elt_ubyte, GLubyte )
-DRAW_ELT( draw_elt_ushort, GLushort )
-DRAW_ELT( draw_elt_uint, GLuint )
-
-
-static GLuint natural_stride[0x10] =
-{
- sizeof(GLbyte), /* 0 */
- sizeof(GLubyte), /* 1 */
- sizeof(GLshort), /* 2 */
- sizeof(GLushort), /* 3 */
- sizeof(GLint), /* 4 */
- sizeof(GLuint), /* 5 */
- sizeof(GLfloat), /* 6 */
- 2 * sizeof(GLbyte), /* 7 */
- 3 * sizeof(GLbyte), /* 8 */
- 4 * sizeof(GLbyte), /* 9 */
- sizeof(GLdouble), /* a */
- 0, /* b */
- 0, /* c */
- 0, /* d */
- 0, /* e */
- 0 /* f */
-};
-
-
-void
-_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
- struct gl_cva *cva;
-
- cva = &ctx->CVA;
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glDrawElements");
-
- if (count <= 0) {
- if (count < 0)
- gl_error( ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
- return;
- }
-
- if (mode < 0 || mode > GL_POLYGON) {
- gl_error( ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
- return;
- }
-
- if (type != GL_UNSIGNED_INT && type != GL_UNSIGNED_BYTE && type != GL_UNSIGNED_SHORT)
- {
- gl_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
- return;
- }
-
- if (ctx->NewState)
- gl_update_state(ctx);
-
- if (ctx->CompileCVAFlag)
- {
- /* Treat VERT_ELT like a special client array.
- */
- ctx->Array._NewArrayState |= VERT_ELT;
- ctx->Array._Summary |= VERT_ELT;
- ctx->Array._Flags |= VERT_ELT;
-
- cva->elt_mode = mode;
- cva->elt_count = count;
- cva->Elt.Type = type;
- cva->Elt.Ptr = (void *) indices;
- cva->Elt.StrideB = natural_stride[TYPE_IDX(type)];
- cva->EltFunc = gl_trans_1ui_tab[TYPE_IDX(type)];
-
- if (!cva->pre.pipeline_valid)
- gl_build_precalc_pipeline( ctx );
- else if (MESA_VERBOSE & VERBOSE_PIPELINE)
- fprintf(stderr, ": dont rebuild\n");
-
- gl_cva_force_precalc( ctx );
-
- /* Did we 'precalculate' the render op?
- */
- if (ctx->CVA.pre.ops & PIPE_OP_RENDER) {
- ctx->Array._NewArrayState |= VERT_ELT;
- ctx->Array._Summary &= ~VERT_ELT;
- ctx->Array._Flags &= ~VERT_ELT;
- return;
- }
-
- if ( (MESA_VERBOSE&VERBOSE_VARRAY) )
- printf("using immediate\n");
- }
-
-
- /* Otherwise, have to use the immediate path to render.
- */
- switch (type) {
- case GL_UNSIGNED_BYTE:
- {
- GLubyte *ub_indices = (GLubyte *) indices;
- if (ctx->Array._Summary & VERT_OBJ_ANY) {
- draw_elt_ubyte( ctx, mode, ub_indices, count );
- } else {
- gl_ArrayElement( ctx, (GLuint) ub_indices[count-1] );
- }
- }
- break;
- case GL_UNSIGNED_SHORT:
- {
- GLushort *us_indices = (GLushort *) indices;
- if (ctx->Array._Summary & VERT_OBJ_ANY) {
- draw_elt_ushort( ctx, mode, us_indices, count );
- } else {
- gl_ArrayElement( ctx, (GLuint) us_indices[count-1] );
- }
- }
- break;
- case GL_UNSIGNED_INT:
- {
- GLuint *ui_indices = (GLuint *) indices;
- if (ctx->Array._Summary & VERT_OBJ_ANY) {
- draw_elt_uint( ctx, mode, ui_indices, count );
- } else {
- gl_ArrayElement( ctx, ui_indices[count-1] );
- }
- }
- break;
- default:
- gl_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
- break;
- }
-
- if (ctx->CompileCVAFlag) {
- ctx->Array._NewArrayState |= VERT_ELT;
- ctx->Array._Summary &= ~VERT_ELT;
- }
-}
-
-
void
_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
@@ -1307,81 +692,3 @@ _mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
-void
-_mesa_DrawRangeElements(GLenum mode, GLuint start,
- GLuint end, GLsizei count,
- GLenum type, const GLvoid *indices)
-{
- GET_CURRENT_CONTEXT(ctx);
-
- if (end < start) {
- gl_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements( end < start )");
- return;
- }
-
-#if 0
- /*
- * XXX something in locked arrays is broken! If start = 0,
- * end = 1 and count = 2 we'll take the LockArrays path and
- * get incorrect results. See Scott McMillan's bug of 3 Jan 2000.
- * For now, don't use locked arrays.
- */
- if (!ctx->Array.LockCount && 2*count > (GLint) 3*(end-start)) {
- glLockArraysEXT( start, end );
- glDrawElements( mode, count, type, indices );
- glUnlockArraysEXT();
- } else {
- glDrawElements( mode, count, type, indices );
- }
-#else
- glDrawElements( mode, count, type, indices );
-#endif
-}
-
-
-
-void gl_update_client_state( GLcontext *ctx )
-{
- static const GLuint sz_flags[5] = {
- 0,
- 0,
- VERT_OBJ_2,
- VERT_OBJ_23,
- VERT_OBJ_234
- };
- static const GLuint tc_flags[5] = {
- 0,
- VERT_TEX0_12,
- VERT_TEX0_12,
- VERT_TEX0_123,
- VERT_TEX0_1234
- };
- GLint i;
-
- ctx->Array._Flags = 0;
- ctx->Array._Summary = 0;
- ctx->input->ArrayIncr = 0;
-
- if (ctx->Array.Normal.Enabled) ctx->Array._Flags |= VERT_NORM;
- if (ctx->Array.Color.Enabled) ctx->Array._Flags |= VERT_RGBA;
- if (ctx->Array.SecondaryColor.Enabled) ctx->Array._Flags |= VERT_SPEC_RGB;
- if (ctx->Array.FogCoord.Enabled) ctx->Array._Flags |= VERT_FOG_COORD;
- if (ctx->Array.Index.Enabled) ctx->Array._Flags |= VERT_INDEX;
- if (ctx->Array.EdgeFlag.Enabled) ctx->Array._Flags |= VERT_EDGE;
- if (ctx->Array.Vertex.Enabled) {
- ctx->Array._Flags |= sz_flags[ctx->Array.Vertex.Size];
- ctx->input->ArrayIncr = 1;
- }
- for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
- if (ctx->Array.TexCoord[i].Enabled) {
- ctx->Array._Flags |= (tc_flags[ctx->Array.TexCoord[i].Size] << (i * NR_TEXSIZE_BITS));
- }
- }
-
- /* Not really important any more:
- */
- ctx->Array._Summary = ctx->Array._Flags & VERT_DATA;
- ctx->input->ArrayAndFlags = ~ctx->Array._Flags;
- ctx->input->ArrayEltFlush = !(ctx->CompileCVAFlag);
-}
-
diff --git a/src/mesa/main/varray.h b/src/mesa/main/varray.h
index 2f42dfabcbd..bc5a679094b 100644
--- a/src/mesa/main/varray.h
+++ b/src/mesa/main/varray.h
@@ -1,4 +1,4 @@
-/* $Id: varray.h,v 1.8 2000/10/27 16:44:41 keithw Exp $ */
+/* $Id: varray.h,v 1.9 2000/11/16 21:05:35 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -96,52 +96,8 @@ _mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
extern void
-_mesa_ArrayElement( GLint );
-
-
-extern void
-_mesa_DrawArrays(GLenum mode, GLint first, GLsizei count);
-
-
-extern void
-_mesa_save_DrawArrays(GLenum mode, GLint first, GLsizei count);
-
-
-extern void
-_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices);
-
-
-extern void
-_mesa_save_DrawElements(GLenum mode, GLsizei count,
- GLenum type, const GLvoid *indices);
-
-
-extern void
_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
-extern void
-_mesa_save_InterleavedArrays(GLenum format, GLsizei stride,
- const GLvoid *pointer);
-
-
-extern void
-_mesa_DrawRangeElements(GLenum mode, GLuint start,
- GLuint end, GLsizei count, GLenum type,
- const GLvoid *indices);
-
-extern void
-_mesa_save_DrawRangeElements(GLenum mode,
- GLuint start, GLuint end, GLsizei count,
- GLenum type, const GLvoid *indices );
-
-
-extern void gl_exec_array_elements( GLcontext *ctx,
- struct immediate *IM,
- GLuint start,
- GLuint end );
-
-extern void gl_update_client_state( GLcontext *ctx );
#endif