r200_context.h revision fc606f7db9072d4f40081aea8f92f1d4489a5115
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */ 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)The Weather Channel (TM) funded Tungsten Graphics to develop the 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)initial release of the Radeon 8500 driver under the XFree86 license. 7424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)This notice must be preserved. 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)Permission is hereby granted, free of charge, to any person obtaining 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)a copy of this software and associated documentation files (the 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)"Software"), to deal in the Software without restriction, including 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)without limitation the rights to use, copy, modify, merge, publish, 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)distribute, sublicense, and/or sell copies of the Software, and to 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)permit persons to whom the Software is furnished to do so, subject to 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)the following conditions: 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)The above copyright notice and this permission notice (including the 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)next paragraph) shall be included in all copies or substantial 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)portions of the Software. 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 252385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen MurdochLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 262385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen MurdochOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 272385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen MurdochWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 292385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch**************************************************************************/ 302385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch 31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)/* 32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) * Authors: 332385ea399aae016c0806a4f9ef3c9cfe3d2a39dfBen Murdoch * Keith Whitwell <keith@tungstengraphics.com> 347d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) */ 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef __R200_CONTEXT_H__ 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define __R200_CONTEXT_H__ 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "tnl/t_vertex.h" 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "drm.h" 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "radeon_drm.h" 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "dri_util.h" 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "texmem.h" 447d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "macros.h" 46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "mtypes.h" 472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "colormac.h" 482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "r200_reg.h" 492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "r200_vertprog.h" 507d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */ 52424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#ifndef R200_EMIT_VAP_PVS_CNTL 542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#error This driver requires a newer libdrm to compile 552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 56424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct r200_context; 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct r200_context r200ContextRec; 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct r200_context *r200ContextPtr; 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* This union is used to avoid warnings/miscompilation 622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) with float to uint32_t casts due to strict-aliasing */ 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)typedef union { GLfloat f; uint32_t ui32; } float_ui32_type; 642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "r200_lock.h" 662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "radeon_screen.h" 675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "mm.h" 685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Flags for software fallback cases */ 702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* See correponding strings in r200_swtcl.c */ 715821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define R200_FALLBACK_TEXTURE 0x01 725821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define R200_FALLBACK_DRAW_BUFFER 0x02 735821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define R200_FALLBACK_STENCIL 0x04 745821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define R200_FALLBACK_RENDER_MODE 0x08 755821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define R200_FALLBACK_DISABLE 0x10 765821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define R200_FALLBACK_BORDER_MODE 0x20 775821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 785821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* The blit width for texture uploads 795821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 802a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define BLIT_WIDTH_BYTES 1024 815821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 825821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)/* Use the templated vertex format: 835821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */ 845821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define COLOR_IS_RGBA 855821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TAG(x) r200##x 865821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "tnl_dd/t_dd_vertex.h" 872a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#undef TAG 882a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 895821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef void (*r200_tri_func)( r200ContextPtr, 905821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) r200Vertex *, 915821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) r200Vertex *, 925821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) r200Vertex * ); 935821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 942a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)typedef void (*r200_line_func)( r200ContextPtr, 952a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) r200Vertex *, 965821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) r200Vertex * ); 975821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 985821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef void (*r200_point_func)( r200ContextPtr, 992a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) r200Vertex * ); 1002a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1012a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1022a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct r200_vertex_program { 1037d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) struct gl_vertex_program mesa_program; /* Must be first */ 1047d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) int translated; 1057d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) /* need excess instr: 1 for late loop checking, 2 for 1067d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) additional instr due to instr/attr, 3 for fog */ 1072a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) VERTEX_SHADER_INSTRUCTION instr[R200_VSF_MAX_INST + 6]; 1082a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int pos_end; 1092a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int inputs[VERT_ATTRIB_MAX]; 1105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) int native; 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int fogpidx; 1122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int fogmode; 1132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct r200_colorbuffer_state { 1162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GLuint clear; 1172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if 000 1182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GLint drawOffset, drawPitch; 1192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 1202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) int roundEnable; 1212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)struct r200_depthbuffer_state { 1252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GLuint clear; 1262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) GLfloat scale; 1272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#if 000 1305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct r200_pixel_state { 1315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLint readOffset, readPitch; 1322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif 1342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct r200_scissor_state { 1365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) drm_clip_rect_t rect; 1375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLboolean enabled; 1382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLuint numClipRects; /* Cliprects active */ 1405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLuint numAllocedClipRects; /* Cliprects available */ 1415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) drm_clip_rect_t *pClipRects; 1425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct r200_stencilbuffer_state { 1455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLboolean hwBuffer; 1465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLuint clear; /* rb3d_stencilrefmask value */ 1475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct r200_stipple_state { 1505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) GLuint mask[32]; 1515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 1525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_0 0x1 1565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_1 0x2 1575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_2 0x4 1585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_3 0x8 1595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_4 0x10 1605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_5 0x20 1615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define TEX_ALL 0x3f 1625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 1635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr; 164 165/* Texture object in locally shared texture space. 166 */ 167struct r200_tex_obj { 168 driTextureObject base; 169 170 GLuint bufAddr; /* Offset to start of locally 171 shared texture block */ 172 173 GLuint dirty_state; /* Flags (1 per texunit) for 174 whether or not this texobj 175 has dirty hardware state 176 (pp_*) that needs to be 177 brought into the 178 texunit. */ 179 180 drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS]; 181 /* Six, for the cube faces */ 182 183 GLuint pp_txfilter; /* hardware register values */ 184 GLuint pp_txformat; 185 GLuint pp_txformat_x; 186 GLuint pp_txoffset; /* Image location in texmem. 187 All cube faces follow. */ 188 GLuint pp_txsize; /* npot only */ 189 GLuint pp_txpitch; /* npot only */ 190 GLuint pp_border_color; 191 GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */ 192 193 GLboolean border_fallback; 194 195 GLuint tile_bits; /* hw texture tile bits used on this texture */ 196}; 197 198 199struct r200_texture_env_state { 200 r200TexObjPtr texobj; 201 GLuint outputreg; 202 GLuint unitneeded; 203}; 204 205#define R200_MAX_TEXTURE_UNITS 6 206 207struct r200_texture_state { 208 struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS]; 209}; 210 211 212struct r200_state_atom { 213 struct r200_state_atom *next, *prev; 214 const char *name; /* for debug */ 215 int cmd_size; /* size in bytes */ 216 GLuint idx; 217 int *cmd; /* one or more cmd's */ 218 int *lastcmd; /* one or more cmd's */ 219 GLboolean dirty; 220 GLboolean (*check)( GLcontext *, int ); /* is this state active? */ 221}; 222 223 224 225/* Trying to keep these relatively short as the variables are becoming 226 * extravagently long. Drop the driver name prefix off the front of 227 * everything - I think we know which driver we're in by now, and keep the 228 * prefix to 3 letters unless absolutely impossible. 229 */ 230 231#define CTX_CMD_0 0 232#define CTX_PP_MISC 1 233#define CTX_PP_FOG_COLOR 2 234#define CTX_RE_SOLID_COLOR 3 235#define CTX_RB3D_BLENDCNTL 4 236#define CTX_RB3D_DEPTHOFFSET 5 237#define CTX_RB3D_DEPTHPITCH 6 238#define CTX_RB3D_ZSTENCILCNTL 7 239#define CTX_CMD_1 8 240#define CTX_PP_CNTL 9 241#define CTX_RB3D_CNTL 10 242#define CTX_RB3D_COLOROFFSET 11 243#define CTX_CMD_2 12 /* why */ 244#define CTX_RB3D_COLORPITCH 13 /* why */ 245#define CTX_STATE_SIZE_OLDDRM 14 246#define CTX_CMD_3 14 247#define CTX_RB3D_BLENDCOLOR 15 248#define CTX_RB3D_ABLENDCNTL 16 249#define CTX_RB3D_CBLENDCNTL 17 250#define CTX_STATE_SIZE_NEWDRM 18 251 252#define SET_CMD_0 0 253#define SET_SE_CNTL 1 254#define SET_RE_CNTL 2 /* replace se_coord_fmt */ 255#define SET_STATE_SIZE 3 256 257#define VTE_CMD_0 0 258#define VTE_SE_VTE_CNTL 1 259#define VTE_STATE_SIZE 2 260 261#define LIN_CMD_0 0 262#define LIN_RE_LINE_PATTERN 1 263#define LIN_RE_LINE_STATE 2 264#define LIN_CMD_1 3 265#define LIN_SE_LINE_WIDTH 4 266#define LIN_STATE_SIZE 5 267 268#define MSK_CMD_0 0 269#define MSK_RB3D_STENCILREFMASK 1 270#define MSK_RB3D_ROPCNTL 2 271#define MSK_RB3D_PLANEMASK 3 272#define MSK_STATE_SIZE 4 273 274#define VPT_CMD_0 0 275#define VPT_SE_VPORT_XSCALE 1 276#define VPT_SE_VPORT_XOFFSET 2 277#define VPT_SE_VPORT_YSCALE 3 278#define VPT_SE_VPORT_YOFFSET 4 279#define VPT_SE_VPORT_ZSCALE 5 280#define VPT_SE_VPORT_ZOFFSET 6 281#define VPT_STATE_SIZE 7 282 283#define ZBS_CMD_0 0 284#define ZBS_SE_ZBIAS_FACTOR 1 285#define ZBS_SE_ZBIAS_CONSTANT 2 286#define ZBS_STATE_SIZE 3 287 288#define MSC_CMD_0 0 289#define MSC_RE_MISC 1 290#define MSC_STATE_SIZE 2 291 292#define TAM_CMD_0 0 293#define TAM_DEBUG3 1 294#define TAM_STATE_SIZE 2 295 296#define TEX_CMD_0 0 297#define TEX_PP_TXFILTER 1 /*2c00*/ 298#define TEX_PP_TXFORMAT 2 /*2c04*/ 299#define TEX_PP_TXFORMAT_X 3 /*2c08*/ 300#define TEX_PP_TXSIZE 4 /*2c0c*/ 301#define TEX_PP_TXPITCH 5 /*2c10*/ 302#define TEX_PP_BORDER_COLOR 6 /*2c14*/ 303#define TEX_CMD_1_OLDDRM 7 304#define TEX_PP_TXOFFSET_OLDDRM 8 /*2d00 */ 305#define TEX_STATE_SIZE_OLDDRM 9 306#define TEX_PP_CUBIC_FACES 7 307#define TEX_PP_TXMULTI_CTL 8 308#define TEX_CMD_1_NEWDRM 9 309#define TEX_PP_TXOFFSET_NEWDRM 10 310#define TEX_STATE_SIZE_NEWDRM 11 311 312#define CUBE_CMD_0 0 /* 1 register follows */ /* this command unnecessary */ 313#define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */ /* with new enough drm */ 314#define CUBE_CMD_1 2 /* 5 registers follow */ 315#define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */ 316#define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */ 317#define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */ 318#define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */ 319#define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */ 320#define CUBE_STATE_SIZE 8 321 322#define PIX_CMD_0 0 323#define PIX_PP_TXCBLEND 1 324#define PIX_PP_TXCBLEND2 2 325#define PIX_PP_TXABLEND 3 326#define PIX_PP_TXABLEND2 4 327#define PIX_STATE_SIZE 5 328 329#define TF_CMD_0 0 330#define TF_TFACTOR_0 1 331#define TF_TFACTOR_1 2 332#define TF_TFACTOR_2 3 333#define TF_TFACTOR_3 4 334#define TF_TFACTOR_4 5 335#define TF_TFACTOR_5 6 336#define TF_STATE_SIZE 7 337 338#define ATF_CMD_0 0 339#define ATF_TFACTOR_0 1 340#define ATF_TFACTOR_1 2 341#define ATF_TFACTOR_2 3 342#define ATF_TFACTOR_3 4 343#define ATF_TFACTOR_4 5 344#define ATF_TFACTOR_5 6 345#define ATF_TFACTOR_6 7 346#define ATF_TFACTOR_7 8 347#define ATF_STATE_SIZE 9 348 349/* ATI_FRAGMENT_SHADER */ 350#define AFS_CMD_0 0 351#define AFS_IC0 1 /* 2f00 */ 352#define AFS_IC1 2 /* 2f04 */ 353#define AFS_IA0 3 /* 2f08 */ 354#define AFS_IA1 4 /* 2f0c */ 355#define AFS_STATE_SIZE 33 356 357#define PVS_CMD_0 0 358#define PVS_CNTL_1 1 359#define PVS_CNTL_2 2 360#define PVS_STATE_SIZE 3 361 362/* those are quite big... */ 363#define VPI_CMD_0 0 364#define VPI_OPDST_0 1 365#define VPI_SRC0_0 2 366#define VPI_SRC1_0 3 367#define VPI_SRC2_0 4 368#define VPI_OPDST_63 253 369#define VPI_SRC0_63 254 370#define VPI_SRC1_63 255 371#define VPI_SRC2_63 256 372#define VPI_STATE_SIZE 257 373 374#define VPP_CMD_0 0 375#define VPP_PARAM0_0 1 376#define VPP_PARAM1_0 2 377#define VPP_PARAM2_0 3 378#define VPP_PARAM3_0 4 379#define VPP_PARAM0_95 381 380#define VPP_PARAM1_95 382 381#define VPP_PARAM2_95 383 382#define VPP_PARAM3_95 384 383#define VPP_STATE_SIZE 385 384 385#define TCL_CMD_0 0 386#define TCL_LIGHT_MODEL_CTL_0 1 387#define TCL_LIGHT_MODEL_CTL_1 2 388#define TCL_PER_LIGHT_CTL_0 3 389#define TCL_PER_LIGHT_CTL_1 4 390#define TCL_PER_LIGHT_CTL_2 5 391#define TCL_PER_LIGHT_CTL_3 6 392#define TCL_CMD_1 7 393#define TCL_UCP_VERT_BLEND_CTL 8 394#define TCL_STATE_SIZE 9 395 396#define MSL_CMD_0 0 397#define MSL_MATRIX_SELECT_0 1 398#define MSL_MATRIX_SELECT_1 2 399#define MSL_MATRIX_SELECT_2 3 400#define MSL_MATRIX_SELECT_3 4 401#define MSL_MATRIX_SELECT_4 5 402#define MSL_STATE_SIZE 6 403 404#define TCG_CMD_0 0 405#define TCG_TEX_PROC_CTL_2 1 406#define TCG_TEX_PROC_CTL_3 2 407#define TCG_TEX_PROC_CTL_0 3 408#define TCG_TEX_PROC_CTL_1 4 409#define TCG_TEX_CYL_WRAP_CTL 5 410#define TCG_STATE_SIZE 6 411 412#define MTL_CMD_0 0 413#define MTL_EMMISSIVE_RED 1 414#define MTL_EMMISSIVE_GREEN 2 415#define MTL_EMMISSIVE_BLUE 3 416#define MTL_EMMISSIVE_ALPHA 4 417#define MTL_AMBIENT_RED 5 418#define MTL_AMBIENT_GREEN 6 419#define MTL_AMBIENT_BLUE 7 420#define MTL_AMBIENT_ALPHA 8 421#define MTL_DIFFUSE_RED 9 422#define MTL_DIFFUSE_GREEN 10 423#define MTL_DIFFUSE_BLUE 11 424#define MTL_DIFFUSE_ALPHA 12 425#define MTL_SPECULAR_RED 13 426#define MTL_SPECULAR_GREEN 14 427#define MTL_SPECULAR_BLUE 15 428#define MTL_SPECULAR_ALPHA 16 429#define MTL_CMD_1 17 430#define MTL_SHININESS 18 431#define MTL_STATE_SIZE 19 432 433#define VAP_CMD_0 0 434#define VAP_SE_VAP_CNTL 1 435#define VAP_STATE_SIZE 2 436 437/* Replaces a lot of packet info from radeon 438 */ 439#define VTX_CMD_0 0 440#define VTX_VTXFMT_0 1 441#define VTX_VTXFMT_1 2 442#define VTX_TCL_OUTPUT_VTXFMT_0 3 443#define VTX_TCL_OUTPUT_VTXFMT_1 4 444#define VTX_CMD_1 5 445#define VTX_TCL_OUTPUT_COMPSEL 6 446#define VTX_CMD_2 7 447#define VTX_STATE_CNTL 8 448#define VTX_STATE_SIZE 9 449 450/* SPR - point sprite state 451 */ 452#define SPR_CMD_0 0 453#define SPR_POINT_SPRITE_CNTL 1 454#define SPR_STATE_SIZE 2 455 456#define PTP_CMD_0 0 457#define PTP_VPORT_SCALE_0 1 458#define PTP_VPORT_SCALE_1 2 459#define PTP_VPORT_SCALE_PTSIZE 3 460#define PTP_VPORT_SCALE_3 4 461#define PTP_CMD_1 5 462#define PTP_ATT_CONST_QUAD 6 463#define PTP_ATT_CONST_LIN 7 464#define PTP_ATT_CONST_CON 8 465#define PTP_ATT_CONST_3 9 466#define PTP_EYE_X 10 467#define PTP_EYE_Y 11 468#define PTP_EYE_Z 12 469#define PTP_EYE_3 13 470#define PTP_CLAMP_MIN 14 471#define PTP_CLAMP_MAX 15 472#define PTP_CLAMP_2 16 473#define PTP_CLAMP_3 17 474#define PTP_STATE_SIZE 18 475 476#define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\ 477 R200_VTX_COLOR_MASK) 478 479/** 480 * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine 481 * how many components are in texture coordinate \c n. 482 */ 483#define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07) 484 485#define MAT_CMD_0 0 486#define MAT_ELT_0 1 487#define MAT_STATE_SIZE 17 488 489#define GRD_CMD_0 0 490#define GRD_VERT_GUARD_CLIP_ADJ 1 491#define GRD_VERT_GUARD_DISCARD_ADJ 2 492#define GRD_HORZ_GUARD_CLIP_ADJ 3 493#define GRD_HORZ_GUARD_DISCARD_ADJ 4 494#define GRD_STATE_SIZE 5 495 496/* position changes frequently when lighting in modelpos - separate 497 * out to new state item? 498 */ 499#define LIT_CMD_0 0 500#define LIT_AMBIENT_RED 1 501#define LIT_AMBIENT_GREEN 2 502#define LIT_AMBIENT_BLUE 3 503#define LIT_AMBIENT_ALPHA 4 504#define LIT_DIFFUSE_RED 5 505#define LIT_DIFFUSE_GREEN 6 506#define LIT_DIFFUSE_BLUE 7 507#define LIT_DIFFUSE_ALPHA 8 508#define LIT_SPECULAR_RED 9 509#define LIT_SPECULAR_GREEN 10 510#define LIT_SPECULAR_BLUE 11 511#define LIT_SPECULAR_ALPHA 12 512#define LIT_POSITION_X 13 513#define LIT_POSITION_Y 14 514#define LIT_POSITION_Z 15 515#define LIT_POSITION_W 16 516#define LIT_DIRECTION_X 17 517#define LIT_DIRECTION_Y 18 518#define LIT_DIRECTION_Z 19 519#define LIT_DIRECTION_W 20 520#define LIT_ATTEN_QUADRATIC 21 521#define LIT_ATTEN_LINEAR 22 522#define LIT_ATTEN_CONST 23 523#define LIT_ATTEN_XXX 24 524#define LIT_CMD_1 25 525#define LIT_SPOT_DCD 26 526#define LIT_SPOT_DCM 27 527#define LIT_SPOT_EXPONENT 28 528#define LIT_SPOT_CUTOFF 29 529#define LIT_SPECULAR_THRESH 30 530#define LIT_RANGE_CUTOFF 31 /* ? */ 531#define LIT_ATTEN_CONST_INV 32 532#define LIT_STATE_SIZE 33 533 534/* Fog 535 */ 536#define FOG_CMD_0 0 537#define FOG_R 1 538#define FOG_C 2 539#define FOG_D 3 540#define FOG_PAD 4 541#define FOG_STATE_SIZE 5 542 543/* UCP 544 */ 545#define UCP_CMD_0 0 546#define UCP_X 1 547#define UCP_Y 2 548#define UCP_Z 3 549#define UCP_W 4 550#define UCP_STATE_SIZE 5 551 552/* GLT - Global ambient 553 */ 554#define GLT_CMD_0 0 555#define GLT_RED 1 556#define GLT_GREEN 2 557#define GLT_BLUE 3 558#define GLT_ALPHA 4 559#define GLT_STATE_SIZE 5 560 561/* EYE 562 */ 563#define EYE_CMD_0 0 564#define EYE_X 1 565#define EYE_Y 2 566#define EYE_Z 3 567#define EYE_RESCALE_FACTOR 4 568#define EYE_STATE_SIZE 5 569 570/* CST - constant state 571 */ 572#define CST_CMD_0 0 573#define CST_PP_CNTL_X 1 574#define CST_CMD_1 2 575#define CST_RB3D_DEPTHXY_OFFSET 3 576#define CST_CMD_2 4 577#define CST_RE_AUX_SCISSOR_CNTL 5 578#define CST_CMD_3 6 579#define CST_RE_SCISSOR_TL_0 7 580#define CST_RE_SCISSOR_BR_0 8 581#define CST_CMD_4 9 582#define CST_SE_VAP_CNTL_STATUS 10 583#define CST_CMD_5 11 584#define CST_RE_POINTSIZE 12 585#define CST_CMD_6 13 586#define CST_SE_TCL_INPUT_VTX_0 14 587#define CST_SE_TCL_INPUT_VTX_1 15 588#define CST_SE_TCL_INPUT_VTX_2 16 589#define CST_SE_TCL_INPUT_VTX_3 17 590#define CST_STATE_SIZE 18 591 592#define PRF_CMD_0 0 593#define PRF_PP_TRI_PERF 1 594#define PRF_PP_PERF_CNTL 2 595#define PRF_STATE_SIZE 3 596 597 598struct r200_hw_state { 599 /* Head of the linked list of state atoms. */ 600 struct r200_state_atom atomlist; 601 602 /* Hardware state, stored as cmdbuf commands: 603 * -- Need to doublebuffer for 604 * - reviving state after loss of context 605 * - eliding noop statechange loops? (except line stipple count) 606 */ 607 struct r200_state_atom ctx; 608 struct r200_state_atom set; 609 struct r200_state_atom vte; 610 struct r200_state_atom lin; 611 struct r200_state_atom msk; 612 struct r200_state_atom vpt; 613 struct r200_state_atom vap; 614 struct r200_state_atom vtx; 615 struct r200_state_atom tcl; 616 struct r200_state_atom msl; 617 struct r200_state_atom tcg; 618 struct r200_state_atom msc; 619 struct r200_state_atom cst; 620 struct r200_state_atom tam; 621 struct r200_state_atom tf; 622 struct r200_state_atom tex[6]; 623 struct r200_state_atom cube[6]; 624 struct r200_state_atom zbs; 625 struct r200_state_atom mtl[2]; 626 struct r200_state_atom mat[9]; 627 struct r200_state_atom lit[8]; /* includes vec, scl commands */ 628 struct r200_state_atom ucp[6]; 629 struct r200_state_atom pix[6]; /* pixshader stages */ 630 struct r200_state_atom eye; /* eye pos */ 631 struct r200_state_atom grd; /* guard band clipping */ 632 struct r200_state_atom fog; 633 struct r200_state_atom glt; 634 struct r200_state_atom prf; 635 struct r200_state_atom afs[2]; 636 struct r200_state_atom pvs; 637 struct r200_state_atom vpi[2]; 638 struct r200_state_atom vpp[2]; 639 struct r200_state_atom atf; 640 struct r200_state_atom spr; 641 struct r200_state_atom ptp; 642 643 int max_state_size; /* Number of bytes necessary for a full state emit. */ 644 GLboolean is_dirty, all_dirty; 645}; 646 647struct r200_state { 648 /* Derived state for internal purposes: 649 */ 650 struct r200_colorbuffer_state color; 651 struct r200_depthbuffer_state depth; 652#if 00 653 struct r200_pixel_state pixel; 654#endif 655 struct r200_scissor_state scissor; 656 struct r200_stencilbuffer_state stencil; 657 struct r200_stipple_state stipple; 658 struct r200_texture_state texture; 659 GLuint envneeded; 660}; 661 662/* Need refcounting on dma buffers: 663 */ 664struct r200_dma_buffer { 665 int refcount; /* the number of retained regions in buf */ 666 drmBufPtr buf; 667}; 668 669#define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \ 670 (rvb)->address - rmesa->dma.buf0_address + \ 671 (rvb)->start) 672 673/* A retained region, eg vertices for indexed vertices. 674 */ 675struct r200_dma_region { 676 struct r200_dma_buffer *buf; 677 char *address; /* == buf->address */ 678 int start, end, ptr; /* offsets from start of buf */ 679 int aos_start; 680 int aos_stride; 681 int aos_size; 682}; 683 684 685struct r200_dma { 686 /* Active dma region. Allocations for vertices and retained 687 * regions come from here. Also used for emitting random vertices, 688 * these may be flushed by calling flush_current(); 689 */ 690 struct r200_dma_region current; 691 692 void (*flush)( r200ContextPtr ); 693 694 char *buf0_address; /* start of buf[0], for index calcs */ 695 GLuint nr_released_bufs; /* flush after so many buffers released */ 696}; 697 698struct r200_dri_mirror { 699 __DRIcontextPrivate *context; /* DRI context */ 700 __DRIscreenPrivate *screen; /* DRI screen */ 701 __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */ 702 703 drm_context_t hwContext; 704 drm_hw_lock_t *hwLock; 705 int fd; 706 int drmMinor; 707}; 708 709 710#define R200_CMD_BUF_SZ (16*1024) 711 712struct r200_store { 713 GLuint statenr; 714 GLuint primnr; 715 char cmd_buf[R200_CMD_BUF_SZ]; 716 int cmd_used; 717 int elts_start; 718}; 719 720 721/* r200_tcl.c 722 */ 723struct r200_tcl_info { 724 GLuint vertex_format; 725 GLint last_offset; 726 GLuint hw_primitive; 727 728/* FIXME: what's the maximum number of components? */ 729 struct r200_dma_region *aos_components[11]; 730 GLuint nr_aos_components; 731 732 GLuint *Elts; 733 734 struct r200_dma_region indexed_verts; 735 struct r200_dma_region obj; 736 struct r200_dma_region rgba; 737 struct r200_dma_region spec; 738 struct r200_dma_region fog; 739 struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS]; 740 struct r200_dma_region norm; 741}; 742 743 744/* r200_swtcl.c 745 */ 746struct r200_swtcl_info { 747 GLuint RenderIndex; 748 749 /** 750 * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is 751 * installed in the Mesa state vector. 752 */ 753 GLuint vertex_size; 754 755 /** 756 * Attributes instructing the Mesa TCL pipeline where / how to put vertex 757 * data in the hardware buffer. 758 */ 759 struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX]; 760 761 /** 762 * Number of elements of \c ::vertex_attrs that are actually used. 763 */ 764 GLuint vertex_attr_count; 765 766 /** 767 * Cached pointer to the buffer where Mesa will store vertex data. 768 */ 769 GLubyte *verts; 770 771 /* Fallback rasterization functions 772 */ 773 r200_point_func draw_point; 774 r200_line_func draw_line; 775 r200_tri_func draw_tri; 776 777 GLuint hw_primitive; 778 GLenum render_primitive; 779 GLuint numverts; 780 781 /** 782 * Offset of the 4UB color data within a hardware (swtcl) vertex. 783 */ 784 GLuint coloroffset; 785 786 /** 787 * Offset of the 3UB specular color data within a hardware (swtcl) vertex. 788 */ 789 GLuint specoffset; 790 791 /** 792 * Should Mesa project vertex data or will the hardware do it? 793 */ 794 GLboolean needproj; 795 796 struct r200_dma_region indexed_verts; 797}; 798 799 800struct r200_ioctl { 801 GLuint vertex_offset; 802 GLuint vertex_size; 803}; 804 805 806 807#define R200_MAX_PRIMS 64 808 809 810/* Want to keep a cache of these around. Each is parameterized by 811 * only a single value which has only a small range. Only expect a 812 * few, so just rescan the list each time? 813 */ 814struct dynfn { 815 struct dynfn *next, *prev; 816 int key[2]; 817 char *code; 818}; 819 820struct dfn_lists { 821 struct dynfn Vertex2f; 822 struct dynfn Vertex2fv; 823 struct dynfn Vertex3f; 824 struct dynfn Vertex3fv; 825 struct dynfn Color4ub; 826 struct dynfn Color4ubv; 827 struct dynfn Color3ub; 828 struct dynfn Color3ubv; 829 struct dynfn Color4f; 830 struct dynfn Color4fv; 831 struct dynfn Color3f; 832 struct dynfn Color3fv; 833 struct dynfn SecondaryColor3ubEXT; 834 struct dynfn SecondaryColor3ubvEXT; 835 struct dynfn SecondaryColor3fEXT; 836 struct dynfn SecondaryColor3fvEXT; 837 struct dynfn Normal3f; 838 struct dynfn Normal3fv; 839 struct dynfn TexCoord3f; 840 struct dynfn TexCoord3fv; 841 struct dynfn TexCoord2f; 842 struct dynfn TexCoord2fv; 843 struct dynfn TexCoord1f; 844 struct dynfn TexCoord1fv; 845 struct dynfn MultiTexCoord3fARB; 846 struct dynfn MultiTexCoord3fvARB; 847 struct dynfn MultiTexCoord2fARB; 848 struct dynfn MultiTexCoord2fvARB; 849 struct dynfn MultiTexCoord1fARB; 850 struct dynfn MultiTexCoord1fvARB; 851 struct dynfn FogCoordfEXT; 852 struct dynfn FogCoordfvEXT; 853}; 854 855struct dfn_generators { 856 struct dynfn *(*Vertex2f)( GLcontext *, const int * ); 857 struct dynfn *(*Vertex2fv)( GLcontext *, const int * ); 858 struct dynfn *(*Vertex3f)( GLcontext *, const int * ); 859 struct dynfn *(*Vertex3fv)( GLcontext *, const int * ); 860 struct dynfn *(*Color4ub)( GLcontext *, const int * ); 861 struct dynfn *(*Color4ubv)( GLcontext *, const int * ); 862 struct dynfn *(*Color3ub)( GLcontext *, const int * ); 863 struct dynfn *(*Color3ubv)( GLcontext *, const int * ); 864 struct dynfn *(*Color4f)( GLcontext *, const int * ); 865 struct dynfn *(*Color4fv)( GLcontext *, const int * ); 866 struct dynfn *(*Color3f)( GLcontext *, const int * ); 867 struct dynfn *(*Color3fv)( GLcontext *, const int * ); 868 struct dynfn *(*SecondaryColor3ubEXT)( GLcontext *, const int * ); 869 struct dynfn *(*SecondaryColor3ubvEXT)( GLcontext *, const int * ); 870 struct dynfn *(*SecondaryColor3fEXT)( GLcontext *, const int * ); 871 struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, const int * ); 872 struct dynfn *(*Normal3f)( GLcontext *, const int * ); 873 struct dynfn *(*Normal3fv)( GLcontext *, const int * ); 874 struct dynfn *(*TexCoord3f)( GLcontext *, const int * ); 875 struct dynfn *(*TexCoord3fv)( GLcontext *, const int * ); 876 struct dynfn *(*TexCoord2f)( GLcontext *, const int * ); 877 struct dynfn *(*TexCoord2fv)( GLcontext *, const int * ); 878 struct dynfn *(*TexCoord1f)( GLcontext *, const int * ); 879 struct dynfn *(*TexCoord1fv)( GLcontext *, const int * ); 880 struct dynfn *(*MultiTexCoord3fARB)( GLcontext *, const int * ); 881 struct dynfn *(*MultiTexCoord3fvARB)( GLcontext *, const int * ); 882 struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, const int * ); 883 struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, const int * ); 884 struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, const int * ); 885 struct dynfn *(*MultiTexCoord1fvARB)( GLcontext *, const int * ); 886 struct dynfn *(*FogCoordfEXT)( GLcontext *, const int * ); 887 struct dynfn *(*FogCoordfvEXT)( GLcontext *, const int * ); 888}; 889 890 891 892struct r200_prim { 893 GLuint start; 894 GLuint end; 895 GLuint prim; 896}; 897 898 /* A maximum total of 29 elements per vertex: 3 floats for position, 3 899 * floats for normal, 4 floats for color, 4 bytes for secondary color, 900 * 3 floats for each texture unit (18 floats total). 901 * 902 * we maybe need add. 4 to prevent segfault if someone specifies 903 * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: ) 904 * 905 * The position data is never actually stored here, so 3 elements could be 906 * trimmed out of the buffer. 907 */ 908 909#define R200_MAX_VERTEX_SIZE ((3*6)+11) 910 911struct r200_vbinfo { 912 GLint counter, initial_counter; 913 GLint *dmaptr; 914 void (*notify)( void ); 915 GLint vertex_size; 916 917 union { float f; int i; r200_color_t color; } vertex[R200_MAX_VERTEX_SIZE]; 918 919 GLfloat *normalptr; 920 GLfloat *floatcolorptr; 921 GLfloat *fogptr; 922 r200_color_t *colorptr; 923 GLfloat *floatspecptr; 924 r200_color_t *specptr; 925 GLfloat *texcoordptr[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */ 926 927 928 GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */ 929 GLuint primflags; 930 GLboolean enabled; /* *_NO_VTXFMT / *_NO_TCL env vars */ 931 GLboolean installed; 932 GLboolean fell_back; 933 GLboolean recheck; 934 GLint nrverts; 935 GLuint vtxfmt_0, vtxfmt_1; 936 937 GLuint installed_vertex_format; 938 GLuint installed_color_3f_sz; 939 940 struct r200_prim primlist[R200_MAX_PRIMS]; 941 int nrprims; 942 943 struct dfn_lists dfn_cache; 944 struct dfn_generators codegen; 945 GLvertexformat vtxfmt; 946}; 947 948 949struct r200_context { 950 GLcontext *glCtx; /* Mesa context */ 951 952 /* Driver and hardware state management 953 */ 954 struct r200_hw_state hw; 955 struct r200_state state; 956 struct r200_vertex_program *curr_vp_hw; 957 958 /* Texture object bookkeeping 959 */ 960 unsigned nr_heaps; 961 driTexHeap * texture_heaps[ RADEON_NR_TEX_HEAPS ]; 962 driTextureObject swapped; 963 int texture_depth; 964 float initialMaxAnisotropy; 965 966 /* Rasterization and vertex state: 967 */ 968 GLuint TclFallback; 969 GLuint Fallback; 970 GLuint NewGLState; 971 DECLARE_RENDERINPUTS(tnl_index_bitset); /* index of bits for last tnl_install_attrs */ 972 973 /* Vertex buffers 974 */ 975 struct r200_ioctl ioctl; 976 struct r200_dma dma; 977 struct r200_store store; 978 /* A full state emit as of the first state emit in the main store, in case 979 * the context is lost. 980 */ 981 struct r200_store backup_store; 982 983 /* Page flipping 984 */ 985 GLuint doPageFlip; 986 987 /* Busy waiting 988 */ 989 GLuint do_usleeps; 990 GLuint do_irqs; 991 GLuint irqsEmitted; 992 drm_radeon_irq_wait_t iw; 993 994 /* Clientdata textures; 995 */ 996 GLuint prefer_gart_client_texturing; 997 998 /* Drawable, cliprect and scissor information 999 */ 1000 GLuint numClipRects; /* Cliprects for the draw buffer */ 1001 drm_clip_rect_t *pClipRects; 1002 unsigned int lastStamp; 1003 GLboolean lost_context; 1004 GLboolean save_on_next_emit; 1005 radeonScreenPtr r200Screen; /* Screen private DRI data */ 1006 drm_radeon_sarea_t *sarea; /* Private SAREA data */ 1007 1008 /* TCL stuff 1009 */ 1010 GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS]; 1011 GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS]; 1012 GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS]; 1013 GLuint TexMatEnabled; 1014 GLuint TexMatCompSel; 1015 GLuint TexGenEnabled; 1016 GLuint TexGenCompSel; 1017 GLmatrix tmpmat; 1018 1019 /* VBI / buffer swap 1020 */ 1021 GLuint vbl_seq; 1022 GLuint vblank_flags; 1023 1024 int64_t swap_ust; 1025 int64_t swap_missed_ust; 1026 1027 GLuint swap_count; 1028 GLuint swap_missed_count; 1029 1030 1031 /* r200_tcl.c 1032 */ 1033 struct r200_tcl_info tcl; 1034 1035 /* r200_swtcl.c 1036 */ 1037 struct r200_swtcl_info swtcl; 1038 1039 /* r200_vtxfmt.c 1040 */ 1041 struct r200_vbinfo vb; 1042 1043 /* Mirrors of some DRI state 1044 */ 1045 struct r200_dri_mirror dri; 1046 1047 /* Configuration cache 1048 */ 1049 driOptionCache optionCache; 1050 1051 GLboolean using_hyperz; 1052 GLboolean texmicrotile; 1053 1054 struct ati_fragment_shader *afs_loaded; 1055}; 1056 1057#define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx)) 1058 1059 1060static __inline GLuint r200PackColor( GLuint cpp, 1061 GLubyte r, GLubyte g, 1062 GLubyte b, GLubyte a ) 1063{ 1064 switch ( cpp ) { 1065 case 2: 1066 return PACK_COLOR_565( r, g, b ); 1067 case 4: 1068 return PACK_COLOR_8888( a, r, g, b ); 1069 default: 1070 return 0; 1071 } 1072} 1073 1074 1075extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv ); 1076extern GLboolean r200CreateContext( const __GLcontextModes *glVisual, 1077 __DRIcontextPrivate *driContextPriv, 1078 void *sharedContextPrivate); 1079extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv ); 1080extern void r200CopySubBuffer( __DRIdrawablePrivate * dPriv, 1081 int x, int y, int w, int h ); 1082extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv, 1083 __DRIdrawablePrivate *driDrawPriv, 1084 __DRIdrawablePrivate *driReadPriv ); 1085extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv ); 1086 1087/* ================================================================ 1088 * Debugging: 1089 */ 1090#define DO_DEBUG 1 1091 1092#if DO_DEBUG 1093extern int R200_DEBUG; 1094#else 1095#define R200_DEBUG 0 1096#endif 1097 1098#define DEBUG_TEXTURE 0x001 1099#define DEBUG_STATE 0x002 1100#define DEBUG_IOCTL 0x004 1101#define DEBUG_PRIMS 0x008 1102#define DEBUG_VERTS 0x010 1103#define DEBUG_FALLBACKS 0x020 1104#define DEBUG_VFMT 0x040 1105#define DEBUG_CODEGEN 0x080 1106#define DEBUG_VERBOSE 0x100 1107#define DEBUG_DRI 0x200 1108#define DEBUG_DMA 0x400 1109#define DEBUG_SANITY 0x800 1110#define DEBUG_SYNC 0x1000 1111#define DEBUG_PIXEL 0x2000 1112#define DEBUG_MEMORY 0x4000 1113 1114#endif /* __R200_CONTEXT_H__ */ 1115