ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

t_context.h
Go to the documentation of this file.
00001 /*
00002  * mesa 3-D graphics library
00003  * Version:  6.5
00004  *
00005  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  */
00024 
00049 #ifndef _T_CONTEXT_H
00050 #define _T_CONTEXT_H
00051 
00052 #include "main/glheader.h"
00053 #include "main/mtypes.h"
00054 
00055 #include "math/m_matrix.h"
00056 #include "math/m_vector.h"
00057 #include "math/m_xform.h"
00058 
00059 #include "vbo/vbo.h"
00060 
00061 #define MAX_PIPELINE_STAGES     30
00062 
00063 /*
00064  * Note: The first attributes match the VERT_ATTRIB_* definitions
00065  * in mtypes.h.  However, the tnl module has additional attributes
00066  * for materials, color indexes, edge flags, etc.
00067  */
00068 /* Although it's nice to use these as bit indexes in a DWORD flag, we
00069  * could manage without if necessary.  Another limit currently is the
00070  * number of bits allocated for these numbers in places like vertex
00071  * program instruction formats and register layouts.
00072  */
00073 /* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for
00074  * GLSL vertex shader which cannot be aliased with conventional vertex attribs.
00075  * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give
00076  * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE*
00077  * attribs want (16).
00078  */
00079 enum {
00080     _TNL_ATTRIB_POS = 0,
00081     _TNL_ATTRIB_WEIGHT = 1,
00082     _TNL_ATTRIB_NORMAL = 2,
00083     _TNL_ATTRIB_COLOR0 = 3,
00084     _TNL_ATTRIB_COLOR1 = 4,
00085     _TNL_ATTRIB_FOG = 5,
00086     _TNL_ATTRIB_COLOR_INDEX = 6,
00087     _TNL_ATTRIB_EDGEFLAG = 7,
00088     _TNL_ATTRIB_TEX0 = 8,
00089     _TNL_ATTRIB_TEX1 = 9,
00090     _TNL_ATTRIB_TEX2 = 10,
00091     _TNL_ATTRIB_TEX3 = 11,
00092     _TNL_ATTRIB_TEX4 = 12,
00093     _TNL_ATTRIB_TEX5 = 13,
00094     _TNL_ATTRIB_TEX6 = 14,
00095     _TNL_ATTRIB_TEX7 = 15,
00096 
00097     _TNL_ATTRIB_GENERIC0 = 16, /* doesn't really exist! */
00098     _TNL_ATTRIB_GENERIC1 = 17,
00099     _TNL_ATTRIB_GENERIC2 = 18,
00100     _TNL_ATTRIB_GENERIC3 = 19,
00101     _TNL_ATTRIB_GENERIC4 = 20,
00102     _TNL_ATTRIB_GENERIC5 = 21,
00103     _TNL_ATTRIB_GENERIC6 = 22,
00104     _TNL_ATTRIB_GENERIC7 = 23,
00105     _TNL_ATTRIB_GENERIC8 = 24,
00106     _TNL_ATTRIB_GENERIC9 = 25,
00107     _TNL_ATTRIB_GENERIC10 = 26,
00108     _TNL_ATTRIB_GENERIC11 = 27,
00109     _TNL_ATTRIB_GENERIC12 = 28,
00110     _TNL_ATTRIB_GENERIC13 = 29,
00111     _TNL_ATTRIB_GENERIC14 = 30,
00112     _TNL_ATTRIB_GENERIC15 = 31,
00113 
00114     /* These alias with the generics, but they are not active
00115      * concurrently, so it's not a problem.  The TNL module
00116      * doesn't have to do anything about this as this is how they
00117      * are passed into the _draw_prims callback.
00118      *
00119      * When we generate fixed-function replacement programs (in
00120      * t_vp_build.c currently), they refer to the appropriate
00121      * generic attribute in order to pick up per-vertex material
00122      * data.
00123      */
00124     _TNL_ATTRIB_MAT_FRONT_AMBIENT = 16,
00125     _TNL_ATTRIB_MAT_BACK_AMBIENT = 17,
00126     _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 18,
00127     _TNL_ATTRIB_MAT_BACK_DIFFUSE = 19,
00128     _TNL_ATTRIB_MAT_FRONT_SPECULAR = 20,
00129     _TNL_ATTRIB_MAT_BACK_SPECULAR = 21,
00130     _TNL_ATTRIB_MAT_FRONT_EMISSION = 22,
00131     _TNL_ATTRIB_MAT_BACK_EMISSION = 23,
00132     _TNL_ATTRIB_MAT_FRONT_SHININESS = 24,
00133     _TNL_ATTRIB_MAT_BACK_SHININESS = 25,
00134     _TNL_ATTRIB_MAT_FRONT_INDEXES = 26,
00135     _TNL_ATTRIB_MAT_BACK_INDEXES = 27,
00136 
00137     /* This is really a VERT_RESULT, not an attrib.  Need to fix
00138      * tnl to understand the difference.
00139      */
00140     _TNL_ATTRIB_POINTSIZE = 16,
00141 
00142     _TNL_ATTRIB_MAX = 32
00143 } ;
00144 
00145 #define _TNL_ATTRIB_TEX(u)       (_TNL_ATTRIB_TEX0 + (u))
00146 #define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n))
00147 
00148 /* special index used for handing invalid glVertexAttribute() indices */
00149 #define _TNL_ATTRIB_ERROR    (_TNL_ATTRIB_GENERIC15 + 1)
00150 
00154 #define _TNL_FIRST_PROG      _TNL_ATTRIB_WEIGHT
00155 #define _TNL_LAST_PROG       _TNL_ATTRIB_TEX7
00156 
00157 #define _TNL_FIRST_TEX       _TNL_ATTRIB_TEX0
00158 #define _TNL_LAST_TEX        _TNL_ATTRIB_TEX7
00159 
00160 #define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0
00161 #define _TNL_LAST_GENERIC  _TNL_ATTRIB_GENERIC15
00162 
00163 #define _TNL_FIRST_MAT       _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */
00164 #define _TNL_LAST_MAT        _TNL_ATTRIB_MAT_BACK_INDEXES  /* GENERIC11 */
00165 
00166 /* Number of available generic attributes */
00167 #define _TNL_NUM_GENERIC 16
00168 
00169 /* Number of attributes used for evaluators */
00170 #define _TNL_NUM_EVAL 16
00171 
00172 
00173 #define PRIM_BEGIN     0x10
00174 #define PRIM_END       0x20
00175 #define PRIM_MODE_MASK 0x0f
00176 
00177 static INLINE GLuint _tnl_translate_prim( const struct _mesa_prim *prim )
00178 {
00179    GLuint flag;
00180    flag = prim->mode;
00181    if (prim->begin) flag |= PRIM_BEGIN;
00182    if (prim->end) flag |= PRIM_END;
00183    return flag;
00184 }
00185 
00186 
00187 
00188 
00192 struct vertex_buffer
00193 {
00194    GLuint Size;  
00196    /* Constant over the pipeline.
00197     */
00198    GLuint Count;  
00200    /* Pointers to current data.
00201     * XXX some of these fields alias AttribPtr below and should be removed
00202     * such as NormalPtr, TexCoordPtr, FogCoordPtr, etc.
00203     */
00204    GLuint      *Elts;                       
00205    GLvector4f  *ObjPtr;                     /* _TNL_BIT_POS */
00206    GLvector4f  *EyePtr;                     /* _TNL_BIT_POS */
00207    GLvector4f  *ClipPtr;                    /* _TNL_BIT_POS */
00208    GLvector4f  *NdcPtr;                         /* _TNL_BIT_POS */
00209    GLubyte     ClipOrMask;                  /* _TNL_BIT_POS */
00210    GLubyte     ClipAndMask;                 /* _TNL_BIT_POS */
00211    GLubyte     *ClipMask;               /* _TNL_BIT_POS */
00212    GLvector4f  *NormalPtr;                  /* _TNL_BIT_NORMAL */
00213    GLfloat     *NormalLengthPtr;            /* _TNL_BIT_NORMAL */
00214    GLboolean   *EdgeFlag;                   /* _TNL_BIT_EDGEFLAG */
00215    GLvector4f  *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
00216    GLvector4f  *IndexPtr[2];                    /* _TNL_BIT_INDEX */
00217    GLvector4f  *ColorPtr[2];                    /* _TNL_BIT_COLOR0 */
00218    GLvector4f  *SecondaryColorPtr[2];           /* _TNL_BIT_COLOR1 */
00219    GLvector4f  *FogCoordPtr;                    /* _TNL_BIT_FOG */
00220 
00221    const struct _mesa_prim  *Primitive;               
00222    GLuint      PrimitiveCount;        
00223 
00224    /* Inputs to the vertex program stage */
00225    GLvector4f *AttribPtr[_TNL_ATTRIB_MAX];      /* GL_NV_vertex_program */
00226 };
00227 
00228 
00232 struct tnl_pipeline_stage
00233 {
00234    const char *name;
00235 
00236    /* Private data for the pipeline stage:
00237     */
00238    void *privatePtr;
00239 
00240    /* Allocate private data
00241     */
00242    GLboolean (*create)( GLcontext *ctx, struct tnl_pipeline_stage * );
00243 
00244    /* Free private data.
00245     */
00246    void (*destroy)( struct tnl_pipeline_stage * );
00247 
00248    /* Called on any statechange or input array size change or
00249     * input array change to/from zero stride.
00250     */
00251    void (*validate)( GLcontext *ctx, struct tnl_pipeline_stage * );
00252 
00253    /* Called from _tnl_run_pipeline().  The stage.changed_inputs value
00254     * encodes all inputs to thee struct which have changed.  If
00255     * non-zero, recompute all affected outputs of the stage, otherwise
00256     * execute any 'sideeffects' of the stage.
00257     *
00258     * Return value: GL_TRUE - keep going
00259     *               GL_FALSE - finished pipeline
00260     */
00261    GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * );
00262 };
00263 
00264 
00265 
00269 struct tnl_pipeline {
00270    
00271    GLuint last_attrib_stride[_TNL_ATTRIB_MAX];
00272    GLuint last_attrib_size[_TNL_ATTRIB_MAX];
00273    GLuint input_changes;
00274    GLuint new_state;
00275 
00276    struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
00277    GLuint nr_stages;
00278 };
00279 
00280 struct tnl_clipspace;
00281 struct tnl_clipspace_attr;
00282 
00283 typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a, 
00284                   GLfloat *out, 
00285                   const GLubyte *v );
00286 
00287 typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a, 
00288                  GLubyte *v, 
00289                  const GLfloat *in );
00290 
00291 typedef void (*tnl_emit_func)( GLcontext *ctx, 
00292                    GLuint count, 
00293                    GLubyte *dest );
00294 
00295 
00300 struct tnl_clipspace_attr
00301 {
00302    GLuint attrib;          /* which vertex attrib (0=position, etc) */
00303    GLuint format;
00304    GLuint vertoffset;      /* position of the attrib in the vertex struct */
00305    GLuint vertattrsize;    /* size of the attribute in bytes */
00306    GLubyte *inputptr;
00307    GLuint inputstride;
00308    GLuint inputsize;
00309    const tnl_insert_func *insert;
00310    tnl_insert_func emit;
00311    tnl_extract_func extract;
00312    const GLfloat *vp;   /* NDC->Viewport mapping matrix */
00313 };
00314 
00315 
00316 
00317 
00318 typedef void (*tnl_points_func)( GLcontext *ctx, GLuint first, GLuint last );
00319 typedef void (*tnl_line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
00320 typedef void (*tnl_triangle_func)( GLcontext *ctx,
00321                    GLuint v1, GLuint v2, GLuint v3 );
00322 typedef void (*tnl_quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
00323                    GLuint v3, GLuint v4 );
00324 typedef void (*tnl_render_func)( GLcontext *ctx, GLuint start, GLuint count,
00325                  GLuint flags );
00326 typedef void (*tnl_interp_func)( GLcontext *ctx,
00327                  GLfloat t, GLuint dst, GLuint out, GLuint in,
00328                  GLboolean force_boundary );
00329 typedef void (*tnl_copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
00330 typedef void (*tnl_setup_func)( GLcontext *ctx,
00331                 GLuint start, GLuint end,
00332                 GLuint new_inputs);
00333 
00334 
00335 struct tnl_attr_type {
00336    GLuint format;
00337    GLuint size;
00338    GLuint stride;
00339    GLuint offset;
00340 };
00341 
00342 struct tnl_clipspace_fastpath {
00343    GLuint vertex_size;
00344    GLuint attr_count;
00345    GLboolean match_strides;
00346 
00347    struct tnl_attr_type *attr;
00348 
00349    tnl_emit_func func;
00350    struct tnl_clipspace_fastpath *next;
00351 };
00352 
00357 struct tnl_clipspace
00358 {
00359    GLboolean need_extras;
00360    
00361    GLuint new_inputs;
00362 
00363    GLubyte *vertex_buf;
00364    GLuint vertex_size;
00365    GLuint max_vertex_size;
00366 
00367    struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX];
00368    GLuint attr_count;
00369 
00370    tnl_emit_func emit;
00371    tnl_interp_func interp;
00372    tnl_copy_pv_func copy_pv;
00373 
00374    /* Parameters and constants for codegen:
00375     */
00376    GLboolean need_viewport;
00377    GLfloat vp_scale[4];     
00378    GLfloat vp_xlate[4];
00379    GLfloat chan_scale[4];
00380    GLfloat identity[4];
00381 
00382    struct tnl_clipspace_fastpath *fastpath;
00383    
00384    void (*codegen_emit)( GLcontext *ctx );
00385 };
00386 
00387 
00388 struct tnl_device_driver
00389 {
00390    /***
00391     *** TNL Pipeline
00392     ***/
00393 
00394    void (*RunPipeline)(GLcontext *ctx);
00395    /* Replaces PipelineStart/PipelineFinish -- intended to allow
00396     * drivers to wrap _tnl_run_pipeline() with code to validate state
00397     * and grab/release hardware locks.  
00398     */
00399 
00400    void (*NotifyMaterialChange)(GLcontext *ctx);
00401    /* Alert tnl-aware drivers of changes to material.
00402     */
00403 
00404    void (*NotifyInputChanges)(GLcontext *ctx, GLuint bitmask);
00405    /* Alert tnl-aware drivers of changes to size and stride of input
00406     * arrays.
00407     */
00408 
00409    /***
00410     *** Rendering -- These functions called only from t_vb_render.c
00411     ***/
00412    struct
00413    {
00414       void (*Start)(GLcontext *ctx);
00415       void (*Finish)(GLcontext *ctx);
00416       /* Called before and after all rendering operations, including DrawPixels,
00417        * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
00418        * These are a suitable place for grabbing/releasing hardware locks.
00419        */
00420 
00421       void (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
00422       /* Called between RenderStart() and RenderFinish() to indicate the
00423        * type of primitive we're about to draw.  Mode will be one of the
00424        * modes accepted by glBegin().
00425        */
00426 
00427       tnl_interp_func Interp;
00428       /* The interp function is called by the clipping routines when we need
00429        * to generate an interpolated vertex.  All pertinant vertex ancilliary
00430        * data should be computed by interpolating between the 'in' and 'out'
00431        * vertices.
00432        */
00433 
00434       tnl_copy_pv_func CopyPV;
00435       /* The copy function is used to make a copy of a vertex.  All pertinant
00436        * vertex attributes should be copied.
00437        */
00438 
00439       void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
00440       /* Render a polygon with <n> vertices whose indexes are in the <elts>
00441        * array.
00442        */
00443 
00444       void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
00445       /* Render a line between the two vertices given by indexes v0 and v1. */
00446 
00447       tnl_points_func           Points; /* must now respect vb->elts */
00448       tnl_line_func             Line;
00449       tnl_triangle_func         Triangle;
00450       tnl_quad_func             Quad;
00451       /* These functions are called in order to render points, lines,
00452        * triangles and quads.  These are only called via the T&L module.
00453        */
00454 
00455       tnl_render_func          *PrimTabVerts;
00456       tnl_render_func          *PrimTabElts;
00457       /* Render whole unclipped primitives (points, lines, linestrips,
00458        * lineloops, etc).  The tables are indexed by the GL enum of the
00459        * primitive to be rendered.  RenderTabVerts is used for non-indexed
00460        * arrays of vertices.  RenderTabElts is used for indexed arrays of
00461        * vertices.
00462        */
00463 
00464       void (*ResetLineStipple)( GLcontext *ctx );
00465       /* Reset the hardware's line stipple counter.
00466        */
00467 
00468       tnl_setup_func BuildVertices;
00469       /* This function is called whenever new vertices are required for
00470        * rendering.  The vertices in question are those n such that start
00471        * <= n < end.  The new_inputs parameter indicates those fields of
00472        * the vertex which need to be updated, if only a partial repair of
00473        * the vertex is required.
00474        *
00475        * This function is called only from _tnl_render_stage in tnl/t_render.c.
00476        */
00477       
00478 
00479       GLboolean (*Multipass)( GLcontext *ctx, GLuint passno );
00480       /* Driver may request additional render passes by returning GL_TRUE
00481        * when this function is called.  This function will be called
00482        * after the first pass, and passes will be made until the function
00483        * returns GL_FALSE.  If no function is registered, only one pass
00484        * is made.
00485        *
00486        * This function will be first invoked with passno == 1.
00487        */
00488    } Render;
00489 };
00490 
00491 
00492 #define DECLARE_RENDERINPUTS(name) BITSET64_DECLARE(name, _TNL_ATTRIB_MAX)
00493 #define RENDERINPUTS_COPY BITSET64_COPY
00494 #define RENDERINPUTS_EQUAL BITSET64_EQUAL
00495 #define RENDERINPUTS_ZERO BITSET64_ZERO
00496 #define RENDERINPUTS_ONES BITSET64_ONES
00497 #define RENDERINPUTS_TEST BITSET64_TEST
00498 #define RENDERINPUTS_SET BITSET64_SET
00499 #define RENDERINPUTS_CLEAR BITSET64_CLEAR
00500 #define RENDERINPUTS_TEST_RANGE BITSET64_TEST_RANGE
00501 #define RENDERINPUTS_SET_RANGE BITSET64_SET_RANGE
00502 #define RENDERINPUTS_CLEAR_RANGE BITSET64_CLEAR_RANGE
00503 
00504 
00508 typedef struct
00509 {
00510    /* Driver interface.
00511     */
00512    struct tnl_device_driver Driver;
00513 
00514    /* Pipeline
00515     */
00516    struct tnl_pipeline pipeline;
00517    struct vertex_buffer vb;
00518 
00519    /* Clipspace/ndc/window vertex managment:
00520     */
00521    struct tnl_clipspace clipspace;
00522 
00523    /* Probably need a better configuration mechanism:
00524     */
00525    GLboolean NeedNdcCoords;
00526    GLboolean AllowVertexFog;
00527    GLboolean AllowPixelFog;
00528    GLboolean _DoVertexFog;  /* eval fog function at each vertex? */
00529 
00530    DECLARE_RENDERINPUTS(render_inputs_bitset);
00531 
00532    GLvector4f tmp_inputs[VERT_ATTRIB_MAX];
00533 
00534    /* Temp storage for t_draw.c: 
00535     */
00536    GLubyte *block[VERT_ATTRIB_MAX];
00537    GLuint nr_blocks;
00538 
00539 } TNLcontext;
00540 
00541 
00542 
00543 #define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context))
00544 
00545 
00546 #define TYPE_IDX(t) ((t) & 0xf)
00547 #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1      /* 0xa + 1 */
00548 
00549 
00550 #endif

Generated on Mon May 28 2012 04:20:25 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.