1f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 2f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * mesa 3-D graphics library 3f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Version: 6.5 4f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 5f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 6f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 7f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Permission is hereby granted, free of charge, to any person obtaining a 8f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * copy of this software and associated documentation files (the "Software"), 9f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to deal in the Software without restriction, including without limitation 10f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the rights to use, copy, modify, merge, publish, distribute, sublicense, 11f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and/or sell copies of the Software, and to permit persons to whom the 12f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Software is furnished to do so, subject to the following conditions: 13f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 14f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The above copyright notice and this permission notice shall be included 15f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * in all copies or substantial portions of the Software. 16f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 17f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 18f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 21f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 22f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 24f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 25f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 26f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \file t_context.h 27f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \brief TnL module datatypes and definitions. 28f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \author Keith Whitwell 29f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 30f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 31f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 32f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 33f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * \mainpage The TNL-module 34f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 35f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * TNL stands for "transform and lighting", i.e. this module implements 36f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * a pipeline that receives as input a buffer of vertices and does all 37f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * necessary transformations (rotations, clipping, vertex shader etc.) 38f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and passes then the output to the rasterizer. 39f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 40f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The tnl_pipeline contains the array of all stages, which should be 41f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * applied. Each stage is a black-box, which is described by an 42f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the 43f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * stages to the vertex_buffer TNLcontext::vb, where the vertex data 44f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * is stored. The last stage in the pipeline is the rasterizer. 45f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 46f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 47f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 48f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 49f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#ifndef _T_CONTEXT_H 50f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _T_CONTEXT_H 51f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 52f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/glheader.h" 53f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/imports.h" 54f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "main/mtypes.h" 55f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 56f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "math/m_vector.h" 57f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 58f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#include "vbo/vbo.h" 59f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 60f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define MAX_PIPELINE_STAGES 30 61f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 62f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* 63f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Note: The first attributes match the VERT_ATTRIB_* definitions 64f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * in mtypes.h. However, the tnl module has additional attributes 65f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * for materials, color indexes, edge flags, etc. 66f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 67f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Although it's nice to use these as bit indexes in a DWORD flag, we 68f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * could manage without if necessary. Another limit currently is the 69f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * number of bits allocated for these numbers in places like vertex 70f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * program instruction formats and register layouts. 71f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 72f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* The bit space exhaustion is a fact now, done by _TNL_ATTRIB_ATTRIBUTE* for 73f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GLSL vertex shader which cannot be aliased with conventional vertex attribs. 74f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Compacting _TNL_ATTRIB_MAT_* attribs would not work, they would not give 75f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * as many free bits (11 plus already 1 free bit) as _TNL_ATTRIB_ATTRIBUTE* 76f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * attribs want (16). 77f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 78f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgenum { 79f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_POS = 0, 80f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_WEIGHT = 1, 81f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_NORMAL = 2, 82f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_COLOR0 = 3, 83f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_COLOR1 = 4, 84f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_FOG = 5, 85f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_COLOR_INDEX = 6, 86f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_EDGEFLAG = 7, 87f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX0 = 8, 88f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX1 = 9, 89f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX2 = 10, 90f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX3 = 11, 91f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX4 = 12, 92f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX5 = 13, 93f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX6 = 14, 94f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_TEX7 = 15, 95f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 96f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC0 = 17, /* doesn't really exist! */ 97f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC1 = 18, 98f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC2 = 19, 99f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC3 = 20, 100f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC4 = 21, 101f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC5 = 22, 102f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC6 = 23, 103f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC7 = 24, 104f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC8 = 25, 105f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC9 = 26, 106f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC10 = 27, 107f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC11 = 28, 108f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC12 = 29, 109f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC13 = 30, 110f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC14 = 31, 111f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_GENERIC15 = 32, 112f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 113f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* These alias with the generics, but they are not active 114f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * concurrently, so it's not a problem. The TNL module 115f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * doesn't have to do anything about this as this is how they 116f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * are passed into the _draw_prims callback. 117f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 118f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * When we generate fixed-function replacement programs (in 119f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * t_vp_build.c currently), they refer to the appropriate 120f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * generic attribute in order to pick up per-vertex material 121f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * data. 122f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 123f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_FRONT_AMBIENT = 17, 124f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_BACK_AMBIENT = 18, 125f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 19, 126f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_BACK_DIFFUSE = 20, 127f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_FRONT_SPECULAR = 21, 128f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_BACK_SPECULAR = 22, 129f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_FRONT_EMISSION = 23, 130f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_BACK_EMISSION = 24, 131f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_FRONT_SHININESS = 25, 132f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_BACK_SHININESS = 26, 133f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_FRONT_INDEXES = 27, 134f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAT_BACK_INDEXES = 28, 135f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 136f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* This is really a VERT_RESULT, not an attrib. Need to fix 137f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * tnl to understand the difference. 138f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 139f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_POINTSIZE = 16, 140f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 141f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org _TNL_ATTRIB_MAX = 33 142f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} ; 143f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 144f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_ATTRIB_TEX(u) (_TNL_ATTRIB_TEX0 + (u)) 145f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_ATTRIB_GENERIC(n) (_TNL_ATTRIB_GENERIC0 + (n)) 146f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 147f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* special index used for handing invalid glVertexAttribute() indices */ 148f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_ATTRIB_ERROR (_TNL_ATTRIB_GENERIC15 + 1) 149f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 150f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 151f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Handy attribute ranges: 152f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 153f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_FIRST_PROG _TNL_ATTRIB_WEIGHT 154f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_LAST_PROG _TNL_ATTRIB_TEX7 155f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 156f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_FIRST_TEX _TNL_ATTRIB_TEX0 157f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_LAST_TEX _TNL_ATTRIB_TEX7 158f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 159f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_FIRST_GENERIC _TNL_ATTRIB_GENERIC0 160f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_LAST_GENERIC _TNL_ATTRIB_GENERIC15 161f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 162f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_FIRST_MAT _TNL_ATTRIB_MAT_FRONT_AMBIENT /* GENERIC0 */ 163f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_LAST_MAT _TNL_ATTRIB_MAT_BACK_INDEXES /* GENERIC11 */ 164f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 165f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Number of available texture attributes */ 166f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_NUM_TEX 8 167f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 168f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Number of available generic attributes */ 169f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_NUM_GENERIC 16 170f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 171f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/* Number of attributes used for evaluators */ 172f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define _TNL_NUM_EVAL 16 173f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 174f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 175f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PRIM_BEGIN 0x10 176f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PRIM_END 0x20 177f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define PRIM_MODE_MASK 0x0f 178f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 179f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstatic inline GLuint _tnl_translate_prim( const struct _mesa_prim *prim ) 180f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 181f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint flag; 182f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org flag = prim->mode; 183f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (prim->begin) flag |= PRIM_BEGIN; 184f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org if (prim->end) flag |= PRIM_END; 185f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org return flag; 186f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} 187f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 188f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 189f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 190f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 191f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 192f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Contains the current state of a running pipeline. 193f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 194f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct vertex_buffer 195f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 196f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint Size; /**< Max vertices per vertex buffer, constant */ 197f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 198f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Constant over the pipeline. 199f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 200f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint Count; /**< Number of vertices currently in buffer */ 201f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 202f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Pointers to current data. Most of the data is in AttribPtr -- all of 203f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * it that is one of VERT_ATTRIB_X. For things only produced by TNL, 204f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * such as backface color or eye-space coordinates, they are stored 205f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * here. 206f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 207f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint *Elts; 208f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *EyePtr; /* _TNL_BIT_POS */ 209f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *ClipPtr; /* _TNL_BIT_POS */ 210f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *NdcPtr; /* _TNL_BIT_POS */ 211f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte ClipOrMask; /* _TNL_BIT_POS */ 212f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte ClipAndMask; /* _TNL_BIT_POS */ 213f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte *ClipMask; /* _TNL_BIT_POS */ 214f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */ 215f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */ 216f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *BackfaceIndexPtr; 217f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *BackfaceColorPtr; 218f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *BackfaceSecondaryColorPtr; 219f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 220f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const struct _mesa_prim *Primitive; 221f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint PrimitiveCount; 222f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 223f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Inputs to the vertex program stage */ 224f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */ 225f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 226f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 227f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 228f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 229f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Describes an individual operation on the pipeline. 230f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 231f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_pipeline_stage 232f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 233f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const char *name; 234f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 235f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Private data for the pipeline stage: 236f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 237f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void *privatePtr; 238f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 239f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Allocate private data 240f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 241f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean (*create)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 242f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 243f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Free private data. 244f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 245f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*destroy)( struct tnl_pipeline_stage * ); 246f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 247f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Called on any statechange or input array size change or 248f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * input array change to/from zero stride. 249f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 250f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*validate)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 251f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 252f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Called from _tnl_run_pipeline(). The stage.changed_inputs value 253f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * encodes all inputs to thee struct which have changed. If 254f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * non-zero, recompute all affected outputs of the stage, otherwise 255f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * execute any 'sideeffects' of the stage. 256f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 257f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Return value: GL_TRUE - keep going 258f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * GL_FALSE - finished pipeline 259f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 260f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean (*run)( struct gl_context *ctx, struct tnl_pipeline_stage * ); 261f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 262f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 263f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 264f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 265f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** Contains the array of all pipeline stages. 266f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * The default values are defined at the end of t_pipeline.c 267f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 268f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_pipeline { 269f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 270f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint last_attrib_stride[_TNL_ATTRIB_MAX]; 271f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint last_attrib_size[_TNL_ATTRIB_MAX]; 272f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint input_changes; 273f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint new_state; 274f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 275f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1]; 276f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint nr_stages; 277f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 278f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 279f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_clipspace; 280f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_clipspace_attr; 281f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 282f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a, 283f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat *out, 284f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLubyte *v ); 285f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 286f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a, 287f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte *v, 288f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLfloat *in ); 289f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 290f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_emit_func)( struct gl_context *ctx, 291f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint count, 292f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte *dest ); 293f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 294f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 295f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 296f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Describes how to convert/move a vertex attribute from a vertex array 297f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to a vertex structure. 298f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 299f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_clipspace_attr 300f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 301f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint attrib; /* which vertex attrib (0=position, etc) */ 302f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint format; 303f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint vertoffset; /* position of the attrib in the vertex struct */ 304f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint vertattrsize; /* size of the attribute in bytes */ 305f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte *inputptr; 306f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint inputstride; 307f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint inputsize; 308f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const tnl_insert_func *insert; 309f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_insert_func emit; 310f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_extract_func extract; 311f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org const GLfloat *vp; /* NDC->Viewport mapping matrix */ 312f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 313f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 314f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 315f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 316f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 317f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_points_func)( struct gl_context *ctx, GLuint first, GLuint last ); 318f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_line_func)( struct gl_context *ctx, GLuint v1, GLuint v2 ); 319f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_triangle_func)( struct gl_context *ctx, 320f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint v1, GLuint v2, GLuint v3 ); 321f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_quad_func)( struct gl_context *ctx, GLuint v1, GLuint v2, 322f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint v3, GLuint v4 ); 323f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_render_func)( struct gl_context *ctx, GLuint start, GLuint count, 324f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint flags ); 325f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_interp_func)( struct gl_context *ctx, 326f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat t, GLuint dst, GLuint out, GLuint in, 327f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean force_boundary ); 328f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_copy_pv_func)( struct gl_context *ctx, GLuint dst, GLuint src ); 329f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef void (*tnl_setup_func)( struct gl_context *ctx, 330f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint start, GLuint end, 331f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint new_inputs); 332f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 333f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 334f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_attr_type { 335f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint format; 336f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint size; 337f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint stride; 338f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint offset; 339f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 340f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 341f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_clipspace_fastpath { 342f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint vertex_size; 343f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint attr_count; 344f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean match_strides; 345f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 346f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_attr_type *attr; 347f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 348f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_emit_func func; 349f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_clipspace_fastpath *next; 350f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 351f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 352f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 353f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Used to describe conversion of vertex arrays to vertex structures. 354f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * I.e. Structure of arrays to arrays of structs. 355f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 356f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_clipspace 357f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 358f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean need_extras; 359f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 360f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint new_inputs; 361f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 362f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte *vertex_buf; 363f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint vertex_size; 364f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint max_vertex_size; 365f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 366f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX]; 367f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint attr_count; 368f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 369f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_emit_func emit; 370f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_interp_func interp; 371f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_copy_pv_func copy_pv; 372f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 373f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Parameters and constants for codegen: 374f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 375f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean need_viewport; 376f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat vp_scale[4]; 377f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat vp_xlate[4]; 378f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat chan_scale[4]; 379f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat identity[4]; 380f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 381f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_clipspace_fastpath *fastpath; 382f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 383f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*codegen_emit)( struct gl_context *ctx ); 384f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 385f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 386f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 387f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */ 388f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 389f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 390f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Material shininess lookup table. 391f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 392f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_shine_tab 393f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 394f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_shine_tab *next, *prev; 395f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat tab[SHINE_TABLE_SIZE+1]; 396f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLfloat shininess; 397f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint refcount; 398f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 399f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 400f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 401f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgstruct tnl_device_driver 402f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 403f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /*** 404f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *** TNL Pipeline 405f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ***/ 406f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 407f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*RunPipeline)(struct gl_context *ctx); 408f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Replaces PipelineStart/PipelineFinish -- intended to allow 409f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * drivers to wrap _tnl_run_pipeline() with code to validate state 410f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * and grab/release hardware locks. 411f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 412f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 413f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*NotifyMaterialChange)(struct gl_context *ctx); 414f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Alert tnl-aware drivers of changes to material. 415f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 416f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 417f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /*** 418f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org *** Rendering -- These functions called only from t_vb_render.c 419f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org ***/ 420f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct 421f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org { 422f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*Start)(struct gl_context *ctx); 423f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*Finish)(struct gl_context *ctx); 424f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Called before and after all rendering operations, including DrawPixels, 425f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands. 426f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * These are a suitable place for grabbing/releasing hardware locks. 427f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 428f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 429f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*PrimitiveNotify)(struct gl_context *ctx, GLenum mode); 430f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Called between RenderStart() and RenderFinish() to indicate the 431f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * type of primitive we're about to draw. Mode will be one of the 432f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * modes accepted by glBegin(). 433f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 434f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 435f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_interp_func Interp; 436f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The interp function is called by the clipping routines when we need 437f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * to generate an interpolated vertex. All pertinant vertex ancilliary 438f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * data should be computed by interpolating between the 'in' and 'out' 439f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * vertices. 440f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 441f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 442f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_copy_pv_func CopyPV; 443f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* The copy function is used to make a copy of a vertex. All pertinant 444f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * vertex attributes should be copied. 445f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 446f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 447f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*ClippedPolygon)( struct gl_context *ctx, const GLuint *elts, GLuint n ); 448f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Render a polygon with <n> vertices whose indexes are in the <elts> 449f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * array. 450f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 451f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 452f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*ClippedLine)( struct gl_context *ctx, GLuint v0, GLuint v1 ); 453f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Render a line between the two vertices given by indexes v0 and v1. */ 454f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 455f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_points_func Points; /* must now respect vb->elts */ 456f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_line_func Line; 457f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_triangle_func Triangle; 458f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_quad_func Quad; 459f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* These functions are called in order to render points, lines, 460f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * triangles and quads. These are only called via the T&L module. 461f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 462f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 463f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_render_func *PrimTabVerts; 464f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_render_func *PrimTabElts; 465f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Render whole unclipped primitives (points, lines, linestrips, 466f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * lineloops, etc). The tables are indexed by the GL enum of the 467f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * primitive to be rendered. RenderTabVerts is used for non-indexed 468f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * arrays of vertices. RenderTabElts is used for indexed arrays of 469f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * vertices. 470f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 471f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 472f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org void (*ResetLineStipple)( struct gl_context *ctx ); 473f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Reset the hardware's line stipple counter. 474f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 475f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 476f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org tnl_setup_func BuildVertices; 477f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* This function is called whenever new vertices are required for 478f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * rendering. The vertices in question are those n such that start 479f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * <= n < end. The new_inputs parameter indicates those fields of 480f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the vertex which need to be updated, if only a partial repair of 481f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * the vertex is required. 482f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 483f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This function is called only from _tnl_render_stage in tnl/t_render.c. 484f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 485f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 486f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 487f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean (*Multipass)( struct gl_context *ctx, GLuint passno ); 488f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Driver may request additional render passes by returning GL_TRUE 489f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * when this function is called. This function will be called 490f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * after the first pass, and passes will be made until the function 491f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * returns GL_FALSE. If no function is registered, only one pass 492f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * is made. 493f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * 494f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * This function will be first invoked with passno == 1. 495f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 496f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org } Render; 497f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org}; 498f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 499f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 500f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org/** 501f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org * Context state for T&L context. 502f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 503f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtypedef struct 504f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org{ 505f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Driver interface. 506f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 507f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_device_driver Driver; 508f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 509f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Pipeline 510f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 511f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_pipeline pipeline; 512f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct vertex_buffer vb; 513f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 514f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Clipspace/ndc/window vertex managment: 515f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 516f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_clipspace clipspace; 517f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 518f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Probably need a better configuration mechanism: 519f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 520f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean NeedNdcCoords; 521f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean AllowVertexFog; 522f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean AllowPixelFog; 523f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLboolean _DoVertexFog; /* eval fog function at each vertex? */ 524f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 525f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLbitfield64 render_inputs_bitset; 526f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 527f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLvector4f tmp_inputs[VERT_ATTRIB_MAX]; 528f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 529f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /* Temp storage for t_draw.c: 530f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org */ 531f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLubyte *block[VERT_ATTRIB_MAX]; 532f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint nr_blocks; 533f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 534f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org GLuint CurInstance; 535f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 536f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_shine_tab *_ShineTable[2]; /**< Active shine tables */ 537f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org struct tnl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */ 538f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org /**@}*/ 539f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org} TNLcontext; 540f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 541f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 542f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 543f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context)) 544f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 545f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 546f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define TYPE_IDX(t) ((t) & 0xf) 547f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ 548f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 549f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 550f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgextern void 551f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.orgtnl_clip_prepare(struct gl_context *ctx); 552f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 553f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org 554f2ba7591b1407a7ee9209f842c50696914dc2dedkbr@chromium.org#endif 555