diff options
author | Keith Whitwell <keith@tungstengraphics.com> | 2002-11-19 12:01:26 +0000 |
---|---|---|
committer | Keith Whitwell <keith@tungstengraphics.com> | 2002-11-19 12:01:26 +0000 |
commit | 878e544c6b9e5b856adba30ccd027dc18f6ec88c (patch) | |
tree | f7fbb3ac0d5184fcc3f0977e3b2418feb4bdb669 | |
parent | 0a72f63fe264a625283bb6afadf30b105cae4462 (diff) |
yet another checkpoint
-rw-r--r-- | src/mesa/Makefile.X11 | 47 | ||||
-rw-r--r-- | src/mesa/main/Makefile.X11 | 47 | ||||
-rw-r--r-- | src/mesa/main/api_loopback.c | 638 | ||||
-rw-r--r-- | src/mesa/main/api_noop.c | 56 | ||||
-rw-r--r-- | src/mesa/main/attrib.c | 4 | ||||
-rw-r--r-- | src/mesa/main/context.c | 11 | ||||
-rw-r--r-- | src/mesa/main/light.c | 410 | ||||
-rw-r--r-- | src/mesa/main/light.h | 9 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 89 | ||||
-rw-r--r-- | src/mesa/main/vtxfmt.c | 176 | ||||
-rw-r--r-- | src/mesa/main/vtxfmt.h | 41 | ||||
-rw-r--r-- | src/mesa/main/vtxfmt_tmp.h | 472 | ||||
-rw-r--r-- | src/mesa/swrast_setup/ss_triangle.c | 20 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_api.c | 65 | ||||
-rw-r--r-- | src/mesa/tnl/t_array_import.c | 274 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.c | 62 | ||||
-rw-r--r-- | src/mesa/tnl/t_context.h | 169 | ||||
-rw-r--r-- | src/mesa/tnl/t_eval_api.c | 76 | ||||
-rw-r--r-- | src/mesa/tnl/t_pipeline.h | 24 | ||||
-rw-r--r-- | src/mesa/tnl/t_vb_program.c | 34 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.c | 536 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_api.h | 154 | ||||
-rw-r--r-- | src/mesa/tnl/t_vtx_exec.c | 468 |
23 files changed, 1053 insertions, 2829 deletions
diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11 index 378df24eb8..2659718244 100644 --- a/src/mesa/Makefile.X11 +++ b/src/mesa/Makefile.X11 @@ -1,4 +1,4 @@ -# $Id: Makefile.X11,v 1.69 2002/09/27 02:45:37 brianp Exp $ +# $Id: Makefile.X11,v 1.69.2.1 2002/11/19 12:01:26 keithw Exp $ # Mesa 3-D graphics library # Version: 4.1 @@ -21,6 +21,22 @@ LIBDIR = ../lib CORE_SOURCES = \ + tnl/t_array_api.c \ + tnl/t_array_import.c \ + tnl/t_context.c \ + tnl/t_eval_api.c \ + tnl/t_vtx_api.c \ + tnl/t_vtx_exec.c \ + tnl/t_pipeline.c \ + tnl/t_vb_fog.c \ + tnl/t_vb_light.c \ + tnl/t_vb_normals.c \ + tnl/t_vb_points.c \ + tnl/t_vb_program.c \ + tnl/t_vb_render.c \ + tnl/t_vb_texgen.c \ + tnl/t_vb_texmat.c \ + tnl/t_vb_vertex.c \ api_arrayelt.c \ api_loopback.c \ api_noop.c \ @@ -74,7 +90,6 @@ CORE_SOURCES = \ vpexec.c \ vpparse.c \ vpstate.c \ - vtxfmt.c \ X86/x86.c \ X86/common_x86.c \ X86/3dnow.c \ @@ -119,29 +134,7 @@ CORE_SOURCES = \ swrast/s_zoom.c \ swrast_setup/ss_context.c \ swrast_setup/ss_triangle.c \ - swrast_setup/ss_vb.c \ - tnl/t_array_api.c \ - tnl/t_array_import.c \ - tnl/t_context.c \ - tnl/t_eval_api.c \ - tnl/t_imm_alloc.c \ - tnl/t_imm_api.c \ - tnl/t_imm_debug.c \ - tnl/t_imm_dlist.c \ - tnl/t_imm_elt.c \ - tnl/t_imm_eval.c \ - tnl/t_imm_exec.c \ - tnl/t_imm_fixup.c \ - tnl/t_pipeline.c \ - tnl/t_vb_fog.c \ - tnl/t_vb_light.c \ - tnl/t_vb_normals.c \ - tnl/t_vb_points.c \ - tnl/t_vb_program.c \ - tnl/t_vb_render.c \ - tnl/t_vb_texgen.c \ - tnl/t_vb_texmat.c \ - tnl/t_vb_vertex.c + swrast_setup/ss_vb.c DRIVER_SOURCES = \ @@ -225,14 +218,14 @@ clean: targets: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(OSMESA_LIB) # Make the GL library -$(LIBDIR)/$(GL_LIB): $(OBJECTS) +$(LIBDIR)/$(GL_LIB):: $(OBJECTS) $(MAKELIB) $(GL_LIB) $(GL_MAJOR) $(GL_MINOR) $(GL_TINY) $(OBJECTS) rm -f $(LIBDIR)/$(GL_LIB)* mv $(GL_LIB)* $(LIBDIR) # Make the OSMesa library -$(LIBDIR)/$(OSMESA_LIB): $(OSMESA_OBJECTS) +$(LIBDIR)/$(OSMESA_LIB):: $(OSMESA_OBJECTS) if [ ${OSMESA_LIB} ] ; then $(MAKELIB) $(OSMESA_LIB) $(MESA_MAJOR) $(MESA_MINOR) $(GL_TINY) $(OSMESA_OBJECTS) ; fi if [ ${OSMESA_LIB} ] ; then rm -f $(LIBDIR)/$(OSMESA_LIB)* ; fi if [ ${OSMESA_LIB} ] ; then mv $(OSMESA_LIB)* $(LIBDIR) ; fi diff --git a/src/mesa/main/Makefile.X11 b/src/mesa/main/Makefile.X11 index 378df24eb8..2659718244 100644 --- a/src/mesa/main/Makefile.X11 +++ b/src/mesa/main/Makefile.X11 @@ -1,4 +1,4 @@ -# $Id: Makefile.X11,v 1.69 2002/09/27 02:45:37 brianp Exp $ +# $Id: Makefile.X11,v 1.69.2.1 2002/11/19 12:01:26 keithw Exp $ # Mesa 3-D graphics library # Version: 4.1 @@ -21,6 +21,22 @@ LIBDIR = ../lib CORE_SOURCES = \ + tnl/t_array_api.c \ + tnl/t_array_import.c \ + tnl/t_context.c \ + tnl/t_eval_api.c \ + tnl/t_vtx_api.c \ + tnl/t_vtx_exec.c \ + tnl/t_pipeline.c \ + tnl/t_vb_fog.c \ + tnl/t_vb_light.c \ + tnl/t_vb_normals.c \ + tnl/t_vb_points.c \ + tnl/t_vb_program.c \ + tnl/t_vb_render.c \ + tnl/t_vb_texgen.c \ + tnl/t_vb_texmat.c \ + tnl/t_vb_vertex.c \ api_arrayelt.c \ api_loopback.c \ api_noop.c \ @@ -74,7 +90,6 @@ CORE_SOURCES = \ vpexec.c \ vpparse.c \ vpstate.c \ - vtxfmt.c \ X86/x86.c \ X86/common_x86.c \ X86/3dnow.c \ @@ -119,29 +134,7 @@ CORE_SOURCES = \ swrast/s_zoom.c \ swrast_setup/ss_context.c \ swrast_setup/ss_triangle.c \ - swrast_setup/ss_vb.c \ - tnl/t_array_api.c \ - tnl/t_array_import.c \ - tnl/t_context.c \ - tnl/t_eval_api.c \ - tnl/t_imm_alloc.c \ - tnl/t_imm_api.c \ - tnl/t_imm_debug.c \ - tnl/t_imm_dlist.c \ - tnl/t_imm_elt.c \ - tnl/t_imm_eval.c \ - tnl/t_imm_exec.c \ - tnl/t_imm_fixup.c \ - tnl/t_pipeline.c \ - tnl/t_vb_fog.c \ - tnl/t_vb_light.c \ - tnl/t_vb_normals.c \ - tnl/t_vb_points.c \ - tnl/t_vb_program.c \ - tnl/t_vb_render.c \ - tnl/t_vb_texgen.c \ - tnl/t_vb_texmat.c \ - tnl/t_vb_vertex.c + swrast_setup/ss_vb.c DRIVER_SOURCES = \ @@ -225,14 +218,14 @@ clean: targets: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(OSMESA_LIB) # Make the GL library -$(LIBDIR)/$(GL_LIB): $(OBJECTS) +$(LIBDIR)/$(GL_LIB):: $(OBJECTS) $(MAKELIB) $(GL_LIB) $(GL_MAJOR) $(GL_MINOR) $(GL_TINY) $(OBJECTS) rm -f $(LIBDIR)/$(GL_LIB)* mv $(GL_LIB)* $(LIBDIR) # Make the OSMesa library -$(LIBDIR)/$(OSMESA_LIB): $(OSMESA_OBJECTS) +$(LIBDIR)/$(OSMESA_LIB):: $(OSMESA_OBJECTS) if [ ${OSMESA_LIB} ] ; then $(MAKELIB) $(OSMESA_LIB) $(MESA_MAJOR) $(MESA_MINOR) $(GL_TINY) $(OSMESA_OBJECTS) ; fi if [ ${OSMESA_LIB} ] ; then rm -f $(LIBDIR)/$(OSMESA_LIB)* ; fi if [ ${OSMESA_LIB} ] ; then mv $(OSMESA_LIB)* $(LIBDIR) ; fi diff --git a/src/mesa/main/api_loopback.c b/src/mesa/main/api_loopback.c index 6838f4f7c1..992dbe7f88 100644 --- a/src/mesa/main/api_loopback.c +++ b/src/mesa/main/api_loopback.c @@ -1,4 +1,4 @@ -/* $Id: api_loopback.c,v 1.15 2002/01/14 16:06:35 brianp Exp $ */ +/* $Id: api_loopback.c,v 1.15.2.1 2002/11/19 12:01:26 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -36,16 +36,16 @@ #include "api_loopback.h" /* KW: A set of functions to convert unusual Color/Normal/Vertex/etc - * calls to a smaller set of driver-provided formats. Currently just - * go back to dispatch to find these (eg. call glNormal3f directly), - * hence 'loopback'. + * calls to a smaller set of common formats. Currently just go back + * to dispatch to find these (eg. call glNormal3f directly), hence + * 'loopback'. * * The driver must supply all of the remaining entry points, which are - * listed in dd.h. The easiest way for a driver to do this is to + * listed below. The easiest way for a driver to do this is to * install the supplied software t&l module. */ -#define COLORUBV(v) glColor4ubv(v) -#define COLORF(r,g,b,a) glColor4f(r,g,b,a) +#define COLOR3(r,g,b) glColor3f(r,g,b) +#define COLOR4(r,g,b,a) glColor4f(r,g,b,a) #define VERTEX2(x,y) glVertex2f(x,y) #define VERTEX3(x,y,z) glVertex3f(x,y,z) #define VERTEX4(x,y,z,w) glVertex4f(x,y,z,w) @@ -63,379 +63,96 @@ #define EVALCOORD2(x,y) glEvalCoord2f(x,y) #define MATERIALFV(a,b,c) glMaterialfv(a,b,c) #define RECTF(a,b,c,d) glRectf(a,b,c,d) - -#define ATTRIB(index, x, y, z, w) _glapi_Dispatch->VertexAttrib4fNV(index, x, y, z, w) - - +#define ATTRIB1(i, x) _glapi_Dispatch->VertexAttrib1fNV(i,x) +#define ATTRIB2(i, x, y) _glapi_Dispatch->VertexAttrib2fNV(i,x,y) +#define ATTRIB3(i, x, y, z) _glapi_Dispatch->VertexAttrib3fNV(i,x,y,z) +#define ATTRIB4(i, x, y, z, w) _glapi_Dispatch->VertexAttrib4fNV(i,x,y,z,w) #define FOGCOORDF(x) _glapi_Dispatch->FogCoordfEXT(x) -#define SECONDARYCOLORUB(a,b,c) _glapi_Dispatch->SecondaryColor3ubEXT(a,b,c) #define SECONDARYCOLORF(a,b,c) _glapi_Dispatch->SecondaryColor3fEXT(a,b,c) static void -loopback_Color3b( GLbyte red, GLbyte green, GLbyte blue ) -{ - GLubyte col[4]; - col[0] = BYTE_TO_UBYTE(red); - col[1] = BYTE_TO_UBYTE(green); - col[2] = BYTE_TO_UBYTE(blue); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3d( GLdouble red, GLdouble green, GLdouble blue ) -{ - GLubyte col[4]; - GLfloat r = (GLfloat) red; - GLfloat g = (GLfloat) green; - GLfloat b = (GLfloat) blue; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); - col[3] = 255; - COLORUBV( col ); -} - -static void -loopback_Color3i( GLint red, GLint green, GLint blue ) -{ - GLubyte col[4]; - col[0] = INT_TO_UBYTE(red); - col[1] = INT_TO_UBYTE(green); - col[2] = INT_TO_UBYTE(blue); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3s( GLshort red, GLshort green, GLshort blue ) -{ - GLubyte col[4]; - col[0] = SHORT_TO_UBYTE(red); - col[1] = SHORT_TO_UBYTE(green); - col[2] = SHORT_TO_UBYTE(blue); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3ui( GLuint red, GLuint green, GLuint blue ) -{ - GLubyte col[4]; - col[0] = UINT_TO_UBYTE(red); - col[1] = UINT_TO_UBYTE(green); - col[2] = UINT_TO_UBYTE(blue); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3us( GLushort red, GLushort green, GLushort blue ) -{ - GLubyte col[4]; - col[0] = USHORT_TO_UBYTE(red); - col[1] = USHORT_TO_UBYTE(green); - col[2] = USHORT_TO_UBYTE(blue); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color4b( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) -{ - GLubyte col[4]; - col[0] = BYTE_TO_UBYTE(red); - col[1] = BYTE_TO_UBYTE(green); - col[2] = BYTE_TO_UBYTE(blue); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color4d( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) -{ - GLubyte col[4]; - GLfloat r = (GLfloat) red; - GLfloat g = (GLfloat) green; - GLfloat b = (GLfloat) blue; - GLfloat a = (GLfloat) alpha; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); - UNCLAMPED_FLOAT_TO_UBYTE(col[3], a); - COLORUBV( col ); -} - -static void -loopback_Color4i( GLint red, GLint green, GLint blue, GLint alpha ) -{ - GLubyte col[4]; - col[0] = INT_TO_UBYTE(red); - col[1] = INT_TO_UBYTE(green); - col[2] = INT_TO_UBYTE(blue); - col[3] = INT_TO_UBYTE(alpha); - COLORUBV(col); -} - -static void -loopback_Color4s( GLshort red, GLshort green, GLshort blue, - GLshort alpha ) -{ - GLubyte col[4]; - col[0] = SHORT_TO_UBYTE(red); - col[1] = SHORT_TO_UBYTE(green); - col[2] = SHORT_TO_UBYTE(blue); - col[3] = SHORT_TO_UBYTE(alpha); - COLORUBV(col); -} - -static void -loopback_Color4ui( GLuint red, GLuint green, GLuint blue, GLuint alpha ) -{ - GLubyte col[4]; - col[0] = UINT_TO_UBYTE(red); - col[1] = UINT_TO_UBYTE(green); - col[2] = UINT_TO_UBYTE(blue); - col[3] = UINT_TO_UBYTE(alpha); - COLORUBV(col); -} - -static void -loopback_Color4us( GLushort red, GLushort green, GLushort blue, - GLushort alpha ) -{ - GLubyte col[4]; - col[0] = USHORT_TO_UBYTE(red); - col[1] = USHORT_TO_UBYTE(green); - col[2] = USHORT_TO_UBYTE(blue); - col[3] = USHORT_TO_UBYTE(alpha); - COLORUBV(col); -} - -static void -loopback_Color3bv( const GLbyte *v ) -{ - GLubyte col[4]; - col[0] = BYTE_TO_UBYTE(v[0]); - col[1] = BYTE_TO_UBYTE(v[1]); - col[2] = BYTE_TO_UBYTE(v[2]); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3dv( const GLdouble *v ) -{ - GLubyte col[4]; - GLfloat r = (GLfloat) v[0]; - GLfloat g = (GLfloat) v[1]; - GLfloat b = (GLfloat) v[2]; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); - col[3] = 255; - COLORUBV( col ); -} - -static void -loopback_Color3iv( const GLint *v ) -{ - GLubyte col[4]; - col[0] = INT_TO_UBYTE(v[0]); - col[1] = INT_TO_UBYTE(v[1]); - col[2] = INT_TO_UBYTE(v[2]); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3sv( const GLshort *v ) -{ - GLubyte col[4]; - col[0] = SHORT_TO_UBYTE(v[0]); - col[1] = SHORT_TO_UBYTE(v[1]); - col[2] = SHORT_TO_UBYTE(v[2]); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3uiv( const GLuint *v ) -{ - GLubyte col[4]; - col[0] = UINT_TO_UBYTE(v[0]); - col[1] = UINT_TO_UBYTE(v[1]); - col[2] = UINT_TO_UBYTE(v[2]); - col[3] = 255; - COLORUBV(col); -} - -static void -loopback_Color3usv( const GLushort *v ) -{ - GLubyte col[4]; - col[0] = USHORT_TO_UBYTE(v[0]); - col[1] = USHORT_TO_UBYTE(v[1]); - col[2] = USHORT_TO_UBYTE(v[2]); - col[3] = 255; - COLORUBV(col); - -} - -static void -loopback_Color4bv( const GLbyte *v ) -{ - GLubyte col[4]; - col[0] = BYTE_TO_UBYTE(v[0]); - col[1] = BYTE_TO_UBYTE(v[1]); - col[2] = BYTE_TO_UBYTE(v[2]); - col[3] = BYTE_TO_UBYTE(v[3]); - COLORUBV(col); -} - -static void -loopback_Color4dv( const GLdouble *v ) -{ - GLubyte col[4]; - GLfloat r = (GLfloat) v[0]; - GLfloat g = (GLfloat) v[1]; - GLfloat b = (GLfloat) v[2]; - GLfloat a = (GLfloat) v[3]; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); - UNCLAMPED_FLOAT_TO_UBYTE(col[3], a); - COLORUBV( col ); -} - -static void -loopback_Color4iv( const GLint *v ) -{ - GLubyte col[4]; - col[0] = INT_TO_UBYTE(v[0]); - col[1] = INT_TO_UBYTE(v[1]); - col[2] = INT_TO_UBYTE(v[2]); - col[3] = INT_TO_UBYTE(v[3]); - COLORUBV(col); -} - -static void -loopback_Color4sv( const GLshort *v) -{ - GLubyte col[4]; - col[0] = SHORT_TO_UBYTE(v[0]); - col[1] = SHORT_TO_UBYTE(v[1]); - col[2] = SHORT_TO_UBYTE(v[2]); - col[3] = SHORT_TO_UBYTE(v[3]); - COLORUBV(col); -} - -static void -loopback_Color4uiv( const GLuint *v) -{ - GLubyte col[4]; - col[0] = UINT_TO_UBYTE(v[0]); - col[1] = UINT_TO_UBYTE(v[1]); - col[2] = UINT_TO_UBYTE(v[2]); - col[3] = UINT_TO_UBYTE(v[3]); - COLORUBV(col); -} - -static void -loopback_Color4usv( const GLushort *v) -{ - GLubyte col[4]; - col[0] = USHORT_TO_UBYTE(v[0]); - col[1] = USHORT_TO_UBYTE(v[1]); - col[2] = USHORT_TO_UBYTE(v[2]); - col[3] = USHORT_TO_UBYTE(v[3]); - COLORUBV(col); -} - -static void loopback_Color3b_f( GLbyte red, GLbyte green, GLbyte blue ) { - COLORF( BYTE_TO_FLOAT(red), + COLOR3( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), - BYTE_TO_FLOAT(blue), - 1.0 ); + BYTE_TO_FLOAT(blue)); } static void loopback_Color3d_f( GLdouble red, GLdouble green, GLdouble blue ) { - COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, 1.0 ); + COLOR3( (GLfloat) red, (GLfloat) green, (GLfloat) blue ); } static void loopback_Color3i_f( GLint red, GLint green, GLint blue ) { - COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), - INT_TO_FLOAT(blue), 1.0); + COLOR3( INT_TO_FLOAT(red), INT_TO_FLOAT(green), + INT_TO_FLOAT(blue)); } static void loopback_Color3s_f( GLshort red, GLshort green, GLshort blue ) { - COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), - SHORT_TO_FLOAT(blue), 1.0); + COLOR3( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), + SHORT_TO_FLOAT(blue)); } static void loopback_Color3ui_f( GLuint red, GLuint green, GLuint blue ) { - COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), - UINT_TO_FLOAT(blue), 1.0 ); + COLOR3( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), + UINT_TO_FLOAT(blue) ); } static void loopback_Color3us_f( GLushort red, GLushort green, GLushort blue ) { - COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), - USHORT_TO_FLOAT(blue), 1.0 ); + COLOR3( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), + USHORT_TO_FLOAT(blue) ); } static void loopback_Color3bv_f( const GLbyte *v ) { - COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), - BYTE_TO_FLOAT(v[2]), 1.0 ); + COLOR3( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + BYTE_TO_FLOAT(v[2]) ); } static void loopback_Color3dv_f( const GLdouble *v ) { - COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0 ); + COLOR3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] ); } static void loopback_Color3iv_f( const GLint *v ) { - COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), - INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) ); + COLOR3( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + INT_TO_FLOAT(v[2]) ); } static void loopback_Color3sv_f( const GLshort *v ) { - COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), - SHORT_TO_FLOAT(v[2]), 1.0 ); + COLOR3( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + SHORT_TO_FLOAT(v[2]) ); } static void loopback_Color3uiv_f( const GLuint *v ) { - COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), - UINT_TO_FLOAT(v[2]), 1.0 ); + COLOR3( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + UINT_TO_FLOAT(v[2]) ); } static void loopback_Color3usv_f( const GLushort *v ) { - COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), - USHORT_TO_FLOAT(v[2]), 1.0 ); + COLOR3( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + USHORT_TO_FLOAT(v[2]) ); } @@ -443,7 +160,7 @@ static void loopback_Color4b_f( GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha ) { - COLORF( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), + COLOR4( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green), BYTE_TO_FLOAT(blue), BYTE_TO_FLOAT(alpha) ); } @@ -451,13 +168,13 @@ static void loopback_Color4d_f( GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha ) { - COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, (GLfloat) alpha ); + COLOR4( (GLfloat) red, (GLfloat) green, (GLfloat) blue, (GLfloat) alpha ); } static void loopback_Color4i_f( GLint red, GLint green, GLint blue, GLint alpha ) { - COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green), + COLOR4( INT_TO_FLOAT(red), INT_TO_FLOAT(green), INT_TO_FLOAT(blue), INT_TO_FLOAT(alpha) ); } @@ -465,21 +182,28 @@ static void loopback_Color4s_f( GLshort red, GLshort green, GLshort blue, GLshort alpha ) { - COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), + COLOR4( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green), SHORT_TO_FLOAT(blue), SHORT_TO_FLOAT(alpha) ); } static void +loopback_Color4ub_f( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) +{ + COLOR4( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue), UBYTE_TO_FLOAT(alpha) ); +} + +static void loopback_Color4ui_f( GLuint red, GLuint green, GLuint blue, GLuint alpha ) { - COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), + COLOR4( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green), UINT_TO_FLOAT(blue), UINT_TO_FLOAT(alpha) ); } static void loopback_Color4us_f( GLushort red, GLushort green, GLushort blue, GLushort alpha ) { - COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), + COLOR4( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green), USHORT_TO_FLOAT(blue), USHORT_TO_FLOAT(alpha) ); } @@ -487,7 +211,7 @@ loopback_Color4us_f( GLushort red, GLushort green, GLushort blue, GLushort alpha static void loopback_Color4iv_f( const GLint *v ) { - COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), + COLOR4( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) ); } @@ -495,36 +219,43 @@ loopback_Color4iv_f( const GLint *v ) static void loopback_Color4bv_f( const GLbyte *v ) { - COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), + COLOR4( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]) ); } static void loopback_Color4dv_f( const GLdouble *v ) { - COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3] ); + COLOR4( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3] ); } static void loopback_Color4sv_f( const GLshort *v) { - COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), + COLOR4( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]) ); } static void +loopback_Color4uiv_f( const GLubyte *v) +{ + COLOR4( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]) ); +} + +static void loopback_Color4uiv_f( const GLuint *v) { - COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), + COLOR4( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]), UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]) ); } static void loopback_Color4usv_f( const GLushort *v) { - COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), + COLOR4( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]), USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]) ); } @@ -1172,114 +903,6 @@ loopback_Rectsv(const GLshort *v1, const GLshort *v2) } static void -loopback_SecondaryColor3bEXT( GLbyte red, GLbyte green, GLbyte blue ) -{ - SECONDARYCOLORUB( BYTE_TO_UBYTE(red), - BYTE_TO_UBYTE(green), - BYTE_TO_UBYTE(blue) ); -} - -static void -loopback_SecondaryColor3dEXT( GLdouble red, GLdouble green, GLdouble blue ) -{ - GLubyte col[3]; - GLfloat r = (GLfloat) red; - GLfloat g = (GLfloat) green; - GLfloat b = (GLfloat) blue; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); - SECONDARYCOLORUB( col[0], col[1], col[2] ); -} - -static void -loopback_SecondaryColor3iEXT( GLint red, GLint green, GLint blue ) -{ - SECONDARYCOLORUB( INT_TO_UBYTE(red), - INT_TO_UBYTE(green), - INT_TO_UBYTE(blue)); -} - -static void -loopback_SecondaryColor3sEXT( GLshort red, GLshort green, GLshort blue ) -{ - SECONDARYCOLORUB(SHORT_TO_UBYTE(red), - SHORT_TO_UBYTE(green), - SHORT_TO_UBYTE(blue)); -} - -static void -loopback_SecondaryColor3uiEXT( GLuint red, GLuint green, GLuint blue ) -{ - SECONDARYCOLORUB(UINT_TO_UBYTE(red), - UINT_TO_UBYTE(green), - UINT_TO_UBYTE(blue)); -} - -static void -loopback_SecondaryColor3usEXT( GLushort red, GLushort green, GLushort blue ) -{ - SECONDARYCOLORUB(USHORT_TO_UBYTE(red), - USHORT_TO_UBYTE(green), - USHORT_TO_UBYTE(blue)); -} - -static void -loopback_SecondaryColor3bvEXT( const GLbyte *v ) -{ - const GLfloat a = BYTE_TO_FLOAT(v[0]); - const GLfloat b = BYTE_TO_FLOAT(v[1]); - const GLfloat c = BYTE_TO_FLOAT(v[2]); - SECONDARYCOLORF(a,b,c); -} - -static void -loopback_SecondaryColor3dvEXT( const GLdouble *v ) -{ - GLubyte col[3]; - GLfloat r = (GLfloat) v[0]; - GLfloat g = (GLfloat) v[1]; - GLfloat b = (GLfloat) v[2]; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], r); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], g); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], b); - SECONDARYCOLORUB( col[0], col[1], col[2] ); -} - -static void -loopback_SecondaryColor3ivEXT( const GLint *v ) -{ - SECONDARYCOLORUB(INT_TO_UBYTE(v[0]), - INT_TO_UBYTE(v[1]), - INT_TO_UBYTE(v[2])); -} - -static void -loopback_SecondaryColor3svEXT( const GLshort *v ) -{ - SECONDARYCOLORUB(SHORT_TO_UBYTE(v[0]), - SHORT_TO_UBYTE(v[1]), - SHORT_TO_UBYTE(v[2])); -} - -static void -loopback_SecondaryColor3uivEXT( const GLuint *v ) -{ - SECONDARYCOLORUB(UINT_TO_UBYTE(v[0]), - UINT_TO_UBYTE(v[1]), - UINT_TO_UBYTE(v[2])); -} - -static void -loopback_SecondaryColor3usvEXT( const GLushort *v ) -{ - SECONDARYCOLORUB(USHORT_TO_UBYTE(v[0]), - USHORT_TO_UBYTE(v[1]), - USHORT_TO_UBYTE(v[2])); -} - - -static void loopback_SecondaryColor3bEXT_f( GLbyte red, GLbyte green, GLbyte blue ) { SECONDARYCOLORF( BYTE_TO_FLOAT(red), @@ -1310,6 +933,14 @@ loopback_SecondaryColor3sEXT_f( GLshort red, GLshort green, GLshort blue ) } static void +loopback_SecondaryColor3ubEXT_f( GLubyte red, GLubyte green, GLubyte blue ) +{ + SECONDARYCOLORF(UBYTE_TO_FLOAT(red), + UBYTE_TO_FLOAT(green), + UBYTE_TO_FLOAT(blue)); +} + +static void loopback_SecondaryColor3uiEXT_f( GLuint red, GLuint green, GLuint blue ) { SECONDARYCOLORF(UINT_TO_FLOAT(red), @@ -1355,6 +986,14 @@ loopback_SecondaryColor3svEXT_f( const GLshort *v ) } static void +loopback_SecondaryColor3ubvEXT_f( const GLubyte *v ) +{ + SECONDARYCOLORF(UBYTE_TO_FLOAT(v[0]), + UBYTE_TO_FLOAT(v[1]), + UBYTE_TO_FLOAT(v[2])); +} + +static void loopback_SecondaryColor3uivEXT_f( const GLuint *v ) { SECONDARYCOLORF(UINT_TO_FLOAT(v[0]), @@ -1634,92 +1273,8 @@ loopback_VertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) -void -_mesa_loopback_prefer_float( struct _glapi_table *dest, - GLboolean prefer_float_colors ) -{ - if (!prefer_float_colors) { - dest->Color3b = loopback_Color3b; - dest->Color3d = loopback_Color3d; - dest->Color3i = loopback_Color3i; - dest->Color3s = loopback_Color3s; - dest->Color3ui = loopback_Color3ui; - dest->Color3us = loopback_Color3us; - dest->Color4b = loopback_Color4b; - dest->Color4d = loopback_Color4d; - dest->Color4i = loopback_Color4i; - dest->Color4s = loopback_Color4s; - dest->Color4ui = loopback_Color4ui; - dest->Color4us = loopback_Color4us; - dest->Color3bv = loopback_Color3bv; - dest->Color3dv = loopback_Color3dv; - dest->Color3iv = loopback_Color3iv; - dest->Color3sv = loopback_Color3sv; - dest->Color3uiv = loopback_Color3uiv; - dest->Color3usv = loopback_Color3usv; - dest->Color4bv = loopback_Color4bv; - dest->Color4dv = loopback_Color4dv; - dest->Color4iv = loopback_Color4iv; - dest->Color4sv = loopback_Color4sv; - dest->Color4uiv = loopback_Color4uiv; - dest->Color4usv = loopback_Color4usv; - dest->SecondaryColor3bEXT = loopback_SecondaryColor3bEXT; - dest->SecondaryColor3dEXT = loopback_SecondaryColor3dEXT; - dest->SecondaryColor3iEXT = loopback_SecondaryColor3iEXT; - dest->SecondaryColor3sEXT = loopback_SecondaryColor3sEXT; - dest->SecondaryColor3uiEXT = loopback_SecondaryColor3uiEXT; - dest->SecondaryColor3usEXT = loopback_SecondaryColor3usEXT; - dest->SecondaryColor3bvEXT = loopback_SecondaryColor3bvEXT; - dest->SecondaryColor3dvEXT = loopback_SecondaryColor3dvEXT; - dest->SecondaryColor3ivEXT = loopback_SecondaryColor3ivEXT; - dest->SecondaryColor3svEXT = loopback_SecondaryColor3svEXT; - dest->SecondaryColor3uivEXT = loopback_SecondaryColor3uivEXT; - dest->SecondaryColor3usvEXT = loopback_SecondaryColor3usvEXT; - } - else { - dest->Color3b = loopback_Color3b_f; - dest->Color3d = loopback_Color3d_f; - dest->Color3i = loopback_Color3i_f; - dest->Color3s = loopback_Color3s_f; - dest->Color3ui = loopback_Color3ui_f; - dest->Color3us = loopback_Color3us_f; - dest->Color4b = loopback_Color4b_f; - dest->Color4d = loopback_Color4d_f; - dest->Color4i = loopback_Color4i_f; - dest->Color4s = loopback_Color4s_f; - dest->Color4ui = loopback_Color4ui_f; - dest->Color4us = loopback_Color4us_f; - dest->Color3bv = loopback_Color3bv_f; - dest->Color3dv = loopback_Color3dv_f; - dest->Color3iv = loopback_Color3iv_f; - dest->Color3sv = loopback_Color3sv_f; - dest->Color3uiv = loopback_Color3uiv_f; - dest->Color3usv = loopback_Color3usv_f; - dest->Color4bv = loopback_Color4bv_f; - dest->Color4dv = loopback_Color4dv_f; - dest->Color4iv = loopback_Color4iv_f; - dest->Color4sv = loopback_Color4sv_f; - dest->Color4uiv = loopback_Color4uiv_f; - dest->Color4usv = loopback_Color4usv_f; - dest->SecondaryColor3bEXT = loopback_SecondaryColor3bEXT_f; - dest->SecondaryColor3dEXT = loopback_SecondaryColor3dEXT_f; - dest->SecondaryColor3iEXT = loopback_SecondaryColor3iEXT_f; - dest->SecondaryColor3sEXT = loopback_SecondaryColor3sEXT_f; - dest->SecondaryColor3uiEXT = loopback_SecondaryColor3uiEXT_f; - dest->SecondaryColor3usEXT = loopback_SecondaryColor3usEXT_f; - dest->SecondaryColor3bvEXT = loopback_SecondaryColor3bvEXT_f; - dest->SecondaryColor3dvEXT = loopback_SecondaryColor3dvEXT_f; - dest->SecondaryColor3ivEXT = loopback_SecondaryColor3ivEXT_f; - dest->SecondaryColor3svEXT = loopback_SecondaryColor3svEXT_f; - dest->SecondaryColor3uivEXT = loopback_SecondaryColor3uivEXT_f; - dest->SecondaryColor3usvEXT = loopback_SecondaryColor3usvEXT_f; - } -} -/* Passing prefer_float_colors as true will mean that all colors - * *except* Color{34}ub{v} are passed as floats. Setting it false will - * mean all colors *except* Color{34}f{v} are passed as ubytes. - * +/* * This code never registers handlers for any of the entry points * listed in vtxfmt.h. */ @@ -1727,7 +1282,46 @@ void _mesa_loopback_init_api_table( struct _glapi_table *dest, GLboolean prefer_float_colors ) { - _mesa_loopback_prefer_float( dest, prefer_float_colors ); + dest->Color3b = loopback_Color3b_f; + dest->Color3d = loopback_Color3d_f; + dest->Color3i = loopback_Color3i_f; + dest->Color3s = loopback_Color3s_f; + dest->Color3ui = loopback_Color3ui_f; + dest->Color3us = loopback_Color3us_f; + dest->Color4b = loopback_Color4b_f; + dest->Color4d = loopback_Color4d_f; + dest->Color4i = loopback_Color4i_f; + dest->Color4s = loopback_Color4s_f; + dest->Color4ub = loopback_Color4ub_f; + dest->Color4ui = loopback_Color4ui_f; + dest->Color4us = loopback_Color4us_f; + dest->Color3bv = loopback_Color3bv_f; + dest->Color3dv = loopback_Color3dv_f; + dest->Color3iv = loopback_Color3iv_f; + dest->Color3sv = loopback_Color3sv_f; + dest->Color3uiv = loopback_Color3uiv_f; + dest->Color3usv = loopback_Color3usv_f; + dest->Color4bv = loopback_Color4bv_f; + dest->Color4dv = loopback_Color4dv_f; + dest->Color4iv = loopback_Color4iv_f; + dest->Color4sv = loopback_Color4sv_f; + dest->Color4ubv = loopback_Color4ubv_f; + dest->Color4uiv = loopback_Color4uiv_f; + dest->Color4usv = loopback_Color4usv_f; + dest->SecondaryColor3bEXT = loopback_SecondaryColor3bEXT_f; + dest->SecondaryColor3dEXT = loopback_SecondaryColor3dEXT_f; + dest->SecondaryColor3iEXT = loopback_SecondaryColor3iEXT_f; + dest->SecondaryColor3sEXT = loopback_SecondaryColor3sEXT_f; + dest->SecondaryColor3ubEXT = loopback_SecondaryColor3ubEXT_f; + dest->SecondaryColor3uiEXT = loopback_SecondaryColor3uiEXT_f; + dest->SecondaryColor3usEXT = loopback_SecondaryColor3usEXT_f; + dest->SecondaryColor3bvEXT = loopback_SecondaryColor3bvEXT_f; + dest->SecondaryColor3dvEXT = loopback_SecondaryColor3dvEXT_f; + dest->SecondaryColor3ivEXT = loopback_SecondaryColor3ivEXT_f; + dest->SecondaryColor3svEXT = loopback_SecondaryColor3svEXT_f; + dest->SecondaryColor3ubvEXT = loopback_SecondaryColor3ubvEXT_f; + dest->SecondaryColor3uivEXT = loopback_SecondaryColor3uivEXT_f; + dest->SecondaryColor3usvEXT = loopback_SecondaryColor3usvEXT_f; dest->Indexd = loopback_Indexd; dest->Indexf = loopback_Indexf; diff --git a/src/mesa/main/api_noop.c b/src/mesa/main/api_noop.c index a44322749e..1f56015dfc 100644 --- a/src/mesa/main/api_noop.c +++ b/src/mesa/main/api_noop.c @@ -1,4 +1,4 @@ -/* $Id: api_noop.c,v 1.10 2002/04/09 16:56:50 keithw Exp $ */ +/* $Id: api_noop.c,v 1.10.2.1 2002/11/19 12:01:26 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -100,56 +100,22 @@ void _mesa_noop_Normal3fv( const GLfloat *v ) void _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); - struct gl_material mat[2]; + int i; + struct gl_material *mat = &ctx->Light.Material; GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, "_mesa_noop_Materialfv" ); + + if (ctx->Light.ColorMaterialEnabled) + bitmask &= ~ctx->Light.ColorMaterialBitmask; + if (bitmask == 0) return; - 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]; - } + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<<i)) + COPY_4FV( mat->Attrib[i], color ); - _mesa_update_material( ctx, mat, bitmask ); + _mesa_update_material( ctx, bitmask ); } void _mesa_noop_Color4ub( GLubyte a, GLubyte b, GLubyte c, GLubyte d ) diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 5c02a6c41e..1310a58b95 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1,4 +1,4 @@ -/* $Id: attrib.c,v 1.73 2002/10/11 21:42:08 brianp Exp $ */ +/* $Id: attrib.c,v 1.73.2.1 2002/11/19 12:01:27 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -943,7 +943,7 @@ _mesa_PopAttrib(void) (GLfloat) light->Model.ColorControl); /* materials */ MEMCPY(ctx->Light.Material, light->Material, - 2 * sizeof(struct gl_material)); + sizeof(struct gl_material)); /* shade model */ _mesa_ShadeModel(light->ShadeModel); /* color material */ diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index e9c82c91be..15966e2d20 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1,4 +1,4 @@ -/* $Id: context.c,v 1.183 2002/10/11 17:41:03 brianp Exp $ */ +/* $Id: context.c,v 1.183.2.1 2002/11/19 12:01:27 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -53,7 +53,6 @@ #include "mtypes.h" #include "varray.h" #include "vpstate.h" -#include "vtxfmt.h" #include "math/m_translate.h" #include "math/m_matrix.h" #include "math/m_xform.h" @@ -1145,8 +1144,7 @@ init_attrib_groups( GLcontext *ctx ) make_empty_list( &ctx->Light.EnabledList ); init_lightmodel( &ctx->Light.Model ); - init_material( &ctx->Light.Material[0] ); - init_material( &ctx->Light.Material[1] ); + init_material( &ctx->Light.Material ); ctx->Light.ShadeModel = GL_SMOOTH; ctx->Light.Enabled = GL_FALSE; ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK; @@ -1854,11 +1852,6 @@ _mesa_initialize_context( GLcontext *ctx, ctx->ExecPrefersFloat = GL_FALSE; ctx->SavePrefersFloat = GL_FALSE; - /* Neutral tnl module stuff */ - _mesa_init_exec_vtxfmt( ctx ); - ctx->TnlModule.Current = NULL; - ctx->TnlModule.SwapCount = 0; - /* Z buffer stuff */ if (ctx->Visual.depthBits == 0) { /* Special case. Even if we don't have a depth buffer we need diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index ebddab0d28..51579d5f8e 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -1,4 +1,4 @@ -/* $Id: light.c,v 1.52 2002/09/16 17:56:02 brianp Exp $ */ +/* $Id: light.c,v 1.52.2.1 2002/11/19 12:01:27 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -499,123 +499,65 @@ _mesa_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname, { GLuint bitmask = 0; - /* Make a bitmask indicating what material attribute(s) we're updating */ switch (pname) { case GL_EMISSION: - bitmask |= FRONT_EMISSION_BIT | BACK_EMISSION_BIT; + bitmask |= MAT_BIT_FRONT_EMISSION; break; case GL_AMBIENT: - bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT; + bitmask |= MAT_BIT_FRONT_AMBIENT; break; case GL_DIFFUSE: - bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT; + bitmask |= MAT_BIT_FRONT_DIFFUSE; break; case GL_SPECULAR: - bitmask |= FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT; + bitmask |= MAT_BIT_FRONT_SPECULAR; break; case GL_SHININESS: - bitmask |= FRONT_SHININESS_BIT | BACK_SHININESS_BIT; + bitmask |= MAT_BIT_FRONT_SHININESS; break; case GL_AMBIENT_AND_DIFFUSE: - bitmask |= FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT; - bitmask |= FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT; + bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_FRONT_DIFFUSE; break; case GL_COLOR_INDEXES: - bitmask |= FRONT_INDEXES_BIT | BACK_INDEXES_BIT; + bitmask |= MAT_BIT_FRONT_INDEXES; break; default: _mesa_error( ctx, GL_INVALID_ENUM, where ); return 0; } - if (face==GL_FRONT) { - bitmask &= FRONT_MATERIAL_BITS; - } - else if (face==GL_BACK) { - bitmask &= BACK_MATERIAL_BITS; - } - else if (face != GL_FRONT_AND_BACK) { - _mesa_error( ctx, GL_INVALID_ENUM, where ); - return 0; - } - - if (bitmask & ~legal) { + switch (face) { + case GL_FRONT: + return bitmask; + case GL_BACK: + return bitmask << 7; + case GL_FRONT_AND_BACK: + return bitmask | (bitmask << 7); + default: _mesa_error( ctx, GL_INVALID_ENUM, where ); return 0; } - - return bitmask; } -/* Perform a straight copy between pairs of materials. +/* Perform a straight copy between materials. */ -void _mesa_copy_material_pairs( struct gl_material dst[2], - const struct gl_material src[2], - GLuint bitmask ) +void _mesa_copy_materials( struct gl_material *dst, + const struct gl_material *src, + GLuint bitmask ) { - if (bitmask & FRONT_EMISSION_BIT) { - COPY_4FV( dst[0].Emission, src[0].Emission ); - } - if (bitmask & BACK_EMISSION_BIT) { - COPY_4FV( dst[1].Emission, src[1].Emission ); - } - if (bitmask & FRONT_AMBIENT_BIT) { - COPY_4FV( dst[0].Ambient, src[0].Ambient ); - } - if (bitmask & BACK_AMBIENT_BIT) { - COPY_4FV( dst[1].Ambient, src[1].Ambient ); - } - if (bitmask & FRONT_DIFFUSE_BIT) { - COPY_4FV( dst[0].Diffuse, src[0].Diffuse ); - } - if (bitmask & BACK_DIFFUSE_BIT) { - COPY_4FV( dst[1].Diffuse, src[1].Diffuse ); - } - if (bitmask & FRONT_SPECULAR_BIT) { - COPY_4FV( dst[0].Specular, src[0].Specular ); - } - if (bitmask & BACK_SPECULAR_BIT) { - COPY_4FV( dst[1].Specular, src[1].Specular ); - } - if (bitmask & FRONT_SHININESS_BIT) { - dst[0].Shininess = src[0].Shininess; - } - if (bitmask & BACK_SHININESS_BIT) { - dst[1].Shininess = src[1].Shininess; - } - if (bitmask & FRONT_INDEXES_BIT) { - dst[0].AmbientIndex = src[0].AmbientIndex; - dst[0].DiffuseIndex = src[0].DiffuseIndex; - dst[0].SpecularIndex = src[0].SpecularIndex; - } - if (bitmask & BACK_INDEXES_BIT) { - dst[1].AmbientIndex = src[1].AmbientIndex; - dst[1].DiffuseIndex = src[1].DiffuseIndex; - dst[1].SpecularIndex = src[1].SpecularIndex; - } + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<<i)) + COPY_4FV( dst->Attrib[i], src->Attrib[i] ); } -/* - * Check if the global material has to be updated with info that was - * associated with a vertex via glMaterial. - * This function is used when any material values get changed between - * glBegin/glEnd either by calling glMaterial() or by calling glColor() - * when GL_COLOR_MATERIAL is enabled. - * - * src[0] is front material, src[1] is back material - * - * Additionally keeps the precomputed lighting state uptodate. +/* Update derived values following a change in ctx->Light.Material */ -void _mesa_update_material( GLcontext *ctx, - const struct gl_material src[2], - GLuint bitmask ) +void _mesa_update_material( GLcontext *ctx, GLuint bitmask ) { struct gl_light *light, *list = &ctx->Light.EnabledList; - - if (ctx->Light.ColorMaterialEnabled) - bitmask &= ~ctx->Light.ColorMaterialBitmask; + struct GLfloat (*mat)[4] = ctx->Light.Material.Attrib; if (MESA_VERBOSE&VERBOSE_IMMEDIATE) _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask); @@ -623,109 +565,71 @@ void _mesa_update_material( GLcontext *ctx, if (!bitmask) return; - /* update material emission */ - if (bitmask & FRONT_EMISSION_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Emission, src[0].Emission ); - } - if (bitmask & BACK_EMISSION_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Emission, src[1].Emission ); - } - /* update material ambience */ - if (bitmask & FRONT_AMBIENT_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Ambient, src[0].Ambient ); + if (bitmask & MAT_BIT_FRONT_AMBIENT) { foreach (light, list) { - SCALE_3V( light->_MatAmbient[0], light->Ambient, src[0].Ambient); + SCALE_3V( light->_MatAmbient[0], light->Ambient, + mat[MAT_ATTRIB_FRONT_AMBIENT]); } } - if (bitmask & BACK_AMBIENT_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Ambient, src[1].Ambient ); + + if (bitmask & MAT_BIT_BACK_AMBIENT) { foreach (light, list) { - SCALE_3V( light->_MatAmbient[1], light->Ambient, src[1].Ambient); + SCALE_3V( light->_MatAmbient[1], light->Ambient, + mat[MAT_ATTRIB_BACK_AMBIENT]); } } /* update BaseColor = emission + scene's ambience * material's ambience */ - if (bitmask & (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT)) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_3V( ctx->Light._BaseColor[0], mat->Emission ); - ACC_SCALE_3V( ctx->Light._BaseColor[0], mat->Ambient, + if (bitmask & (MAT_BIT_FRONT_EMISSION | MAT_BIT_FRONT_AMBIENT)) { + COPY_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_EMISSION] ); + ACC_SCALE_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_AMBIENT], ctx->Light.Model.Ambient ); } - if (bitmask & (BACK_EMISSION_BIT | BACK_AMBIENT_BIT)) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_3V( ctx->Light._BaseColor[1], mat->Emission ); - ACC_SCALE_3V( ctx->Light._BaseColor[1], mat->Ambient, + + if (bitmask & (MAT_BIT_BACK_EMISSION | MAT_BIT_BACK_AMBIENT)) { + COPY_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_EMISSION] ); + ACC_SCALE_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_AMBIENT], ctx->Light.Model.Ambient ); } /* update material diffuse values */ - if (bitmask & FRONT_DIFFUSE_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Diffuse, src[0].Diffuse ); + if (bitmask & MAT_BIT_FRONT_DIFFUSE) { foreach (light, list) { - SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse ); + SCALE_3V( light->_MatDiffuse[0], light->Diffuse, + mat[MAT_ATTRIB_FRONT_DIFFUSE] ); } } - if (bitmask & BACK_DIFFUSE_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Diffuse, src[1].Diffuse ); + + if (bitmask & MAT_BIT_BACK_DIFFUSE) { foreach (light, list) { - SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse ); + SCALE_3V( light->_MatDiffuse[1], light->Diffuse, + mat[MAT_ATTRIB_BACK_DIFFUSE] ); } } /* update material specular values */ - if (bitmask & FRONT_SPECULAR_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Specular, src[0].Specular ); + if (bitmask & MAT_BIT_FRONT_SPECULAR) { foreach (light, list) { - SCALE_3V( light->_MatSpecular[0], light->Specular, mat->Specular); + SCALE_3V( light->_MatSpecular[0], light->Specular, + mat[MAT_ATTRIB_FRONT_SPECULAR]); } } - if (bitmask & BACK_SPECULAR_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Specular, src[1].Specular ); + + if (bitmask & MAT_BIT_BACK_SPECULAR) { foreach (light, list) { - SCALE_3V( light->_MatSpecular[1], light->Specular, mat->Specular); + SCALE_3V( light->_MatSpecular[1], light->Specular, + mat[MAT_ATTRIB_BACK_SPECULAR]); } } if (bitmask & FRONT_SHININESS_BIT) { - ctx->Light.Material[0].Shininess = src[0].Shininess; _mesa_invalidate_shine_table( ctx, 0 ); } + if (bitmask & BACK_SHININESS_BIT) { - ctx->Light.Material[1].Shininess = src[1].Shininess; _mesa_invalidate_shine_table( ctx, 1 ); } - - if (bitmask & FRONT_INDEXES_BIT) { - ctx->Light.Material[0].AmbientIndex = src[0].AmbientIndex; - ctx->Light.Material[0].DiffuseIndex = src[0].DiffuseIndex; - ctx->Light.Material[0].SpecularIndex = src[0].SpecularIndex; - } - if (bitmask & BACK_INDEXES_BIT) { - ctx->Light.Material[1].AmbientIndex = src[1].AmbientIndex; - ctx->Light.Material[1].DiffuseIndex = src[1].DiffuseIndex; - ctx->Light.Material[1].SpecularIndex = src[1].SpecularIndex; - } - - if (0) { - struct gl_material *mat = &ctx->Light.Material[0]; - _mesa_debug(ctx, "update_mat emission : %f %f %f\n", - mat->Emission[0], mat->Emission[1], mat->Emission[2]); - _mesa_debug(ctx, "update_mat specular : %f %f %f\n", - mat->Specular[0], mat->Specular[1], mat->Specular[2]); - _mesa_debug(ctx, "update_mat diffuse : %f %f %f\n", - mat->Diffuse[0], mat->Diffuse[1], mat->Diffuse[2]); - _mesa_debug(ctx, "update_mat ambient : %f %f %f\n", - mat->Ambient[0], mat->Ambient[1], mat->Ambient[2]); - } } @@ -742,98 +646,14 @@ void _mesa_update_material( GLcontext *ctx, void _mesa_update_color_material( GLcontext *ctx, const GLfloat color[4] ) { - struct gl_light *light, *list = &ctx->Light.EnabledList; GLuint bitmask = ctx->Light.ColorMaterialBitmask; + struct gl_material *mat = &ctx->Light.Material; - if (MESA_VERBOSE&VERBOSE_IMMEDIATE) - _mesa_debug(ctx, "_mesa_update_color_material, mask 0x%x\n", bitmask); - - /* update emissive colors */ - if (bitmask & FRONT_EMISSION_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Emission, color ); - } + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) + if (bitmask & (1<<i)) + COPY_4FV( mat->Attrib[i], color ); - if (bitmask & BACK_EMISSION_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Emission, color ); - } - - /* update light->_MatAmbient = light's ambient * material's ambient */ - if (bitmask & FRONT_AMBIENT_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - foreach (light, list) { - SCALE_3V( light->_MatAmbient[0], light->Ambient, color); - } - COPY_4FV( mat->Ambient, color ); - } - - if (bitmask & BACK_AMBIENT_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - foreach (light, list) { - SCALE_3V( light->_MatAmbient[1], light->Ambient, color); - } - COPY_4FV( mat->Ambient, color ); - } - - /* update BaseColor = emission + scene's ambience * material's ambience */ - if (bitmask & (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT)) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_3V( ctx->Light._BaseColor[0], mat->Emission ); - ACC_SCALE_3V( ctx->Light._BaseColor[0], mat->Ambient, ctx->Light.Model.Ambient ); - } - - if (bitmask & (BACK_EMISSION_BIT | BACK_AMBIENT_BIT)) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_3V( ctx->Light._BaseColor[1], mat->Emission ); - ACC_SCALE_3V( ctx->Light._BaseColor[1], mat->Ambient, ctx->Light.Model.Ambient ); - } - - /* update light->_MatDiffuse = light's diffuse * material's diffuse */ - if (bitmask & FRONT_DIFFUSE_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Diffuse, color ); - foreach (light, list) { - SCALE_3V( light->_MatDiffuse[0], light->Diffuse, mat->Diffuse ); - } - } - - if (bitmask & BACK_DIFFUSE_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Diffuse, color ); - foreach (light, list) { - SCALE_3V( light->_MatDiffuse[1], light->Diffuse, mat->Diffuse ); - } - } - - /* update light->_MatSpecular = light's specular * material's specular */ - if (bitmask & FRONT_SPECULAR_BIT) { - struct gl_material *mat = &ctx->Light.Material[0]; - COPY_4FV( mat->Specular, color ); - foreach (light, list) { - ACC_SCALE_3V( light->_MatSpecular[0], light->Specular, mat->Specular); - } - } - - if (bitmask & BACK_SPECULAR_BIT) { - struct gl_material *mat = &ctx->Light.Material[1]; - COPY_4FV( mat->Specular, color ); - foreach (light, list) { - ACC_SCALE_3V( light->_MatSpecular[1], light->Specular, mat->Specular); - } - } - - if (0) { - struct gl_material *mat = &ctx->Light.Material[0]; - _mesa_debug(ctx, "update_color_mat emission : %f %f %f\n", - mat->Emission[0], mat->Emission[1], mat->Emission[2]); - _mesa_debug(ctx, "update_color_mat specular : %f %f %f\n", - mat->Specular[0], mat->Specular[1], mat->Specular[2]); - _mesa_debug(ctx, "update_color_mat diffuse : %f %f %f\n", - mat->Diffuse[0], mat->Diffuse[1], mat->Diffuse[2]); - _mesa_debug(ctx, "update_color_mat ambient : %f %f %f\n", - mat->Ambient[0], mat->Ambient[1], mat->Ambient[2]); - } + _mesa_update_material( ctx, bitmask ); } @@ -844,10 +664,10 @@ _mesa_ColorMaterial( GLenum face, GLenum mode ) { GET_CURRENT_CONTEXT(ctx); GLuint bitmask; - GLuint legal = (FRONT_EMISSION_BIT | BACK_EMISSION_BIT | - FRONT_SPECULAR_BIT | BACK_SPECULAR_BIT | - FRONT_DIFFUSE_BIT | BACK_DIFFUSE_BIT | - FRONT_AMBIENT_BIT | BACK_AMBIENT_BIT); + GLuint legal = (MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION | + MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR | + MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE | + MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT); ASSERT_OUTSIDE_BEGIN_END(ctx); if (MESA_VERBOSE&VERBOSE_API) @@ -869,7 +689,8 @@ _mesa_ColorMaterial( GLenum face, GLenum mode ) if (ctx->Light.ColorMaterialEnabled) { FLUSH_CURRENT( ctx, 0 ); - _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + _mesa_update_color_material( ctx, + ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); } if (ctx->Driver.ColorMaterial) @@ -885,38 +706,40 @@ _mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); GLuint f; + const GLfloat (*mat)[4] = ctx->Light.Material.Attrib; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ if (face==GL_FRONT) { f = 0; } else if (face==GL_BACK) { - f = 1; + f = MAT_ATTRIB_BACK_EMISSION; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" ); return; } + switch (pname) { case GL_AMBIENT: - COPY_4FV( params, ctx->Light.Material[f].Ambient ); + COPY_4FV( params, mat[f + MAT_ATTRIB_FRONT_AMBIENT] ); break; case GL_DIFFUSE: - COPY_4FV( params, ctx->Light.Material[f].Diffuse ); + COPY_4FV( params, mat[f + MAT_ATTRIB_FRONT_DIFFUSE] ); break; case GL_SPECULAR: - COPY_4FV( params, ctx->Light.Material[f].Specular ); + COPY_4FV( params, mat[f + MAT_ATTRIB_FRONT_SPECULAR] ); break; case GL_EMISSION: - COPY_4FV( params, ctx->Light.Material[f].Emission ); + COPY_4FV( params, mat[f + MAT_ATTRIB_FRONT_EMISSION] ); break; case GL_SHININESS: - *params = ctx->Light.Material[f].Shininess; + *params = mat[f + MAT_ATTRIB_FRONT_SHININESS][0]; break; case GL_COLOR_INDEXES: - params[0] = ctx->Light.Material[f].AmbientIndex; - params[1] = ctx->Light.Material[f].DiffuseIndex; - params[2] = ctx->Light.Material[f].SpecularIndex; + params[0] = mat[f + MAT_ATTRIB_FRONT_INDEXES][0]; + params[1] = mat[f + MAT_ATTRIB_FRONT_INDEXES][1]; + params[2] = mat[f + MAT_ATTRIB_FRONT_INDEXES][2]; break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); @@ -931,12 +754,13 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) GET_CURRENT_CONTEXT(ctx); GLuint f; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */ + const GLfloat (*mat)[4] = ctx->Light.Material.Attrib; if (face==GL_FRONT) { f = 0; } else if (face==GL_BACK) { - f = 1; + f = MAT_ATTRIB_BACK_EMISSION; } else { _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" ); @@ -944,36 +768,36 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) } switch (pname) { case GL_AMBIENT: - params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[0] ); - params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[1] ); - params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[2] ); - params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Ambient[3] ); + params[0] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_AMBIENT][0] ); + params[1] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_AMBIENT][1] ); + params[2] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_AMBIENT][2] ); + params[3] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_AMBIENT][3] ); break; case GL_DIFFUSE: - params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[0] ); - params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[1] ); - params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[2] ); - params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Diffuse[3] ); + params[0] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_DIFFUSE][0] ); + params[1] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_DIFFUSE][1] ); + params[2] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_DIFFUSE][2] ); + params[3] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_DIFFUSE][3] ); break; case GL_SPECULAR: - params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[0] ); - params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[1] ); - params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[2] ); - params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Specular[3] ); + params[0] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_SPECULAR][0] ); + params[1] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_SPECULAR][1] ); + params[2] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_SPECULAR][2] ); + params[3] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_SPECULAR][3] ); break; case GL_EMISSION: - params[0] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[0] ); - params[1] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[1] ); - params[2] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[2] ); - params[3] = FLOAT_TO_INT( ctx->Light.Material[f].Emission[3] ); + params[0] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_EMISSION][0] ); + params[1] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_EMISSION][1] ); + params[2] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_EMISSION][2] ); + params[3] = FLOAT_TO_INT( mat[f + MAT_ATTRIB_FRONT_EMISSION][3] ); break; case GL_SHININESS: - *params = ROUNDF( ctx->Light.Material[f].Shininess ); + *params = ROUNDF( mat[f + MAT_ATTRIB_FRONT_SHININESS][0] ); break; case GL_COLOR_INDEXES: - params[0] = ROUNDF( ctx->Light.Material[f].AmbientIndex ); - params[1] = ROUNDF( ctx->Light.Material[f].DiffuseIndex ); - params[2] = ROUNDF( ctx->Light.Material[f].SpecularIndex ); + params[0] = ROUNDF( mat[f + MAT_ATTRIB_FRONT_INDEXES][0] ); + params[1] = ROUNDF( mat[f + MAT_ATTRIB_FRONT_INDEXES][1] ); + params[2] = ROUNDF( mat[f + MAT_ATTRIB_FRONT_INDEXES][2] ); break; default: _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" ); @@ -1190,26 +1014,22 @@ _mesa_update_lighting( GLcontext *ctx ) * are flushed, they will update the derived state at that time. */ if (ctx->Visual.rgbMode) { - GLuint sides = ctx->Light.Model.TwoSide ? 2 : 1; - GLuint side; - for (side=0; side < sides; side++) { - struct gl_material *mat = &ctx->Light.Material[side]; - - COPY_3V(ctx->Light._BaseColor[side], mat->Emission); - ACC_SCALE_3V(ctx->Light._BaseColor[side], - ctx->Light.Model.Ambient, - mat->Ambient); - } - - foreach (light, &ctx->Light.EnabledList) { - for (side=0; side< sides; side++) { - const struct gl_material *mat = &ctx->Light.Material[side]; - SCALE_3V( light->_MatDiffuse[side], light->Diffuse, mat->Diffuse ); - SCALE_3V( light->_MatAmbient[side], light->Ambient, mat->Ambient ); - SCALE_3V( light->_MatSpecular[side], light->Specular, - mat->Specular); - } - } + if (ctx->Light.Model.TwoSide) + _mesa_update_material( ctx, + MAT_BIT_FRONT_EMISSION | + MAT_BIT_FRONT_AMBIENT | + MAT_BIT_FRONT_DIFFUSE | + MAT_BIT_FRONT_SPECULAR | + MAT_BIT_BACK_EMISSION | + MAT_BIT_BACK_AMBIENT | + MAT_BIT_BACK_DIFFUSE | + MAT_BIT_BACK_SPECULAR); + else + _mesa_update_material( ctx, + MAT_BIT_FRONT_EMISSION | + MAT_BIT_FRONT_AMBIENT | + MAT_BIT_FRONT_DIFFUSE | + MAT_BIT_FRONT_SPECULAR); } else { static const GLfloat ci[3] = { .30F, .59F, .11F }; diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h index 5cd24e83ff..94a622cd5d 100644 --- a/src/mesa/main/light.h +++ b/src/mesa/main/light.h @@ -1,4 +1,4 @@ -/* $Id: light.h,v 1.14 2001/09/14 21:36:43 brianp Exp $ */ +/* $Id: light.h,v 1.14.4.1 2002/11/19 12:01:28 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -109,12 +109,11 @@ extern void _mesa_update_lighting( GLcontext *ctx ); extern void _mesa_compute_light_positions( GLcontext *ctx ); extern void _mesa_update_material( GLcontext *ctx, - const struct gl_material src[2], GLuint bitmask ); -extern void _mesa_copy_material_pairs( struct gl_material dst[2], - const struct gl_material src[2], - GLuint bitmask ); +extern void _mesa_copy_materials( struct gl_material *dst, + const struct gl_material *src, + GLuint bitmask ); extern void _mesa_update_color_material( GLcontext *ctx, const GLfloat rgba[4] ); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 10f8e2bf57..763fda0cee 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1,4 +1,4 @@ -/* $Id: mtypes.h,v 1.96 2002/10/11 17:41:04 brianp Exp $ */ +/* $Id: mtypes.h,v 1.96.2.1 2002/11/19 12:01:28 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -194,29 +194,57 @@ struct gl_color_table { /* * Bit flags used for updating material values. */ -#define FRONT_AMBIENT_BIT 0x1 -#define BACK_AMBIENT_BIT 0x2 -#define FRONT_DIFFUSE_BIT 0x4 -#define BACK_DIFFUSE_BIT 0x8 -#define FRONT_SPECULAR_BIT 0x10 -#define BACK_SPECULAR_BIT 0x20 -#define FRONT_EMISSION_BIT 0x40 -#define BACK_EMISSION_BIT 0x80 -#define FRONT_SHININESS_BIT 0x100 -#define BACK_SHININESS_BIT 0x200 -#define FRONT_INDEXES_BIT 0x400 -#define BACK_INDEXES_BIT 0x800 - -#define FRONT_MATERIAL_BITS (FRONT_EMISSION_BIT | FRONT_AMBIENT_BIT | \ - FRONT_DIFFUSE_BIT | FRONT_SPECULAR_BIT | \ - FRONT_SHININESS_BIT | FRONT_INDEXES_BIT) - -#define BACK_MATERIAL_BITS (BACK_EMISSION_BIT | BACK_AMBIENT_BIT | \ - BACK_DIFFUSE_BIT | BACK_SPECULAR_BIT | \ - BACK_SHININESS_BIT | BACK_INDEXES_BIT) +#define MAT_ATTRIB_FRONT_AMBIENT 0 +#define MAT_ATTRIB_FRONT_DIFFUSE 1 +#define MAT_ATTRIB_FRONT_SPECULAR 2 +#define MAT_ATTRIB_FRONT_EMISSION 3 +#define MAT_ATTRIB_FRONT_SHININESS 4 +#define MAT_ATTRIB_FRONT_INDEXES 5 +#define MAT_ATTRIB_BACK_AMBIENT 6 +#define MAT_ATTRIB_BACK_DIFFUSE 7 +#define MAT_ATTRIB_BACK_SPECULAR 8 +#define MAT_ATTRIB_BACK_EMISSION 9 +#define MAT_ATTRIB_BACK_SHININESS 10 +#define MAT_ATTRIB_BACK_INDEXES 11 +#define MAT_ATTRIB_MAX 12 + + +#define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT) +#define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE) +#define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR) +#define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION) +#define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS) +#define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES) +#define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT) +#define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE) +#define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR) +#define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION) +#define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS) +#define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES) + + +#define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \ + MAT_BIT_FRONT_AMBIENT | \ + MAT_BIT_FRONT_DIFFUSE | \ + MAT_BIT_FRONT_SPECULAR | \ + MAT_BIT_FRONT_SHININESS | \ + MAT_BIT_FRONT_INDEXES) + +#define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \ + MAT_BIT_BACK_AMBIENT | \ + MAT_BIT_BACK_DIFFUSE | \ + MAT_BIT_BACK_SPECULAR | \ + MAT_BIT_BACK_SHININESS | \ + MAT_BIT_BACK_INDEXES) #define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS) +struct gl_material +{ + GLfloat Attrib[MAT_ATTRIB_MAX][4]; +}; + + /* @@ -277,19 +305,6 @@ struct gl_lightmodel { }; -struct gl_material -{ - GLfloat Ambient[4]; - GLfloat Diffuse[4]; - GLfloat Specular[4]; - GLfloat Emission[4]; - GLfloat Shininess; - GLfloat AmbientIndex; /* for color index lighting */ - GLfloat DiffuseIndex; /* for color index lighting */ - GLfloat SpecularIndex; /* for color index lighting */ -}; - - /* * Attribute structures: * We define a struct for each attribute group to make pushing and @@ -351,7 +366,7 @@ struct gl_current_attrib { GLfloat Attrib[VERT_ATTRIB_MAX][4]; /* Current vertex attributes */ /* indexed by VERT_ATTRIB_* */ GLuint Index; /* Current color index */ - GLboolean EdgeFlag; /* Current edge flag */ + GLuint EdgeFlag; /* Current edge flag (as uint) */ /* These values are always valid. BTW, note how similar this set of * attributes is to the SWvertex datatype in the software rasterizer... @@ -540,7 +555,7 @@ struct gl_light_attrib { /* Must flush FLUSH_VERTICES before referencing: */ - struct gl_material Material[2]; /* Material 0=front, 1=back */ + struct gl_material Material; /* Material */ GLboolean Enabled; /* Lighting enabled flag */ GLenum ShadeModel; /* GL_FLAT or GL_SMOOTH */ @@ -1637,7 +1652,7 @@ struct __GLcontextRec { /* API function pointer tables */ struct _glapi_table *Save; /**< Display list save funcs */ struct _glapi_table *Exec; /**< Execute funcs */ - struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */ + struct _glapi_table *CurrentDispatch; /**< == Save, Exec or driver table. */ GLboolean ExecPrefersFloat; /**< What preference for color conversion? */ GLboolean SavePrefersFloat; diff --git a/src/mesa/main/vtxfmt.c b/src/mesa/main/vtxfmt.c deleted file mode 100644 index 44e387f92c..0000000000 --- a/src/mesa/main/vtxfmt.c +++ /dev/null @@ -1,176 +0,0 @@ -/* $Id: vtxfmt.c,v 1.12 2002/06/29 19:48:16 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - * Gareth Hughes <gareth@valinux.com> - */ - -#include "glheader.h" -#include "api_loopback.h" -#include "context.h" -#include "mtypes.h" -#include "state.h" -#include "vtxfmt.h" - - -/* The neutral vertex format. This wraps all tnl module functions, - * verifying that the currently-installed module is valid and then - * installing the function pointers in a lazy fashion. It records the - * function pointers that have been swapped out, which allows a fast - * restoration of the neutral module in almost all cases -- a typical - * app might only require 4-6 functions to be modified from the neutral - * baseline, and only restoring these is certainly preferable to doing - * the entire module's 60 or so function pointers. - */ - -#define PRE_LOOPBACK( FUNC ) \ -{ \ - GET_CURRENT_CONTEXT(ctx); \ - struct gl_tnl_module *tnl = &(ctx->TnlModule); \ - \ - ASSERT( tnl->Current ); \ - ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \ - \ - /* Save the swapped function's dispatch entry so it can be */ \ - /* restored later. */ \ - tnl->Swapped[tnl->SwapCount][0] = (void *)&(ctx->Exec->FUNC); \ - tnl->Swapped[tnl->SwapCount][1] = (void *)TAG(FUNC); \ - tnl->SwapCount++; \ - \ - if ( 0 ) \ - _mesa_debug(ctx, " swapping gl" #FUNC"...\n" ); \ - \ - /* Install the tnl function pointer. */ \ - ctx->Exec->FUNC = tnl->Current->FUNC; \ -} - -#define TAG(x) neutral_##x -#include "vtxfmt_tmp.h" - - - -static void install_vtxfmt( struct _glapi_table *tab, GLvertexformat *vfmt ) -{ - tab->ArrayElement = vfmt->ArrayElement; - tab->Color3f = vfmt->Color3f; - tab->Color3fv = vfmt->Color3fv; - tab->Color3ub = vfmt->Color3ub; - tab->Color3ubv = vfmt->Color3ubv; - tab->Color4f = vfmt->Color4f; - tab->Color4fv = vfmt->Color4fv; - tab->Color4ub = vfmt->Color4ub; - tab->Color4ubv = vfmt->Color4ubv; - tab->EdgeFlag = vfmt->EdgeFlag; - tab->EdgeFlagv = vfmt->EdgeFlagv; - tab->EvalCoord1f = vfmt->EvalCoord1f; - tab->EvalCoord1fv = vfmt->EvalCoord1fv; - tab->EvalCoord2f = vfmt->EvalCoord2f; - tab->EvalCoord2fv = vfmt->EvalCoord2fv; - tab->EvalPoint1 = vfmt->EvalPoint1; - tab->EvalPoint2 = vfmt->EvalPoint2; - tab->FogCoordfEXT = vfmt->FogCoordfEXT; - tab->FogCoordfvEXT = vfmt->FogCoordfvEXT; - tab->Indexi = vfmt->Indexi; - tab->Indexiv = vfmt->Indexiv; - tab->Materialfv = vfmt->Materialfv; - tab->MultiTexCoord1fARB = vfmt->MultiTexCoord1fARB; - tab->MultiTexCoord1fvARB = vfmt->MultiTexCoord1fvARB; - tab->MultiTexCoord2fARB = vfmt->MultiTexCoord2fARB; - tab->MultiTexCoord2fvARB = vfmt->MultiTexCoord2fvARB; - tab->MultiTexCoord3fARB = vfmt->MultiTexCoord3fARB; - tab->MultiTexCoord3fvARB = vfmt->MultiTexCoord3fvARB; - tab->MultiTexCoord4fARB = vfmt->MultiTexCoord4fARB; - tab->MultiTexCoord4fvARB = vfmt->MultiTexCoord4fvARB; - tab->Normal3f = vfmt->Normal3f; - tab->Normal3fv = vfmt->Normal3fv; - tab->SecondaryColor3fEXT = vfmt->SecondaryColor3fEXT; - tab->SecondaryColor3fvEXT = vfmt->SecondaryColor3fvEXT; - tab->SecondaryColor3ubEXT = vfmt->SecondaryColor3ubEXT; - tab->SecondaryColor3ubvEXT = vfmt->SecondaryColor3ubvEXT; - tab->TexCoord1f = vfmt->TexCoord1f; - tab->TexCoord1fv = vfmt->TexCoord1fv; - tab->TexCoord2f = vfmt->TexCoord2f; - tab->TexCoord2fv = vfmt->TexCoord2fv; - tab->TexCoord3f = vfmt->TexCoord3f; - tab->TexCoord3fv = vfmt->TexCoord3fv; - tab->TexCoord4f = vfmt->TexCoord4f; - tab->TexCoord4fv = vfmt->TexCoord4fv; - tab->Vertex2f = vfmt->Vertex2f; - tab->Vertex2fv = vfmt->Vertex2fv; - tab->Vertex3f = vfmt->Vertex3f; - tab->Vertex3fv = vfmt->Vertex3fv; - tab->Vertex4f = vfmt->Vertex4f; - tab->Vertex4fv = vfmt->Vertex4fv; - tab->CallList = vfmt->CallList; - tab->Begin = vfmt->Begin; - tab->End = vfmt->End; - tab->VertexAttrib4fNV = vfmt->VertexAttrib4fNV; - tab->Rectf = vfmt->Rectf; - tab->DrawArrays = vfmt->DrawArrays; - tab->DrawElements = vfmt->DrawElements; - tab->DrawRangeElements = vfmt->DrawRangeElements; - tab->EvalMesh1 = vfmt->EvalMesh1; - tab->EvalMesh2 = vfmt->EvalMesh2; - assert(tab->EvalMesh2); -} - - -void _mesa_init_exec_vtxfmt( GLcontext *ctx ) -{ - install_vtxfmt( ctx->Exec, &neutral_vtxfmt ); - ctx->TnlModule.SwapCount = 0; -} - - -void _mesa_install_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt ) -{ - ctx->TnlModule.Current = vfmt; - _mesa_restore_exec_vtxfmt( ctx ); - if ( ctx->ExecPrefersFloat != vfmt->prefer_float_colors ) - _mesa_loopback_prefer_float( ctx->Exec, vfmt->prefer_float_colors ); -} - -void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt ) -{ - install_vtxfmt( ctx->Save, vfmt ); - if ( ctx->SavePrefersFloat != vfmt->prefer_float_colors ) - _mesa_loopback_prefer_float( ctx->Save, vfmt->prefer_float_colors ); -} - - -void _mesa_restore_exec_vtxfmt( GLcontext *ctx ) -{ - struct gl_tnl_module *tnl = &(ctx->TnlModule); - GLuint i; - - /* Restore the neutral tnl module wrapper. - */ - for ( i = 0 ; i < tnl->SwapCount ; i++ ) { - *(void **)tnl->Swapped[i][0] = tnl->Swapped[i][1]; - } - - tnl->SwapCount = 0; -} diff --git a/src/mesa/main/vtxfmt.h b/src/mesa/main/vtxfmt.h deleted file mode 100644 index 25a458936e..0000000000 --- a/src/mesa/main/vtxfmt.h +++ /dev/null @@ -1,41 +0,0 @@ -/* $Id: vtxfmt.h,v 1.4 2001/03/12 00:48:39 gareth Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 3.5 - * - * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Keith Whitwell <keithw@valinux.com> - * Gareth Hughes <gareth@valinux.com> - */ - -#ifndef _VTXFMT_H_ -#define _VTXFMT_H_ - -extern void _mesa_init_exec_vtxfmt( GLcontext *ctx ); - -extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt ); -extern void _mesa_install_save_vtxfmt( GLcontext *ctx, GLvertexformat *vfmt ); - -extern void _mesa_restore_exec_vtxfmt( GLcontext *ctx ); - -#endif diff --git a/src/mesa/main/vtxfmt_tmp.h b/src/mesa/main/vtxfmt_tmp.h deleted file mode 100644 index 81117c4e29..0000000000 --- a/src/mesa/main/vtxfmt_tmp.h +++ /dev/null @@ -1,472 +0,0 @@ -/* $Id: vtxfmt_tmp.h,v 1.10 2002/10/08 23:58:55 brianp Exp $ */ - -/* - * Mesa 3-D graphics library - * Version: 4.1 - * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Authors: - * Gareth Hughes <gareth@valinux.com> - */ - -#ifndef PRE_LOOPBACK -#define PRE_LOOPBACK( FUNC ) -#endif - -static void TAG(ArrayElement)( GLint i ) -{ - PRE_LOOPBACK( ArrayElement ); - _glapi_Dispatch->ArrayElement( i ); -} - -static void TAG(Color3f)( GLfloat r, GLfloat g, GLfloat b ) -{ - PRE_LOOPBACK( Color3f ); - _glapi_Dispatch->Color3f( r, g, b ); -} - -static void TAG(Color3fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Color3fv ); - _glapi_Dispatch->Color3fv( v ); -} - -static void TAG(Color3ub)( GLubyte r, GLubyte g, GLubyte b ) -{ - PRE_LOOPBACK( Color3ub ); - _glapi_Dispatch->Color3ub( r, g, b ); -} - -static void TAG(Color3ubv)( const GLubyte *v ) -{ - PRE_LOOPBACK( Color3ubv ); - _glapi_Dispatch->Color3ubv( v ); -} - -static void TAG(Color4f)( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) -{ - PRE_LOOPBACK( Color4f ); - _glapi_Dispatch->Color4f( r, g, b, a ); -} - -static void TAG(Color4fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Color4fv ); - _glapi_Dispatch->Color4fv( v ); -} - -static void TAG(Color4ub)( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) -{ - PRE_LOOPBACK( Color4ub ); - _glapi_Dispatch->Color4ub( r, g, b, a ); -} - -static void TAG(Color4ubv)( const GLubyte *v ) -{ - PRE_LOOPBACK( Color4ubv ); - _glapi_Dispatch->Color4ubv( v ); -} - -static void TAG(EdgeFlag)( GLboolean e ) -{ - PRE_LOOPBACK( EdgeFlag ); - _glapi_Dispatch->EdgeFlag( e ); -} - -static void TAG(EdgeFlagv)( const GLboolean *v ) -{ - PRE_LOOPBACK( EdgeFlagv ); - _glapi_Dispatch->EdgeFlagv( v ); -} - -static void TAG(EvalCoord1f)( GLfloat s ) -{ - PRE_LOOPBACK( EvalCoord1f ); - _glapi_Dispatch->EvalCoord1f( s ); -} - -static void TAG(EvalCoord1fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( EvalCoord1fv ); - _glapi_Dispatch->EvalCoord1fv( v ); -} - -static void TAG(EvalCoord2f)( GLfloat s, GLfloat t ) -{ - PRE_LOOPBACK( EvalCoord2f ); - _glapi_Dispatch->EvalCoord2f( s, t ); -} - -static void TAG(EvalCoord2fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( EvalCoord2fv ); - _glapi_Dispatch->EvalCoord2fv( v ); -} - -static void TAG(EvalPoint1)( GLint i ) -{ - PRE_LOOPBACK( EvalPoint1 ); - _glapi_Dispatch->EvalPoint1( i ); -} - -static void TAG(EvalPoint2)( GLint i, GLint j ) -{ - PRE_LOOPBACK( EvalPoint2 ); - _glapi_Dispatch->EvalPoint2( i, j ); -} - -static void TAG(FogCoordfEXT)( GLfloat f ) -{ - PRE_LOOPBACK( FogCoordfEXT ); - _glapi_Dispatch->FogCoordfEXT( f ); -} - -static void TAG(FogCoordfvEXT)( const GLfloat *v ) -{ - PRE_LOOPBACK( FogCoordfvEXT ); - _glapi_Dispatch->FogCoordfvEXT( v ); -} - -static void TAG(Indexi)( GLint i ) -{ - PRE_LOOPBACK( Indexi ); - _glapi_Dispatch->Indexi( i ); -} - -static void TAG(Indexiv)( const GLint *v ) -{ - PRE_LOOPBACK( Indexiv ); - _glapi_Dispatch->Indexiv( v ); -} - -static void TAG(Materialfv)( GLenum face, GLenum pname, const GLfloat *v ) -{ - PRE_LOOPBACK( Materialfv ); - _glapi_Dispatch->Materialfv( face, pname, v ); -} - -static void TAG(MultiTexCoord1fARB)( GLenum target, GLfloat a ) -{ - PRE_LOOPBACK( MultiTexCoord1fARB ); - _glapi_Dispatch->MultiTexCoord1fARB( target, a ); -} - -static void TAG(MultiTexCoord1fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord1fvARB ); - _glapi_Dispatch->MultiTexCoord1fvARB( target, tc ); -} - -static void TAG(MultiTexCoord2fARB)( GLenum target, GLfloat s, GLfloat t ) -{ - PRE_LOOPBACK( MultiTexCoord2fARB ); - _glapi_Dispatch->MultiTexCoord2fARB( target, s, t ); -} - -static void TAG(MultiTexCoord2fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord2fvARB ); - _glapi_Dispatch->MultiTexCoord2fvARB( target, tc ); -} - -static void TAG(MultiTexCoord3fARB)( GLenum target, GLfloat s, - GLfloat t, GLfloat r ) -{ - PRE_LOOPBACK( MultiTexCoord3fARB ); - _glapi_Dispatch->MultiTexCoord3fARB( target, s, t, r ); -} - -static void TAG(MultiTexCoord3fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord3fvARB ); - _glapi_Dispatch->MultiTexCoord3fvARB( target, tc ); -} - -static void TAG(MultiTexCoord4fARB)( GLenum target, GLfloat s, - GLfloat t, GLfloat r, GLfloat q ) -{ - PRE_LOOPBACK( MultiTexCoord4fARB ); - _glapi_Dispatch->MultiTexCoord4fARB( target, s, t, r, q ); -} - -static void TAG(MultiTexCoord4fvARB)( GLenum target, const GLfloat *tc ) -{ - PRE_LOOPBACK( MultiTexCoord4fvARB ); - _glapi_Dispatch->MultiTexCoord4fvARB( target, tc ); -} - -static void TAG(Normal3f)( GLfloat x, GLfloat y, GLfloat z ) -{ - PRE_LOOPBACK( Normal3f ); - _glapi_Dispatch->Normal3f( x, y, z ); -} - -static void TAG(Normal3fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Normal3fv ); - _glapi_Dispatch->Normal3fv( v ); -} - -static void TAG(SecondaryColor3fEXT)( GLfloat r, GLfloat g, GLfloat b ) -{ - PRE_LOOPBACK( SecondaryColor3fEXT ); - _glapi_Dispatch->SecondaryColor3fEXT( r, g, b ); -} - -static void TAG(SecondaryColor3fvEXT)( const GLfloat *v ) -{ - PRE_LOOPBACK( SecondaryColor3fvEXT ); - _glapi_Dispatch->SecondaryColor3fvEXT( v ); -} - -static void TAG(SecondaryColor3ubEXT)( GLubyte r, GLubyte g, GLubyte b ) -{ - PRE_LOOPBACK( SecondaryColor3ubEXT ); - _glapi_Dispatch->SecondaryColor3ubEXT( r, g, b ); -} - -static void TAG(SecondaryColor3ubvEXT)( const GLubyte *v ) -{ - PRE_LOOPBACK( SecondaryColor3ubvEXT ); - _glapi_Dispatch->SecondaryColor3ubvEXT( v ); -} - -static void TAG(TexCoord1f)( GLfloat s ) -{ - PRE_LOOPBACK( TexCoord1f ); - _glapi_Dispatch->TexCoord1f( s ); -} - -static void TAG(TexCoord1fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord1fv ); - _glapi_Dispatch->TexCoord1fv( tc ); -} - -static void TAG(TexCoord2f)( GLfloat s, GLfloat t ) -{ - PRE_LOOPBACK( TexCoord2f ); - _glapi_Dispatch->TexCoord2f( s, t ); -} - -static void TAG(TexCoord2fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord2fv ); - _glapi_Dispatch->TexCoord2fv( tc ); -} - -static void TAG(TexCoord3f)( GLfloat s, GLfloat t, GLfloat r ) -{ - PRE_LOOPBACK( TexCoord3f ); - _glapi_Dispatch->TexCoord3f( s, t, r ); -} - -static void TAG(TexCoord3fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord3fv ); - _glapi_Dispatch->TexCoord3fv( tc ); -} - -static void TAG(TexCoord4f)( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) -{ - PRE_LOOPBACK( TexCoord4f ); - _glapi_Dispatch->TexCoord4f( s, t, r, q ); -} - -static void TAG(TexCoord4fv)( const GLfloat *tc ) -{ - PRE_LOOPBACK( TexCoord4fv ); - _glapi_Dispatch->TexCoord4fv( tc ); -} - -static void TAG(Vertex2f)( GLfloat x, GLfloat y ) -{ - PRE_LOOPBACK( Vertex2f ); - _glapi_Dispatch->Vertex2f( x, y ); -} - -static void TAG(Vertex2fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Vertex2fv ); - _glapi_Dispatch->Vertex2fv( v ); -} - -static void TAG(Vertex3f)( GLfloat x, GLfloat y, GLfloat z ) -{ - PRE_LOOPBACK( Vertex3f ); - _glapi_Dispatch->Vertex3f( x, y, z ); -} - -static void TAG(Vertex3fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Vertex3fv ); - _glapi_Dispatch->Vertex3fv( v ); -} - -static void TAG(Vertex4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - PRE_LOOPBACK( Vertex4f ); - _glapi_Dispatch->Vertex4f( x, y, z, w ); -} - -static void TAG(Vertex4fv)( const GLfloat *v ) -{ - PRE_LOOPBACK( Vertex4fv ); - _glapi_Dispatch->Vertex4fv( v ); -} - -static void TAG(CallList)( GLuint i ) -{ - PRE_LOOPBACK( CallList ); - _glapi_Dispatch->CallList( i ); -} - -static void TAG(Begin)( GLenum mode ) -{ - PRE_LOOPBACK( Begin ); - _glapi_Dispatch->Begin( mode ); -} - -static void TAG(End)( void ) -{ - PRE_LOOPBACK( End ); - _glapi_Dispatch->End(); -} - -static void TAG(Rectf)( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) -{ - PRE_LOOPBACK( Rectf ); - _glapi_Dispatch->Rectf( x1, y1, x2, y2 ); -} - -static void TAG(DrawArrays)( GLenum mode, GLint start, GLsizei count ) -{ - PRE_LOOPBACK( DrawArrays ); - _glapi_Dispatch->DrawArrays( mode, start, count ); -} - -static void TAG(DrawElements)( GLenum mode, GLsizei count, GLenum type, - const void *indices ) -{ - PRE_LOOPBACK( DrawElements ); - _glapi_Dispatch->DrawElements( mode, count, type, indices ); -} - -static void TAG(DrawRangeElements)( GLenum mode, GLuint start, - GLuint end, GLsizei count, - GLenum type, const void *indices ) -{ - PRE_LOOPBACK( DrawRangeElements ); - _glapi_Dispatch->DrawRangeElements( mode, start, end, count, type, indices ); -} - -static void TAG(EvalMesh1)( GLenum mode, GLint i1, GLint i2 ) -{ - PRE_LOOPBACK( EvalMesh1 ); - _glapi_Dispatch->EvalMesh1( mode, i1, i2 ); -} - -static void TAG(EvalMesh2)( GLenum mode, GLint i1, GLint i2, - GLint j1, GLint j2 ) -{ - PRE_LOOPBACK( EvalMesh2 ); - _glapi_Dispatch->EvalMesh2( mode, i1, i2, j1, j2 ); -} - -static void TAG(VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w ) -{ - PRE_LOOPBACK( VertexAttrib4fNV ); - _glapi_Dispatch->VertexAttrib4fNV( index, x, y, z, w ); -} - -static void TAG(VertexAttrib4fvNV)( GLuint index, const GLfloat *v ) -{ - PRE_LOOPBACK( VertexAttrib4fNV ); - _glapi_Dispatch->VertexAttrib4fvNV( index, v ); -} - - -static GLvertexformat TAG(vtxfmt) = { - TAG(ArrayElement), - TAG(Color3f), - TAG(Color3fv), - TAG(Color3ub), - TAG(Color3ubv), - TAG(Color4f), - TAG(Color4fv), - TAG(Color4ub), - TAG(Color4ubv), - TAG(EdgeFlag), - TAG(EdgeFlagv), - TAG(EvalCoord1f), - TAG(EvalCoord1fv), - TAG(EvalCoord2f), - TAG(EvalCoord2fv), - TAG(EvalPoint1), - TAG(EvalPoint2), - TAG(FogCoordfEXT), - TAG(FogCoordfvEXT), - TAG(Indexi), - TAG(Indexiv), - TAG(Materialfv), - TAG(MultiTexCoord1fARB), - TAG(MultiTexCoord1fvARB), - TAG(MultiTexCoord2fARB), - TAG(MultiTexCoord2fvARB), - TAG(MultiTexCoord3fARB), - TAG(MultiTexCoord3fvARB), - TAG(MultiTexCoord4fARB), - TAG(MultiTexCoord4fvARB), - TAG(Normal3f), - TAG(Normal3fv), - TAG(SecondaryColor3fEXT), - TAG(SecondaryColor3fvEXT), - TAG(SecondaryColor3ubEXT), - TAG(SecondaryColor3ubvEXT), - TAG(TexCoord1f), - TAG(TexCoord1fv), - TAG(TexCoord2f), - TAG(TexCoord2fv), - TAG(TexCoord3f), - TAG(TexCoord3fv), - TAG(TexCoord4f), - TAG(TexCoord4fv), - TAG(Vertex2f), - TAG(Vertex2fv), - TAG(Vertex3f), - TAG(Vertex3fv), - TAG(Vertex4f), - TAG(Vertex4fv), - TAG(CallList), - TAG(Begin), - TAG(End), - TAG(VertexAttrib4fNV), - TAG(VertexAttrib4fvNV), - TAG(Rectf), - TAG(DrawArrays), - TAG(DrawElements), - TAG(DrawRangeElements), - TAG(EvalMesh1), - TAG(EvalMesh2) -}; - -#undef TAG -#undef PRE_LOOPBACK diff --git a/src/mesa/swrast_setup/ss_triangle.c b/src/mesa/swrast_setup/ss_triangle.c index 3c7e65049d..04cf5df058 100644 --- a/src/mesa/swrast_setup/ss_triangle.c +++ b/src/mesa/swrast_setup/ss_triangle.c @@ -1,4 +1,4 @@ -/* $Id: ss_triangle.c,v 1.18.2.1 2002/10/17 14:27:51 keithw Exp $ */ +/* $Id: ss_triangle.c,v 1.18.2.2 2002/11/19 12:01:28 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -232,22 +232,10 @@ void _swsetup_trifuncs_init( GLcontext *ctx ) } -static void swsetup_points( GLcontext *ctx, GLuint first, GLuint last ) +static void swsetup_point( GLcontext *ctx, GLuint v0 ) { - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts; - GLuint i; - - if (VB->Elts) { - for (i = first; i < last; i++) - if (VB->ClipMask[VB->Elts[i]] == 0) - _swrast_Point( ctx, &verts[VB->Elts[i]] ); - } - else { - for (i = first; i < last; i++) - if (VB->ClipMask[i] == 0) - _swrast_Point( ctx, &verts[i] ); - } + _swrast_Point( ctx, &verts[i] ); } static void swsetup_line( GLcontext *ctx, GLuint v0, GLuint v1 ) @@ -284,7 +272,7 @@ void _swsetup_choose_trifuncs( GLcontext *ctx ) tnl->Driver.Render.Triangle = tri_tab[ind]; tnl->Driver.Render.Quad = quad_tab[ind]; tnl->Driver.Render.Line = swsetup_line; - tnl->Driver.Render.Points = swsetup_points; + tnl->Driver.Render.Point = swsetup_point; ctx->_Facing = 0; } diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c index 5ab0cc0e5e..9ae478f40c 100644 --- a/src/mesa/tnl/t_array_api.c +++ b/src/mesa/tnl/t_array_api.c @@ -1,4 +1,4 @@ -/* $Id: t_array_api.c,v 1.27.2.2 2002/10/17 14:26:37 keithw Exp $ */ +/* $Id: t_array_api.c,v 1.27.2.3 2002/11/19 12:01:28 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -43,15 +43,14 @@ #include "t_array_api.h" #include "t_array_import.h" -#include "t_imm_api.h" -#include "t_imm_exec.h" #include "t_context.h" #include "t_pipeline.h" static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, GLsizei count ) { - if (_tnl_hard_begin( ctx, mode )) { + glBegin( mode ); + { GLint i; for (i = start; i < count; i++) glArrayElement( i ); @@ -63,7 +62,8 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start, static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count, const GLuint *indices) { - if (_tnl_hard_begin(ctx, mode)) { + glBeing( mode ); + { GLint i; for (i = 0 ; i < count ; i++) glArrayElement( indices[i] ); @@ -78,6 +78,7 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, { TNLcontext *tnl = TNL_CONTEXT(ctx); + struct tnl_prim tmp; FLUSH_CURRENT( ctx, 0 ); /* _mesa_debug(ctx, "%s\n", __FUNCTION__); */ @@ -86,9 +87,12 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, _tnl_vb_bind_arrays( ctx, start, end ); - tnl->vb.FirstPrimitive = 0; - tnl->vb.Primitive[0] = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; - tnl->vb.PrimitiveLength[0] = count; + tmp.flags = mode | PRIM_BEGIN | PRIM_END; + tmp.start = 0; + tmp.end = count; + + tnl->vb.Primitive = &tmp; + tnl->vb.NrPrimitives = 1; tnl->vb.Elts = (GLuint *)indices; if (ctx->Array.LockCount) @@ -96,9 +100,9 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode, else { /* Note that arrays may have changed before/after execution. */ - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes[0] |= ctx->Array._Enabled; tnl->Driver.RunPipeline( ctx ); - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes[0] |= ctx->Array._Enabled; } } @@ -137,6 +141,7 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) } else if (ctx->Array.LockCount && count < (GLint) ctx->Const.MaxArrayLockSize) { + struct tnl_prim tmp_prim; /* Locked primitives which can fit in a single vertex buffer: */ @@ -152,9 +157,9 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount ); VB->Primitive = &tmp_prim; - VB->Primitive[0].flags = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; + VB->Primitive[0].flags = mode | PRIM_BEGIN | PRIM_END; VB->Primitive[0].start = start; - VB->Primitive[0].finish = start + count; + VB->Primitive[0].end = start + count; VB->NrPrimitives = 1; tnl->Driver.RunPipeline( ctx ); @@ -228,20 +233,21 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count) count += start; for (j = start + minimum ; j < count ; j += nr + skip ) { + struct tnl_prim tmp_prim; nr = MIN2( bufsz, count - j ); _tnl_vb_bind_arrays( ctx, j - minimum, j + nr ); VB->Primitive = &tmp_prim; - VB->Primitive[0].flags = mode | PRIM_BEGIN | PRIM_END | PRIM_LAST; + VB->Primitive[0].flags = mode | PRIM_BEGIN | PRIM_END; VB->Primitive[0].start = 0; - VB->Primitive[0].finish = nr + minimum; + VB->Primitive[0].end = nr + minimum; VB->NrPrimitives = 1; - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes[0] |= ctx->Array._Enabled; tnl->Driver.RunPipeline( ctx ); - tnl->pipeline.run_input_changes |= ctx->Array._Enabled; + tnl->pipeline.run_input_changes[0] |= ctx->Array._Enabled; } } } @@ -373,27 +379,11 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type, void _tnl_array_init( GLcontext *ctx ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - struct vertex_arrays *tmp = &tnl->array_inputs; - GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt); - GLuint i; - - vfmt->DrawArrays = _tnl_DrawArrays; - vfmt->DrawElements = _tnl_DrawElements; - vfmt->DrawRangeElements = _tnl_DrawRangeElements; - - /* Setup vector pointers that will be used to bind arrays to VB's. - */ - _mesa_vector4f_init( &tmp->Obj, 0, 0 ); - _mesa_vector4f_init( &tmp->Normal, 0, 0 ); - _mesa_vector4f_init( &tmp->FogCoord, 0, 0 ); - _mesa_vector1ui_init( &tmp->Index, 0, 0 ); - _mesa_vector1ub_init( &tmp->EdgeFlag, 0, 0 ); - - for (i = 0; i < ctx->Const.MaxTextureUnits; i++) - _mesa_vector4f_init( &tmp->TexCoord[i], 0, 0); + struct _glapi_table *exec = tnl->Exec; - tnl->tmp_primitive = (GLuint *)MALLOC(sizeof(GLuint)*tnl->vb.Size); - tnl->tmp_primitive_length = (GLuint *)MALLOC(sizeof(GLuint)*tnl->vb.Size); + exec->DrawArrays = _tnl_DrawArrays; + exec->DrawElements = _tnl_DrawElements; + exec->DrawRangeElements = _tnl_DrawRangeElements; } @@ -403,7 +393,4 @@ void _tnl_array_init( GLcontext *ctx ) */ void _tnl_array_destroy( GLcontext *ctx ) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - if (tnl->tmp_primitive_length) FREE(tnl->tmp_primitive_length); - if (tnl->tmp_primitive) FREE(tnl->tmp_primitive); } diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index 957b2888ac..9c935a626c 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -1,4 +1,4 @@ -/* $Id: t_array_import.c,v 1.25.2.2 2002/10/17 14:26:37 keithw Exp $ */ +/* $Id: t_array_import.c,v 1.25.2.3 2002/11/19 12:01:29 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -40,55 +40,24 @@ #include "t_array_import.h" #include "t_context.h" -#include "t_imm_debug.h" static void _tnl_import_vertex( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - - tmp = _ac_import_vertex(ctx, - GL_FLOAT, - stride ? 4*sizeof(GLfloat) : 0, - 0, - writeable, - &is_writeable); - - inputs->Attribs[VERT_ATTRIB_POS].data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Attribs[VERT_ATTRIB_POS].start = (GLfloat *) tmp->Ptr; - inputs->Attribs[VERT_ATTRIB_POS].stride = tmp->StrideB; - inputs->Attribs[VERT_ATTRIB_POS].size = tmp->Size; - inputs->Attribs[VERT_ATTRIB_POS].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Attribs[VERT_ATTRIB_POS].stride != 4*sizeof(GLfloat)) - inputs->Attribs[VERT_ATTRIB_POS].flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Attribs[VERT_ATTRIB_POS].flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_POS] = _ac_import_vertex(ctx, + GL_FLOAT, + 0, 0, 0, 0); } static void _tnl_import_normal( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - - tmp = _ac_import_normal(ctx, GL_FLOAT, - stride ? 3*sizeof(GLfloat) : 0, writeable, - &is_writeable); - - inputs->Normal.data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Normal.start = (GLfloat *) tmp->Ptr; - inputs->Normal.stride = tmp->StrideB; - inputs->Normal.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Normal.stride != 3*sizeof(GLfloat)) - inputs->Normal.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Normal.flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_NORMAL] = _ac_import_normal(ctx, GL_FLOAT, 0, 0, 0); } @@ -97,18 +66,9 @@ static void _tnl_import_color( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - - tmp = _ac_import_color(ctx, - type, - stride ? 4*sizeof(GLfloat) : 0, - 4, - writeable, - &is_writeable); - - inputs->Color = *tmp; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_COLOR0] = _ac_import_color(ctx, GL_FLOAT, + 0, 4, 0, 0); } @@ -117,62 +77,27 @@ static void _tnl_import_secondarycolor( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - - tmp = _ac_import_secondarycolor(ctx, - type, - stride ? 4*sizeof(GLfloat) : 0, - 4, - writeable, - &is_writeable); - - inputs->SecondaryColor = *tmp; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_COLOR1] = _ac_import_secondarycolor(ctx, GL_FLOAT, + 0, 4, 0, 0); } static void _tnl_import_fogcoord( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - - tmp = _ac_import_fogcoord(ctx, GL_FLOAT, - stride ? sizeof(GLfloat) : 0, writeable, - &is_writeable); - - inputs->FogCoord.data = (GLfloat (*)[4]) tmp->Ptr; - inputs->FogCoord.start = (GLfloat *) tmp->Ptr; - inputs->FogCoord.stride = tmp->StrideB; - inputs->FogCoord.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->FogCoord.stride != sizeof(GLfloat)) - inputs->FogCoord.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->FogCoord.flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_FOG] = _ac_import_fogcoord(ctx, GL_FLOAT, + 0, 0, 0); } static void _tnl_import_index( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - - tmp = _ac_import_index(ctx, GL_UNSIGNED_INT, - stride ? sizeof(GLuint) : 0, writeable, - &is_writeable); - - inputs->Index.data = (GLuint *) tmp->Ptr; - inputs->Index.start = (GLuint *) tmp->Ptr; - inputs->Index.stride = tmp->StrideB; - inputs->Index.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Index.stride != sizeof(GLuint)) - inputs->Index.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Index.flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_INDEX] = _ac_import_index(ctx, GL_UNSIGNED_INT, + 0, 0, 0); } @@ -181,25 +106,9 @@ static void _tnl_import_texcoord( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - - tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT, - stride ? 4 * sizeof(GLfloat) : 0, - 0, - writeable, - &is_writeable); - - inputs->TexCoord[unit].data = (GLfloat (*)[4]) tmp->Ptr; - inputs->TexCoord[unit].start = (GLfloat *) tmp->Ptr; - inputs->TexCoord[unit].stride = tmp->StrideB; - inputs->TexCoord[unit].size = tmp->Size; - inputs->TexCoord[unit].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->TexCoord[unit].stride != 4*sizeof(GLfloat)) - inputs->TexCoord[unit].flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->TexCoord[unit].flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_TEX0+unit] = _ac_import_texcoord(ctx, unit, GL_FLOAT, + 0, 0, 0, 0); } @@ -207,23 +116,10 @@ static void _tnl_import_edgeflag( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - - tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE, - stride ? sizeof(GLubyte) : 0, - 0, - &is_writeable); - - inputs->EdgeFlag.data = (GLubyte *) tmp->Ptr; - inputs->EdgeFlag.start = (GLubyte *) tmp->Ptr; - inputs->EdgeFlag.stride = tmp->StrideB; - inputs->EdgeFlag.flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->EdgeFlag.stride != sizeof(GLubyte)) - inputs->EdgeFlag.flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->EdgeFlag.flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[VERT_ATTRIB_EDGEFLAG] = _ac_import_edgeflag(ctx, + GL_UNSIGNED_BYTE, + 0, 0, 0); } @@ -233,25 +129,12 @@ static void _tnl_import_attrib( GLcontext *ctx, GLboolean writeable, GLboolean stride ) { - struct vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs; - struct gl_client_array *tmp; - GLboolean is_writeable = 0; - - tmp = _ac_import_attrib(ctx, index, GL_FLOAT, - stride ? 4 * sizeof(GLfloat) : 0, - 4, /* want GLfloat[4] */ - writeable, - &is_writeable); - - inputs->Attribs[index].data = (GLfloat (*)[4]) tmp->Ptr; - inputs->Attribs[index].start = (GLfloat *) tmp->Ptr; - inputs->Attribs[index].stride = tmp->StrideB; - inputs->Attribs[index].size = tmp->Size; - inputs->Attribs[index].flags &= ~(VEC_BAD_STRIDE|VEC_NOT_WRITEABLE); - if (inputs->Attribs[index].stride != 4 * sizeof(GLfloat)) - inputs->Attribs[index].flags |= VEC_BAD_STRIDE; - if (!is_writeable) - inputs->Attribs[index].flags |= VEC_NOT_WRITEABLE; + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + VB->Attrib[index] = _ac_import_attrib(ctx, index, GL_FLOAT, + 0, + 4, /* want GLfloat[4]??? */ + 0, + 0); } @@ -262,22 +145,11 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; - GLuint inputs = tnl->pipeline.inputs; - struct vertex_arrays *tmp = &tnl->array_inputs; - -/* _mesa_debug(ctx, "%s %d..%d // %d..%d\n", __FUNCTION__, */ -/* start, count, ctx->Array.LockFirst, ctx->Array.LockCount); */ -/* _tnl_print_vert_flags(" inputs", inputs); */ -/* _tnl_print_vert_flags(" _Enabled", ctx->Array._Enabled); */ + const GLuint *inputs = tnl->pipeline.inputs; VB->Count = count - start; VB->FirstClipped = VB->Count; VB->Elts = NULL; - VB->MaterialMask = NULL; - VB->Material = NULL; - VB->Flag = NULL; - VB->Primitive = tnl->tmp_primitive; - VB->PrimitiveLength = tnl->tmp_primitive_length; if (ctx->Array.LockCount) { ASSERT(start == (GLint) ctx->Array.LockFirst); @@ -286,75 +158,45 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLsizei count ) _ac_import_range( ctx, start, count ); - if (inputs & VERT_BIT_POS) { + if (TEST_BIT(inputs, VERT_ATTRIB_POS)) _tnl_import_vertex( ctx, 0, 0 ); - tmp->Attribs[VERT_ATTRIB_POS].count = VB->Count; - VB->AttribPtr[VERT_ATTRIB_POS] = &tmp->Obj; - } - if (inputs & VERT_BIT_NORMAL) { + if (TEST_BIT(inputs, VERT_ATTRIB_NORMAL)) _tnl_import_normal( ctx, 0, 0 ); - tmp->Attribs[VERT_ATTRIB_NORMAL].count = VB->Count; - VB->AttribPtr[VERT_ATTRIB_NORMAL] = &tmp->Attribs[VERT_ATTRIB_NORMAL]; - } - if (inputs & VERT_BIT_COLOR0) { + /* XXX: For colormaterial, should bind incoming color to *material* + * attributes, not color. + */ + if (TEST_BIT(inputs, VERT_ATTRIB_COLOR0)) _tnl_import_color( ctx, 0, 0, 0 ); - VB->AttribPtr[VERT_ATTRIB_COLOR0] = &tmp->Attribs[VERT_ATTRIB_COLOR0]; - VB->AttribPtr[VERT_ATTRIB_BACK_COLOR0] = 0; - } - if (inputs & VERT_BITS_TEX_ANY) { + { GLuint unit; - for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { - if (inputs & VERT_BIT_TEX(unit)) { - _tnl_import_texcoord( ctx, unit, GL_FALSE, GL_FALSE ); - tmp->Attribs[VERT_ATTRIB_TEX0+unit].count = VB->Count; - VB->AttribPtr[VERT_ATTRIB_TEX0+unit] = - &tmp->Attribs[VERT_ATTRIB_TEX0+unit]; - } - } + for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) + if (TEST_BIT(inputs, (VERT_ATTRIB_TEX0+unit))) + _tnl_import_texcoord( ctx, unit, 0, 0 ); } - if (inputs & (VERT_BIT_INDEX | VERT_BIT_FOG | - VERT_BIT_EDGEFLAG | VERT_BIT_COLOR1)) { - if (inputs & VERT_BIT_INDEX) { - _tnl_import_index( ctx, 0, 0 ); - tmp->Index.count = VB->Count; - VB->IndexPtr[0] = &tmp->Index; - VB->IndexPtr[1] = 0; - } - - if (inputs & VERT_BIT_EDGEFLAG) { - _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) ); - VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag.data; - } - - - if (inputs & VERT_BIT_FOG) { - _tnl_import_fogcoord( ctx, 0, 0 ); - tmp->Attribs[VERT_ATTRIB_FOG].count = VB->Count; - VB->AttribPtr[VERT_ATTRIB_FOG] = &tmp->Attribs[VERT_ATTRIB_FOG]; - } - - if (inputs & VERT_BIT_COLOR1) { - _tnl_import_secondarycolor( ctx, 0, 0, 0 ); - tmp->Attribs[VERT_ATTRIB_COLOR1].count = VB->Count; - VB->AttribPtr[VERT_ATTRIB_COLOR1] = &tmp->Attribs[VERT_ATTRIB_COLOR1]; - VB->AttribPtr[VERT_ATTRIB_BACK_COLOR1] = 0; - } - } + if (TEST_BIT(inputs, VERT_ATTRIB_INDEX)) + _tnl_import_index( ctx, 0, 0 ); + + if (TEST_BIT(inputs, VERT_ATTRIB_EDGEFLAG)) + _tnl_import_edgeflag( ctx, 0, 0 ); + + if (TEST_BIT(inputs, VERT_ATTRIB_FOG)) + _tnl_import_fogcoord( ctx, 0, 0 ); + + if (TEST_BIT(inputs, VERT_BIT_COLOR1)) + _tnl_import_secondarycolor( ctx, 0, 0, 0 ); /* If vertex programs are enabled, vertex-attrib arrays override * the old type arrays, where enabled. + * + * XXX check program->InputsRead to reduce work here */ if (ctx->VertexProgram.Enabled) { GLuint index; - for (index = 0; index < VERT_ATTRIB_MAX; index++) { - /* XXX check program->InputsRead to reduce work here */ - _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE ); - VB->AttribPtr[index].count = VB->Count; - VB->AttribPtr[index] = &tmp->Attribs[index]; - } + for (index = 0; index < VERT_ATTRIB_MAX; index++) + _tnl_import_attrib( ctx, index, 0, 0 ); } } diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c index 2aa72c7aee..5036301527 100644 --- a/src/mesa/tnl/t_context.c +++ b/src/mesa/tnl/t_context.c @@ -1,4 +1,4 @@ -/* $Id: t_context.c,v 1.28 2002/08/21 13:05:37 brianp Exp $ */ +/* $Id: t_context.c,v 1.28.2.1 2002/11/19 12:01:29 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -34,15 +34,11 @@ #include "mem.h" #include "dlist.h" #include "light.h" -#include "vtxfmt.h" #include "t_context.h" #include "t_array_api.h" #include "t_eval_api.h" -#include "t_imm_alloc.h" -#include "t_imm_api.h" -#include "t_imm_exec.h" -#include "t_imm_dlist.h" +#include "t_vtx_api.h" #include "t_pipeline.h" #include "tnl.h" @@ -65,12 +61,12 @@ _tnl_MakeCurrent( GLcontext *ctx, static void install_driver_callbacks( GLcontext *ctx ) { - ctx->Driver.NewList = _tnl_NewList; - ctx->Driver.EndList = _tnl_EndList; - ctx->Driver.FlushVertices = _tnl_flush_vertices; + ctx->Driver.NewList = _tnl_NewList; + ctx->Driver.EndList = _tnl_EndList; + ctx->Driver.FlushVertices = _tnl_FlushVertices; ctx->Driver.MakeCurrent = _tnl_MakeCurrent; - ctx->Driver.BeginCallList = _tnl_BeginCallList; - ctx->Driver.EndCallList = _tnl_EndCallList; + ctx->Driver.BeginCallList = _tnl_BeginCallList; + ctx->Driver.EndCallList = _tnl_EndCallList; } @@ -90,8 +86,7 @@ _tnl_CreateContext( GLcontext *ctx ) /* Initialize the VB. */ - tnl->vb.Size = MAX2( IMM_SIZE, - ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES); + tnl->vb.Size = ctx->Const.MaxArrayLockSize; /* Initialize tnl state and tnl->vtxfmt. @@ -104,20 +99,18 @@ _tnl_CreateContext( GLcontext *ctx ) tnl->NeedNdcCoords = GL_TRUE; - tnl->LoopbackDListCassettes = GL_FALSE; - tnl->CalcDListNormalLengths = GL_TRUE; /* Hook our functions into exec and compile dispatch tables. */ - _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); +/* _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); */ - tnl->save_vtxfmt = tnl->vtxfmt; - tnl->save_vtxfmt.CallList = _mesa_save_CallList; - tnl->save_vtxfmt.EvalMesh1 = _mesa_save_EvalMesh1; - tnl->save_vtxfmt.EvalMesh2 = _mesa_save_EvalMesh2; - tnl->save_vtxfmt.Begin = _tnl_save_Begin; +/* tnl->save_vtxfmt = tnl->vtxfmt; */ +/* tnl->save_vtxfmt.CallList = _mesa_save_CallList; */ +/* tnl->save_vtxfmt.EvalMesh1 = _mesa_save_EvalMesh1; */ +/* tnl->save_vtxfmt.EvalMesh2 = _mesa_save_EvalMesh2; */ +/* tnl->save_vtxfmt.Begin = _tnl_save_Begin; */ - _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); +/* _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); */ /* Set a few default values in the driver struct. @@ -145,7 +138,6 @@ _tnl_DestroyContext( GLcontext *ctx ) _tnl_array_destroy( ctx ); _tnl_imm_destroy( ctx ); _tnl_destroy_pipeline( ctx ); - _tnl_free_immediate( ctx, tnl->freed_immediate ); FREE(tnl); ctx->swtnl_context = 0; @@ -158,12 +150,7 @@ _tnl_InvalidateState( GLcontext *ctx, GLuint new_state ) TNLcontext *tnl = TNL_CONTEXT(ctx); if (new_state & _NEW_ARRAY) { - struct immediate *IM = TNL_CURRENT_IM(ctx); - IM->ArrayEltFlags = ~ctx->Array._Enabled; - IM->ArrayEltFlush = (ctx->Array.LockCount - ? FLUSH_ELT_LAZY : FLUSH_ELT_EAGER); - IM->ArrayEltIncr = ctx->Array.Vertex.Enabled ? 1 : 0; - tnl->pipeline.run_input_changes |= ctx->Array.NewState; /* overkill */ + tnl->pipeline.run_input_changes[0] |= ctx->Array.NewState; } tnl->pipeline.run_state_changes |= new_state; @@ -184,7 +171,7 @@ _tnl_wakeup_exec( GLcontext *ctx ) /* Hook our functions into exec and compile dispatch tables. */ - _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); +/* _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); */ /* Call all appropriate driver callbacks to revive state. */ @@ -193,7 +180,8 @@ _tnl_wakeup_exec( GLcontext *ctx ) /* Assume we haven't been getting state updates either: */ _tnl_InvalidateState( ctx, ~0 ); - tnl->pipeline.run_input_changes = ~0; + tnl->pipeline.run_input_changes[0] = ~0; + tnl->pipeline.run_input_changes[1] = ~0; if (ctx->Light.ColorMaterialEnabled) { _mesa_update_color_material( ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0] ); @@ -205,10 +193,10 @@ _tnl_wakeup_exec( GLcontext *ctx ) void _tnl_wakeup_save_exec( GLcontext *ctx ) { - TNLcontext *tnl = TNL_CONTEXT(ctx); +/* TNLcontext *tnl = TNL_CONTEXT(ctx); */ _tnl_wakeup_exec( ctx ); - _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); +/* _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt ); */ } @@ -225,15 +213,15 @@ _tnl_need_projected_coords( GLcontext *ctx, GLboolean mode ) void _tnl_need_dlist_loopback( GLcontext *ctx, GLboolean mode ) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->LoopbackDListCassettes = mode; +/* TNLcontext *tnl = TNL_CONTEXT(ctx); */ +/* tnl->LoopbackDListCassettes = mode; */ } void _tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean mode ) { - TNLcontext *tnl = TNL_CONTEXT(ctx); - tnl->CalcDListNormalLengths = mode; +/* TNLcontext *tnl = TNL_CONTEXT(ctx); */ +/* tnl->CalcDListNormalLengths = mode; */ } void diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index beab24abb6..0ee194a085 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.43.2.2 2002/10/17 14:26:37 keithw Exp $ */ +/* $Id: t_context.h,v 1.43.2.3 2002/11/19 12:01:29 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -36,9 +36,6 @@ #include "glheader.h" #include "mtypes.h" -#include "math/m_matrix.h" -#include "math/m_vector.h" -#include "math/m_xform.h" #define MAX_PIPELINE_STAGES 30 @@ -49,30 +46,35 @@ * defining the VERT_BIT equivalents as we have to use 2 32bit bitsets * to talk about these now. */ -#define VERT_ATTRIB_INDEX 16 /* not naturally a float */ -#define VERT_ATTRIB_EDGEFLAG 17 /* not naturally a float */ -#define VERT_ATTRIB_POINTSIZE 18 -#define VERT_ATTRIB_MAT_FRONT_AMBIENT 19 -#define VERT_ATTRIB_MAT_FRONT_DIFFUSE 20 -#define VERT_ATTRIB_MAT_FRONT_SPECULAR 21 -#define VERT_ATTRIB_MAT_FRONT_EMISSION 22 -#define VERT_ATTRIB_MAT_FRONT_SHININESS 23 -#define VERT_ATTRIB_MAT_FRONT_INDEXES 24 -#define VERT_ATTRIB_MAT_BACK_AMBIENT 25 -#define VERT_ATTRIB_MAT_BACK_DIFFUSE 26 -#define VERT_ATTRIB_MAT_BACK_SPECULAR 27 -#define VERT_ATTRIB_MAT_BACK_EMISSION 28 -#define VERT_ATTRIB_MAT_BACK_SHININESS 29 -#define VERT_ATTRIB_MAT_BACK_INDEXES 30 +#define VERT_ATTRIB_MAT_FRONT_AMBIENT (MAT_ATTRIB_FRONT_AMBIENT+16) +#define VERT_ATTRIB_MAT_FRONT_DIFFUSE (MAT_ATTRIB_FRONT_DIFFUSE+16) +#define VERT_ATTRIB_MAT_FRONT_SPECULAR (MAT_ATTRIB_FRONT_SPECULAR+16) +#define VERT_ATTRIB_MAT_FRONT_EMISSION (MAT_ATTRIB_FRONT_EMISSION+16) +#define VERT_ATTRIB_MAT_FRONT_SHININESS (MAT_ATTRIB_FRONT_SHININESS+16) +#define VERT_ATTRIB_MAT_FRONT_INDEXES (MAT_ATTRIB_FRONT_INDEXES+16) +#define VERT_ATTRIB_MAT_BACK_AMBIENT (MAT_ATTRIB_BACK_AMBIENT+16) +#define VERT_ATTRIB_MAT_BACK_DIFFUSE (MAT_ATTRIB_BACK_DIFFUSE+16) +#define VERT_ATTRIB_MAT_BACK_SPECULAR (MAT_ATTRIB_BACK_SPECULAR+16) +#define VERT_ATTRIB_MAT_BACK_EMISSION (MAT_ATTRIB_BACK_EMISSION+16) +#define VERT_ATTRIB_MAT_BACK_SHININESS (MAT_ATTRIB_BACK_SHININESS+16) +#define VERT_ATTRIB_MAT_BACK_INDEXES (MAT_ATTRIB_BACK_INDEXES+16) +#define VERT_ATTRIB_INDEX 28 /* not naturally a float */ +#define VERT_ATTRIB_EDGEFLAG 29 /* not naturally a float */ +#define VERT_ATTRIB_POINTSIZE 30 #define VERT_ATTRIB_BACK_COLOR0 31 #define VERT_ATTRIB_BACK_COLOR1 32 -#define VERT_ATTRIB_BACK_INDEX 33 +#define VERT_ATTRIB_BACK_INDEX 33 /* not naturally a float */ +#define TNL_ATTRIB_MAX 34 #define TEST_BIT( bset, bit ) (bset[bit/32] & (1<<(bit&31))) #define SET_BIT( bset, bit ) (bset[bit/32] |= (1<<(bit&31))) #define CLEAR_BIT( bset, bit ) (bset[bit/32] &= ~(1<<(bit&31))) +#define TNL_EVAL_COORD1 0x1 +#define TNL_EVAL_COORD2 0x2 +#define TNL_EVAL_POINT1 0x4 +#define TNL_EVAL_POINT2 0x8 /* Numbers for sizing immediate structs. @@ -85,12 +87,17 @@ struct vertex_block { GLuint refcount; - GLuint vertex_format[4]; + GLuint vertex_format[2]; GLuint vertex_size; GLuint block_size; GLubyte verts[1]; -} +}; + +#define PRIM_MODE_MASK 0xff /* Extract the actual primitive */ +#define PRIM_BEGIN 0x100 /* The prim starts here (not wrapped) */ +#define PRIM_END 0x200 /* The prim ends in this VB (does not wrap) */ +#define PRIM_PARITY 0x400 /* The prim wrapped on an odd number of verts */ struct tnl_prim { @@ -100,11 +107,10 @@ struct tnl_prim }; - /** * Contains the current state of a running pipeline. */ -typedef struct vertex_buffer +struct vertex_buffer { /* Constant over life of the vertex_buffer. */ @@ -114,22 +120,21 @@ typedef struct vertex_buffer */ GLuint Count; /* for everything except Elts */ GLuint FirstClipped; /* temp verts for clipping */ - GLuint FirstPrimitive; /* usually zero */ /* Pointers to current data. */ - GLuint *Elts; - GLvector4f *EyePtr; - GLvector4f *ClipPtr; - GLvector4f *NdcPtr; - GLubyte *ClipMask; - GLfloat *NormalLengthPtr; - GLvector4f *PointSizePtr; /* why not just a float *? */ + GLuint *Elts; + struct gl_client_array *EyePtr; + struct gl_client_array *ClipPtr; + struct gl_client_array *NdcPtr; + GLubyte *ClipMask; + GLfloat *NormalLengthPtr; + struct gl_client_array *PointSizePtr; /* why not just a float *? */ struct tnl_prim *Primitive; /* primitive descriptors */ - GLuint nrPrimitives; /* nr */ + GLuint NrPrimitives; /* nr */ - GLvector4f *AttribPtr[TNL_ATTRIB_MAX]; + struct gl_client_array *Attrib[TNL_ATTRIB_MAX]; /* All other vertex data. Edgeflag & Index are included in here as * float arrays. This may have to change later. */ @@ -143,13 +148,13 @@ typedef struct vertex_buffer * in this struct. */ -} TNLvertexbuffer; +}; /* Describes an individual operation on the pipeline. */ -struct gl_pipeline_stage { +struct tnl_pipeline_stage { const char *name; GLuint check_state; /* All state referenced in check() -- * When is the pipeline_stage struct @@ -181,12 +186,12 @@ struct gl_pipeline_stage { /* Free private data. May not be null. */ - void (*destroy)( struct gl_pipeline_stage * ); + void (*destroy)( struct tnl_pipeline_stage * ); /* Called from _tnl_validate_pipeline(). Must update all fields in * the pipeline_stage struct for the current state. */ - void (*check)( GLcontext *ctx, struct gl_pipeline_stage * ); + void (*check)( GLcontext *ctx, struct tnl_pipeline_stage * ); /* Called from _tnl_run_pipeline(). The stage.changed_inputs value * encodes all inputs to thee struct which have changed. If @@ -196,17 +201,17 @@ struct gl_pipeline_stage { * Return value: GL_TRUE - keep going * GL_FALSE - finished pipeline */ - GLboolean (*run)( GLcontext *ctx, struct gl_pipeline_stage * ); + GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * ); }; -struct gl_pipeline { +struct tnl_pipeline { GLuint build_state_trigger; /* state changes which require build */ GLuint build_state_changes; /* state changes since last build */ GLuint run_state_changes; /* state changes since last run */ GLuint run_input_changes[2]; /* VERT_* changes since last run */ GLuint inputs[2]; /* VERT_* inputs to pipeline */ - struct gl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; + struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; GLuint nr_stages; }; @@ -333,6 +338,64 @@ struct tnl_device_driver { */ } Render; }; + +union uif { GLuint ui; GLfloat f; }; + +/* Want to keep a cache of these around. Each is parameterized by + * only a single value which has only a small range. Only expect a + * few, so just rescan the list each time? + */ +struct dynfn { + struct dynfn *next, *prev; + int key; + char *code; +}; + +#define TNL_BEGIN 0x0 +#define TNL_END 0x1 +#define TNL_BE_MAX 3 /* XXX */ + +struct tnl_vtx { + int initial_counter; + int counter; /* nr of vertices */ + int vertex_size; + union uif *vbstart; /* built vertices */ + union uif *vbptr; /* built vertices */ + union uif *attrptr[TNL_ATTRIB_MAX]; /* pointers into vertex below */ + union uif vertex[TNL_ATTRIB_MAX*4]; /* current vertex */ + + GLubyte attrib_sz[TNL_ATTRIB_MAX]; + + struct dynfn *generated[4][2][2]; /* chains of generated functions + * could use a hash also. + */ + + struct dynfn *(*codegen[4][2][2])( GLcontext *ctx, int key ); + + + /* Second level dispatch table for MultiTexCoord, Material and + * VertexAttribNV. + * + * Need this because we want to track things like vertex attribute + * sizes, presence/otherwise of attribs in recorded vertices, etc, by + * manipulating the state of dispatch tables. Need therefore a + * dispatch slot for each value of 'index' or 'unit' in VertexAttribNV + * and MultiTexCoordARB. Also need a mechnism for keeping this data + * consistent with what's coming in via the Vertex/Normal/etc api + * above (where aliasing exists with the traditional entrypoints). + * Note that MultiTexCoordARB aliases with TexCoord when unit==0. + * + * Need presence tracking for material components, too, but not size + * tracking or help with aliasing. Could move material to seperate + * dispatch without the "*4" below, or even do the checks every time. + */ + void (*tabfv[4][TNL_ATTRIB_MAX])( const GLfloat * ); + + /* Build a list of begins and ends. + */ + struct { GLint type; GLint idx; GLenum mode; } be[TNL_BE_MAX]; + GLint be_count; +}; typedef struct { @@ -340,6 +403,10 @@ typedef struct { /* Driver interface. */ struct tnl_device_driver Driver; + + /* Support for vertex assembly from begin/end objects: + */ + struct tnl_vtx vtx; /* Track whether the module is active. */ @@ -348,33 +415,15 @@ typedef struct { /* Display list extensions */ GLuint opcode_vertex_block; - GLuint opcode_begin; - GLuint opcode_end; /* Pipeline */ - struct gl_pipeline pipeline; + struct tnl_pipeline pipeline; struct vertex_buffer vb; - /* GLvectors for binding to vb: - */ - struct vertex_arrays imm_inputs; - struct vertex_arrays array_inputs; - - /* Note which vertices need copying over succesive immediates. - * Will add save versions to precompute vertex copying where - * possible. - */ - struct vertex_block *ExecCopySource; - GLuint ExecCopyCount; - GLuint ExecCopyElts[IMM_MAX_COPIED_VERTS]; - GLuint ExecParity; - /* Probably need a better configuration mechanism: */ GLboolean NeedNdcCoords; - GLboolean LoopbackDListCassettes; - GLboolean CalcDListNormalLengths; GLboolean IsolateMaterials; /* Derived state and storage for _tnl_eval_vb: diff --git a/src/mesa/tnl/t_eval_api.c b/src/mesa/tnl/t_eval_api.c index 91592c9823..0f4fafdeec 100644 --- a/src/mesa/tnl/t_eval_api.c +++ b/src/mesa/tnl/t_eval_api.c @@ -1,4 +1,4 @@ -/* $Id: t_eval_api.c,v 1.11 2002/06/23 02:36:27 brianp Exp $ */ +/* $Id: t_eval_api.c,v 1.11.2.1 2002/11/19 12:01:29 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -39,9 +39,6 @@ #include "math/m_eval.h" #include "t_eval_api.h" -#include "t_imm_api.h" -#include "t_imm_alloc.h" -#include "t_imm_exec.h" /* KW: If are compiling, we don't know whether eval will produce a @@ -103,37 +100,22 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) */ { GLboolean compiling = ctx->CompileFlag; - TNLcontext *tnl = TNL_CONTEXT(ctx); - struct immediate *im = TNL_CURRENT_IM(ctx); - GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p); - - NotifyBegin = tnl->Driver.NotifyBegin; - tnl->Driver.NotifyBegin = 0; if (compiling) { - struct immediate *tmp = _tnl_alloc_immediate( ctx ); - FLUSH_VERTICES( ctx, 0 ); - SET_IMMEDIATE( ctx, tmp ); - TNL_CURRENT_IM(ctx)->ref_count++; - ctx->CompileFlag = GL_FALSE; + assert(0); } - _tnl_Begin( prim ); + glBegin( prim ); for (i=i1;i<=i2;i++,u+=du) { - _tnl_eval_coord1f( ctx, u ); + glEvalCoord1f( u ); } - _tnl_end(ctx); + glEnd(); /* Need this for replay *and* compile: */ FLUSH_VERTICES( ctx, 0 ); - tnl->Driver.NotifyBegin = NotifyBegin; if (compiling) { - TNL_CURRENT_IM(ctx)->ref_count--; - ASSERT( TNL_CURRENT_IM(ctx)->ref_count == 0 ); - _tnl_free_immediate( ctx, TNL_CURRENT_IM(ctx) ); - SET_IMMEDIATE( ctx, im ); ctx->CompileFlag = GL_TRUE; } } @@ -169,55 +151,46 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) */ { GLboolean compiling = ctx->CompileFlag; - struct immediate *im = TNL_CURRENT_IM(ctx); - TNLcontext *tnl = TNL_CONTEXT(ctx); - GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p); - - NotifyBegin = tnl->Driver.NotifyBegin; - tnl->Driver.NotifyBegin = 0; if (compiling) { - struct immediate *tmp = _tnl_alloc_immediate( ctx ); - FLUSH_VERTICES( ctx, 0 ); - SET_IMMEDIATE( ctx, tmp ); - TNL_CURRENT_IM(ctx)->ref_count++; + assert(0); ctx->CompileFlag = GL_FALSE; } switch (mode) { case GL_POINT: - _tnl_Begin( GL_POINTS ); + glBegin( GL_POINTS ); for (v=v1,j=j1;j<=j2;j++,v+=dv) { for (u=u1,i=i1;i<=i2;i++,u+=du) { - _tnl_eval_coord2f( ctx, u, v ); + glEvalCoord2f( u, v ); } } - _tnl_end(ctx); + glEnd(); break; case GL_LINE: for (v=v1,j=j1;j<=j2;j++,v+=dv) { - _tnl_Begin( GL_LINE_STRIP ); + glBegin( GL_LINE_STRIP ); for (u=u1,i=i1;i<=i2;i++,u+=du) { - _tnl_eval_coord2f( ctx, u, v ); + glEvalCoord2f( u, v ); } - _tnl_end(ctx); + glEnd(); } for (u=u1,i=i1;i<=i2;i++,u+=du) { - _tnl_Begin( GL_LINE_STRIP ); + glBegin( GL_LINE_STRIP ); for (v=v1,j=j1;j<=j2;j++,v+=dv) { - _tnl_eval_coord2f( ctx, u, v ); + glEvalCoord2f( u, v ); } - _tnl_end(ctx); + glEnd(); } break; case GL_FILL: for (v=v1,j=j1;j<j2;j++,v+=dv) { - _tnl_Begin( GL_TRIANGLE_STRIP ); + glBegin( GL_TRIANGLE_STRIP ); for (u=u1,i=i1;i<=i2;i++,u+=du) { - _tnl_eval_coord2f( ctx, u, v ); - _tnl_eval_coord2f( ctx, u, v+dv ); + glEvalCoord2f( u, v ); + glEvalCoord2f( u, v+dv ); } - _tnl_end(ctx); + glEnd(); } break; default: @@ -228,12 +201,8 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) /* Need this for replay *and* compile: */ FLUSH_VERTICES( ctx, 0 ); - tnl->Driver.NotifyBegin = NotifyBegin; if (compiling) { - TNL_CURRENT_IM(ctx)->ref_count--; - _tnl_free_immediate( ctx, TNL_CURRENT_IM( ctx ) ); - SET_IMMEDIATE( ctx, im ); ctx->CompileFlag = GL_TRUE; } } @@ -242,7 +211,8 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) void _tnl_eval_init( GLcontext *ctx ) { - GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->vtxfmt); - vfmt->EvalMesh1 = _tnl_exec_EvalMesh1; - vfmt->EvalMesh2 = _tnl_exec_EvalMesh2; + struct _glapi_table *exec = TNL_CONTEXT(ctx)->Exec; + + exec->EvalMesh1 = _tnl_exec_EvalMesh1; + exec->EvalMesh2 = _tnl_exec_EvalMesh2; } diff --git a/src/mesa/tnl/t_pipeline.h b/src/mesa/tnl/t_pipeline.h index 6138df32d5..9ff480fa0d 100644 --- a/src/mesa/tnl/t_pipeline.h +++ b/src/mesa/tnl/t_pipeline.h @@ -1,4 +1,4 @@ -/* $Id: t_pipeline.h,v 1.9 2001/12/14 02:51:45 brianp Exp $ */ +/* $Id: t_pipeline.h,v 1.9.2.1 2002/11/19 12:01:29 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -42,24 +42,24 @@ extern void _tnl_validate_pipeline( GLcontext *ctx ); extern void _tnl_destroy_pipeline( GLcontext *ctx ); extern void _tnl_install_pipeline( GLcontext *ctx, - const struct gl_pipeline_stage **stages ); + const struct tnl_pipeline_stage **stages ); /* These are implemented in the t_vb_*.c files: */ -extern const struct gl_pipeline_stage _tnl_vertex_transform_stage; -extern const struct gl_pipeline_stage _tnl_normal_transform_stage; -extern const struct gl_pipeline_stage _tnl_lighting_stage; -extern const struct gl_pipeline_stage _tnl_fog_coordinate_stage; -extern const struct gl_pipeline_stage _tnl_texgen_stage; -extern const struct gl_pipeline_stage _tnl_texture_transform_stage; -extern const struct gl_pipeline_stage _tnl_point_attenuation_stage; -extern const struct gl_pipeline_stage _tnl_vertex_program_stage; -extern const struct gl_pipeline_stage _tnl_render_stage; +extern const struct tnl_pipeline_stage _tnl_vertex_transform_stage; +extern const struct tnl_pipeline_stage _tnl_normal_transform_stage; +extern const struct tnl_pipeline_stage _tnl_lighting_stage; +extern const struct tnl_pipeline_stage _tnl_fog_coordinate_stage; +extern const struct tnl_pipeline_stage _tnl_texgen_stage; +extern const struct tnl_pipeline_stage _tnl_texture_transform_stage; +extern const struct tnl_pipeline_stage _tnl_point_attenuation_stage; +extern const struct tnl_pipeline_stage _tnl_vertex_program_stage; +extern const struct tnl_pipeline_stage _tnl_render_stage; /* Shorthand to plug in the default pipeline: */ -extern const struct gl_pipeline_stage *_tnl_default_pipeline[]; +extern const struct tnl_pipeline_stage *_tnl_default_pipeline[]; /* Convenience routines provided by t_vb_render.c: diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index f99f8d2251..91290239ff 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -1,4 +1,4 @@ -/* $Id: t_vb_program.c,v 1.14.2.2 2002/10/17 14:26:37 keithw Exp $ */ +/* $Id: t_vb_program.c,v 1.14.2.3 2002/11/19 12:01:29 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -160,20 +160,20 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) #if 0 printf("Input %d: %f, %f, %f, %f\n", i, - VB->AttribPtr[0]->data[i][0], - VB->AttribPtr[0]->data[i][1], - VB->AttribPtr[0]->data[i][2], - VB->AttribPtr[0]->data[i][3]); + VB->Attrib[0]->data[i][0], + VB->Attrib[0]->data[i][1], + VB->Attrib[0]->data[i][2], + VB->Attrib[0]->data[i][3]); printf(" color: %f, %f, %f, %f\n", - VB->AttribPtr[3]->data[i][0], - VB->AttribPtr[3]->data[i][1], - VB->AttribPtr[3]->data[i][2], - VB->AttribPtr[3]->data[i][3]); + VB->Attrib[3]->data[i][0], + VB->Attrib[3]->data[i][1], + VB->Attrib[3]->data[i][2], + VB->Attrib[3]->data[i][3]); printf(" normal: %f, %f, %f, %f\n", - VB->AttribPtr[2]->data[i][0], - VB->AttribPtr[2]->data[i][1], - VB->AttribPtr[2]->data[i][2], - VB->AttribPtr[2]->data[i][3]); + VB->Attrib[2]->data[i][0], + VB->Attrib[2]->data[i][1], + VB->Attrib[2]->data[i][2], + VB->Attrib[2]->data[i][3]); #endif /* load the input attribute registers */ @@ -182,7 +182,7 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { if (VB->Flag[i] & (1 << attr)) { COPY_4V(machine->Registers[VP_INPUT_REG_START + attr], - VB->AttribPtr[attr]->data[i]); + VB->Attrib[attr]->data[i]); } } } @@ -190,11 +190,11 @@ static GLboolean run_vp( GLcontext *ctx, struct gl_pipeline_stage *stage ) /* the vertex array case */ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) { if (program->InputsRead & (1 << attr)) { - const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data; - const GLuint stride = VB->AttribPtr[attr]->stride; + const GLubyte *ptr = (const GLubyte*) VB->Attrib[attr]->data; + const GLuint stride = VB->Attrib[attr]->stride; const GLfloat *data = (GLfloat *) (ptr + stride * i); COPY_4V(machine->Registers[VP_INPUT_REG_START + attr], data); - /*ASSERT(VB->AttribPtr[attr]->size == 4);*/ + /*ASSERT(VB->Attrib[attr]->size == 4);*/ ASSERT(stride == 4 * sizeof(GLfloat) || stride == 0); } } diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c index 936197699f..4338978056 100644 --- a/src/mesa/tnl/t_vtx_api.c +++ b/src/mesa/tnl/t_vtx_api.c @@ -31,8 +31,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Keith Whitwell <keith@tungstengraphics.com> */ #include "mtypes.h" +#include "context.h" #include "colormac.h" #include "simple_list.h" +#include "api_arrayelt.h" #include "t_context.h" #include "t_vtx_api.h" @@ -49,40 +51,40 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * is the job of the chooser function when switching between Color4f * and Color3f. */ -#define ATTRF( ATTR, N, A, B, C, D ) \ -{ \ - GET_CURRENT_CONTEXT( ctx ); \ - TNLcontext *tnl = TNL_CONTEXT(ctx); \ - \ - if ((ATTR) == 0) { \ - int i; \ - \ - if (N>0) tnl->vbptr[0].f = A; \ - if (N>1) tnl->vbptr[1].f = B; \ - if (N>2) tnl->vbptr[2].f = C; \ - if (N>3) tnl->vbptr[3].f = D; \ - \ - for (i = N; i < tnl->vertex_size; i++) \ - *tnl->vbptr[i].i = tnl->vertex[i].i; \ - \ - tnl->vbptr += tnl->vertex_size; \ - \ - if (--tnl->counter == 0) \ - tnl->notify(); \ - } \ - else { \ - GLfloat *dest = tnl->attrptr[ATTR]; \ - if (N>0) dest[0] = A; \ - if (N>1) dest[1] = B; \ - if (N>2) dest[2] = C; \ - if (N>3) dest[3] = D; \ - } \ +#define ATTRF( ATTR, N, A, B, C, D ) \ +{ \ + GET_CURRENT_CONTEXT( ctx ); \ + TNLcontext *tnl = TNL_CONTEXT(ctx); \ + \ + if ((ATTR) == 0) { \ + int i; \ + \ + if (N>0) tnl->vtx.vbptr[0].f = A; \ + if (N>1) tnl->vtx.vbptr[1].f = B; \ + if (N>2) tnl->vtx.vbptr[2].f = C; \ + if (N>3) tnl->vtx.vbptr[3].f = D; \ + \ + for (i = N; i < tnl->vtx.vertex_size; i++) \ + tnl->vtx.vbptr[i].ui = tnl->vtx.vertex[i].ui; \ + \ + tnl->vtx.vbptr += tnl->vtx.vertex_size; \ + \ + if (--tnl->vtx.counter == 0) \ + _tnl_FlushVertices( ctx, FLUSH_STORED_VERTICES ); \ + } \ + else { \ + union uif *dest = tnl->vtx.attrptr[ATTR]; \ + if (N>0) dest[0].f = A; \ + if (N>1) dest[1].f = B; \ + if (N>2) dest[2].f = C; \ + if (N>3) dest[3].f = D; \ + } \ } #define ATTR4F( ATTR, A, B, C, D ) ATTRF( ATTR, 4, A, B, C, D ) -#define ATTR3F( ATTR, A, B, C, D ) ATTRF( ATTR, 3, A, B, C, 1 ) -#define ATTR2F( ATTR, A, B, C, D ) ATTRF( ATTR, 2, A, B, 0, 1 ) -#define ATTR1F( ATTR, A, B, C, D ) ATTRF( ATTR, 1, A, 0, 0, 1 ) +#define ATTR3F( ATTR, A, B, C ) ATTRF( ATTR, 3, A, B, C, 1 ) +#define ATTR2F( ATTR, A, B ) ATTRF( ATTR, 2, A, B, 0, 1 ) +#define ATTR1F( ATTR, A ) ATTRF( ATTR, 1, A, 0, 0, 1 ) #define ATTRS( ATTRIB ) \ static void attrib_##ATTRIB##_1_0( GLfloat s ) \ @@ -161,24 +163,24 @@ static float id[4] = { 0, 0, 0, 1 }; static void _tnl_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz ) { - if (tnl->vertex_present[ATTR] < SZ) { - tnl_upgrade_vertex( tnl, ATTR, SZ ); + TNLcontext *tnl = TNL_CONTEXT(ctx); + + if (tnl->vtx.attrib_sz[attr] < sz) { + tnl_upgrade_vertex( tnl, attr, sz ); } else { int i; - - /* Just clean the bits that won't be touched otherwise: - */ - for (i = SZ ; i < tnl->vertex_present[ATTR] ; i++) - tnl->attrptr[ATTR][i] = id[i]; - - if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) { - _tnl_reset_attr_dispatch_tab( ctx ); - _mesa_install_exec_vtxfmt( ctx, &tnl->chooser ); - } + for (i = tnl->vtx.attrib_sz[attr] ; i < sz; i++) + tnl->vtx.attrptr[attr][i].f = id[i]; } + + /* Reset the dispatch table so that pingponging is noticed. + */ + _tnl_reset_attr_dispatch_tab( ctx ); } +static int dispatch_offset[TNL_ATTRIB_MAX][4][2]; + static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v, void *fallback_attr_func ) @@ -188,21 +190,22 @@ static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v, struct dynfn *dfn; void *ptr = 0; int isvertex = (attr == 0); + int key; /* This will remove any installed handlers for attr with different * sz, will flush, copy and expand the copied vertices if sz won't * fit in the current vertex, or will clean the current vertex if * it already has this attribute in a larger size. */ - if (tnl->vertex_active[attr] != sz) + if (tnl->vtx.attrib_sz[attr] != sz) tnl_fixup_vertex( ctx, attr, sz ); if (isvertex) - key = tnl->vertex_size; + key = tnl->vtx.vertex_size; else - key = (GLuint)tnl->attrptr[attr]; + key = (GLuint)tnl->vtx.attrptr[attr]; - for (dfn = tnl->generated[sz][v][isvertex] ; dfn ; dfn = dfn->next) { + for (dfn = tnl->vtx.generated[sz-1][v][isvertex] ; dfn ; dfn = dfn->next) { if (dfn->key == key) { ptr = dfn->code; break; @@ -210,11 +213,11 @@ static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v, } if (ptr == 0) { - dfn = tnl->codegen[sz][v][isvertex]( ctx, key ); + dfn = tnl->vtx.codegen[sz-1][v][isvertex]( ctx, key ); if (dfn) { ptr = dfn->code; - dfn->next = tnl->generated[sz][v][isvertex]; - tnl->generated[sz][v][isvertex] = dfn; + dfn->next = tnl->vtx.generated[sz-1][v][isvertex]; + tnl->vtx.generated[sz-1][v][isvertex] = dfn; } } @@ -223,8 +226,10 @@ static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v, ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; - if (dispatch_entry[attr][sz-1][v]) - ((void **)tnl->Exec)[dispatch_entry[attr][sz-1][v]] = ptr; + /* Need to set all the aliases to this function, too + */ + if (dispatch_offset[attr][sz-1][v]) + ((void **)tnl->Exec)[dispatch_offset[attr][sz-1][v]] = ptr; return ptr; } @@ -234,83 +239,75 @@ static void *lookup_or_generate( GLuint attr, GLuint sz, GLuint v, * codegen). Like the ATTR functions, they live in the GL dispatch * table and in the second-level dispatch table for MultiTexCoord, * AttribNV, etc. + * + * Need ATTR1 for use in constructing name of 'attrib_x_y_z' function. */ -#define CHOOSE( FNTYPE, ATTR, SZ, V, ARGS1, ARGS2 ) \ -static void choose_##ATTR##_##SZ##_##V ARGS1 \ +#define CHOOSE( ATTR1, ATTR2, SZ, V, FNTYPE, ARGS1, ARGS2 ) \ +static void choose_##ATTR2##_##SZ##_##V ARGS1 \ { \ - void *ptr = lookup_or_generate(ctx, ATTR, SZ, V, \ - attrib_##ATTR##_##SZ##_##V ); \ + void *ptr = lookup_or_generate(ATTR1, SZ, V, \ + (void *)attrib_##ATTR1##_##SZ##_##V ); \ \ - (FN_TYPE) ptr ARGS2; \ -} - -#define CHOOSERS( ATTR ) \ -CHOOSE( ATTR, 1, 1, pfv, (const GLfloat *v), (v)) \ -CHOOSE( ATTR, 2, 1, pfv, (const GLfloat *v), (v)) \ -CHOOSE( ATTR, 3, 1, pfv, (const GLfloat *v), (v)) \ -CHOOSE( ATTR, 4, 1, pfv, (const GLfloat *v), (v)) \ -CHOOSE( ATTR, 1, 0, p1f, (GLfloat a), (a)) \ -CHOOSE( ATTR, 2, 0, p2f, (GLfloat a, GLfloat b), (a,b)) \ -CHOOSE( ATTR, 3, 0, p3f, (GLfloat a, GLfloat b, GLfloat c), (a,b,c)) \ -CHOOSE( ATTR, 4, 0, p4f, (GLfloat a, GLfloat b, GLfloat c, GLfloat d), \ - (a,b,c,d)) - - -CHOOSERS( 0 ) -CHOOSERS( 1 ) -CHOOSERS( 2 ) -CHOOSERS( 3 ) -CHOOSERS( 4 ) -CHOOSERS( 5 ) -CHOOSERS( 6 ) -CHOOSERS( 7 ) -CHOOSERS( 8 ) -CHOOSERS( 9 ) -CHOOSERS( 10 ) -CHOOSERS( 11 ) -CHOOSERS( 12 ) -CHOOSERS( 13 ) -CHOOSERS( 14 ) -CHOOSERS( 15 ) - - -/* Second level dispatch table for MultiTexCoord, Material and - * VertexAttribNV. - * - * Need this because we want to track things like vertex attribute - * sizes, presence/otherwise of attribs in recorded vertices, etc, by - * manipulating the state of dispatch tables. Need therefore a - * dispatch slot for each value of 'index' or 'unit' in VertexAttribNV - * and MultiTexCoordARB. Also need a mechnism for keeping this data - * consistent with what's coming in via the Vertex/Normal/etc api - * above (where aliasing exists with the traditional entrypoints). - * Note that MultiTexCoordARB aliases with TexCoord when unit==0. - * - * Need presence tracking for material components, too, but not size - * tracking or help with aliasing. Could move material to seperate - * dispatch without the "*4" below, or even do the checks every time. - */ -struct attr_dispatch_tab { - void (*tabfv[4][32])( const GLfloat * ); + assert(ATTR1 == ATTR2); \ + ((FNTYPE) ptr) ARGS2; \ +} - int swapcount; - int installed; /* bitmap */ - int installed_sizes[32]; /* active sizes */ -}; +#define afv (const GLfloat *v) +#define a1f (GLfloat a) +#define a2f (GLfloat a, GLfloat b) +#define a3f (GLfloat a, GLfloat b, GLfloat c) +#define a4f (GLfloat a, GLfloat b, GLfloat c, GLfloat d) -#define DISPATCH_ATTRFV( ATTR, COUNT, P ) tnl->vb.tabfv[COUNT-1][ATTR]( P ) -#define DISPATCH_ATTR1FV( ATTR, V ) tnl->vb.tabfv[0][attr]( V ) -#define DISPATCH_ATTR2FV( ATTR, V ) tnl->vb.tabfv[1][attr]( V ) -#define DISPATCH_ATTR3FV( ATTR, V ) tnl->vb.tabfv[2][attr]( V ) -#define DISPATCH_ATTR4FV( ATTR, V ) tnl->vb.tabfv[3][attr]( V ) +/* Not that many entrypoints when it all boils down: + */ +CHOOSE( 0, VERT_ATTRIB_POS, 2, 1, pfv, afv, (v) ) +CHOOSE( 0, VERT_ATTRIB_POS, 2, 0, p2f, a2f, (a,b) ) +CHOOSE( 0, VERT_ATTRIB_POS, 3, 1, pfv, afv, (v) ) +CHOOSE( 0, VERT_ATTRIB_POS, 3, 0, p3f, a3f, (a,b,c) ) +CHOOSE( 0, VERT_ATTRIB_POS, 4, 1, pfv, afv, (v) ) +CHOOSE( 0, VERT_ATTRIB_POS, 4, 0, p4f, a4f, (a,b,c,d) ) +CHOOSE( 2, VERT_ATTRIB_NORMAL, 3, 1, pfv, afv, (v) ) +CHOOSE( 2, VERT_ATTRIB_NORMAL, 3, 0, p3f, a3f, (a,b,c) ) +CHOOSE( 3, VERT_ATTRIB_COLOR0, 3, 1, pfv, afv, (v) ) +CHOOSE( 3, VERT_ATTRIB_COLOR0, 3, 0, p3f, a3f, (a,b,c) ) +CHOOSE( 3, VERT_ATTRIB_COLOR0, 4, 1, pfv, afv, (v) ) +CHOOSE( 3, VERT_ATTRIB_COLOR0, 4, 0, p4f, a4f, (a,b,c,d) ) +CHOOSE( 4, VERT_ATTRIB_COLOR1, 3, 1, pfv, afv, (v) ) +CHOOSE( 4, VERT_ATTRIB_COLOR1, 3, 0, p3f, a3f, (a,b,c) ) +CHOOSE( 5, VERT_ATTRIB_FOG, 1, 1, pfv, afv, (v) ) +CHOOSE( 5, VERT_ATTRIB_FOG, 1, 0, p1f, a1f, (a) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 1, 1, pfv, afv, (v) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 1, 0, p1f, a1f, (a) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 2, 1, pfv, afv, (v) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 2, 0, p2f, a2f, (a,b) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 3, 1, pfv, afv, (v) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 3, 0, p3f, a3f, (a,b,c) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 4, 1, pfv, afv, (v) ) +CHOOSE( 8, VERT_ATTRIB_TEX0, 4, 0, p4f, a4f, (a,b,c,d) ) + + +/* Gack. Need to do this without going through the + * GET_CURRENT_CONTEXT hoohah. Could codegen this, I suppose... + */ +#define DISPATCH_ATTRFV( ATTR, COUNT, P ) \ +do { \ + GET_CURRENT_CONTEXT( ctx ); \ + TNLcontext *tnl = TNL_CONTEXT(ctx); \ + tnl->vtx.tabfv[COUNT-1][ATTR]( P ); \ +} while (0) + +#define DISPATCH_ATTR1FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 1, V ) +#define DISPATCH_ATTR2FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 2, V ) +#define DISPATCH_ATTR3FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 3, V ) +#define DISPATCH_ATTR4FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 4, V ) -#define DISPATCH_ATTR1F( ATTR, S ) tnl->vb.tabfv[0][attr]( &S ) +#define DISPATCH_ATTR1F( ATTR, S ) DISPATCH_ATTRFV( ATTR, 1, &(S) ) #ifdef USE_X86_ASM /* Naughty cheat: */ -#define DISPATCH_ATTR2F( ATTR, S,T ) tnl->vb.tabfv[1][attr]( &S ) -#define DISPATCH_ATTR3F( ATTR, S,T,R ) tnl->vb.tabfv[2][attr]( &S ) -#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) tnl->vb.tabfv[3][attr]( &S ) +#define DISPATCH_ATTR2F( ATTR, S,T ) DISPATCH_ATTRFV( ATTR, 2, &(S) ) +#define DISPATCH_ATTR3F( ATTR, S,T,R ) DISPATCH_ATTRFV( ATTR, 3, &(S) ) +#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) DISPATCH_ATTRFV( ATTR, 4, &(S) ) #else /* Safe: */ @@ -318,19 +315,19 @@ struct attr_dispatch_tab { do { \ GLfloat v[2]; \ v[0] = S; v[1] = T; \ - tnl->vb.tabfv[1][attr]( v ); \ + DISPATCH_ATTR2FV( ATTR, v ); \ } while (0) #define DISPATCH_ATTR3F( ATTR, S,T,R ) \ do { \ GLfloat v[3]; \ v[0] = S; v[1] = T; v[2] = R; \ - tnl->vb.tabfv[2][attr]( v ); \ + DISPATCH_ATTR3FV( ATTR, v ); \ } while (0) #define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) \ do { \ GLfloat v[4]; \ v[0] = S; v[1] = T; v[2] = R; v[3] = Q; \ - tnl->vb.tabfv[3][attr]( v ); \ + DISPATCH_ATTR4FV( ATTR, v ); \ } while (0) #endif @@ -355,51 +352,51 @@ static void op_error( void ) * Assembly can optimize the generation of arrays by using &s instead * of building 'v'. */ -static void tnl_MultiTexCoord1f( GLenum target, GLfloat s ) +static void _tnl_MultiTexCoord1f( GLenum target, GLfloat s ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR1FV( attr, &s ); } -static void tnl_MultiTexCoord1fv( GLenum target, const GLfloat *v ) +static void _tnl_MultiTexCoord1fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR1FV( attr, v ); } -static void tnl_MultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ) +static void _tnl_MultiTexCoord2f( GLenum target, GLfloat s, GLfloat t ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR2F( attr, s, t ); } -static void tnl_MultiTexCoord2fv( GLenum target, const GLfloat *v ) +static void _tnl_MultiTexCoord2fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR2FV( attr, v ); } -static void tnl_MultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, +static void _tnl_MultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR3F( attr, s, t, r ); } -static void tnl_MultiTexCoord3fv( GLenum target, const GLfloat *v ) +static void _tnl_MultiTexCoord3fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR3FV( attr, v ); } -static void tnl_MultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, +static void _tnl_MultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR4F( attr, s, t, r, q ); } -static void tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v ) +static void _tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v ) { GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0; DISPATCH_ATTR4FV( attr, v ); @@ -411,67 +408,67 @@ static void tnl_MultiTexCoord4fv( GLenum target, const GLfloat *v ) * Check for errors & reroute through second dispatch layer to get * size tracking per-attribute. */ -static void tnl_VertexAttrib1fNV( GLuint index, GLfloat s ) +static void _tnl_VertexAttrib1fNV( GLuint index, GLfloat s ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR1F( index, s ); else enum_error(); } -static void tnl_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) +static void _tnl_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR1FV( index, v ); else enum_error(); } -static void tnl_VertexAttrib2fNV( GLuint index, GLfloat s, GLfloat t ) +static void _tnl_VertexAttrib2fNV( GLuint index, GLfloat s, GLfloat t ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR2F( index, s, t ); else enum_error(); } -static void tnl_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) +static void _tnl_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR2FV( index, v ); else enum_error(); } -static void tnl_VertexAttrib3fNV( GLuint index, GLfloat s, GLfloat t, +static void _tnl_VertexAttrib3fNV( GLuint index, GLfloat s, GLfloat t, GLfloat r ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR3F( index, s, t, r ); else enum_error(); } -static void tnl_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) +static void _tnl_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR3FV( index, v ); else enum_error(); } -static void tnl_VertexAttrib4fNV( GLuint index, GLfloat s, GLfloat t, +static void _tnl_VertexAttrib4fNV( GLuint index, GLfloat s, GLfloat t, GLfloat r, GLfloat q ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR4F( index, s, t, r, q ); else enum_error(); } -static void tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) +static void _tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) { - if (index < MAX_VERT_ATTRS) + if (index < TNL_ATTRIB_MAX) DISPATCH_ATTR4FV( index, v ); else enum_error(); @@ -491,27 +488,30 @@ static void tnl_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) */ #define MAT_ATTR( A, N, params ) \ do { \ - if (tnl->vertex_active[A] != N) { \ + if (tnl->vtx.attrib_sz[A] != N) { \ tnl_fixup_vertex( ctx, A, N ); \ } \ \ { \ - GLfloat *dest = tnl->attrptr[A]; \ - if (N>0) dest[0] = params[0]; \ - if (N>1) dest[1] = params[1]; \ - if (N>2) dest[2] = params[2]; \ - if (N>3) dest[3] = params[3]; \ + union uif *dest = tnl->vtx.attrptr[A]; \ + if (N>0) dest[0].f = params[0]; \ + if (N>1) dest[1].f = params[1]; \ + if (N>2) dest[2].f = params[2]; \ + if (N>3) dest[3].f = params[3]; \ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \ } \ } while (0) -#define MAT( ATTR, N, face, params ) \ -do { \ - if (face != GL_BACK) \ - MAT_ATTR( ATTR, N, params ); /* front */ \ - if (face != GL_FRONT) \ - MAT_ATTR( ATTR+7, N, params ); /* back */ \ +#define MAT( ATTR, N, face, params ) \ +do { \ + if (face != GL_BACK) \ + MAT_ATTR( ATTR, N, params ); /* front */ \ + if (face != GL_FRONT) \ + MAT_ATTR( ATTR - \ + VERT_ATTRIB_MAT_FRONT_EMISSION + \ + VERT_ATTRIB_MAT_BACK_EMISSION, \ + N, params ); /* back */ \ } while (0) @@ -526,7 +526,7 @@ static void _tnl_Materialfv( GLenum face, GLenum pname, switch (pname) { case GL_EMISSION: - MAT( VERT_ATTRIB_MAT_FRONT_EMMISSION, 4, face, params ); + MAT( VERT_ATTRIB_MAT_FRONT_EMISSION, 4, face, params ); break; case GL_AMBIENT: MAT( VERT_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params ); @@ -548,14 +548,48 @@ static void _tnl_Materialfv( GLenum face, GLenum pname, MAT( VERT_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params ); break; default: - _mesa_error( ctx, GL_INVALID_ENUM, where ); + _mesa_error( ctx, GL_INVALID_ENUM, __FUNCTION__ ); return; } } +#define IDX_ATTR( A, IDX ) \ +do { \ + GET_CURRENT_CONTEXT( ctx ); \ + TNLcontext *tnl = TNL_CONTEXT(ctx); \ + \ + if (tnl->vtx.attrib_sz[A] != 1) { \ + tnl_fixup_vertex( ctx, A, 1 ); \ + } \ + \ + { \ + union uif *dest = tnl->vtx.attrptr[A]; \ + dest[0].ui = IDX; \ + ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \ + } \ +} while (0) + + +static void _tnl_EdgeFlag( GLboolean f ) +{ + IDX_ATTR( VERT_ATTRIB_EDGEFLAG, f ); +} + +static void _tnl_EdgeFlagv( const GLboolean *f ) +{ + IDX_ATTR( VERT_ATTRIB_EDGEFLAG, f[0] ); +} +static void _tnl_Indexi( GLint i ) +{ + IDX_ATTR( VERT_ATTRIB_INDEX, i ); +} +static void _tnl_Indexiv( const GLint *i ) +{ + IDX_ATTR( VERT_ATTRIB_INDEX, i[0] ); +} @@ -563,6 +597,7 @@ static void _tnl_Materialfv( GLenum face, GLenum pname, */ static void evalcoord( GLfloat a, GLfloat b, GLuint type ) { +#if 0 GET_CURRENT_CONTEXT( ctx ); TNLcontext *tnl = TNL_CONTEXT(ctx); @@ -580,37 +615,72 @@ static void evalcoord( GLfloat a, GLfloat b, GLuint type ) /* Now emit the vertex with eval data in obj coordinates: */ ATTRF( 0, 2, a, b, 0, 1 ); +#endif } static void _tnl_EvalCoord1f( GLfloat u ) { - evalcoord( u, 0, _TNL_EVAL_COORD1 ); + evalcoord( u, 0, TNL_EVAL_COORD1 ); } static void _tnl_EvalCoord1fv( const GLfloat *v ) { - evalcoord( v[0], 0, _TNL_EVAL_COORD1 ); + evalcoord( v[0], 0, TNL_EVAL_COORD1 ); } static void _tnl_EvalCoord2f( GLfloat u, GLfloat v ) { - evalcoord( u, v, _TNL_EVAL_COORD2 ); + evalcoord( u, v, TNL_EVAL_COORD2 ); } -static void _tnl_EvalCoord2fv( const GLfloat *u ) +static void _tnl_EvalCoord2fv( const GLfloat *v ) { - evalcoord( v[0], v[1], _TNL_EVAL_COORD2 ); + evalcoord( v[0], v[1], TNL_EVAL_COORD2 ); } static void _tnl_EvalPoint1( GLint i ) { - evalcoord( (GLfloat)i, 0, _TNL_EVAL_POINT1 ); + evalcoord( (GLfloat)i, 0, TNL_EVAL_POINT1 ); } static void _tnl_EvalPoint2( GLint i, GLint j ) { - evalcoord( (GLfloat)i, (GLfloat)j, _TNL_EVAL_POINT2 ); + evalcoord( (GLfloat)i, (GLfloat)j, TNL_EVAL_POINT2 ); +} + +/* Don't do a lot of processing here - errors are raised when this + * list is scanned later on (perhaps in display list playback) to + * build tnl_prim structs. + */ +static void _tnl_Begin( GLenum mode ) +{ + GET_CURRENT_CONTEXT( ctx ); + TNLcontext *tnl = TNL_CONTEXT(ctx); + int i; + + i = tnl->vtx.be_count++; + tnl->vtx.be[i].type = TNL_BEGIN; + tnl->vtx.be[i].idx = tnl->vtx.initial_counter - tnl->vtx.counter; + tnl->vtx.be[i].mode = mode; + + if (tnl->vtx.be_count == TNL_BE_MAX) + _tnl_FlushVertices( ctx, FLUSH_STORED_VERTICES ); +} + +static void _tnl_End( void ) +{ + GET_CURRENT_CONTEXT( ctx ); + TNLcontext *tnl = TNL_CONTEXT(ctx); + int i; + + i = tnl->vtx.be_count++; + tnl->vtx.be[i].type = TNL_END; + tnl->vtx.be[i].idx = tnl->vtx.initial_counter - tnl->vtx.counter; + tnl->vtx.be[i].mode = 0; + + if (tnl->vtx.be_count == TNL_BE_MAX) + _tnl_FlushVertices( ctx, FLUSH_STORED_VERTICES ); } @@ -619,7 +689,7 @@ static void _tnl_EvalPoint2( GLint i, GLint j ) -void _tnl_InitDispatch( struct _glapi_table *tab ) +static void _tnl_InitDispatch( struct _glapi_table *tab ) { GLint i; @@ -630,65 +700,65 @@ void _tnl_InitDispatch( struct _glapi_table *tab ) * wasteful if swapping is expensive (threads?). */ for (i = 0 ; i < sizeof(tab)/sizeof(void*) ; i++) - ((int *)tab)[i] = op_error; - - - tab->Color3f = choose_Color3f; - tab->Color3fv = choose_Color3fv; - tab->Color4f = choose_Color4f; - tab->Color4fv = choose_Color4fv; - tab->SecondaryColor3fEXT = choose_SecondaryColor3fEXT; - tab->SecondaryColor3fvEXT = choose_SecondaryColor3fvEXT; - tab->MultiTexCoord1fARB = dd_MultiTexCoord1f; - tab->MultiTexCoord1fvARB = dd_MultiTexCoord1fv; - tab->MultiTexCoord2fARB = dd_MultiTexCoord2f; - tab->MultiTexCoord2fvARB = dd_MultiTexCoord2fv; - tab->MultiTexCoord3fARB = dd_MultiTexCoord3f; - tab->MultiTexCoord3fvARB = dd_MultiTexCoord3fv; - tab->MultiTexCoord4fARB = dd_MultiTexCoord4f; - tab->MultiTexCoord4fvARB = dd_MultiTexCoord4fv; - tab->Normal3f = choose_Normal3f; - tab->Normal3fv = choose_Normal3fv; - tab->TexCoord1f = choose_TexCoord1f; - tab->TexCoord1fv = choose_TexCoord1fv; - tab->TexCoord2f = choose_TexCoord2f; - tab->TexCoord2fv = choose_TexCoord2fv; - tab->TexCoord3f = choose_TexCoord3f; - tab->TexCoord3fv = choose_TexCoord3fv; - tab->TexCoord4f = choose_TexCoord4f; - tab->TexCoord4fv = choose_TexCoord4fv; - tab->Vertex2f = choose_Vertex2f; - tab->Vertex2fv = choose_Vertex2fv; - tab->Vertex3f = choose_Vertex3f; - tab->Vertex3fv = choose_Vertex3fv; - tab->Vertex4f = choose_Vertex4f; - tab->Vertex4fv = choose_Vertex4fv; - tab->FogCoordfvEXT = choose_FogCoordfvEXT; - tab->FogCoordfEXT = choose_FogCoordfEXT; - tab->EdgeFlag = choose_EdgeFlag; - tab->EdgeFlagv = choose_EdgeFlagv; - tab->Indexi = choose_Indexi; - tab->Indexiv = choose_Indexiv; - tab->EvalCoord1f = choose_EvalCoord1f; - tab->EvalCoord1fv = choose_EvalCoord1fv; - tab->EvalCoord2f = choose_EvalCoord2f; - tab->EvalCoord2fv = choose_EvalCoord2fv; - tab->Materialfv = dd_Materialfv; + ((void **)tab)[i] = (void *)op_error; - tab->ArrayElement = _ae_loopback_array_elt; /* generic helper */ tab->Begin = _tnl_Begin; tab->End = _tnl_End; + tab->Color3f = choose_VERT_ATTRIB_COLOR0_3_0; + tab->Color3fv = choose_VERT_ATTRIB_COLOR0_3_1; + tab->Color4f = choose_VERT_ATTRIB_COLOR0_4_0; + tab->Color4fv = choose_VERT_ATTRIB_COLOR0_4_1; + tab->SecondaryColor3fEXT = choose_VERT_ATTRIB_COLOR1_3_0; + tab->SecondaryColor3fvEXT = choose_VERT_ATTRIB_COLOR1_3_1; + tab->MultiTexCoord1fARB = _tnl_MultiTexCoord1f; + tab->MultiTexCoord1fvARB = _tnl_MultiTexCoord1fv; + tab->MultiTexCoord2fARB = _tnl_MultiTexCoord2f; + tab->MultiTexCoord2fvARB = _tnl_MultiTexCoord2fv; + tab->MultiTexCoord3fARB = _tnl_MultiTexCoord3f; + tab->MultiTexCoord3fvARB = _tnl_MultiTexCoord3fv; + tab->MultiTexCoord4fARB = _tnl_MultiTexCoord4f; + tab->MultiTexCoord4fvARB = _tnl_MultiTexCoord4fv; + tab->Normal3f = choose_VERT_ATTRIB_NORMAL_3_0; + tab->Normal3fv = choose_VERT_ATTRIB_NORMAL_3_1; + tab->TexCoord1f = choose_VERT_ATTRIB_TEX0_1_0; + tab->TexCoord1fv = choose_VERT_ATTRIB_TEX0_1_1; + tab->TexCoord2f = choose_VERT_ATTRIB_TEX0_2_0; + tab->TexCoord2fv = choose_VERT_ATTRIB_TEX0_2_1; + tab->TexCoord3f = choose_VERT_ATTRIB_TEX0_3_0; + tab->TexCoord3fv = choose_VERT_ATTRIB_TEX0_3_1; + tab->TexCoord4f = choose_VERT_ATTRIB_TEX0_4_0; + tab->TexCoord4fv = choose_VERT_ATTRIB_TEX0_4_1; + tab->Vertex2f = choose_VERT_ATTRIB_POS_2_0; + tab->Vertex2fv = choose_VERT_ATTRIB_POS_2_1; + tab->Vertex3f = choose_VERT_ATTRIB_POS_3_0; + tab->Vertex3fv = choose_VERT_ATTRIB_POS_3_1; + tab->Vertex4f = choose_VERT_ATTRIB_POS_4_0; + tab->Vertex4fv = choose_VERT_ATTRIB_POS_4_1; + tab->FogCoordfEXT = choose_VERT_ATTRIB_FOG_1_0; + tab->FogCoordfvEXT = choose_VERT_ATTRIB_FOG_1_1; + tab->EdgeFlag = _tnl_EdgeFlag; + tab->EdgeFlagv = _tnl_EdgeFlagv; + tab->Indexi = _tnl_Indexi; + tab->Indexiv = _tnl_Indexiv; + tab->EvalCoord1f = _tnl_EvalCoord1f; + tab->EvalCoord1fv = _tnl_EvalCoord1fv; + tab->EvalCoord2f = _tnl_EvalCoord2f; + tab->EvalCoord2fv = _tnl_EvalCoord2fv; + tab->Materialfv = _tnl_Materialfv; + tab->ArrayElement = _ae_loopback_array_elt; /* generic helper */ } -static struct dynfn *codegen_noop( struct _vb *vb, int key ) + +static struct dynfn *codegen_noop( GLcontext *ctx, int key ) { - (void) vb; (void) key; + (void) ctx; (void) key; return 0; } -void _tnl_InitCodegen( struct dfn_generators *gen ) +static void _tnl_InitCodegen( GLcontext *ctx ) { + TNLcontext *tnl = TNL_CONTEXT(ctx); int sz, v, z; /* attr[n][v] @@ -708,13 +778,13 @@ void _tnl_InitCodegen( struct dfn_generators *gen ) for (sz = 1 ; sz < 5 ; sz++) { for (v = 0 ; v < 2 ; v++) { for (z = 0 ; z < 2 ; z++) { - tnl->codegen[sz][v][z] = codegen_noop; - tnl->generated[sz][v][z] = 0; + tnl->vtx.codegen[sz-1][v][z] = codegen_noop; + tnl->vtx.generated[sz-1][v][z] = 0; } } } - +#if 0 if (!getenv("MESA_NO_CODEGEN")) { #if defined(USE_X86_ASM) _tnl_InitX86Codegen( gen ); @@ -730,18 +800,31 @@ void _tnl_InitCodegen( struct dfn_generators *gen ) #if defined(USE_SPARC_ASM) #endif } +#endif } -void _tnl_DestroyCodegen( GLcontext *ctx ) + + +void _tnl_InitVtx( GLcontext *ctx ) { + TNLcontext *tnl = TNL_CONTEXT(ctx); + _tnl_InitDispatch( tnl->Exec ); + _tnl_InitCodegen( ctx ); +} + + + +void _tnl_DestroyVtx( GLcontext *ctx ) +{ + TNLcontext *tnl = TNL_CONTEXT(ctx); int sz, v, z; - struct dynfn *dfn, next; + struct dynfn *dfn, *next; - for (sz = 1 ; sz < 5 ; sz++) { - for (v = 0 ; v < 2 ; v++) { - for (z = 0 ; z < 2 ; z++) { - dfn = tnl->generated[sz][v][z]; + for (sz = 1 ; sz <= 4 ; sz++) { + for (v = 0 ; v <= 1 ; v++) { + for (z = 0 ; z <= 1 ; z++) { + dfn = tnl->vtx.generated[sz-1][v][z]; while (dfn) { next = dfn->next; FREE(dfn); @@ -751,3 +834,4 @@ void _tnl_DestroyCodegen( GLcontext *ctx ) } } } + diff --git a/src/mesa/tnl/t_vtx_api.h b/src/mesa/tnl/t_vtx_api.h index 86062d3de5..cecf102e3b 100644 --- a/src/mesa/tnl/t_vtx_api.h +++ b/src/mesa/tnl/t_vtx_api.h @@ -32,12 +32,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * */ -#ifndef __RADEON_VTXFMT_H__ -#define __RADEON_VTXFMT_H__ +#ifndef __TNL_VTX_API_H__ +#define __TNL_VTX_API_H__ -#ifdef GLX_DIRECT_RENDERING - -#include "_tnl__context.h" +#include "t_context.h" extern void _tnl_UpdateVtxfmt( GLcontext *ctx ); extern void _tnl_InitVtxfmt( GLcontext *ctx ); @@ -53,149 +51,15 @@ typedef void (*pe1f)( GLenum, GLfloat ); typedef void (*pfv)( const GLfloat * ); typedef void (*pefv)( GLenum, const GLfloat * ); -/* Want to keep a cache of these around. Each is parameterized by - * only a single value which has only a small range. Only expect a - * few, so just rescan the list each time? - */ -struct dynfn { - struct dynfn *next, *prev; - int key; - char *code; -}; - -struct dfn_lists { - struct dynfn Attr1f; - struct dynfn Attr1fv; - struct dynfn Attr2f; - struct dynfn Attr2fv; - struct dynfn Attr3f; - struct dynfn Attr3fv; - struct dynfn Attr4f; - struct dynfn Attr4fv; - struct dynfn Vertex1f; - struct dynfn Vertex1fv; - struct dynfn Vertex2f; - struct dynfn Vertex2fv; - struct dynfn Vertex3f; - struct dynfn Vertex3fv; - struct dynfn Vertex4f; - struct dynfn Vertex4fv; -}; - -struct _vb; - -struct dfn_generators { - struct dynfn *(*Attr1f)( struct _vb *, int ); - struct dynfn *(*Attr1fv)( struct _vb *, int ); - struct dynfn *(*Attr2f)( struct _vb *, int ); - struct dynfn *(*Attr2fv)( struct _vb *, int ); - struct dynfn *(*Attr3f)( struct _vb *, int ); - struct dynfn *(*Attr3fv)( struct _vb *, int ); - struct dynfn *(*Attr4f)( struct _vb *, int ); - struct dynfn *(*Attr4fv)( struct _vb *, int ); - struct dynfn *(*Vertex1f)( struct _vb *, int ); - struct dynfn *(*Vertex1fv)( struct _vb *, int ); - struct dynfn *(*Vertex2f)( struct _vb *, int ); - struct dynfn *(*Vertex2fv)( struct _vb *, int ); - struct dynfn *(*Vertex3f)( struct _vb *, int ); - struct dynfn *(*Vertex3fv)( struct _vb *, int ); - struct dynfn *(*Vertex4f)( struct _vb *, int ); - struct dynfn *(*Vertex4fv)( struct _vb *, int ); -}; - -struct prim { - GLuint start; - GLuint end; - GLuint prim; -}; - -#define _TNL__MAX_PRIMS 64 - - - -struct tnl_vbinfo { - /* Keep these first: referenced from codegen templates: - */ - GLint counter; - GLint *dmaptr; - void (*notify)( void ); - union { float f; int i; GLubyte ub4[4]; } vertex[16*4]; - - GLfloat *attrptr[16]; - GLuint size[16]; - - GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */ - GLuint primflags; - - GLboolean installed; - GLboolean recheck; - - GLint vertex_size; - GLint initial_counter; - GLint nrverts; - GLuint vertex_format; - - GLuint installed_vertex_format; - - struct prim primlist[RADEON_MAX_PRIMS]; - int nrprims; - - struct dfn_lists dfn_cache; - struct dfn_generators codegen; - GLvertexformat vtxfmt; -}; - - -extern void _tnl_InitVtxfmtChoosers( GLvertexformat *vfmt ); - - -#define FIXUP( CODE, OFFSET, CHECKVAL, NEWVAL ) \ -do { \ - int *icode = (int *)(CODE+OFFSET); \ - assert (*icode == CHECKVAL); \ - *icode = (int)NEWVAL; \ -} while (0) - - -/* Useful for figuring out the offsets: - */ -#define FIXUP2( CODE, OFFSET, CHECKVAL, NEWVAL ) \ -do { \ - while (*(int *)(CODE+OFFSET) != CHECKVAL) OFFSET++; \ - fprintf(stderr, "%s/%d CVAL %x OFFSET %d\n", __FUNCTION__, \ - __LINE__, CHECKVAL, OFFSET); \ - *(int *)(CODE+OFFSET) = (int)NEWVAL; \ - OFFSET += 4; \ -} while (0) - -/* - */ -void _tnl_InitCodegen( struct dfn_generators *gen ); -void _tnl_InitX86Codegen( struct dfn_generators *gen ); -void _tnl_InitSSECodegen( struct dfn_generators *gen ); - -void _tnl_copy_to_current( GLcontext *ctx ); -/* Defined in tnl_vtxfmt_c.c. +/* t_vtx_dlist.c */ -struct dynfn *tnl_makeX86Vertex2f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Vertex2fv( TNLcontext *, int ); -struct dynfn *tnl_makeX86Vertex3f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Vertex3fv( TNLcontext *, int ); -struct dynfn *tnl_makeX86Vertex4f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Vertex4fv( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr4f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr4fv( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr3f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr3fv( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr2f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr2fv( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr1f( TNLcontext *, int ); -struct dynfn *tnl_makeX86Attr1fv( TNLcontext *, int ); - +extern void _tnl_BeginCallList( GLcontext *ctx, GLuint list ); +extern void _tnl_EndCallList( GLcontext *ctx ); +extern void _tnl_EndList( GLcontext *ctx ); +extern void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode ); +extern void _tnl_FlushVertices( GLcontext *ctx, GLuint flags ); - -#endif #endif diff --git a/src/mesa/tnl/t_vtx_exec.c b/src/mesa/tnl/t_vtx_exec.c index 05b80bd126..64965a4095 100644 --- a/src/mesa/tnl/t_vtx_exec.c +++ b/src/mesa/tnl/t_vtx_exec.c @@ -42,78 +42,94 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "colormac.h" #include "light.h" #include "state.h" -#include "vtxfmt.h" #include "tnl/tnl.h" #include "tnl/t_context.h" #include "tnl/t_array_api.h" -static void _tnl_FlushVertices( GLcontext *, GLuint ); - -void tnl_copy_to_current( GLcontext *ctx ) +void tnl_copy_to_current( GLcontext *ctx, struct tnl_vtx_block *v ) { TNLcontext *tnl = TNL_CONTEXT(ctx); - GLuint flag = tnl->vertex_format; - GLint i; + GLint i, update = 0; assert(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT); for (i = 0 ; i < 16 ; i++) - if (flag & (1<<i)) - COPY_4FV( ctx->Current.Attrib[i], tnl->attribptr[i] ); - - if (flag & VERT_BIT_INDEX) - ctx->Current.Index = tnl->indexptr[0]; - - if (flag & VERT_BIT_EDGEFLAG) - ctx->Current.EdgeFlag = tnl->edgeflagptr[0]; - - if (flag & VERT_BIT_MATERIAL) { - _mesa_update_material( ctx, - IM->Material[IM->LastMaterial], - IM->MaterialOrMask ); + if (tnl->vtx.attrib_sz[i]) + COPY_SZ( ctx->Current.Attrib[i], + &(tnl->vtx.attrptr[i][0].f), + tnl->vtx.attrib_sz[i] ); + + if (tnl->vtx.attrib_sz[VERT_ATTRIB_INDEX]) + ctx->Current.Index = tnl->vtx.attrptr[VERT_ATTRIB_INDEX][0].ui; + + if (tnl->vtx.attrib_sz[VERT_ATTRIB_EDGEFLAG]) + ctx->Current.EdgeFlag = tnl->vtx.attrptr[VERT_ATTRIB_EDGEFLAG][0].ui; + + for (i = 0 ; i < MAT_ATTRIB_MAX ; i++ ) { + if (tnl->vtx.attrib_sz[i + VERT_ATTRIB_MAT_FRONT_EMISSION]) { + COPY_SZ( ctx->Light.Material.Attrib[i], + &(tnl->vtx.attrptr[i+VERT_ATTRIB_MAT_FRONT_EMISSION][0].f), + tnl->vtx.attrib_sz[i]); + update |= 1 << i; + } - tnl->Driver.NotifyMaterialChange( ctx ); + if (update) + _mesa_update_material( ctx, update ); } - ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; } -static GLboolean discreet_gl_prim[GL_POLYGON+1] = { - 1, /* 0 points */ - 1, /* 1 lines */ - 0, /* 2 line_strip */ - 0, /* 3 line_loop */ - 1, /* 4 tris */ - 0, /* 5 tri_fan */ - 0, /* 6 tri_strip */ - 1, /* 7 quads */ - 0, /* 8 quadstrip */ - 0, /* 9 poly */ +static GLboolean discrete_gl_prim[GL_POLYGON+1] = { + 1, /* 0 points */ + 1, /* 1 lines */ + 0, /* 2 line_strip */ + 0, /* 3 line_loop */ + 1, /* 4 tris */ + 0, /* 5 tri_fan */ + 0, /* 6 tri_strip */ + 1, /* 7 quads */ + 0, /* 8 quadstrip */ + 0, /* 9 poly */ +}; + +static GLint prim_modulo[GL_POLYGON+1] = { + 1, /* 0 points */ + 2, /* 1 lines */ + 0, /* 2 line_strip */ + 0, /* 3 line_loop */ + 3, /* 4 tris */ + 0, /* 5 tri_fan */ + 0, /* 6 tri_strip */ + 4, /* 7 quads */ + 0, /* 8 quadstrip */ + 0, /* 9 poly */ }; -/* Optimize the primitive list: +/* Optimize primitive list where possible. */ static void optimize_prims( TNLcontext *tnl ) { - int i, j; + struct tnl_prim *prim = tnl->primlist; if (tnl->nrprims <= 1) return; for (j = 0, i = 1 ; i < tnl->nrprims; i++) { - int pj = tnl->primlist[j].prim & 0xf; - int pi = tnl->primlist[i].prim & 0xf; + int pj = prim[j].prim & 0xf; + int pi = prim[i].prim & 0xf; - if (pj == pi && discreet_gl_prim[pj] && - tnl->primlist[i].start == tnl->primlist[j].end) { - tnl->primlist[j].end = tnl->primlist[i].end; + if (pj == pi && + discrete_gl_prim[pj] && + prim[i].start == prim[j].end && + (prim[i].end - prim[i].start) % prim_modulo[pi] == 0) { + prim[j].end = prim[i].end; } else { j++; - if (j != i) tnl->primlist[j] = tnl->primlist[i]; + if (j != i) prim[j] = prim[i]; } } @@ -121,48 +137,54 @@ static void optimize_prims( TNLcontext *tnl ) } -/* Bind vertex buffer pointers, run pipeline: + +/* Build a primitive list from the begin/end buffer. */ -static void flush_prims( TNLcontext *tnl ) +static void build_prims( TNLcontext *tnl ) { - int i,j; - - tnl->dma.current.ptr = tnl->dma.current.start += - (tnl->initial_counter - tnl->counter) * tnl->vertex_size * 4; - - tnl->tcl.vertex_format = tnl->vertex_format; - tnl->tcl.aos_components[0] = &tmp; - tnl->tcl.nr_aos_components = 1; - tnl->dma.flush = 0; + int i, j; + struct tnl_be *be = tnl->vtx.be; + struct tnl_prim *prim = tnl->primlist; + GLenum state = ctx->Driver.CurrentExecPrimitive; - tnl->Driver.RunPipeline( ... ); - tnl->nrprims = 0; -} - - -static void start_prim( TNLcontext *tnl, GLuint mode ) -{ - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s %d\n", __FUNCTION__, - tnl->initial_counter - tnl->counter); - tnl->primlist[tnl->nrprims].start = tnl->initial_counter - tnl->counter; - tnl->primlist[tnl->nrprims].prim = mode; -} - -static void note_last_prim( TNLcontext *tnl, GLuint flags ) -{ - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s %d\n", __FUNCTION__, - tnl->initial_counter - tnl->counter); + /* Initialize first prim if inside begin/end + */ + if (state != PRIM_OUTSIDE_BEGIN_END) { + prim[j].start = be[i].idx; + prim[j].mode = state; + } - if (tnl->prim[0] != GL_POLYGON+1) { - tnl->primlist[tnl->nrprims].prim |= flags; - tnl->primlist[tnl->nrprims].end = tnl->initial_counter - tnl->counter; - if (++tnl->nrprims == TNL_MAX_PRIMS) - flush_prims( tnl ); + /* Convert begin/ends into prims + */ + for (i = 0 ; i < tnl->vtx.be_count ; i++) { + switch (be[i].type) { + case TNL_BEGIN: + if (state != PRIM_OUTSIDE_BEGIN_END || + be[i].mode > GL_POLYGON) { + error = 1; + } + else { + prim[j].start = be[i].idx; + prim[j].mode = be[i].mode | PRIM_BEGIN; + state = be[i].mode; + } + break; + case TNL_END: + if (state == PRIM_OUTSIDE_BEGIN_END) { + error = 1; + } + else { + prim[j].mode |= PRIM_END; + prim[j].end = be[i].idx; + } + } + } + + if (state != PRIM_OUTSIDE_BEGIN_END) { + prim[j].end = tnl->vtx.initial_counter - tnl->vtx.counter; } } @@ -230,6 +252,8 @@ static GLuint copy_wrapped_verts( TNLcontext *tnl, GLfloat (*tmp)[15] ) return 2; } case GL_TRIANGLE_STRIP: + /* FIXME: parity. + */ ovf = MIN2( nr-1, 2 ); for (i = 0 ; i < ovf ; i++) copy_vertex( tnl, nr-ovf+i, tmp[i] ); @@ -244,59 +268,19 @@ static GLuint copy_wrapped_verts( TNLcontext *tnl, GLfloat (*tmp)[15] ) assert(0); return 0; } -} - +} -/* Extend for vertex-format changes on wrap: - */ -static void wrap_buffer( void ) +static void save_wrapped_verts( TNLcontext *tnl ) { - TNLcontext *tnl = tnl->tnl; - GLfloat tmp[3][15]; - GLuint i, nrverts; - - if (MESA_VERBOSE & (DEBUG_VFMT|DEBUG_PRIMS)) - _mesa_debug(NULL, "%s %d\n", __FUNCTION__, - tnl->initial_counter - tnl->counter); - -#if 0 - /* Don't deal with parity. - */ - if ((((tnl->initial_counter - tnl->counter) - - tnl->primlist[tnl->nrprims].start) & 1)) { - tnl->counter++; - tnl->initial_counter++; - return; - } -#endif - - /* Copy vertices out of dma: - */ - nrverts = copy_dma_verts( tnl, tmp ); - - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%d vertices to copy\n", nrverts); - - - /* Finish the prim at this point: - */ - note_last_prim( tnl, 0 ); - flush_prims( tnl ); + tnl->wrap.nr_verts = copy_wrapped_verts( tnl ); +} - /* Reset counter, dmaptr - */ - tnl->dmaptr = (int *)(tnl->dma.current.ptr + tnl->dma.current.address); - tnl->counter = (tnl->dma.current.end - tnl->dma.current.ptr) / - (tnl->vertex_size * 4); - tnl->counter--; - tnl->initial_counter = tnl->counter; - tnl->notify = wrap_buffer; - tnl->dma.flush = flush_prims; - start_prim( tnl, tnl->prim[0] ); +static void emit_wrapped_verts( TNLcontext *tnl ) +{ /* Reemit saved vertices * *** POSSIBLY IN NEW FORMAT * --> Can't always extend at end of vertex @@ -318,247 +302,31 @@ static void wrap_buffer( void ) -/* Always follow data, don't try to predict what's necessary. - */ -static GLboolean check_vtx_fmt( GLcontext *ctx ) -{ - TNLcontext *tnl = TNL_CONTEXT(ctx); - - if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) - ctx->Driver.FlushVertices( ctx, FLUSH_UPDATE_CURRENT ); - - - TNL_NEWPRIM(tnl); - tnl->vertex_format = VERT_BIT_POS; - tnl->prim = &ctx->Driver.CurrentExecPrimitive; - /* Currently allow the full 4 components per attrib. Can use the - * mechanism from radeon driver color handling to reduce this (and - * also to store ubyte colors where these are incoming). This - * won't work for compile mode. - * - * Only adding components when they are first received eliminates - * the need for displaylist fixup, as there are no 'empty' slots - * at the start of buffers. +/* Bind vertex buffer pointers, run pipeline: + */ +void _tnl_execute_buffer( TNLcontext *tnl, struct tnl_vtx_block *v ) +{ + /* Bring back wrapped vertices: */ - for (i = 0 ; i < 16 ; i++) { - if (ind & (1<<i)) { - tnl->attribptr[i] = &tnl->vertex[tnl->vertex_size].f; - tnl->vertex_size += 4; - tnl->attribptr[i][0] = ctx->Current.Attrib[i][0]; - tnl->attribptr[i][1] = ctx->Current.Attrib[i][1]; - tnl->attribptr[i][2] = ctx->Current.Attrib[i][2]; - tnl->attribptr[i][3] = ctx->Current.Attrib[i][3]; - } - else - tnl->attribptr[i] = ctx->Current.Attrib[i]; - } + revive_wrapped_verts( tnl, v ); - /* Edgeflag, Index: + /* Build primitive list from begin/end events in buffer */ - for (i = 16 ; i < 18 ; i++) - ; + build_prims( tnl, v ); - /* Materials: + /* Bind the arrays and run the pipeline */ - for (i = 18 ; i < 28 ; i++) - ; + bind_vertex_buffer( tnl, v ); + tnl->Driver.RunPipeline( ctx, &tnl->vb ); - /* Eval: + /* Copy wrapped vertices for next time:: */ - for (i = 28 ; i < 29 ; i++) - ; - - - if (tnl->installed_vertex_format != tnl->vertex_format) { - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "reinstall on vertex_format change\n"); - _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); - tnl->installed_vertex_format = tnl->vertex_format; - } - - return GL_TRUE; -} - - -void _tnl_InvalidateVtxfmt( GLcontext *ctx ) -{ - tnl->recheck = GL_TRUE; - tnl->fell_back = GL_FALSE; + save_wrapped_verts( tnl, v ); } -static void _tnl_ValidateVtxfmt( GLcontext *ctx ) -{ - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s\n", __FUNCTION__); - - if (ctx->Driver.NeedFlush) - ctx->Driver.FlushVertices( ctx, ctx->Driver.NeedFlush ); - - tnl->recheck = GL_FALSE; - - if (check_vtx_fmt( ctx )) { - if (!tnl->installed) { - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "reinstall (new install)\n"); - - _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); - ctx->Driver.FlushVertices = _tnl_FlushVertices; - tnl->installed = GL_TRUE; - } - else - _mesa_debug(NULL, "%s: already installed", __FUNCTION__); - } - else { - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s: failed\n", __FUNCTION__); - - if (tnl->installed) { - if (tnl->tnl->dma.flush) - tnl->tnl->dma.flush( tnl->tnl ); - _tnl_wakeup_exec( ctx ); - tnl->installed = GL_FALSE; - } - } -} - - -static void _tnl_transition_Begin( GLenum mode ) -{ - if (ctx->NewState) - _mesa_update_state( ctx ); - - if (tnl->recheck) - _tnl_ValidateVtxfmt( ctx ); - - ctx->CurrentDispatch = tnl->Exec; - ctx->CurrentDispatch->Begin( mode ); -} - - - -/* Begin/End - */ -static void _tnl_Begin( GLenum mode ) -{ - GLcontext *ctx = tnl->context; - TNLcontext *tnl = tnl->tnl; - - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s\n", __FUNCTION__); - - if (mode > GL_POLYGON) { - _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" ); - return; - } - - if (tnl->prim[0] != GL_POLYGON+1) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" ); - return; - } - - if (tnl->dma.flush && tnl->counter < 12) { - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s: flush almost-empty buffers\n", __FUNCTION__); - flush_prims( tnl ); - } - - if (!tnl->dma.flush) { - if (tnl->dma.current.ptr + 12*tnl->vertex_size*4 > - tnl->dma.current.end) { - TNL_NEWPRIM( tnl ); - _tnl_RefillCurrentDmaRegion( tnl ); - } - - tnl->dmaptr = (int *)(tnl->dma.current.address + tnl->dma.current.ptr); - tnl->counter = (tnl->dma.current.end - tnl->dma.current.ptr) / - (tnl->vertex_size * 4); - tnl->counter--; - tnl->initial_counter = tnl->counter; - tnl->notify = wrap_buffer; - tnl->dma.flush = flush_prims; - tnl->context->Driver.NeedFlush |= FLUSH_STORED_VERTICES; - } - - - tnl->prim[0] = mode; - start_prim( tnl, mode | PRIM_BEGIN ); -} - - - - - -static void _tnl_End( void ) -{ - TNLcontext *tnl = tnl->tnl; - GLcontext *ctx = tnl->context; - - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s\n", __FUNCTION__); - - if (tnl->prim[0] == GL_POLYGON+1) { - _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" ); - return; - } - - note_last_prim( tnl, PRIM_END ); - tnl->prim[0] = GL_POLYGON+1; -} - - -static void _tnl_FlushVertices( GLcontext *ctx, GLuint flags ) -{ - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "%s\n", __FUNCTION__); - - assert(tnl->installed); - - if (flags & FLUSH_UPDATE_CURRENT) { - _tnl_copy_to_current( ctx ); - if (MESA_VERBOSE & DEBUG_VFMT) - _mesa_debug(NULL, "reinstall on update_current\n"); - _mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt ); - ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT; - } - - if (flags & FLUSH_STORED_VERTICES) { - TNLcontext *tnl = TNL_CONTEXT( ctx ); - assert (tnl->dma.flush == 0 || - tnl->dma.flush == flush_prims); - if (tnl->dma.flush == flush_prims) - flush_prims( TNL_CONTEXT( ctx ) ); - ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES; - } -} - - - -/* At this point, don't expect very many versions of each function to - * be generated, so not concerned about freeing them? - */ - - -static void _tnl_InitVtx( GLcontext *ctx ) -{ - - - tnl->context = ctx; - tnl->tnl = TNL_CONTEXT(ctx); - tnl->prim = &ctx->Driver.CurrentExecPrimitive; - tnl->primflags = 0; - - _tnl_InitCodegen( ctx ); -} - - - -static void _tnl_DestroyVtx( GLcontext *ctx ) -{ - _tnl_DestroyCodegen( ctx ); -} |