summaryrefslogtreecommitdiff
path: root/src/mesa/tnl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/tnl')
-rw-r--r--src/mesa/tnl/t_array_api.c55
-rw-r--r--src/mesa/tnl/t_context.c24
-rw-r--r--src/mesa/tnl/t_context.h13
-rw-r--r--src/mesa/tnl/t_eval_api.c24
-rw-r--r--src/mesa/tnl/t_imm_api.c149
-rw-r--r--src/mesa/tnl/t_imm_api.h3
-rw-r--r--src/mesa/tnl/t_imm_dlist.c5
-rw-r--r--src/mesa/tnl/t_imm_eval.c14
-rw-r--r--src/mesa/tnl/t_imm_exec.c11
-rw-r--r--src/mesa/tnl/t_imm_fixup.c4
-rw-r--r--src/mesa/tnl/t_vb_render.c9
-rw-r--r--src/mesa/tnl/t_vb_vertex.c9
12 files changed, 185 insertions, 135 deletions
diff --git a/src/mesa/tnl/t_array_api.c b/src/mesa/tnl/t_array_api.c
index 1187538c73..0ad9ca419b 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.24 2002/01/22 14:35:16 brianp Exp $ */
+/* $Id: t_array_api.c,v 1.25 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -53,10 +53,9 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start,
{
if (_tnl_hard_begin( ctx, mode )) {
GLint i;
- for (i = start; i < count; i++) {
- _tnl_array_element( ctx, i );
- }
- _tnl_end( ctx );
+ for (i = start; i < count; i++)
+ glArrayElement( i );
+ glEnd();
}
}
@@ -64,13 +63,11 @@ static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start,
static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count,
const GLuint *indices)
{
- /* Simple version of the above code.
- */
if (_tnl_hard_begin(ctx, mode)) {
GLint i;
for (i = 0 ; i < count ; i++)
- _tnl_array_element( ctx, indices[i] );
- _tnl_end( ctx );
+ glArrayElement( indices[i] );
+ glEnd();
}
}
@@ -82,6 +79,10 @@ static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode,
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
FLUSH_CURRENT( ctx, 0 );
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+ if (tnl->pipeline.build_state_changes)
+ _tnl_validate_pipeline( ctx );
_tnl_vb_bind_arrays( ctx, start, end );
@@ -112,8 +113,10 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
GET_CURRENT_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
-
-/* fprintf(stderr, "%s %d %d\n", __FUNCTION__, start, count); */
+ GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_tnl_DrawArrays %d %d\n", start, count);
/* Check arguments, etc.
*/
@@ -126,10 +129,16 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
if (ctx->CompileFlag) {
fallback_drawarrays( ctx, mode, start, start + count );
}
+ else if (!ctx->Array.LockCount && count < thresh) {
+ /* Small primitives: attempt to share a vb (at the expense of
+ * using the immediate interface).
+ */
+ fallback_drawarrays( ctx, mode, start, start + count );
+ }
else if (ctx->Array.LockCount &&
count < (GLint) ctx->Const.MaxArrayLockSize) {
- /* Small primitives which can fit in a single vertex buffer:
+ /* Locked primitives which can fit in a single vertex buffer:
*/
FLUSH_CURRENT( ctx, 0 );
@@ -210,10 +219,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
FLUSH_CURRENT( ctx, 0 );
-/* fprintf(stderr, "start %d count %d min %d modulo %d skip %d\n", */
-/* start, count, minimum, modulo, skip); */
-
-
bufsz -= bufsz % modulo;
bufsz -= minimum;
count += start;
@@ -222,8 +227,6 @@ _tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
nr = MIN2( bufsz, count - j );
-/* fprintf(stderr, "%d..%d\n", j - minimum, j+nr); */
-
_tnl_vb_bind_arrays( ctx, j - minimum, j + nr );
VB->FirstPrimitive = 0;
@@ -246,10 +249,10 @@ _tnl_DrawRangeElements(GLenum mode,
GLsizei count, GLenum type, const GLvoid *indices)
{
GET_CURRENT_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint *ui_indices;
-
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_tnl_DrawRangeElements %d %d %d\n", start, end, count);
/* Check arguments, etc.
*/
@@ -257,9 +260,6 @@ _tnl_DrawRangeElements(GLenum mode,
type, indices ))
return;
- if (tnl->pipeline.build_state_changes)
- _tnl_validate_pipeline( ctx );
-
ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
count, type, indices );
@@ -316,19 +316,16 @@ _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices)
{
GET_CURRENT_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
GLuint *ui_indices;
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_tnl_DrawElements %d\n", count);
/* Check arguments, etc.
*/
if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
return;
- if (tnl->pipeline.build_state_changes)
- _tnl_validate_pipeline( ctx );
-
ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
count, type, indices );
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index 2cea4b1dcd..7be74c61c6 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.24 2002/02/13 00:53:20 keithw Exp $ */
+/* $Id: t_context.c,v 1.25 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -110,12 +110,15 @@ _tnl_CreateContext( GLcontext *ctx )
/* Hook our functions into exec and compile dispatch tables.
*/
_mesa_install_exec_vtxfmt( ctx, &tnl->vtxfmt );
- _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt );
- ctx->Save->CallList = _mesa_save_CallList;
- ctx->Save->CallLists = _mesa_save_CallLists;
- ctx->Save->EvalMesh1 = _mesa_save_EvalMesh1;
- ctx->Save->EvalMesh2 = _mesa_save_EvalMesh2;
- ctx->Save->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 );
+
/* Set a few default values in the driver struct.
*/
@@ -200,12 +203,7 @@ _tnl_wakeup_save_exec( GLcontext *ctx )
TNLcontext *tnl = TNL_CONTEXT(ctx);
_tnl_wakeup_exec( ctx );
- _mesa_install_save_vtxfmt( ctx, &tnl->vtxfmt );
- ctx->Save->CallList = _mesa_save_CallList; /* fixme */
- ctx->Save->CallLists = _mesa_save_CallLists;
- ctx->Save->EvalMesh1 = _mesa_save_EvalMesh1; /* fixme */
- ctx->Save->EvalMesh2 = _mesa_save_EvalMesh2;
- ctx->Save->Begin = _tnl_save_Begin;
+ _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt );
}
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index 92483e6999..31d917f3d5 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.39 2002/04/04 18:25:40 kschultz Exp $ */
+/* $Id: t_context.h,v 1.40 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -387,9 +387,13 @@ struct tnl_device_driver {
*/
void (*NotifyMaterialChange)(GLcontext *ctx);
- /* Alert tnl-aware drivers of changes to material, especially in
- * exec_empty_cassette, which doesn't otherwise reach the driver.
- * --> Need to be able to disable exec_empty_cassette???
+ /* Alert tnl-aware drivers of changes to material.
+ */
+
+ GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
+ /* Allow drivers to hook in optimized begin/end engines.
+ * Return value: GL_TRUE - driver handled the begin
+ * GL_FALSE - driver didn't handle the begin
*/
/***
@@ -539,6 +543,7 @@ typedef struct {
/* Functions to be plugged into dispatch when tnl is active.
*/
GLvertexformat vtxfmt;
+ GLvertexformat save_vtxfmt;
} TNLcontext;
diff --git a/src/mesa/tnl/t_eval_api.c b/src/mesa/tnl/t_eval_api.c
index 37d8f69118..fc6e671bfe 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.8 2001/12/03 17:39:12 keithw Exp $ */
+/* $Id: t_eval_api.c,v 1.9 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -100,7 +100,12 @@ _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 );
@@ -110,7 +115,7 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
ctx->CompileFlag = GL_FALSE;
}
- _tnl_hard_begin( ctx, prim );
+ _tnl_Begin( prim );
for (i=i1;i<=i2;i++,u+=du) {
_tnl_eval_coord1f( ctx, u );
}
@@ -119,6 +124,7 @@ _tnl_exec_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
/* Need this for replay *and* compile:
*/
FLUSH_VERTICES( ctx, 0 );
+ tnl->Driver.NotifyBegin = NotifyBegin;
if (compiling) {
TNL_CURRENT_IM(ctx)->ref_count--;
@@ -160,6 +166,11 @@ _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 );
@@ -171,7 +182,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
switch (mode) {
case GL_POINT:
- _tnl_hard_begin( ctx, GL_POINTS );
+ _tnl_Begin( 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 );
@@ -181,14 +192,14 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
break;
case GL_LINE:
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
- _tnl_hard_begin( ctx, GL_LINE_STRIP );
+ _tnl_Begin( GL_LINE_STRIP );
for (u=u1,i=i1;i<=i2;i++,u+=du) {
_tnl_eval_coord2f( ctx, u, v );
}
_tnl_end(ctx);
}
for (u=u1,i=i1;i<=i2;i++,u+=du) {
- _tnl_hard_begin( ctx, GL_LINE_STRIP );
+ _tnl_Begin( GL_LINE_STRIP );
for (v=v1,j=j1;j<=j2;j++,v+=dv) {
_tnl_eval_coord2f( ctx, u, v );
}
@@ -197,7 +208,7 @@ _tnl_exec_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
break;
case GL_FILL:
for (v=v1,j=j1;j<j2;j++,v+=dv) {
- _tnl_hard_begin( ctx, GL_TRIANGLE_STRIP );
+ _tnl_Begin( 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 );
@@ -213,6 +224,7 @@ _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--;
diff --git a/src/mesa/tnl/t_imm_api.c b/src/mesa/tnl/t_imm_api.c
index d19f6a6e00..a67851df13 100644
--- a/src/mesa/tnl/t_imm_api.c
+++ b/src/mesa/tnl/t_imm_api.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_api.c,v 1.25 2002/02/13 00:53:20 keithw Exp $ */
+/* $Id: t_imm_api.c,v 1.26 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -53,6 +53,10 @@ void _tnl_flush_immediate( struct immediate *IM )
{
GLcontext *ctx = IM->backref;
+ if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
+ fprintf(stderr, "_tnl_flush_immediate IM: %d compiling: %d\n",
+ IM->id, ctx->CompileFlag);
+
if (IM->FlushElt == FLUSH_ELT_EAGER) {
_tnl_translate_array_elts( ctx, IM, IM->LastPrimitive, IM->Count );
}
@@ -69,10 +73,18 @@ void _tnl_flush_immediate( struct immediate *IM )
}
+/* Hook for ctx->Driver.FlushVertices:
+ */
void _tnl_flush_vertices( GLcontext *ctx, GLuint flags )
{
struct immediate *IM = TNL_CURRENT_IM(ctx);
+ if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
+ fprintf( stderr,
+ "_tnl_flush_vertices flags %x IM(%d) %d..%d Flag[%d]: %x\n",
+ flags, IM->id, IM->Start, IM->Count, IM->Start,
+ IM->Flag[IM->Start]);
+
if (IM->Flag[IM->Start])
if ((flags & FLUSH_UPDATE_CURRENT) || IM->Count > IM->Start)
_tnl_flush_immediate( IM );
@@ -81,29 +93,23 @@ void _tnl_flush_vertices( GLcontext *ctx, GLuint flags )
-/* Note the ctx argument. This function called only by _tnl_Begin,
- * _tnl_save_Begin and _tnl_hard_begin() in this file.
- */
-static void
-_tnl_begin( GLcontext *ctx, GLenum p )
+void
+_tnl_save_Begin( GLenum mode )
{
+ GET_CURRENT_CONTEXT(ctx);
struct immediate *IM = TNL_CURRENT_IM(ctx);
GLuint inflags, state;
- if (MESA_VERBOSE&VERBOSE_API)
- fprintf(stderr, "glBegin(IM %d) %s\n", IM->id,
- _mesa_lookup_enum_by_nr(p));
+/* fprintf(stderr, "%s: before: %x\n", __FUNCTION__, IM->BeginState); */
+
+ if (mode > GL_POLYGON) {
+ _mesa_compile_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" );
+ return;
+ }
if (ctx->NewState)
_mesa_update_state(ctx);
- /* if only a very few slots left, might as well flush now
- */
- if (IM->Count > IMM_MAXDATA-8) {
- _tnl_flush_immediate( IM );
- IM = TNL_CURRENT_IM(ctx);
- }
-
/* Check for and flush buffered vertices from internal operations.
*/
if (IM->SavedBeginState) {
@@ -124,7 +130,7 @@ _tnl_begin( GLcontext *ctx, GLenum p )
state |= (VERT_BEGIN_0|VERT_BEGIN_1);
IM->Flag[count] |= VERT_BIT_BEGIN;
- IM->Primitive[count] = p | PRIM_BEGIN;
+ IM->Primitive[count] = mode | PRIM_BEGIN;
IM->PrimitiveLength[IM->LastPrimitive] = count - IM->LastPrimitive;
IM->LastPrimitive = count;
@@ -139,20 +145,15 @@ _tnl_begin( GLcontext *ctx, GLenum p )
ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
IM->BeginState = state;
-}
-
-void
-_tnl_save_Begin( GLenum mode )
-{
- GET_CURRENT_CONTEXT(ctx);
-
- if (mode > GL_POLYGON) {
- _mesa_compile_error( ctx, GL_INVALID_ENUM, "glBegin" );
- return;
+ if (ctx->ExecuteFlag) {
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" );
+ }
+ else
+ ctx->Driver.CurrentExecPrimitive = mode;
}
- _tnl_begin( ctx, mode );
/* Update save_primitive now.
*/
@@ -167,18 +168,52 @@ void
_tnl_Begin( GLenum mode )
{
GET_CURRENT_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ ASSERT (!ctx->CompileFlag);
if (mode > GL_POLYGON) {
- _mesa_compile_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ _mesa_error( ctx, GL_INVALID_ENUM, "_tnl_Begin" );
return;
}
- _tnl_begin(ctx, mode);
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_Begin" );
+ return;
+ }
- /* Update exec_primitive now.
- */
- ASSERT (!ctx->CompileFlag);
- if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) {
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ {
+ struct immediate *IM = TNL_CURRENT_IM(ctx);
+ GLuint count = IM->Count;
+ GLuint last = IM->LastPrimitive;
+
+ if (IM->Start == IM->Count &&
+ tnl->Driver.NotifyBegin &&
+ tnl->Driver.NotifyBegin( ctx, mode ))
+ return;
+
+ assert( IM->SavedBeginState == 0 );
+ assert( IM->BeginState == 0 );
+
+ /* Not quite right. Need to use the fallback '_aa_ArrayElement'
+ * when not known to be inside begin/end and arrays are
+ * unlocked.
+ */
+ if (IM->FlushElt == FLUSH_ELT_EAGER) {
+ _tnl_translate_array_elts( ctx, IM, last, count );
+ }
+
+ IM->Flag[count] |= VERT_BIT_BEGIN;
+ IM->Primitive[count] = mode | PRIM_BEGIN;
+ IM->PrimitiveLength[last] = count - last;
+ IM->LastPrimitive = count;
+ IM->BeginState = (VERT_BEGIN_0|VERT_BEGIN_1);
+
+/* fprintf(stderr, "%s: %x\n", __FUNCTION__, IM->BeginState); */
+
+ ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
ctx->Driver.CurrentExecPrimitive = mode;
}
}
@@ -191,12 +226,13 @@ _tnl_Begin( GLenum mode )
GLboolean
_tnl_hard_begin( GLcontext *ctx, GLenum p )
{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
if (!ctx->CompileFlag) {
/* If not compiling, treat as a normal begin().
*/
- _tnl_begin( ctx, p );
- ASSERT(ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END);
- ctx->Driver.CurrentExecPrimitive = p;
+/* fprintf(stderr, "%s: treating as glBegin\n", __FUNCTION__); */
+ glBegin( p );
return GL_TRUE;
}
else {
@@ -262,7 +298,7 @@ _tnl_hard_begin( GLcontext *ctx, GLenum p )
return GL_TRUE;
default:
- ASSERT (0);
+ assert (0);
return GL_TRUE;
}
}
@@ -285,6 +321,8 @@ _tnl_end( GLcontext *ctx )
GLuint state = IM->BeginState;
GLuint inflags = (~state) & (VERT_BEGIN_0|VERT_BEGIN_1);
+ assert( ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES );
+
state |= inflags << 2; /* errors */
if (inflags != (VERT_BEGIN_0|VERT_BEGIN_1))
@@ -308,8 +346,11 @@ _tnl_end( GLcontext *ctx )
IM->BeginState = state;
- if (!ctx->CompileFlag) {
- ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
+ if (ctx->ExecuteFlag) {
+ if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END)
+ _mesa_error( ctx, GL_INVALID_OPERATION, "_tnl_End" );
+ else
+ ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
}
/* You can set this flag to get the old 'flush_vb on glEnd()'
@@ -1076,19 +1117,6 @@ _tnl_eval_coord2f( GLcontext *CC, GLfloat u, GLfloat v )
EVALCOORD2( i, u, v );
}
-void
-_tnl_array_element( GLcontext *CC, GLint i )
-{
- struct immediate *im = TNL_CURRENT_IM(CC);
- ARRAY_ELT( im, i );
-}
-
-void
-_tnl_vertex2f( GLcontext *ctx, GLfloat x, GLfloat y )
-{
- struct immediate *im = TNL_CURRENT_IM(ctx);
- VERTEX2( im, x, y );
-}
@@ -1141,14 +1169,12 @@ _tnl_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
{
GET_CURRENT_CONTEXT(ctx);
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
-
if (_tnl_hard_begin( ctx, GL_QUADS )) {
- _tnl_vertex2f( ctx, x1, y1 );
- _tnl_vertex2f( ctx, x2, y1 );
- _tnl_vertex2f( ctx, x2, y2 );
- _tnl_vertex2f( ctx, x1, y2 );
- _tnl_end( ctx );
+ glVertex2f( x1, y1 );
+ glVertex2f( x2, y1 );
+ glVertex2f( x2, y2 );
+ glVertex2f( x1, y2 );
+ glEnd();
}
}
@@ -1164,6 +1190,9 @@ _tnl_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
if (bitmask == 0)
return;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_tnl_Materialfv\n");
if (tnl->IsolateMaterials &&
!(IM->BeginState & VERT_BEGIN_1)) /* heuristic */
diff --git a/src/mesa/tnl/t_imm_api.h b/src/mesa/tnl/t_imm_api.h
index c13dde77aa..6615a9ce93 100644
--- a/src/mesa/tnl/t_imm_api.h
+++ b/src/mesa/tnl/t_imm_api.h
@@ -1,4 +1,4 @@
-/* $Id: t_imm_api.h,v 1.4 2001/12/14 02:51:44 brianp Exp $ */
+/* $Id: t_imm_api.h,v 1.5 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -33,6 +33,7 @@
extern void _tnl_save_Begin( GLenum mode );
+extern void _tnl_Begin( GLenum mode );
extern void _tnl_Begin( GLenum mode );
diff --git a/src/mesa/tnl/t_imm_dlist.c b/src/mesa/tnl/t_imm_dlist.c
index dfc4e7795d..8805c23b12 100644
--- a/src/mesa/tnl/t_imm_dlist.c
+++ b/src/mesa/tnl/t_imm_dlist.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_dlist.c,v 1.38 2002/02/13 00:53:20 keithw Exp $ */
+/* $Id: t_imm_dlist.c,v 1.39 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -128,6 +128,9 @@ _tnl_compile_cassette( GLcontext *ctx, struct immediate *IM )
TNLvertexcassette *node;
GLuint new_beginstate;
+ if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
+ fprintf(stderr, "_tnl_compiled_cassette IM: %d\n", IM->id);
+
if (IM->FlushElt) {
ASSERT (IM->FlushElt == FLUSH_ELT_LAZY);
_tnl_translate_array_elts( ctx, IM, IM->Start, IM->Count );
diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c
index 01c886bec0..1b95f15f10 100644
--- a/src/mesa/tnl/t_imm_eval.c
+++ b/src/mesa/tnl/t_imm_eval.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_eval.c,v 1.21 2002/01/22 14:35:16 brianp Exp $ */
+/* $Id: t_imm_eval.c,v 1.22 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -242,7 +242,6 @@ static void eval2_4f( GLvector4f *dest,
if (flags[i] & (VERT_BIT_EVAL_C2|VERT_BIT_EVAL_P2)) {
GLfloat u = (coord[i][0] - u1) * du;
GLfloat v = (coord[i][1] - v1) * dv;
-/* fprintf(stderr, "coord %d: %f %f\n", i, coord[i][0], coord[i][1]); */
_math_horner_bezier_surf(map->Points, to[i], u, v, dimension,
map->Uorder, map->Vorder);
@@ -344,8 +343,6 @@ static void copy_4f_stride( GLfloat to[][4], GLfloat *from,
MEMCPY( to, from, count * sizeof(to[0]));
else {
GLuint i;
-/* fprintf(stderr, "%s stride %d count %d\n", __FUNCTION__, */
-/* stride, count); */
for (i = 0 ; i < count ; i++, STRIDE_F(from, stride))
COPY_4FV( to[i], from );
}
@@ -354,11 +351,7 @@ static void copy_4f_stride( GLfloat to[][4], GLfloat *from,
static void copy_3f( GLfloat to[][4], GLfloat from[][4], GLuint count )
{
GLuint i;
-/* MEMCPY( to, from, (count) * sizeof(to[0])); */
for (i = 0 ; i < count ; i++) {
-/* fprintf(stderr, "copy norm %d from %p: %f %f %f\n", i, */
-/* from[i], */
-/* from[i][0], from[i][1], from[i][2]); */
COPY_3FV(to[i], from[i]);
}
}
@@ -459,9 +452,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM )
else
copycount = IM->Count - IM->CopyStart; /* copy all vertices */
-/* fprintf(stderr, "%s copystart %d start %d count %d copycount %d\n", */
-/* __FUNCTION__, IM->CopyStart, IM->Start, IM->Count, copycount); */
-
if (!store)
store = tnl->eval.im = _tnl_alloc_immediate( ctx );
@@ -711,8 +701,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM )
struct vertex_buffer *VB = &tnl->vb;
GLuint i,j,count = VB->Count;
-/* fprintf(stderr, "PURGING\n"); */
-
for (i = 0, j = 0 ; i < count ; i++) {
if (flags[i] & vertex) {
store->Elt[j++] = i;
diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c
index 007d688e14..c2b31ee869 100644
--- a/src/mesa/tnl/t_imm_exec.c
+++ b/src/mesa/tnl/t_imm_exec.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_exec.c,v 1.37 2002/02/13 23:53:19 keithw Exp $ */
+/* $Id: t_imm_exec.c,v 1.38 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -71,6 +71,10 @@ static void reset_input( GLcontext *ctx,
if (start < IM->Count+2)
MEMSET(IM->Flag + start, 0, sizeof(GLuint) * (IM->Count+2-start));
+ if (MESA_VERBOSE & VERBOSE_IMMEDIATE)
+ fprintf(stderr, "reset_input: IM(%d) new %x\n",
+ IM->id, beginstate);
+
IM->Start = start;
IM->Count = start;
IM->LastMaterial = start;
@@ -432,7 +436,7 @@ static void exec_elt_cassette( GLcontext *ctx, struct immediate *IM )
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *VB = &tnl->vb;
-/* fprintf(stderr, "%s\n", __FUNCTION__); */
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
_tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst, ctx->Array.LockCount );
@@ -514,6 +518,9 @@ void _tnl_execute_cassette( GLcontext *ctx, struct immediate *IM )
if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1)
ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES;
+
+/* fprintf(stderr, "%s: NeedFlush: %x\n", __FUNCTION__, */
+/* ctx->Driver.NeedFlush); */
}
diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c
index 8e3f52e621..c589980588 100644
--- a/src/mesa/tnl/t_imm_fixup.c
+++ b/src/mesa/tnl/t_imm_fixup.c
@@ -1,4 +1,4 @@
-/* $Id: t_imm_fixup.c,v 1.34 2002/02/13 00:53:20 keithw Exp $ */
+/* $Id: t_imm_fixup.c,v 1.35 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -386,6 +386,7 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM )
vulnerable );
+ ++i;
} while (vulnerable);
}
}
@@ -680,6 +681,7 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM )
vulnerable );
+ ++i;
} while (vulnerable);
}
}
diff --git a/src/mesa/tnl/t_vb_render.c b/src/mesa/tnl/t_vb_render.c
index 1721b88323..496c22cc42 100644
--- a/src/mesa/tnl/t_vb_render.c
+++ b/src/mesa/tnl/t_vb_render.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_render.c,v 1.28 2002/02/13 00:53:20 keithw Exp $ */
+/* $Id: t_vb_render.c,v 1.29 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -42,6 +42,7 @@
#include "glheader.h"
#include "context.h"
+#include "enums.h"
#include "macros.h"
#include "mem.h"
#include "mtypes.h"
@@ -324,6 +325,12 @@ static GLboolean run_render( GLcontext *ctx,
length= VB->PrimitiveLength[i];
ASSERT(length || (flags & PRIM_LAST));
ASSERT((flags & PRIM_MODE_MASK) <= GL_POLYGON+1);
+
+ if (MESA_VERBOSE & VERBOSE_PRIMS)
+ fprintf(stderr, "MESA prim %s %d..%d\n",
+ _mesa_lookup_enum_by_nr(flags & PRIM_MODE_MASK),
+ i, i+length);
+
if (length)
tab[flags & PRIM_MODE_MASK]( ctx, i, i + length, flags );
}
diff --git a/src/mesa/tnl/t_vb_vertex.c b/src/mesa/tnl/t_vb_vertex.c
index 4369df16f6..e13b8bc0a1 100644
--- a/src/mesa/tnl/t_vb_vertex.c
+++ b/src/mesa/tnl/t_vb_vertex.c
@@ -1,4 +1,4 @@
-/* $Id: t_vb_vertex.c,v 1.13 2002/03/29 17:27:59 brianp Exp $ */
+/* $Id: t_vb_vertex.c,v 1.14 2002/04/09 16:56:52 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -140,7 +140,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
if (stage->changed_inputs) {
if (ctx->_NeedEyeCoords) {
- /* Separate modelview and project transformations:
+ /* Separate modelview transformation:
+ * Use combined ModelProject to avoid some depth artifacts
*/
if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
VB->EyePtr = VB->ObjPtr;
@@ -153,8 +154,8 @@ static GLboolean run_vertex_stage( GLcontext *ctx,
VB->ClipPtr = VB->EyePtr;
else
VB->ClipPtr = TransformRaw( &store->clip,
- ctx->ProjectionMatrixStack.Top,
- VB->EyePtr );
+ &ctx->_ModelProjectMatrix,
+ VB->ObjPtr );
}
else {
/* Combined modelviewproject transform: