-/* $Id: t_context.h,v 1.11 2001/01/14 06:14:21 keithw Exp $ */
+/* $Id: t_context.h,v 1.28 2001/06/04 16:09:28 keithw Exp $ */
/*
* Mesa 3-D graphics library
* Version: 3.5
*
- * Copyright (C) 1999 Brian Paul All Rights Reserved.
+ * 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"),
#define IMM_SIZE (IMM_MAXDATA + MAX_CLIPPED_VERTICES)
-/* Values for IM->BeginState
+/* Values for IM->BeginState
*/
#define VERT_BEGIN_0 0x1 /* glBegin (if initially inside beg/end) */
#define VERT_BEGIN_1 0x2 /* glBegin (if initially outside beg/end) */
/* Flags that describe the inputs and outputs of pipeline stages, and
- * the contents of a vertex-cassette.
+ * the contents of a vertex-cassette.
*
* 5 spare flags, rearrangement of eval flags can secure at least 3
- * more.
+ * more.
*/
-#define VERT_OBJ _NEW_ARRAY_VERTEX
-#define VERT_RGBA _NEW_ARRAY_COLOR
-#define VERT_NORM _NEW_ARRAY_NORMAL
-#define VERT_INDEX _NEW_ARRAY_INDEX
-#define VERT_EDGE _NEW_ARRAY_EDGEFLAG
+#define VERT_OBJ _NEW_ARRAY_VERTEX
+#define VERT_RGBA _NEW_ARRAY_COLOR
+#define VERT_NORM _NEW_ARRAY_NORMAL
+#define VERT_INDEX _NEW_ARRAY_INDEX
+#define VERT_EDGE _NEW_ARRAY_EDGEFLAG
#define VERT_SPEC_RGB _NEW_ARRAY_SECONDARYCOLOR
#define VERT_FOG_COORD _NEW_ARRAY_FOGCOORD
#define VERT_TEX0 _NEW_ARRAY_TEXCOORD_0
*/
struct immediate
{
- struct __GLcontextRec *backref;
+ struct __GLcontextRec *backref;
GLuint id, ref_count;
/* This must be saved when immediates are shared in display lists.
GLuint AndFlag, OrFlag;
GLuint TexSize; /* keep track of texcoord sizes */
GLuint BeginState, SavedBeginState;
- GLuint LastPrimitive;
+ GLuint LastPrimitive;
GLuint ArrayEltFlags; /* precalc'ed for glArrayElt */
GLuint ArrayEltIncr;
GLuint ArrayEltFlush;
+
+#define FLUSH_ELT_EAGER 0x1
+#define FLUSH_ELT_LAZY 0x2
GLuint FlushElt;
GLuint MaxTextureUnits; /* precalc'ed for glMultiTexCoordARB */
- /* Temporary values created when vertices are copied into the
+ /* Temporary values created when vertices are copied into the
* first 3 slots of the struct:
*/
GLuint CopyOrFlag;
*/
struct gl_material (*Material)[2];
GLuint *MaterialMask;
- GLfloat *NormalLengths;
+ GLuint LastMaterial;
+ GLuint MaterialOrMask;
+ GLuint MaterialAndMask;
+
GLfloat (*TexCoord[MAX_TEXTURE_UNITS])[4];
GLuint Primitive[IMM_SIZE]; /* BEGIN/END */
GLuint PrimitiveLength[IMM_SIZE]; /* BEGIN/END */
GLuint Flag[IMM_SIZE]; /* VERT_* flags */
- GLchan Color[IMM_SIZE][4];
- GLfloat Obj[IMM_SIZE][4];
+ GLfloat Color[IMM_SIZE][4];
+ GLfloat Obj[IMM_SIZE][4];
GLfloat Normal[IMM_SIZE][3];
GLfloat TexCoord0[IMM_SIZE][4]; /* just VERT_TEX0 */
GLuint Elt[IMM_SIZE];
GLubyte EdgeFlag[IMM_SIZE];
GLuint Index[IMM_SIZE];
- GLubyte SecondaryColor[IMM_SIZE][4];
+ GLfloat SecondaryColor[IMM_SIZE][4];
GLfloat FogCoord[IMM_SIZE];
};
{
GLvector4f Obj;
GLvector3f Normal;
- GLvector4ub Color;
+ struct gl_client_array Color;
+ struct gl_client_array SecondaryColor;
GLvector1ui Index;
GLvector1ub EdgeFlag;
GLvector4f TexCoord[MAX_TEXTURE_UNITS];
GLvector1ui Elt;
- GLvector4ub SecondaryColor;
GLvector1f FogCoord;
};
typedef struct gl_material GLmaterial;
-typedef void (*interp_func)( GLcontext *ctx,
- GLfloat t, GLuint dst, GLuint in, GLuint out,
- GLboolean force_boundary );
-
-typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
-
/* Contains the current state of a running pipeline.
*/
typedef struct vertex_buffer
GLubyte ClipOrMask; /* VERT_CLIP (3) */
GLubyte *ClipMask; /* VERT_CLIP (4) */
GLvector3f *NormalPtr; /* VERT_NORM */
- GLfloat *NormalLengthPtr; /* VERT_NORM (optional) */
GLboolean *EdgeFlag; /* VERT_EDGE */
GLvector4f *TexCoordPtr[MAX_TEXTURE_UNITS]; /* VERT_TEX_0..n */
GLvector1ui *IndexPtr[2]; /* VERT_INDEX */
- GLvector4ub *ColorPtr[2]; /* VERT_RGBA */
- GLvector4ub *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
+ struct gl_client_array *ColorPtr[2]; /* VERT_RGBA */
+ struct gl_client_array *SecondaryColorPtr[2]; /* VERT_SPEC_RGB */
GLvector1f *FogCoordPtr; /* VERT_FOG_COORD */
GLvector1f *PointSizePtr; /* VERT_POINT_SIZE */
GLmaterial (*Material)[2]; /* VERT_MATERIAL, optional */
GLuint *Primitive; /* GL_(mode)|PRIM_* flags */
GLuint *PrimitiveLength; /* integers */
-
+
GLuint importable_data;
+ void *import_source;
void (*import_data)( GLcontext *ctx, GLuint flags, GLuint vecflags );
/* Callback to the provider of the untransformed input for the
* render stage (or other stages) to call if they need to write into
* write-protected arrays, or fixup the stride on input arrays.
- *
+ *
* This is currently only necessary for client arrays that make it
* as far down the pipeline as the render stage.
*/
GLuint LastClipped;
- interp_func interpfunc;
- copy_pv_func copypvfunc;
/* Private data from _tnl_render_stage that has no business being
- * in this struct.
+ * in this struct.
*/
} TNLvertexbuffer;
-/* Describes an individual operation on the pipeline.
+/* Describes an individual operation on the pipeline.
*/
struct gl_pipeline_stage {
const char *name;
*/
GLuint run_state; /* All state referenced in run() --
* When is the cached output of the
- * stage invalidated?
+ * stage invalidated?
*/
-
+
GLboolean active; /* True if runnable in current state */
GLuint inputs; /* VERT_* inputs to the stage */
GLuint outputs; /* VERT_* outputs of the stage */
*/
GLuint changed_inputs; /* Generated value -- inputs to the
* stage that have changed since last
- * call to 'run'.
+ * call to 'run'.
*/
/* Private data for the pipeline stage:
*/
- void *private;
+ void *privatePtr;
/* Free private data. May not be null.
*/
void (*destroy)( struct gl_pipeline_stage * );
/* Called from _tnl_validate_pipeline(). Must update all fields in
- * the pipeline_stage struct for the current state.
+ * the pipeline_stage struct for the current state.
*/
void (*check)( GLcontext *ctx, struct gl_pipeline_stage * );
/* Called from _tnl_run_pipeline(). The stage.changed_inputs value
* encodes all inputs to thee struct which have changed. If
* non-zero, recompute all affected outputs of the stage, otherwise
- * execute any 'sideeffects' of the stage.
+ * execute any 'sideeffects' of the stage.
*
* Return value: GL_TRUE - keep going
* GL_FALSE - finished pipeline
GLuint run_state_changes; /* state changes since last run */
GLuint run_input_changes; /* VERT_* changes since last run */
GLuint inputs; /* VERT_* inputs to pipeline */
- struct gl_pipeline_stage stages[MAX_PIPELINE_STAGES];
+ struct gl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
GLuint nr_stages;
};
GLuint EvalMap1Flags;
GLuint EvalMap2Flags;
GLuint EvalNewState;
+ struct immediate *im; /* used for temporary data */
+};
- GLfloat Coord[IMM_SIZE][4];
- GLfloat Obj[IMM_SIZE][4];
- GLfloat TexCoord[IMM_SIZE][4];
- GLfloat Normal[IMM_SIZE][3];
- GLchan Color[IMM_SIZE][4];
- GLuint Index[IMM_SIZE];
- GLuint Flag[IMM_SIZE];
- GLuint Elts[IMM_SIZE];
+
+typedef void (*points_func)( GLcontext *ctx, GLuint first, GLuint last );
+typedef void (*line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
+typedef void (*triangle_func)( GLcontext *ctx,
+ GLuint v1, GLuint v2, GLuint v3 );
+typedef void (*quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
+ GLuint v3, GLuint v4 );
+typedef void (*render_func)( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint flags );
+typedef void (*interp_func)( GLcontext *ctx,
+ GLfloat t, GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary );
+typedef void (*copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
+
+
+struct tnl_device_driver {
+ /***
+ *** TNL Pipeline
+ ***/
+
+ void (*RunPipeline)(GLcontext *ctx);
+ /* Replaces PipelineStart/PipelineFinish -- intended to allow
+ * drivers to wrap _tnl_run_pipeline() with code to validate state
+ * and grab/release hardware locks.
+ */
+
+ /***
+ *** Rendering
+ ***/
+
+ void (*RenderStart)(GLcontext *ctx);
+ void (*RenderFinish)(GLcontext *ctx);
+ /* Called before and after all rendering operations, including DrawPixels,
+ * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
+ * These are a suitable place for grabbing/releasing hardware locks.
+ */
+
+ void (*RenderPrimitive)(GLcontext *ctx, GLenum mode);
+ /* Called between RednerStart() and RenderFinish() to indicate the
+ * type of primitive we're about to draw. Mode will be one of the
+ * modes accepted by glBegin().
+ */
+
+ interp_func RenderInterp;
+ /* The interp function is called by the clipping routines when we need
+ * to generate an interpolated vertex. All pertinant vertex ancilliary
+ * data should be computed by interpolating between the 'in' and 'out'
+ * vertices.
+ */
+
+ copy_pv_func RenderCopyPV;
+ /* The copy function is used to make a copy of a vertex. All pertinant
+ * vertex attributes should be copied.
+ */
+
+ void (*RenderClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
+ /* Render a polygon with <n> vertices whose indexes are in the <elts>
+ * array.
+ */
+
+ void (*RenderClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
+ /* Render a line between the two vertices given by indexes v0 and v1. */
+
+ points_func PointsFunc; /* must now respect vb->elts */
+ line_func LineFunc;
+ triangle_func TriangleFunc;
+ quad_func QuadFunc;
+ /* These functions are called in order to render points, lines,
+ * triangles and quads. These are only called via the T&L module.
+ */
+
+ render_func *RenderTabVerts;
+ render_func *RenderTabElts;
+ /* Render whole unclipped primitives (points, lines, linestrips,
+ * lineloops, etc). The tables are indexed by the GL enum of the
+ * primitive to be rendered. RenderTabVerts is used for non-indexed
+ * arrays of vertices. RenderTabElts is used for indexed arrays of
+ * vertices.
+ */
+
+ void (*ResetLineStipple)( GLcontext *ctx );
+ /* Reset the hardware's line stipple counter.
+ */
+
+ void (*BuildProjectedVertices)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ GLuint new_inputs);
+ /* This function is called whenever new vertices are required for
+ * rendering. The vertices in question are those n such that start
+ * <= n < end. The new_inputs parameter indicates those fields of
+ * the vertex which need to be updated, if only a partial repair of
+ * the vertex is required.
+ *
+ * This function is called only from _tnl_render_stage in tnl/t_render.c.
+ */
+
+
+ GLboolean (*MultipassFunc)( GLcontext *ctx, GLuint passno );
+ /* Driver may request additional render passes by returning GL_TRUE
+ * when this function is called. This function will be called
+ * after the first pass, and passes will be made until the function
+ * returns GL_FALSE. If no function is registered, only one pass
+ * is made.
+ *
+ * This function will be first invoked with passno == 1.
+ */
};
-typedef struct {
+
+typedef struct {
+
+ /* Driver interface.
+ */
+ struct tnl_device_driver Driver;
/* Track whether the module is active.
*/
GLuint *tmp_primitive;
GLuint *tmp_primitive_length;
- /* Set when executing an internally generated immediate.
+ /* Set when executing an internally generated begin/end object. If
+ * such an object is encountered in a display list, it will be
+ * replayed only if the list is outside any existing begin/end
+ * objects.
*/
- GLboolean ReplayHardBeginEnd;
- GLenum CurrentPrimitive;
+ GLboolean ReplayHardBeginEnd;
/* Note which vertices need copying over succesive immediates.
* Will add save versions to precompute vertex copying where
* possible.
*/
- struct immediate *ExecCopySource;
+ struct immediate *ExecCopySource;
GLuint ExecCopyCount;
GLuint ExecCopyElts[IMM_MAX_COPIED_VERTS];
GLuint ExecCopyTexSize;
GLuint DlistPrimitiveLength;
GLuint DlistLastPrimitive;
+ /* Cache a single free immediate (refcount == 0)
+ */
+ struct immediate *freed_immediate;
+
/* Probably need a better configuration mechanism:
*/
GLboolean NeedProjCoords;
+ GLboolean LoopbackDListCassettes;
/* Derived state and storage for _tnl_eval_vb:
*/