1848b8605Smrg/* 2848b8605Smrg * mesa 3-D graphics library 3848b8605Smrg * 4848b8605Smrg * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the "Software"), 8848b8605Smrg * to deal in the Software without restriction, including without limitation 9848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 11848b8605Smrg * Software is furnished to do so, subject to the following conditions: 12848b8605Smrg * 13848b8605Smrg * The above copyright notice and this permission notice shall be included 14848b8605Smrg * in all copies or substantial portions of the Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE. 23848b8605Smrg */ 24848b8605Smrg 25848b8605Smrg/** 26848b8605Smrg * \file t_context.h 27848b8605Smrg * \brief TnL module datatypes and definitions. 28848b8605Smrg * \author Keith Whitwell 29848b8605Smrg */ 30848b8605Smrg 31848b8605Smrg 32848b8605Smrg/** 33848b8605Smrg * \mainpage The TNL-module 34848b8605Smrg * 35848b8605Smrg * TNL stands for "transform and lighting", i.e. this module implements 36848b8605Smrg * a pipeline that receives as input a buffer of vertices and does all 37848b8605Smrg * necessary transformations (rotations, clipping, vertex shader etc.) 38848b8605Smrg * and passes then the output to the rasterizer. 39848b8605Smrg * 40848b8605Smrg * The tnl_pipeline contains the array of all stages, which should be 41848b8605Smrg * applied. Each stage is a black-box, which is described by an 42848b8605Smrg * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the 43848b8605Smrg * stages to the vertex_buffer TNLcontext::vb, where the vertex data 44848b8605Smrg * is stored. The last stage in the pipeline is the rasterizer. 45848b8605Smrg * 46848b8605Smrg */ 47848b8605Smrg 48848b8605Smrg 49848b8605Smrg#ifndef _T_CONTEXT_H 50848b8605Smrg#define _T_CONTEXT_H 51848b8605Smrg 52848b8605Smrg#include "main/glheader.h" 53848b8605Smrg#include "main/imports.h" 54848b8605Smrg#include "main/mtypes.h" 55848b8605Smrg 56848b8605Smrg#include "math/m_vector.h" 57848b8605Smrg 58848b8605Smrg#include "vbo/vbo.h" 59848b8605Smrg 60b8e80941Smrg#include "tnl.h" 61b8e80941Smrg 62848b8605Smrg#define MAX_PIPELINE_STAGES 30 63848b8605Smrg 64848b8605Smrg/* 65848b8605Smrg * Note: The first attributes match the VERT_ATTRIB_* definitions 66848b8605Smrg * in mtypes.h. However, the tnl module has additional attributes 67848b8605Smrg * for materials, color indexes, edge flags, etc. 68848b8605Smrg */ 69848b8605Smrg/* Although it's nice to use these as bit indexes in a DWORD flag, we 70848b8605Smrg * could manage without if necessary. Another limit currently is the 71848b8605Smrg * number of bits allocated for these numbers in places like vertex 72848b8605Smrg * program instruction formats and register layouts. 73848b8605Smrg */ 74848b8605Smrg/* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for 75848b8605Smrg * GLSL vertex shader which cannot be aliased with conventional vertex attribs. 76848b8605Smrg * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give 77848b8605Smrg * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE* 78848b8605Smrg * attribs want (16). 79848b8605Smrg */ 80848b8605Smrgenum { 81b8e80941Smrg _TNL_ATTRIB_POS, 82b8e80941Smrg _TNL_ATTRIB_NORMAL, 83b8e80941Smrg _TNL_ATTRIB_COLOR0, 84b8e80941Smrg _TNL_ATTRIB_COLOR1, 85b8e80941Smrg _TNL_ATTRIB_FOG, 86b8e80941Smrg _TNL_ATTRIB_COLOR_INDEX, 87b8e80941Smrg _TNL_ATTRIB_EDGEFLAG, 88b8e80941Smrg _TNL_ATTRIB_TEX0, 89b8e80941Smrg _TNL_ATTRIB_TEX1, 90b8e80941Smrg _TNL_ATTRIB_TEX2, 91b8e80941Smrg _TNL_ATTRIB_TEX3, 92b8e80941Smrg _TNL_ATTRIB_TEX4, 93b8e80941Smrg _TNL_ATTRIB_TEX5, 94b8e80941Smrg _TNL_ATTRIB_TEX6, 95b8e80941Smrg _TNL_ATTRIB_TEX7, 96b8e80941Smrg 97b8e80941Smrg /* This is really a VARYING_SLOT, not an attrib. Need to fix 98b8e80941Smrg * tnl to understand the difference. 99b8e80941Smrg */ 100b8e80941Smrg _TNL_ATTRIB_POINTSIZE, 101b8e80941Smrg 102b8e80941Smrg _TNL_ATTRIB_GENERIC0, /* doesn't really exist! */ 103b8e80941Smrg _TNL_ATTRIB_GENERIC1, 104b8e80941Smrg _TNL_ATTRIB_GENERIC2, 105b8e80941Smrg _TNL_ATTRIB_GENERIC3, 106b8e80941Smrg _TNL_ATTRIB_GENERIC4, 107b8e80941Smrg _TNL_ATTRIB_GENERIC5, 108b8e80941Smrg _TNL_ATTRIB_GENERIC6, 109b8e80941Smrg _TNL_ATTRIB_GENERIC7, 110b8e80941Smrg _TNL_ATTRIB_GENERIC8, 111b8e80941Smrg _TNL_ATTRIB_GENERIC9, 112b8e80941Smrg _TNL_ATTRIB_GENERIC10, 113b8e80941Smrg _TNL_ATTRIB_GENERIC11, 114b8e80941Smrg _TNL_ATTRIB_GENERIC12, 115b8e80941Smrg _TNL_ATTRIB_GENERIC13, 116b8e80941Smrg _TNL_ATTRIB_GENERIC14, 117b8e80941Smrg _TNL_ATTRIB_GENERIC15, 118b8e80941Smrg 119b8e80941Smrg _TNL_ATTRIB_MAX, 120848b8605Smrg 121848b8605Smrg /* These alias with the generics, but they are not active 122848b8605Smrg * concurrently, so it's not a problem. The TNL module 123848b8605Smrg * doesn't have to do anything about this as this is how they 124848b8605Smrg * are passed into the _draw_prims callback. 125848b8605Smrg * 126848b8605Smrg * When we generate fixed-function replacement programs (in 127848b8605Smrg * t_vp_build.c currently), they refer to the appropriate 128848b8605Smrg * generic attribute in order to pick up per-vertex material 129848b8605Smrg * data. 130848b8605Smrg */ 131b8e80941Smrg _TNL_ATTRIB_MAT_FRONT_AMBIENT=VERT_ATTRIB_MAT(MAT_ATTRIB_FRONT_AMBIENT), 132b8e80941Smrg _TNL_ATTRIB_MAT_BACK_AMBIENT, 133b8e80941Smrg _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 134b8e80941Smrg _TNL_ATTRIB_MAT_BACK_DIFFUSE, 135b8e80941Smrg _TNL_ATTRIB_MAT_FRONT_SPECULAR, 136b8e80941Smrg _TNL_ATTRIB_MAT_BACK_SPECULAR, 137b8e80941Smrg _TNL_ATTRIB_MAT_FRONT_EMISSION, 138b8e80941Smrg _TNL_ATTRIB_MAT_BACK_EMISSION, 139b8e80941Smrg _TNL_ATTRIB_MAT_FRONT_SHININESS, 140b8e80941Smrg _TNL_ATTRIB_MAT_BACK_SHININESS, 141b8e80941Smrg _TNL_ATTRIB_MAT_FRONT_INDEXES, 142b8e80941Smrg _TNL_ATTRIB_MAT_BACK_INDEXES, 143b8e80941Smrg}; 144848b8605Smrg 145848b8605Smrg#define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u)) 146848b8605Smrg#define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n)) 147848b8605Smrg 148848b8605Smrg/* special index used for handing invalid glVertexAttribute() indices */ 149848b8605Smrg#define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_GENERIC15 + 1) 150848b8605Smrg 151848b8605Smrg/** 152848b8605Smrg * Handy attribute ranges: 153848b8605Smrg */ 154b8e80941Smrg#define _TNL_FIRST_PROG _TNL_ATTRIB_NORMAL 155848b8605Smrg#define _TNL_LAST_PROG _TNL_ATTRIB_TEX7 156848b8605Smrg 157848b8605Smrg#define _TNL_FIRST_TEX _TNL_ATTRIB_TEX0 158848b8605Smrg#define _TNL_LAST_TEX _TNL_ATTRIB_TEX7 159848b8605Smrg 160848b8605Smrg#define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0 161848b8605Smrg#define _TNL_LAST_GENERIC _TNL_ATTRIB_GENERIC15 162848b8605Smrg 163b8e80941Smrg#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC4 */ 164b8e80941Smrg#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* GENERIC15 */ 165848b8605Smrg 166848b8605Smrg/* Number of available texture attributes */ 167848b8605Smrg#define _TNL_NUM_TEX 8 168848b8605Smrg 169848b8605Smrg/* Number of available generic attributes */ 170848b8605Smrg#define _TNL_NUM_GENERIC 16 171848b8605Smrg 172848b8605Smrg/* Number of attributes used for evaluators */ 173848b8605Smrg#define _TNL_NUM_EVAL 16 174848b8605Smrg 175848b8605Smrg 176848b8605Smrg#define PRIM_BEGIN 0x10 177848b8605Smrg#define PRIM_END 0x20 178848b8605Smrg#define PRIM_MODE_MASK 0x0f 179848b8605Smrg 180848b8605Smrgstatic inline GLuint _tnl_translate_prim( const struct _mesa_prim *prim ) 181848b8605Smrg{ 182848b8605Smrg GLuint flag; 183848b8605Smrg flag = prim->mode; 184848b8605Smrg if (prim->begin) flag |= PRIM_BEGIN; 185848b8605Smrg if (prim->end) flag |= PRIM_END; 186848b8605Smrg return flag; 187848b8605Smrg} 188848b8605Smrg 189848b8605Smrg 190848b8605Smrg 191848b8605Smrg 192848b8605Smrg/** 193848b8605Smrg * Contains the current state of a running pipeline. 194848b8605Smrg */ 195848b8605Smrgstruct vertex_buffer 196848b8605Smrg{ 197848b8605Smrg GLuint Size; /**< Max vertices per vertex buffer, constant */ 198848b8605Smrg 199848b8605Smrg /* Constant over the pipeline. 200848b8605Smrg */ 201848b8605Smrg GLuint Count; /**< Number of vertices currently in buffer */ 202848b8605Smrg 203848b8605Smrg /* Pointers to current data. Most of the data is in AttribPtr -- all of 204848b8605Smrg * it that is one of VERT_ATTRIB_X. For things only produced by TNL, 205848b8605Smrg * such as backface color or eye-space coordinates, they are stored 206848b8605Smrg * here. 207848b8605Smrg */ 208848b8605Smrg GLuint *Elts; 209848b8605Smrg GLvector4f *EyePtr; /* _TNL_BIT_POS */ 210848b8605Smrg GLvector4f *ClipPtr; /* _TNL_BIT_POS */ 211848b8605Smrg GLvector4f *NdcPtr; /* _TNL_BIT_POS */ 212848b8605Smrg GLubyte ClipOrMask; /* _TNL_BIT_POS */ 213848b8605Smrg GLubyte ClipAndMask; /* _TNL_BIT_POS */ 214848b8605Smrg GLubyte *ClipMask; /* _TNL_BIT_POS */ 215848b8605Smrg GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */ 216848b8605Smrg GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */ 217848b8605Smrg GLvector4f *BackfaceIndexPtr; 218848b8605Smrg GLvector4f *BackfaceColorPtr; 219848b8605Smrg GLvector4f *BackfaceSecondaryColorPtr; 220848b8605Smrg 221848b8605Smrg const struct _mesa_prim *Primitive; 222848b8605Smrg GLuint PrimitiveCount; 223848b8605Smrg 224848b8605Smrg /* Inputs to the vertex program stage */ 225848b8605Smrg GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; 226848b8605Smrg}; 227848b8605Smrg 228848b8605Smrg 229848b8605Smrg/** 230848b8605Smrg * Describes an individual operation on the pipeline. 231848b8605Smrg */ 232848b8605Smrgstruct tnl_pipeline_stage 233848b8605Smrg{ 234848b8605Smrg const char *name; 235848b8605Smrg 236848b8605Smrg /* Private data for the pipeline stage: 237848b8605Smrg */ 238848b8605Smrg void *privatePtr; 239848b8605Smrg 240848b8605Smrg /* Allocate private data 241848b8605Smrg */ 242848b8605Smrg GLboolean (*create)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 243848b8605Smrg 244848b8605Smrg /* Free private data. 245848b8605Smrg */ 246848b8605Smrg void (*destroy)( struct tnl_pipeline_stage * ); 247848b8605Smrg 248848b8605Smrg /* Called on any statechange or input array size change or 249848b8605Smrg * input array change to/from zero stride. 250848b8605Smrg */ 251848b8605Smrg void (*validate)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 252848b8605Smrg 253848b8605Smrg /* Called from _tnl_run_pipeline(). The stage.changed_inputs value 254848b8605Smrg * encodes all inputs to thee struct which have changed. If 255848b8605Smrg * non-zero, recompute all affected outputs of the stage, otherwise 256848b8605Smrg * execute any 'sideeffects' of the stage. 257848b8605Smrg * 258848b8605Smrg * Return value: GL_TRUE - keep going 259848b8605Smrg * GL_FALSE - finished pipeline 260848b8605Smrg */ 261848b8605Smrg GLboolean (*run)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 262848b8605Smrg}; 263848b8605Smrg 264848b8605Smrg 265848b8605Smrg 266848b8605Smrg/** Contains the array of all pipeline stages. 267848b8605Smrg * The default values are defined at the end of t_pipeline.c 268848b8605Smrg */ 269848b8605Smrgstruct tnl_pipeline { 270848b8605Smrg 271848b8605Smrg GLuint last_attrib_stride[_TNL_ATTRIB_MAX]; 272848b8605Smrg GLuint last_attrib_size[_TNL_ATTRIB_MAX]; 273848b8605Smrg GLuint input_changes; 274848b8605Smrg GLuint new_state; 275848b8605Smrg 276848b8605Smrg struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; 277848b8605Smrg GLuint nr_stages; 278848b8605Smrg}; 279848b8605Smrg 280848b8605Smrgstruct tnl_clipspace; 281848b8605Smrgstruct tnl_clipspace_attr; 282848b8605Smrg 283848b8605Smrgtypedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a, 284848b8605Smrg GLfloat *out, 285848b8605Smrg const GLubyte *v ); 286848b8605Smrg 287848b8605Smrgtypedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a, 288848b8605Smrg GLubyte *v, 289848b8605Smrg const GLfloat *in ); 290848b8605Smrg 291848b8605Smrgtypedef void (*tnl_emit_func)( struct gl_context *ctx, 292848b8605Smrg GLuint count, 293848b8605Smrg GLubyte *dest ); 294848b8605Smrg 295848b8605Smrg 296848b8605Smrg/** 297848b8605Smrg * Describes how to convert/move a vertex attribute from a vertex array 298848b8605Smrg * to a vertex structure. 299848b8605Smrg */ 300848b8605Smrgstruct tnl_clipspace_attr 301848b8605Smrg{ 302848b8605Smrg GLuint attrib; /* which vertex attrib (0=position, etc) */ 303848b8605Smrg GLuint format; 304848b8605Smrg GLuint vertoffset; /* position of the attrib in the vertex struct */ 305848b8605Smrg GLuint vertattrsize; /* size of the attribute in bytes */ 306848b8605Smrg GLubyte *inputptr; 307848b8605Smrg GLuint inputstride; 308848b8605Smrg GLuint inputsize; 309848b8605Smrg const tnl_insert_func *insert; 310848b8605Smrg tnl_insert_func emit; 311848b8605Smrg tnl_extract_func extract; 312848b8605Smrg const GLfloat *vp; /* NDC->Viewport mapping matrix */ 313848b8605Smrg}; 314848b8605Smrg 315848b8605Smrg 316848b8605Smrg 317848b8605Smrg 318848b8605Smrgtypedef void (*tnl_points_func)( struct gl_context *ctx, GLuint first, GLuint last ); 319848b8605Smrgtypedef void (*tnl_line_func)( struct gl_context *ctx, GLuint v1, GLuint v2 ); 320848b8605Smrgtypedef void (*tnl_triangle_func)( struct gl_context *ctx, 321848b8605Smrg GLuint v1, GLuint v2, GLuint v3 ); 322848b8605Smrgtypedef void (*tnl_quad_func)( struct gl_context *ctx, GLuint v1, GLuint v2, 323848b8605Smrg GLuint v3, GLuint v4 ); 324848b8605Smrgtypedef void (*tnl_render_func)( struct gl_context *ctx, GLuint start, GLuint count, 325848b8605Smrg GLuint flags ); 326848b8605Smrgtypedef void (*tnl_interp_func)( struct gl_context *ctx, 327848b8605Smrg GLfloat t, GLuint dst, GLuint out, GLuint in, 328848b8605Smrg GLboolean force_boundary ); 329848b8605Smrgtypedef void (*tnl_copy_pv_func)( struct gl_context *ctx, GLuint dst, GLuint src ); 330848b8605Smrgtypedef void (*tnl_setup_func)( struct gl_context *ctx, 331848b8605Smrg GLuint start, GLuint end, 332848b8605Smrg GLuint new_inputs); 333848b8605Smrg 334848b8605Smrg 335848b8605Smrgstruct tnl_attr_type { 336848b8605Smrg GLuint format; 337848b8605Smrg GLuint size; 338848b8605Smrg GLuint stride; 339848b8605Smrg GLuint offset; 340848b8605Smrg}; 341848b8605Smrg 342848b8605Smrgstruct tnl_clipspace_fastpath { 343848b8605Smrg GLuint vertex_size; 344848b8605Smrg GLuint attr_count; 345848b8605Smrg GLboolean match_strides; 346848b8605Smrg 347848b8605Smrg struct tnl_attr_type *attr; 348848b8605Smrg 349848b8605Smrg tnl_emit_func func; 350848b8605Smrg struct tnl_clipspace_fastpath *next; 351848b8605Smrg}; 352848b8605Smrg 353848b8605Smrg/** 354848b8605Smrg * Used to describe conversion of vertex arrays to vertex structures. 355848b8605Smrg * I.e. Structure of arrays to arrays of structs. 356848b8605Smrg */ 357848b8605Smrgstruct tnl_clipspace 358848b8605Smrg{ 359848b8605Smrg GLboolean need_extras; 360848b8605Smrg 361848b8605Smrg GLuint new_inputs; 362848b8605Smrg 363848b8605Smrg GLubyte *vertex_buf; 364848b8605Smrg GLuint vertex_size; 365848b8605Smrg GLuint max_vertex_size; 366848b8605Smrg 367848b8605Smrg struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX]; 368848b8605Smrg GLuint attr_count; 369848b8605Smrg 370848b8605Smrg tnl_emit_func emit; 371848b8605Smrg tnl_interp_func interp; 372848b8605Smrg tnl_copy_pv_func copy_pv; 373848b8605Smrg 374848b8605Smrg /* Parameters and constants for codegen: 375848b8605Smrg */ 376848b8605Smrg GLboolean need_viewport; 377848b8605Smrg GLfloat vp_scale[4]; 378848b8605Smrg GLfloat vp_xlate[4]; 379848b8605Smrg GLfloat chan_scale[4]; 380848b8605Smrg GLfloat identity[4]; 381848b8605Smrg 382848b8605Smrg struct tnl_clipspace_fastpath *fastpath; 383848b8605Smrg 384848b8605Smrg void (*codegen_emit)( struct gl_context *ctx ); 385848b8605Smrg}; 386848b8605Smrg 387848b8605Smrg 388848b8605Smrg#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */ 389848b8605Smrg 390848b8605Smrg/** 391848b8605Smrg * Material shininess lookup table. 392848b8605Smrg */ 393848b8605Smrgstruct tnl_shine_tab 394848b8605Smrg{ 395848b8605Smrg struct tnl_shine_tab *next, *prev; 396848b8605Smrg GLfloat tab[SHINE_TABLE_SIZE+1]; 397848b8605Smrg GLfloat shininess; 398848b8605Smrg GLuint refcount; 399848b8605Smrg}; 400848b8605Smrg 401848b8605Smrg 402848b8605Smrgstruct tnl_device_driver 403848b8605Smrg{ 404848b8605Smrg /*** 405848b8605Smrg *** TNL Pipeline 406848b8605Smrg ***/ 407848b8605Smrg 408848b8605Smrg void (*RunPipeline)(struct gl_context *ctx); 409848b8605Smrg /* Replaces PipelineStart/PipelineFinish -- intended to allow 410848b8605Smrg * drivers to wrap _tnl_run_pipeline() with code to validate state 411848b8605Smrg * and grab/release hardware locks. 412848b8605Smrg */ 413848b8605Smrg 414848b8605Smrg void (*NotifyMaterialChange)(struct gl_context *ctx); 415848b8605Smrg /* Alert tnl-aware drivers of changes to material. 416848b8605Smrg */ 417848b8605Smrg 418848b8605Smrg /*** 419848b8605Smrg *** Rendering -- These functions called only from t_vb_render.c 420848b8605Smrg ***/ 421848b8605Smrg struct 422848b8605Smrg { 423848b8605Smrg void (*Start)(struct gl_context *ctx); 424848b8605Smrg void (*Finish)(struct gl_context *ctx); 425848b8605Smrg /* Called before and after all rendering operations, including DrawPixels, 426848b8605Smrg * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands. 427848b8605Smrg * These are a suitable place for grabbing/releasing hardware locks. 428848b8605Smrg */ 429848b8605Smrg 430848b8605Smrg void (*PrimitiveNotify)(struct gl_context *ctx, GLenum mode); 431848b8605Smrg /* Called between RenderStart() and RenderFinish() to indicate the 432848b8605Smrg * type of primitive we're about to draw. Mode will be one of the 433848b8605Smrg * modes accepted by glBegin(). 434848b8605Smrg */ 435848b8605Smrg 436848b8605Smrg tnl_interp_func Interp; 437848b8605Smrg /* The interp function is called by the clipping routines when we need 438848b8605Smrg * to generate an interpolated vertex. All pertinant vertex ancilliary 439848b8605Smrg * data should be computed by interpolating between the 'in' and 'out' 440848b8605Smrg * vertices. 441848b8605Smrg */ 442848b8605Smrg 443848b8605Smrg tnl_copy_pv_func CopyPV; 444848b8605Smrg /* The copy function is used to make a copy of a vertex. All pertinant 445848b8605Smrg * vertex attributes should be copied. 446848b8605Smrg */ 447848b8605Smrg 448848b8605Smrg void (*ClippedPolygon)( struct gl_context *ctx, const GLuint *elts, GLuint n ); 449848b8605Smrg /* Render a polygon with <n> vertices whose indexes are in the <elts> 450848b8605Smrg * array. 451848b8605Smrg */ 452848b8605Smrg 453848b8605Smrg void (*ClippedLine)( struct gl_context *ctx, GLuint v0, GLuint v1 ); 454848b8605Smrg /* Render a line between the two vertices given by indexes v0 and v1. */ 455848b8605Smrg 456848b8605Smrg tnl_points_func Points; /* must now respect vb->elts */ 457848b8605Smrg tnl_line_func Line; 458848b8605Smrg tnl_triangle_func Triangle; 459848b8605Smrg tnl_quad_func Quad; 460848b8605Smrg /* These functions are called in order to render points, lines, 461848b8605Smrg * triangles and quads. These are only called via the T&L module. 462848b8605Smrg */ 463848b8605Smrg 464848b8605Smrg tnl_render_func *PrimTabVerts; 465848b8605Smrg tnl_render_func *PrimTabElts; 466848b8605Smrg /* Render whole unclipped primitives (points, lines, linestrips, 467848b8605Smrg * lineloops, etc). The tables are indexed by the GL enum of the 468848b8605Smrg * primitive to be rendered. RenderTabVerts is used for non-indexed 469848b8605Smrg * arrays of vertices. RenderTabElts is used for indexed arrays of 470848b8605Smrg * vertices. 471848b8605Smrg */ 472848b8605Smrg 473848b8605Smrg void (*ResetLineStipple)( struct gl_context *ctx ); 474848b8605Smrg /* Reset the hardware's line stipple counter. 475848b8605Smrg */ 476848b8605Smrg 477848b8605Smrg tnl_setup_func BuildVertices; 478848b8605Smrg /* This function is called whenever new vertices are required for 479848b8605Smrg * rendering. The vertices in question are those n such that start 480848b8605Smrg * <= n < end. The new_inputs parameter indicates those fields of 481848b8605Smrg * the vertex which need to be updated, if only a partial repair of 482848b8605Smrg * the vertex is required. 483848b8605Smrg * 484848b8605Smrg * This function is called only from _tnl_render_stage in tnl/t_render.c. 485848b8605Smrg */ 486848b8605Smrg 487848b8605Smrg 488848b8605Smrg GLboolean (*Multipass)( struct gl_context *ctx, GLuint passno ); 489848b8605Smrg /* Driver may request additional render passes by returning GL_TRUE 490848b8605Smrg * when this function is called. This function will be called 491848b8605Smrg * after the first pass, and passes will be made until the function 492848b8605Smrg * returns GL_FALSE. If no function is registered, only one pass 493848b8605Smrg * is made. 494848b8605Smrg * 495848b8605Smrg * This function will be first invoked with passno == 1. 496848b8605Smrg */ 497848b8605Smrg } Render; 498848b8605Smrg}; 499848b8605Smrg 500848b8605Smrg 501b8e80941Smrg/** 502b8e80941Smrg * Utility that tracks and updates the current array entries. 503b8e80941Smrg */ 504b8e80941Smrgstruct tnl_inputs 505b8e80941Smrg{ 506b8e80941Smrg /** 507b8e80941Smrg * Array of inputs to be set to the _DrawArrays pointer. 508b8e80941Smrg * The array contains pointers into the _DrawVAO and to the vbo modules 509b8e80941Smrg * current values. The array of pointers is updated incrementally 510b8e80941Smrg * based on the current and vertex_processing_mode values below. 511b8e80941Smrg */ 512b8e80941Smrg struct tnl_vertex_array inputs[VERT_ATTRIB_MAX]; 513b8e80941Smrg /** Those VERT_BIT_'s where the inputs array point to current values. */ 514b8e80941Smrg GLbitfield current; 515b8e80941Smrg /** Store which aliasing current values - generics or materials - are set. */ 516b8e80941Smrg gl_vertex_processing_mode vertex_processing_mode; 517b8e80941Smrg}; 518b8e80941Smrg 519b8e80941Smrg 520b8e80941Smrg/** 521b8e80941Smrg * Initialize inputs. 522b8e80941Smrg */ 523b8e80941Smrgvoid 524b8e80941Smrg_tnl_init_inputs(struct tnl_inputs *inputs); 525b8e80941Smrg 526b8e80941Smrg 527b8e80941Smrg/** 528b8e80941Smrg * Update the tnl_vertex_array array inside the tnl_inputs structure 529b8e80941Smrg * provided the current _VPMode, the provided vao and 530b8e80941Smrg * the vao's enabled arrays filtered by the filter bitmask. 531b8e80941Smrg */ 532b8e80941Smrgvoid 533b8e80941Smrg_tnl_update_inputs(struct gl_context *ctx, struct tnl_inputs *inputs); 534b8e80941Smrg 535b8e80941Smrg 536848b8605Smrg/** 537848b8605Smrg * Context state for T&L context. 538848b8605Smrg */ 539848b8605Smrgtypedef struct 540848b8605Smrg{ 541848b8605Smrg /* Driver interface. 542848b8605Smrg */ 543848b8605Smrg struct tnl_device_driver Driver; 544848b8605Smrg 545848b8605Smrg /* Pipeline 546848b8605Smrg */ 547848b8605Smrg struct tnl_pipeline pipeline; 548848b8605Smrg struct vertex_buffer vb; 549848b8605Smrg 550848b8605Smrg /* Clipspace/ndc/window vertex managment: 551848b8605Smrg */ 552848b8605Smrg struct tnl_clipspace clipspace; 553b8e80941Smrg GLmatrix _WindowMap; 554848b8605Smrg 555848b8605Smrg /* Probably need a better configuration mechanism: 556848b8605Smrg */ 557848b8605Smrg GLboolean NeedNdcCoords; 558848b8605Smrg GLboolean AllowVertexFog; 559848b8605Smrg GLboolean AllowPixelFog; 560848b8605Smrg GLboolean _DoVertexFog; /* eval fog function at each vertex? */ 561848b8605Smrg 562848b8605Smrg GLbitfield64 render_inputs_bitset; 563848b8605Smrg 564848b8605Smrg GLvector4f tmp_inputs[VERT_ATTRIB_MAX]; 565848b8605Smrg 566848b8605Smrg /* Temp storage for t_draw.c: 567848b8605Smrg */ 568848b8605Smrg GLubyte *block[VERT_ATTRIB_MAX]; 569848b8605Smrg GLuint nr_blocks; 570848b8605Smrg 571848b8605Smrg GLuint CurInstance; 572848b8605Smrg 573848b8605Smrg struct tnl_shine_tab *_ShineTable[2]; /**< Active shine tables */ 574848b8605Smrg struct tnl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ 575848b8605Smrg /**@}*/ 576b8e80941Smrg 577b8e80941Smrg /* The list of tnl_vertex_array inputs. */ 578b8e80941Smrg struct tnl_inputs draw_arrays; 579848b8605Smrg} TNLcontext; 580848b8605Smrg 581848b8605Smrg 582848b8605Smrg 583848b8605Smrg#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context)) 584848b8605Smrg 585848b8605Smrg 586848b8605Smrg#define TYPE_IDX(t) ((t) & 0xf) 587848b8605Smrg#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ 588848b8605Smrg 589848b8605Smrg 590848b8605Smrgextern void 591848b8605Smrgtnl_clip_prepare(struct gl_context *ctx); 592848b8605Smrg 593848b8605Smrg 594848b8605Smrg#endif 595