-/* $Id: api_arrayelt.c,v 1.6 2002/01/14 16:06:35 brianp Exp $ */
+/* $Id: api_arrayelt.c,v 1.7 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
static void (*colorfuncs[2][8])( const void * ) = {
{ (array_func)glColor3bv,
- (array_func)glColor3ub,
+ (array_func)glColor3ubv,
(array_func)glColor3sv,
(array_func)glColor3usv,
(array_func)glColor3iv,
(array_func)glColor3dv },
{ (array_func)glColor4bv,
- (array_func)glColor4ub,
+ (array_func)glColor4ubv,
(array_func)glColor4sv,
(array_func)glColor4usv,
(array_func)glColor4iv,
-/* $Id: api_noop.c,v 1.9 2001/12/14 02:50:01 brianp Exp $ */
+/* $Id: api_noop.c,v 1.10 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
}
}
-void _mesa_noop_MultiTexCoord1fvARB( GLenum target, GLfloat *v )
+void _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLuint unit = target - GL_TEXTURE0_ARB;
}
}
-void _mesa_noop_MultiTexCoord2fvARB( GLenum target, GLfloat *v )
+void _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLuint unit = target - GL_TEXTURE0_ARB;
}
}
-void _mesa_noop_MultiTexCoord3fvARB( GLenum target, GLfloat *v )
+void _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLuint unit = target - GL_TEXTURE0_ARB;
}
}
-void _mesa_noop_MultiTexCoord4fvARB( GLenum target, GLfloat *v )
+void _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLuint unit = target - GL_TEXTURE0_ARB;
dest[3] = 1;
}
-void _mesa_noop_TexCoord1fv( GLfloat *v )
+void _mesa_noop_TexCoord1fv( const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
dest[3] = 1;
}
-void _mesa_noop_TexCoord2fv( GLfloat *v )
+void _mesa_noop_TexCoord2fv( const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
dest[3] = 1;
}
-void _mesa_noop_TexCoord3fv( GLfloat *v )
+void _mesa_noop_TexCoord3fv( const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
COPY_FLOAT(dest[3], d);
}
-void _mesa_noop_TexCoord4fv( GLfloat *v )
+void _mesa_noop_TexCoord4fv( const GLfloat *v )
{
GET_CURRENT_CONTEXT(ctx);
GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
COPY_FLOAT(dest[3], v[3]);
}
+/* Useful outside begin/end?
+ */
+void _mesa_noop_Vertex2fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void _mesa_noop_Vertex3fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void _mesa_noop_Vertex4fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void _mesa_noop_Vertex2f( GLfloat a, GLfloat b )
+{
+ (void) a; (void) b;
+}
+
+void _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c )
+{
+ (void) a; (void) b; (void) c;
+}
+
+void _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
+{
+ (void) a; (void) b; (void) c; (void) d;
+}
+
+
+
void _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x,
GLfloat y, GLfloat z, GLfloat w )
{
-/* $Id: api_noop.h,v 1.4 2001/12/14 02:50:01 brianp Exp $ */
+/* $Id: api_noop.h,v 1.5 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
extern void _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a );
-extern void _mesa_noop_MultiTexCoord1fvARB( GLenum target, GLfloat *v );
+extern void _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v );
extern void _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a,
GLfloat b );
-extern void _mesa_noop_MultiTexCoord2fvARB( GLenum target, GLfloat *v );
+extern void _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v );
extern void _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a,
GLfloat b, GLfloat c);
-extern void _mesa_noop_MultiTexCoord3fvARB( GLenum target, GLfloat *v );
+extern void _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v );
extern void _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a,
GLfloat b, GLfloat c, GLfloat d );
-extern void _mesa_noop_MultiTexCoord4fvARB( GLenum target, GLfloat *v );
+extern void _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v );
extern void _mesa_noop_SecondaryColor3ubEXT( GLubyte a, GLubyte b, GLubyte c );
extern void _mesa_noop_TexCoord1f( GLfloat a );
-extern void _mesa_noop_TexCoord1fv( GLfloat *v );
+extern void _mesa_noop_TexCoord1fv( const GLfloat *v );
extern void _mesa_noop_TexCoord2f( GLfloat a, GLfloat b );
-extern void _mesa_noop_TexCoord2fv( GLfloat *v );
+extern void _mesa_noop_TexCoord2fv( const GLfloat *v );
extern void _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c );
-extern void _mesa_noop_TexCoord3fv( GLfloat *v );
+extern void _mesa_noop_TexCoord3fv( const GLfloat *v );
extern void _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d );
-extern void _mesa_noop_TexCoord4fv( GLfloat *v );
+extern void _mesa_noop_TexCoord4fv( const GLfloat *v );
+
+extern void _mesa_noop_Vertex2fv( const GLfloat *v );
+
+extern void _mesa_noop_Vertex3fv( const GLfloat *v );
+
+extern void _mesa_noop_Vertex4fv( const GLfloat *v );
+
+extern void _mesa_noop_Vertex2f( GLfloat a, GLfloat b );
+
+extern void _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c );
+
+extern void _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d );
extern void _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x,
GLfloat y, GLfloat z, GLfloat w );
-/* $Id: context.c,v 1.159 2002/04/09 14:58:03 keithw Exp $ */
+/* $Id: context.c,v 1.160 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
#endif
#ifndef MESA_VERBOSE
-int MESA_VERBOSE = 0
-/* | VERBOSE_PIPELINE */
-/* | VERBOSE_IMMEDIATE */
-/* | VERBOSE_VARRAY */
-/* | VERBOSE_TEXTURE */
-/* | VERBOSE_API */
-/* | VERBOSE_DRIVER */
-/* | VERBOSE_STATE */
-/* | VERBOSE_DISPLAY_LIST */
-;
+int MESA_VERBOSE = 0;
#endif
#ifndef MESA_DEBUG_FLAGS
-int MESA_DEBUG_FLAGS = 0
-/* | DEBUG_ALWAYS_FLUSH */
-;
+int MESA_DEBUG_FLAGS = 0;
#endif
}
+static void add_debug_flags( const char *debug )
+{
+#ifdef MESA_DEBUG
+ if (strstr(debug, "varray"))
+ MESA_VERBOSE |= VERBOSE_VARRAY;
+
+ if (strstr(debug, "tex"))
+ MESA_VERBOSE |= VERBOSE_TEXTURE;
+
+ if (strstr(debug, "imm"))
+ MESA_VERBOSE |= VERBOSE_IMMEDIATE;
+
+ if (strstr(debug, "pipe"))
+ MESA_VERBOSE |= VERBOSE_PIPELINE;
+
+ if (strstr(debug, "driver"))
+ MESA_VERBOSE |= VERBOSE_DRIVER;
+
+ if (strstr(debug, "state"))
+ MESA_VERBOSE |= VERBOSE_STATE;
+
+ if (strstr(debug, "api"))
+ MESA_VERBOSE |= VERBOSE_API;
+
+ if (strstr(debug, "list"))
+ MESA_VERBOSE |= VERBOSE_DISPLAY_LIST;
+
+ if (strstr(debug, "lighting"))
+ MESA_VERBOSE |= VERBOSE_LIGHTING;
+
+ /* Debug flag:
+ */
+ if (strstr(debug, "flush"))
+ MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
+#endif
+}
+
+
/*
* Initialize a GLcontext struct. This includes allocating all the
* other structs and arrays which hang off of the context by pointers.
trInitDispatch(ctx->TraceDispatch);
#endif
+
+ if (getenv("MESA_DEBUG"))
+ add_debug_flags(getenv("MESA_DEBUG"));
+
+ if (getenv("MESA_VERBOSE"))
+ add_debug_flags(getenv("MESA_VERBOSE"));
+
return GL_TRUE;
}
-/* $Id: dlist.c,v 1.85 2002/04/02 16:15:17 brianp Exp $ */
+/* $Id: dlist.c,v 1.86 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
{
GET_CURRENT_CONTEXT(ctx);
FLUSH_CURRENT(ctx, 0); /* must be called before assert */
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
if (MESA_VERBOSE&VERBOSE_API)
fprintf(stderr, "glEndList\n");
- ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx ); /* ??? */
-
/* Check that a list is under construction */
if (!ctx->CurrentListPtr) {
_mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
ctx->CurrentDispatch = ctx->Exec;
_glapi_set_dispatch( ctx->CurrentDispatch );
-
}
/* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
/* execute the display list, and restore the CompileFlag. */
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_mesa_CallList %d\n", list);
+
/* mesa_print_display_list( list ); */
save_compile_flag = ctx->CompileFlag;
GLint i;
GLboolean save_compile_flag;
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_mesa_CallLists %d\n", n);
+
/* Save the CompileFlag status, turn it off, execute display list,
* and restore the CompileFlag.
*/
-/* $Id: mtypes.h,v 1.69 2002/03/29 17:27:59 brianp Exp $ */
+/* $Id: mtypes.h,v 1.70 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
/* The string names for GL_POINT, GL_LINE_LOOP, etc */
extern const char *_mesa_prim_name[GL_POLYGON+4];
+#ifndef MESA_DEBUG
+#define MESA_DEBUG
+#endif
#ifdef MESA_DEBUG
extern int MESA_VERBOSE;
VERBOSE_DRIVER = 0x0010,
VERBOSE_STATE = 0x0020,
VERBOSE_API = 0x0040,
- VERBOSE_DISPLAY_LIST = 0x0200,
- VERBOSE_LIGHTING = 0x0400
+ VERBOSE_DISPLAY_LIST = 0x0100,
+ VERBOSE_LIGHTING = 0x0200,
+ VERBOSE_PRIMS = 0x0400,
+ VERBOSE_VERTS = 0x0800
};
/* Eventually let the driver specify what statechanges require a flush:
*/
-#define FLUSH_VERTICES(ctx, newstate) \
-do { \
- if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
- ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
- ctx->NewState |= newstate; \
+#define FLUSH_VERTICES(ctx, newstate) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ fprintf(stderr, "FLUSH_VERTICES in %s\n", __FUNCTION__); \
+ if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
+ ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
+ ctx->NewState |= newstate; \
} while (0)
-#define FLUSH_CURRENT(ctx, newstate) \
-do { \
- if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
- ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
- ctx->NewState |= newstate; \
+#define FLUSH_CURRENT(ctx, newstate) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ fprintf(stderr, "FLUSH_CURRENT in %s\n", __FUNCTION__); \
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
+ ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
+ ctx->NewState |= newstate; \
} while (0)
#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
-/* $Id: state.c,v 1.80 2002/04/02 16:15:17 brianp Exp $ */
+/* $Id: state.c,v 1.81 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
const GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
if (MESA_VERBOSE & VERBOSE_STATE)
- _mesa_print_state("", new_state);
+ _mesa_print_state("_mesa_update_state", new_state);
if (new_state & _NEW_MODELVIEW)
_math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
-/* $Id: vtxfmt.c,v 1.10 2001/12/15 02:14:43 brianp Exp $ */
+/* $Id: vtxfmt.c,v 1.11 2002/04/09 16:56:50 keithw Exp $ */
/*
* Mesa 3-D graphics library
{ \
GET_CURRENT_CONTEXT(ctx); \
struct gl_tnl_module *tnl = &(ctx->TnlModule); \
- const GLuint new_state = ctx->NewState; \
- \
- if ( new_state ) \
- _mesa_update_state( ctx ); \
- \
- /* Validate the current tnl module. */ \
- if ( new_state & ctx->Driver.NeedValidate ) \
- ctx->Driver.ValidateTnlModule( ctx, new_state ); \
\
ASSERT( tnl->Current ); \
ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \
void _mesa_init_exec_vtxfmt( GLcontext *ctx )
{
install_vtxfmt( ctx->Exec, &neutral_vtxfmt );
+ ctx->TnlModule.SwapCount = 0;
}
-/* $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
{
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();
}
}
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();
}
}
{
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 );
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.
*/
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 );
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;
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;
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.
*/
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 );
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 );
-/* $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
/* 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.
*/
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 );
}
-/* $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
*/
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
*/
/***
/* Functions to be plugged into dispatch when tnl is active.
*/
GLvertexformat vtxfmt;
+ GLvertexformat save_vtxfmt;
} TNLcontext;
-/* $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
*/
{
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 );
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 );
}
/* Need this for replay *and* compile:
*/
FLUSH_VERTICES( ctx, 0 );
+ tnl->Driver.NotifyBegin = NotifyBegin;
if (compiling) {
TNL_CURRENT_IM(ctx)->ref_count--;
{
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 );
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 );
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 );
}
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 );
/* Need this for replay *and* compile:
*/
FLUSH_VERTICES( ctx, 0 );
+ tnl->Driver.NotifyBegin = NotifyBegin;
if (compiling) {
TNL_CURRENT_IM(ctx)->ref_count--;
-/* $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
{
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 );
}
}
+/* 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 );
-/* 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) {
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;
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.
*/
_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;
}
}
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 {
return GL_TRUE;
default:
- ASSERT (0);
+ assert (0);
return GL_TRUE;
}
}
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))
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()'
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 );
-}
{
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();
}
}
if (bitmask == 0)
return;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ fprintf(stderr, "_tnl_Materialfv\n");
if (tnl->IsolateMaterials &&
!(IM->BeginState & VERT_BEGIN_1)) /* heuristic */
-/* $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
extern void _tnl_save_Begin( GLenum mode );
+extern void _tnl_Begin( GLenum mode );
extern void _tnl_Begin( GLenum mode );
-/* $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
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 );
-/* $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
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);
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 );
}
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]);
}
}
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 );
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;
-/* $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
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;
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 );
if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1)
ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES;
+
+/* fprintf(stderr, "%s: NeedFlush: %x\n", __FUNCTION__, */
+/* ctx->Driver.NeedFlush); */
}
-/* $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
vulnerable );
+ ++i;
} while (vulnerable);
}
}
vulnerable );
+ ++i;
} while (vulnerable);
}
}
-/* $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
#include "glheader.h"
#include "context.h"
+#include "enums.h"
#include "macros.h"
#include "mem.h"
#include "mtypes.h"
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 );
}
-/* $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
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;
VB->ClipPtr = VB->EyePtr;
else
VB->ClipPtr = TransformRaw( &store->clip,
- ctx->ProjectionMatrixStack.Top,
- VB->EyePtr );
+ &ctx->_ModelProjectMatrix,
+ VB->ObjPtr );
}
else {
/* Combined modelviewproject transform: