summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2003-10-09 17:42:36 +0000
committerKeith Whitwell <[email protected]>2003-10-09 17:42:36 +0000
commit0c390fec04e1a8d8ca7809ec2769c30e32d0c010 (patch)
treeb3f0f436f2ca3c498ca85418e988c76bb2722846 /src
parentd5c9fd383bf4712ddcdc850a70002f4fb0f3a83a (diff)
Checkpoint -- The whole library compiles now...
Diffstat (limited to 'src')
-rw-r--r--src/mesa/Makefile.X111
-rw-r--r--src/mesa/main/context.h3
-rw-r--r--src/mesa/main/dd.h2
-rw-r--r--src/mesa/main/dlist.c35
-rw-r--r--src/mesa/main/dlist.h5
-rw-r--r--src/mesa/tnl/t_context.c1
-rw-r--r--src/mesa/tnl/t_save_api.c96
-rw-r--r--src/mesa/tnl/t_save_api.h5
-rw-r--r--src/mesa/tnl/t_save_playback.c7
-rw-r--r--src/mesa/tnl/t_vtx_api.c61
-rw-r--r--src/mesa/tnl/t_vtx_api.h4
-rw-r--r--src/mesa/tnl/t_vtx_exec.c35
12 files changed, 214 insertions, 41 deletions
diff --git a/src/mesa/Makefile.X11 b/src/mesa/Makefile.X11
index 8dd594bbd4a..e62907b5523 100644
--- a/src/mesa/Makefile.X11
+++ b/src/mesa/Makefile.X11
@@ -135,7 +135,6 @@ TNL_SOURCES = \
tnl/t_array_api.c \
tnl/t_array_import.c \
tnl/t_context.c \
- tnl/t_eval_api.c \
tnl/t_pipeline.c \
tnl/t_save_api.c \
tnl/t_save_loopback.c \
diff --git a/src/mesa/main/context.h b/src/mesa/main/context.h
index 8bbd787914a..caf81d8a21c 100644
--- a/src/mesa/main/context.h
+++ b/src/mesa/main/context.h
@@ -264,6 +264,7 @@ _mesa_Flush( void );
/** \name Macros for contexts/flushing. */
/*@{*/
+
/**
* Flush vertices.
*
@@ -273,8 +274,6 @@ _mesa_Flush( void );
* Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
* and calls dd_function_table::FlushVertices if so. Marks
* __GLcontextRec::NewState with \p newstate.
- *
- * \todo Eventually let the driver specify what state changes require a flush:
*/
#define FLUSH_VERTICES(ctx, newstate) \
do { \
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 0d9bf5a2100..5f9e3764c27 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -808,6 +808,7 @@ struct dd_function_table {
* these conditions.
*/
GLuint NeedFlush;
+ GLuint SaveNeedFlush;
/**
* If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if
@@ -819,6 +820,7 @@ struct dd_function_table {
* FLUSH_UPDATE_CURRENT bit, even after performing the update.
*/
void (*FlushVertices)( GLcontext *ctx, GLuint flags );
+ void (*SaveFlushVertices)( GLcontext *ctx );
/**
* Notify driver that the special derived value _NeedEyeCoords has
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 0fe7ac0b332..895739e8ddd 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -83,6 +83,21 @@
#include "math/m_xform.h"
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ *
+ * Checks if dd_function_table::SaveNeedFlush is marked to flush
+ * stored (save) vertices, and calls
+ * dd_function_table::SaveFlushVertices if so.
+ */
+#define SAVE_FLUSH_VERTICES(ctx) \
+do { \
+ if (ctx->Driver.SaveNeedFlush) \
+ ctx->Driver.SaveFlushVertices(ctx); \
+} while (0)
+
/**
* Macro to assert that the API call was made outside the
@@ -124,7 +139,7 @@ do { \
#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \
do { \
ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
- FLUSH_VERTICES(ctx, 0); \
+ SAVE_FLUSH_VERTICES(ctx); \
} while (0)
/**
@@ -137,7 +152,7 @@ do { \
#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
do { \
ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
- FLUSH_VERTICES(ctx, 0); \
+ SAVE_FLUSH_VERTICES(ctx); \
} while (0)
@@ -7710,14 +7725,14 @@ void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
vfmt->Rectf = save_Rectf;
+ vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
+ vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
- /* TODO: These all need outside-begin-end checks:
+ /* To implement as opcodes these would need new code for the
+ * runtime outside-begin-end checks. As these functions aren't
+ * actually needed at this point, I'll punt on that for now:
*/
-#if 0
- vfmt->DrawArrays = _mesa_noop_DrawArrays;
- vfmt->DrawElements = _mesa_noop_DrawElements;
- vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements;
- vfmt->EvalMesh1 = _mesa_noop_EvalMesh1;
- vfmt->EvalMesh2 = _mesa_noop_EvalMesh2;
-#endif
+ vfmt->DrawArrays = 0;
+ vfmt->DrawElements = 0;
+ vfmt->DrawRangeElements = 0;
}
diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h
index 945cebbaab9..f0beaf47acb 100644
--- a/src/mesa/main/dlist.h
+++ b/src/mesa/main/dlist.h
@@ -79,6 +79,8 @@ extern void _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 );
extern void _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists );
extern void _mesa_save_CallList( GLuint list );
extern void _mesa_init_display_list( GLcontext * ctx );
+extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt );
+
#else
@@ -94,6 +96,9 @@ extern void _mesa_init_display_list( GLcontext * ctx );
/** No-op */
#define _mesa_init_display_list(c) ((void)0)
+/** No-op */
+#define _mesa_save_vtxfmt_init(v) ((void)0)
+
#endif
#endif
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 6f9dfeb379a..4b9ee1d8add 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -58,6 +58,7 @@ install_driver_callbacks( GLcontext *ctx )
ctx->Driver.NewList = _tnl_NewList;
ctx->Driver.EndList = _tnl_EndList;
ctx->Driver.FlushVertices = _tnl_FlushVertices;
+ ctx->Driver.SaveFlushVertices = _tnl_SaveFlushVertices;
ctx->Driver.MakeCurrent = _tnl_MakeCurrent;
ctx->Driver.BeginCallList = _tnl_BeginCallList;
ctx->Driver.EndCallList = _tnl_EndCallList;
diff --git a/src/mesa/tnl/t_save_api.c b/src/mesa/tnl/t_save_api.c
index 007984ddb8a..74770a12c64 100644
--- a/src/mesa/tnl/t_save_api.c
+++ b/src/mesa/tnl/t_save_api.c
@@ -73,6 +73,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "macros.h"
#include "api_validate.h"
#include "api_arrayelt.h"
+#include "vtxfmt.h"
#include "t_save_api.h"
/*
@@ -492,6 +493,17 @@ static void choose_##ATTR##_##N( const GLfloat *v ) \
v ); \
}
+#define INIT(ATTR) \
+static void init_##ATTR( TNLcontext *tnl ) \
+{ \
+ tnl->save.tabfv[ATTR][0] = choose_##ATTR##_1; \
+ tnl->save.tabfv[ATTR][1] = choose_##ATTR##_2; \
+ tnl->save.tabfv[ATTR][2] = choose_##ATTR##_3; \
+ tnl->save.tabfv[ATTR][3] = choose_##ATTR##_4; \
+}
+
+
+
#define ATTRS( ATTRIB ) \
ATTRFV( ATTRIB, 1 ) \
ATTRFV( ATTRIB, 2 ) \
@@ -501,6 +513,7 @@ static void choose_##ATTR##_##N( const GLfloat *v ) \
CHOOSE( ATTRIB, 2 ) \
CHOOSE( ATTRIB, 3 ) \
CHOOSE( ATTRIB, 4 ) \
+ INIT( ATTRIB ) \
/* Generate a lot of functions. These are the actual worker
@@ -524,6 +537,28 @@ ATTRS( 13 )
ATTRS( 14 )
ATTRS( 15 )
+
+static void init_attrfv( TNLcontext *tnl )
+{
+ init_0( tnl );
+ init_1( tnl );
+ init_2( tnl );
+ init_3( tnl );
+ init_4( tnl );
+ init_5( tnl );
+ init_6( tnl );
+ init_7( tnl );
+ init_8( tnl );
+ init_9( tnl );
+ init_10( tnl );
+ init_11( tnl );
+ init_12( tnl );
+ init_13( tnl );
+ init_14( tnl );
+ init_15( tnl );
+}
+
+
/* Cope with aliasing of classic Vertex, Normal, etc. and the fan-out
* of glMultTexCoord and glProgramParamterNV by routing all these
* through a second level dispatch table.
@@ -996,6 +1031,8 @@ static void _save_NotifyBegin( GLenum mode )
tnl->save.prim[i].count = 0;
}
+
+
static void _save_End( void )
{
GET_CURRENT_CONTEXT( ctx );
@@ -1017,7 +1054,7 @@ static void _save_End( void )
* -- Need to ensure that these vertices are flushed in that case.
* -- Just use the regular flush mechanism.
*/
- _save_swapout_vtxfmt();
+ _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt );
}
@@ -1156,10 +1193,14 @@ static void _save_vtxfmt_init( GLcontext *ctx )
void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ assert(tnl->save.vertex_size == 0);
}
void _tnl_EndList( GLcontext *ctx )
{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ assert(tnl->save.vertex_size == 0);
}
void _tnl_BeginCallList( GLcontext *ctx, GLuint list )
@@ -1170,8 +1211,47 @@ void _tnl_EndCallList( GLcontext *ctx )
{
}
+/* Called when
+ */
+void _tnl_SaveFlushVertices( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ _save_compile_vertex_list( ctx );
+
+ init_attrfv( tnl );
+
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ tnl->save.attrsz[i] = 0;
+
+ tnl->save.vertex_size = 0;
+}
+
+static void
+_tnl_destroy_vertex_list( GLcontext *ctx, void *data )
+{
+ struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
+
+ if ( --node->vertex_store->refcount == 0 )
+ ALIGN_FREE( node->vertex_store );
+
+ if ( --node->prim_store->refcount == 0 )
+ ALIGN_FREE( node->prim_store );
+
+ FREE( node );
+}
+
+static void
+_tnl_print_vertex_list( GLcontext *ctx, void *data )
+{
+ struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
+ _mesa_debug(ctx, "TNL-VERTEX-LIST, %u vertices %d primitives\n",
+ node->count,
+ node->prim_count);
+}
/**
* Setup vector pointers that will be used to bind immediates to VB's.
@@ -1182,10 +1262,24 @@ void _tnl_save_init( GLcontext *ctx )
struct tnl_vertex_arrays *tmp = &tnl->save_inputs;
GLuint i;
+ init_attrfv( tnl );
+
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ tnl->save.attrsz[i] = 0;
+
+ tnl->save.vertex_size = 0;
+
_save_vtxfmt_init( ctx );
for (i = 0; i < _TNL_ATTRIB_MAX; i++)
_mesa_vector4f_init( &tmp->Attribs[i], 0, 0);
+
+ tnl->save.opcode_vertex_list =
+ _mesa_alloc_opcode( ctx,
+ sizeof(struct tnl_vertex_list),
+ _tnl_playback_vertex_list,
+ _tnl_destroy_vertex_list,
+ _tnl_print_vertex_list );
}
diff --git a/src/mesa/tnl/t_save_api.h b/src/mesa/tnl/t_save_api.h
index 33b1d6add04..a6a8cd011bd 100644
--- a/src/mesa/tnl/t_save_api.h
+++ b/src/mesa/tnl/t_save_api.h
@@ -45,13 +45,14 @@ extern void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode );
extern void _tnl_EndCallList( GLcontext *ctx );
extern void _tnl_BeginCallList( GLcontext *ctx, GLuint list );
+extern void _tnl_SaveFlushVertices( GLcontext *ctx );
+
extern void _tnl_save_init( GLcontext *ctx );
extern void _tnl_save_destroy( GLcontext *ctx );
extern void _tnl_loopback_vertex_list( GLcontext *ctx,
struct tnl_vertex_list *list );
-extern void _tnl_playback_vertex_list( GLcontext *ctx,
- struct tnl_vertex_list *list );
+extern void _tnl_playback_vertex_list( GLcontext *ctx, void *data );
#endif
diff --git a/src/mesa/tnl/t_save_playback.c b/src/mesa/tnl/t_save_playback.c
index 022b9976410..18ac265996c 100644
--- a/src/mesa/tnl/t_save_playback.c
+++ b/src/mesa/tnl/t_save_playback.c
@@ -55,7 +55,6 @@ static void _tnl_bind_vertex_list( GLcontext *ctx,
VB->SecondaryColorPtr[1] = NULL;
VB->IndexPtr[1] = NULL;
-
for (attr = 0; attr <= _TNL_ATTRIB_INDEX; attr++) {
if (node->attrsz[attr]) {
tmp->Attribs[attr].count = node->count;
@@ -75,7 +74,8 @@ static void _tnl_bind_vertex_list( GLcontext *ctx,
/* Copy edgeflag to a contiguous array
*/
if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
- VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data, node->count,
+ VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data,
+ node->count,
node->vertex_size );
data++;
}
@@ -98,8 +98,9 @@ static void _tnl_bind_vertex_list( GLcontext *ctx,
/**
* Execute the buffer and save copied verts.
*/
-void _tnl_playback_vertex_list( GLcontext *ctx, struct tnl_vertex_list *node )
+void _tnl_playback_vertex_list( GLcontext *ctx, void *data )
{
+ struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
TNLcontext *tnl = TNL_CONTEXT(ctx);
if (!node->prim_count)
diff --git a/src/mesa/tnl/t_vtx_api.c b/src/mesa/tnl/t_vtx_api.c
index 8da76b844c2..567fea18cd6 100644
--- a/src/mesa/tnl/t_vtx_api.c
+++ b/src/mesa/tnl/t_vtx_api.c
@@ -33,6 +33,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "context.h"
#include "macros.h"
+#include "vtxfmt.h"
#include "dlist.h"
#include "api_arrayelt.h"
#include "api_noop.h"
@@ -356,6 +357,16 @@ static void choose_##ATTR##_##N( const GLfloat *v ) \
v ); \
}
+#define INIT(ATTR) \
+static void init_##ATTR( TNLcontext *tnl ) \
+{ \
+ tnl->vtx.tabfv[ATTR][0] = choose_##ATTR##_1; \
+ tnl->vtx.tabfv[ATTR][1] = choose_##ATTR##_2; \
+ tnl->vtx.tabfv[ATTR][2] = choose_##ATTR##_3; \
+ tnl->vtx.tabfv[ATTR][3] = choose_##ATTR##_4; \
+}
+
+
#define ATTRS( ATTRIB ) \
ATTRFV( ATTRIB, 1 ) \
ATTRFV( ATTRIB, 2 ) \
@@ -365,6 +376,7 @@ static void choose_##ATTR##_##N( const GLfloat *v ) \
CHOOSE( ATTRIB, 2 ) \
CHOOSE( ATTRIB, 3 ) \
CHOOSE( ATTRIB, 4 ) \
+ INIT( ATTRIB ) \
/* Generate a lot of functions. These are the actual worker
@@ -388,6 +400,32 @@ ATTRS( 13 )
ATTRS( 14 )
ATTRS( 15 )
+static void init_attrfv( TNLcontext *tnl )
+{
+ GLuint i;
+
+ init_0( tnl );
+ init_1( tnl );
+ init_2( tnl );
+ init_3( tnl );
+ init_4( tnl );
+ init_5( tnl );
+ init_6( tnl );
+ init_7( tnl );
+ init_8( tnl );
+ init_9( tnl );
+ init_10( tnl );
+ init_11( tnl );
+ init_12( tnl );
+ init_13( tnl );
+ init_14( tnl );
+ init_15( tnl );
+
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ tnl->vtx.attrsz[i] = 0;
+
+ tnl->vtx.vertex_size = 0;
+}
/* These can be made efficient with codegen. Further, by adding more
* logic to do_choose(), the double-dispatch for legacy entrypoints
@@ -1002,6 +1040,26 @@ static void _tnl_imm_vtxfmt_init( GLcontext *ctx )
+void _tnl_FlushVertices( GLcontext *ctx, GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)
+ return;
+
+ if (tnl->vtx.counter != tnl->vtx.initial_counter)
+ _tnl_flush_vtx( ctx );
+
+ if (flags & FLUSH_UPDATE_CURRENT) {
+ _tnl_copy_to_current( ctx );
+
+ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
+
+ /* reset attrfv table
+ */
+ init_attrfv( tnl );
+ }
+}
void _tnl_vtx_init( GLcontext *ctx )
@@ -1014,6 +1072,9 @@ void _tnl_vtx_init( GLcontext *ctx )
_mesa_vector4f_init( &tmp->Attribs[i], 0, 0);
_tnl_imm_vtxfmt_init( ctx );
+
+ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
+ init_attrfv( tnl );
}
diff --git a/src/mesa/tnl/t_vtx_api.h b/src/mesa/tnl/t_vtx_api.h
index 12edd9077da..98ee617b69b 100644
--- a/src/mesa/tnl/t_vtx_api.h
+++ b/src/mesa/tnl/t_vtx_api.h
@@ -47,4 +47,8 @@ extern void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v );
extern void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u);
extern void _tnl_update_eval( GLcontext *ctx );
+extern GLboolean *_tnl_translate_edgeflag( GLcontext *ctx,
+ const GLfloat *data,
+ GLuint count,
+ GLuint stride );
#endif
diff --git a/src/mesa/tnl/t_vtx_exec.c b/src/mesa/tnl/t_vtx_exec.c
index 31f9e7f958d..cce515db9c2 100644
--- a/src/mesa/tnl/t_vtx_exec.c
+++ b/src/mesa/tnl/t_vtx_exec.c
@@ -33,6 +33,19 @@
#include "t_vtx_api.h"
#include "t_pipeline.h"
+GLboolean *_tnl_translate_edgeflag( GLcontext *ctx, const GLfloat *data,
+ GLuint count, GLuint stride )
+{
+ GLboolean *ef = 0;
+ GLuint i;
+
+ for (i = 0 ; i < count ; i++, data += stride)
+ ef[i] = (data[0] == 1.0);
+
+ return ef;
+}
+
+
/* Some nasty stuff still hanging on here.
*
* TODO - remove VB->ColorPtr, etc and just use the AttrPtr's.
@@ -201,25 +214,3 @@ void _tnl_flush_vtx( GLcontext *ctx )
-void _tnl_FlushVertices( GLcontext *ctx, GLuint flags )
-{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- GLuint i;
-
- if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END)
- return;
-
- if (tnl->vtx.counter != tnl->vtx.initial_counter)
- _tnl_flush_vtx( ctx );
-
- if (flags & FLUSH_UPDATE_CURRENT) {
- _tnl_copy_to_current( ctx );
- _tnl_reset_vtxfmt( ctx );
-
- /* DO THIS IN _tnl_reset_vtxfmt:
- */
- tnl->vtx.vertex_size = 0;
- for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
- tnl->vtx.attrsz[i] = 0;
- }
-}