/* $Id: t_context.h,v 1.23 2001/05/10 12:18:38 keithw Exp $ */ /* * Mesa 3-D graphics library * Version: 3.5 * * 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"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * Author: * Keith Whitwell */ #ifndef _T_CONTEXT_H #define _T_CONTEXT_H #include "glheader.h" #include "mtypes.h" #include "math/m_matrix.h" #include "math/m_vector.h" #include "math/m_xform.h" #define MAX_PIPELINE_STAGES 30 /* Numbers for sizing immediate structs. */ #define IMM_MAX_COPIED_VERTS 3 #define IMM_MAXDATA (216 + IMM_MAX_COPIED_VERTS) #define IMM_SIZE (IMM_MAXDATA + MAX_CLIPPED_VERTICES) /* 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) */ #define VERT_ERROR_0 0x4 /* invalid_operation in initial state 0 */ #define VERT_ERROR_1 0x8 /* invalid_operation in initial state 1 */ /* Flags to be added to the primitive enum in VB->Primitive. */ #define PRIM_MODE_MASK 0xff /* Extract the actual primitive */ #define PRIM_BEGIN 0x100 /* The prim starts here (not wrapped) */ #define PRIM_END 0x200 /* The prim ends in this VB (does not wrap) */ #define PRIM_PARITY 0x400 /* The prim wrapped on an odd number of verts */ #define PRIM_LAST 0x800 /* No more prims in the VB */ /* Flags that describe the inputs and outputs of pipeline stages, and * the contents of a vertex-cassette. * * 5 spare flags, rearrangement of eval flags can secure at least 3 * 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_SPEC_RGB _NEW_ARRAY_SECONDARYCOLOR #define VERT_FOG_COORD _NEW_ARRAY_FOGCOORD #define VERT_TEX0 _NEW_ARRAY_TEXCOORD_0 #define VERT_TEX1 _NEW_ARRAY_TEXCOORD_1 #define VERT_TEX2 _NEW_ARRAY_TEXCOORD_2 #define VERT_TEX3 _NEW_ARRAY_TEXCOORD_3 #define VERT_TEX4 _NEW_ARRAY_TEXCOORD_4 #define VERT_TEX5 _NEW_ARRAY_TEXCOORD_5 #define VERT_TEX6 _NEW_ARRAY_TEXCOORD_6 #define VERT_TEX7 _NEW_ARRAY_TEXCOORD_7 #define VERT_EVAL_C1 0x8000 /* imm only */ #define VERT_EVAL_C2 0x10000 /* imm only */ #define VERT_EVAL_P1 0x20000 /* imm only */ #define VERT_EVAL_P2 0x40000 /* imm only */ #define VERT_OBJ_3 0x80000 /* imm only */ #define VERT_OBJ_4 0x100000 /* imm only */ #define VERT_MATERIAL 0x200000 /* imm only, but tested in vb code */ #define VERT_ELT 0x400000 /* imm only */ #define VERT_BEGIN 0x800000 /* imm only, but tested in vb code */ #define VERT_END 0x1000000 /* imm only, but tested in vb code */ #define VERT_END_VB 0x2000000 /* imm only, but tested in vb code */ #define VERT_POINT_SIZE 0x4000000 /* vb only, could reuse a bit */ #define VERT_EYE VERT_BEGIN /* vb only, reuse imm bit */ #define VERT_CLIP VERT_END /* vb only, reuse imm bit*/ /* Flags for IM->TexCoordSize. Enough flags for 16 units. */ #define TEX_0_SIZE_3 0x1 #define TEX_0_SIZE_4 0x1001 #define TEX_SIZE_3(unit) (TEX_0_SIZE_3<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. */ 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 { /* Driver interface. */ struct tnl_device_driver Driver; /* Track whether the module is active. */ GLboolean bound_exec; /* Display list extensions */ GLuint opcode_vertex_cassette; /* Pipeline */ struct gl_pipeline pipeline; struct vertex_buffer vb; /* GLvectors for binding to vb: */ struct vertex_arrays imm_inputs; struct vertex_arrays array_inputs; GLuint *tmp_primitive; GLuint *tmp_primitive_length; /* 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; /* Note which vertices need copying over succesive immediates. * Will add save versions to precompute vertex copying where * possible. */ struct immediate *ExecCopySource; GLuint ExecCopyCount; GLuint ExecCopyElts[IMM_MAX_COPIED_VERTS]; GLuint ExecCopyTexSize; GLuint ExecParity; GLuint DlistPrimitive; GLuint DlistPrimitiveLength; GLuint DlistLastPrimitive; /* Cache a single free immediate (refcount == 0) */ struct immediate *freed_immediate; /* Probably need a better configuration mechanism: */ GLboolean NeedProjCoords; /* Derived state and storage for _tnl_eval_vb: */ struct tnl_eval_store eval; /* Functions to be plugged into dispatch when tnl is active. */ GLvertexformat vtxfmt; } TNLcontext; #define TNL_CONTEXT(ctx) ((TNLcontext *)(ctx->swtnl_context)) #define TNL_CURRENT_IM(ctx) ((struct immediate *)(ctx->swtnl_im)) #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 ); /* * Macros for fetching current input buffer. */ #ifdef THREADS #define GET_IMMEDIATE struct immediate *IM = TNL_CURRENT_IM(((GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context()))) #define SET_IMMEDIATE(ctx, im) ctx->swtnl_im = (void *)im #else extern struct immediate *_tnl_CurrentInput; #define GET_IMMEDIATE struct immediate *IM = _tnl_CurrentInput #define SET_IMMEDIATE(ctx, im) \ do { \ ctx->swtnl_im = (void *)im; \ _tnl_CurrentInput = im; \ } while (0) #endif #endif