r200_context.h revision 24a44d74b6e9880dfc019bd1cfa9ce0351377c85
1bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
2bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl/*
3adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellCopyright (C) The Weather Channel, Inc.  2002.  All Rights Reserved.
4adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
5adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellThe Weather Channel (TM) funded Tungsten Graphics to develop the
6adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellinitial release of the Radeon 8500 driver under the XFree86 license.
7adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellThis notice must be preserved.
8adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
9adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellPermission is hereby granted, free of charge, to any person obtaining
10adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwella copy of this software and associated documentation files (the
11adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell"Software"), to deal in the Software without restriction, including
12adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellwithout limitation the rights to use, copy, modify, merge, publish,
13adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelldistribute, sublicense, and/or sell copies of the Software, and to
14adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellpermit persons to whom the Software is furnished to do so, subject to
15adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellthe following conditions:
16adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
17adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellThe above copyright notice and this permission notice (including the
18adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellnext paragraph) shall be included in all copies or substantial
19adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellportions of the Software.
20adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
21adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellIN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
25adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27adbec39bbf671ad80f6c557801e274cac0d305faKeith WhitwellWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
29adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell**************************************************************************/
30adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
31adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/*
32adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Authors:
33adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell *   Keith Whitwell <keith@tungstengraphics.com>
34adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
35adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
36adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#ifndef __R200_CONTEXT_H__
37adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define __R200_CONTEXT_H__
38adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
39e946688edac5cdf153652defae3ef732a3487416Ian Romanick#include "tnl/t_vertex.h"
40ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl#include "drm.h"
41ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl#include "radeon_drm.h"
42adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "dri_util.h"
43adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "texmem.h"
44adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
45adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "macros.h"
46adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "mtypes.h"
47adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "colormac.h"
48adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "r200_reg.h"
49adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
5095a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick#define ENABLE_HW_3D_TEXTURE 1  /* XXX this is temporary! */
51adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
52adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_context;
53adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelltypedef struct r200_context r200ContextRec;
54adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelltypedef struct r200_context *r200ContextPtr;
55adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
56adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "r200_lock.h"
57adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "r200_screen.h"
58adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "mm.h"
59adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
60adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Flags for software fallback cases */
61adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* See correponding strings in r200_swtcl.c */
62ef377c3c007611e57aef176cb66d8b4c18f1a6c3Eric Anholt#define R200_FALLBACK_TEXTURE           0x01
63ef377c3c007611e57aef176cb66d8b4c18f1a6c3Eric Anholt#define R200_FALLBACK_DRAW_BUFFER       0x02
64ef377c3c007611e57aef176cb66d8b4c18f1a6c3Eric Anholt#define R200_FALLBACK_STENCIL           0x04
65ef377c3c007611e57aef176cb66d8b4c18f1a6c3Eric Anholt#define R200_FALLBACK_RENDER_MODE       0x08
66ef377c3c007611e57aef176cb66d8b4c18f1a6c3Eric Anholt#define R200_FALLBACK_DISABLE           0x10
67ef377c3c007611e57aef176cb66d8b4c18f1a6c3Eric Anholt#define R200_FALLBACK_BORDER_MODE       0x20
68adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
69adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* The blit width for texture uploads
70adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
71adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define BLIT_WIDTH_BYTES 1024
72adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
73adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Use the templated vertex format:
74adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
75adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define COLOR_IS_RGBA
76adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TAG(x) r200##x
77adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#include "tnl_dd/t_dd_vertex.h"
78adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#undef TAG
79adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
80adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelltypedef void (*r200_tri_func)( r200ContextPtr,
81adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				 r200Vertex *,
82adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				 r200Vertex *,
83adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				 r200Vertex * );
84adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
85adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelltypedef void (*r200_line_func)( r200ContextPtr,
86adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				  r200Vertex *,
87adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				  r200Vertex * );
88adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
89adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelltypedef void (*r200_point_func)( r200ContextPtr,
90adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				   r200Vertex * );
91adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
92adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
93adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_colorbuffer_state {
94adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint clear;
95fcbfeb5d28aea87c60f2d02daa213d0c0c2516e8Brian Paul#if 000
96adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLint drawOffset, drawPitch;
97fcbfeb5d28aea87c60f2d02daa213d0c0c2516e8Brian Paul#endif
98273e52f86fa41564f573c8e84d013f995e01a8f0Alan Hourihane   int roundEnable;
99adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
100adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
101adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
102adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_depthbuffer_state {
103b31b7836d6e7abf80dd4feacce333d4b1fe6e4abRoland Scheidegger   GLuint clear;
104adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLfloat scale;
105adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
106adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
107fcbfeb5d28aea87c60f2d02daa213d0c0c2516e8Brian Paul#if 000
108adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_pixel_state {
109adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLint readOffset, readPitch;
110adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
111fcbfeb5d28aea87c60f2d02daa213d0c0c2516e8Brian Paul#endif
112adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
113adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_scissor_state {
114ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_clip_rect_t rect;
115adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean enabled;
116adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
117adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint numClipRects;			/* Cliprects active */
118adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint numAllocedClipRects;		/* Cliprects available */
119ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_clip_rect_t *pClipRects;
120adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
121adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
122adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_stencilbuffer_state {
123adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean hwBuffer;
124adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint clear;			/* rb3d_stencilrefmask value */
125adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
126adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
127adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_stipple_state {
128adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint mask[32];
129adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
130adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
131adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
132adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
133adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_0   0x1
134adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_1   0x2
13548ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define TEX_2	0x4
13648ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define TEX_3	0x8
13748ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define TEX_4	0x10
13848ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define TEX_5	0x20
13948ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define TEX_ALL 0x3f
140adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
141adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwelltypedef struct r200_tex_obj r200TexObj, *r200TexObjPtr;
142adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
143adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Texture object in locally shared texture space.
144adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
145adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_tex_obj {
146adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   driTextureObject   base;
147adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
148adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint bufAddr;			/* Offset to start of locally
149adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   shared texture block */
150adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
151adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint dirty_state;		        /* Flags (1 per texunit) for
152adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   whether or not this texobj
153adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   has dirty hardware state
154adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   (pp_*) that needs to be
155adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   brought into the
156adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   texunit. */
157adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
158ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
159adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					/* Six, for the cube faces */
160adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
161adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_txfilter;		        /* hardware register values */
162adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_txformat;
163adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_txformat_x;
164adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_txoffset;		        /* Image location in texmem.
165adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					   All cube faces follow. */
166adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_txsize;		        /* npot only */
167adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_txpitch;		        /* npot only */
168adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_border_color;
169adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint pp_cubic_faces;	        /* cube face 1,2,3,4 log2 sizes */
170adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
171adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean  border_fallback;
1724837ea30208d002bc36a836d2117f826d40c8bfaRoland Scheidegger
1734837ea30208d002bc36a836d2117f826d40c8bfaRoland Scheidegger   GLuint tile_bits;			/* hw texture tile bits used on this texture */
174adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
175adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
176adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
177adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_texture_env_state {
178adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200TexObjPtr texobj;
17936603539ccdb1c507724d8a1c314e6c9cc9863d9Roland Scheidegger   GLuint outputreg;
18036603539ccdb1c507724d8a1c314e6c9cc9863d9Roland Scheidegger   GLuint unitneeded;
181adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
182adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
18348ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define R200_MAX_TEXTURE_UNITS 6
184adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
185adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_texture_state {
186adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS];
187adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
188adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
189adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
190adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_state_atom {
191adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom *next, *prev;
192adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   const char *name;		         /* for debug */
193adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int cmd_size;		         /* size in bytes */
194adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint idx;
195adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int *cmd;			         /* one or more cmd's */
196adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int *lastcmd;			 /* one or more cmd's */
197a05b1549f7b6da7d9313b9addf2d01b9c61f34d7Keith Whitwell   GLboolean dirty;
198adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean (*check)( GLcontext *, int );    /* is this state active? */
199adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
200adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
201adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
202adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
203adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Trying to keep these relatively short as the variables are becoming
204adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * extravagently long.  Drop the driver name prefix off the front of
205adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * everything - I think we know which driver we're in by now, and keep the
206adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * prefix to 3 letters unless absolutely impossible.
207adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
208adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
209adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_CMD_0             0
210adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_PP_MISC           1
211adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_PP_FOG_COLOR      2
212adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RE_SOLID_COLOR    3
213adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_BLENDCNTL    4
214adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_DEPTHOFFSET  5
215adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_DEPTHPITCH   6
216adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_ZSTENCILCNTL 7
217adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_CMD_1             8
218adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_PP_CNTL           9
219adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_CNTL         10
220adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_COLOROFFSET  11
221adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_CMD_2             12 /* why */
222adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CTX_RB3D_COLORPITCH   13 /* why */
223033728555cb2f39d8c77f228e1eccc45329bb40aRoland Scheidegger#define CTX_STATE_SIZE_OLDDRM 14
224033728555cb2f39d8c77f228e1eccc45329bb40aRoland Scheidegger#define CTX_CMD_3             14
225033728555cb2f39d8c77f228e1eccc45329bb40aRoland Scheidegger#define CTX_RB3D_BLENDCOLOR   15
226033728555cb2f39d8c77f228e1eccc45329bb40aRoland Scheidegger#define CTX_RB3D_ABLENDCNTL   16
227033728555cb2f39d8c77f228e1eccc45329bb40aRoland Scheidegger#define CTX_RB3D_CBLENDCNTL   17
228033728555cb2f39d8c77f228e1eccc45329bb40aRoland Scheidegger#define CTX_STATE_SIZE_NEWDRM 18
229adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
230adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define SET_CMD_0               0
231adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define SET_SE_CNTL             1
232adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define SET_RE_CNTL             2 /* replace se_coord_fmt */
233adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define SET_STATE_SIZE          3
234adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
235adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTE_CMD_0               0
236adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTE_SE_VTE_CNTL         1
237adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTE_STATE_SIZE          2
238adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
239adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIN_CMD_0               0
240adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIN_RE_LINE_PATTERN     1
241adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIN_RE_LINE_STATE       2
242adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIN_CMD_1               3
243adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIN_SE_LINE_WIDTH       4
244adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIN_STATE_SIZE          5
245adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
246adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSK_CMD_0               0
247adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSK_RB3D_STENCILREFMASK 1
248adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSK_RB3D_ROPCNTL        2
249adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSK_RB3D_PLANEMASK      3
250adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSK_STATE_SIZE          4
251adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
252adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_CMD_0           0
253adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_SE_VPORT_XSCALE          1
254adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_SE_VPORT_XOFFSET         2
255adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_SE_VPORT_YSCALE          3
256adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_SE_VPORT_YOFFSET         4
257adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_SE_VPORT_ZSCALE          5
258adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_SE_VPORT_ZOFFSET         6
259adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VPT_STATE_SIZE      7
260adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
261adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define ZBS_CMD_0               0
262adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define ZBS_SE_ZBIAS_FACTOR     1
263adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define ZBS_SE_ZBIAS_CONSTANT   2
264adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define ZBS_STATE_SIZE          3
265adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
266adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSC_CMD_0               0
267adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSC_RE_MISC             1
268adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSC_STATE_SIZE          2
269adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
270adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TAM_CMD_0               0
271adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TAM_DEBUG3              1
272adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TAM_STATE_SIZE          2
273adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
274adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_CMD_0                   0
275adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_PP_TXFILTER             1  /*2c00*/
276adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_PP_TXFORMAT             2  /*2c04*/
277adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_PP_TXFORMAT_X           3  /*2c08*/
278adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_PP_TXSIZE               4  /*2c0c*/
279adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_PP_TXPITCH              5  /*2c10*/
280adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TEX_PP_BORDER_COLOR         6  /*2c14*/
281f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_CMD_1_OLDDRM            7
282f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_PP_TXOFFSET_OLDDRM      8  /*2d00 */
283f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_STATE_SIZE_OLDDRM       9
284f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_PP_CUBIC_FACES          7
285f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_PP_TXMULTI_CTL          8
286f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_CMD_1_NEWDRM            9
287f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_PP_TXOFFSET_NEWDRM     10
288f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define TEX_STATE_SIZE_NEWDRM      11
289f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger
290f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define CUBE_CMD_0                  0  /* 1 register follows */ /* this command unnecessary */
291f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define CUBE_PP_CUBIC_FACES         1  /* 0x2c18 */             /* with new enough drm */
292adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_CMD_1                  2  /* 5 registers follow */
293adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_PP_CUBIC_OFFSET_F1     3  /* 0x2d04 */
294adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_PP_CUBIC_OFFSET_F2     4  /* 0x2d08 */
295adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_PP_CUBIC_OFFSET_F3     5  /* 0x2d0c */
296adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_PP_CUBIC_OFFSET_F4     6  /* 0x2d10 */
297adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_PP_CUBIC_OFFSET_F5     7  /* 0x2d14 */
298adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CUBE_STATE_SIZE             8
299adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
300adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define PIX_CMD_0                   0
301adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define PIX_PP_TXCBLEND             1
302adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define PIX_PP_TXCBLEND2            2
303adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define PIX_PP_TXABLEND             3
304adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define PIX_PP_TXABLEND2            4
305adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define PIX_STATE_SIZE              5
306adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
307adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_CMD_0                    0
308adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_TFACTOR_0                1
309adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_TFACTOR_1                2
310adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_TFACTOR_2                3
311adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_TFACTOR_3                4
312adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_TFACTOR_4                5
313adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_TFACTOR_5                6
314adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TF_STATE_SIZE               7
315adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
316f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_CMD_0                   0
317f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_0               1
318f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_1               2
319f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_2               3
320f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_3               4
321f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_4               5
322f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_5               6
323f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_6               7
324f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_TFACTOR_7               8
325f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define ATF_STATE_SIZE              9
326f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger
327f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger/* ATI_FRAGMENT_SHADER */
328f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define AFS_CMD_0                 0
329f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define AFS_IC0                   1 /* 2f00 */
330f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define AFS_IC1                   2 /* 2f04 */
331f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define AFS_IA0                   3 /* 2f08 */
332f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define AFS_IA1                   4 /* 2f0c */
333f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger#define AFS_STATE_SIZE           33
334f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger
335adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_CMD_0                 0
336adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_LIGHT_MODEL_CTL_0     1
337adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_LIGHT_MODEL_CTL_1     2
338adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_PER_LIGHT_CTL_0       3
339adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_PER_LIGHT_CTL_1       4
340adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_PER_LIGHT_CTL_2       5
341adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_PER_LIGHT_CTL_3       6
342adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_CMD_1                 7
343adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_UCP_VERT_BLEND_CTL    8
344adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCL_STATE_SIZE            9
345adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
346adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_CMD_0                     0
347adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_MATRIX_SELECT_0           1
348adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_MATRIX_SELECT_1           2
349adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_MATRIX_SELECT_2           3
350adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_MATRIX_SELECT_3           4
351adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_MATRIX_SELECT_4           5
352adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MSL_STATE_SIZE                6
353adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
354adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_CMD_0                 0
355adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_TEX_PROC_CTL_2            1
356adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_TEX_PROC_CTL_3            2
357adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_TEX_PROC_CTL_0            3
358adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_TEX_PROC_CTL_1            4
359adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_TEX_CYL_WRAP_CTL      5
360adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define TCG_STATE_SIZE            6
361adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
362adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_CMD_0            0
363adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_EMMISSIVE_RED    1
364adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_EMMISSIVE_GREEN  2
365adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_EMMISSIVE_BLUE   3
366adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_EMMISSIVE_ALPHA  4
367adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_AMBIENT_RED      5
368adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_AMBIENT_GREEN    6
369adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_AMBIENT_BLUE     7
370adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_AMBIENT_ALPHA    8
371adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_DIFFUSE_RED      9
372adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_DIFFUSE_GREEN    10
373adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_DIFFUSE_BLUE     11
374adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_DIFFUSE_ALPHA    12
375adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_SPECULAR_RED     13
376adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_SPECULAR_GREEN   14
377adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_SPECULAR_BLUE    15
378adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_SPECULAR_ALPHA   16
379adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_CMD_1            17
380adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_SHININESS        18
381adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MTL_STATE_SIZE       19
382adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
383adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VAP_CMD_0                   0
384adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VAP_SE_VAP_CNTL             1
385adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VAP_STATE_SIZE              2
386adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
387adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Replaces a lot of packet info from radeon
388adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
389adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_CMD_0                   0
390adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_VTXFMT_0            1
391adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_VTXFMT_1            2
392adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_TCL_OUTPUT_VTXFMT_0 3
393adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_TCL_OUTPUT_VTXFMT_1 4
394adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_CMD_1               5
395adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_TCL_OUTPUT_COMPSEL  6
396adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_CMD_2               7
397adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_STATE_CNTL          8
398adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_STATE_SIZE          9
399adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
40044dace86eaf9eded8e6465adfadf6345658686ddRoland Scheidegger/* SPR - point sprite state
40144dace86eaf9eded8e6465adfadf6345658686ddRoland Scheidegger */
40244dace86eaf9eded8e6465adfadf6345658686ddRoland Scheidegger#define SPR_CMD_0             0
40344dace86eaf9eded8e6465adfadf6345658686ddRoland Scheidegger#define SPR_POINT_SPRITE_CNTL 1
40444dace86eaf9eded8e6465adfadf6345658686ddRoland Scheidegger#define SPR_STATE_SIZE        2
405adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
406adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define VTX_COLOR(v,n)   (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
407adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell                         R200_VTX_COLOR_MASK)
408adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
40995a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick/**
41095a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
41195a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick * how many components are in texture coordinate \c n.
41295a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick */
41395a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick#define VTX_TEXn_COUNT(v,n)   (((v) >> (3 * n)) & 0x07)
41495a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick
415adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MAT_CMD_0              0
416adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MAT_ELT_0              1
417adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define MAT_STATE_SIZE         17
418adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
419adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GRD_CMD_0                  0
420adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GRD_VERT_GUARD_CLIP_ADJ    1
421adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GRD_VERT_GUARD_DISCARD_ADJ 2
422adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GRD_HORZ_GUARD_CLIP_ADJ    3
423adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GRD_HORZ_GUARD_DISCARD_ADJ 4
424adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GRD_STATE_SIZE             5
425adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
426adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* position changes frequently when lighting in modelpos - separate
427adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * out to new state item?
428adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
429adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_CMD_0                  0
430adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_AMBIENT_RED            1
431adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_AMBIENT_GREEN          2
432adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_AMBIENT_BLUE           3
433adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_AMBIENT_ALPHA          4
434adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIFFUSE_RED            5
435adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIFFUSE_GREEN          6
436adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIFFUSE_BLUE           7
437adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIFFUSE_ALPHA          8
438adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPECULAR_RED           9
439adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPECULAR_GREEN         10
440adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPECULAR_BLUE          11
441adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPECULAR_ALPHA         12
442adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_POSITION_X             13
443adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_POSITION_Y             14
444adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_POSITION_Z             15
445adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_POSITION_W             16
446adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIRECTION_X            17
447adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIRECTION_Y            18
448adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIRECTION_Z            19
449adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_DIRECTION_W            20
4505d00e131d8a264498b8d050c3eded093ee5c42f2Michel Dänzer#define LIT_ATTEN_QUADRATIC        21
451adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_ATTEN_LINEAR           22
4525d00e131d8a264498b8d050c3eded093ee5c42f2Michel Dänzer#define LIT_ATTEN_CONST            23
453adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_ATTEN_XXX              24
454adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_CMD_1                  25
455adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPOT_DCD               26
456adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPOT_DCM               27
457adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPOT_EXPONENT          28
458adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPOT_CUTOFF            29
459adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_SPECULAR_THRESH        30
460adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_RANGE_CUTOFF           31 /* ? */
4615d00e131d8a264498b8d050c3eded093ee5c42f2Michel Dänzer#define LIT_ATTEN_CONST_INV        32
462adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define LIT_STATE_SIZE             33
463adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
464adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Fog
465adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
466adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define FOG_CMD_0      0
467adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define FOG_R          1
468adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define FOG_C          2
469adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define FOG_D          3
470adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define FOG_PAD        4
471adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define FOG_STATE_SIZE 5
472adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
473adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* UCP
474adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
475adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define UCP_CMD_0      0
476adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define UCP_X          1
477adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define UCP_Y          2
478adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define UCP_Z          3
479adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define UCP_W          4
480adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define UCP_STATE_SIZE 5
481adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
482adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* GLT - Global ambient
483adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
484adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GLT_CMD_0      0
485adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GLT_RED        1
486adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GLT_GREEN      2
487adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GLT_BLUE       3
488adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GLT_ALPHA      4
489adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define GLT_STATE_SIZE 5
490adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
491adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* EYE
492adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
493adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define EYE_CMD_0          0
494adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define EYE_X              1
495adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define EYE_Y              2
496adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define EYE_Z              3
497adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define EYE_RESCALE_FACTOR 4
498adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define EYE_STATE_SIZE     5
499adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
500adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* CST - constant state
501adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
502adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_0                             0
503adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_PP_CNTL_X                         1
504adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_1                             2
505adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_RB3D_DEPTHXY_OFFSET               3
506adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_2                             4
507adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_RE_AUX_SCISSOR_CNTL               5
508adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_3                             6
509adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_RE_SCISSOR_TL_0                   7
510adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_RE_SCISSOR_BR_0                   8
511adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_4                             9
512adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_SE_VAP_CNTL_STATUS                10
513adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_5                             11
514adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_RE_POINTSIZE                      12
515adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_CMD_6                             13
516adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_SE_TCL_INPUT_VTX_0                14
517adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_SE_TCL_INPUT_VTX_1                15
518adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_SE_TCL_INPUT_VTX_2                16
519adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_SE_TCL_INPUT_VTX_3                17
520adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define CST_STATE_SIZE                        18
521adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
522fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger#define PRF_CMD_0         0
523fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger#define PRF_PP_TRI_PERF   1
524fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger#define PRF_PP_PERF_CNTL  2
525fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger#define PRF_STATE_SIZE    3
526adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
527adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
528adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_hw_state {
5290c8f8d3dc9d60ed34eeca7f3606651420a81753cEric Anholt   /* Head of the linked list of state atoms. */
5300c8f8d3dc9d60ed34eeca7f3606651420a81753cEric Anholt   struct r200_state_atom atomlist;
531adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
532adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Hardware state, stored as cmdbuf commands:
533adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    *   -- Need to doublebuffer for
534adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    *           - reviving state after loss of context
535adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    *           - eliding noop statechange loops? (except line stipple count)
536adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
537adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom ctx;
538adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom set;
539adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom vte;
540adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom lin;
541adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom msk;
542adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom vpt;
543adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom vap;
544adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom vtx;
545adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom tcl;
546adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom msl;
547adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom tcg;
548adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom msc;
549adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom cst;
550adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom tam;
551adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom tf;
55248ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   struct r200_state_atom tex[6];
55348ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   struct r200_state_atom cube[6];
554adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom zbs;
555fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger   struct r200_state_atom mtl[2];
556fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger   struct r200_state_atom mat[9];
557adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom lit[8]; /* includes vec, scl commands */
558adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom ucp[6];
559adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom pix[6]; /* pixshader stages */
560adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom eye; /* eye pos */
561adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state_atom grd; /* guard band clipping */
562fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger   struct r200_state_atom fog;
563fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger   struct r200_state_atom glt;
564fbe5296d1463e1052590b744f3d62ebb9e5d5dd4Roland Scheidegger   struct r200_state_atom prf;
565f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger   struct r200_state_atom afs[2];
566f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger   struct r200_state_atom atf;
56744dace86eaf9eded8e6465adfadf6345658686ddRoland Scheidegger   struct r200_state_atom spr;
5686f3cc6a5226fd4b5d44cca91e2f76216ecaff831Eric Anholt
5696f3cc6a5226fd4b5d44cca91e2f76216ecaff831Eric Anholt   int max_state_size;	/* Number of bytes necessary for a full state emit. */
5700c8f8d3dc9d60ed34eeca7f3606651420a81753cEric Anholt   GLboolean is_dirty, all_dirty;
571adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
572adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
573adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_state {
574adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Derived state for internal purposes:
575adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
576adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_colorbuffer_state color;
577adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_depthbuffer_state depth;
578fcbfeb5d28aea87c60f2d02daa213d0c0c2516e8Brian Paul#if 00
579adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_pixel_state pixel;
580fcbfeb5d28aea87c60f2d02daa213d0c0c2516e8Brian Paul#endif
581adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_scissor_state scissor;
582adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_stencilbuffer_state stencil;
583adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_stipple_state stipple;
584adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_texture_state texture;
58536603539ccdb1c507724d8a1c314e6c9cc9863d9Roland Scheidegger   GLuint envneeded;
586adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
587adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
588adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Need refcounting on dma buffers:
589adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
590adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_dma_buffer {
591adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int refcount;		/* the number of retained regions in buf */
592adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   drmBufPtr buf;
593adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
594adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
595bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl#define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset +		\
596adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell			(rvb)->address - rmesa->dma.buf0_address +	\
597adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell			(rvb)->start)
598adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
599adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* A retained region, eg vertices for indexed vertices.
600adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
601adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_dma_region {
602adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_buffer *buf;
603adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   char *address;		/* == buf->address */
604adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int start, end, ptr;		/* offsets from start of buf */
605adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int aos_start;
606adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int aos_stride;
607adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int aos_size;
608adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
609adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
610adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
611adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_dma {
612adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Active dma region.  Allocations for vertices and retained
613adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    * regions come from here.  Also used for emitting random vertices,
614adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    * these may be flushed by calling flush_current();
615adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
616adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region current;
617adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
618adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   void (*flush)( r200ContextPtr );
619adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
620adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   char *buf0_address;		/* start of buf[0], for index calcs */
621adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint nr_released_bufs;	/* flush after so many buffers released */
622adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
623adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
624adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_dri_mirror {
625adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   __DRIcontextPrivate	*context;	/* DRI context */
626adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   __DRIscreenPrivate	*screen;	/* DRI screen */
627adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   __DRIdrawablePrivate	*drawable;	/* DRI drawable bound to this ctx */
628adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
629c06b25594e5effe34a90c067e1a3da0f61cf2b13Ian Romanick   drm_context_t hwContext;
630ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_hw_lock_t *hwLock;
631adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int fd;
632adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int drmMinor;
633adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
634adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
635adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
636adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define R200_CMD_BUF_SZ  (8*1024)
637adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
638adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_store {
639adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint statenr;
640adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint primnr;
641adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   char cmd_buf[R200_CMD_BUF_SZ];
642adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int cmd_used;
643adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int elts_start;
644adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
645adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
646adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
647adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* r200_tcl.c
648adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
649adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_tcl_info {
650adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vertex_format;
651adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLint last_offset;
652adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint hw_primitive;
653adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
654adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region *aos_components[8];
655adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint nr_aos_components;
656adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
657adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint *Elts;
658adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
659adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region indexed_verts;
660adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region obj;
661adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region rgba;
662adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region spec;
663adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region fog;
664adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS];
665adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region norm;
666adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
667adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
668adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
669adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* r200_swtcl.c
670adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
671adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_swtcl_info {
672adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint RenderIndex;
673e946688edac5cdf153652defae3ef732a3487416Ian Romanick
674e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
675e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Size of a hardware vertex.  This is calculated when \c ::vertex_attrs is
676e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * installed in the Mesa state vector.
677e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
678adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vertex_size;
679e946688edac5cdf153652defae3ef732a3487416Ian Romanick
680e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
681e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Attributes instructing the Mesa TCL pipeline where / how to put vertex
682e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * data in the hardware buffer.
683e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
684e946688edac5cdf153652defae3ef732a3487416Ian Romanick   struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
685e946688edac5cdf153652defae3ef732a3487416Ian Romanick
686e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
687e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Number of elements of \c ::vertex_attrs that are actually used.
688e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
689e946688edac5cdf153652defae3ef732a3487416Ian Romanick   GLuint vertex_attr_count;
690e946688edac5cdf153652defae3ef732a3487416Ian Romanick
691e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
692e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Cached pointer to the buffer where Mesa will store vertex data.
693e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
6945df82c82bd53db90eb72c5aad4dd20cf6f1116b1Brian Paul   GLubyte *verts;
695adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
696adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Fallback rasterization functions
697adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
698adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200_point_func draw_point;
699adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200_line_func draw_line;
700adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200_tri_func draw_tri;
701adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
702adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint hw_primitive;
703adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLenum render_primitive;
704adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint numverts;
705adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
706e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
707e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Offset of the 4UB color data within a hardware (swtcl) vertex.
708e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
709e946688edac5cdf153652defae3ef732a3487416Ian Romanick   GLuint coloroffset;
710e946688edac5cdf153652defae3ef732a3487416Ian Romanick
711e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
712e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
713e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
714e946688edac5cdf153652defae3ef732a3487416Ian Romanick   GLuint specoffset;
715e946688edac5cdf153652defae3ef732a3487416Ian Romanick
716e946688edac5cdf153652defae3ef732a3487416Ian Romanick   /**
717e946688edac5cdf153652defae3ef732a3487416Ian Romanick    * Should Mesa project vertex data or will the hardware do it?
718e946688edac5cdf153652defae3ef732a3487416Ian Romanick    */
719e946688edac5cdf153652defae3ef732a3487416Ian Romanick   GLboolean needproj;
720e946688edac5cdf153652defae3ef732a3487416Ian Romanick
721adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma_region indexed_verts;
722adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
723adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
724adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
725adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_ioctl {
726adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vertex_offset;
727adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vertex_size;
728adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
729adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
730adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
731adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
732adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define R200_MAX_PRIMS 64
733adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
734adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
735adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* Want to keep a cache of these around.  Each is parameterized by
736adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * only a single value which has only a small range.  Only expect a
737adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * few, so just rescan the list each time?
738adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
739adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct dynfn {
740adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *next, *prev;
741adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int key[2];
742adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   char *code;
743adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
744adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
745adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct dfn_lists {
746adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Vertex2f;
747adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Vertex2fv;
748adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Vertex3f;
749adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Vertex3fv;
750adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color4ub;
751adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color4ubv;
752adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color3ub;
753adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color3ubv;
754adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color4f;
755adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color4fv;
756adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color3f;
757adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Color3fv;
758adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn SecondaryColor3ubEXT;
759adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn SecondaryColor3ubvEXT;
760adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn SecondaryColor3fEXT;
761adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn SecondaryColor3fvEXT;
762adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Normal3f;
763adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn Normal3fv;
76495a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn TexCoord3f;
76595a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn TexCoord3fv;
766adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn TexCoord2f;
767adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn TexCoord2fv;
768adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn TexCoord1f;
769adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn TexCoord1fv;
77095a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn MultiTexCoord3fARB;
77195a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn MultiTexCoord3fvARB;
772adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn MultiTexCoord2fARB;
773adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn MultiTexCoord2fvARB;
774adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn MultiTexCoord1fARB;
775adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn MultiTexCoord1fvARB;
776d294f79190a5b25ef0fbbbf3ac94b15c9402d009Roland Scheidegger   struct dynfn FogCoordfEXT;
777d294f79190a5b25ef0fbbbf3ac94b15c9402d009Roland Scheidegger   struct dynfn FogCoordfvEXT;
778adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
779adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
780adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct dfn_generators {
781adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Vertex2f)( GLcontext *, const int * );
782adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Vertex2fv)( GLcontext *, const int * );
783adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Vertex3f)( GLcontext *, const int * );
784adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Vertex3fv)( GLcontext *, const int * );
785adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color4ub)( GLcontext *, const int * );
786adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color4ubv)( GLcontext *, const int * );
787adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color3ub)( GLcontext *, const int * );
788adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color3ubv)( GLcontext *, const int * );
789adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color4f)( GLcontext *, const int * );
790adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color4fv)( GLcontext *, const int * );
791adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color3f)( GLcontext *, const int * );
792adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Color3fv)( GLcontext *, const int * );
793adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*SecondaryColor3ubEXT)( GLcontext *, const int * );
794adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*SecondaryColor3ubvEXT)( GLcontext *, const int * );
795adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*SecondaryColor3fEXT)( GLcontext *, const int * );
796adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, const int * );
797adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Normal3f)( GLcontext *, const int * );
798adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*Normal3fv)( GLcontext *, const int * );
79995a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn *(*TexCoord3f)( GLcontext *, const int * );
80095a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn *(*TexCoord3fv)( GLcontext *, const int * );
801adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*TexCoord2f)( GLcontext *, const int * );
802adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*TexCoord2fv)( GLcontext *, const int * );
803adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*TexCoord1f)( GLcontext *, const int * );
804adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*TexCoord1fv)( GLcontext *, const int * );
80595a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn *(*MultiTexCoord3fARB)( GLcontext *, const int * );
80695a0bd6762737bb25bdf5c4147da9d1372f6aac3Ian Romanick   struct dynfn *(*MultiTexCoord3fvARB)( GLcontext *, const int * );
807adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, const int * );
808adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, const int * );
809adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, const int * );
810adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dynfn *(*MultiTexCoord1fvARB)( GLcontext *, const int * );
811d294f79190a5b25ef0fbbbf3ac94b15c9402d009Roland Scheidegger   struct dynfn *(*FogCoordfEXT)( GLcontext *, const int * );
812d294f79190a5b25ef0fbbbf3ac94b15c9402d009Roland Scheidegger   struct dynfn *(*FogCoordfvEXT)( GLcontext *, const int * );
813adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
814adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
815adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
816adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
817adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_prim {
818adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint start;
819adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint end;
820adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint prim;
821adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
822adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
82348ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   /* A maximum total of 29 elements per vertex:  3 floats for position, 3
824adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    * floats for normal, 4 floats for color, 4 bytes for secondary color,
82548ccaf200940613032dfaaafe71382947f398004Roland Scheidegger    * 3 floats for each texture unit (18 floats total).
826adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    *
82748ccaf200940613032dfaaafe71382947f398004Roland Scheidegger    * we maybe need add. 4 to prevent segfault if someone specifies
82848ccaf200940613032dfaaafe71382947f398004Roland Scheidegger    * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
829adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    *
830adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    * The position data is never actually stored here, so 3 elements could be
831adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    * trimmed out of the buffer.
832adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
83348ccaf200940613032dfaaafe71382947f398004Roland Scheidegger
83448ccaf200940613032dfaaafe71382947f398004Roland Scheidegger#define R200_MAX_VERTEX_SIZE ((3*6)+11)
83548ccaf200940613032dfaaafe71382947f398004Roland Scheidegger
83648ccaf200940613032dfaaafe71382947f398004Roland Scheideggerstruct r200_vbinfo {
83748ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   GLint counter, initial_counter;
83848ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   GLint *dmaptr;
83948ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   void (*notify)( void );
84048ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   GLint vertex_size;
84148ccaf200940613032dfaaafe71382947f398004Roland Scheidegger
84248ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   union { float f; int i; r200_color_t color; } vertex[R200_MAX_VERTEX_SIZE];
843adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
844adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLfloat *normalptr;
845adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLfloat *floatcolorptr;
846d294f79190a5b25ef0fbbbf3ac94b15c9402d009Roland Scheidegger   GLfloat *fogptr;
847adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200_color_t *colorptr;
848adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLfloat *floatspecptr;
849adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200_color_t *specptr;
85048ccaf200940613032dfaaafe71382947f398004Roland Scheidegger   GLfloat *texcoordptr[8];	/* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
851adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
852adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
853adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLenum *prim;		/* &ctx->Driver.CurrentExecPrimitive */
854adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint primflags;
855adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean enabled;		/* *_NO_VTXFMT / *_NO_TCL env vars */
856adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean installed;
857adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean fell_back;
858adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean recheck;
859adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLint nrverts;
860adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vtxfmt_0, vtxfmt_1;
861adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
862adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint installed_vertex_format;
863adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint installed_color_3f_sz;
864adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
865adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_prim primlist[R200_MAX_PRIMS];
866adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   int nrprims;
867adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
868adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dfn_lists dfn_cache;
869adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct dfn_generators codegen;
870adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLvertexformat vtxfmt;
871adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
872adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
873adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
874adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstruct r200_context {
875adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLcontext *glCtx;			/* Mesa context */
876adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
877adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Driver and hardware state management
878adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
879adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_hw_state hw;
880adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_state state;
881adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
882adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Texture object bookkeeping
883adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
884adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   unsigned              nr_heaps;
885adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   driTexHeap          * texture_heaps[ R200_NR_TEX_HEAPS ];
886adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   driTextureObject      swapped;
887d907a75498360fb96ec2314bb0abb105be74d500Alan Hourihane   int                   texture_depth;
888d3fd7ba8af15bead2f770d68a893449adeb11397Brian Paul   float                 initialMaxAnisotropy;
889adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
890adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Rasterization and vertex state:
891adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
892adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint TclFallback;
893adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint Fallback;
894adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint NewGLState;
895b1ebd306bf4fdc4076d3d3daa410b08f477cb4c4Eric Anholt   GLuint tnl_index;	/* index of bits for last tnl_install_attrs */
896adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
897adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Vertex buffers
898adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
899adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_ioctl ioctl;
900adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dma dma;
901adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_store store;
9027a086dc05e665a78f7e9d069aa4fc70e844b8988Eric Anholt   /* A full state emit as of the first state emit in the main store, in case
9037a086dc05e665a78f7e9d069aa4fc70e844b8988Eric Anholt    * the context is lost.
9047a086dc05e665a78f7e9d069aa4fc70e844b8988Eric Anholt    */
9057a086dc05e665a78f7e9d069aa4fc70e844b8988Eric Anholt   struct r200_store backup_store;
906adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
907adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Page flipping
908adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
909adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint doPageFlip;
910adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
911adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Busy waiting
912adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
913adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint do_usleeps;
914adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint do_irqs;
915adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint irqsEmitted;
916ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_radeon_irq_wait_t iw;
917adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
918adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Clientdata textures;
919adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
920bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl   GLuint prefer_gart_client_texturing;
921adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
922adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Drawable, cliprect and scissor information
923adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
924adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint numClipRects;			/* Cliprects for the draw buffer */
925ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_clip_rect_t *pClipRects;
926adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   unsigned int lastStamp;
927adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean lost_context;
9287a086dc05e665a78f7e9d069aa4fc70e844b8988Eric Anholt   GLboolean save_on_next_emit;
929adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   r200ScreenPtr r200Screen;	/* Screen private DRI data */
930ae4a1cc0666860bf5cc37a5cb549afc9aa5448b0Jon Smirl   drm_radeon_sarea_t *sarea;		/* Private SAREA data */
931adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
932adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* TCL stuff
933adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
934adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS];
935adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS];
936adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS];
93724a44d74b6e9880dfc019bd1cfa9ce0351377c85Roland Scheidegger   GLuint TexMatEnabled;
938adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint TexMatCompSel;
939adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint TexGenEnabled;
940adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint TexGenCompSel;
941adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLmatrix tmpmat;
942adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
943adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* VBI / buffer swap
944adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
945adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vbl_seq;
946adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint vblank_flags;
947adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
948afa446db83ecf5dcb38ce46648fb12911628de32Ian Romanick   int64_t swap_ust;
949afa446db83ecf5dcb38ce46648fb12911628de32Ian Romanick   int64_t swap_missed_ust;
950adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
951adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint swap_count;
952adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   GLuint swap_missed_count;
953adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
954adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
955adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* r200_tcl.c
956adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
957adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_tcl_info tcl;
958adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
959adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* r200_swtcl.c
960adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
961adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_swtcl_info swtcl;
962adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
963adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* r200_vtxfmt.c
964adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
965adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_vbinfo vb;
966adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
967adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   /* Mirrors of some DRI state
968adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell    */
969adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   struct r200_dri_mirror dri;
970bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl
971bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl   /* Configuration cache
972bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl    */
973bcc6eddd335e97d49ed2ef3a1440f94d58dce12dJon Smirl   driOptionCache optionCache;
974b31b7836d6e7abf80dd4feacce333d4b1fe6e4abRoland Scheidegger
975b31b7836d6e7abf80dd4feacce333d4b1fe6e4abRoland Scheidegger   GLboolean using_hyperz;
9764837ea30208d002bc36a836d2117f826d40c8bfaRoland Scheidegger   GLboolean texmicrotile;
977f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger
978f20917de5bd2b1fc152e74304d3649a1f6042422Roland Scheidegger  struct ati_fragment_shader *afs_loaded;
979adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell};
980adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
981adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define R200_CONTEXT(ctx)		((r200ContextPtr)(ctx->DriverCtx))
982adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
983adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
984adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellstatic __inline GLuint r200PackColor( GLuint cpp,
985adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					GLubyte r, GLubyte g,
986adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell					GLubyte b, GLubyte a )
987adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell{
988adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   switch ( cpp ) {
989adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   case 2:
990adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell      return PACK_COLOR_565( r, g, b );
991adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   case 4:
992adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell      return PACK_COLOR_8888( a, r, g, b );
993adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   default:
994adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell      return 0;
995adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell   }
996adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell}
997adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
998adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
999adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellextern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
1000adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellextern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
1001adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				    __DRIcontextPrivate *driContextPriv,
1002adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				    void *sharedContextPrivate);
1003adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellextern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
1004adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellextern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
1005adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				  __DRIdrawablePrivate *driDrawPriv,
1006adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell				  __DRIdrawablePrivate *driReadPriv );
1007adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellextern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv );
1008adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
1009adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell/* ================================================================
1010adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell * Debugging:
1011adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell */
1012adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DO_DEBUG		1
1013adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
1014adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#if DO_DEBUG
1015adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwellextern int R200_DEBUG;
1016adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#else
1017adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define R200_DEBUG		0
1018adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#endif
1019adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
1020adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_TEXTURE	0x001
1021adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_STATE	0x002
1022adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_IOCTL	0x004
1023adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_PRIMS	0x008
1024adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_VERTS	0x010
1025adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_FALLBACKS	0x020
1026adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_VFMT	0x040
1027adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_CODEGEN	0x080
1028adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_VERBOSE	0x100
1029adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_DRI       0x200
1030adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_DMA       0x400
1031adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_SANITY    0x800
1032adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_SYNC      0x1000
1033adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_PIXEL     0x2000
1034adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#define DEBUG_MEMORY    0x4000
1035adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell
1036adbec39bbf671ad80f6c557801e274cac0d305faKeith Whitwell#endif /* __R200_CONTEXT_H__ */
1037