xref: /linux/drivers/gpu/drm/radeon/r300_reg.h (revision c0e09200dc0813972442e550a5905a132768e56c)
1*c0e09200SDave Airlie /**************************************************************************
2*c0e09200SDave Airlie 
3*c0e09200SDave Airlie Copyright (C) 2004-2005 Nicolai Haehnle et al.
4*c0e09200SDave Airlie 
5*c0e09200SDave Airlie Permission is hereby granted, free of charge, to any person obtaining a
6*c0e09200SDave Airlie copy of this software and associated documentation files (the "Software"),
7*c0e09200SDave Airlie to deal in the Software without restriction, including without limitation
8*c0e09200SDave Airlie on the rights to use, copy, modify, merge, publish, distribute, sub
9*c0e09200SDave Airlie license, and/or sell copies of the Software, and to permit persons to whom
10*c0e09200SDave Airlie the Software is furnished to do so, subject to the following conditions:
11*c0e09200SDave Airlie 
12*c0e09200SDave Airlie The above copyright notice and this permission notice (including the next
13*c0e09200SDave Airlie paragraph) shall be included in all copies or substantial portions of the
14*c0e09200SDave Airlie Software.
15*c0e09200SDave Airlie 
16*c0e09200SDave Airlie THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*c0e09200SDave Airlie IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*c0e09200SDave Airlie FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19*c0e09200SDave Airlie THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20*c0e09200SDave Airlie DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21*c0e09200SDave Airlie OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22*c0e09200SDave Airlie USE OR OTHER DEALINGS IN THE SOFTWARE.
23*c0e09200SDave Airlie 
24*c0e09200SDave Airlie **************************************************************************/
25*c0e09200SDave Airlie 
26*c0e09200SDave Airlie #ifndef _R300_REG_H
27*c0e09200SDave Airlie #define _R300_REG_H
28*c0e09200SDave Airlie 
29*c0e09200SDave Airlie #define R300_MC_INIT_MISC_LAT_TIMER	0x180
30*c0e09200SDave Airlie #	define R300_MC_MISC__MC_CPR_INIT_LAT_SHIFT	0
31*c0e09200SDave Airlie #	define R300_MC_MISC__MC_VF_INIT_LAT_SHIFT	4
32*c0e09200SDave Airlie #	define R300_MC_MISC__MC_DISP0R_INIT_LAT_SHIFT	8
33*c0e09200SDave Airlie #	define R300_MC_MISC__MC_DISP1R_INIT_LAT_SHIFT	12
34*c0e09200SDave Airlie #	define R300_MC_MISC__MC_FIXED_INIT_LAT_SHIFT	16
35*c0e09200SDave Airlie #	define R300_MC_MISC__MC_E2R_INIT_LAT_SHIFT	20
36*c0e09200SDave Airlie #	define R300_MC_MISC__MC_SAME_PAGE_PRIO_SHIFT	24
37*c0e09200SDave Airlie #	define R300_MC_MISC__MC_GLOBW_INIT_LAT_SHIFT	28
38*c0e09200SDave Airlie 
39*c0e09200SDave Airlie #define R300_MC_INIT_GFX_LAT_TIMER	0x154
40*c0e09200SDave Airlie #	define R300_MC_MISC__MC_G3D0R_INIT_LAT_SHIFT	0
41*c0e09200SDave Airlie #	define R300_MC_MISC__MC_G3D1R_INIT_LAT_SHIFT	4
42*c0e09200SDave Airlie #	define R300_MC_MISC__MC_G3D2R_INIT_LAT_SHIFT	8
43*c0e09200SDave Airlie #	define R300_MC_MISC__MC_G3D3R_INIT_LAT_SHIFT	12
44*c0e09200SDave Airlie #	define R300_MC_MISC__MC_TX0R_INIT_LAT_SHIFT	16
45*c0e09200SDave Airlie #	define R300_MC_MISC__MC_TX1R_INIT_LAT_SHIFT	20
46*c0e09200SDave Airlie #	define R300_MC_MISC__MC_GLOBR_INIT_LAT_SHIFT	24
47*c0e09200SDave Airlie #	define R300_MC_MISC__MC_GLOBW_FULL_LAT_SHIFT	28
48*c0e09200SDave Airlie 
49*c0e09200SDave Airlie /*
50*c0e09200SDave Airlie  * This file contains registers and constants for the R300. They have been
51*c0e09200SDave Airlie  * found mostly by examining command buffers captured using glxtest, as well
52*c0e09200SDave Airlie  * as by extrapolating some known registers and constants from the R200.
53*c0e09200SDave Airlie  * I am fairly certain that they are correct unless stated otherwise
54*c0e09200SDave Airlie  * in comments.
55*c0e09200SDave Airlie  */
56*c0e09200SDave Airlie 
57*c0e09200SDave Airlie #define R300_SE_VPORT_XSCALE                0x1D98
58*c0e09200SDave Airlie #define R300_SE_VPORT_XOFFSET               0x1D9C
59*c0e09200SDave Airlie #define R300_SE_VPORT_YSCALE                0x1DA0
60*c0e09200SDave Airlie #define R300_SE_VPORT_YOFFSET               0x1DA4
61*c0e09200SDave Airlie #define R300_SE_VPORT_ZSCALE                0x1DA8
62*c0e09200SDave Airlie #define R300_SE_VPORT_ZOFFSET               0x1DAC
63*c0e09200SDave Airlie 
64*c0e09200SDave Airlie 
65*c0e09200SDave Airlie /*
66*c0e09200SDave Airlie  * Vertex Array Processing (VAP) Control
67*c0e09200SDave Airlie  * Stolen from r200 code from Christoph Brill (It's a guess!)
68*c0e09200SDave Airlie  */
69*c0e09200SDave Airlie #define R300_VAP_CNTL	0x2080
70*c0e09200SDave Airlie 
71*c0e09200SDave Airlie /* This register is written directly and also starts data section
72*c0e09200SDave Airlie  * in many 3d CP_PACKET3's
73*c0e09200SDave Airlie  */
74*c0e09200SDave Airlie #define R300_VAP_VF_CNTL	0x2084
75*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PRIM_TYPE__SHIFT              0
76*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_NONE                     (0<<0)
77*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_POINTS                   (1<<0)
78*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_LINES                    (2<<0)
79*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_LINE_STRIP               (3<<0)
80*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_TRIANGLES                (4<<0)
81*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN             (5<<0)
82*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP           (6<<0)
83*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_LINE_LOOP                (12<<0)
84*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_QUADS                    (13<<0)
85*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_QUAD_STRIP               (14<<0)
86*c0e09200SDave Airlie #	define  R300_VAP_VF_CNTL__PRIM_POLYGON                  (15<<0)
87*c0e09200SDave Airlie 
88*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PRIM_WALK__SHIFT              4
89*c0e09200SDave Airlie 	/* State based - direct writes to registers trigger vertex
90*c0e09200SDave Airlie            generation */
91*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PRIM_WALK_STATE_BASED         (0<<4)
92*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PRIM_WALK_INDICES             (1<<4)
93*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST         (2<<4)
94*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED     (3<<4)
95*c0e09200SDave Airlie 
96*c0e09200SDave Airlie 	/* I don't think I saw these three used.. */
97*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__COLOR_ORDER__SHIFT            6
98*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__TCL_OUTPUT_CTL_ENA__SHIFT     9
99*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__PROG_STREAM_ENA__SHIFT        10
100*c0e09200SDave Airlie 
101*c0e09200SDave Airlie 	/* index size - when not set the indices are assumed to be 16 bit */
102*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__INDEX_SIZE_32bit              (1<<11)
103*c0e09200SDave Airlie 	/* number of vertices */
104*c0e09200SDave Airlie #	define	R300_VAP_VF_CNTL__NUM_VERTICES__SHIFT           16
105*c0e09200SDave Airlie 
106*c0e09200SDave Airlie /* BEGIN: Wild guesses */
107*c0e09200SDave Airlie #define R300_VAP_OUTPUT_VTX_FMT_0           0x2090
108*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT     (1<<0)
109*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT   (1<<1)
110*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2)  /* GUESS */
111*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3)  /* GUESS */
112*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4)  /* GUESS */
113*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
114*c0e09200SDave Airlie 
115*c0e09200SDave Airlie #define R300_VAP_OUTPUT_VTX_FMT_1           0x2094
116*c0e09200SDave Airlie 	/* each of the following is 3 bits wide, specifies number
117*c0e09200SDave Airlie 	   of components */
118*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
119*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
120*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
121*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
122*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
123*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
124*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
125*c0e09200SDave Airlie #       define R300_VAP_OUTPUT_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
126*c0e09200SDave Airlie /* END: Wild guesses */
127*c0e09200SDave Airlie 
128*c0e09200SDave Airlie #define R300_SE_VTE_CNTL                  0x20b0
129*c0e09200SDave Airlie #	define     R300_VPORT_X_SCALE_ENA                0x00000001
130*c0e09200SDave Airlie #	define     R300_VPORT_X_OFFSET_ENA               0x00000002
131*c0e09200SDave Airlie #	define     R300_VPORT_Y_SCALE_ENA                0x00000004
132*c0e09200SDave Airlie #	define     R300_VPORT_Y_OFFSET_ENA               0x00000008
133*c0e09200SDave Airlie #	define     R300_VPORT_Z_SCALE_ENA                0x00000010
134*c0e09200SDave Airlie #	define     R300_VPORT_Z_OFFSET_ENA               0x00000020
135*c0e09200SDave Airlie #	define     R300_VTX_XY_FMT                       0x00000100
136*c0e09200SDave Airlie #	define     R300_VTX_Z_FMT                        0x00000200
137*c0e09200SDave Airlie #	define     R300_VTX_W0_FMT                       0x00000400
138*c0e09200SDave Airlie #	define     R300_VTX_W0_NORMALIZE                 0x00000800
139*c0e09200SDave Airlie #	define     R300_VTX_ST_DENORMALIZED              0x00001000
140*c0e09200SDave Airlie 
141*c0e09200SDave Airlie /* BEGIN: Vertex data assembly - lots of uncertainties */
142*c0e09200SDave Airlie 
143*c0e09200SDave Airlie /* gap */
144*c0e09200SDave Airlie 
145*c0e09200SDave Airlie #define R300_VAP_CNTL_STATUS              0x2140
146*c0e09200SDave Airlie #	define R300_VC_NO_SWAP                  (0 << 0)
147*c0e09200SDave Airlie #	define R300_VC_16BIT_SWAP               (1 << 0)
148*c0e09200SDave Airlie #	define R300_VC_32BIT_SWAP               (2 << 0)
149*c0e09200SDave Airlie #	define R300_VAP_TCL_BYPASS		(1 << 8)
150*c0e09200SDave Airlie 
151*c0e09200SDave Airlie /* gap */
152*c0e09200SDave Airlie 
153*c0e09200SDave Airlie /* Where do we get our vertex data?
154*c0e09200SDave Airlie  *
155*c0e09200SDave Airlie  * Vertex data either comes either from immediate mode registers or from
156*c0e09200SDave Airlie  * vertex arrays.
157*c0e09200SDave Airlie  * There appears to be no mixed mode (though we can force the pitch of
158*c0e09200SDave Airlie  * vertex arrays to 0, effectively reusing the same element over and over
159*c0e09200SDave Airlie  * again).
160*c0e09200SDave Airlie  *
161*c0e09200SDave Airlie  * Immediate mode is controlled by the INPUT_CNTL registers. I am not sure
162*c0e09200SDave Airlie  * if these registers influence vertex array processing.
163*c0e09200SDave Airlie  *
164*c0e09200SDave Airlie  * Vertex arrays are controlled via the 3D_LOAD_VBPNTR packet3.
165*c0e09200SDave Airlie  *
166*c0e09200SDave Airlie  * In both cases, vertex attributes are then passed through INPUT_ROUTE.
167*c0e09200SDave Airlie  *
168*c0e09200SDave Airlie  * Beginning with INPUT_ROUTE_0_0 is a list of WORDs that route vertex data
169*c0e09200SDave Airlie  * into the vertex processor's input registers.
170*c0e09200SDave Airlie  * The first word routes the first input, the second word the second, etc.
171*c0e09200SDave Airlie  * The corresponding input is routed into the register with the given index.
172*c0e09200SDave Airlie  * The list is ended by a word with INPUT_ROUTE_END set.
173*c0e09200SDave Airlie  *
174*c0e09200SDave Airlie  * Always set COMPONENTS_4 in immediate mode.
175*c0e09200SDave Airlie  */
176*c0e09200SDave Airlie 
177*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_0            0x2150
178*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_COMPONENTS_1     (0 << 0)
179*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_COMPONENTS_2     (1 << 0)
180*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_COMPONENTS_3     (2 << 0)
181*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_COMPONENTS_4     (3 << 0)
182*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_COMPONENTS_RGBA  (4 << 0) /* GUESS */
183*c0e09200SDave Airlie #       define R300_VAP_INPUT_ROUTE_IDX_SHIFT    8
184*c0e09200SDave Airlie #       define R300_VAP_INPUT_ROUTE_IDX_MASK     (31 << 8) /* GUESS */
185*c0e09200SDave Airlie #       define R300_VAP_INPUT_ROUTE_END          (1 << 13)
186*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_IMMEDIATE_MODE   (0 << 14) /* GUESS */
187*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_FLOAT            (1 << 14) /* GUESS */
188*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_UNSIGNED_BYTE    (2 << 14) /* GUESS */
189*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_FLOAT_COLOR      (3 << 14) /* GUESS */
190*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_1            0x2154
191*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_2            0x2158
192*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_3            0x215C
193*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_4            0x2160
194*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_5            0x2164
195*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_6            0x2168
196*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_0_7            0x216C
197*c0e09200SDave Airlie 
198*c0e09200SDave Airlie /* gap */
199*c0e09200SDave Airlie 
200*c0e09200SDave Airlie /* Notes:
201*c0e09200SDave Airlie  *  - always set up to produce at least two attributes:
202*c0e09200SDave Airlie  *    if vertex program uses only position, fglrx will set normal, too
203*c0e09200SDave Airlie  *  - INPUT_CNTL_0_COLOR and INPUT_CNTL_COLOR bits are always equal.
204*c0e09200SDave Airlie  */
205*c0e09200SDave Airlie #define R300_VAP_INPUT_CNTL_0               0x2180
206*c0e09200SDave Airlie #       define R300_INPUT_CNTL_0_COLOR           0x00000001
207*c0e09200SDave Airlie #define R300_VAP_INPUT_CNTL_1               0x2184
208*c0e09200SDave Airlie #       define R300_INPUT_CNTL_POS               0x00000001
209*c0e09200SDave Airlie #       define R300_INPUT_CNTL_NORMAL            0x00000002
210*c0e09200SDave Airlie #       define R300_INPUT_CNTL_COLOR             0x00000004
211*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC0               0x00000400
212*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC1               0x00000800
213*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC2               0x00001000 /* GUESS */
214*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC3               0x00002000 /* GUESS */
215*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC4               0x00004000 /* GUESS */
216*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC5               0x00008000 /* GUESS */
217*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC6               0x00010000 /* GUESS */
218*c0e09200SDave Airlie #       define R300_INPUT_CNTL_TC7               0x00020000 /* GUESS */
219*c0e09200SDave Airlie 
220*c0e09200SDave Airlie /* gap */
221*c0e09200SDave Airlie 
222*c0e09200SDave Airlie /* Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
223*c0e09200SDave Airlie  * are set to a swizzling bit pattern, other words are 0.
224*c0e09200SDave Airlie  *
225*c0e09200SDave Airlie  * In immediate mode, the pattern is always set to xyzw. In vertex array
226*c0e09200SDave Airlie  * mode, the swizzling pattern is e.g. used to set zw components in texture
227*c0e09200SDave Airlie  * coordinates with only tweo components.
228*c0e09200SDave Airlie  */
229*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_0            0x21E0
230*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_X    0
231*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_Y    1
232*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_Z    2
233*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_W    3
234*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_ZERO 4
235*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_ONE  5
236*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_SELECT_MASK 7
237*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_X_SHIFT     0
238*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_Y_SHIFT     3
239*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_Z_SHIFT     6
240*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_W_SHIFT     9
241*c0e09200SDave Airlie #       define R300_INPUT_ROUTE_ENABLE      (15 << 12)
242*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_1            0x21E4
243*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_2            0x21E8
244*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_3            0x21EC
245*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_4            0x21F0
246*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_5            0x21F4
247*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_6            0x21F8
248*c0e09200SDave Airlie #define R300_VAP_INPUT_ROUTE_1_7            0x21FC
249*c0e09200SDave Airlie 
250*c0e09200SDave Airlie /* END: Vertex data assembly */
251*c0e09200SDave Airlie 
252*c0e09200SDave Airlie /* gap */
253*c0e09200SDave Airlie 
254*c0e09200SDave Airlie /* BEGIN: Upload vertex program and data */
255*c0e09200SDave Airlie 
256*c0e09200SDave Airlie /*
257*c0e09200SDave Airlie  * The programmable vertex shader unit has a memory bank of unknown size
258*c0e09200SDave Airlie  * that can be written to in 16 byte units by writing the address into
259*c0e09200SDave Airlie  * UPLOAD_ADDRESS, followed by data in UPLOAD_DATA (multiples of 4 DWORDs).
260*c0e09200SDave Airlie  *
261*c0e09200SDave Airlie  * Pointers into the memory bank are always in multiples of 16 bytes.
262*c0e09200SDave Airlie  *
263*c0e09200SDave Airlie  * The memory bank is divided into areas with fixed meaning.
264*c0e09200SDave Airlie  *
265*c0e09200SDave Airlie  * Starting at address UPLOAD_PROGRAM: Vertex program instructions.
266*c0e09200SDave Airlie  * Native limits reported by drivers from ATI suggest size 256 (i.e. 4KB),
267*c0e09200SDave Airlie  * whereas the difference between known addresses suggests size 512.
268*c0e09200SDave Airlie  *
269*c0e09200SDave Airlie  * Starting at address UPLOAD_PARAMETERS: Vertex program parameters.
270*c0e09200SDave Airlie  * Native reported limits and the VPI layout suggest size 256, whereas
271*c0e09200SDave Airlie  * difference between known addresses suggests size 512.
272*c0e09200SDave Airlie  *
273*c0e09200SDave Airlie  * At address UPLOAD_POINTSIZE is a vector (0, 0, ps, 0), where ps is the
274*c0e09200SDave Airlie  * floating point pointsize. The exact purpose of this state is uncertain,
275*c0e09200SDave Airlie  * as there is also the R300_RE_POINTSIZE register.
276*c0e09200SDave Airlie  *
277*c0e09200SDave Airlie  * Multiple vertex programs and parameter sets can be loaded at once,
278*c0e09200SDave Airlie  * which could explain the size discrepancy.
279*c0e09200SDave Airlie  */
280*c0e09200SDave Airlie #define R300_VAP_PVS_UPLOAD_ADDRESS         0x2200
281*c0e09200SDave Airlie #       define R300_PVS_UPLOAD_PROGRAM           0x00000000
282*c0e09200SDave Airlie #       define R300_PVS_UPLOAD_PARAMETERS        0x00000200
283*c0e09200SDave Airlie #       define R300_PVS_UPLOAD_POINTSIZE         0x00000406
284*c0e09200SDave Airlie 
285*c0e09200SDave Airlie /* gap */
286*c0e09200SDave Airlie 
287*c0e09200SDave Airlie #define R300_VAP_PVS_UPLOAD_DATA            0x2208
288*c0e09200SDave Airlie 
289*c0e09200SDave Airlie /* END: Upload vertex program and data */
290*c0e09200SDave Airlie 
291*c0e09200SDave Airlie /* gap */
292*c0e09200SDave Airlie 
293*c0e09200SDave Airlie /* I do not know the purpose of this register. However, I do know that
294*c0e09200SDave Airlie  * it is set to 221C_CLEAR for clear operations and to 221C_NORMAL
295*c0e09200SDave Airlie  * for normal rendering.
296*c0e09200SDave Airlie  */
297*c0e09200SDave Airlie #define R300_VAP_UNKNOWN_221C               0x221C
298*c0e09200SDave Airlie #       define R300_221C_NORMAL                  0x00000000
299*c0e09200SDave Airlie #       define R300_221C_CLEAR                   0x0001C000
300*c0e09200SDave Airlie 
301*c0e09200SDave Airlie /* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
302*c0e09200SDave Airlie  * plane is per-pixel and the second plane is per-vertex.
303*c0e09200SDave Airlie  *
304*c0e09200SDave Airlie  * This was determined by experimentation alone but I believe it is correct.
305*c0e09200SDave Airlie  *
306*c0e09200SDave Airlie  * These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
307*c0e09200SDave Airlie  */
308*c0e09200SDave Airlie #define R300_VAP_CLIP_X_0                   0x2220
309*c0e09200SDave Airlie #define R300_VAP_CLIP_X_1                   0x2224
310*c0e09200SDave Airlie #define R300_VAP_CLIP_Y_0                   0x2228
311*c0e09200SDave Airlie #define R300_VAP_CLIP_Y_1                   0x2230
312*c0e09200SDave Airlie 
313*c0e09200SDave Airlie /* gap */
314*c0e09200SDave Airlie 
315*c0e09200SDave Airlie /* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
316*c0e09200SDave Airlie  * rendering commands and overwriting vertex program parameters.
317*c0e09200SDave Airlie  * Therefore, I suspect writing zero to 0x2284 synchronizes the engine and
318*c0e09200SDave Airlie  * avoids bugs caused by still running shaders reading bad data from memory.
319*c0e09200SDave Airlie  */
320*c0e09200SDave Airlie #define R300_VAP_PVS_WAITIDLE               0x2284 /* GUESS */
321*c0e09200SDave Airlie 
322*c0e09200SDave Airlie /* Absolutely no clue what this register is about. */
323*c0e09200SDave Airlie #define R300_VAP_UNKNOWN_2288               0x2288
324*c0e09200SDave Airlie #       define R300_2288_R300                    0x00750000 /* -- nh */
325*c0e09200SDave Airlie #       define R300_2288_RV350                   0x0000FFFF /* -- Vladimir */
326*c0e09200SDave Airlie 
327*c0e09200SDave Airlie /* gap */
328*c0e09200SDave Airlie 
329*c0e09200SDave Airlie /* Addresses are relative to the vertex program instruction area of the
330*c0e09200SDave Airlie  * memory bank. PROGRAM_END points to the last instruction of the active
331*c0e09200SDave Airlie  * program
332*c0e09200SDave Airlie  *
333*c0e09200SDave Airlie  * The meaning of the two UNKNOWN fields is obviously not known. However,
334*c0e09200SDave Airlie  * experiments so far have shown that both *must* point to an instruction
335*c0e09200SDave Airlie  * inside the vertex program, otherwise the GPU locks up.
336*c0e09200SDave Airlie  *
337*c0e09200SDave Airlie  * fglrx usually sets CNTL_3_UNKNOWN to the end of the program and
338*c0e09200SDave Airlie  * R300_PVS_CNTL_1_POS_END_SHIFT points to instruction where last write to
339*c0e09200SDave Airlie  * position takes place.
340*c0e09200SDave Airlie  *
341*c0e09200SDave Airlie  * Most likely this is used to ignore rest of the program in cases
342*c0e09200SDave Airlie  * where group of verts arent visible. For some reason this "section"
343*c0e09200SDave Airlie  * is sometimes accepted other instruction that have no relationship with
344*c0e09200SDave Airlie  * position calculations.
345*c0e09200SDave Airlie  */
346*c0e09200SDave Airlie #define R300_VAP_PVS_CNTL_1                 0x22D0
347*c0e09200SDave Airlie #       define R300_PVS_CNTL_1_PROGRAM_START_SHIFT   0
348*c0e09200SDave Airlie #       define R300_PVS_CNTL_1_POS_END_SHIFT         10
349*c0e09200SDave Airlie #       define R300_PVS_CNTL_1_PROGRAM_END_SHIFT     20
350*c0e09200SDave Airlie /* Addresses are relative the the vertex program parameters area. */
351*c0e09200SDave Airlie #define R300_VAP_PVS_CNTL_2                 0x22D4
352*c0e09200SDave Airlie #       define R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0
353*c0e09200SDave Airlie #       define R300_PVS_CNTL_2_PARAM_COUNT_SHIFT  16
354*c0e09200SDave Airlie #define R300_VAP_PVS_CNTL_3	           0x22D8
355*c0e09200SDave Airlie #       define R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT 10
356*c0e09200SDave Airlie #       define R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT 0
357*c0e09200SDave Airlie 
358*c0e09200SDave Airlie /* The entire range from 0x2300 to 0x2AC inclusive seems to be used for
359*c0e09200SDave Airlie  * immediate vertices
360*c0e09200SDave Airlie  */
361*c0e09200SDave Airlie #define R300_VAP_VTX_COLOR_R                0x2464
362*c0e09200SDave Airlie #define R300_VAP_VTX_COLOR_G                0x2468
363*c0e09200SDave Airlie #define R300_VAP_VTX_COLOR_B                0x246C
364*c0e09200SDave Airlie #define R300_VAP_VTX_POS_0_X_1              0x2490 /* used for glVertex2*() */
365*c0e09200SDave Airlie #define R300_VAP_VTX_POS_0_Y_1              0x2494
366*c0e09200SDave Airlie #define R300_VAP_VTX_COLOR_PKD              0x249C /* RGBA */
367*c0e09200SDave Airlie #define R300_VAP_VTX_POS_0_X_2              0x24A0 /* used for glVertex3*() */
368*c0e09200SDave Airlie #define R300_VAP_VTX_POS_0_Y_2              0x24A4
369*c0e09200SDave Airlie #define R300_VAP_VTX_POS_0_Z_2              0x24A8
370*c0e09200SDave Airlie /* write 0 to indicate end of packet? */
371*c0e09200SDave Airlie #define R300_VAP_VTX_END_OF_PKT             0x24AC
372*c0e09200SDave Airlie 
373*c0e09200SDave Airlie /* gap */
374*c0e09200SDave Airlie 
375*c0e09200SDave Airlie /* These are values from r300_reg/r300_reg.h - they are known to be correct
376*c0e09200SDave Airlie  * and are here so we can use one register file instead of several
377*c0e09200SDave Airlie  * - Vladimir
378*c0e09200SDave Airlie  */
379*c0e09200SDave Airlie #define R300_GB_VAP_RASTER_VTX_FMT_0	0x4000
380*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__POS_PRESENT	(1<<0)
381*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_0_PRESENT	(1<<1)
382*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_1_PRESENT	(1<<2)
383*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_2_PRESENT	(1<<3)
384*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_3_PRESENT	(1<<4)
385*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_SPACE	(0xf<<5)
386*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_0__PT_SIZE_PRESENT	(0x1<<16)
387*c0e09200SDave Airlie 
388*c0e09200SDave Airlie #define R300_GB_VAP_RASTER_VTX_FMT_1	0x4004
389*c0e09200SDave Airlie 	/* each of the following is 3 bits wide, specifies number
390*c0e09200SDave Airlie 	   of components */
391*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT	0
392*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT	3
393*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT	6
394*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT	9
395*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT	12
396*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT	15
397*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT	18
398*c0e09200SDave Airlie #	define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT	21
399*c0e09200SDave Airlie 
400*c0e09200SDave Airlie /* UNK30 seems to enables point to quad transformation on textures
401*c0e09200SDave Airlie  * (or something closely related to that).
402*c0e09200SDave Airlie  * This bit is rather fatal at the time being due to lackings at pixel
403*c0e09200SDave Airlie  * shader side
404*c0e09200SDave Airlie  */
405*c0e09200SDave Airlie #define R300_GB_ENABLE	0x4008
406*c0e09200SDave Airlie #	define R300_GB_POINT_STUFF_ENABLE	(1<<0)
407*c0e09200SDave Airlie #	define R300_GB_LINE_STUFF_ENABLE	(1<<1)
408*c0e09200SDave Airlie #	define R300_GB_TRIANGLE_STUFF_ENABLE	(1<<2)
409*c0e09200SDave Airlie #	define R300_GB_STENCIL_AUTO_ENABLE	(1<<4)
410*c0e09200SDave Airlie #	define R300_GB_UNK31			(1<<31)
411*c0e09200SDave Airlie 	/* each of the following is 2 bits wide */
412*c0e09200SDave Airlie #define R300_GB_TEX_REPLICATE	0
413*c0e09200SDave Airlie #define R300_GB_TEX_ST		1
414*c0e09200SDave Airlie #define R300_GB_TEX_STR		2
415*c0e09200SDave Airlie #	define R300_GB_TEX0_SOURCE_SHIFT	16
416*c0e09200SDave Airlie #	define R300_GB_TEX1_SOURCE_SHIFT	18
417*c0e09200SDave Airlie #	define R300_GB_TEX2_SOURCE_SHIFT	20
418*c0e09200SDave Airlie #	define R300_GB_TEX3_SOURCE_SHIFT	22
419*c0e09200SDave Airlie #	define R300_GB_TEX4_SOURCE_SHIFT	24
420*c0e09200SDave Airlie #	define R300_GB_TEX5_SOURCE_SHIFT	26
421*c0e09200SDave Airlie #	define R300_GB_TEX6_SOURCE_SHIFT	28
422*c0e09200SDave Airlie #	define R300_GB_TEX7_SOURCE_SHIFT	30
423*c0e09200SDave Airlie 
424*c0e09200SDave Airlie /* MSPOS - positions for multisample antialiasing (?) */
425*c0e09200SDave Airlie #define R300_GB_MSPOS0	0x4010
426*c0e09200SDave Airlie 	/* shifts - each of the fields is 4 bits */
427*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MS_X0_SHIFT	0
428*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MS_Y0_SHIFT	4
429*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MS_X1_SHIFT	8
430*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MS_Y1_SHIFT	12
431*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MS_X2_SHIFT	16
432*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MS_Y2_SHIFT	20
433*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MSBD0_Y		24
434*c0e09200SDave Airlie #	define R300_GB_MSPOS0__MSBD0_X		28
435*c0e09200SDave Airlie 
436*c0e09200SDave Airlie #define R300_GB_MSPOS1	0x4014
437*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MS_X3_SHIFT	0
438*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MS_Y3_SHIFT	4
439*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MS_X4_SHIFT	8
440*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MS_Y4_SHIFT	12
441*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MS_X5_SHIFT	16
442*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MS_Y5_SHIFT	20
443*c0e09200SDave Airlie #	define R300_GB_MSPOS1__MSBD1		24
444*c0e09200SDave Airlie 
445*c0e09200SDave Airlie 
446*c0e09200SDave Airlie #define R300_GB_TILE_CONFIG	0x4018
447*c0e09200SDave Airlie #	define R300_GB_TILE_ENABLE	(1<<0)
448*c0e09200SDave Airlie #	define R300_GB_TILE_PIPE_COUNT_RV300	0
449*c0e09200SDave Airlie #	define R300_GB_TILE_PIPE_COUNT_R300	(3<<1)
450*c0e09200SDave Airlie #	define R300_GB_TILE_PIPE_COUNT_R420	(7<<1)
451*c0e09200SDave Airlie #	define R300_GB_TILE_PIPE_COUNT_RV410	(3<<1)
452*c0e09200SDave Airlie #	define R300_GB_TILE_SIZE_8		0
453*c0e09200SDave Airlie #	define R300_GB_TILE_SIZE_16		(1<<4)
454*c0e09200SDave Airlie #	define R300_GB_TILE_SIZE_32		(2<<4)
455*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_1		(0<<6)
456*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_2		(1<<6)
457*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_4		(2<<6)
458*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_8		(3<<6)
459*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_16		(4<<6)
460*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_32		(5<<6)
461*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_64		(6<<6)
462*c0e09200SDave Airlie #	define R300_GB_SUPER_SIZE_128		(7<<6)
463*c0e09200SDave Airlie #	define R300_GB_SUPER_X_SHIFT		9	/* 3 bits wide */
464*c0e09200SDave Airlie #	define R300_GB_SUPER_Y_SHIFT		12	/* 3 bits wide */
465*c0e09200SDave Airlie #	define R300_GB_SUPER_TILE_A		0
466*c0e09200SDave Airlie #	define R300_GB_SUPER_TILE_B		(1<<15)
467*c0e09200SDave Airlie #	define R300_GB_SUBPIXEL_1_12		0
468*c0e09200SDave Airlie #	define R300_GB_SUBPIXEL_1_16		(1<<16)
469*c0e09200SDave Airlie 
470*c0e09200SDave Airlie #define R300_GB_FIFO_SIZE	0x4024
471*c0e09200SDave Airlie 	/* each of the following is 2 bits wide */
472*c0e09200SDave Airlie #define R300_GB_FIFO_SIZE_32	0
473*c0e09200SDave Airlie #define R300_GB_FIFO_SIZE_64	1
474*c0e09200SDave Airlie #define R300_GB_FIFO_SIZE_128	2
475*c0e09200SDave Airlie #define R300_GB_FIFO_SIZE_256	3
476*c0e09200SDave Airlie #	define R300_SC_IFIFO_SIZE_SHIFT	0
477*c0e09200SDave Airlie #	define R300_SC_TZFIFO_SIZE_SHIFT	2
478*c0e09200SDave Airlie #	define R300_SC_BFIFO_SIZE_SHIFT	4
479*c0e09200SDave Airlie 
480*c0e09200SDave Airlie #	define R300_US_OFIFO_SIZE_SHIFT	12
481*c0e09200SDave Airlie #	define R300_US_WFIFO_SIZE_SHIFT	14
482*c0e09200SDave Airlie 	/* the following use the same constants as above, but meaning is
483*c0e09200SDave Airlie 	   is times 2 (i.e. instead of 32 words it means 64 */
484*c0e09200SDave Airlie #	define R300_RS_TFIFO_SIZE_SHIFT	6
485*c0e09200SDave Airlie #	define R300_RS_CFIFO_SIZE_SHIFT	8
486*c0e09200SDave Airlie #	define R300_US_RAM_SIZE_SHIFT		10
487*c0e09200SDave Airlie 	/* watermarks, 3 bits wide */
488*c0e09200SDave Airlie #	define R300_RS_HIGHWATER_COL_SHIFT	16
489*c0e09200SDave Airlie #	define R300_RS_HIGHWATER_TEX_SHIFT	19
490*c0e09200SDave Airlie #	define R300_OFIFO_HIGHWATER_SHIFT	22	/* two bits only */
491*c0e09200SDave Airlie #	define R300_CUBE_FIFO_HIGHWATER_COL_SHIFT	24
492*c0e09200SDave Airlie 
493*c0e09200SDave Airlie #define R300_GB_SELECT	0x401C
494*c0e09200SDave Airlie #	define R300_GB_FOG_SELECT_C0A		0
495*c0e09200SDave Airlie #	define R300_GB_FOG_SELECT_C1A		1
496*c0e09200SDave Airlie #	define R300_GB_FOG_SELECT_C2A		2
497*c0e09200SDave Airlie #	define R300_GB_FOG_SELECT_C3A		3
498*c0e09200SDave Airlie #	define R300_GB_FOG_SELECT_1_1_W	4
499*c0e09200SDave Airlie #	define R300_GB_FOG_SELECT_Z		5
500*c0e09200SDave Airlie #	define R300_GB_DEPTH_SELECT_Z		0
501*c0e09200SDave Airlie #	define R300_GB_DEPTH_SELECT_1_1_W	(1<<3)
502*c0e09200SDave Airlie #	define R300_GB_W_SELECT_1_W		0
503*c0e09200SDave Airlie #	define R300_GB_W_SELECT_1		(1<<4)
504*c0e09200SDave Airlie 
505*c0e09200SDave Airlie #define R300_GB_AA_CONFIG		0x4020
506*c0e09200SDave Airlie #	define R300_AA_DISABLE			0x00
507*c0e09200SDave Airlie #	define R300_AA_ENABLE			0x01
508*c0e09200SDave Airlie #	define R300_AA_SUBSAMPLES_2		0
509*c0e09200SDave Airlie #	define R300_AA_SUBSAMPLES_3		(1<<1)
510*c0e09200SDave Airlie #	define R300_AA_SUBSAMPLES_4		(2<<1)
511*c0e09200SDave Airlie #	define R300_AA_SUBSAMPLES_6		(3<<1)
512*c0e09200SDave Airlie 
513*c0e09200SDave Airlie /* gap */
514*c0e09200SDave Airlie 
515*c0e09200SDave Airlie /* Zero to flush caches. */
516*c0e09200SDave Airlie #define R300_TX_CNTL                        0x4100
517*c0e09200SDave Airlie #define R300_TX_FLUSH                       0x0
518*c0e09200SDave Airlie 
519*c0e09200SDave Airlie /* The upper enable bits are guessed, based on fglrx reported limits. */
520*c0e09200SDave Airlie #define R300_TX_ENABLE                      0x4104
521*c0e09200SDave Airlie #       define R300_TX_ENABLE_0                  (1 << 0)
522*c0e09200SDave Airlie #       define R300_TX_ENABLE_1                  (1 << 1)
523*c0e09200SDave Airlie #       define R300_TX_ENABLE_2                  (1 << 2)
524*c0e09200SDave Airlie #       define R300_TX_ENABLE_3                  (1 << 3)
525*c0e09200SDave Airlie #       define R300_TX_ENABLE_4                  (1 << 4)
526*c0e09200SDave Airlie #       define R300_TX_ENABLE_5                  (1 << 5)
527*c0e09200SDave Airlie #       define R300_TX_ENABLE_6                  (1 << 6)
528*c0e09200SDave Airlie #       define R300_TX_ENABLE_7                  (1 << 7)
529*c0e09200SDave Airlie #       define R300_TX_ENABLE_8                  (1 << 8)
530*c0e09200SDave Airlie #       define R300_TX_ENABLE_9                  (1 << 9)
531*c0e09200SDave Airlie #       define R300_TX_ENABLE_10                 (1 << 10)
532*c0e09200SDave Airlie #       define R300_TX_ENABLE_11                 (1 << 11)
533*c0e09200SDave Airlie #       define R300_TX_ENABLE_12                 (1 << 12)
534*c0e09200SDave Airlie #       define R300_TX_ENABLE_13                 (1 << 13)
535*c0e09200SDave Airlie #       define R300_TX_ENABLE_14                 (1 << 14)
536*c0e09200SDave Airlie #       define R300_TX_ENABLE_15                 (1 << 15)
537*c0e09200SDave Airlie 
538*c0e09200SDave Airlie /* The pointsize is given in multiples of 6. The pointsize can be
539*c0e09200SDave Airlie  * enormous: Clear() renders a single point that fills the entire
540*c0e09200SDave Airlie  * framebuffer.
541*c0e09200SDave Airlie  */
542*c0e09200SDave Airlie #define R300_RE_POINTSIZE                   0x421C
543*c0e09200SDave Airlie #       define R300_POINTSIZE_Y_SHIFT            0
544*c0e09200SDave Airlie #       define R300_POINTSIZE_Y_MASK             (0xFFFF << 0) /* GUESS */
545*c0e09200SDave Airlie #       define R300_POINTSIZE_X_SHIFT            16
546*c0e09200SDave Airlie #       define R300_POINTSIZE_X_MASK             (0xFFFF << 16) /* GUESS */
547*c0e09200SDave Airlie #       define R300_POINTSIZE_MAX             (R300_POINTSIZE_Y_MASK / 6)
548*c0e09200SDave Airlie 
549*c0e09200SDave Airlie /* The line width is given in multiples of 6.
550*c0e09200SDave Airlie  * In default mode lines are classified as vertical lines.
551*c0e09200SDave Airlie  * HO: horizontal
552*c0e09200SDave Airlie  * VE: vertical or horizontal
553*c0e09200SDave Airlie  * HO & VE: no classification
554*c0e09200SDave Airlie  */
555*c0e09200SDave Airlie #define R300_RE_LINE_CNT                      0x4234
556*c0e09200SDave Airlie #       define R300_LINESIZE_SHIFT            0
557*c0e09200SDave Airlie #       define R300_LINESIZE_MASK             (0xFFFF << 0) /* GUESS */
558*c0e09200SDave Airlie #       define R300_LINESIZE_MAX             (R300_LINESIZE_MASK / 6)
559*c0e09200SDave Airlie #       define R300_LINE_CNT_HO               (1 << 16)
560*c0e09200SDave Airlie #       define R300_LINE_CNT_VE               (1 << 17)
561*c0e09200SDave Airlie 
562*c0e09200SDave Airlie /* Some sort of scale or clamp value for texcoordless textures. */
563*c0e09200SDave Airlie #define R300_RE_UNK4238                       0x4238
564*c0e09200SDave Airlie 
565*c0e09200SDave Airlie /* Something shade related */
566*c0e09200SDave Airlie #define R300_RE_SHADE                         0x4274
567*c0e09200SDave Airlie 
568*c0e09200SDave Airlie #define R300_RE_SHADE_MODEL                   0x4278
569*c0e09200SDave Airlie #	define R300_RE_SHADE_MODEL_SMOOTH     0x3aaaa
570*c0e09200SDave Airlie #	define R300_RE_SHADE_MODEL_FLAT       0x39595
571*c0e09200SDave Airlie 
572*c0e09200SDave Airlie /* Dangerous */
573*c0e09200SDave Airlie #define R300_RE_POLYGON_MODE                  0x4288
574*c0e09200SDave Airlie #	define R300_PM_ENABLED                (1 << 0)
575*c0e09200SDave Airlie #	define R300_PM_FRONT_POINT            (0 << 0)
576*c0e09200SDave Airlie #	define R300_PM_BACK_POINT             (0 << 0)
577*c0e09200SDave Airlie #	define R300_PM_FRONT_LINE             (1 << 4)
578*c0e09200SDave Airlie #	define R300_PM_FRONT_FILL             (1 << 5)
579*c0e09200SDave Airlie #	define R300_PM_BACK_LINE              (1 << 7)
580*c0e09200SDave Airlie #	define R300_PM_BACK_FILL              (1 << 8)
581*c0e09200SDave Airlie 
582*c0e09200SDave Airlie /* Fog parameters */
583*c0e09200SDave Airlie #define R300_RE_FOG_SCALE                     0x4294
584*c0e09200SDave Airlie #define R300_RE_FOG_START                     0x4298
585*c0e09200SDave Airlie 
586*c0e09200SDave Airlie /* Not sure why there are duplicate of factor and constant values.
587*c0e09200SDave Airlie  * My best guess so far is that there are separate zbiases for test and write.
588*c0e09200SDave Airlie  * Ordering might be wrong.
589*c0e09200SDave Airlie  * Some of the tests indicate that fgl has a fallback implementation of zbias
590*c0e09200SDave Airlie  * via pixel shaders.
591*c0e09200SDave Airlie  */
592*c0e09200SDave Airlie #define R300_RE_ZBIAS_CNTL                    0x42A0 /* GUESS */
593*c0e09200SDave Airlie #define R300_RE_ZBIAS_T_FACTOR                0x42A4
594*c0e09200SDave Airlie #define R300_RE_ZBIAS_T_CONSTANT              0x42A8
595*c0e09200SDave Airlie #define R300_RE_ZBIAS_W_FACTOR                0x42AC
596*c0e09200SDave Airlie #define R300_RE_ZBIAS_W_CONSTANT              0x42B0
597*c0e09200SDave Airlie 
598*c0e09200SDave Airlie /* This register needs to be set to (1<<1) for RV350 to correctly
599*c0e09200SDave Airlie  * perform depth test (see --vb-triangles in r300_demo)
600*c0e09200SDave Airlie  * Don't know about other chips. - Vladimir
601*c0e09200SDave Airlie  * This is set to 3 when GL_POLYGON_OFFSET_FILL is on.
602*c0e09200SDave Airlie  * My guess is that there are two bits for each zbias primitive
603*c0e09200SDave Airlie  * (FILL, LINE, POINT).
604*c0e09200SDave Airlie  *  One to enable depth test and one for depth write.
605*c0e09200SDave Airlie  * Yet this doesnt explain why depth writes work ...
606*c0e09200SDave Airlie  */
607*c0e09200SDave Airlie #define R300_RE_OCCLUSION_CNTL		    0x42B4
608*c0e09200SDave Airlie #	define R300_OCCLUSION_ON		(1<<1)
609*c0e09200SDave Airlie 
610*c0e09200SDave Airlie #define R300_RE_CULL_CNTL                   0x42B8
611*c0e09200SDave Airlie #       define R300_CULL_FRONT                   (1 << 0)
612*c0e09200SDave Airlie #       define R300_CULL_BACK                    (1 << 1)
613*c0e09200SDave Airlie #       define R300_FRONT_FACE_CCW               (0 << 2)
614*c0e09200SDave Airlie #       define R300_FRONT_FACE_CW                (1 << 2)
615*c0e09200SDave Airlie 
616*c0e09200SDave Airlie 
617*c0e09200SDave Airlie /* BEGIN: Rasterization / Interpolators - many guesses */
618*c0e09200SDave Airlie 
619*c0e09200SDave Airlie /* 0_UNKNOWN_18 has always been set except for clear operations.
620*c0e09200SDave Airlie  * TC_CNT is the number of incoming texture coordinate sets (i.e. it depends
621*c0e09200SDave Airlie  * on the vertex program, *not* the fragment program)
622*c0e09200SDave Airlie  */
623*c0e09200SDave Airlie #define R300_RS_CNTL_0                      0x4300
624*c0e09200SDave Airlie #       define R300_RS_CNTL_TC_CNT_SHIFT         2
625*c0e09200SDave Airlie #       define R300_RS_CNTL_TC_CNT_MASK          (7 << 2)
626*c0e09200SDave Airlie 	/* number of color interpolators used */
627*c0e09200SDave Airlie #	define R300_RS_CNTL_CI_CNT_SHIFT         7
628*c0e09200SDave Airlie #       define R300_RS_CNTL_0_UNKNOWN_18         (1 << 18)
629*c0e09200SDave Airlie 	/* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n
630*c0e09200SDave Airlie 	   register. */
631*c0e09200SDave Airlie #define R300_RS_CNTL_1                      0x4304
632*c0e09200SDave Airlie 
633*c0e09200SDave Airlie /* gap */
634*c0e09200SDave Airlie 
635*c0e09200SDave Airlie /* Only used for texture coordinates.
636*c0e09200SDave Airlie  * Use the source field to route texture coordinate input from the
637*c0e09200SDave Airlie  * vertex program to the desired interpolator. Note that the source
638*c0e09200SDave Airlie  * field is relative to the outputs the vertex program *actually*
639*c0e09200SDave Airlie  * writes. If a vertex program only writes texcoord[1], this will
640*c0e09200SDave Airlie  * be source index 0.
641*c0e09200SDave Airlie  * Set INTERP_USED on all interpolators that produce data used by
642*c0e09200SDave Airlie  * the fragment program. INTERP_USED looks like a swizzling mask,
643*c0e09200SDave Airlie  * but I haven't seen it used that way.
644*c0e09200SDave Airlie  *
645*c0e09200SDave Airlie  * Note: The _UNKNOWN constants are always set in their respective
646*c0e09200SDave Airlie  * register. I don't know if this is necessary.
647*c0e09200SDave Airlie  */
648*c0e09200SDave Airlie #define R300_RS_INTERP_0                    0x4310
649*c0e09200SDave Airlie #define R300_RS_INTERP_1                    0x4314
650*c0e09200SDave Airlie #       define R300_RS_INTERP_1_UNKNOWN          0x40
651*c0e09200SDave Airlie #define R300_RS_INTERP_2                    0x4318
652*c0e09200SDave Airlie #       define R300_RS_INTERP_2_UNKNOWN          0x80
653*c0e09200SDave Airlie #define R300_RS_INTERP_3                    0x431C
654*c0e09200SDave Airlie #       define R300_RS_INTERP_3_UNKNOWN          0xC0
655*c0e09200SDave Airlie #define R300_RS_INTERP_4                    0x4320
656*c0e09200SDave Airlie #define R300_RS_INTERP_5                    0x4324
657*c0e09200SDave Airlie #define R300_RS_INTERP_6                    0x4328
658*c0e09200SDave Airlie #define R300_RS_INTERP_7                    0x432C
659*c0e09200SDave Airlie #       define R300_RS_INTERP_SRC_SHIFT          2
660*c0e09200SDave Airlie #       define R300_RS_INTERP_SRC_MASK           (7 << 2)
661*c0e09200SDave Airlie #       define R300_RS_INTERP_USED               0x00D10000
662*c0e09200SDave Airlie 
663*c0e09200SDave Airlie /* These DWORDs control how vertex data is routed into fragment program
664*c0e09200SDave Airlie  * registers, after interpolators.
665*c0e09200SDave Airlie  */
666*c0e09200SDave Airlie #define R300_RS_ROUTE_0                     0x4330
667*c0e09200SDave Airlie #define R300_RS_ROUTE_1                     0x4334
668*c0e09200SDave Airlie #define R300_RS_ROUTE_2                     0x4338
669*c0e09200SDave Airlie #define R300_RS_ROUTE_3                     0x433C /* GUESS */
670*c0e09200SDave Airlie #define R300_RS_ROUTE_4                     0x4340 /* GUESS */
671*c0e09200SDave Airlie #define R300_RS_ROUTE_5                     0x4344 /* GUESS */
672*c0e09200SDave Airlie #define R300_RS_ROUTE_6                     0x4348 /* GUESS */
673*c0e09200SDave Airlie #define R300_RS_ROUTE_7                     0x434C /* GUESS */
674*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_0     0
675*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_1     1
676*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_2     2
677*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_3     3
678*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_4     4
679*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_5     5 /* GUESS */
680*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_6     6 /* GUESS */
681*c0e09200SDave Airlie #       define R300_RS_ROUTE_SOURCE_INTERP_7     7 /* GUESS */
682*c0e09200SDave Airlie #       define R300_RS_ROUTE_ENABLE              (1 << 3) /* GUESS */
683*c0e09200SDave Airlie #       define R300_RS_ROUTE_DEST_SHIFT          6
684*c0e09200SDave Airlie #       define R300_RS_ROUTE_DEST_MASK           (31 << 6) /* GUESS */
685*c0e09200SDave Airlie 
686*c0e09200SDave Airlie /* Special handling for color: When the fragment program uses color,
687*c0e09200SDave Airlie  * the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
688*c0e09200SDave Airlie  * color register index.
689*c0e09200SDave Airlie  *
690*c0e09200SDave Airlie  * Apperently you may set the R300_RS_ROUTE_0_COLOR bit, but not provide any
691*c0e09200SDave Airlie  * R300_RS_ROUTE_0_COLOR_DEST value; this setup is used for clearing the state.
692*c0e09200SDave Airlie  * See r300_ioctl.c:r300EmitClearState. I'm not sure if this setup is strictly
693*c0e09200SDave Airlie  * correct or not. - Oliver.
694*c0e09200SDave Airlie  */
695*c0e09200SDave Airlie #       define R300_RS_ROUTE_0_COLOR             (1 << 14)
696*c0e09200SDave Airlie #       define R300_RS_ROUTE_0_COLOR_DEST_SHIFT  17
697*c0e09200SDave Airlie #       define R300_RS_ROUTE_0_COLOR_DEST_MASK   (31 << 17) /* GUESS */
698*c0e09200SDave Airlie /* As above, but for secondary color */
699*c0e09200SDave Airlie #		define R300_RS_ROUTE_1_COLOR1            (1 << 14)
700*c0e09200SDave Airlie #		define R300_RS_ROUTE_1_COLOR1_DEST_SHIFT 17
701*c0e09200SDave Airlie #		define R300_RS_ROUTE_1_COLOR1_DEST_MASK  (31 << 17)
702*c0e09200SDave Airlie #		define R300_RS_ROUTE_1_UNKNOWN11         (1 << 11)
703*c0e09200SDave Airlie /* END: Rasterization / Interpolators - many guesses */
704*c0e09200SDave Airlie 
705*c0e09200SDave Airlie /* Hierarchical Z Enable */
706*c0e09200SDave Airlie #define R300_SC_HYPERZ                   0x43a4
707*c0e09200SDave Airlie #	define R300_SC_HYPERZ_DISABLE     (0 << 0)
708*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ENABLE      (1 << 0)
709*c0e09200SDave Airlie #	define R300_SC_HYPERZ_MIN         (0 << 1)
710*c0e09200SDave Airlie #	define R300_SC_HYPERZ_MAX         (1 << 1)
711*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_256     (0 << 2)
712*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_128     (1 << 2)
713*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_64      (2 << 2)
714*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_32      (3 << 2)
715*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_16      (4 << 2)
716*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_8       (5 << 2)
717*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_4       (6 << 2)
718*c0e09200SDave Airlie #	define R300_SC_HYPERZ_ADJ_2       (7 << 2)
719*c0e09200SDave Airlie #	define R300_SC_HYPERZ_HZ_Z0MIN_NO (0 << 5)
720*c0e09200SDave Airlie #	define R300_SC_HYPERZ_HZ_Z0MIN    (1 << 5)
721*c0e09200SDave Airlie #	define R300_SC_HYPERZ_HZ_Z0MAX_NO (0 << 6)
722*c0e09200SDave Airlie #	define R300_SC_HYPERZ_HZ_Z0MAX    (1 << 6)
723*c0e09200SDave Airlie 
724*c0e09200SDave Airlie #define R300_SC_EDGERULE                 0x43a8
725*c0e09200SDave Airlie 
726*c0e09200SDave Airlie /* BEGIN: Scissors and cliprects */
727*c0e09200SDave Airlie 
728*c0e09200SDave Airlie /* There are four clipping rectangles. Their corner coordinates are inclusive.
729*c0e09200SDave Airlie  * Every pixel is assigned a number from 0 and 15 by setting bits 0-3 depending
730*c0e09200SDave Airlie  * on whether the pixel is inside cliprects 0-3, respectively. For example,
731*c0e09200SDave Airlie  * if a pixel is inside cliprects 0 and 1, but outside 2 and 3, it is assigned
732*c0e09200SDave Airlie  * the number 3 (binary 0011).
733*c0e09200SDave Airlie  * Iff the bit corresponding to the pixel's number in RE_CLIPRECT_CNTL is set,
734*c0e09200SDave Airlie  * the pixel is rasterized.
735*c0e09200SDave Airlie  *
736*c0e09200SDave Airlie  * In addition to this, there is a scissors rectangle. Only pixels inside the
737*c0e09200SDave Airlie  * scissors rectangle are drawn. (coordinates are inclusive)
738*c0e09200SDave Airlie  *
739*c0e09200SDave Airlie  * For some reason, the top-left corner of the framebuffer is at (1440, 1440)
740*c0e09200SDave Airlie  * for the purpose of clipping and scissors.
741*c0e09200SDave Airlie  */
742*c0e09200SDave Airlie #define R300_RE_CLIPRECT_TL_0               0x43B0
743*c0e09200SDave Airlie #define R300_RE_CLIPRECT_BR_0               0x43B4
744*c0e09200SDave Airlie #define R300_RE_CLIPRECT_TL_1               0x43B8
745*c0e09200SDave Airlie #define R300_RE_CLIPRECT_BR_1               0x43BC
746*c0e09200SDave Airlie #define R300_RE_CLIPRECT_TL_2               0x43C0
747*c0e09200SDave Airlie #define R300_RE_CLIPRECT_BR_2               0x43C4
748*c0e09200SDave Airlie #define R300_RE_CLIPRECT_TL_3               0x43C8
749*c0e09200SDave Airlie #define R300_RE_CLIPRECT_BR_3               0x43CC
750*c0e09200SDave Airlie #       define R300_CLIPRECT_OFFSET              1440
751*c0e09200SDave Airlie #       define R300_CLIPRECT_MASK                0x1FFF
752*c0e09200SDave Airlie #       define R300_CLIPRECT_X_SHIFT             0
753*c0e09200SDave Airlie #       define R300_CLIPRECT_X_MASK              (0x1FFF << 0)
754*c0e09200SDave Airlie #       define R300_CLIPRECT_Y_SHIFT             13
755*c0e09200SDave Airlie #       define R300_CLIPRECT_Y_MASK              (0x1FFF << 13)
756*c0e09200SDave Airlie #define R300_RE_CLIPRECT_CNTL               0x43D0
757*c0e09200SDave Airlie #       define R300_CLIP_OUT                     (1 << 0)
758*c0e09200SDave Airlie #       define R300_CLIP_0                       (1 << 1)
759*c0e09200SDave Airlie #       define R300_CLIP_1                       (1 << 2)
760*c0e09200SDave Airlie #       define R300_CLIP_10                      (1 << 3)
761*c0e09200SDave Airlie #       define R300_CLIP_2                       (1 << 4)
762*c0e09200SDave Airlie #       define R300_CLIP_20                      (1 << 5)
763*c0e09200SDave Airlie #       define R300_CLIP_21                      (1 << 6)
764*c0e09200SDave Airlie #       define R300_CLIP_210                     (1 << 7)
765*c0e09200SDave Airlie #       define R300_CLIP_3                       (1 << 8)
766*c0e09200SDave Airlie #       define R300_CLIP_30                      (1 << 9)
767*c0e09200SDave Airlie #       define R300_CLIP_31                      (1 << 10)
768*c0e09200SDave Airlie #       define R300_CLIP_310                     (1 << 11)
769*c0e09200SDave Airlie #       define R300_CLIP_32                      (1 << 12)
770*c0e09200SDave Airlie #       define R300_CLIP_320                     (1 << 13)
771*c0e09200SDave Airlie #       define R300_CLIP_321                     (1 << 14)
772*c0e09200SDave Airlie #       define R300_CLIP_3210                    (1 << 15)
773*c0e09200SDave Airlie 
774*c0e09200SDave Airlie /* gap */
775*c0e09200SDave Airlie 
776*c0e09200SDave Airlie #define R300_RE_SCISSORS_TL                 0x43E0
777*c0e09200SDave Airlie #define R300_RE_SCISSORS_BR                 0x43E4
778*c0e09200SDave Airlie #       define R300_SCISSORS_OFFSET              1440
779*c0e09200SDave Airlie #       define R300_SCISSORS_X_SHIFT             0
780*c0e09200SDave Airlie #       define R300_SCISSORS_X_MASK              (0x1FFF << 0)
781*c0e09200SDave Airlie #       define R300_SCISSORS_Y_SHIFT             13
782*c0e09200SDave Airlie #       define R300_SCISSORS_Y_MASK              (0x1FFF << 13)
783*c0e09200SDave Airlie /* END: Scissors and cliprects */
784*c0e09200SDave Airlie 
785*c0e09200SDave Airlie /* BEGIN: Texture specification */
786*c0e09200SDave Airlie 
787*c0e09200SDave Airlie /*
788*c0e09200SDave Airlie  * The texture specification dwords are grouped by meaning and not by texture
789*c0e09200SDave Airlie  * unit. This means that e.g. the offset for texture image unit N is found in
790*c0e09200SDave Airlie  * register TX_OFFSET_0 + (4*N)
791*c0e09200SDave Airlie  */
792*c0e09200SDave Airlie #define R300_TX_FILTER_0                    0x4400
793*c0e09200SDave Airlie #       define R300_TX_REPEAT                    0
794*c0e09200SDave Airlie #       define R300_TX_MIRRORED                  1
795*c0e09200SDave Airlie #       define R300_TX_CLAMP                     4
796*c0e09200SDave Airlie #       define R300_TX_CLAMP_TO_EDGE             2
797*c0e09200SDave Airlie #       define R300_TX_CLAMP_TO_BORDER           6
798*c0e09200SDave Airlie #       define R300_TX_WRAP_S_SHIFT              0
799*c0e09200SDave Airlie #       define R300_TX_WRAP_S_MASK               (7 << 0)
800*c0e09200SDave Airlie #       define R300_TX_WRAP_T_SHIFT              3
801*c0e09200SDave Airlie #       define R300_TX_WRAP_T_MASK               (7 << 3)
802*c0e09200SDave Airlie #       define R300_TX_WRAP_Q_SHIFT              6
803*c0e09200SDave Airlie #       define R300_TX_WRAP_Q_MASK               (7 << 6)
804*c0e09200SDave Airlie #       define R300_TX_MAG_FILTER_NEAREST        (1 << 9)
805*c0e09200SDave Airlie #       define R300_TX_MAG_FILTER_LINEAR         (2 << 9)
806*c0e09200SDave Airlie #       define R300_TX_MAG_FILTER_MASK           (3 << 9)
807*c0e09200SDave Airlie #       define R300_TX_MIN_FILTER_NEAREST        (1 << 11)
808*c0e09200SDave Airlie #       define R300_TX_MIN_FILTER_LINEAR         (2 << 11)
809*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_NEAREST_MIP_NEAREST       (5  <<  11)
810*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_NEAREST_MIP_LINEAR        (9  <<  11)
811*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_LINEAR_MIP_NEAREST        (6  <<  11)
812*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_LINEAR_MIP_LINEAR         (10 <<  11)
813*c0e09200SDave Airlie 
814*c0e09200SDave Airlie /* NOTE: NEAREST doesnt seem to exist.
815*c0e09200SDave Airlie  * Im not seting MAG_FILTER_MASK and (3 << 11) on for all
816*c0e09200SDave Airlie  * anisotropy modes because that would void selected mag filter
817*c0e09200SDave Airlie  */
818*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_ANISO_NEAREST             (0 << 13)
819*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_ANISO_LINEAR              (0 << 13)
820*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (1 << 13)
821*c0e09200SDave Airlie #	define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR  (2 << 13)
822*c0e09200SDave Airlie #       define R300_TX_MIN_FILTER_MASK   ( (15 << 11) | (3 << 13) )
823*c0e09200SDave Airlie #	define R300_TX_MAX_ANISO_1_TO_1  (0 << 21)
824*c0e09200SDave Airlie #	define R300_TX_MAX_ANISO_2_TO_1  (2 << 21)
825*c0e09200SDave Airlie #	define R300_TX_MAX_ANISO_4_TO_1  (4 << 21)
826*c0e09200SDave Airlie #	define R300_TX_MAX_ANISO_8_TO_1  (6 << 21)
827*c0e09200SDave Airlie #	define R300_TX_MAX_ANISO_16_TO_1 (8 << 21)
828*c0e09200SDave Airlie #	define R300_TX_MAX_ANISO_MASK    (14 << 21)
829*c0e09200SDave Airlie 
830*c0e09200SDave Airlie #define R300_TX_FILTER1_0                      0x4440
831*c0e09200SDave Airlie #	define R300_CHROMA_KEY_MODE_DISABLE    0
832*c0e09200SDave Airlie #	define R300_CHROMA_KEY_FORCE	       1
833*c0e09200SDave Airlie #	define R300_CHROMA_KEY_BLEND           2
834*c0e09200SDave Airlie #	define R300_MC_ROUND_NORMAL            (0<<2)
835*c0e09200SDave Airlie #	define R300_MC_ROUND_MPEG4             (1<<2)
836*c0e09200SDave Airlie #	define R300_LOD_BIAS_MASK	    0x1fff
837*c0e09200SDave Airlie #	define R300_EDGE_ANISO_EDGE_DIAG       (0<<13)
838*c0e09200SDave Airlie #	define R300_EDGE_ANISO_EDGE_ONLY       (1<<13)
839*c0e09200SDave Airlie #	define R300_MC_COORD_TRUNCATE_DISABLE  (0<<14)
840*c0e09200SDave Airlie #	define R300_MC_COORD_TRUNCATE_MPEG     (1<<14)
841*c0e09200SDave Airlie #	define R300_TX_TRI_PERF_0_8            (0<<15)
842*c0e09200SDave Airlie #	define R300_TX_TRI_PERF_1_8            (1<<15)
843*c0e09200SDave Airlie #	define R300_TX_TRI_PERF_1_4            (2<<15)
844*c0e09200SDave Airlie #	define R300_TX_TRI_PERF_3_8            (3<<15)
845*c0e09200SDave Airlie #	define R300_ANISO_THRESHOLD_MASK       (7<<17)
846*c0e09200SDave Airlie 
847*c0e09200SDave Airlie #define R300_TX_SIZE_0                      0x4480
848*c0e09200SDave Airlie #       define R300_TX_WIDTHMASK_SHIFT           0
849*c0e09200SDave Airlie #       define R300_TX_WIDTHMASK_MASK            (2047 << 0)
850*c0e09200SDave Airlie #       define R300_TX_HEIGHTMASK_SHIFT          11
851*c0e09200SDave Airlie #       define R300_TX_HEIGHTMASK_MASK           (2047 << 11)
852*c0e09200SDave Airlie #       define R300_TX_UNK23                     (1 << 23)
853*c0e09200SDave Airlie #       define R300_TX_MAX_MIP_LEVEL_SHIFT       26
854*c0e09200SDave Airlie #       define R300_TX_MAX_MIP_LEVEL_MASK        (0xf << 26)
855*c0e09200SDave Airlie #       define R300_TX_SIZE_PROJECTED            (1<<30)
856*c0e09200SDave Airlie #       define R300_TX_SIZE_TXPITCH_EN           (1<<31)
857*c0e09200SDave Airlie #define R300_TX_FORMAT_0                    0x44C0
858*c0e09200SDave Airlie 	/* The interpretation of the format word by Wladimir van der Laan */
859*c0e09200SDave Airlie 	/* The X, Y, Z and W refer to the layout of the components.
860*c0e09200SDave Airlie 	   They are given meanings as R, G, B and Alpha by the swizzle
861*c0e09200SDave Airlie 	   specification */
862*c0e09200SDave Airlie #	define R300_TX_FORMAT_X8		    0x0
863*c0e09200SDave Airlie #	define R300_TX_FORMAT_X16		    0x1
864*c0e09200SDave Airlie #	define R300_TX_FORMAT_Y4X4		    0x2
865*c0e09200SDave Airlie #	define R300_TX_FORMAT_Y8X8		    0x3
866*c0e09200SDave Airlie #	define R300_TX_FORMAT_Y16X16		    0x4
867*c0e09200SDave Airlie #	define R300_TX_FORMAT_Z3Y3X2		    0x5
868*c0e09200SDave Airlie #	define R300_TX_FORMAT_Z5Y6X5		    0x6
869*c0e09200SDave Airlie #	define R300_TX_FORMAT_Z6Y5X5		    0x7
870*c0e09200SDave Airlie #	define R300_TX_FORMAT_Z11Y11X10		    0x8
871*c0e09200SDave Airlie #	define R300_TX_FORMAT_Z10Y11X11		    0x9
872*c0e09200SDave Airlie #	define R300_TX_FORMAT_W4Z4Y4X4		    0xA
873*c0e09200SDave Airlie #	define R300_TX_FORMAT_W1Z5Y5X5		    0xB
874*c0e09200SDave Airlie #	define R300_TX_FORMAT_W8Z8Y8X8		    0xC
875*c0e09200SDave Airlie #	define R300_TX_FORMAT_W2Z10Y10X10	    0xD
876*c0e09200SDave Airlie #	define R300_TX_FORMAT_W16Z16Y16X16	    0xE
877*c0e09200SDave Airlie #	define R300_TX_FORMAT_DXT1		    0xF
878*c0e09200SDave Airlie #	define R300_TX_FORMAT_DXT3		    0x10
879*c0e09200SDave Airlie #	define R300_TX_FORMAT_DXT5		    0x11
880*c0e09200SDave Airlie #	define R300_TX_FORMAT_D3DMFT_CxV8U8	    0x12     /* no swizzle */
881*c0e09200SDave Airlie #	define R300_TX_FORMAT_A8R8G8B8		    0x13     /* no swizzle */
882*c0e09200SDave Airlie #	define R300_TX_FORMAT_B8G8_B8G8		    0x14     /* no swizzle */
883*c0e09200SDave Airlie #	define R300_TX_FORMAT_G8R8_G8B8		    0x15     /* no swizzle */
884*c0e09200SDave Airlie 	/* 0x16 - some 16 bit green format.. ?? */
885*c0e09200SDave Airlie #	define R300_TX_FORMAT_UNK25		   (1 << 25) /* no swizzle */
886*c0e09200SDave Airlie #	define R300_TX_FORMAT_CUBIC_MAP		   (1 << 26)
887*c0e09200SDave Airlie 
888*c0e09200SDave Airlie 	/* gap */
889*c0e09200SDave Airlie 	/* Floating point formats */
890*c0e09200SDave Airlie 	/* Note - hardware supports both 16 and 32 bit floating point */
891*c0e09200SDave Airlie #	define R300_TX_FORMAT_FL_I16		    0x18
892*c0e09200SDave Airlie #	define R300_TX_FORMAT_FL_I16A16		    0x19
893*c0e09200SDave Airlie #	define R300_TX_FORMAT_FL_R16G16B16A16	    0x1A
894*c0e09200SDave Airlie #	define R300_TX_FORMAT_FL_I32		    0x1B
895*c0e09200SDave Airlie #	define R300_TX_FORMAT_FL_I32A32		    0x1C
896*c0e09200SDave Airlie #	define R300_TX_FORMAT_FL_R32G32B32A32	    0x1D
897*c0e09200SDave Airlie 	/* alpha modes, convenience mostly */
898*c0e09200SDave Airlie 	/* if you have alpha, pick constant appropriate to the
899*c0e09200SDave Airlie 	   number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
900*c0e09200SDave Airlie #	define R300_TX_FORMAT_ALPHA_1CH		    0x000
901*c0e09200SDave Airlie #	define R300_TX_FORMAT_ALPHA_2CH		    0x200
902*c0e09200SDave Airlie #	define R300_TX_FORMAT_ALPHA_4CH		    0x600
903*c0e09200SDave Airlie #	define R300_TX_FORMAT_ALPHA_NONE	    0xA00
904*c0e09200SDave Airlie 	/* Swizzling */
905*c0e09200SDave Airlie 	/* constants */
906*c0e09200SDave Airlie #	define R300_TX_FORMAT_X		0
907*c0e09200SDave Airlie #	define R300_TX_FORMAT_Y		1
908*c0e09200SDave Airlie #	define R300_TX_FORMAT_Z		2
909*c0e09200SDave Airlie #	define R300_TX_FORMAT_W		3
910*c0e09200SDave Airlie #	define R300_TX_FORMAT_ZERO	4
911*c0e09200SDave Airlie #	define R300_TX_FORMAT_ONE	5
912*c0e09200SDave Airlie 	/* 2.0*Z, everything above 1.0 is set to 0.0 */
913*c0e09200SDave Airlie #	define R300_TX_FORMAT_CUT_Z	6
914*c0e09200SDave Airlie 	/* 2.0*W, everything above 1.0 is set to 0.0 */
915*c0e09200SDave Airlie #	define R300_TX_FORMAT_CUT_W	7
916*c0e09200SDave Airlie 
917*c0e09200SDave Airlie #	define R300_TX_FORMAT_B_SHIFT	18
918*c0e09200SDave Airlie #	define R300_TX_FORMAT_G_SHIFT	15
919*c0e09200SDave Airlie #	define R300_TX_FORMAT_R_SHIFT	12
920*c0e09200SDave Airlie #	define R300_TX_FORMAT_A_SHIFT	9
921*c0e09200SDave Airlie 	/* Convenience macro to take care of layout and swizzling */
922*c0e09200SDave Airlie #	define R300_EASY_TX_FORMAT(B, G, R, A, FMT)	(		\
923*c0e09200SDave Airlie 		((R300_TX_FORMAT_##B)<<R300_TX_FORMAT_B_SHIFT)		\
924*c0e09200SDave Airlie 		| ((R300_TX_FORMAT_##G)<<R300_TX_FORMAT_G_SHIFT)	\
925*c0e09200SDave Airlie 		| ((R300_TX_FORMAT_##R)<<R300_TX_FORMAT_R_SHIFT)	\
926*c0e09200SDave Airlie 		| ((R300_TX_FORMAT_##A)<<R300_TX_FORMAT_A_SHIFT)	\
927*c0e09200SDave Airlie 		| (R300_TX_FORMAT_##FMT)				\
928*c0e09200SDave Airlie 		)
929*c0e09200SDave Airlie 	/* These can be ORed with result of R300_EASY_TX_FORMAT()
930*c0e09200SDave Airlie 	   We don't really know what they do. Take values from a
931*c0e09200SDave Airlie            constant color ? */
932*c0e09200SDave Airlie #	define R300_TX_FORMAT_CONST_X		(1<<5)
933*c0e09200SDave Airlie #	define R300_TX_FORMAT_CONST_Y		(2<<5)
934*c0e09200SDave Airlie #	define R300_TX_FORMAT_CONST_Z		(4<<5)
935*c0e09200SDave Airlie #	define R300_TX_FORMAT_CONST_W		(8<<5)
936*c0e09200SDave Airlie 
937*c0e09200SDave Airlie #	define R300_TX_FORMAT_YUV_MODE		0x00800000
938*c0e09200SDave Airlie 
939*c0e09200SDave Airlie #define R300_TX_PITCH_0			    0x4500 /* obvious missing in gap */
940*c0e09200SDave Airlie #define R300_TX_OFFSET_0                    0x4540
941*c0e09200SDave Airlie 	/* BEGIN: Guess from R200 */
942*c0e09200SDave Airlie #       define R300_TXO_ENDIAN_NO_SWAP           (0 << 0)
943*c0e09200SDave Airlie #       define R300_TXO_ENDIAN_BYTE_SWAP         (1 << 0)
944*c0e09200SDave Airlie #       define R300_TXO_ENDIAN_WORD_SWAP         (2 << 0)
945*c0e09200SDave Airlie #       define R300_TXO_ENDIAN_HALFDW_SWAP       (3 << 0)
946*c0e09200SDave Airlie #       define R300_TXO_MACRO_TILE               (1 << 2)
947*c0e09200SDave Airlie #       define R300_TXO_MICRO_TILE               (1 << 3)
948*c0e09200SDave Airlie #       define R300_TXO_OFFSET_MASK              0xffffffe0
949*c0e09200SDave Airlie #       define R300_TXO_OFFSET_SHIFT             5
950*c0e09200SDave Airlie 	/* END: Guess from R200 */
951*c0e09200SDave Airlie 
952*c0e09200SDave Airlie /* 32 bit chroma key */
953*c0e09200SDave Airlie #define R300_TX_CHROMA_KEY_0                      0x4580
954*c0e09200SDave Airlie /* ff00ff00 == { 0, 1.0, 0, 1.0 } */
955*c0e09200SDave Airlie #define R300_TX_BORDER_COLOR_0              0x45C0
956*c0e09200SDave Airlie 
957*c0e09200SDave Airlie /* END: Texture specification */
958*c0e09200SDave Airlie 
959*c0e09200SDave Airlie /* BEGIN: Fragment program instruction set */
960*c0e09200SDave Airlie 
961*c0e09200SDave Airlie /* Fragment programs are written directly into register space.
962*c0e09200SDave Airlie  * There are separate instruction streams for texture instructions and ALU
963*c0e09200SDave Airlie  * instructions.
964*c0e09200SDave Airlie  * In order to synchronize these streams, the program is divided into up
965*c0e09200SDave Airlie  * to 4 nodes. Each node begins with a number of TEX operations, followed
966*c0e09200SDave Airlie  * by a number of ALU operations.
967*c0e09200SDave Airlie  * The first node can have zero TEX ops, all subsequent nodes must have at
968*c0e09200SDave Airlie  * least
969*c0e09200SDave Airlie  * one TEX ops.
970*c0e09200SDave Airlie  * All nodes must have at least one ALU op.
971*c0e09200SDave Airlie  *
972*c0e09200SDave Airlie  * The index of the last node is stored in PFS_CNTL_0: A value of 0 means
973*c0e09200SDave Airlie  * 1 node, a value of 3 means 4 nodes.
974*c0e09200SDave Airlie  * The total amount of instructions is defined in PFS_CNTL_2. The offsets are
975*c0e09200SDave Airlie  * offsets into the respective instruction streams, while *_END points to the
976*c0e09200SDave Airlie  * last instruction relative to this offset.
977*c0e09200SDave Airlie  */
978*c0e09200SDave Airlie #define R300_PFS_CNTL_0                     0x4600
979*c0e09200SDave Airlie #       define R300_PFS_CNTL_LAST_NODES_SHIFT    0
980*c0e09200SDave Airlie #       define R300_PFS_CNTL_LAST_NODES_MASK     (3 << 0)
981*c0e09200SDave Airlie #       define R300_PFS_CNTL_FIRST_NODE_HAS_TEX  (1 << 3)
982*c0e09200SDave Airlie #define R300_PFS_CNTL_1                     0x4604
983*c0e09200SDave Airlie /* There is an unshifted value here which has so far always been equal to the
984*c0e09200SDave Airlie  * index of the highest used temporary register.
985*c0e09200SDave Airlie  */
986*c0e09200SDave Airlie #define R300_PFS_CNTL_2                     0x4608
987*c0e09200SDave Airlie #       define R300_PFS_CNTL_ALU_OFFSET_SHIFT    0
988*c0e09200SDave Airlie #       define R300_PFS_CNTL_ALU_OFFSET_MASK     (63 << 0)
989*c0e09200SDave Airlie #       define R300_PFS_CNTL_ALU_END_SHIFT       6
990*c0e09200SDave Airlie #       define R300_PFS_CNTL_ALU_END_MASK        (63 << 6)
991*c0e09200SDave Airlie #       define R300_PFS_CNTL_TEX_OFFSET_SHIFT    12
992*c0e09200SDave Airlie #       define R300_PFS_CNTL_TEX_OFFSET_MASK     (31 << 12) /* GUESS */
993*c0e09200SDave Airlie #       define R300_PFS_CNTL_TEX_END_SHIFT       18
994*c0e09200SDave Airlie #       define R300_PFS_CNTL_TEX_END_MASK        (31 << 18) /* GUESS */
995*c0e09200SDave Airlie 
996*c0e09200SDave Airlie /* gap */
997*c0e09200SDave Airlie 
998*c0e09200SDave Airlie /* Nodes are stored backwards. The last active node is always stored in
999*c0e09200SDave Airlie  * PFS_NODE_3.
1000*c0e09200SDave Airlie  * Example: In a 2-node program, NODE_0 and NODE_1 are set to 0. The
1001*c0e09200SDave Airlie  * first node is stored in NODE_2, the second node is stored in NODE_3.
1002*c0e09200SDave Airlie  *
1003*c0e09200SDave Airlie  * Offsets are relative to the master offset from PFS_CNTL_2.
1004*c0e09200SDave Airlie  */
1005*c0e09200SDave Airlie #define R300_PFS_NODE_0                     0x4610
1006*c0e09200SDave Airlie #define R300_PFS_NODE_1                     0x4614
1007*c0e09200SDave Airlie #define R300_PFS_NODE_2                     0x4618
1008*c0e09200SDave Airlie #define R300_PFS_NODE_3                     0x461C
1009*c0e09200SDave Airlie #       define R300_PFS_NODE_ALU_OFFSET_SHIFT    0
1010*c0e09200SDave Airlie #       define R300_PFS_NODE_ALU_OFFSET_MASK     (63 << 0)
1011*c0e09200SDave Airlie #       define R300_PFS_NODE_ALU_END_SHIFT       6
1012*c0e09200SDave Airlie #       define R300_PFS_NODE_ALU_END_MASK        (63 << 6)
1013*c0e09200SDave Airlie #       define R300_PFS_NODE_TEX_OFFSET_SHIFT    12
1014*c0e09200SDave Airlie #       define R300_PFS_NODE_TEX_OFFSET_MASK     (31 << 12)
1015*c0e09200SDave Airlie #       define R300_PFS_NODE_TEX_END_SHIFT       17
1016*c0e09200SDave Airlie #       define R300_PFS_NODE_TEX_END_MASK        (31 << 17)
1017*c0e09200SDave Airlie #		define R300_PFS_NODE_OUTPUT_COLOR        (1 << 22)
1018*c0e09200SDave Airlie #		define R300_PFS_NODE_OUTPUT_DEPTH        (1 << 23)
1019*c0e09200SDave Airlie 
1020*c0e09200SDave Airlie /* TEX
1021*c0e09200SDave Airlie  * As far as I can tell, texture instructions cannot write into output
1022*c0e09200SDave Airlie  * registers directly. A subsequent ALU instruction is always necessary,
1023*c0e09200SDave Airlie  * even if it's just MAD o0, r0, 1, 0
1024*c0e09200SDave Airlie  */
1025*c0e09200SDave Airlie #define R300_PFS_TEXI_0                     0x4620
1026*c0e09200SDave Airlie #	define R300_FPITX_SRC_SHIFT              0
1027*c0e09200SDave Airlie #	define R300_FPITX_SRC_MASK               (31 << 0)
1028*c0e09200SDave Airlie 	/* GUESS */
1029*c0e09200SDave Airlie #	define R300_FPITX_SRC_CONST              (1 << 5)
1030*c0e09200SDave Airlie #	define R300_FPITX_DST_SHIFT              6
1031*c0e09200SDave Airlie #	define R300_FPITX_DST_MASK               (31 << 6)
1032*c0e09200SDave Airlie #	define R300_FPITX_IMAGE_SHIFT            11
1033*c0e09200SDave Airlie 	/* GUESS based on layout and native limits */
1034*c0e09200SDave Airlie #       define R300_FPITX_IMAGE_MASK             (15 << 11)
1035*c0e09200SDave Airlie /* Unsure if these are opcodes, or some kind of bitfield, but this is how
1036*c0e09200SDave Airlie  * they were set when I checked
1037*c0e09200SDave Airlie  */
1038*c0e09200SDave Airlie #	define R300_FPITX_OPCODE_SHIFT		15
1039*c0e09200SDave Airlie #		define R300_FPITX_OP_TEX	1
1040*c0e09200SDave Airlie #		define R300_FPITX_OP_KIL	2
1041*c0e09200SDave Airlie #		define R300_FPITX_OP_TXP	3
1042*c0e09200SDave Airlie #		define R300_FPITX_OP_TXB	4
1043*c0e09200SDave Airlie #	define R300_FPITX_OPCODE_MASK           (7 << 15)
1044*c0e09200SDave Airlie 
1045*c0e09200SDave Airlie /* ALU
1046*c0e09200SDave Airlie  * The ALU instructions register blocks are enumerated according to the order
1047*c0e09200SDave Airlie  * in which fglrx. I assume there is space for 64 instructions, since
1048*c0e09200SDave Airlie  * each block has space for a maximum of 64 DWORDs, and this matches reported
1049*c0e09200SDave Airlie  * native limits.
1050*c0e09200SDave Airlie  *
1051*c0e09200SDave Airlie  * The basic functional block seems to be one MAD for each color and alpha,
1052*c0e09200SDave Airlie  * and an adder that adds all components after the MUL.
1053*c0e09200SDave Airlie  *  - ADD, MUL, MAD etc.: use MAD with appropriate neutral operands
1054*c0e09200SDave Airlie  *  - DP4: Use OUTC_DP4, OUTA_DP4
1055*c0e09200SDave Airlie  *  - DP3: Use OUTC_DP3, OUTA_DP4, appropriate alpha operands
1056*c0e09200SDave Airlie  *  - DPH: Use OUTC_DP4, OUTA_DP4, appropriate alpha operands
1057*c0e09200SDave Airlie  *  - CMPH: If ARG2 > 0.5, return ARG0, else return ARG1
1058*c0e09200SDave Airlie  *  - CMP: If ARG2 < 0, return ARG1, else return ARG0
1059*c0e09200SDave Airlie  *  - FLR: use FRC+MAD
1060*c0e09200SDave Airlie  *  - XPD: use MAD+MAD
1061*c0e09200SDave Airlie  *  - SGE, SLT: use MAD+CMP
1062*c0e09200SDave Airlie  *  - RSQ: use ABS modifier for argument
1063*c0e09200SDave Airlie  *  - Use OUTC_REPL_ALPHA to write results of an alpha-only operation
1064*c0e09200SDave Airlie  *    (e.g. RCP) into color register
1065*c0e09200SDave Airlie  *  - apparently, there's no quick DST operation
1066*c0e09200SDave Airlie  *  - fglrx set FPI2_UNKNOWN_31 on a "MAD fragment.color, tmp0, tmp1, tmp2"
1067*c0e09200SDave Airlie  *  - fglrx set FPI2_UNKNOWN_31 on a "MAX r2, r1, c0"
1068*c0e09200SDave Airlie  *  - fglrx once set FPI0_UNKNOWN_31 on a "FRC r1, r1"
1069*c0e09200SDave Airlie  *
1070*c0e09200SDave Airlie  * Operand selection
1071*c0e09200SDave Airlie  * First stage selects three sources from the available registers and
1072*c0e09200SDave Airlie  * constant parameters. This is defined in INSTR1 (color) and INSTR3 (alpha).
1073*c0e09200SDave Airlie  * fglrx sorts the three source fields: Registers before constants,
1074*c0e09200SDave Airlie  * lower indices before higher indices; I do not know whether this is
1075*c0e09200SDave Airlie  * necessary.
1076*c0e09200SDave Airlie  *
1077*c0e09200SDave Airlie  * fglrx fills unused sources with "read constant 0"
1078*c0e09200SDave Airlie  * According to specs, you cannot select more than two different constants.
1079*c0e09200SDave Airlie  *
1080*c0e09200SDave Airlie  * Second stage selects the operands from the sources. This is defined in
1081*c0e09200SDave Airlie  * INSTR0 (color) and INSTR2 (alpha). You can also select the special constants
1082*c0e09200SDave Airlie  * zero and one.
1083*c0e09200SDave Airlie  * Swizzling and negation happens in this stage, as well.
1084*c0e09200SDave Airlie  *
1085*c0e09200SDave Airlie  * Important: Color and alpha seem to be mostly separate, i.e. their sources
1086*c0e09200SDave Airlie  * selection appears to be fully independent (the register storage is probably
1087*c0e09200SDave Airlie  * physically split into a color and an alpha section).
1088*c0e09200SDave Airlie  * However (because of the apparent physical split), there is some interaction
1089*c0e09200SDave Airlie  * WRT swizzling. If, for example, you want to load an R component into an
1090*c0e09200SDave Airlie  * Alpha operand, this R component is taken from a *color* source, not from
1091*c0e09200SDave Airlie  * an alpha source. The corresponding register doesn't even have to appear in
1092*c0e09200SDave Airlie  * the alpha sources list. (I hope this all makes sense to you)
1093*c0e09200SDave Airlie  *
1094*c0e09200SDave Airlie  * Destination selection
1095*c0e09200SDave Airlie  * The destination register index is in FPI1 (color) and FPI3 (alpha)
1096*c0e09200SDave Airlie  * together with enable bits.
1097*c0e09200SDave Airlie  * There are separate enable bits for writing into temporary registers
1098*c0e09200SDave Airlie  * (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_*
1099*c0e09200SDave Airlie  * /DSTA_OUTPUT). You can write to both at once, or not write at all (the
1100*c0e09200SDave Airlie  * same index must be used for both).
1101*c0e09200SDave Airlie  *
1102*c0e09200SDave Airlie  * Note: There is a special form for LRP
1103*c0e09200SDave Airlie  *  - Argument order is the same as in ARB_fragment_program.
1104*c0e09200SDave Airlie  *  - Operation is MAD
1105*c0e09200SDave Airlie  *  - ARG1 is set to ARGC_SRC1C_LRP/ARGC_SRC1A_LRP
1106*c0e09200SDave Airlie  *  - Set FPI0/FPI2_SPECIAL_LRP
1107*c0e09200SDave Airlie  * Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD
1108*c0e09200SDave Airlie  */
1109*c0e09200SDave Airlie #define R300_PFS_INSTR1_0                   0x46C0
1110*c0e09200SDave Airlie #       define R300_FPI1_SRC0C_SHIFT             0
1111*c0e09200SDave Airlie #       define R300_FPI1_SRC0C_MASK              (31 << 0)
1112*c0e09200SDave Airlie #       define R300_FPI1_SRC0C_CONST             (1 << 5)
1113*c0e09200SDave Airlie #       define R300_FPI1_SRC1C_SHIFT             6
1114*c0e09200SDave Airlie #       define R300_FPI1_SRC1C_MASK              (31 << 6)
1115*c0e09200SDave Airlie #       define R300_FPI1_SRC1C_CONST             (1 << 11)
1116*c0e09200SDave Airlie #       define R300_FPI1_SRC2C_SHIFT             12
1117*c0e09200SDave Airlie #       define R300_FPI1_SRC2C_MASK              (31 << 12)
1118*c0e09200SDave Airlie #       define R300_FPI1_SRC2C_CONST             (1 << 17)
1119*c0e09200SDave Airlie #       define R300_FPI1_SRC_MASK                0x0003ffff
1120*c0e09200SDave Airlie #       define R300_FPI1_DSTC_SHIFT              18
1121*c0e09200SDave Airlie #       define R300_FPI1_DSTC_MASK               (31 << 18)
1122*c0e09200SDave Airlie #		define R300_FPI1_DSTC_REG_MASK_SHIFT     23
1123*c0e09200SDave Airlie #       define R300_FPI1_DSTC_REG_X              (1 << 23)
1124*c0e09200SDave Airlie #       define R300_FPI1_DSTC_REG_Y              (1 << 24)
1125*c0e09200SDave Airlie #       define R300_FPI1_DSTC_REG_Z              (1 << 25)
1126*c0e09200SDave Airlie #		define R300_FPI1_DSTC_OUTPUT_MASK_SHIFT  26
1127*c0e09200SDave Airlie #       define R300_FPI1_DSTC_OUTPUT_X           (1 << 26)
1128*c0e09200SDave Airlie #       define R300_FPI1_DSTC_OUTPUT_Y           (1 << 27)
1129*c0e09200SDave Airlie #       define R300_FPI1_DSTC_OUTPUT_Z           (1 << 28)
1130*c0e09200SDave Airlie 
1131*c0e09200SDave Airlie #define R300_PFS_INSTR3_0                   0x47C0
1132*c0e09200SDave Airlie #       define R300_FPI3_SRC0A_SHIFT             0
1133*c0e09200SDave Airlie #       define R300_FPI3_SRC0A_MASK              (31 << 0)
1134*c0e09200SDave Airlie #       define R300_FPI3_SRC0A_CONST             (1 << 5)
1135*c0e09200SDave Airlie #       define R300_FPI3_SRC1A_SHIFT             6
1136*c0e09200SDave Airlie #       define R300_FPI3_SRC1A_MASK              (31 << 6)
1137*c0e09200SDave Airlie #       define R300_FPI3_SRC1A_CONST             (1 << 11)
1138*c0e09200SDave Airlie #       define R300_FPI3_SRC2A_SHIFT             12
1139*c0e09200SDave Airlie #       define R300_FPI3_SRC2A_MASK              (31 << 12)
1140*c0e09200SDave Airlie #       define R300_FPI3_SRC2A_CONST             (1 << 17)
1141*c0e09200SDave Airlie #       define R300_FPI3_SRC_MASK                0x0003ffff
1142*c0e09200SDave Airlie #       define R300_FPI3_DSTA_SHIFT              18
1143*c0e09200SDave Airlie #       define R300_FPI3_DSTA_MASK               (31 << 18)
1144*c0e09200SDave Airlie #       define R300_FPI3_DSTA_REG                (1 << 23)
1145*c0e09200SDave Airlie #       define R300_FPI3_DSTA_OUTPUT             (1 << 24)
1146*c0e09200SDave Airlie #		define R300_FPI3_DSTA_DEPTH              (1 << 27)
1147*c0e09200SDave Airlie 
1148*c0e09200SDave Airlie #define R300_PFS_INSTR0_0                   0x48C0
1149*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0C_XYZ          0
1150*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0C_XXX          1
1151*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0C_YYY          2
1152*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0C_ZZZ          3
1153*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_XYZ          4
1154*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_XXX          5
1155*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_YYY          6
1156*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_ZZZ          7
1157*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2C_XYZ          8
1158*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2C_XXX          9
1159*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2C_YYY          10
1160*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2C_ZZZ          11
1161*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0A              12
1162*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1A              13
1163*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2A              14
1164*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_LRP          15
1165*c0e09200SDave Airlie #       define R300_FPI0_ARGC_ZERO               20
1166*c0e09200SDave Airlie #       define R300_FPI0_ARGC_ONE                21
1167*c0e09200SDave Airlie 	/* GUESS */
1168*c0e09200SDave Airlie #       define R300_FPI0_ARGC_HALF               22
1169*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0C_YZX          23
1170*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_YZX          24
1171*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2C_YZX          25
1172*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0C_ZXY          26
1173*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1C_ZXY          27
1174*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2C_ZXY          28
1175*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC0CA_WZY         29
1176*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC1CA_WZY         30
1177*c0e09200SDave Airlie #       define R300_FPI0_ARGC_SRC2CA_WZY         31
1178*c0e09200SDave Airlie 
1179*c0e09200SDave Airlie #       define R300_FPI0_ARG0C_SHIFT             0
1180*c0e09200SDave Airlie #       define R300_FPI0_ARG0C_MASK              (31 << 0)
1181*c0e09200SDave Airlie #       define R300_FPI0_ARG0C_NEG               (1 << 5)
1182*c0e09200SDave Airlie #       define R300_FPI0_ARG0C_ABS               (1 << 6)
1183*c0e09200SDave Airlie #       define R300_FPI0_ARG1C_SHIFT             7
1184*c0e09200SDave Airlie #       define R300_FPI0_ARG1C_MASK              (31 << 7)
1185*c0e09200SDave Airlie #       define R300_FPI0_ARG1C_NEG               (1 << 12)
1186*c0e09200SDave Airlie #       define R300_FPI0_ARG1C_ABS               (1 << 13)
1187*c0e09200SDave Airlie #       define R300_FPI0_ARG2C_SHIFT             14
1188*c0e09200SDave Airlie #       define R300_FPI0_ARG2C_MASK              (31 << 14)
1189*c0e09200SDave Airlie #       define R300_FPI0_ARG2C_NEG               (1 << 19)
1190*c0e09200SDave Airlie #       define R300_FPI0_ARG2C_ABS               (1 << 20)
1191*c0e09200SDave Airlie #       define R300_FPI0_SPECIAL_LRP             (1 << 21)
1192*c0e09200SDave Airlie #       define R300_FPI0_OUTC_MAD                (0 << 23)
1193*c0e09200SDave Airlie #       define R300_FPI0_OUTC_DP3                (1 << 23)
1194*c0e09200SDave Airlie #       define R300_FPI0_OUTC_DP4                (2 << 23)
1195*c0e09200SDave Airlie #       define R300_FPI0_OUTC_MIN                (4 << 23)
1196*c0e09200SDave Airlie #       define R300_FPI0_OUTC_MAX                (5 << 23)
1197*c0e09200SDave Airlie #       define R300_FPI0_OUTC_CMPH               (7 << 23)
1198*c0e09200SDave Airlie #       define R300_FPI0_OUTC_CMP                (8 << 23)
1199*c0e09200SDave Airlie #       define R300_FPI0_OUTC_FRC                (9 << 23)
1200*c0e09200SDave Airlie #       define R300_FPI0_OUTC_REPL_ALPHA         (10 << 23)
1201*c0e09200SDave Airlie #       define R300_FPI0_OUTC_SAT                (1 << 30)
1202*c0e09200SDave Airlie #       define R300_FPI0_INSERT_NOP              (1 << 31)
1203*c0e09200SDave Airlie 
1204*c0e09200SDave Airlie #define R300_PFS_INSTR2_0                   0x49C0
1205*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC0C_X            0
1206*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC0C_Y            1
1207*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC0C_Z            2
1208*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC1C_X            3
1209*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC1C_Y            4
1210*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC1C_Z            5
1211*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC2C_X            6
1212*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC2C_Y            7
1213*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC2C_Z            8
1214*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC0A              9
1215*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC1A              10
1216*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC2A              11
1217*c0e09200SDave Airlie #       define R300_FPI2_ARGA_SRC1A_LRP          15
1218*c0e09200SDave Airlie #       define R300_FPI2_ARGA_ZERO               16
1219*c0e09200SDave Airlie #       define R300_FPI2_ARGA_ONE                17
1220*c0e09200SDave Airlie 	/* GUESS */
1221*c0e09200SDave Airlie #       define R300_FPI2_ARGA_HALF               18
1222*c0e09200SDave Airlie #       define R300_FPI2_ARG0A_SHIFT             0
1223*c0e09200SDave Airlie #       define R300_FPI2_ARG0A_MASK              (31 << 0)
1224*c0e09200SDave Airlie #       define R300_FPI2_ARG0A_NEG               (1 << 5)
1225*c0e09200SDave Airlie 	/* GUESS */
1226*c0e09200SDave Airlie #	define R300_FPI2_ARG0A_ABS		 (1 << 6)
1227*c0e09200SDave Airlie #       define R300_FPI2_ARG1A_SHIFT             7
1228*c0e09200SDave Airlie #       define R300_FPI2_ARG1A_MASK              (31 << 7)
1229*c0e09200SDave Airlie #       define R300_FPI2_ARG1A_NEG               (1 << 12)
1230*c0e09200SDave Airlie 	/* GUESS */
1231*c0e09200SDave Airlie #	define R300_FPI2_ARG1A_ABS		 (1 << 13)
1232*c0e09200SDave Airlie #       define R300_FPI2_ARG2A_SHIFT             14
1233*c0e09200SDave Airlie #       define R300_FPI2_ARG2A_MASK              (31 << 14)
1234*c0e09200SDave Airlie #       define R300_FPI2_ARG2A_NEG               (1 << 19)
1235*c0e09200SDave Airlie 	/* GUESS */
1236*c0e09200SDave Airlie #	define R300_FPI2_ARG2A_ABS		 (1 << 20)
1237*c0e09200SDave Airlie #       define R300_FPI2_SPECIAL_LRP             (1 << 21)
1238*c0e09200SDave Airlie #       define R300_FPI2_OUTA_MAD                (0 << 23)
1239*c0e09200SDave Airlie #       define R300_FPI2_OUTA_DP4                (1 << 23)
1240*c0e09200SDave Airlie #       define R300_FPI2_OUTA_MIN                (2 << 23)
1241*c0e09200SDave Airlie #       define R300_FPI2_OUTA_MAX                (3 << 23)
1242*c0e09200SDave Airlie #       define R300_FPI2_OUTA_CMP                (6 << 23)
1243*c0e09200SDave Airlie #       define R300_FPI2_OUTA_FRC                (7 << 23)
1244*c0e09200SDave Airlie #       define R300_FPI2_OUTA_EX2                (8 << 23)
1245*c0e09200SDave Airlie #       define R300_FPI2_OUTA_LG2                (9 << 23)
1246*c0e09200SDave Airlie #       define R300_FPI2_OUTA_RCP                (10 << 23)
1247*c0e09200SDave Airlie #       define R300_FPI2_OUTA_RSQ                (11 << 23)
1248*c0e09200SDave Airlie #       define R300_FPI2_OUTA_SAT                (1 << 30)
1249*c0e09200SDave Airlie #       define R300_FPI2_UNKNOWN_31              (1 << 31)
1250*c0e09200SDave Airlie /* END: Fragment program instruction set */
1251*c0e09200SDave Airlie 
1252*c0e09200SDave Airlie /* Fog state and color */
1253*c0e09200SDave Airlie #define R300_RE_FOG_STATE                   0x4BC0
1254*c0e09200SDave Airlie #       define R300_FOG_ENABLE                   (1 << 0)
1255*c0e09200SDave Airlie #	define R300_FOG_MODE_LINEAR              (0 << 1)
1256*c0e09200SDave Airlie #	define R300_FOG_MODE_EXP                 (1 << 1)
1257*c0e09200SDave Airlie #	define R300_FOG_MODE_EXP2                (2 << 1)
1258*c0e09200SDave Airlie #	define R300_FOG_MODE_MASK                (3 << 1)
1259*c0e09200SDave Airlie #define R300_FOG_COLOR_R                    0x4BC8
1260*c0e09200SDave Airlie #define R300_FOG_COLOR_G                    0x4BCC
1261*c0e09200SDave Airlie #define R300_FOG_COLOR_B                    0x4BD0
1262*c0e09200SDave Airlie 
1263*c0e09200SDave Airlie #define R300_PP_ALPHA_TEST                  0x4BD4
1264*c0e09200SDave Airlie #       define R300_REF_ALPHA_MASK               0x000000ff
1265*c0e09200SDave Airlie #       define R300_ALPHA_TEST_FAIL              (0 << 8)
1266*c0e09200SDave Airlie #       define R300_ALPHA_TEST_LESS              (1 << 8)
1267*c0e09200SDave Airlie #       define R300_ALPHA_TEST_LEQUAL            (3 << 8)
1268*c0e09200SDave Airlie #       define R300_ALPHA_TEST_EQUAL             (2 << 8)
1269*c0e09200SDave Airlie #       define R300_ALPHA_TEST_GEQUAL            (6 << 8)
1270*c0e09200SDave Airlie #       define R300_ALPHA_TEST_GREATER           (4 << 8)
1271*c0e09200SDave Airlie #       define R300_ALPHA_TEST_NEQUAL            (5 << 8)
1272*c0e09200SDave Airlie #       define R300_ALPHA_TEST_PASS              (7 << 8)
1273*c0e09200SDave Airlie #       define R300_ALPHA_TEST_OP_MASK           (7 << 8)
1274*c0e09200SDave Airlie #       define R300_ALPHA_TEST_ENABLE            (1 << 11)
1275*c0e09200SDave Airlie 
1276*c0e09200SDave Airlie /* gap */
1277*c0e09200SDave Airlie 
1278*c0e09200SDave Airlie /* Fragment program parameters in 7.16 floating point */
1279*c0e09200SDave Airlie #define R300_PFS_PARAM_0_X                  0x4C00
1280*c0e09200SDave Airlie #define R300_PFS_PARAM_0_Y                  0x4C04
1281*c0e09200SDave Airlie #define R300_PFS_PARAM_0_Z                  0x4C08
1282*c0e09200SDave Airlie #define R300_PFS_PARAM_0_W                  0x4C0C
1283*c0e09200SDave Airlie /* GUESS: PARAM_31 is last, based on native limits reported by fglrx */
1284*c0e09200SDave Airlie #define R300_PFS_PARAM_31_X                 0x4DF0
1285*c0e09200SDave Airlie #define R300_PFS_PARAM_31_Y                 0x4DF4
1286*c0e09200SDave Airlie #define R300_PFS_PARAM_31_Z                 0x4DF8
1287*c0e09200SDave Airlie #define R300_PFS_PARAM_31_W                 0x4DFC
1288*c0e09200SDave Airlie 
1289*c0e09200SDave Airlie /* Notes:
1290*c0e09200SDave Airlie  * - AFAIK fglrx always sets BLEND_UNKNOWN when blending is used in
1291*c0e09200SDave Airlie  *   the application
1292*c0e09200SDave Airlie  * - AFAIK fglrx always sets BLEND_NO_SEPARATE when CBLEND and ABLEND
1293*c0e09200SDave Airlie  *    are set to the same
1294*c0e09200SDave Airlie  *   function (both registers are always set up completely in any case)
1295*c0e09200SDave Airlie  * - Most blend flags are simply copied from R200 and not tested yet
1296*c0e09200SDave Airlie  */
1297*c0e09200SDave Airlie #define R300_RB3D_CBLEND                    0x4E04
1298*c0e09200SDave Airlie #define R300_RB3D_ABLEND                    0x4E08
1299*c0e09200SDave Airlie /* the following only appear in CBLEND */
1300*c0e09200SDave Airlie #       define R300_BLEND_ENABLE                     (1 << 0)
1301*c0e09200SDave Airlie #       define R300_BLEND_UNKNOWN                    (3 << 1)
1302*c0e09200SDave Airlie #       define R300_BLEND_NO_SEPARATE                (1 << 3)
1303*c0e09200SDave Airlie /* the following are shared between CBLEND and ABLEND */
1304*c0e09200SDave Airlie #       define R300_FCN_MASK                         (3  << 12)
1305*c0e09200SDave Airlie #       define R300_COMB_FCN_ADD_CLAMP               (0  << 12)
1306*c0e09200SDave Airlie #       define R300_COMB_FCN_ADD_NOCLAMP             (1  << 12)
1307*c0e09200SDave Airlie #       define R300_COMB_FCN_SUB_CLAMP               (2  << 12)
1308*c0e09200SDave Airlie #       define R300_COMB_FCN_SUB_NOCLAMP             (3  << 12)
1309*c0e09200SDave Airlie #       define R300_COMB_FCN_MIN                     (4  << 12)
1310*c0e09200SDave Airlie #       define R300_COMB_FCN_MAX                     (5  << 12)
1311*c0e09200SDave Airlie #       define R300_COMB_FCN_RSUB_CLAMP              (6  << 12)
1312*c0e09200SDave Airlie #       define R300_COMB_FCN_RSUB_NOCLAMP            (7  << 12)
1313*c0e09200SDave Airlie #       define R300_BLEND_GL_ZERO                    (32)
1314*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE                     (33)
1315*c0e09200SDave Airlie #       define R300_BLEND_GL_SRC_COLOR               (34)
1316*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE_MINUS_SRC_COLOR     (35)
1317*c0e09200SDave Airlie #       define R300_BLEND_GL_DST_COLOR               (36)
1318*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE_MINUS_DST_COLOR     (37)
1319*c0e09200SDave Airlie #       define R300_BLEND_GL_SRC_ALPHA               (38)
1320*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE_MINUS_SRC_ALPHA     (39)
1321*c0e09200SDave Airlie #       define R300_BLEND_GL_DST_ALPHA               (40)
1322*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE_MINUS_DST_ALPHA     (41)
1323*c0e09200SDave Airlie #       define R300_BLEND_GL_SRC_ALPHA_SATURATE      (42)
1324*c0e09200SDave Airlie #       define R300_BLEND_GL_CONST_COLOR             (43)
1325*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE_MINUS_CONST_COLOR   (44)
1326*c0e09200SDave Airlie #       define R300_BLEND_GL_CONST_ALPHA             (45)
1327*c0e09200SDave Airlie #       define R300_BLEND_GL_ONE_MINUS_CONST_ALPHA   (46)
1328*c0e09200SDave Airlie #       define R300_BLEND_MASK                       (63)
1329*c0e09200SDave Airlie #       define R300_SRC_BLEND_SHIFT                  (16)
1330*c0e09200SDave Airlie #       define R300_DST_BLEND_SHIFT                  (24)
1331*c0e09200SDave Airlie #define R300_RB3D_BLEND_COLOR               0x4E10
1332*c0e09200SDave Airlie #define R300_RB3D_COLORMASK                 0x4E0C
1333*c0e09200SDave Airlie #       define R300_COLORMASK0_B                 (1<<0)
1334*c0e09200SDave Airlie #       define R300_COLORMASK0_G                 (1<<1)
1335*c0e09200SDave Airlie #       define R300_COLORMASK0_R                 (1<<2)
1336*c0e09200SDave Airlie #       define R300_COLORMASK0_A                 (1<<3)
1337*c0e09200SDave Airlie 
1338*c0e09200SDave Airlie /* gap */
1339*c0e09200SDave Airlie 
1340*c0e09200SDave Airlie #define R300_RB3D_COLOROFFSET0              0x4E28
1341*c0e09200SDave Airlie #       define R300_COLOROFFSET_MASK             0xFFFFFFF0 /* GUESS */
1342*c0e09200SDave Airlie #define R300_RB3D_COLOROFFSET1              0x4E2C /* GUESS */
1343*c0e09200SDave Airlie #define R300_RB3D_COLOROFFSET2              0x4E30 /* GUESS */
1344*c0e09200SDave Airlie #define R300_RB3D_COLOROFFSET3              0x4E34 /* GUESS */
1345*c0e09200SDave Airlie 
1346*c0e09200SDave Airlie /* gap */
1347*c0e09200SDave Airlie 
1348*c0e09200SDave Airlie /* Bit 16: Larger tiles
1349*c0e09200SDave Airlie  * Bit 17: 4x2 tiles
1350*c0e09200SDave Airlie  * Bit 18: Extremely weird tile like, but some pixels duplicated?
1351*c0e09200SDave Airlie  */
1352*c0e09200SDave Airlie #define R300_RB3D_COLORPITCH0               0x4E38
1353*c0e09200SDave Airlie #       define R300_COLORPITCH_MASK              0x00001FF8 /* GUESS */
1354*c0e09200SDave Airlie #       define R300_COLOR_TILE_ENABLE            (1 << 16) /* GUESS */
1355*c0e09200SDave Airlie #       define R300_COLOR_MICROTILE_ENABLE       (1 << 17) /* GUESS */
1356*c0e09200SDave Airlie #       define R300_COLOR_ENDIAN_NO_SWAP         (0 << 18) /* GUESS */
1357*c0e09200SDave Airlie #       define R300_COLOR_ENDIAN_WORD_SWAP       (1 << 18) /* GUESS */
1358*c0e09200SDave Airlie #       define R300_COLOR_ENDIAN_DWORD_SWAP      (2 << 18) /* GUESS */
1359*c0e09200SDave Airlie #       define R300_COLOR_FORMAT_RGB565          (2 << 22)
1360*c0e09200SDave Airlie #       define R300_COLOR_FORMAT_ARGB8888        (3 << 22)
1361*c0e09200SDave Airlie #define R300_RB3D_COLORPITCH1               0x4E3C /* GUESS */
1362*c0e09200SDave Airlie #define R300_RB3D_COLORPITCH2               0x4E40 /* GUESS */
1363*c0e09200SDave Airlie #define R300_RB3D_COLORPITCH3               0x4E44 /* GUESS */
1364*c0e09200SDave Airlie 
1365*c0e09200SDave Airlie /* gap */
1366*c0e09200SDave Airlie 
1367*c0e09200SDave Airlie /* Guess by Vladimir.
1368*c0e09200SDave Airlie  * Set to 0A before 3D operations, set to 02 afterwards.
1369*c0e09200SDave Airlie  */
1370*c0e09200SDave Airlie /*#define R300_RB3D_DSTCACHE_CTLSTAT          0x4E4C*/
1371*c0e09200SDave Airlie #       define R300_RB3D_DSTCACHE_UNKNOWN_02             0x00000002
1372*c0e09200SDave Airlie #       define R300_RB3D_DSTCACHE_UNKNOWN_0A             0x0000000A
1373*c0e09200SDave Airlie 
1374*c0e09200SDave Airlie /* gap */
1375*c0e09200SDave Airlie /* There seems to be no "write only" setting, so use Z-test = ALWAYS
1376*c0e09200SDave Airlie  * for this.
1377*c0e09200SDave Airlie  * Bit (1<<8) is the "test" bit. so plain write is 6  - vd
1378*c0e09200SDave Airlie  */
1379*c0e09200SDave Airlie #define R300_ZB_CNTL                             0x4F00
1380*c0e09200SDave Airlie #	define R300_STENCIL_ENABLE		 (1 << 0)
1381*c0e09200SDave Airlie #	define R300_Z_ENABLE		         (1 << 1)
1382*c0e09200SDave Airlie #	define R300_Z_WRITE_ENABLE		 (1 << 2)
1383*c0e09200SDave Airlie #	define R300_Z_SIGNED_COMPARE		 (1 << 3)
1384*c0e09200SDave Airlie #	define R300_STENCIL_FRONT_BACK		 (1 << 4)
1385*c0e09200SDave Airlie 
1386*c0e09200SDave Airlie #define R300_ZB_ZSTENCILCNTL                   0x4f04
1387*c0e09200SDave Airlie 	/* functions */
1388*c0e09200SDave Airlie #	define R300_ZS_NEVER			0
1389*c0e09200SDave Airlie #	define R300_ZS_LESS			1
1390*c0e09200SDave Airlie #	define R300_ZS_LEQUAL			2
1391*c0e09200SDave Airlie #	define R300_ZS_EQUAL			3
1392*c0e09200SDave Airlie #	define R300_ZS_GEQUAL			4
1393*c0e09200SDave Airlie #	define R300_ZS_GREATER			5
1394*c0e09200SDave Airlie #	define R300_ZS_NOTEQUAL			6
1395*c0e09200SDave Airlie #	define R300_ZS_ALWAYS			7
1396*c0e09200SDave Airlie #       define R300_ZS_MASK                     7
1397*c0e09200SDave Airlie 	/* operations */
1398*c0e09200SDave Airlie #	define R300_ZS_KEEP			0
1399*c0e09200SDave Airlie #	define R300_ZS_ZERO			1
1400*c0e09200SDave Airlie #	define R300_ZS_REPLACE			2
1401*c0e09200SDave Airlie #	define R300_ZS_INCR			3
1402*c0e09200SDave Airlie #	define R300_ZS_DECR			4
1403*c0e09200SDave Airlie #	define R300_ZS_INVERT			5
1404*c0e09200SDave Airlie #	define R300_ZS_INCR_WRAP		6
1405*c0e09200SDave Airlie #	define R300_ZS_DECR_WRAP		7
1406*c0e09200SDave Airlie #	define R300_Z_FUNC_SHIFT		0
1407*c0e09200SDave Airlie 	/* front and back refer to operations done for front
1408*c0e09200SDave Airlie 	   and back faces, i.e. separate stencil function support */
1409*c0e09200SDave Airlie #	define R300_S_FRONT_FUNC_SHIFT	        3
1410*c0e09200SDave Airlie #	define R300_S_FRONT_SFAIL_OP_SHIFT	6
1411*c0e09200SDave Airlie #	define R300_S_FRONT_ZPASS_OP_SHIFT	9
1412*c0e09200SDave Airlie #	define R300_S_FRONT_ZFAIL_OP_SHIFT      12
1413*c0e09200SDave Airlie #	define R300_S_BACK_FUNC_SHIFT           15
1414*c0e09200SDave Airlie #	define R300_S_BACK_SFAIL_OP_SHIFT       18
1415*c0e09200SDave Airlie #	define R300_S_BACK_ZPASS_OP_SHIFT       21
1416*c0e09200SDave Airlie #	define R300_S_BACK_ZFAIL_OP_SHIFT       24
1417*c0e09200SDave Airlie 
1418*c0e09200SDave Airlie #define R300_ZB_STENCILREFMASK                        0x4f08
1419*c0e09200SDave Airlie #	define R300_STENCILREF_SHIFT       0
1420*c0e09200SDave Airlie #	define R300_STENCILREF_MASK        0x000000ff
1421*c0e09200SDave Airlie #	define R300_STENCILMASK_SHIFT      8
1422*c0e09200SDave Airlie #	define R300_STENCILMASK_MASK       0x0000ff00
1423*c0e09200SDave Airlie #	define R300_STENCILWRITEMASK_SHIFT 16
1424*c0e09200SDave Airlie #	define R300_STENCILWRITEMASK_MASK  0x00ff0000
1425*c0e09200SDave Airlie 
1426*c0e09200SDave Airlie /* gap */
1427*c0e09200SDave Airlie 
1428*c0e09200SDave Airlie #define R300_ZB_FORMAT                             0x4f10
1429*c0e09200SDave Airlie #	define R300_DEPTHFORMAT_16BIT_INT_Z   (0 << 0)
1430*c0e09200SDave Airlie #	define R300_DEPTHFORMAT_16BIT_13E3    (1 << 0)
1431*c0e09200SDave Airlie #	define R300_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL   (2 << 0)
1432*c0e09200SDave Airlie /* reserved up to (15 << 0) */
1433*c0e09200SDave Airlie #	define R300_INVERT_13E3_LEADING_ONES  (0 << 4)
1434*c0e09200SDave Airlie #	define R300_INVERT_13E3_LEADING_ZEROS (1 << 4)
1435*c0e09200SDave Airlie 
1436*c0e09200SDave Airlie #define R300_ZB_ZTOP                             0x4F14
1437*c0e09200SDave Airlie #	define R300_ZTOP_DISABLE                 (0 << 0)
1438*c0e09200SDave Airlie #	define R300_ZTOP_ENABLE                  (1 << 0)
1439*c0e09200SDave Airlie 
1440*c0e09200SDave Airlie /* gap */
1441*c0e09200SDave Airlie 
1442*c0e09200SDave Airlie #define R300_ZB_ZCACHE_CTLSTAT            0x4f18
1443*c0e09200SDave Airlie #       define R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_NO_EFFECT      (0 << 0)
1444*c0e09200SDave Airlie #       define R300_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE (1 << 0)
1445*c0e09200SDave Airlie #       define R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_NO_EFFECT       (0 << 1)
1446*c0e09200SDave Airlie #       define R300_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE            (1 << 1)
1447*c0e09200SDave Airlie #       define R300_ZB_ZCACHE_CTLSTAT_ZC_BUSY_IDLE            (0 << 31)
1448*c0e09200SDave Airlie #       define R300_ZB_ZCACHE_CTLSTAT_ZC_BUSY_BUSY            (1 << 31)
1449*c0e09200SDave Airlie 
1450*c0e09200SDave Airlie #define R300_ZB_BW_CNTL                     0x4f1c
1451*c0e09200SDave Airlie #	define R300_HIZ_DISABLE                              (0 << 0)
1452*c0e09200SDave Airlie #	define R300_HIZ_ENABLE                               (1 << 0)
1453*c0e09200SDave Airlie #	define R300_HIZ_MIN                                  (0 << 1)
1454*c0e09200SDave Airlie #	define R300_HIZ_MAX                                  (1 << 1)
1455*c0e09200SDave Airlie #	define R300_FAST_FILL_DISABLE                        (0 << 2)
1456*c0e09200SDave Airlie #	define R300_FAST_FILL_ENABLE                         (1 << 2)
1457*c0e09200SDave Airlie #	define R300_RD_COMP_DISABLE                          (0 << 3)
1458*c0e09200SDave Airlie #	define R300_RD_COMP_ENABLE                           (1 << 3)
1459*c0e09200SDave Airlie #	define R300_WR_COMP_DISABLE                          (0 << 4)
1460*c0e09200SDave Airlie #	define R300_WR_COMP_ENABLE                           (1 << 4)
1461*c0e09200SDave Airlie #	define R300_ZB_CB_CLEAR_RMW                          (0 << 5)
1462*c0e09200SDave Airlie #	define R300_ZB_CB_CLEAR_CACHE_LINEAR                 (1 << 5)
1463*c0e09200SDave Airlie #	define R300_FORCE_COMPRESSED_STENCIL_VALUE_DISABLE   (0 << 6)
1464*c0e09200SDave Airlie #	define R300_FORCE_COMPRESSED_STENCIL_VALUE_ENABLE    (1 << 6)
1465*c0e09200SDave Airlie 
1466*c0e09200SDave Airlie #	define R500_ZEQUAL_OPTIMIZE_ENABLE                   (0 << 7)
1467*c0e09200SDave Airlie #	define R500_ZEQUAL_OPTIMIZE_DISABLE                  (1 << 7)
1468*c0e09200SDave Airlie #	define R500_SEQUAL_OPTIMIZE_ENABLE                   (0 << 8)
1469*c0e09200SDave Airlie #	define R500_SEQUAL_OPTIMIZE_DISABLE                  (1 << 8)
1470*c0e09200SDave Airlie 
1471*c0e09200SDave Airlie #	define R500_BMASK_ENABLE                             (0 << 10)
1472*c0e09200SDave Airlie #	define R500_BMASK_DISABLE                            (1 << 10)
1473*c0e09200SDave Airlie #	define R500_HIZ_EQUAL_REJECT_DISABLE                 (0 << 11)
1474*c0e09200SDave Airlie #	define R500_HIZ_EQUAL_REJECT_ENABLE                  (1 << 11)
1475*c0e09200SDave Airlie #	define R500_HIZ_FP_EXP_BITS_DISABLE                  (0 << 12)
1476*c0e09200SDave Airlie #	define R500_HIZ_FP_EXP_BITS_1                        (1 << 12)
1477*c0e09200SDave Airlie #	define R500_HIZ_FP_EXP_BITS_2                        (2 << 12)
1478*c0e09200SDave Airlie #	define R500_HIZ_FP_EXP_BITS_3                        (3 << 12)
1479*c0e09200SDave Airlie #	define R500_HIZ_FP_EXP_BITS_4                        (4 << 12)
1480*c0e09200SDave Airlie #	define R500_HIZ_FP_EXP_BITS_5                        (5 << 12)
1481*c0e09200SDave Airlie #	define R500_HIZ_FP_INVERT_LEADING_ONES               (0 << 15)
1482*c0e09200SDave Airlie #	define R500_HIZ_FP_INVERT_LEADING_ZEROS              (1 << 15)
1483*c0e09200SDave Airlie #	define R500_TILE_OVERWRITE_RECOMPRESSION_ENABLE      (0 << 16)
1484*c0e09200SDave Airlie #	define R500_TILE_OVERWRITE_RECOMPRESSION_DISABLE     (1 << 16)
1485*c0e09200SDave Airlie #	define R500_CONTIGUOUS_6XAA_SAMPLES_ENABLE           (0 << 17)
1486*c0e09200SDave Airlie #	define R500_CONTIGUOUS_6XAA_SAMPLES_DISABLE          (1 << 17)
1487*c0e09200SDave Airlie #	define R500_PEQ_PACKING_DISABLE                      (0 << 18)
1488*c0e09200SDave Airlie #	define R500_PEQ_PACKING_ENABLE                       (1 << 18)
1489*c0e09200SDave Airlie #	define R500_COVERED_PTR_MASKING_DISABLE              (0 << 18)
1490*c0e09200SDave Airlie #	define R500_COVERED_PTR_MASKING_ENABLE               (1 << 18)
1491*c0e09200SDave Airlie 
1492*c0e09200SDave Airlie 
1493*c0e09200SDave Airlie /* gap */
1494*c0e09200SDave Airlie 
1495*c0e09200SDave Airlie /* Z Buffer Address Offset.
1496*c0e09200SDave Airlie  * Bits 31 to 5 are used for aligned Z buffer address offset for macro tiles.
1497*c0e09200SDave Airlie  */
1498*c0e09200SDave Airlie #define R300_ZB_DEPTHOFFSET               0x4f20
1499*c0e09200SDave Airlie 
1500*c0e09200SDave Airlie /* Z Buffer Pitch and Endian Control */
1501*c0e09200SDave Airlie #define R300_ZB_DEPTHPITCH                0x4f24
1502*c0e09200SDave Airlie #       define R300_DEPTHPITCH_MASK              0x00003FFC
1503*c0e09200SDave Airlie #       define R300_DEPTHMACROTILE_DISABLE      (0 << 16)
1504*c0e09200SDave Airlie #       define R300_DEPTHMACROTILE_ENABLE       (1 << 16)
1505*c0e09200SDave Airlie #       define R300_DEPTHMICROTILE_LINEAR       (0 << 17)
1506*c0e09200SDave Airlie #       define R300_DEPTHMICROTILE_TILED        (1 << 17)
1507*c0e09200SDave Airlie #       define R300_DEPTHMICROTILE_TILED_SQUARE (2 << 17)
1508*c0e09200SDave Airlie #       define R300_DEPTHENDIAN_NO_SWAP         (0 << 18)
1509*c0e09200SDave Airlie #       define R300_DEPTHENDIAN_WORD_SWAP       (1 << 18)
1510*c0e09200SDave Airlie #       define R300_DEPTHENDIAN_DWORD_SWAP      (2 << 18)
1511*c0e09200SDave Airlie #       define R300_DEPTHENDIAN_HALF_DWORD_SWAP (3 << 18)
1512*c0e09200SDave Airlie 
1513*c0e09200SDave Airlie /* Z Buffer Clear Value */
1514*c0e09200SDave Airlie #define R300_ZB_DEPTHCLEARVALUE                  0x4f28
1515*c0e09200SDave Airlie 
1516*c0e09200SDave Airlie #define R300_ZB_ZMASK_OFFSET			 0x4f30
1517*c0e09200SDave Airlie #define R300_ZB_ZMASK_PITCH			 0x4f34
1518*c0e09200SDave Airlie #define R300_ZB_ZMASK_WRINDEX			 0x4f38
1519*c0e09200SDave Airlie #define R300_ZB_ZMASK_DWORD			 0x4f3c
1520*c0e09200SDave Airlie #define R300_ZB_ZMASK_RDINDEX			 0x4f40
1521*c0e09200SDave Airlie 
1522*c0e09200SDave Airlie /* Hierarchical Z Memory Offset */
1523*c0e09200SDave Airlie #define R300_ZB_HIZ_OFFSET                       0x4f44
1524*c0e09200SDave Airlie 
1525*c0e09200SDave Airlie /* Hierarchical Z Write Index */
1526*c0e09200SDave Airlie #define R300_ZB_HIZ_WRINDEX                      0x4f48
1527*c0e09200SDave Airlie 
1528*c0e09200SDave Airlie /* Hierarchical Z Data */
1529*c0e09200SDave Airlie #define R300_ZB_HIZ_DWORD                        0x4f4c
1530*c0e09200SDave Airlie 
1531*c0e09200SDave Airlie /* Hierarchical Z Read Index */
1532*c0e09200SDave Airlie #define R300_ZB_HIZ_RDINDEX                      0x4f50
1533*c0e09200SDave Airlie 
1534*c0e09200SDave Airlie /* Hierarchical Z Pitch */
1535*c0e09200SDave Airlie #define R300_ZB_HIZ_PITCH                        0x4f54
1536*c0e09200SDave Airlie 
1537*c0e09200SDave Airlie /* Z Buffer Z Pass Counter Data */
1538*c0e09200SDave Airlie #define R300_ZB_ZPASS_DATA                       0x4f58
1539*c0e09200SDave Airlie 
1540*c0e09200SDave Airlie /* Z Buffer Z Pass Counter Address */
1541*c0e09200SDave Airlie #define R300_ZB_ZPASS_ADDR                       0x4f5c
1542*c0e09200SDave Airlie 
1543*c0e09200SDave Airlie /* Depth buffer X and Y coordinate offset */
1544*c0e09200SDave Airlie #define R300_ZB_DEPTHXY_OFFSET                   0x4f60
1545*c0e09200SDave Airlie #	define R300_DEPTHX_OFFSET_SHIFT  1
1546*c0e09200SDave Airlie #	define R300_DEPTHX_OFFSET_MASK   0x000007FE
1547*c0e09200SDave Airlie #	define R300_DEPTHY_OFFSET_SHIFT  17
1548*c0e09200SDave Airlie #	define R300_DEPTHY_OFFSET_MASK   0x07FE0000
1549*c0e09200SDave Airlie 
1550*c0e09200SDave Airlie /* Sets the fifo sizes */
1551*c0e09200SDave Airlie #define R500_ZB_FIFO_SIZE                        0x4fd0
1552*c0e09200SDave Airlie #	define R500_OP_FIFO_SIZE_FULL   (0 << 0)
1553*c0e09200SDave Airlie #	define R500_OP_FIFO_SIZE_HALF   (1 << 0)
1554*c0e09200SDave Airlie #	define R500_OP_FIFO_SIZE_QUATER (2 << 0)
1555*c0e09200SDave Airlie #	define R500_OP_FIFO_SIZE_EIGTHS (4 << 0)
1556*c0e09200SDave Airlie 
1557*c0e09200SDave Airlie /* Stencil Reference Value and Mask for backfacing quads */
1558*c0e09200SDave Airlie /* R300_ZB_STENCILREFMASK handles front face */
1559*c0e09200SDave Airlie #define R500_ZB_STENCILREFMASK_BF                0x4fd4
1560*c0e09200SDave Airlie #	define R500_STENCILREF_SHIFT       0
1561*c0e09200SDave Airlie #	define R500_STENCILREF_MASK        0x000000ff
1562*c0e09200SDave Airlie #	define R500_STENCILMASK_SHIFT      8
1563*c0e09200SDave Airlie #	define R500_STENCILMASK_MASK       0x0000ff00
1564*c0e09200SDave Airlie #	define R500_STENCILWRITEMASK_SHIFT 16
1565*c0e09200SDave Airlie #	define R500_STENCILWRITEMASK_MASK  0x00ff0000
1566*c0e09200SDave Airlie 
1567*c0e09200SDave Airlie /* BEGIN: Vertex program instruction set */
1568*c0e09200SDave Airlie 
1569*c0e09200SDave Airlie /* Every instruction is four dwords long:
1570*c0e09200SDave Airlie  *  DWORD 0: output and opcode
1571*c0e09200SDave Airlie  *  DWORD 1: first argument
1572*c0e09200SDave Airlie  *  DWORD 2: second argument
1573*c0e09200SDave Airlie  *  DWORD 3: third argument
1574*c0e09200SDave Airlie  *
1575*c0e09200SDave Airlie  * Notes:
1576*c0e09200SDave Airlie  *  - ABS r, a is implemented as MAX r, a, -a
1577*c0e09200SDave Airlie  *  - MOV is implemented as ADD to zero
1578*c0e09200SDave Airlie  *  - XPD is implemented as MUL + MAD
1579*c0e09200SDave Airlie  *  - FLR is implemented as FRC + ADD
1580*c0e09200SDave Airlie  *  - apparently, fglrx tries to schedule instructions so that there is at
1581*c0e09200SDave Airlie  *    least one instruction between the write to a temporary and the first
1582*c0e09200SDave Airlie  *    read from said temporary; however, violations of this scheduling are
1583*c0e09200SDave Airlie  *    allowed
1584*c0e09200SDave Airlie  *  - register indices seem to be unrelated with OpenGL aliasing to
1585*c0e09200SDave Airlie  *    conventional state
1586*c0e09200SDave Airlie  *  - only one attribute and one parameter can be loaded at a time; however,
1587*c0e09200SDave Airlie  *    the same attribute/parameter can be used for more than one argument
1588*c0e09200SDave Airlie  *  - the second software argument for POW is the third hardware argument
1589*c0e09200SDave Airlie  *    (no idea why)
1590*c0e09200SDave Airlie  *  - MAD with only temporaries as input seems to use VPI_OUT_SELECT_MAD_2
1591*c0e09200SDave Airlie  *
1592*c0e09200SDave Airlie  * There is some magic surrounding LIT:
1593*c0e09200SDave Airlie  *   The single argument is replicated across all three inputs, but swizzled:
1594*c0e09200SDave Airlie  *     First argument: xyzy
1595*c0e09200SDave Airlie  *     Second argument: xyzx
1596*c0e09200SDave Airlie  *     Third argument: xyzw
1597*c0e09200SDave Airlie  *   Whenever the result is used later in the fragment program, fglrx forces
1598*c0e09200SDave Airlie  *   x and w to be 1.0 in the input selection; I don't know whether this is
1599*c0e09200SDave Airlie  *   strictly necessary
1600*c0e09200SDave Airlie  */
1601*c0e09200SDave Airlie #define R300_VPI_OUT_OP_DOT                     (1 << 0)
1602*c0e09200SDave Airlie #define R300_VPI_OUT_OP_MUL                     (2 << 0)
1603*c0e09200SDave Airlie #define R300_VPI_OUT_OP_ADD                     (3 << 0)
1604*c0e09200SDave Airlie #define R300_VPI_OUT_OP_MAD                     (4 << 0)
1605*c0e09200SDave Airlie #define R300_VPI_OUT_OP_DST                     (5 << 0)
1606*c0e09200SDave Airlie #define R300_VPI_OUT_OP_FRC                     (6 << 0)
1607*c0e09200SDave Airlie #define R300_VPI_OUT_OP_MAX                     (7 << 0)
1608*c0e09200SDave Airlie #define R300_VPI_OUT_OP_MIN                     (8 << 0)
1609*c0e09200SDave Airlie #define R300_VPI_OUT_OP_SGE                     (9 << 0)
1610*c0e09200SDave Airlie #define R300_VPI_OUT_OP_SLT                     (10 << 0)
1611*c0e09200SDave Airlie 	/* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, vector(scalar, vector) */
1612*c0e09200SDave Airlie #define R300_VPI_OUT_OP_UNK12                   (12 << 0)
1613*c0e09200SDave Airlie #define R300_VPI_OUT_OP_ARL                     (13 << 0)
1614*c0e09200SDave Airlie #define R300_VPI_OUT_OP_EXP                     (65 << 0)
1615*c0e09200SDave Airlie #define R300_VPI_OUT_OP_LOG                     (66 << 0)
1616*c0e09200SDave Airlie 	/* Used in fog computations, scalar(scalar) */
1617*c0e09200SDave Airlie #define R300_VPI_OUT_OP_UNK67                   (67 << 0)
1618*c0e09200SDave Airlie #define R300_VPI_OUT_OP_LIT                     (68 << 0)
1619*c0e09200SDave Airlie #define R300_VPI_OUT_OP_POW                     (69 << 0)
1620*c0e09200SDave Airlie #define R300_VPI_OUT_OP_RCP                     (70 << 0)
1621*c0e09200SDave Airlie #define R300_VPI_OUT_OP_RSQ                     (72 << 0)
1622*c0e09200SDave Airlie 	/* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, scalar(scalar) */
1623*c0e09200SDave Airlie #define R300_VPI_OUT_OP_UNK73                   (73 << 0)
1624*c0e09200SDave Airlie #define R300_VPI_OUT_OP_EX2                     (75 << 0)
1625*c0e09200SDave Airlie #define R300_VPI_OUT_OP_LG2                     (76 << 0)
1626*c0e09200SDave Airlie #define R300_VPI_OUT_OP_MAD_2                   (128 << 0)
1627*c0e09200SDave Airlie 	/* all temps, vector(scalar, vector, vector) */
1628*c0e09200SDave Airlie #define R300_VPI_OUT_OP_UNK129                  (129 << 0)
1629*c0e09200SDave Airlie 
1630*c0e09200SDave Airlie #define R300_VPI_OUT_REG_CLASS_TEMPORARY        (0 << 8)
1631*c0e09200SDave Airlie #define R300_VPI_OUT_REG_CLASS_ADDR             (1 << 8)
1632*c0e09200SDave Airlie #define R300_VPI_OUT_REG_CLASS_RESULT           (2 << 8)
1633*c0e09200SDave Airlie #define R300_VPI_OUT_REG_CLASS_MASK             (31 << 8)
1634*c0e09200SDave Airlie 
1635*c0e09200SDave Airlie #define R300_VPI_OUT_REG_INDEX_SHIFT            13
1636*c0e09200SDave Airlie 	/* GUESS based on fglrx native limits */
1637*c0e09200SDave Airlie #define R300_VPI_OUT_REG_INDEX_MASK             (31 << 13)
1638*c0e09200SDave Airlie 
1639*c0e09200SDave Airlie #define R300_VPI_OUT_WRITE_X                    (1 << 20)
1640*c0e09200SDave Airlie #define R300_VPI_OUT_WRITE_Y                    (1 << 21)
1641*c0e09200SDave Airlie #define R300_VPI_OUT_WRITE_Z                    (1 << 22)
1642*c0e09200SDave Airlie #define R300_VPI_OUT_WRITE_W                    (1 << 23)
1643*c0e09200SDave Airlie 
1644*c0e09200SDave Airlie #define R300_VPI_IN_REG_CLASS_TEMPORARY         (0 << 0)
1645*c0e09200SDave Airlie #define R300_VPI_IN_REG_CLASS_ATTRIBUTE         (1 << 0)
1646*c0e09200SDave Airlie #define R300_VPI_IN_REG_CLASS_PARAMETER         (2 << 0)
1647*c0e09200SDave Airlie #define R300_VPI_IN_REG_CLASS_NONE              (9 << 0)
1648*c0e09200SDave Airlie #define R300_VPI_IN_REG_CLASS_MASK              (31 << 0)
1649*c0e09200SDave Airlie 
1650*c0e09200SDave Airlie #define R300_VPI_IN_REG_INDEX_SHIFT             5
1651*c0e09200SDave Airlie 	/* GUESS based on fglrx native limits */
1652*c0e09200SDave Airlie #define R300_VPI_IN_REG_INDEX_MASK              (255 << 5)
1653*c0e09200SDave Airlie 
1654*c0e09200SDave Airlie /* The R300 can select components from the input register arbitrarily.
1655*c0e09200SDave Airlie  * Use the following constants, shifted by the component shift you
1656*c0e09200SDave Airlie  * want to select
1657*c0e09200SDave Airlie  */
1658*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_X    0
1659*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_Y    1
1660*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_Z    2
1661*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_W    3
1662*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_ZERO 4
1663*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_ONE  5
1664*c0e09200SDave Airlie #define R300_VPI_IN_SELECT_MASK 7
1665*c0e09200SDave Airlie 
1666*c0e09200SDave Airlie #define R300_VPI_IN_X_SHIFT                     13
1667*c0e09200SDave Airlie #define R300_VPI_IN_Y_SHIFT                     16
1668*c0e09200SDave Airlie #define R300_VPI_IN_Z_SHIFT                     19
1669*c0e09200SDave Airlie #define R300_VPI_IN_W_SHIFT                     22
1670*c0e09200SDave Airlie 
1671*c0e09200SDave Airlie #define R300_VPI_IN_NEG_X                       (1 << 25)
1672*c0e09200SDave Airlie #define R300_VPI_IN_NEG_Y                       (1 << 26)
1673*c0e09200SDave Airlie #define R300_VPI_IN_NEG_Z                       (1 << 27)
1674*c0e09200SDave Airlie #define R300_VPI_IN_NEG_W                       (1 << 28)
1675*c0e09200SDave Airlie /* END: Vertex program instruction set */
1676*c0e09200SDave Airlie 
1677*c0e09200SDave Airlie /* BEGIN: Packet 3 commands */
1678*c0e09200SDave Airlie 
1679*c0e09200SDave Airlie /* A primitive emission dword. */
1680*c0e09200SDave Airlie #define R300_PRIM_TYPE_NONE                     (0 << 0)
1681*c0e09200SDave Airlie #define R300_PRIM_TYPE_POINT                    (1 << 0)
1682*c0e09200SDave Airlie #define R300_PRIM_TYPE_LINE                     (2 << 0)
1683*c0e09200SDave Airlie #define R300_PRIM_TYPE_LINE_STRIP               (3 << 0)
1684*c0e09200SDave Airlie #define R300_PRIM_TYPE_TRI_LIST                 (4 << 0)
1685*c0e09200SDave Airlie #define R300_PRIM_TYPE_TRI_FAN                  (5 << 0)
1686*c0e09200SDave Airlie #define R300_PRIM_TYPE_TRI_STRIP                (6 << 0)
1687*c0e09200SDave Airlie #define R300_PRIM_TYPE_TRI_TYPE2                (7 << 0)
1688*c0e09200SDave Airlie #define R300_PRIM_TYPE_RECT_LIST                (8 << 0)
1689*c0e09200SDave Airlie #define R300_PRIM_TYPE_3VRT_POINT_LIST          (9 << 0)
1690*c0e09200SDave Airlie #define R300_PRIM_TYPE_3VRT_LINE_LIST           (10 << 0)
1691*c0e09200SDave Airlie 	/* GUESS (based on r200) */
1692*c0e09200SDave Airlie #define R300_PRIM_TYPE_POINT_SPRITES            (11 << 0)
1693*c0e09200SDave Airlie #define R300_PRIM_TYPE_LINE_LOOP                (12 << 0)
1694*c0e09200SDave Airlie #define R300_PRIM_TYPE_QUADS                    (13 << 0)
1695*c0e09200SDave Airlie #define R300_PRIM_TYPE_QUAD_STRIP               (14 << 0)
1696*c0e09200SDave Airlie #define R300_PRIM_TYPE_POLYGON                  (15 << 0)
1697*c0e09200SDave Airlie #define R300_PRIM_TYPE_MASK                     0xF
1698*c0e09200SDave Airlie #define R300_PRIM_WALK_IND                      (1 << 4)
1699*c0e09200SDave Airlie #define R300_PRIM_WALK_LIST                     (2 << 4)
1700*c0e09200SDave Airlie #define R300_PRIM_WALK_RING                     (3 << 4)
1701*c0e09200SDave Airlie #define R300_PRIM_WALK_MASK                     (3 << 4)
1702*c0e09200SDave Airlie 	/* GUESS (based on r200) */
1703*c0e09200SDave Airlie #define R300_PRIM_COLOR_ORDER_BGRA              (0 << 6)
1704*c0e09200SDave Airlie #define R300_PRIM_COLOR_ORDER_RGBA              (1 << 6)
1705*c0e09200SDave Airlie #define R300_PRIM_NUM_VERTICES_SHIFT            16
1706*c0e09200SDave Airlie #define R300_PRIM_NUM_VERTICES_MASK             0xffff
1707*c0e09200SDave Airlie 
1708*c0e09200SDave Airlie /* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR.
1709*c0e09200SDave Airlie  * Two parameter dwords:
1710*c0e09200SDave Airlie  * 0. The first parameter appears to be always 0
1711*c0e09200SDave Airlie  * 1. The second parameter is a standard primitive emission dword.
1712*c0e09200SDave Airlie  */
1713*c0e09200SDave Airlie #define R300_PACKET3_3D_DRAW_VBUF           0x00002800
1714*c0e09200SDave Airlie 
1715*c0e09200SDave Airlie /* Specify the full set of vertex arrays as (address, stride).
1716*c0e09200SDave Airlie  * The first parameter is the number of vertex arrays specified.
1717*c0e09200SDave Airlie  * The rest of the command is a variable length list of blocks, where
1718*c0e09200SDave Airlie  * each block is three dwords long and specifies two arrays.
1719*c0e09200SDave Airlie  * The first dword of a block is split into two words, the lower significant
1720*c0e09200SDave Airlie  * word refers to the first array, the more significant word to the second
1721*c0e09200SDave Airlie  * array in the block.
1722*c0e09200SDave Airlie  * The low byte of each word contains the size of an array entry in dwords,
1723*c0e09200SDave Airlie  * the high byte contains the stride of the array.
1724*c0e09200SDave Airlie  * The second dword of a block contains the pointer to the first array,
1725*c0e09200SDave Airlie  * the third dword of a block contains the pointer to the second array.
1726*c0e09200SDave Airlie  * Note that if the total number of arrays is odd, the third dword of
1727*c0e09200SDave Airlie  * the last block is omitted.
1728*c0e09200SDave Airlie  */
1729*c0e09200SDave Airlie #define R300_PACKET3_3D_LOAD_VBPNTR         0x00002F00
1730*c0e09200SDave Airlie 
1731*c0e09200SDave Airlie #define R300_PACKET3_INDX_BUFFER            0x00003300
1732*c0e09200SDave Airlie #    define R300_EB_UNK1_SHIFT                      24
1733*c0e09200SDave Airlie #    define R300_EB_UNK1                    (0x80<<24)
1734*c0e09200SDave Airlie #    define R300_EB_UNK2                        0x0810
1735*c0e09200SDave Airlie #define R300_PACKET3_3D_DRAW_VBUF_2         0x00003400
1736*c0e09200SDave Airlie #define R300_PACKET3_3D_DRAW_INDX_2         0x00003600
1737*c0e09200SDave Airlie 
1738*c0e09200SDave Airlie /* END: Packet 3 commands */
1739*c0e09200SDave Airlie 
1740*c0e09200SDave Airlie 
1741*c0e09200SDave Airlie /* Color formats for 2d packets
1742*c0e09200SDave Airlie  */
1743*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_CI8	2
1744*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_ARGB1555	3
1745*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_RGB565	4
1746*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_ARGB8888	6
1747*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_RGB332	7
1748*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_RGB8	9
1749*c0e09200SDave Airlie #define R300_CP_COLOR_FORMAT_ARGB4444	15
1750*c0e09200SDave Airlie 
1751*c0e09200SDave Airlie /*
1752*c0e09200SDave Airlie  * CP type-3 packets
1753*c0e09200SDave Airlie  */
1754*c0e09200SDave Airlie #define R300_CP_CMD_BITBLT_MULTI	0xC0009B00
1755*c0e09200SDave Airlie 
1756*c0e09200SDave Airlie #define R500_VAP_INDEX_OFFSET		0x208c
1757*c0e09200SDave Airlie 
1758*c0e09200SDave Airlie #define R500_GA_US_VECTOR_INDEX         0x4250
1759*c0e09200SDave Airlie #define R500_GA_US_VECTOR_DATA          0x4254
1760*c0e09200SDave Airlie 
1761*c0e09200SDave Airlie #define R500_RS_IP_0                    0x4074
1762*c0e09200SDave Airlie #define R500_RS_INST_0                  0x4320
1763*c0e09200SDave Airlie 
1764*c0e09200SDave Airlie #define R500_US_CONFIG                  0x4600
1765*c0e09200SDave Airlie 
1766*c0e09200SDave Airlie #define R500_US_FC_CTRL			0x4624
1767*c0e09200SDave Airlie #define R500_US_CODE_ADDR		0x4630
1768*c0e09200SDave Airlie 
1769*c0e09200SDave Airlie #define R500_RB3D_COLOR_CLEAR_VALUE_AR  0x46c0
1770*c0e09200SDave Airlie #define R500_RB3D_CONSTANT_COLOR_AR     0x4ef8
1771*c0e09200SDave Airlie 
1772*c0e09200SDave Airlie #endif /* _R300_REG_H */
1773