📄 t_context.h
字号:
GLvector4f Index;
GLubyte *EdgeFlag;
GLuint *Elt;
/* These attributes don't alias with the conventional attributes.
* The GL_NV_vertex_program extension defines 16 extra sets of vertex
* arrays which have precedent over the conventional arrays when enabled.
*/
GLvector4f Attribs[_TNL_ATTRIB_MAX];
};
/**
* Contains the current state of a running pipeline.
*/
struct vertex_buffer
{
/* Constant over life of the vertex_buffer.
*/
GLuint Size;
/* Constant over the pipeline.
*/
GLuint Count; /* for everything except Elts */
/* Pointers to current data.
*/
GLuint *Elts;
GLvector4f *ObjPtr; /* _TNL_BIT_POS */
GLvector4f *EyePtr; /* _TNL_BIT_POS */
GLvector4f *ClipPtr; /* _TNL_BIT_POS */
GLvector4f *NdcPtr; /* _TNL_BIT_POS */
GLubyte ClipOrMask; /* _TNL_BIT_POS */
GLubyte ClipAndMask; /* _TNL_BIT_POS */
GLubyte *ClipMask; /* _TNL_BIT_POS */
GLvector4f *NormalPtr; /* _TNL_BIT_NORMAL */
GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */
GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */
GLvector4f *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
GLvector4f *IndexPtr[2]; /* _TNL_BIT_INDEX */
GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
GLvector4f *PointSizePtr; /* _TNL_BIT_POS */
GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
struct tnl_prim *Primitive;
GLuint PrimitiveCount;
/* Inputs to the vertex program stage */
GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */
GLuint LastClipped;
/* Private data from _tnl_render_stage that has no business being
* in this struct.
*/
};
/** Describes an individual operation on the pipeline.
*/
struct tnl_pipeline_stage
{
const char *name;
/* Private data for the pipeline stage:
*/
void *privatePtr;
/* Allocate private data
*/
GLboolean (*create)( GLcontext *ctx, struct tnl_pipeline_stage * );
/* Free private data.
*/
void (*destroy)( struct tnl_pipeline_stage * );
/* Called on any statechange or input array size change or
* input array change to/from zero stride.
*/
void (*validate)( 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
* non-zero, recompute all affected outputs of the stage, otherwise
* execute any 'sideeffects' of the stage.
*
* Return value: GL_TRUE - keep going
* GL_FALSE - finished pipeline
*/
GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * );
};
/** Contains the array of all pipeline stages.
* The default values are defined at the end of t_pipeline.c
*/
struct tnl_pipeline {
GLuint last_attrib_stride[_TNL_ATTRIB_MAX];
GLuint last_attrib_size[_TNL_ATTRIB_MAX];
GLuint input_changes;
GLuint new_state;
struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
GLuint nr_stages;
};
struct tnl_clipspace;
struct tnl_clipspace_attr;
typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a,
GLfloat *out,
const GLubyte *v );
typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a,
GLubyte *v,
const GLfloat *in );
typedef void (*tnl_emit_func)( GLcontext *ctx,
GLuint count,
GLubyte *dest );
/**
* Describes how to convert/move a vertex attribute from a vertex array
* to a vertex structure.
*/
struct tnl_clipspace_attr
{
GLuint attrib; /* which vertex attrib (0=position, etc) */
GLuint format;
GLuint vertoffset; /* position of the attrib in the vertex struct */
GLuint vertattrsize; /* size of the attribute in bytes */
GLubyte *inputptr;
GLuint inputstride;
GLuint inputsize;
const tnl_insert_func *insert;
tnl_insert_func emit;
tnl_extract_func extract;
const GLfloat *vp; /* NDC->Viewport mapping matrix */
};
typedef void (*tnl_points_func)( GLcontext *ctx, GLuint first, GLuint last );
typedef void (*tnl_line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
typedef void (*tnl_triangle_func)( GLcontext *ctx,
GLuint v1, GLuint v2, GLuint v3 );
typedef void (*tnl_quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
GLuint v3, GLuint v4 );
typedef void (*tnl_render_func)( GLcontext *ctx, GLuint start, GLuint count,
GLuint flags );
typedef void (*tnl_interp_func)( GLcontext *ctx,
GLfloat t, GLuint dst, GLuint out, GLuint in,
GLboolean force_boundary );
typedef void (*tnl_copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
typedef void (*tnl_setup_func)( GLcontext *ctx,
GLuint start, GLuint end,
GLuint new_inputs);
struct tnl_clipspace_fastpath {
GLuint vertex_size;
GLuint attr_count;
GLboolean match_strides;
struct {
GLuint format;
GLuint size;
GLuint stride;
GLuint offset;
} *attr;
tnl_emit_func func;
struct tnl_clipspace_fastpath *next;
};
/**
* Used to describe conversion of vertex arrays to vertex structures.
* I.e. Structure of arrays to arrays of structs.
*/
struct tnl_clipspace
{
GLboolean need_extras;
GLuint new_inputs;
GLubyte *vertex_buf;
GLuint vertex_size;
GLuint max_vertex_size;
struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX];
GLuint attr_count;
tnl_emit_func emit;
tnl_interp_func interp;
tnl_copy_pv_func copy_pv;
/* Parameters and constants for codegen:
*/
GLboolean need_viewport;
GLfloat vp_scale[4];
GLfloat vp_xlate[4];
GLfloat chan_scale[4];
GLfloat identity[4];
struct tnl_clipspace_fastpath *fastpath;
void (*codegen_emit)( GLcontext *ctx );
};
struct tnl_cache {
GLuint hash;
void *key;
void *data;
struct tnl_cache *next;
};
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.
*/
void (*NotifyMaterialChange)(GLcontext *ctx);
/* 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
*/
/***
*** Rendering -- These functions called only from t_vb_render.c
***/
struct
{
void (*Start)(GLcontext *ctx);
void (*Finish)(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 (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
/* Called between RenderStart() and RenderFinish() to indicate the
* type of primitive we're about to draw. Mode will be one of the
* modes accepted by glBegin().
*/
tnl_interp_func Interp;
/* 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.
*/
tnl_copy_pv_func CopyPV;
/* The copy function is used to make a copy of a vertex. All pertinant
* vertex attributes should be copied.
*/
void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
/* Render a polygon with <n> vertices whose indexes are in the <elts>
* array.
*/
void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
/* Render a line between the two vertices given by indexes v0 and v1. */
tnl_points_func Points; /* must now respect vb->elts */
tnl_line_func Line;
tnl_triangle_func Triangle;
tnl_quad_func Quad;
/* These functions are called in order to render points, lines,
* triangles and quads. These are only called via the T&L module.
*/
tnl_render_func *PrimTabVerts;
tnl_render_func *PrimTabElts;
/* 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.
*/
tnl_setup_func BuildVertices;
/* 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 (*Multipass)( 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.
*/
} Render;
};
/**
* Context state for T&L context.
*/
typedef struct
{
/* Driver interface.
*/
struct tnl_device_driver Driver;
/* Execute:
*/
struct tnl_vtx vtx;
/* Compile:
*/
struct tnl_save save;
/* Pipeline
*/
struct tnl_pipeline pipeline;
struct vertex_buffer vb;
/* GLvectors for binding to vb:
*/
struct tnl_vertex_arrays vtx_inputs;
struct tnl_vertex_arrays save_inputs;
struct tnl_vertex_arrays current;
struct tnl_vertex_arrays array_inputs;
/* Clipspace/ndc/window vertex managment:
*/
struct tnl_clipspace clipspace;
/* Probably need a better configuration mechanism:
*/
GLboolean NeedNdcCoords;
GLboolean LoopbackDListCassettes;
GLboolean CalcDListNormalLengths;
GLboolean IsolateMaterials;
GLboolean AllowVertexFog;
GLboolean AllowPixelFog;
GLboolean AllowCodegen;
GLboolean _DoVertexFog; /* eval fog function at each vertex? */
GLuint render_inputs;
GLvertexformat exec_vtxfmt;
GLvertexformat save_vtxfmt;
struct tnl_cache *vp_cache;
} TNLcontext;
#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context))
#define TYPE_IDX(t) ((t) & 0xf)
#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
extern void _tnl_MakeCurrent( GLcontext *ctx,
GLframebuffer *drawBuffer,
GLframebuffer *readBuffer );
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -