123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell/* 2ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell * mesa 3-D graphics library 3b43671c8bf0ff640243c670ff98225d2a3c10632Brian Paul * Version: 6.5 45e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 5bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 65e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Permission is hereby granted, free of charge, to any person obtaining a 823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * copy of this software and associated documentation files (the "Software"), 923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * to deal in the Software without restriction, including without limitation 1023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * the rights to use, copy, modify, merge, publish, distribute, sublicense, 1123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * and/or sell copies of the Software, and to permit persons to whom the 1223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * Software is furnished to do so, subject to the following conditions: 135e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 1423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * The above copyright notice and this permission notice shall be included 1523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * in all copies or substantial portions of the Software. 165e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen * 1723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 1823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 2023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 2123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 2223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 234c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul */ 244c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul 254c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul/** 264c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul * \file t_context.h 274c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul * \brief TnL module datatypes and definitions. 284c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul * \author Keith Whitwell 2923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 3023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 31c8f2f456f94232671511745e1b236339af6b44ceBrian Paul 32c8f2f456f94232671511745e1b236339af6b44ceBrian Paul/** 33c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * \mainpage The TNL-module 34c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * 35c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * TNL stands for "transform and lighting", i.e. this module implements 36c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * a pipeline that receives as input a buffer of vertices and does all 37c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * necessary transformations (rotations, clipping, vertex shader etc.) 38c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * and passes then the output to the rasterizer. 39c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * 40ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell * The tnl_pipeline contains the array of all stages, which should be 41e53aa5022f5d70abe81d5b97dccebcb389cf4647Brian Paul * applied. Each stage is a black-box, which is described by an 42ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the 43e53aa5022f5d70abe81d5b97dccebcb389cf4647Brian Paul * stages to the vertex_buffer TNLcontext::vb, where the vertex data 44e53aa5022f5d70abe81d5b97dccebcb389cf4647Brian Paul * is stored. The last stage in the pipeline is the rasterizer. 45c8f2f456f94232671511745e1b236339af6b44ceBrian Paul * 46c8f2f456f94232671511745e1b236339af6b44ceBrian Paul */ 47c8f2f456f94232671511745e1b236339af6b44ceBrian Paul 48e53aa5022f5d70abe81d5b97dccebcb389cf4647Brian Paul 4923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#ifndef _T_CONTEXT_H 5023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#define _T_CONTEXT_H 5123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 52c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/glheader.h" 5350e0091a9d70f9e6383ad322d4df7576bd7c38f7Mathias Fröhlich#include "main/imports.h" 54c223c6b663cd5db39ba19c2be74b88cc3b8f53f3Brian#include "main/mtypes.h" 5523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 5623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#include "math/m_vector.h" 5723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 5870dd0126bd25f2cc2fedae60281ab5c256cb8664Keith Whitwell#include "vbo/vbo.h" 5923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 60cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#define MAX_PIPELINE_STAGES 30 6123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 6241c310b20a97a9719100f61c6871e9fd4b3ff5f9Brian Paul/* 6341c310b20a97a9719100f61c6871e9fd4b3ff5f9Brian Paul * Note: The first attributes match the VERT_ATTRIB_* definitions 6441c310b20a97a9719100f61c6871e9fd4b3ff5f9Brian Paul * in mtypes.h. However, the tnl module has additional attributes 6541c310b20a97a9719100f61c6871e9fd4b3ff5f9Brian Paul * for materials, color indexes, edge flags, etc. 6641c310b20a97a9719100f61c6871e9fd4b3ff5f9Brian Paul */ 676f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell/* Although it's nice to use these as bit indexes in a DWORD flag, we 686f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell * could manage without if necessary. Another limit currently is the 696f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell * number of bits allocated for these numbers in places like vertex 706f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell * program instruction formats and register layouts. 71588225770c60834dfd2a95850435cc549167dc05Keith Whitwell */ 72bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol/* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for 73bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol * GLSL vertex shader which cannot be aliased with conventional vertex attribs. 74bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give 75bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE* 76bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol * attribs want (16). 77bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol */ 78ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwellenum { 79ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_POS = 0, 80ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_WEIGHT = 1, 81ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_NORMAL = 2, 82ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_COLOR0 = 3, 83ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_COLOR1 = 4, 84ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_FOG = 5, 8594b30dc390f1fdd526c080080830016fad3e2ee2Brian Paul _TNL_ATTRIB_COLOR_INDEX = 6, 86b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell _TNL_ATTRIB_EDGEFLAG = 7, 87ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX0 = 8, 88ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX1 = 9, 89ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX2 = 10, 90ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX3 = 11, 91ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX4 = 12, 92ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX5 = 13, 93ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX6 = 14, 94ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell _TNL_ATTRIB_TEX7 = 15, 95b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell 96ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC0 = 17, /* doesn't really exist! */ 97ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC1 = 18, 98ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC2 = 19, 99ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC3 = 20, 100ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC4 = 21, 101ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC5 = 22, 102ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC6 = 23, 103ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC7 = 24, 104ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC8 = 25, 105ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC9 = 26, 106ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC10 = 27, 107ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC11 = 28, 108ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC12 = 29, 109ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC13 = 30, 110ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC14 = 31, 111ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_GENERIC15 = 32, 112b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell 113b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell /* These alias with the generics, but they are not active 114b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * concurrently, so it's not a problem. The TNL module 115b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * doesn't have to do anything about this as this is how they 116b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * are passed into the _draw_prims callback. 117b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * 118b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * When we generate fixed-function replacement programs (in 119b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * t_vp_build.c currently), they refer to the appropriate 120b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * generic attribute in order to pick up per-vertex material 121b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * data. 122b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell */ 123ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_FRONT_AMBIENT = 17, 124ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_BACK_AMBIENT = 18, 125ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 19, 126ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_BACK_DIFFUSE = 20, 127ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_FRONT_SPECULAR = 21, 128ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_BACK_SPECULAR = 22, 129ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_FRONT_EMISSION = 23, 130ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_BACK_EMISSION = 24, 131ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_FRONT_SHININESS = 25, 132ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_BACK_SHININESS = 26, 133ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_FRONT_INDEXES = 27, 134ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAT_BACK_INDEXES = 28, 135b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell 136b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell /* This is really a VERT_RESULT, not an attrib. Need to fix 137b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell * tnl to understand the difference. 138b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell */ 139b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell _TNL_ATTRIB_POINTSIZE = 16, 140b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell 141ce45aecfdab9926b767d9924bddbc4304d59641cMathias Fröhlich _TNL_ATTRIB_MAX = 33 142ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell} ; 143ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell 144bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol#define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u)) 14562dc134771858638ac38687c16bbb0578d20c419Brian Paul#define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n)) 146bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol 147095c6699f449ed4803f23e844cc0227743a9c3e1Brian Paul/* special index used for handing invalid glVertexAttribute() indices */ 14862dc134771858638ac38687c16bbb0578d20c419Brian Paul#define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_GENERIC15 + 1) 149095c6699f449ed4803f23e844cc0227743a9c3e1Brian Paul 15094b30dc390f1fdd526c080080830016fad3e2ee2Brian Paul/** 15194b30dc390f1fdd526c080080830016fad3e2ee2Brian Paul * Handy attribute ranges: 15223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 153bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol#define _TNL_FIRST_PROG _TNL_ATTRIB_WEIGHT 154bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol#define _TNL_LAST_PROG _TNL_ATTRIB_TEX7 155bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol 156bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol#define _TNL_FIRST_TEX _TNL_ATTRIB_TEX0 157bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol#define _TNL_LAST_TEX _TNL_ATTRIB_TEX7 158bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol 15962dc134771858638ac38687c16bbb0578d20c419Brian Paul#define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0 16062dc134771858638ac38687c16bbb0578d20c419Brian Paul#define _TNL_LAST_GENERIC _TNL_ATTRIB_GENERIC15 161ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell 162b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */ 163b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* GENERIC11 */ 164ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell 16550e0091a9d70f9e6383ad322d4df7576bd7c38f7Mathias Fröhlich/* Number of available texture attributes */ 16650e0091a9d70f9e6383ad322d4df7576bd7c38f7Mathias Fröhlich#define _TNL_NUM_TEX 8 16750e0091a9d70f9e6383ad322d4df7576bd7c38f7Mathias Fröhlich 168ff5b590382d716dccd9d3122ead9a9236f019aaaTilman Sauerbeck/* Number of available generic attributes */ 169ff5b590382d716dccd9d3122ead9a9236f019aaaTilman Sauerbeck#define _TNL_NUM_GENERIC 16 170ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell 1710749e2723b32ba430539791b94acd95dcf939a1dBrian Paul/* Number of attributes used for evaluators */ 1720749e2723b32ba430539791b94acd95dcf939a1dBrian Paul#define _TNL_NUM_EVAL 16 1730749e2723b32ba430539791b94acd95dcf939a1dBrian Paul 174b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell 175ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell#define PRIM_BEGIN 0x10 176ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell#define PRIM_END 0x20 177ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell#define PRIM_MODE_MASK 0x0f 178ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell 1791ad5a1a2460dcfe2dd36e19e8699aa58c4a46025Brian Paulstatic inline GLuint _tnl_translate_prim( const struct _mesa_prim *prim ) 180b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell{ 181b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell GLuint flag; 182b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell flag = prim->mode; 183b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell if (prim->begin) flag |= PRIM_BEGIN; 184b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell if (prim->end) flag |= PRIM_END; 185b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell return flag; 186b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell} 18786b842790b720cd6b1499ce8edca8a4e9c8dc029Brian Paul 1885e3bc0c2a2bcdf59949410f94c9b705fc1281ce8Jouk Jansen 18923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 19023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 1914c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul/** 1924c8fadc6d996c8c433826c4c763104b7d69cf7e5Brian Paul * Contains the current state of a running pipeline. 19323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 194ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwellstruct vertex_buffer 19523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell{ 19662dc134771858638ac38687c16bbb0578d20c419Brian Paul GLuint Size; /**< Max vertices per vertex buffer, constant */ 19723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 198cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell /* Constant over the pipeline. 19923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 20062dc134771858638ac38687c16bbb0578d20c419Brian Paul GLuint Count; /**< Number of vertices currently in buffer */ 20123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 202fc9a2970dc539b21b035ea0a770ec69822962145Eric Anholt /* Pointers to current data. Most of the data is in AttribPtr -- all of 203fc9a2970dc539b21b035ea0a770ec69822962145Eric Anholt * it that is one of VERT_ATTRIB_X. For things only produced by TNL, 204fc9a2970dc539b21b035ea0a770ec69822962145Eric Anholt * such as backface color or eye-space coordinates, they are stored 205fc9a2970dc539b21b035ea0a770ec69822962145Eric Anholt * here. 20623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 207ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLuint *Elts; 208ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLvector4f *EyePtr; /* _TNL_BIT_POS */ 209ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLvector4f *ClipPtr; /* _TNL_BIT_POS */ 210ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLvector4f *NdcPtr; /* _TNL_BIT_POS */ 211ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLubyte ClipOrMask; /* _TNL_BIT_POS */ 212352d4dbfb24c65f327759c00c7db7d30a9482e35Keith Whitwell GLubyte ClipAndMask; /* _TNL_BIT_POS */ 213ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLubyte *ClipMask; /* _TNL_BIT_POS */ 214ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */ 215ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */ 2160a9187801505130738ae947c69cafa8a1dd118d1Eric Anholt GLvector4f *BackfaceIndexPtr; 2170a9187801505130738ae947c69cafa8a1dd118d1Eric Anholt GLvector4f *BackfaceColorPtr; 2180a9187801505130738ae947c69cafa8a1dd118d1Eric Anholt GLvector4f *BackfaceSecondaryColorPtr; 219ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell 220b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell const struct _mesa_prim *Primitive; 221ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLuint PrimitiveCount; 222cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 223363049160da54f4aafe88f99bb2140a9bfed142bBrian Paul /* Inputs to the vertex program stage */ 224ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */ 225ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell}; 22623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 22723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 22862dc134771858638ac38687c16bbb0578d20c419Brian Paul/** 22962dc134771858638ac38687c16bbb0578d20c419Brian Paul * Describes an individual operation on the pipeline. 230cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */ 23109da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paulstruct tnl_pipeline_stage 23209da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul{ 233cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell const char *name; 234790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 235cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell /* Private data for the pipeline stage: 236cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */ 237b51b0a847d7e7daaea69f77ab569086ef81c24a2Brian Paul void *privatePtr; 23823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2396f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell /* Allocate private data 2406f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell */ 241f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg GLboolean (*create)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 2426f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell 2436f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell /* Free private data. 244cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */ 245ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell void (*destroy)( struct tnl_pipeline_stage * ); 24623caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2476f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell /* Called on any statechange or input array size change or 2486f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell * input array change to/from zero stride. 249cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */ 250f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*validate)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 251cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 252cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell /* Called from _tnl_run_pipeline(). The stage.changed_inputs value 253cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * encodes all inputs to thee struct which have changed. If 254cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * non-zero, recompute all affected outputs of the stage, otherwise 25522144ab7552f0799bcfca506bf4ffa7f70a06649Gareth Hughes * execute any 'sideeffects' of the stage. 256cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * 257cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * Return value: GL_TRUE - keep going 258cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell * GL_FALSE - finished pipeline 259cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell */ 260f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg GLboolean (*run)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 26123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell}; 26223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 2636f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell 2646f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell 265c8f2f456f94232671511745e1b236339af6b44ceBrian Paul/** Contains the array of all pipeline stages. 2666f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell * The default values are defined at the end of t_pipeline.c 2676f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell */ 268ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwellstruct tnl_pipeline { 2696f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell 2706f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell GLuint last_attrib_stride[_TNL_ATTRIB_MAX]; 2716f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell GLuint last_attrib_size[_TNL_ATTRIB_MAX]; 2726f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell GLuint input_changes; 2736f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell GLuint new_state; 2746f973f33679e034b7cb63806f1ddfabdbdd70123Keith Whitwell 275ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; 276cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell GLuint nr_stages; 27723caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell}; 27823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 279009aa3ef5ea6bc13c903d6f902b7039adef8fc74Keith Whitwellstruct tnl_clipspace; 280588225770c60834dfd2a95850435cc549167dc05Keith Whitwellstruct tnl_clipspace_attr; 281588225770c60834dfd2a95850435cc549167dc05Keith Whitwell 2823d38361b718d490e1e7fda64519952ec887cd149Keith Whitwelltypedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a, 2833d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLfloat *out, 2843d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell const GLubyte *v ); 285588225770c60834dfd2a95850435cc549167dc05Keith Whitwell 2863d38361b718d490e1e7fda64519952ec887cd149Keith Whitwelltypedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a, 2873d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLubyte *v, 2883d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell const GLfloat *in ); 289588225770c60834dfd2a95850435cc549167dc05Keith Whitwell 290f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_emit_func)( struct gl_context *ctx, 2919a8a9fb01fa5beeb843415277b48b086b099aa97Keith Whitwell GLuint count, 2929a8a9fb01fa5beeb843415277b48b086b099aa97Keith Whitwell GLubyte *dest ); 293009aa3ef5ea6bc13c903d6f902b7039adef8fc74Keith Whitwell 29423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 295fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul/** 296fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul * Describes how to convert/move a vertex attribute from a vertex array 297fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul * to a vertex structure. 298fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul */ 29909da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paulstruct tnl_clipspace_attr 30009da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul{ 301fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul GLuint attrib; /* which vertex attrib (0=position, etc) */ 302009aa3ef5ea6bc13c903d6f902b7039adef8fc74Keith Whitwell GLuint format; 303fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul GLuint vertoffset; /* position of the attrib in the vertex struct */ 304fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul GLuint vertattrsize; /* size of the attribute in bytes */ 305588225770c60834dfd2a95850435cc549167dc05Keith Whitwell GLubyte *inputptr; 306fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul GLuint inputstride; 3072b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLuint inputsize; 308c07ec046b7492602f32f9139a13bfcc8db0253c3Brian Paul const tnl_insert_func *insert; 3093d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_insert_func emit; 3103d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_extract_func extract; 311fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul const GLfloat *vp; /* NDC->Viewport mapping matrix */ 312790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell}; 313790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 314ad2ac216fa0cbebc36530bf9e5256e902710b892Keith Whitwell 315009aa3ef5ea6bc13c903d6f902b7039adef8fc74Keith Whitwell 316709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell 317f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_points_func)( struct gl_context *ctx, GLuint first, GLuint last ); 318f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_line_func)( struct gl_context *ctx, GLuint v1, GLuint v2 ); 319f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_triangle_func)( struct gl_context *ctx, 3203d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLuint v1, GLuint v2, GLuint v3 ); 321f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_quad_func)( struct gl_context *ctx, GLuint v1, GLuint v2, 3223d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLuint v3, GLuint v4 ); 323f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_render_func)( struct gl_context *ctx, GLuint start, GLuint count, 3243d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLuint flags ); 325f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_interp_func)( struct gl_context *ctx, 3263d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLfloat t, GLuint dst, GLuint out, GLuint in, 3273d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLboolean force_boundary ); 328f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_copy_pv_func)( struct gl_context *ctx, GLuint dst, GLuint src ); 329f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtypedef void (*tnl_setup_func)( struct gl_context *ctx, 3303d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLuint start, GLuint end, 3313d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell GLuint new_inputs); 332709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell 333709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell 3347a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paulstruct tnl_attr_type { 3357a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul GLuint format; 3367a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul GLuint size; 3377a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul GLuint stride; 3387a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul GLuint offset; 3397a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul}; 3407a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul 3412b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwellstruct tnl_clipspace_fastpath { 3422b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLuint vertex_size; 3432b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLuint attr_count; 3442b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLboolean match_strides; 3452b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell 3467a7aa2aabb90a2f6833f582ff4701f3840d399f7Brian Paul struct tnl_attr_type *attr; 3472b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell 3482b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell tnl_emit_func func; 3492b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell struct tnl_clipspace_fastpath *next; 3502b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell}; 3512b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell 352fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul/** 353fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul * Used to describe conversion of vertex arrays to vertex structures. 354fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul * I.e. Structure of arrays to arrays of structs. 355fde4c53a7d460a7fed929ef457172f3b245d875dBrian Paul */ 35609da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paulstruct tnl_clipspace 35709da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul{ 358790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell GLboolean need_extras; 359790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 360790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell GLuint new_inputs; 361790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 362790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell GLubyte *vertex_buf; 363790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell GLuint vertex_size; 364790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell GLuint max_vertex_size; 365790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 366790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX]; 367790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell GLuint attr_count; 368790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 3693d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_emit_func emit; 3703d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_interp_func interp; 3713d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_copy_pv_func copy_pv; 372009aa3ef5ea6bc13c903d6f902b7039adef8fc74Keith Whitwell 3732b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell /* Parameters and constants for codegen: 3742b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell */ 3752b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLboolean need_viewport; 3762b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLfloat vp_scale[4]; 3772b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLfloat vp_xlate[4]; 3782b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLfloat chan_scale[4]; 3792b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell GLfloat identity[4]; 3802b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell 3812b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell struct tnl_clipspace_fastpath *fastpath; 3822b2bd08589099cb480b983835b01cc76a766a3c4Keith Whitwell 383f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*codegen_emit)( struct gl_context *ctx ); 384790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell}; 385790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 386790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 387ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */ 388ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich 389ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich/** 390ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich * Material shininess lookup table. 391ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich */ 392ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlichstruct tnl_shine_tab 393ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich{ 394ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich struct tnl_shine_tab *next, *prev; 395ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich GLfloat tab[SHINE_TABLE_SIZE+1]; 396ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich GLfloat shininess; 397ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich GLuint refcount; 398ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich}; 399ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich 400ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich 40109da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paulstruct tnl_device_driver 40209da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul{ 403709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell /*** 404709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell *** TNL Pipeline 405709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell ***/ 406709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell 407f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*RunPipeline)(struct gl_context *ctx); 4087954a0cafdce545cde193e8ec317afa85be2b736Keith Whitwell /* Replaces PipelineStart/PipelineFinish -- intended to allow 4097954a0cafdce545cde193e8ec317afa85be2b736Keith Whitwell * drivers to wrap _tnl_run_pipeline() with code to validate state 4107954a0cafdce545cde193e8ec317afa85be2b736Keith Whitwell * and grab/release hardware locks. 411709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell */ 412709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell 413f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*NotifyMaterialChange)(struct gl_context *ctx); 414306d3fcdbad523428501833405e47e9897896defKeith Whitwell /* Alert tnl-aware drivers of changes to material. 415306d3fcdbad523428501833405e47e9897896defKeith Whitwell */ 416306d3fcdbad523428501833405e47e9897896defKeith Whitwell 417709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell /*** 4181182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell *** Rendering -- These functions called only from t_vb_render.c 419709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell ***/ 42009da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul struct 42109da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul { 422f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*Start)(struct gl_context *ctx); 423f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*Finish)(struct gl_context *ctx); 4241182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Called before and after all rendering operations, including DrawPixels, 4251182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands. 4261182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * These are a suitable place for grabbing/releasing hardware locks. 4271182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4281182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 429f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*PrimitiveNotify)(struct gl_context *ctx, GLenum mode); 4301182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Called between RenderStart() and RenderFinish() to indicate the 4311182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * type of primitive we're about to draw. Mode will be one of the 4321182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * modes accepted by glBegin(). 4331182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4341182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 4353d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_interp_func Interp; 4361182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* The interp function is called by the clipping routines when we need 4371182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * to generate an interpolated vertex. All pertinant vertex ancilliary 4381182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * data should be computed by interpolating between the 'in' and 'out' 4391182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * vertices. 4401182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4411182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 4423d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_copy_pv_func CopyPV; 4431182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* The copy function is used to make a copy of a vertex. All pertinant 4441182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * vertex attributes should be copied. 4451182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4461182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 447f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*ClippedPolygon)( struct gl_context *ctx, const GLuint *elts, GLuint n ); 4481182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Render a polygon with <n> vertices whose indexes are in the <elts> 4491182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * array. 4501182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4511182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 452f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*ClippedLine)( struct gl_context *ctx, GLuint v0, GLuint v1 ); 4531182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Render a line between the two vertices given by indexes v0 and v1. */ 4541182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 4553d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_points_func Points; /* must now respect vb->elts */ 4563d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_line_func Line; 4573d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_triangle_func Triangle; 4583d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_quad_func Quad; 4591182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* These functions are called in order to render points, lines, 4601182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * triangles and quads. These are only called via the T&L module. 4611182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4621182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 4633d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_render_func *PrimTabVerts; 4643d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_render_func *PrimTabElts; 4651182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Render whole unclipped primitives (points, lines, linestrips, 4661182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * lineloops, etc). The tables are indexed by the GL enum of the 4671182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * primitive to be rendered. RenderTabVerts is used for non-indexed 4681182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * arrays of vertices. RenderTabElts is used for indexed arrays of 4691182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * vertices. 4701182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4711182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 472f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg void (*ResetLineStipple)( struct gl_context *ctx ); 4731182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Reset the hardware's line stipple counter. 4741182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4751182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 4763d38361b718d490e1e7fda64519952ec887cd149Keith Whitwell tnl_setup_func BuildVertices; 4771182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* This function is called whenever new vertices are required for 4781182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * rendering. The vertices in question are those n such that start 4791182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * <= n < end. The new_inputs parameter indicates those fields of 4801182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * the vertex which need to be updated, if only a partial repair of 4811182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * the vertex is required. 4821182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * 4831182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * This function is called only from _tnl_render_stage in tnl/t_render.c. 4841182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4851182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 4861182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell 487f9995b30756140724f41daf963fa06167912be7fKristian Høgsberg GLboolean (*Multipass)( struct gl_context *ctx, GLuint passno ); 4881182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell /* Driver may request additional render passes by returning GL_TRUE 4891182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * when this function is called. This function will be called 4901182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * after the first pass, and passes will be made until the function 4911182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * returns GL_FALSE. If no function is registered, only one pass 4921182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * is made. 4931182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * 4941182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell * This function will be first invoked with passno == 1. 4951182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell */ 4961182ffeec39bf419928ba862c225e80a439fee7aKeith Whitwell } Render; 497709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell}; 498bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol 499bb38cadb1c5f2dc13096a091bdaf61dc3e3cfa4dMichal Krol 50009da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul/** 50109da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul * Context state for T&L context. 50209da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul */ 50309da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paultypedef struct 50409da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul{ 505709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell /* Driver interface. 506709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell */ 507709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell struct tnl_device_driver Driver; 508709892459922a32096fe9dd8261d0d92337bb02fKeith Whitwell 509cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell /* Pipeline 51023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell */ 511ae0eaf93e092ac8e8b1c98f3e986de96940663faKeith Whitwell struct tnl_pipeline pipeline; 512cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell struct vertex_buffer vb; 51323caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 514790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell /* Clipspace/ndc/window vertex managment: 515790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell */ 516790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell struct tnl_clipspace clipspace; 517790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 518321f67c4729adeebd7aa9ef9e22c95e709952851Keith Whitwell /* Probably need a better configuration mechanism: 519321f67c4729adeebd7aa9ef9e22c95e709952851Keith Whitwell */ 52030f51ae067379c2b3573c06b707d25a9704df7beBrian Paul GLboolean NeedNdcCoords; 52109da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul GLboolean AllowVertexFog; 5228d407300c2b94f32c955b6dd75c2e18d6d58caa5Brian Paul GLboolean AllowPixelFog; 52309da0b8e6621a831e3eeb9381430f2bed18a22adBrian Paul GLboolean _DoVertexFog; /* eval fog function at each vertex? */ 524790734045b69c47b1525fbf9106a7ca5a8eb7416Keith Whitwell 525ccbf192f597186f6a4a04ed14391dba82ffee18bMathias Fröhlich GLbitfield64 render_inputs_bitset; 526ad2ac216fa0cbebc36530bf9e5256e902710b892Keith Whitwell 527b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell GLvector4f tmp_inputs[VERT_ATTRIB_MAX]; 528ad2ac216fa0cbebc36530bf9e5256e902710b892Keith Whitwell 529b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell /* Temp storage for t_draw.c: 530b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell */ 531b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell GLubyte *block[VERT_ATTRIB_MAX]; 532b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell GLuint nr_blocks; 533b1f176039ae3690b38e3ccacb079b3d7c3e50402Keith Whitwell 534a63486ac680acc0bfb895037aca130a457caa01aBrian Paul GLuint CurInstance; 535ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich 536ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich struct tnl_shine_tab *_ShineTable[2]; /**< Active shine tables */ 537ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich struct tnl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ 538ba1d921bdf7a15fcc4a4e3162ea6fe9810f233d6Mathias Fröhlich /**@}*/ 53923caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell} TNLcontext; 54023caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 54123caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 54223caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 54380875253ce0e166bd8f529ba9b869139ce82902aBrian Paul#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context)) 54423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 54523caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 546cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#define TYPE_IDX(t) ((t) & 0xf) 547cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ 54823caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell 549cab974cf6c2dbfbf5dd5d291e1aae0f8eeb34290Keith Whitwell 5503fed69eb168774d2303e4efb9149f34e55d91b58Brian Paulextern void 551f9995b30756140724f41daf963fa06167912be7fKristian Høgsbergtnl_clip_prepare(struct gl_context *ctx); 5523fed69eb168774d2303e4efb9149f34e55d91b58Brian Paul 5533fed69eb168774d2303e4efb9149f34e55d91b58Brian Paul 55423caf20169ac38436ee9c13914f1d6aa7cf6bb5eKeith Whitwell#endif 555