73ce069e4f894f2dd8de464a6a5a39210677ae3f
[mesa.git] / src / mesa / drivers / dri / r600 / r600_reg.h
1 /**************************************************************************
2
3 Copyright (C) 2004-2005 Nicolai Haehnle et al.
4
5 Permission is hereby granted, free of charge, to any person obtaining a
6 copy of this software and associated documentation files (the "Software"),
7 to deal in the Software without restriction, including without limitation
8 on the rights to use, copy, modify, merge, publish, distribute, sub
9 license, and/or sell copies of the Software, and to permit persons to whom
10 the Software is furnished to do so, subject to the following conditions:
11
12 The above copyright notice and this permission notice (including the next
13 paragraph) shall be included in all copies or substantial portions of the
14 Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 **************************************************************************/
25
26 /* *INDENT-OFF* */
27
28 #ifndef _R600_REG_H
29 #define _R600_REG_H
30
31 #define R600_MC_INIT_MISC_LAT_TIMER 0x180
32 # define R600_MC_MISC__MC_CPR_INIT_LAT_SHIFT 0
33 # define R600_MC_MISC__MC_VF_INIT_LAT_SHIFT 4
34 # define R600_MC_MISC__MC_DISP0R_INIT_LAT_SHIFT 8
35 # define R600_MC_MISC__MC_DISP1R_INIT_LAT_SHIFT 12
36 # define R600_MC_MISC__MC_FIXED_INIT_LAT_SHIFT 16
37 # define R600_MC_MISC__MC_E2R_INIT_LAT_SHIFT 20
38 # define R600_MC_MISC__MC_SAME_PAGE_PRIO_SHIFT 24
39 # define R600_MC_MISC__MC_GLOBW_INIT_LAT_SHIFT 28
40
41
42 #define R600_MC_INIT_GFX_LAT_TIMER 0x154
43 # define R600_MC_MISC__MC_G3D0R_INIT_LAT_SHIFT 0
44 # define R600_MC_MISC__MC_G3D1R_INIT_LAT_SHIFT 4
45 # define R600_MC_MISC__MC_G3D2R_INIT_LAT_SHIFT 8
46 # define R600_MC_MISC__MC_G3D3R_INIT_LAT_SHIFT 12
47 # define R600_MC_MISC__MC_TX0R_INIT_LAT_SHIFT 16
48 # define R600_MC_MISC__MC_TX1R_INIT_LAT_SHIFT 20
49 # define R600_MC_MISC__MC_GLOBR_INIT_LAT_SHIFT 24
50 # define R600_MC_MISC__MC_GLOBW_FULL_LAT_SHIFT 28
51
52 /*
53 * This file contains registers and constants for the R600. They have been
54 * found mostly by examining command buffers captured using glxtest, as well
55 * as by extrapolating some known registers and constants from the R200.
56 * I am fairly certain that they are correct unless stated otherwise
57 * in comments.
58 */
59
60 #define R600_SE_VPORT_XSCALE 0x1D98
61 #define R600_SE_VPORT_XOFFSET 0x1D9C
62 #define R600_SE_VPORT_YSCALE 0x1DA0
63 #define R600_SE_VPORT_YOFFSET 0x1DA4
64 #define R600_SE_VPORT_ZSCALE 0x1DA8
65 #define R600_SE_VPORT_ZOFFSET 0x1DAC
66
67 #define R600_VAP_PORT_IDX0 0x2040
68 /*
69 * Vertex Array Processing (VAP) Control
70 */
71 #define R600_VAP_CNTL 0x2080
72 # define R600_PVS_NUM_SLOTS_SHIFT 0
73 # define R600_PVS_NUM_CNTLRS_SHIFT 4
74 # define R600_PVS_NUM_FPUS_SHIFT 8
75 # define R600_VF_MAX_VTX_NUM_SHIFT 18
76 # define R600_GL_CLIP_SPACE_DEF (0 << 22)
77 # define R600_DX_CLIP_SPACE_DEF (1 << 22)
78
79 /* This register is written directly and also starts data section
80 * in many 3d CP_PACKET3's
81 */
82 #define R600_VAP_VF_CNTL 0x2084
83 # define R600_VAP_VF_CNTL__PRIM_TYPE__SHIFT 0
84 # define R600_VAP_VF_CNTL__PRIM_NONE (0<<0)
85 # define R600_VAP_VF_CNTL__PRIM_POINTS (1<<0)
86 # define R600_VAP_VF_CNTL__PRIM_LINES (2<<0)
87 # define R600_VAP_VF_CNTL__PRIM_LINE_STRIP (3<<0)
88 # define R600_VAP_VF_CNTL__PRIM_TRIANGLES (4<<0)
89 # define R600_VAP_VF_CNTL__PRIM_TRIANGLE_FAN (5<<0)
90 # define R600_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP (6<<0)
91 # define R600_VAP_VF_CNTL__PRIM_LINE_LOOP (12<<0)
92 # define R600_VAP_VF_CNTL__PRIM_QUADS (13<<0)
93 # define R600_VAP_VF_CNTL__PRIM_QUAD_STRIP (14<<0)
94 # define R600_VAP_VF_CNTL__PRIM_POLYGON (15<<0)
95
96 # define R600_VAP_VF_CNTL__PRIM_WALK__SHIFT 4
97 /* State based - direct writes to registers trigger vertex
98 generation */
99 # define R600_VAP_VF_CNTL__PRIM_WALK_STATE_BASED (0<<4)
100 # define R600_VAP_VF_CNTL__PRIM_WALK_INDICES (1<<4)
101 # define R600_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST (2<<4)
102 # define R600_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED (3<<4)
103
104 /* I don't think I saw these three used.. */
105 # define R600_VAP_VF_CNTL__COLOR_ORDER__SHIFT 6
106 # define R600_VAP_VF_CNTL__TCL_OUTPUT_CTL_ENA__SHIFT 9
107 # define R600_VAP_VF_CNTL__PROG_STREAM_ENA__SHIFT 10
108
109 /* index size - when not set the indices are assumed to be 16 bit */
110 # define R600_VAP_VF_CNTL__INDEX_SIZE_32bit (1<<11)
111 /* number of vertices */
112 # define R600_VAP_VF_CNTL__NUM_VERTICES__SHIFT 16
113
114
115 #define R600_VAP_OUTPUT_VTX_FMT_0 0x2090
116 # define R600_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT (1<<0)
117 # define R600_VAP_OUTPUT_VTX_FMT_0__COLOR_0_PRESENT (1<<1)
118 # define R600_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2)
119 # define R600_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3)
120 # define R600_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4)
121 # define R600_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16)
122
123 #define R600_VAP_OUTPUT_VTX_FMT_1 0x2094
124 /* each of the following is 3 bits wide, specifies number
125 of components */
126 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
127 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
128 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
129 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
130 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
131 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
132 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
133 # define R600_VAP_OUTPUT_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
134 # define R600_VAP_OUTPUT_VTX_FMT_1__NOT_PRESENT 0
135 # define R600_VAP_OUTPUT_VTX_FMT_1__1_COMPONENT 1
136 # define R600_VAP_OUTPUT_VTX_FMT_1__2_COMPONENTS 2
137 # define R600_VAP_OUTPUT_VTX_FMT_1__3_COMPONENTS 3
138 # define R600_VAP_OUTPUT_VTX_FMT_1__4_COMPONENTS 4
139
140 #define R600_SE_VTE_CNTL 0x20b0
141 # define R600_VPORT_X_SCALE_ENA (1 << 0)
142 # define R600_VPORT_X_OFFSET_ENA (1 << 1)
143 # define R600_VPORT_Y_SCALE_ENA (1 << 2)
144 # define R600_VPORT_Y_OFFSET_ENA (1 << 3)
145 # define R600_VPORT_Z_SCALE_ENA (1 << 4)
146 # define R600_VPORT_Z_OFFSET_ENA (1 << 5)
147 # define R600_VTX_XY_FMT (1 << 8)
148 # define R600_VTX_Z_FMT (1 << 9)
149 # define R600_VTX_W0_FMT (1 << 10)
150 # define R600_SERIAL_PROC_ENA (1 << 11)
151
152 /* BEGIN: Vertex data assembly - lots of uncertainties */
153
154 /* gap */
155
156 /* Maximum Vertex Indx Clamp */
157 #define R600_VAP_VF_MAX_VTX_INDX 0x2134
158 /* Minimum Vertex Indx Clamp */
159 #define R600_VAP_VF_MIN_VTX_INDX 0x2138
160
161 /** Vertex assembler/processor control status */
162 #define R600_VAP_CNTL_STATUS 0x2140
163 /* No swap at all (default) */
164 # define R600_VC_NO_SWAP (0 << 0)
165 /* 16-bit swap: 0xAABBCCDD becomes 0xBBAADDCC */
166 # define R600_VC_16BIT_SWAP (1 << 0)
167 /* 32-bit swap: 0xAABBCCDD becomes 0xDDCCBBAA */
168 # define R600_VC_32BIT_SWAP (2 << 0)
169 /* Half-dword swap: 0xAABBCCDD becomes 0xCCDDAABB */
170 # define R600_VC_HALF_DWORD_SWAP (3 << 0)
171 /* The TCL engine will not be used (as it is logically or even physically removed) */
172 # define R600_VAP_TCL_BYPASS (1 << 8)
173 /* Read only flag if TCL engine is busy. */
174 # define R600_VAP_PVS_BUSY (1 << 11)
175 /* TODO: gap for MAX_MPS */
176 /* Read only flag if the vertex store is busy. */
177 # define R600_VAP_VS_BUSY (1 << 24)
178 /* Read only flag if the reciprocal engine is busy. */
179 # define R600_VAP_RCP_BUSY (1 << 25)
180 /* Read only flag if the viewport transform engine is busy. */
181 # define R600_VAP_VTE_BUSY (1 << 26)
182 /* Read only flag if the memory interface unit is busy. */
183 # define R600_VAP_MUI_BUSY (1 << 27)
184 /* Read only flag if the vertex cache is busy. */
185 # define R600_VAP_VC_BUSY (1 << 28)
186 /* Read only flag if the vertex fetcher is busy. */
187 # define R600_VAP_VF_BUSY (1 << 29)
188 /* Read only flag if the register pipeline is busy. */
189 # define R600_VAP_REGPIPE_BUSY (1 << 30)
190 /* Read only flag if the VAP engine is busy. */
191 # define R600_VAP_VAP_BUSY (1 << 31)
192
193 /* gap */
194
195 /* Where do we get our vertex data?
196 *
197 * Vertex data either comes either from immediate mode registers or from
198 * vertex arrays.
199 * There appears to be no mixed mode (though we can force the pitch of
200 * vertex arrays to 0, effectively reusing the same element over and over
201 * again).
202 *
203 * Immediate mode is controlled by the INPUT_CNTL registers. I am not sure
204 * if these registers influence vertex array processing.
205 *
206 * Vertex arrays are controlled via the 3D_LOAD_VBPNTR packet3.
207 *
208 * In both cases, vertex attributes are then passed through INPUT_ROUTE.
209 *
210 * Beginning with INPUT_ROUTE_0_0 is a list of WORDs that route vertex data
211 * into the vertex processor's input registers.
212 * The first word routes the first input, the second word the second, etc.
213 * The corresponding input is routed into the register with the given index.
214 * The list is ended by a word with INPUT_ROUTE_END set.
215 *
216 * Always set COMPONENTS_4 in immediate mode.
217 */
218
219 #define R600_VAP_PROG_STREAM_CNTL_0 0x2150
220 # define R600_DATA_TYPE_0_SHIFT 0
221 # define R600_DATA_TYPE_FLOAT_1 0
222 # define R600_DATA_TYPE_FLOAT_2 1
223 # define R600_DATA_TYPE_FLOAT_3 2
224 # define R600_DATA_TYPE_FLOAT_4 3
225 # define R600_DATA_TYPE_BYTE 4
226 # define R600_DATA_TYPE_D3DCOLOR 5
227 # define R600_DATA_TYPE_SHORT_2 6
228 # define R600_DATA_TYPE_SHORT_4 7
229 # define R600_DATA_TYPE_VECTOR_3_TTT 8
230 # define R600_DATA_TYPE_VECTOR_3_EET 9
231 # define R600_SKIP_DWORDS_SHIFT 4
232 # define R600_DST_VEC_LOC_SHIFT 8
233 # define R600_LAST_VEC (1 << 13)
234 # define R600_SIGNED (1 << 14)
235 # define R600_NORMALIZE (1 << 15)
236 # define R600_DATA_TYPE_1_SHIFT 16
237 #define R600_VAP_PROG_STREAM_CNTL_1 0x2154
238 #define R600_VAP_PROG_STREAM_CNTL_2 0x2158
239 #define R600_VAP_PROG_STREAM_CNTL_3 0x215C
240 #define R600_VAP_PROG_STREAM_CNTL_4 0x2160
241 #define R600_VAP_PROG_STREAM_CNTL_5 0x2164
242 #define R600_VAP_PROG_STREAM_CNTL_6 0x2168
243 #define R600_VAP_PROG_STREAM_CNTL_7 0x216C
244 /* gap */
245
246 /* Notes:
247 * - always set up to produce at least two attributes:
248 * if vertex program uses only position, fglrx will set normal, too
249 * - INPUT_CNTL_0_COLOR and INPUT_CNTL_COLOR bits are always equal.
250 */
251 #define R600_VAP_VTX_STATE_CNTL 0x2180
252 # define R600_COLOR_0_ASSEMBLY_SHIFT 0
253 # define R600_SEL_COLOR 0
254 # define R600_SEL_USER_COLOR_0 1
255 # define R600_SEL_USER_COLOR_1 2
256 # define R600_COLOR_1_ASSEMBLY_SHIFT 2
257 # define R600_COLOR_2_ASSEMBLY_SHIFT 4
258 # define R600_COLOR_3_ASSEMBLY_SHIFT 6
259 # define R600_COLOR_4_ASSEMBLY_SHIFT 8
260 # define R600_COLOR_5_ASSEMBLY_SHIFT 10
261 # define R600_COLOR_6_ASSEMBLY_SHIFT 12
262 # define R600_COLOR_7_ASSEMBLY_SHIFT 14
263 # define R600_UPDATE_USER_COLOR_0_ENA (1 << 16)
264
265 /*
266 * Each bit in this field applies to the corresponding vector in the VSM
267 * memory (i.e. Bit 0 applies to VECTOR_0 (POSITION), etc.). If the bit
268 * is set, then the corresponding 4-Dword Vector is output into the Vertex Stream.
269 */
270 #define R600_VAP_VSM_VTX_ASSM 0x2184
271 # define R600_INPUT_CNTL_POS 0x00000001
272 # define R600_INPUT_CNTL_NORMAL 0x00000002
273 # define R600_INPUT_CNTL_COLOR 0x00000004
274 # define R600_INPUT_CNTL_TC0 0x00000400
275 # define R600_INPUT_CNTL_TC1 0x00000800
276 # define R600_INPUT_CNTL_TC2 0x00001000 /* GUESS */
277 # define R600_INPUT_CNTL_TC3 0x00002000 /* GUESS */
278 # define R600_INPUT_CNTL_TC4 0x00004000 /* GUESS */
279 # define R600_INPUT_CNTL_TC5 0x00008000 /* GUESS */
280 # define R600_INPUT_CNTL_TC6 0x00010000 /* GUESS */
281 # define R600_INPUT_CNTL_TC7 0x00020000 /* GUESS */
282
283 /* Programmable Stream Control Signed Normalize Control */
284 #define R600_VAP_PSC_SGN_NORM_CNTL 0x21dc
285 # define SGN_NORM_ZERO 0
286 # define SGN_NORM_ZERO_CLAMP_MINUS_ONE 1
287 # define SGN_NORM_NO_ZERO 2
288
289 /* gap */
290
291 /* Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
292 * are set to a swizzling bit pattern, other words are 0.
293 *
294 * In immediate mode, the pattern is always set to xyzw. In vertex array
295 * mode, the swizzling pattern is e.g. used to set zw components in texture
296 * coordinates with only tweo components.
297 */
298 #define R600_VAP_PROG_STREAM_CNTL_EXT_0 0x21e0
299 # define R600_SWIZZLE0_SHIFT 0
300 # define R600_SWIZZLE_SELECT_X_SHIFT 0
301 # define R600_SWIZZLE_SELECT_Y_SHIFT 3
302 # define R600_SWIZZLE_SELECT_Z_SHIFT 6
303 # define R600_SWIZZLE_SELECT_W_SHIFT 9
304
305 # define R600_SWIZZLE_SELECT_X 0
306 # define R600_SWIZZLE_SELECT_Y 1
307 # define R600_SWIZZLE_SELECT_Z 2
308 # define R600_SWIZZLE_SELECT_W 3
309 # define R600_SWIZZLE_SELECT_FP_ZERO 4
310 # define R600_SWIZZLE_SELECT_FP_ONE 5
311 /* alternate forms for r600_emit.c */
312 # define R600_INPUT_ROUTE_SELECT_X 0
313 # define R600_INPUT_ROUTE_SELECT_Y 1
314 # define R600_INPUT_ROUTE_SELECT_Z 2
315 # define R600_INPUT_ROUTE_SELECT_W 3
316 # define R600_INPUT_ROUTE_SELECT_ZERO 4
317 # define R600_INPUT_ROUTE_SELECT_ONE 5
318
319 # define R600_WRITE_ENA_SHIFT 12
320 # define R600_WRITE_ENA_X 1
321 # define R600_WRITE_ENA_Y 2
322 # define R600_WRITE_ENA_Z 4
323 # define R600_WRITE_ENA_W 8
324 # define R600_SWIZZLE1_SHIFT 16
325 #define R600_VAP_PROG_STREAM_CNTL_EXT_1 0x21e4
326 #define R600_VAP_PROG_STREAM_CNTL_EXT_2 0x21e8
327 #define R600_VAP_PROG_STREAM_CNTL_EXT_3 0x21ec
328 #define R600_VAP_PROG_STREAM_CNTL_EXT_4 0x21f0
329 #define R600_VAP_PROG_STREAM_CNTL_EXT_5 0x21f4
330 #define R600_VAP_PROG_STREAM_CNTL_EXT_6 0x21f8
331 #define R600_VAP_PROG_STREAM_CNTL_EXT_7 0x21fc
332
333 /* END: Vertex data assembly */
334
335 /* gap */
336
337 /* BEGIN: Upload vertex program and data */
338
339 /*
340 * The programmable vertex shader unit has a memory bank of unknown size
341 * that can be written to in 16 byte units by writing the address into
342 * UPLOAD_ADDRESS, followed by data in UPLOAD_DATA (multiples of 4 DWORDs).
343 *
344 * Pointers into the memory bank are always in multiples of 16 bytes.
345 *
346 * The memory bank is divided into areas with fixed meaning.
347 *
348 * Starting at address UPLOAD_PROGRAM: Vertex program instructions.
349 * Native limits reported by drivers from ATI suggest size 256 (i.e. 4KB),
350 * whereas the difference between known addresses suggests size 512.
351 *
352 * Starting at address UPLOAD_PARAMETERS: Vertex program parameters.
353 * Native reported limits and the VPI layout suggest size 256, whereas
354 * difference between known addresses suggests size 512.
355 *
356 * At address UPLOAD_POINTSIZE is a vector (0, 0, ps, 0), where ps is the
357 * floating point pointsize. The exact purpose of this state is uncertain,
358 * as there is also the R600_RE_POINTSIZE register.
359 *
360 * Multiple vertex programs and parameter sets can be loaded at once,
361 * which could explain the size discrepancy.
362 */
363 #define R600_VAP_PVS_VECTOR_INDX_REG 0x2200
364 # define R600_PVS_CODE_START 0
365 # define R600_MAX_PVS_CODE_LINES 256
366 # define R600_PVS_CONST_START 512
367 # define R600_MAX_PVS_CONST_VECS 256
368 # define R600_PVS_UCP_START 1024
369 # define R600_POINT_VPORT_SCALE_OFFSET 1030
370 # define R600_POINT_GEN_TEX_OFFSET 1031
371
372 /*
373 * These are obsolete defines form r600_context.h, but they might give some
374 * clues when investigating the addresses further...
375 */
376 #if 0
377 #define VSF_DEST_PROGRAM 0x0
378 #define VSF_DEST_MATRIX0 0x200
379 #define VSF_DEST_MATRIX1 0x204
380 #define VSF_DEST_MATRIX2 0x208
381 #define VSF_DEST_VECTOR0 0x20c
382 #define VSF_DEST_VECTOR1 0x20d
383 #define VSF_DEST_UNKNOWN1 0x400
384 #define VSF_DEST_UNKNOWN2 0x406
385 #endif
386
387 /* gap */
388
389 #define R600_VAP_PVS_UPLOAD_DATA 0x2208
390
391 /* END: Upload vertex program and data */
392
393 /* gap */
394
395 /* I do not know the purpose of this register. However, I do know that
396 * it is set to 221C_CLEAR for clear operations and to 221C_NORMAL
397 * for normal rendering.
398 *
399 * 2007-11-05: This register is the user clip plane control register, but there
400 * also seems to be a rendering mode control; the NORMAL/CLEAR defines.
401 *
402 * See bug #9871. http://bugs.freedesktop.org/attachment.cgi?id=10672&action=view
403 */
404 #define R600_VAP_CLIP_CNTL 0x221C
405 # define R600_VAP_UCP_ENABLE_0 (1 << 0)
406 # define R600_VAP_UCP_ENABLE_1 (1 << 1)
407 # define R600_VAP_UCP_ENABLE_2 (1 << 2)
408 # define R600_VAP_UCP_ENABLE_3 (1 << 3)
409 # define R600_VAP_UCP_ENABLE_4 (1 << 4)
410 # define R600_VAP_UCP_ENABLE_5 (1 << 5)
411 # define R600_PS_UCP_MODE_DIST_COP (0 << 14)
412 # define R600_PS_UCP_MODE_RADIUS_COP (1 << 14)
413 # define R600_PS_UCP_MODE_RADIUS_COP_CLIP (2 << 14)
414 # define R600_PS_UCP_MODE_CLIP_AS_TRIFAN (3 << 14)
415 # define R600_CLIP_DISABLE (1 << 16)
416 # define R600_UCP_CULL_ONLY_ENABLE (1 << 17)
417 # define R600_BOUNDARY_EDGE_FLAG_ENABLE (1 << 18)
418
419 /* These seem to be per-pixel and per-vertex X and Y clipping planes. The first
420 * plane is per-pixel and the second plane is per-vertex.
421 *
422 * This was determined by experimentation alone but I believe it is correct.
423 *
424 * These registers are called X_QUAD0_1_FL to X_QUAD0_4_FL by glxtest.
425 */
426 #define R600_VAP_GB_VERT_CLIP_ADJ 0x2220
427 #define R600_VAP_GB_VERT_DISC_ADJ 0x2224
428 #define R600_VAP_GB_HORZ_CLIP_ADJ 0x2228
429 #define R600_VAP_GB_HORZ_DISC_ADJ 0x222c
430
431 /* gap */
432
433 /* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
434 * rendering commands and overwriting vertex program parameters.
435 * Therefore, I suspect writing zero to 0x2284 synchronizes the engine and
436 * avoids bugs caused by still running shaders reading bad data from memory.
437 */
438 #define R600_VAP_PVS_STATE_FLUSH_REG 0x2284
439
440 /* This register is used to define the number of core clocks to wait for a
441 * vertex to be received by the VAP input controller (while the primitive
442 * path is backed up) before forcing any accumulated vertices to be submitted
443 * to the vertex processing path.
444 */
445 #define VAP_PVS_VTX_TIMEOUT_REG 0x2288
446 # define R600_2288_R600 0x00750000 /* -- nh */
447 # define R600_2288_RV350 0x0000FFFF /* -- Vladimir */
448
449 /* gap */
450
451 /* Addresses are relative to the vertex program instruction area of the
452 * memory bank. PROGRAM_END points to the last instruction of the active
453 * program
454 *
455 * The meaning of the two UNKNOWN fields is obviously not known. However,
456 * experiments so far have shown that both *must* point to an instruction
457 * inside the vertex program, otherwise the GPU locks up.
458 *
459 * fglrx usually sets CNTL_3_UNKNOWN to the end of the program and
460 * R600_PVS_CNTL_1_POS_END_SHIFT points to instruction where last write to
461 * position takes place.
462 *
463 * Most likely this is used to ignore rest of the program in cases
464 * where group of verts arent visible. For some reason this "section"
465 * is sometimes accepted other instruction that have no relationship with
466 * position calculations.
467 */
468 #define R600_VAP_PVS_CODE_CNTL_0 0x22D0
469 # define R600_PVS_FIRST_INST_SHIFT 0
470 # define R600_PVS_XYZW_VALID_INST_SHIFT 10
471 # define R600_PVS_LAST_INST_SHIFT 20
472 /* Addresses are relative the the vertex program parameters area. */
473 #define R600_VAP_PVS_CONST_CNTL 0x22D4
474 # define R600_PVS_CONST_BASE_OFFSET_SHIFT 0
475 # define R600_PVS_MAX_CONST_ADDR_SHIFT 16
476 #define R600_VAP_PVS_CODE_CNTL_1 0x22D8
477 # define R600_PVS_LAST_VTX_SRC_INST_SHIFT 0
478 #define R600_VAP_PVS_FLOW_CNTL_OPC 0x22DC
479
480 /* The entire range from 0x2300 to 0x2AC inclusive seems to be used for
481 * immediate vertices
482 */
483 #define R600_VAP_VTX_COLOR_R 0x2464
484 #define R600_VAP_VTX_COLOR_G 0x2468
485 #define R600_VAP_VTX_COLOR_B 0x246C
486 #define R600_VAP_VTX_POS_0_X_1 0x2490 /* used for glVertex2*() */
487 #define R600_VAP_VTX_POS_0_Y_1 0x2494
488 #define R600_VAP_VTX_COLOR_PKD 0x249C /* RGBA */
489 #define R600_VAP_VTX_POS_0_X_2 0x24A0 /* used for glVertex3*() */
490 #define R600_VAP_VTX_POS_0_Y_2 0x24A4
491 #define R600_VAP_VTX_POS_0_Z_2 0x24A8
492 /* write 0 to indicate end of packet? */
493 #define R600_VAP_VTX_END_OF_PKT 0x24AC
494
495 /* gap */
496
497 /* These are values from r600_reg/r600_reg.h - they are known to be correct
498 * and are here so we can use one register file instead of several
499 * - Vladimir
500 */
501 #define R600_GB_VAP_RASTER_VTX_FMT_0 0x4000
502 # define R600_GB_VAP_RASTER_VTX_FMT_0__POS_PRESENT (1<<0)
503 # define R600_GB_VAP_RASTER_VTX_FMT_0__COLOR_0_PRESENT (1<<1)
504 # define R600_GB_VAP_RASTER_VTX_FMT_0__COLOR_1_PRESENT (1<<2)
505 # define R600_GB_VAP_RASTER_VTX_FMT_0__COLOR_2_PRESENT (1<<3)
506 # define R600_GB_VAP_RASTER_VTX_FMT_0__COLOR_3_PRESENT (1<<4)
507 # define R600_GB_VAP_RASTER_VTX_FMT_0__COLOR_SPACE (0xf<<5)
508 # define R600_GB_VAP_RASTER_VTX_FMT_0__PT_SIZE_PRESENT (0x1<<16)
509
510 #define R600_GB_VAP_RASTER_VTX_FMT_1 0x4004
511 /* each of the following is 3 bits wide, specifies number
512 of components */
513 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
514 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
515 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
516 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
517 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
518 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
519 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
520 # define R600_GB_VAP_RASTER_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
521
522 /* UNK30 seems to enables point to quad transformation on textures
523 * (or something closely related to that).
524 * This bit is rather fatal at the time being due to lackings at pixel
525 * shader side
526 * Specifies top of Raster pipe specific enable controls.
527 */
528 #define R600_GB_ENABLE 0x4008
529 # define R600_GB_POINT_STUFF_DISABLE (0 << 0)
530 # define R600_GB_POINT_STUFF_ENABLE (1 << 0) /* Specifies if points will have stuffed texture coordinates. */
531 # define R600_GB_LINE_STUFF_DISABLE (0 << 1)
532 # define R600_GB_LINE_STUFF_ENABLE (1 << 1) /* Specifies if lines will have stuffed texture coordinates. */
533 # define R600_GB_TRIANGLE_STUFF_DISABLE (0 << 2)
534 # define R600_GB_TRIANGLE_STUFF_ENABLE (1 << 2) /* Specifies if triangles will have stuffed texture coordinates. */
535 # define R600_GB_STENCIL_AUTO_DISABLE (0 << 4)
536 # define R600_GB_STENCIL_AUTO_ENABLE (1 << 4) /* Enable stencil auto inc/dec based on triangle cw/ccw, force into dzy low bit. */
537 # define R600_GB_STENCIL_AUTO_FORCE (2 << 4) /* Force 0 into dzy low bit. */
538
539 /* each of the following is 2 bits wide */
540 #define R600_GB_TEX_REPLICATE 0 /* Replicate VAP source texture coordinates (S,T,[R,Q]). */
541 #define R600_GB_TEX_ST 1 /* Stuff with source texture coordinates (S,T). */
542 #define R600_GB_TEX_STR 2 /* Stuff with source texture coordinates (S,T,R). */
543 # define R600_GB_TEX0_SOURCE_SHIFT 16
544 # define R600_GB_TEX1_SOURCE_SHIFT 18
545 # define R600_GB_TEX2_SOURCE_SHIFT 20
546 # define R600_GB_TEX3_SOURCE_SHIFT 22
547 # define R600_GB_TEX4_SOURCE_SHIFT 24
548 # define R600_GB_TEX5_SOURCE_SHIFT 26
549 # define R600_GB_TEX6_SOURCE_SHIFT 28
550 # define R600_GB_TEX7_SOURCE_SHIFT 30
551
552 /* MSPOS - positions for multisample antialiasing (?) */
553 #define R600_GB_MSPOS0 0x4010
554 /* shifts - each of the fields is 4 bits */
555 # define R600_GB_MSPOS0__MS_X0_SHIFT 0
556 # define R600_GB_MSPOS0__MS_Y0_SHIFT 4
557 # define R600_GB_MSPOS0__MS_X1_SHIFT 8
558 # define R600_GB_MSPOS0__MS_Y1_SHIFT 12
559 # define R600_GB_MSPOS0__MS_X2_SHIFT 16
560 # define R600_GB_MSPOS0__MS_Y2_SHIFT 20
561 # define R600_GB_MSPOS0__MSBD0_Y 24
562 # define R600_GB_MSPOS0__MSBD0_X 28
563
564 #define R600_GB_MSPOS1 0x4014
565 # define R600_GB_MSPOS1__MS_X3_SHIFT 0
566 # define R600_GB_MSPOS1__MS_Y3_SHIFT 4
567 # define R600_GB_MSPOS1__MS_X4_SHIFT 8
568 # define R600_GB_MSPOS1__MS_Y4_SHIFT 12
569 # define R600_GB_MSPOS1__MS_X5_SHIFT 16
570 # define R600_GB_MSPOS1__MS_Y5_SHIFT 20
571 # define R600_GB_MSPOS1__MSBD1 24
572
573 /* Specifies the graphics pipeline configuration for rasterization. */
574 #define R600_GB_TILE_CONFIG 0x4018
575 # define R600_GB_TILE_DISABLE (0 << 0)
576 # define R600_GB_TILE_ENABLE (1 << 0)
577 # define R600_GB_TILE_PIPE_COUNT_RV300 (0 << 1) /* RV350 (1 pipe, 1 ctx) */
578 # define R600_GB_TILE_PIPE_COUNT_R600 (3 << 1) /* R600 (2 pipes, 1 ctx) */
579 # define R600_GB_TILE_PIPE_COUNT_R420_3P (6 << 1) /* R420-3P (3 pipes, 1 ctx) */
580 # define R600_GB_TILE_PIPE_COUNT_R420 (7 << 1) /* R420 (4 pipes, 1 ctx) */
581 # define R600_GB_TILE_SIZE_8 (0 << 4)
582 # define R600_GB_TILE_SIZE_16 (1 << 4)
583 # define R600_GB_TILE_SIZE_32 (2 << 4)
584 # define R600_GB_SUPER_SIZE_1 (0 << 6)
585 # define R600_GB_SUPER_SIZE_2 (1 << 6)
586 # define R600_GB_SUPER_SIZE_4 (2 << 6)
587 # define R600_GB_SUPER_SIZE_8 (3 << 6)
588 # define R600_GB_SUPER_SIZE_16 (4 << 6)
589 # define R600_GB_SUPER_SIZE_32 (5 << 6)
590 # define R600_GB_SUPER_SIZE_64 (6 << 6)
591 # define R600_GB_SUPER_SIZE_128 (7 << 6)
592 # define R600_GB_SUPER_X_SHIFT 9 /* 3 bits wide */
593 # define R600_GB_SUPER_Y_SHIFT 12 /* 3 bits wide */
594 # define R600_GB_SUPER_TILE_A (0 << 15)
595 # define R600_GB_SUPER_TILE_B (1 << 15)
596 # define R600_GB_SUBPIXEL_1_12 (0 << 16)
597 # define R600_GB_SUBPIXEL_1_16 (1 << 16)
598 # define GB_TILE_CONFIG_QUADS_PER_RAS_4 (0 << 17)
599 # define GB_TILE_CONFIG_QUADS_PER_RAS_8 (1 << 17)
600 # define GB_TILE_CONFIG_QUADS_PER_RAS_16 (2 << 17)
601 # define GB_TILE_CONFIG_QUADS_PER_RAS_32 (3 << 17)
602 # define GB_TILE_CONFIG_BB_SCAN_INTERCEPT (0 << 19)
603 # define GB_TILE_CONFIG_BB_SCAN_BOUND_BOX (1 << 19)
604 # define GB_TILE_CONFIG_ALT_SCAN_EN_LR (0 << 20)
605 # define GB_TILE_CONFIG_ALT_SCAN_EN_LRL (1 << 20)
606 # define GB_TILE_CONFIG_ALT_OFFSET (0 << 21)
607 # define GB_TILE_CONFIG_SUBPRECISION (0 << 22)
608 # define GB_TILE_CONFIG_ALT_TILING_DEF (0 << 23)
609 # define GB_TILE_CONFIG_ALT_TILING_3_2 (1 << 23)
610 # define GB_TILE_CONFIG_Z_EXTENDED_24_1 (0 << 24)
611 # define GB_TILE_CONFIG_Z_EXTENDED_S25_1 (1 << 24)
612
613 /* Specifies the sizes of the various FIFO`s in the sc/rs/us. This register must be the first one written */
614 #define R600_GB_FIFO_SIZE 0x4024
615 /* each of the following is 2 bits wide */
616 #define R600_GB_FIFO_SIZE_32 0
617 #define R600_GB_FIFO_SIZE_64 1
618 #define R600_GB_FIFO_SIZE_128 2
619 #define R600_GB_FIFO_SIZE_256 3
620 # define R600_SC_IFIFO_SIZE_SHIFT 0
621 # define R600_SC_TZFIFO_SIZE_SHIFT 2
622 # define R600_SC_BFIFO_SIZE_SHIFT 4
623
624 # define R600_US_OFIFO_SIZE_SHIFT 12
625 # define R600_US_WFIFO_SIZE_SHIFT 14
626 /* the following use the same constants as above, but meaning is
627 is times 2 (i.e. instead of 32 words it means 64 */
628 # define R600_RS_TFIFO_SIZE_SHIFT 6
629 # define R600_RS_CFIFO_SIZE_SHIFT 8
630 # define R600_US_RAM_SIZE_SHIFT 10
631 /* watermarks, 3 bits wide */
632 # define R600_RS_HIGHWATER_COL_SHIFT 16
633 # define R600_RS_HIGHWATER_TEX_SHIFT 19
634 # define R600_OFIFO_HIGHWATER_SHIFT 22 /* two bits only */
635 # define R600_CUBE_FIFO_HIGHWATER_COL_SHIFT 24
636
637 #define GB_Z_PEQ_CONFIG 0x4028
638 # define GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_4_4 (0 << 0)
639 # define GB_Z_PEQ_CONFIG_Z_PEQ_SIZE_8_8 (1 << 0)
640
641 /* Specifies various polygon specific selects (fog, depth, perspective). */
642 #define R600_GB_SELECT 0x401c
643 # define R600_GB_FOG_SELECT_C0A (0 << 0)
644 # define R600_GB_FOG_SELECT_C1A (1 << 0)
645 # define R600_GB_FOG_SELECT_C2A (2 << 0)
646 # define R600_GB_FOG_SELECT_C3A (3 << 0)
647 # define R600_GB_FOG_SELECT_1_1_W (4 << 0)
648 # define R600_GB_FOG_SELECT_Z (5 << 0)
649 # define R600_GB_DEPTH_SELECT_Z (0 << 3)
650 # define R600_GB_DEPTH_SELECT_1_1_W (1 << 3)
651 # define R600_GB_W_SELECT_1_W (0 << 4)
652 # define R600_GB_W_SELECT_1 (1 << 4)
653 # define R600_GB_FOG_STUFF_DISABLE (0 << 5)
654 # define R600_GB_FOG_STUFF_ENABLE (1 << 5)
655 # define R600_GB_FOG_STUFF_TEX_SHIFT 6
656 # define R600_GB_FOG_STUFF_TEX_MASK 0x000003c0
657 # define R600_GB_FOG_STUFF_COMP_SHIFT 10
658 # define R600_GB_FOG_STUFF_COMP_MASK 0x00000c00
659
660 /* Specifies the graphics pipeline configuration for antialiasing. */
661 #define GB_AA_CONFIG 0x4020
662 # define GB_AA_CONFIG_AA_DISABLE (0 << 0)
663 # define GB_AA_CONFIG_AA_ENABLE (1 << 0)
664 # define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2 (0 << 1)
665 # define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3 (1 << 1)
666 # define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4 (2 << 1)
667 # define GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6 (3 << 1)
668
669 /* Selects which of 4 pipes are active. */
670 #define GB_PIPE_SELECT 0x402c
671 # define GB_PIPE_SELECT_PIPE0_ID_SHIFT 0
672 # define GB_PIPE_SELECT_PIPE1_ID_SHIFT 2
673 # define GB_PIPE_SELECT_PIPE2_ID_SHIFT 4
674 # define GB_PIPE_SELECT_PIPE3_ID_SHIFT 6
675 # define GB_PIPE_SELECT_PIPE_MASK_SHIFT 8
676 # define GB_PIPE_SELECT_MAX_PIPE 12
677 # define GB_PIPE_SELECT_BAD_PIPES 14
678 # define GB_PIPE_SELECT_CONFIG_PIPES 18
679
680
681 /* Specifies the sizes of the various FIFO`s in the sc/rs. */
682 #define GB_FIFO_SIZE1 0x4070
683 /* High water mark for SC input fifo */
684 # define GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_SHIFT 0
685 # define GB_FIFO_SIZE1_SC_HIGHWATER_IFIFO_MASK 0x0000003f
686 /* High water mark for SC input fifo (B) */
687 # define GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_SHIFT 6
688 # define GB_FIFO_SIZE1_SC_HIGHWATER_BFIFO_MASK 0x00000fc0
689 /* High water mark for RS colors' fifo */
690 # define GB_FIFO_SIZE1_SC_HIGHWATER_COL_SHIFT 12
691 # define GB_FIFO_SIZE1_SC_HIGHWATER_COL_MASK 0x0003f000
692 /* High water mark for RS textures' fifo */
693 # define GB_FIFO_SIZE1_SC_HIGHWATER_TEX_SHIFT 18
694 # define GB_FIFO_SIZE1_SC_HIGHWATER_TEX_MASK 0x00fc0000
695
696 /* gap */
697
698 /* Zero to flush caches. */
699 #define R600_TX_INVALTAGS 0x4100
700 #define R600_TX_FLUSH 0x0
701
702 /* The upper enable bits are guessed, based on fglrx reported limits. */
703 #define R600_TX_ENABLE 0x4104
704 # define R600_TX_ENABLE_0 (1 << 0)
705 # define R600_TX_ENABLE_1 (1 << 1)
706 # define R600_TX_ENABLE_2 (1 << 2)
707 # define R600_TX_ENABLE_3 (1 << 3)
708 # define R600_TX_ENABLE_4 (1 << 4)
709 # define R600_TX_ENABLE_5 (1 << 5)
710 # define R600_TX_ENABLE_6 (1 << 6)
711 # define R600_TX_ENABLE_7 (1 << 7)
712 # define R600_TX_ENABLE_8 (1 << 8)
713 # define R600_TX_ENABLE_9 (1 << 9)
714 # define R600_TX_ENABLE_10 (1 << 10)
715 # define R600_TX_ENABLE_11 (1 << 11)
716 # define R600_TX_ENABLE_12 (1 << 12)
717 # define R600_TX_ENABLE_13 (1 << 13)
718 # define R600_TX_ENABLE_14 (1 << 14)
719 # define R600_TX_ENABLE_15 (1 << 15)
720
721 /* S Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) */
722 #define R600_GA_POINT_S0 0x4200
723
724 /* T Texture Coordinate of Vertex 0 for Point texture stuffing (LLC) */
725 #define R600_GA_POINT_T0 0x4204
726
727 /* S Texture Coordinate of Vertex 2 for Point texture stuffing (URC) */
728 #define R600_GA_POINT_S1 0x4208
729
730 /* T Texture Coordinate of Vertex 2 for Point texture stuffing (URC) */
731 #define R600_GA_POINT_T1 0x420c
732
733 /* Specifies amount to shift integer position of vertex (screen space) before
734 * converting to float for triangle stipple.
735 */
736 #define R600_GA_TRIANGLE_STIPPLE 0x4214
737 # define R600_GA_TRIANGLE_STIPPLE_X_SHIFT_SHIFT 0
738 # define R600_GA_TRIANGLE_STIPPLE_X_SHIFT_MASK 0x0000000f
739 # define R600_GA_TRIANGLE_STIPPLE_Y_SHIFT_SHIFT 16
740 # define R600_GA_TRIANGLE_STIPPLE_Y_SHIFT_MASK 0x000f0000
741
742 /* The pointsize is given in multiples of 6. The pointsize can be enormous:
743 * Clear() renders a single point that fills the entire framebuffer.
744 * 1/2 Height of point; fixed (16.0), subpixel format (1/12 or 1/16, even if in
745 * 8b precision).
746 */
747 #define R600_GA_POINT_SIZE 0x421C
748 # define R600_POINTSIZE_Y_SHIFT 0
749 # define R600_POINTSIZE_Y_MASK 0x0000ffff
750 # define R600_POINTSIZE_X_SHIFT 16
751 # define R600_POINTSIZE_X_MASK 0xffff0000
752 # define R600_POINTSIZE_MAX (R600_POINTSIZE_Y_MASK / 6)
753
754
755 /* Specifies maximum and minimum point & sprite sizes for per vertex size
756 * specification. The lower part (15:0) is MIN and (31:16) is max.
757 */
758 #define R600_GA_POINT_MINMAX 0x4230
759 # define R600_GA_POINT_MINMAX_MIN_SHIFT 0
760 # define R600_GA_POINT_MINMAX_MIN_MASK (0xFFFF << 0)
761 # define R600_GA_POINT_MINMAX_MAX_SHIFT 16
762 # define R600_GA_POINT_MINMAX_MAX_MASK (0xFFFF << 16)
763
764 /* 1/2 width of line, in subpixels (1/12 or 1/16 only, even in 8b
765 * subprecision); (16.0) fixed format.
766 *
767 * The line width is given in multiples of 6.
768 * In default mode lines are classified as vertical lines.
769 * HO: horizontal
770 * VE: vertical or horizontal
771 * HO & VE: no classification
772 */
773 #define R600_GA_LINE_CNTL 0x4234
774 # define R600_GA_LINE_CNTL_WIDTH_SHIFT 0
775 # define R600_GA_LINE_CNTL_WIDTH_MASK 0x0000ffff
776 # define R600_GA_LINE_CNTL_END_TYPE_HOR (0 << 16)
777 # define R600_GA_LINE_CNTL_END_TYPE_VER (1 << 16)
778 # define R600_GA_LINE_CNTL_END_TYPE_SQR (2 << 16) /* horizontal or vertical depending upon slope */
779 # define R600_GA_LINE_CNTL_END_TYPE_COMP (3 << 16) /* Computed (perpendicular to slope) */
780 /** TODO: looks wrong */
781 # define R600_LINESIZE_MAX (R600_GA_LINE_CNTL_WIDTH_MASK / 6)
782 /** TODO: looks wrong */
783 # define R600_LINE_CNT_HO (1 << 16)
784 /** TODO: looks wrong */
785 # define R600_LINE_CNT_VE (1 << 17)
786
787 /* Line Stipple configuration information. */
788 #define R600_GA_LINE_STIPPLE_CONFIG 0x4238
789 # define R600_GA_LINE_STIPPLE_CONFIG_LINE_RESET_NO (0 << 0)
790 # define R600_GA_LINE_STIPPLE_CONFIG_LINE_RESET_LINE (1 << 0)
791 # define R600_GA_LINE_STIPPLE_CONFIG_LINE_RESET_PACKET (2 << 0)
792 # define R600_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_SHIFT 2
793 # define R600_GA_LINE_STIPPLE_CONFIG_STIPPLE_SCALE_MASK 0xfffffffc
794
795 /* Current value of stipple accumulator. */
796 #define R600_GA_LINE_STIPPLE_VALUE 0x4260
797
798 /* S Texture Coordinate Value for Vertex 0 of Line (stuff textures -- i.e. AA) */
799 #define R600_GA_LINE_S0 0x4264
800 /* S Texture Coordinate Value for Vertex 1 of Lines (V2 of parallelogram -- stuff textures -- i.e. AA) */
801 #define R600_GA_LINE_S1 0x4268
802
803 /* GA enhance/tweaks */
804 #define R600_GA_ENHANCE 0x4274
805 # define R600_GA_ENHANCE_DEADLOCK_CNTL_NO_EFFECT (0 << 0)
806 # define R600_GA_ENHANCE_DEADLOCK_CNTL_PREVENT_TCL (1 << 0) /* Prevents TCL interface from deadlocking on GA side. */
807 # define R600_GA_ENHANCE_FASTSYNC_CNTL_NO_EFFECT (0 << 1)
808 # define R600_GA_ENHANCE_FASTSYNC_CNTL_ENABLE (1 << 1) /* Enables high-performance register/primitive switching. */
809
810 #define R600_GA_COLOR_CONTROL 0x4278
811 # define R600_GA_COLOR_CONTROL_RGB0_SHADING_SOLID (0 << 0)
812 # define R600_GA_COLOR_CONTROL_RGB0_SHADING_FLAT (1 << 0)
813 # define R600_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD (2 << 0)
814 # define R600_GA_COLOR_CONTROL_ALPHA0_SHADING_SOLID (0 << 2)
815 # define R600_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT (1 << 2)
816 # define R600_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD (2 << 2)
817 # define R600_GA_COLOR_CONTROL_RGB1_SHADING_SOLID (0 << 4)
818 # define R600_GA_COLOR_CONTROL_RGB1_SHADING_FLAT (1 << 4)
819 # define R600_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD (2 << 4)
820 # define R600_GA_COLOR_CONTROL_ALPHA1_SHADING_SOLID (0 << 6)
821 # define R600_GA_COLOR_CONTROL_ALPHA1_SHADING_FLAT (1 << 6)
822 # define R600_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD (2 << 6)
823 # define R600_GA_COLOR_CONTROL_RGB2_SHADING_SOLID (0 << 8)
824 # define R600_GA_COLOR_CONTROL_RGB2_SHADING_FLAT (1 << 8)
825 # define R600_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD (2 << 8)
826 # define R600_GA_COLOR_CONTROL_ALPHA2_SHADING_SOLID (0 << 10)
827 # define R600_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT (1 << 10)
828 # define R600_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD (2 << 10)
829 # define R600_GA_COLOR_CONTROL_RGB3_SHADING_SOLID (0 << 12)
830 # define R600_GA_COLOR_CONTROL_RGB3_SHADING_FLAT (1 << 12)
831 # define R600_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD (2 << 12)
832 # define R600_GA_COLOR_CONTROL_ALPHA3_SHADING_SOLID (0 << 14)
833 # define R600_GA_COLOR_CONTROL_ALPHA3_SHADING_FLAT (1 << 14)
834 # define R600_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD (2 << 14)
835 # define R600_GA_COLOR_CONTROL_PROVOKING_VERTEX_FIRST (0 << 16)
836 # define R600_GA_COLOR_CONTROL_PROVOKING_VERTEX_SECOND (1 << 16)
837 # define R600_GA_COLOR_CONTROL_PROVOKING_VERTEX_THIRD (2 << 16)
838 # define R600_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST (3 << 16)
839
840 /** TODO: might be candidate for removal */
841 # define R600_RE_SHADE_MODEL_SMOOTH ( \
842 R600_GA_COLOR_CONTROL_RGB0_SHADING_GOURAUD | R600_GA_COLOR_CONTROL_ALPHA0_SHADING_GOURAUD | \
843 R600_GA_COLOR_CONTROL_RGB1_SHADING_GOURAUD | R600_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
844 R600_GA_COLOR_CONTROL_RGB2_SHADING_GOURAUD | R600_GA_COLOR_CONTROL_ALPHA2_SHADING_GOURAUD | \
845 R600_GA_COLOR_CONTROL_RGB3_SHADING_GOURAUD | R600_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
846 R600_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
847 /** TODO: might be candidate for removal, the GOURAUD stuff also looks buggy to me */
848 # define R600_RE_SHADE_MODEL_FLAT ( \
849 R600_GA_COLOR_CONTROL_RGB0_SHADING_FLAT | R600_GA_COLOR_CONTROL_ALPHA0_SHADING_FLAT | \
850 R600_GA_COLOR_CONTROL_RGB1_SHADING_FLAT | R600_GA_COLOR_CONTROL_ALPHA1_SHADING_GOURAUD | \
851 R600_GA_COLOR_CONTROL_RGB2_SHADING_FLAT | R600_GA_COLOR_CONTROL_ALPHA2_SHADING_FLAT | \
852 R600_GA_COLOR_CONTROL_RGB3_SHADING_FLAT | R600_GA_COLOR_CONTROL_ALPHA3_SHADING_GOURAUD | \
853 R600_GA_COLOR_CONTROL_PROVOKING_VERTEX_LAST )
854
855 /* Specifies red & green components of fill color -- S312 format -- Backwards comp. */
856 #define R600_GA_SOLID_RG 0x427c
857 # define GA_SOLID_RG_COLOR_GREEN_SHIFT 0
858 # define GA_SOLID_RG_COLOR_GREEN_MASK 0x0000ffff
859 # define GA_SOLID_RG_COLOR_RED_SHIFT 16
860 # define GA_SOLID_RG_COLOR_RED_MASK 0xffff0000
861 /* Specifies blue & alpha components of fill color -- S312 format -- Backwards comp. */
862 #define R600_GA_SOLID_BA 0x4280
863 # define GA_SOLID_BA_COLOR_ALPHA_SHIFT 0
864 # define GA_SOLID_BA_COLOR_ALPHA_MASK 0x0000ffff
865 # define GA_SOLID_BA_COLOR_BLUE_SHIFT 16
866 # define GA_SOLID_BA_COLOR_BLUE_MASK 0xffff0000
867
868 /* Polygon Mode
869 * Dangerous
870 */
871 #define R600_GA_POLY_MODE 0x4288
872 # define R600_GA_POLY_MODE_DISABLE (0 << 0)
873 # define R600_GA_POLY_MODE_DUAL (1 << 0) /* send 2 sets of 3 polys with specified poly type */
874 /* reserved */
875 # define R600_GA_POLY_MODE_FRONT_PTYPE_POINT (0 << 4)
876 # define R600_GA_POLY_MODE_FRONT_PTYPE_LINE (1 << 4)
877 # define R600_GA_POLY_MODE_FRONT_PTYPE_TRI (2 << 4)
878 /* reserved */
879 # define R600_GA_POLY_MODE_BACK_PTYPE_POINT (0 << 7)
880 # define R600_GA_POLY_MODE_BACK_PTYPE_LINE (1 << 7)
881 # define R600_GA_POLY_MODE_BACK_PTYPE_TRI (2 << 7)
882 /* reserved */
883
884 /* Specifies the rouding mode for geometry & color SPFP to FP conversions. */
885 #define R600_GA_ROUND_MODE 0x428c
886 # define R600_GA_ROUND_MODE_GEOMETRY_ROUND_TRUNC (0 << 0)
887 # define R600_GA_ROUND_MODE_GEOMETRY_ROUND_NEAREST (1 << 0)
888 # define R600_GA_ROUND_MODE_COLOR_ROUND_TRUNC (0 << 2)
889 # define R600_GA_ROUND_MODE_COLOR_ROUND_NEAREST (1 << 2)
890 # define R600_GA_ROUND_MODE_RGB_CLAMP_RGB (0 << 4)
891 # define R600_GA_ROUND_MODE_RGB_CLAMP_FP20 (1 << 4)
892 # define R600_GA_ROUND_MODE_ALPHA_CLAMP_RGB (0 << 5)
893 # define R600_GA_ROUND_MODE_ALPHA_CLAMP_FP20 (1 << 5)
894
895 /* Specifies x & y offsets for vertex data after conversion to FP.
896 * Offsets are in S15 format (subpixels -- 1/12 or 1/16, even in 8b
897 * subprecision).
898 */
899 #define R600_GA_OFFSET 0x4290
900 # define R600_GA_OFFSET_X_OFFSET_SHIFT 0
901 # define R600_GA_OFFSET_X_OFFSET_MASK 0x0000ffff
902 # define R600_GA_OFFSET_Y_OFFSET_SHIFT 16
903 # define R600_GA_OFFSET_Y_OFFSET_MASK 0xffff0000
904
905 /* Specifies the scale to apply to fog. */
906 #define R600_GA_FOG_SCALE 0x4294
907 /* Specifies the offset to apply to fog. */
908 #define R600_GA_FOG_OFFSET 0x4298
909 /* Specifies number of cycles to assert reset, and also causes RB3D soft reset to assert. */
910 #define R600_GA_SOFT_RESET 0x429c
911
912 /* Not sure why there are duplicate of factor and constant values.
913 * My best guess so far is that there are seperate zbiases for test and write.
914 * Ordering might be wrong.
915 * Some of the tests indicate that fgl has a fallback implementation of zbias
916 * via pixel shaders.
917 */
918 #define R600_SU_TEX_WRAP 0x42A0
919 #define R600_SU_POLY_OFFSET_FRONT_SCALE 0x42A4
920 #define R600_SU_POLY_OFFSET_FRONT_OFFSET 0x42A8
921 #define R600_SU_POLY_OFFSET_BACK_SCALE 0x42AC
922 #define R600_SU_POLY_OFFSET_BACK_OFFSET 0x42B0
923
924 /* This register needs to be set to (1<<1) for RV350 to correctly
925 * perform depth test (see --vb-triangles in r600_demo)
926 * Don't know about other chips. - Vladimir
927 * This is set to 3 when GL_POLYGON_OFFSET_FILL is on.
928 * My guess is that there are two bits for each zbias primitive
929 * (FILL, LINE, POINT).
930 * One to enable depth test and one for depth write.
931 * Yet this doesnt explain why depth writes work ...
932 */
933 #define R600_SU_POLY_OFFSET_ENABLE 0x42B4
934 # define R600_FRONT_ENABLE (1 << 0)
935 # define R600_BACK_ENABLE (1 << 1)
936 # define R600_PARA_ENABLE (1 << 2)
937
938 #define R600_SU_CULL_MODE 0x42B8
939 # define R600_CULL_FRONT (1 << 0)
940 # define R600_CULL_BACK (1 << 1)
941 # define R600_FRONT_FACE_CCW (0 << 2)
942 # define R600_FRONT_FACE_CW (1 << 2)
943
944 /* SU Depth Scale value */
945 #define R600_SU_DEPTH_SCALE 0x42c0
946 /* SU Depth Offset value */
947 #define R600_SU_DEPTH_OFFSET 0x42c4
948
949
950 /* BEGIN: Rasterization / Interpolators - many guesses */
951
952 /*
953 * TC_CNT is the number of incoming texture coordinate sets (i.e. it depends
954 * on the vertex program, *not* the fragment program)
955 */
956 #define R600_RS_COUNT 0x4300
957 # define R600_IT_COUNT_SHIFT 0
958 # define R600_IT_COUNT_MASK 0x0000007f
959 # define R600_IC_COUNT_SHIFT 7
960 # define R600_IC_COUNT_MASK 0x00000780
961 # define R600_W_ADDR_SHIFT 12
962 # define R600_W_ADDR_MASK 0x0003f000
963 # define R600_HIRES_DIS (0 << 18)
964 # define R600_HIRES_EN (1 << 18)
965
966 #define R600_RS_INST_COUNT 0x4304
967 # define R600_RS_INST_COUNT_SHIFT 0
968 # define R600_RS_INST_COUNT_MASK 0x0000000f
969 # define R600_RS_TX_OFFSET_SHIFT 5
970 # define R600_RS_TX_OFFSET_MASK 0x000000e0
971
972 /* gap */
973
974 /* Only used for texture coordinates.
975 * Use the source field to route texture coordinate input from the
976 * vertex program to the desired interpolator. Note that the source
977 * field is relative to the outputs the vertex program *actually*
978 * writes. If a vertex program only writes texcoord[1], this will
979 * be source index 0.
980 * Set INTERP_USED on all interpolators that produce data used by
981 * the fragment program. INTERP_USED looks like a swizzling mask,
982 * but I haven't seen it used that way.
983 *
984 * Note: The _UNKNOWN constants are always set in their respective
985 * register. I don't know if this is necessary.
986 */
987 #define R600_RS_IP_0 0x4310
988 #define R600_RS_IP_1 0x4314
989 #define R600_RS_IP_2 0x4318
990 #define R600_RS_IP_3 0x431C
991 # define R600_RS_INTERP_SRC_SHIFT 2 /* TODO: check for removal */
992 # define R600_RS_INTERP_SRC_MASK (7 << 2) /* TODO: check for removal */
993 # define R600_RS_TEX_PTR(x) ((x) << 0)
994 # define R600_RS_COL_PTR(x) ((x) << 6)
995 # define R600_RS_COL_FMT(x) ((x) << 9)
996 # define R600_RS_COL_FMT_RGBA 0
997 # define R600_RS_COL_FMT_RGB0 1
998 # define R600_RS_COL_FMT_RGB1 2
999 # define R600_RS_COL_FMT_000A 4
1000 # define R600_RS_COL_FMT_0000 5
1001 # define R600_RS_COL_FMT_0001 6
1002 # define R600_RS_COL_FMT_111A 8
1003 # define R600_RS_COL_FMT_1110 9
1004 # define R600_RS_COL_FMT_1111 10
1005 # define R600_RS_SEL_S(x) ((x) << 13)
1006 # define R600_RS_SEL_T(x) ((x) << 16)
1007 # define R600_RS_SEL_R(x) ((x) << 19)
1008 # define R600_RS_SEL_Q(x) ((x) << 22)
1009 # define R600_RS_SEL_C0 0
1010 # define R600_RS_SEL_C1 1
1011 # define R600_RS_SEL_C2 2
1012 # define R600_RS_SEL_C3 3
1013 # define R600_RS_SEL_K0 4
1014 # define R600_RS_SEL_K1 5
1015
1016 /* These DWORDs control how vertex data is routed into fragment program
1017 * registers, after interpolators.
1018 */
1019 #define R600_RS_INST_0 0x4330
1020 #define R600_RS_INST_1 0x4334
1021 #define R600_RS_INST_2 0x4338
1022 #define R600_RS_INST_3 0x433C /* GUESS */
1023 #define R600_RS_INST_4 0x4340 /* GUESS */
1024 #define R600_RS_INST_5 0x4344 /* GUESS */
1025 #define R600_RS_INST_6 0x4348 /* GUESS */
1026 #define R600_RS_INST_7 0x434C /* GUESS */
1027 # define R600_RS_INST_TEX_ID(x) ((x) << 0)
1028 # define R600_RS_INST_TEX_CN_WRITE (1 << 3)
1029 # define R600_RS_INST_TEX_ADDR_SHIFT 6
1030 # define R600_RS_INST_TEX_ADDR(x) ((x) << R600_RS_INST_TEX_ADDR_SHIFT)
1031 # define R600_RS_INST_COL_ID(x) ((x) << 11)
1032 # define R600_RS_INST_COL_CN_WRITE (1 << 14)
1033 # define R600_RS_INST_COL_ADDR_SHIFT 17
1034 # define R600_RS_INST_COL_ADDR(x) ((x) << R600_RS_INST_COL_ADDR_SHIFT)
1035 # define R600_RS_INST_TEX_ADJ (1 << 22)
1036 # define R600_RS_COL_BIAS_UNUSED_SHIFT 23
1037
1038 /* END: Rasterization / Interpolators - many guesses */
1039
1040 /* Hierarchical Z Enable */
1041 #define R600_SC_HYPERZ 0x43a4
1042 # define R600_SC_HYPERZ_DISABLE (0 << 0)
1043 # define R600_SC_HYPERZ_ENABLE (1 << 0)
1044 # define R600_SC_HYPERZ_MIN (0 << 1)
1045 # define R600_SC_HYPERZ_MAX (1 << 1)
1046 # define R600_SC_HYPERZ_ADJ_256 (0 << 2)
1047 # define R600_SC_HYPERZ_ADJ_128 (1 << 2)
1048 # define R600_SC_HYPERZ_ADJ_64 (2 << 2)
1049 # define R600_SC_HYPERZ_ADJ_32 (3 << 2)
1050 # define R600_SC_HYPERZ_ADJ_16 (4 << 2)
1051 # define R600_SC_HYPERZ_ADJ_8 (5 << 2)
1052 # define R600_SC_HYPERZ_ADJ_4 (6 << 2)
1053 # define R600_SC_HYPERZ_ADJ_2 (7 << 2)
1054 # define R600_SC_HYPERZ_HZ_Z0MIN_NO (0 << 5)
1055 # define R600_SC_HYPERZ_HZ_Z0MIN (1 << 5)
1056 # define R600_SC_HYPERZ_HZ_Z0MAX_NO (0 << 6)
1057 # define R600_SC_HYPERZ_HZ_Z0MAX (1 << 6)
1058
1059 #define R600_SC_EDGERULE 0x43a8
1060
1061 /* BEGIN: Scissors and cliprects */
1062
1063 /* There are four clipping rectangles. Their corner coordinates are inclusive.
1064 * Every pixel is assigned a number from 0 and 15 by setting bits 0-3 depending
1065 * on whether the pixel is inside cliprects 0-3, respectively. For example,
1066 * if a pixel is inside cliprects 0 and 1, but outside 2 and 3, it is assigned
1067 * the number 3 (binary 0011).
1068 * Iff the bit corresponding to the pixel's number in RE_CLIPRECT_CNTL is set,
1069 * the pixel is rasterized.
1070 *
1071 * In addition to this, there is a scissors rectangle. Only pixels inside the
1072 * scissors rectangle are drawn. (coordinates are inclusive)
1073 *
1074 * For some reason, the top-left corner of the framebuffer is at (1440, 1440)
1075 * for the purpose of clipping and scissors.
1076 */
1077 #define R600_SC_CLIPRECT_TL_0 0x43B0
1078 #define R600_SC_CLIPRECT_BR_0 0x43B4
1079 #define R600_SC_CLIPRECT_TL_1 0x43B8
1080 #define R600_SC_CLIPRECT_BR_1 0x43BC
1081 #define R600_SC_CLIPRECT_TL_2 0x43C0
1082 #define R600_SC_CLIPRECT_BR_2 0x43C4
1083 #define R600_SC_CLIPRECT_TL_3 0x43C8
1084 #define R600_SC_CLIPRECT_BR_3 0x43CC
1085 # define R600_CLIPRECT_OFFSET 1440
1086 # define R600_CLIPRECT_MASK 0x1FFF
1087 # define R600_CLIPRECT_X_SHIFT 0
1088 # define R600_CLIPRECT_X_MASK (0x1FFF << 0)
1089 # define R600_CLIPRECT_Y_SHIFT 13
1090 # define R600_CLIPRECT_Y_MASK (0x1FFF << 13)
1091 #define R600_SC_CLIP_RULE 0x43D0
1092 # define R600_CLIP_OUT (1 << 0)
1093 # define R600_CLIP_0 (1 << 1)
1094 # define R600_CLIP_1 (1 << 2)
1095 # define R600_CLIP_10 (1 << 3)
1096 # define R600_CLIP_2 (1 << 4)
1097 # define R600_CLIP_20 (1 << 5)
1098 # define R600_CLIP_21 (1 << 6)
1099 # define R600_CLIP_210 (1 << 7)
1100 # define R600_CLIP_3 (1 << 8)
1101 # define R600_CLIP_30 (1 << 9)
1102 # define R600_CLIP_31 (1 << 10)
1103 # define R600_CLIP_310 (1 << 11)
1104 # define R600_CLIP_32 (1 << 12)
1105 # define R600_CLIP_320 (1 << 13)
1106 # define R600_CLIP_321 (1 << 14)
1107 # define R600_CLIP_3210 (1 << 15)
1108
1109 /* gap */
1110
1111 #define R600_SC_SCISSORS_TL 0x43E0
1112 #define R600_SC_SCISSORS_BR 0x43E4
1113 # define R600_SCISSORS_OFFSET 1440
1114 # define R600_SCISSORS_X_SHIFT 0
1115 # define R600_SCISSORS_X_MASK (0x1FFF << 0)
1116 # define R600_SCISSORS_Y_SHIFT 13
1117 # define R600_SCISSORS_Y_MASK (0x1FFF << 13)
1118
1119 /* Screen door sample mask */
1120 #define R600_SC_SCREENDOOR 0x43e8
1121
1122 /* END: Scissors and cliprects */
1123
1124 /* BEGIN: Texture specification */
1125
1126 /*
1127 * The texture specification dwords are grouped by meaning and not by texture
1128 * unit. This means that e.g. the offset for texture image unit N is found in
1129 * register TX_OFFSET_0 + (4*N)
1130 */
1131 #define R600_TX_FILTER0_0 0x4400
1132 #define R600_TX_FILTER0_1 0x4404
1133 #define R600_TX_FILTER0_2 0x4408
1134 #define R600_TX_FILTER0_3 0x440c
1135 #define R600_TX_FILTER0_4 0x4410
1136 #define R600_TX_FILTER0_5 0x4414
1137 #define R600_TX_FILTER0_6 0x4418
1138 #define R600_TX_FILTER0_7 0x441c
1139 #define R600_TX_FILTER0_8 0x4420
1140 #define R600_TX_FILTER0_9 0x4424
1141 #define R600_TX_FILTER0_10 0x4428
1142 #define R600_TX_FILTER0_11 0x442c
1143 #define R600_TX_FILTER0_12 0x4430
1144 #define R600_TX_FILTER0_13 0x4434
1145 #define R600_TX_FILTER0_14 0x4438
1146 #define R600_TX_FILTER0_15 0x443c
1147 # define R600_TX_REPEAT 0
1148 # define R600_TX_MIRRORED 1
1149 # define R600_TX_CLAMP_TO_EDGE 2
1150 # define R600_TX_MIRROR_ONCE_TO_EDGE 3
1151 # define R600_TX_CLAMP 4
1152 # define R600_TX_MIRROR_ONCE 5
1153 # define R600_TX_CLAMP_TO_BORDER 6
1154 # define R600_TX_MIRROR_ONCE_TO_BORDER 7
1155 # define R600_TX_WRAP_S_SHIFT 0
1156 # define R600_TX_WRAP_S_MASK (7 << 0)
1157 # define R600_TX_WRAP_T_SHIFT 3
1158 # define R600_TX_WRAP_T_MASK (7 << 3)
1159 # define R600_TX_WRAP_R_SHIFT 6
1160 # define R600_TX_WRAP_R_MASK (7 << 6)
1161 # define R600_TX_MAG_FILTER_4 (0 << 9)
1162 # define R600_TX_MAG_FILTER_NEAREST (1 << 9)
1163 # define R600_TX_MAG_FILTER_LINEAR (2 << 9)
1164 # define R600_TX_MAG_FILTER_ANISO (3 << 9)
1165 # define R600_TX_MAG_FILTER_MASK (3 << 9)
1166 # define R600_TX_MIN_FILTER_NEAREST (1 << 11)
1167 # define R600_TX_MIN_FILTER_LINEAR (2 << 11)
1168 # define R600_TX_MIN_FILTER_ANISO (3 << 11)
1169 # define R600_TX_MIN_FILTER_MASK (3 << 11)
1170 # define R600_TX_MIN_FILTER_MIP_NONE (0 << 13)
1171 # define R600_TX_MIN_FILTER_MIP_NEAREST (1 << 13)
1172 # define R600_TX_MIN_FILTER_MIP_LINEAR (2 << 13)
1173 # define R600_TX_MIN_FILTER_MIP_MASK (3 << 13)
1174 # define R600_TX_MAX_ANISO_1_TO_1 (0 << 21)
1175 # define R600_TX_MAX_ANISO_2_TO_1 (1 << 21)
1176 # define R600_TX_MAX_ANISO_4_TO_1 (2 << 21)
1177 # define R600_TX_MAX_ANISO_8_TO_1 (3 << 21)
1178 # define R600_TX_MAX_ANISO_16_TO_1 (4 << 21)
1179 # define R600_TX_MAX_ANISO_MASK (7 << 21)
1180
1181 #define R600_TX_FILTER1_0 0x4440
1182 # define R600_CHROMA_KEY_MODE_DISABLE 0
1183 # define R600_CHROMA_KEY_FORCE 1
1184 # define R600_CHROMA_KEY_BLEND 2
1185 # define R600_MC_ROUND_NORMAL (0<<2)
1186 # define R600_MC_ROUND_MPEG4 (1<<2)
1187 # define R600_LOD_BIAS_SHIFT 3
1188 # define R600_LOD_BIAS_MASK 0x1ff8
1189 # define R600_EDGE_ANISO_EDGE_DIAG (0<<13)
1190 # define R600_EDGE_ANISO_EDGE_ONLY (1<<13)
1191 # define R600_MC_COORD_TRUNCATE_DISABLE (0<<14)
1192 # define R600_MC_COORD_TRUNCATE_MPEG (1<<14)
1193 # define R600_TX_TRI_PERF_0_8 (0<<15)
1194 # define R600_TX_TRI_PERF_1_8 (1<<15)
1195 # define R600_TX_TRI_PERF_1_4 (2<<15)
1196 # define R600_TX_TRI_PERF_3_8 (3<<15)
1197 # define R600_ANISO_THRESHOLD_MASK (7<<17)
1198
1199 #define R600_TX_SIZE_0 0x4480
1200 # define R600_TX_WIDTHMASK_SHIFT 0
1201 # define R600_TX_WIDTHMASK_MASK (2047 << 0)
1202 # define R600_TX_HEIGHTMASK_SHIFT 11
1203 # define R600_TX_HEIGHTMASK_MASK (2047 << 11)
1204 # define R600_TX_DEPTHMASK_SHIFT 22
1205 # define R600_TX_DEPTHMASK_MASK (0xf << 22)
1206 # define R600_TX_MAX_MIP_LEVEL_SHIFT 26
1207 # define R600_TX_MAX_MIP_LEVEL_MASK (0xf << 26)
1208 # define R600_TX_SIZE_PROJECTED (1<<30)
1209 # define R600_TX_SIZE_TXPITCH_EN (1<<31)
1210 #define R600_TX_FORMAT_0 0x44C0
1211 /* The interpretation of the format word by Wladimir van der Laan */
1212 /* The X, Y, Z and W refer to the layout of the components.
1213 They are given meanings as R, G, B and Alpha by the swizzle
1214 specification */
1215 # define R600_TX_FORMAT_X8 0x0
1216 # define R600_TX_FORMAT_X16 0x1
1217 # define R600_TX_FORMAT_Y4X4 0x2
1218 # define R600_TX_FORMAT_Y8X8 0x3
1219 # define R600_TX_FORMAT_Y16X16 0x4
1220 # define R600_TX_FORMAT_Z3Y3X2 0x5
1221 # define R600_TX_FORMAT_Z5Y6X5 0x6
1222 # define R600_TX_FORMAT_Z6Y5X5 0x7
1223 # define R600_TX_FORMAT_Z11Y11X10 0x8
1224 # define R600_TX_FORMAT_Z10Y11X11 0x9
1225 # define R600_TX_FORMAT_W4Z4Y4X4 0xA
1226 # define R600_TX_FORMAT_W1Z5Y5X5 0xB
1227 # define R600_TX_FORMAT_W8Z8Y8X8 0xC
1228 # define R600_TX_FORMAT_W2Z10Y10X10 0xD
1229 # define R600_TX_FORMAT_W16Z16Y16X16 0xE
1230 # define R600_TX_FORMAT_DXT1 0xF
1231 # define R600_TX_FORMAT_DXT3 0x10
1232 # define R600_TX_FORMAT_DXT5 0x11
1233 # define R600_TX_FORMAT_D3DMFT_CxV8U8 0x12 /* no swizzle */
1234 # define R600_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */
1235 # define R600_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */
1236 # define R600_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */
1237
1238 /* These two values are wrong, but they're the only values that
1239 * produce any even vaguely correct results. Can r600 only do 16-bit
1240 * depth textures?
1241 */
1242 # define R600_TX_FORMAT_X24_Y8 0x1e
1243 # define R600_TX_FORMAT_X32 0x1e
1244
1245 /* 0x16 - some 16 bit green format.. ?? */
1246 # define R600_TX_FORMAT_3D (1 << 25)
1247 # define R600_TX_FORMAT_CUBIC_MAP (2 << 25)
1248
1249 /* gap */
1250 /* Floating point formats */
1251 /* Note - hardware supports both 16 and 32 bit floating point */
1252 # define R600_TX_FORMAT_FL_I16 0x18
1253 # define R600_TX_FORMAT_FL_I16A16 0x19
1254 # define R600_TX_FORMAT_FL_R16G16B16A16 0x1A
1255 # define R600_TX_FORMAT_FL_I32 0x1B
1256 # define R600_TX_FORMAT_FL_I32A32 0x1C
1257 # define R600_TX_FORMAT_FL_R32G32B32A32 0x1D
1258 /* alpha modes, convenience mostly */
1259 /* if you have alpha, pick constant appropriate to the
1260 number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
1261 # define R600_TX_FORMAT_ALPHA_1CH 0x000
1262 # define R600_TX_FORMAT_ALPHA_2CH 0x200
1263 # define R600_TX_FORMAT_ALPHA_4CH 0x600
1264 # define R600_TX_FORMAT_ALPHA_NONE 0xA00
1265 /* Swizzling */
1266 /* constants */
1267 # define R600_TX_FORMAT_X 0
1268 # define R600_TX_FORMAT_Y 1
1269 # define R600_TX_FORMAT_Z 2
1270 # define R600_TX_FORMAT_W 3
1271 # define R600_TX_FORMAT_ZERO 4
1272 # define R600_TX_FORMAT_ONE 5
1273 /* 2.0*Z, everything above 1.0 is set to 0.0 */
1274 # define R600_TX_FORMAT_CUT_Z 6
1275 /* 2.0*W, everything above 1.0 is set to 0.0 */
1276 # define R600_TX_FORMAT_CUT_W 7
1277
1278 # define R600_TX_FORMAT_B_SHIFT 18
1279 # define R600_TX_FORMAT_G_SHIFT 15
1280 # define R600_TX_FORMAT_R_SHIFT 12
1281 # define R600_TX_FORMAT_A_SHIFT 9
1282 /* Convenience macro to take care of layout and swizzling */
1283 # define R600_EASY_TX_FORMAT(B, G, R, A, FMT) ( \
1284 ((R600_TX_FORMAT_##B)<<R600_TX_FORMAT_B_SHIFT) \
1285 | ((R600_TX_FORMAT_##G)<<R600_TX_FORMAT_G_SHIFT) \
1286 | ((R600_TX_FORMAT_##R)<<R600_TX_FORMAT_R_SHIFT) \
1287 | ((R600_TX_FORMAT_##A)<<R600_TX_FORMAT_A_SHIFT) \
1288 | (R600_TX_FORMAT_##FMT) \
1289 )
1290 /* These can be ORed with result of R600_EASY_TX_FORMAT()
1291 We don't really know what they do. Take values from a
1292 constant color ? */
1293 # define R600_TX_FORMAT_CONST_X (1<<5)
1294 # define R600_TX_FORMAT_CONST_Y (2<<5)
1295 # define R600_TX_FORMAT_CONST_Z (4<<5)
1296 # define R600_TX_FORMAT_CONST_W (8<<5)
1297
1298 # define R600_TX_FORMAT_YUV_MODE 0x00800000
1299
1300 #define R600_TX_FORMAT2_0 0x4500 /* obvious missing in gap */
1301 # define R600_TX_PITCHMASK_SHIFT 0
1302 # define R600_TX_PITCHMASK_MASK (2047 << 0)
1303
1304 #define R600_TX_OFFSET_0 0x4540
1305 #define R600_TX_OFFSET_1 0x4544
1306 #define R600_TX_OFFSET_2 0x4548
1307 #define R600_TX_OFFSET_3 0x454C
1308 #define R600_TX_OFFSET_4 0x4550
1309 #define R600_TX_OFFSET_5 0x4554
1310 #define R600_TX_OFFSET_6 0x4558
1311 #define R600_TX_OFFSET_7 0x455C
1312 /* BEGIN: Guess from R200 */
1313 # define R600_TXO_ENDIAN_NO_SWAP (0 << 0)
1314 # define R600_TXO_ENDIAN_BYTE_SWAP (1 << 0)
1315 # define R600_TXO_ENDIAN_WORD_SWAP (2 << 0)
1316 # define R600_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
1317 # define R600_TXO_MACRO_TILE (1 << 2)
1318 # define R600_TXO_MICRO_TILE_LINEAR (0 << 3)
1319 # define R600_TXO_MICRO_TILE (1 << 3)
1320 # define R600_TXO_MICRO_TILE_SQUARE (2 << 3)
1321 # define R600_TXO_OFFSET_MASK 0xffffffe0
1322 # define R600_TXO_OFFSET_SHIFT 5
1323 /* END: Guess from R200 */
1324
1325 /* 32 bit chroma key */
1326 #define R600_TX_CHROMA_KEY_0 0x4580
1327 #define R600_TX_CHROMA_KEY_1 0x4584
1328 #define R600_TX_CHROMA_KEY_2 0x4588
1329 #define R600_TX_CHROMA_KEY_3 0x458c
1330 #define R600_TX_CHROMA_KEY_4 0x4590
1331 #define R600_TX_CHROMA_KEY_5 0x4594
1332 #define R600_TX_CHROMA_KEY_6 0x4598
1333 #define R600_TX_CHROMA_KEY_7 0x459c
1334 #define R600_TX_CHROMA_KEY_8 0x45a0
1335 #define R600_TX_CHROMA_KEY_9 0x45a4
1336 #define R600_TX_CHROMA_KEY_10 0x45a8
1337 #define R600_TX_CHROMA_KEY_11 0x45ac
1338 #define R600_TX_CHROMA_KEY_12 0x45b0
1339 #define R600_TX_CHROMA_KEY_13 0x45b4
1340 #define R600_TX_CHROMA_KEY_14 0x45b8
1341 #define R600_TX_CHROMA_KEY_15 0x45bc
1342 /* ff00ff00 == { 0, 1.0, 0, 1.0 } */
1343
1344 /* Border Color */
1345 #define R600_TX_BORDER_COLOR_0 0x45c0
1346 #define R600_TX_BORDER_COLOR_1 0x45c4
1347 #define R600_TX_BORDER_COLOR_2 0x45c8
1348 #define R600_TX_BORDER_COLOR_3 0x45cc
1349 #define R600_TX_BORDER_COLOR_4 0x45d0
1350 #define R600_TX_BORDER_COLOR_5 0x45d4
1351 #define R600_TX_BORDER_COLOR_6 0x45d8
1352 #define R600_TX_BORDER_COLOR_7 0x45dc
1353 #define R600_TX_BORDER_COLOR_8 0x45e0
1354 #define R600_TX_BORDER_COLOR_9 0x45e4
1355 #define R600_TX_BORDER_COLOR_10 0x45e8
1356 #define R600_TX_BORDER_COLOR_11 0x45ec
1357 #define R600_TX_BORDER_COLOR_12 0x45f0
1358 #define R600_TX_BORDER_COLOR_13 0x45f4
1359 #define R600_TX_BORDER_COLOR_14 0x45f8
1360 #define R600_TX_BORDER_COLOR_15 0x45fc
1361
1362
1363 /* END: Texture specification */
1364
1365 /* BEGIN: Fragment program instruction set */
1366
1367 /* Fragment programs are written directly into register space.
1368 * There are separate instruction streams for texture instructions and ALU
1369 * instructions.
1370 * In order to synchronize these streams, the program is divided into up
1371 * to 4 nodes. Each node begins with a number of TEX operations, followed
1372 * by a number of ALU operations.
1373 * The first node can have zero TEX ops, all subsequent nodes must have at
1374 * least
1375 * one TEX ops.
1376 * All nodes must have at least one ALU op.
1377 *
1378 * The index of the last node is stored in PFS_CNTL_0: A value of 0 means
1379 * 1 node, a value of 3 means 4 nodes.
1380 * The total amount of instructions is defined in PFS_CNTL_2. The offsets are
1381 * offsets into the respective instruction streams, while *_END points to the
1382 * last instruction relative to this offset.
1383 */
1384 #define R600_US_CONFIG 0x4600
1385 # define R600_PFS_CNTL_LAST_NODES_SHIFT 0
1386 # define R600_PFS_CNTL_LAST_NODES_MASK (3 << 0)
1387 # define R600_PFS_CNTL_FIRST_NODE_HAS_TEX (1 << 3)
1388 #define R600_US_PIXSIZE 0x4604
1389 /* There is an unshifted value here which has so far always been equal to the
1390 * index of the highest used temporary register.
1391 */
1392 #define R600_US_CODE_OFFSET 0x4608
1393 # define R600_PFS_CNTL_ALU_OFFSET_SHIFT 0
1394 # define R600_PFS_CNTL_ALU_OFFSET_MASK (63 << 0)
1395 # define R600_PFS_CNTL_ALU_END_SHIFT 6
1396 # define R600_PFS_CNTL_ALU_END_MASK (63 << 6)
1397 # define R600_PFS_CNTL_TEX_OFFSET_SHIFT 13
1398 # define R600_PFS_CNTL_TEX_OFFSET_MASK (31 << 13)
1399 # define R600_PFS_CNTL_TEX_END_SHIFT 18
1400 # define R600_PFS_CNTL_TEX_END_MASK (31 << 18)
1401
1402 /* gap */
1403
1404 /* Nodes are stored backwards. The last active node is always stored in
1405 * PFS_NODE_3.
1406 * Example: In a 2-node program, NODE_0 and NODE_1 are set to 0. The
1407 * first node is stored in NODE_2, the second node is stored in NODE_3.
1408 *
1409 * Offsets are relative to the master offset from PFS_CNTL_2.
1410 */
1411 #define R600_US_CODE_ADDR_0 0x4610
1412 #define R600_US_CODE_ADDR_1 0x4614
1413 #define R600_US_CODE_ADDR_2 0x4618
1414 #define R600_US_CODE_ADDR_3 0x461C
1415 # define R600_ALU_START_SHIFT 0
1416 # define R600_ALU_START_MASK (63 << 0)
1417 # define R600_ALU_SIZE_SHIFT 6
1418 # define R600_ALU_SIZE_MASK (63 << 6)
1419 # define R600_TEX_START_SHIFT 12
1420 # define R600_TEX_START_MASK (31 << 12)
1421 # define R600_TEX_SIZE_SHIFT 17
1422 # define R600_TEX_SIZE_MASK (31 << 17)
1423 # define R600_RGBA_OUT (1 << 22)
1424 # define R600_W_OUT (1 << 23)
1425
1426 /* TEX
1427 * As far as I can tell, texture instructions cannot write into output
1428 * registers directly. A subsequent ALU instruction is always necessary,
1429 * even if it's just MAD o0, r0, 1, 0
1430 */
1431 #define R600_US_TEX_INST_0 0x4620
1432 # define R600_SRC_ADDR_SHIFT 0
1433 # define R600_SRC_ADDR_MASK (31 << 0)
1434 # define R600_DST_ADDR_SHIFT 6
1435 # define R600_DST_ADDR_MASK (31 << 6)
1436 # define R600_TEX_ID_SHIFT 11
1437 # define R600_TEX_ID_MASK (15 << 11)
1438 # define R600_TEX_INST_SHIFT 15
1439 # define R600_TEX_OP_NOP 0
1440 # define R600_TEX_OP_LD 1
1441 # define R600_TEX_OP_KIL 2
1442 # define R600_TEX_OP_TXP 3
1443 # define R600_TEX_OP_TXB 4
1444 # define R600_TEX_INST_MASK (7 << 15)
1445
1446 /* Output format from the unfied shader */
1447 #define R600_US_OUT_FMT 0x46A4
1448 # define R600_US_OUT_FMT_C4_8 (0 << 0)
1449 # define R600_US_OUT_FMT_C4_10 (1 << 0)
1450 # define R600_US_OUT_FMT_C4_10_GAMMA (2 << 0)
1451 # define R600_US_OUT_FMT_C_16 (3 << 0)
1452 # define R600_US_OUT_FMT_C2_16 (4 << 0)
1453 # define R600_US_OUT_FMT_C4_16 (5 << 0)
1454 # define R600_US_OUT_FMT_C_16_MPEG (6 << 0)
1455 # define R600_US_OUT_FMT_C2_16_MPEG (7 << 0)
1456 # define R600_US_OUT_FMT_C2_4 (8 << 0)
1457 # define R600_US_OUT_FMT_C_3_3_2 (9 << 0)
1458 # define R600_US_OUT_FMT_C_6_5_6 (10 << 0)
1459 # define R600_US_OUT_FMT_C_11_11_10 (11 << 0)
1460 # define R600_US_OUT_FMT_C_10_11_11 (12 << 0)
1461 # define R600_US_OUT_FMT_C_2_10_10_10 (13 << 0)
1462 /* reserved */
1463 # define R600_US_OUT_FMT_UNUSED (15 << 0)
1464 # define R600_US_OUT_FMT_C_16_FP (16 << 0)
1465 # define R600_US_OUT_FMT_C2_16_FP (17 << 0)
1466 # define R600_US_OUT_FMT_C4_16_FP (18 << 0)
1467 # define R600_US_OUT_FMT_C_32_FP (19 << 0)
1468 # define R600_US_OUT_FMT_C2_32_FP (20 << 0)
1469 # define R600_US_OUT_FMT_C4_32_FP (20 << 0)
1470
1471 /* ALU
1472 * The ALU instructions register blocks are enumerated according to the order
1473 * in which fglrx. I assume there is space for 64 instructions, since
1474 * each block has space for a maximum of 64 DWORDs, and this matches reported
1475 * native limits.
1476 *
1477 * The basic functional block seems to be one MAD for each color and alpha,
1478 * and an adder that adds all components after the MUL.
1479 * - ADD, MUL, MAD etc.: use MAD with appropriate neutral operands
1480 * - DP4: Use OUTC_DP4, OUTA_DP4
1481 * - DP3: Use OUTC_DP3, OUTA_DP4, appropriate alpha operands
1482 * - DPH: Use OUTC_DP4, OUTA_DP4, appropriate alpha operands
1483 * - CMPH: If ARG2 > 0.5, return ARG0, else return ARG1
1484 * - CMP: If ARG2 < 0, return ARG1, else return ARG0
1485 * - FLR: use FRC+MAD
1486 * - XPD: use MAD+MAD
1487 * - SGE, SLT: use MAD+CMP
1488 * - RSQ: use ABS modifier for argument
1489 * - Use OUTC_REPL_ALPHA to write results of an alpha-only operation
1490 * (e.g. RCP) into color register
1491 * - apparently, there's no quick DST operation
1492 * - fglrx set FPI2_UNKNOWN_31 on a "MAD fragment.color, tmp0, tmp1, tmp2"
1493 * - fglrx set FPI2_UNKNOWN_31 on a "MAX r2, r1, c0"
1494 * - fglrx once set FPI0_UNKNOWN_31 on a "FRC r1, r1"
1495 *
1496 * Operand selection
1497 * First stage selects three sources from the available registers and
1498 * constant parameters. This is defined in INSTR1 (color) and INSTR3 (alpha).
1499 * fglrx sorts the three source fields: Registers before constants,
1500 * lower indices before higher indices; I do not know whether this is
1501 * necessary.
1502 *
1503 * fglrx fills unused sources with "read constant 0"
1504 * According to specs, you cannot select more than two different constants.
1505 *
1506 * Second stage selects the operands from the sources. This is defined in
1507 * INSTR0 (color) and INSTR2 (alpha). You can also select the special constants
1508 * zero and one.
1509 * Swizzling and negation happens in this stage, as well.
1510 *
1511 * Important: Color and alpha seem to be mostly separate, i.e. their sources
1512 * selection appears to be fully independent (the register storage is probably
1513 * physically split into a color and an alpha section).
1514 * However (because of the apparent physical split), there is some interaction
1515 * WRT swizzling. If, for example, you want to load an R component into an
1516 * Alpha operand, this R component is taken from a *color* source, not from
1517 * an alpha source. The corresponding register doesn't even have to appear in
1518 * the alpha sources list. (I hope this all makes sense to you)
1519 *
1520 * Destination selection
1521 * The destination register index is in FPI1 (color) and FPI3 (alpha)
1522 * together with enable bits.
1523 * There are separate enable bits for writing into temporary registers
1524 * (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_*
1525 * /DSTA_OUTPUT). You can write to both at once, or not write at all (the
1526 * same index must be used for both).
1527 *
1528 * Note: There is a special form for LRP
1529 * - Argument order is the same as in ARB_fragment_program.
1530 * - Operation is MAD
1531 * - ARG1 is set to ARGC_SRC1C_LRP/ARGC_SRC1A_LRP
1532 * - Set FPI0/FPI2_SPECIAL_LRP
1533 * Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD
1534 */
1535 #define R600_US_ALU_RGB_ADDR_0 0x46C0
1536 # define R600_ALU_SRC0C_SHIFT 0
1537 # define R600_ALU_SRC0C_MASK (31 << 0)
1538 # define R600_ALU_SRC0C_CONST (1 << 5)
1539 # define R600_ALU_SRC1C_SHIFT 6
1540 # define R600_ALU_SRC1C_MASK (31 << 6)
1541 # define R600_ALU_SRC1C_CONST (1 << 11)
1542 # define R600_ALU_SRC2C_SHIFT 12
1543 # define R600_ALU_SRC2C_MASK (31 << 12)
1544 # define R600_ALU_SRC2C_CONST (1 << 17)
1545 # define R600_ALU_SRC_MASK 0x0003ffff
1546 # define R600_ALU_DSTC_SHIFT 18
1547 # define R600_ALU_DSTC_MASK (31 << 18)
1548 # define R600_ALU_DSTC_REG_MASK_SHIFT 23
1549 # define R600_ALU_DSTC_REG_X (1 << 23)
1550 # define R600_ALU_DSTC_REG_Y (1 << 24)
1551 # define R600_ALU_DSTC_REG_Z (1 << 25)
1552 # define R600_ALU_DSTC_OUTPUT_MASK_SHIFT 26
1553 # define R600_ALU_DSTC_OUTPUT_X (1 << 26)
1554 # define R600_ALU_DSTC_OUTPUT_Y (1 << 27)
1555 # define R600_ALU_DSTC_OUTPUT_Z (1 << 28)
1556
1557 #define R600_US_ALU_ALPHA_ADDR_0 0x47C0
1558 # define R600_ALU_SRC0A_SHIFT 0
1559 # define R600_ALU_SRC0A_MASK (31 << 0)
1560 # define R600_ALU_SRC0A_CONST (1 << 5)
1561 # define R600_ALU_SRC1A_SHIFT 6
1562 # define R600_ALU_SRC1A_MASK (31 << 6)
1563 # define R600_ALU_SRC1A_CONST (1 << 11)
1564 # define R600_ALU_SRC2A_SHIFT 12
1565 # define R600_ALU_SRC2A_MASK (31 << 12)
1566 # define R600_ALU_SRC2A_CONST (1 << 17)
1567 # define R600_ALU_SRC_MASK 0x0003ffff
1568 # define R600_ALU_DSTA_SHIFT 18
1569 # define R600_ALU_DSTA_MASK (31 << 18)
1570 # define R600_ALU_DSTA_REG (1 << 23)
1571 # define R600_ALU_DSTA_OUTPUT (1 << 24)
1572 # define R600_ALU_DSTA_DEPTH (1 << 27)
1573
1574 #define R600_US_ALU_RGB_INST_0 0x48C0
1575 # define R600_ALU_ARGC_SRC0C_XYZ 0
1576 # define R600_ALU_ARGC_SRC0C_XXX 1
1577 # define R600_ALU_ARGC_SRC0C_YYY 2
1578 # define R600_ALU_ARGC_SRC0C_ZZZ 3
1579 # define R600_ALU_ARGC_SRC1C_XYZ 4
1580 # define R600_ALU_ARGC_SRC1C_XXX 5
1581 # define R600_ALU_ARGC_SRC1C_YYY 6
1582 # define R600_ALU_ARGC_SRC1C_ZZZ 7
1583 # define R600_ALU_ARGC_SRC2C_XYZ 8
1584 # define R600_ALU_ARGC_SRC2C_XXX 9
1585 # define R600_ALU_ARGC_SRC2C_YYY 10
1586 # define R600_ALU_ARGC_SRC2C_ZZZ 11
1587 # define R600_ALU_ARGC_SRC0A 12
1588 # define R600_ALU_ARGC_SRC1A 13
1589 # define R600_ALU_ARGC_SRC2A 14
1590 # define R600_ALU_ARGC_SRCP_XYZ 15
1591 # define R600_ALU_ARGC_SRCP_XXX 16
1592 # define R600_ALU_ARGC_SRCP_YYY 17
1593 # define R600_ALU_ARGC_SRCP_ZZZ 18
1594 # define R600_ALU_ARGC_SRCP_WWW 19
1595 # define R600_ALU_ARGC_ZERO 20
1596 # define R600_ALU_ARGC_ONE 21
1597 # define R600_ALU_ARGC_HALF 22
1598 # define R600_ALU_ARGC_SRC0C_YZX 23
1599 # define R600_ALU_ARGC_SRC1C_YZX 24
1600 # define R600_ALU_ARGC_SRC2C_YZX 25
1601 # define R600_ALU_ARGC_SRC0C_ZXY 26
1602 # define R600_ALU_ARGC_SRC1C_ZXY 27
1603 # define R600_ALU_ARGC_SRC2C_ZXY 28
1604 # define R600_ALU_ARGC_SRC0CA_WZY 29
1605 # define R600_ALU_ARGC_SRC1CA_WZY 30
1606 # define R600_ALU_ARGC_SRC2CA_WZY 31
1607
1608 # define R600_ALU_ARG0C_SHIFT 0
1609 # define R600_ALU_ARG0C_MASK (31 << 0)
1610 # define R600_ALU_ARG0C_NOP (0 << 5)
1611 # define R600_ALU_ARG0C_NEG (1 << 5)
1612 # define R600_ALU_ARG0C_ABS (2 << 5)
1613 # define R600_ALU_ARG0C_NAB (3 << 5)
1614 # define R600_ALU_ARG1C_SHIFT 7
1615 # define R600_ALU_ARG1C_MASK (31 << 7)
1616 # define R600_ALU_ARG1C_NOP (0 << 12)
1617 # define R600_ALU_ARG1C_NEG (1 << 12)
1618 # define R600_ALU_ARG1C_ABS (2 << 12)
1619 # define R600_ALU_ARG1C_NAB (3 << 12)
1620 # define R600_ALU_ARG2C_SHIFT 14
1621 # define R600_ALU_ARG2C_MASK (31 << 14)
1622 # define R600_ALU_ARG2C_NOP (0 << 19)
1623 # define R600_ALU_ARG2C_NEG (1 << 19)
1624 # define R600_ALU_ARG2C_ABS (2 << 19)
1625 # define R600_ALU_ARG2C_NAB (3 << 19)
1626 # define R600_ALU_SRCP_1_MINUS_2_SRC0 (0 << 21)
1627 # define R600_ALU_SRCP_SRC1_MINUS_SRC0 (1 << 21)
1628 # define R600_ALU_SRCP_SRC1_PLUS_SRC0 (2 << 21)
1629 # define R600_ALU_SRCP_1_MINUS_SRC0 (3 << 21)
1630
1631 # define R600_ALU_OUTC_MAD (0 << 23)
1632 # define R600_ALU_OUTC_DP3 (1 << 23)
1633 # define R600_ALU_OUTC_DP4 (2 << 23)
1634 # define R600_ALU_OUTC_D2A (3 << 23)
1635 # define R600_ALU_OUTC_MIN (4 << 23)
1636 # define R600_ALU_OUTC_MAX (5 << 23)
1637 # define R600_ALU_OUTC_CMPH (7 << 23)
1638 # define R600_ALU_OUTC_CMP (8 << 23)
1639 # define R600_ALU_OUTC_FRC (9 << 23)
1640 # define R600_ALU_OUTC_REPL_ALPHA (10 << 23)
1641
1642 # define R600_ALU_OUTC_MOD_NOP (0 << 27)
1643 # define R600_ALU_OUTC_MOD_MUL2 (1 << 27)
1644 # define R600_ALU_OUTC_MOD_MUL4 (2 << 27)
1645 # define R600_ALU_OUTC_MOD_MUL8 (3 << 27)
1646 # define R600_ALU_OUTC_MOD_DIV2 (4 << 27)
1647 # define R600_ALU_OUTC_MOD_DIV4 (5 << 27)
1648 # define R600_ALU_OUTC_MOD_DIV8 (6 << 27)
1649
1650 # define R600_ALU_OUTC_CLAMP (1 << 30)
1651 # define R600_ALU_INSERT_NOP (1 << 31)
1652
1653 #define R600_US_ALU_ALPHA_INST_0 0x49C0
1654 # define R600_ALU_ARGA_SRC0C_X 0
1655 # define R600_ALU_ARGA_SRC0C_Y 1
1656 # define R600_ALU_ARGA_SRC0C_Z 2
1657 # define R600_ALU_ARGA_SRC1C_X 3
1658 # define R600_ALU_ARGA_SRC1C_Y 4
1659 # define R600_ALU_ARGA_SRC1C_Z 5
1660 # define R600_ALU_ARGA_SRC2C_X 6
1661 # define R600_ALU_ARGA_SRC2C_Y 7
1662 # define R600_ALU_ARGA_SRC2C_Z 8
1663 # define R600_ALU_ARGA_SRC0A 9
1664 # define R600_ALU_ARGA_SRC1A 10
1665 # define R600_ALU_ARGA_SRC2A 11
1666 # define R600_ALU_ARGA_SRCP_X 12
1667 # define R600_ALU_ARGA_SRCP_Y 13
1668 # define R600_ALU_ARGA_SRCP_Z 14
1669 # define R600_ALU_ARGA_SRCP_W 15
1670
1671 # define R600_ALU_ARGA_ZERO 16
1672 # define R600_ALU_ARGA_ONE 17
1673 # define R600_ALU_ARGA_HALF 18
1674 # define R600_ALU_ARG0A_SHIFT 0
1675 # define R600_ALU_ARG0A_MASK (31 << 0)
1676 # define R600_ALU_ARG0A_NOP (0 << 5)
1677 # define R600_ALU_ARG0A_NEG (1 << 5)
1678 # define R600_ALU_ARG0A_ABS (2 << 5)
1679 # define R600_ALU_ARG0A_NAB (3 << 5)
1680 # define R600_ALU_ARG1A_SHIFT 7
1681 # define R600_ALU_ARG1A_MASK (31 << 7)
1682 # define R600_ALU_ARG1A_NOP (0 << 12)
1683 # define R600_ALU_ARG1A_NEG (1 << 12)
1684 # define R600_ALU_ARG1A_ABS (2 << 12)
1685 # define R600_ALU_ARG1A_NAB (3 << 12)
1686 # define R600_ALU_ARG2A_SHIFT 14
1687 # define R600_ALU_ARG2A_MASK (31 << 14)
1688 # define R600_ALU_ARG2A_NOP (0 << 19)
1689 # define R600_ALU_ARG2A_NEG (1 << 19)
1690 # define R600_ALU_ARG2A_ABS (2 << 19)
1691 # define R600_ALU_ARG2A_NAB (3 << 19)
1692 # define R600_ALU_SRCP_1_MINUS_2_SRC0 (0 << 21)
1693 # define R600_ALU_SRCP_SRC1_MINUS_SRC0 (1 << 21)
1694 # define R600_ALU_SRCP_SRC1_PLUS_SRC0 (2 << 21)
1695 # define R600_ALU_SRCP_1_MINUS_SRC0 (3 << 21)
1696
1697 # define R600_ALU_OUTA_MAD (0 << 23)
1698 # define R600_ALU_OUTA_DP4 (1 << 23)
1699 # define R600_ALU_OUTA_MIN (2 << 23)
1700 # define R600_ALU_OUTA_MAX (3 << 23)
1701 # define R600_ALU_OUTA_CND (5 << 23)
1702 # define R600_ALU_OUTA_CMP (6 << 23)
1703 # define R600_ALU_OUTA_FRC (7 << 23)
1704 # define R600_ALU_OUTA_EX2 (8 << 23)
1705 # define R600_ALU_OUTA_LG2 (9 << 23)
1706 # define R600_ALU_OUTA_RCP (10 << 23)
1707 # define R600_ALU_OUTA_RSQ (11 << 23)
1708
1709 # define R600_ALU_OUTA_MOD_NOP (0 << 27)
1710 # define R600_ALU_OUTA_MOD_MUL2 (1 << 27)
1711 # define R600_ALU_OUTA_MOD_MUL4 (2 << 27)
1712 # define R600_ALU_OUTA_MOD_MUL8 (3 << 27)
1713 # define R600_ALU_OUTA_MOD_DIV2 (4 << 27)
1714 # define R600_ALU_OUTA_MOD_DIV4 (5 << 27)
1715 # define R600_ALU_OUTA_MOD_DIV8 (6 << 27)
1716
1717 # define R600_ALU_OUTA_CLAMP (1 << 30)
1718 /* END: Fragment program instruction set */
1719
1720 /* Fog: Fog Blending Enable */
1721 #define R600_FG_FOG_BLEND 0x4bc0
1722 # define R600_FG_FOG_BLEND_DISABLE (0 << 0)
1723 # define R600_FG_FOG_BLEND_ENABLE (1 << 0)
1724 # define R600_FG_FOG_BLEND_FN_LINEAR (0 << 1)
1725 # define R600_FG_FOG_BLEND_FN_EXP (1 << 1)
1726 # define R600_FG_FOG_BLEND_FN_EXP2 (2 << 1)
1727 # define R600_FG_FOG_BLEND_FN_CONSTANT (3 << 1)
1728 # define R600_FG_FOG_BLEND_FN_MASK (3 << 1)
1729
1730 /* Fog: Red Component of Fog Color */
1731 #define R600_FG_FOG_COLOR_R 0x4bc8
1732 /* Fog: Green Component of Fog Color */
1733 #define R600_FG_FOG_COLOR_G 0x4bcc
1734 /* Fog: Blue Component of Fog Color */
1735 #define R600_FG_FOG_COLOR_B 0x4bd0
1736 # define R600_FG_FOG_COLOR_MASK 0x000003ff
1737
1738 /* Fog: Constant Factor for Fog Blending */
1739 #define R600_FG_FOG_FACTOR 0x4bc4
1740 # define FG_FOG_FACTOR_MASK 0x000003ff
1741
1742 /* Fog: Alpha function */
1743 #define R600_FG_ALPHA_FUNC 0x4bd4
1744 # define R600_FG_ALPHA_FUNC_VAL_MASK 0x000000ff
1745 # define R600_FG_ALPHA_FUNC_NEVER (0 << 8)
1746 # define R600_FG_ALPHA_FUNC_LESS (1 << 8)
1747 # define R600_FG_ALPHA_FUNC_EQUAL (2 << 8)
1748 # define R600_FG_ALPHA_FUNC_LE (3 << 8)
1749 # define R600_FG_ALPHA_FUNC_GREATER (4 << 8)
1750 # define R600_FG_ALPHA_FUNC_NOTEQUAL (5 << 8)
1751 # define R600_FG_ALPHA_FUNC_GE (6 << 8)
1752 # define R600_FG_ALPHA_FUNC_ALWAYS (7 << 8)
1753 # define R600_ALPHA_TEST_OP_MASK (7 << 8)
1754 # define R600_FG_ALPHA_FUNC_DISABLE (0 << 11)
1755 # define R600_FG_ALPHA_FUNC_ENABLE (1 << 11)
1756
1757 # define R600_FG_ALPHA_FUNC_MASK_DISABLE (0 << 16)
1758 # define R600_FG_ALPHA_FUNC_MASK_ENABLE (1 << 16)
1759 # define R600_FG_ALPHA_FUNC_CFG_2_OF_4 (0 << 17)
1760 # define R600_FG_ALPHA_FUNC_CFG_3_OF_6 (1 << 17)
1761
1762 # define R600_FG_ALPHA_FUNC_DITH_DISABLE (0 << 20)
1763 # define R600_FG_ALPHA_FUNC_DITH_ENABLE (1 << 20)
1764
1765 /* Fog: Where does the depth come from? */
1766 #define R600_FG_DEPTH_SRC 0x4bd8
1767 # define R600_FG_DEPTH_SRC_SCAN (0 << 0)
1768 # define R600_FG_DEPTH_SRC_SHADER (1 << 0)
1769
1770 /* gap */
1771
1772 /* Fragment program parameters in 7.16 floating point */
1773 #define R600_PFS_PARAM_0_X 0x4C00
1774 #define R600_PFS_PARAM_0_Y 0x4C04
1775 #define R600_PFS_PARAM_0_Z 0x4C08
1776 #define R600_PFS_PARAM_0_W 0x4C0C
1777 /* last consts */
1778 #define R600_PFS_PARAM_31_X 0x4DF0
1779 #define R600_PFS_PARAM_31_Y 0x4DF4
1780 #define R600_PFS_PARAM_31_Z 0x4DF8
1781 #define R600_PFS_PARAM_31_W 0x4DFC
1782
1783 /* Unpipelined. */
1784 #define R600_RB3D_CCTL 0x4e00
1785 # define R600_RB3D_CCTL_NUM_MULTIWRITES_1_BUFFER (0 << 5)
1786 # define R600_RB3D_CCTL_NUM_MULTIWRITES_2_BUFFERS (1 << 5)
1787 # define R600_RB3D_CCTL_NUM_MULTIWRITES_3_BUFFERS (2 << 5)
1788 # define R600_RB3D_CCTL_NUM_MULTIWRITES_4_BUFFERS (3 << 5)
1789 # define R600_RB3D_CCTL_CLRCMP_FLIPE_DISABLE (0 << 7)
1790 # define R600_RB3D_CCTL_CLRCMP_FLIPE_ENABLE (1 << 7)
1791 # define R600_RB3D_CCTL_AA_COMPRESSION_DISABLE (0 << 9)
1792 # define R600_RB3D_CCTL_AA_COMPRESSION_ENABLE (1 << 9)
1793 # define R600_RB3D_CCTL_CMASK_DISABLE (0 << 10)
1794 # define R600_RB3D_CCTL_CMASK_ENABLE (1 << 10)
1795 /* reserved */
1796 # define R600_RB3D_CCTL_INDEPENDENT_COLOR_CHANNEL_MASK_DISABLE (0 << 12)
1797 # define R600_RB3D_CCTL_INDEPENDENT_COLOR_CHANNEL_MASK_ENABLE (1 << 12)
1798 # define R600_RB3D_CCTL_WRITE_COMPRESSION_ENABLE (0 << 13)
1799 # define R600_RB3D_CCTL_WRITE_COMPRESSION_DISABLE (1 << 13)
1800 # define R600_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_DISABLE (0 << 14)
1801 # define R600_RB3D_CCTL_INDEPENDENT_COLORFORMAT_ENABLE_ENABLE (1 << 14)
1802
1803
1804 /* Notes:
1805 * - AFAIK fglrx always sets BLEND_UNKNOWN when blending is used in
1806 * the application
1807 * - AFAIK fglrx always sets BLEND_NO_SEPARATE when CBLEND and ABLEND
1808 * are set to the same
1809 * function (both registers are always set up completely in any case)
1810 * - Most blend flags are simply copied from R200 and not tested yet
1811 */
1812 #define R600_RB3D_CBLEND 0x4E04
1813 #define R600_RB3D_ABLEND 0x4E08
1814 /* the following only appear in CBLEND */
1815 # define R600_ALPHA_BLEND_ENABLE (1 << 0)
1816 # define R600_SEPARATE_ALPHA_ENABLE (1 << 1)
1817 # define R600_READ_ENABLE (1 << 2)
1818 # define R600_DISCARD_SRC_PIXELS_DIS (0 << 3)
1819 # define R600_DISCARD_SRC_PIXELS_SRC_ALPHA_0 (1 << 3)
1820 # define R600_DISCARD_SRC_PIXELS_SRC_COLOR_0 (2 << 3)
1821 # define R600_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_0 (3 << 3)
1822 # define R600_DISCARD_SRC_PIXELS_SRC_ALPHA_1 (4 << 3)
1823 # define R600_DISCARD_SRC_PIXELS_SRC_COLOR_1 (5 << 3)
1824 # define R600_DISCARD_SRC_PIXELS_SRC_ALPHA_COLOR_1 (6 << 3)
1825
1826 /* the following are shared between CBLEND and ABLEND */
1827 # define R600_FCN_MASK (3 << 12)
1828 # define R600_COMB_FCN_ADD_CLAMP (0 << 12)
1829 # define R600_COMB_FCN_ADD_NOCLAMP (1 << 12)
1830 # define R600_COMB_FCN_SUB_CLAMP (2 << 12)
1831 # define R600_COMB_FCN_SUB_NOCLAMP (3 << 12)
1832 # define R600_COMB_FCN_MIN (4 << 12)
1833 # define R600_COMB_FCN_MAX (5 << 12)
1834 # define R600_COMB_FCN_RSUB_CLAMP (6 << 12)
1835 # define R600_COMB_FCN_RSUB_NOCLAMP (7 << 12)
1836 # define R600_BLEND_GL_ZERO (32)
1837 # define R600_BLEND_GL_ONE (33)
1838 # define R600_BLEND_GL_SRC_COLOR (34)
1839 # define R600_BLEND_GL_ONE_MINUS_SRC_COLOR (35)
1840 # define R600_BLEND_GL_DST_COLOR (36)
1841 # define R600_BLEND_GL_ONE_MINUS_DST_COLOR (37)
1842 # define R600_BLEND_GL_SRC_ALPHA (38)
1843 # define R600_BLEND_GL_ONE_MINUS_SRC_ALPHA (39)
1844 # define R600_BLEND_GL_DST_ALPHA (40)
1845 # define R600_BLEND_GL_ONE_MINUS_DST_ALPHA (41)
1846 # define R600_BLEND_GL_SRC_ALPHA_SATURATE (42)
1847 # define R600_BLEND_GL_CONST_COLOR (43)
1848 # define R600_BLEND_GL_ONE_MINUS_CONST_COLOR (44)
1849 # define R600_BLEND_GL_CONST_ALPHA (45)
1850 # define R600_BLEND_GL_ONE_MINUS_CONST_ALPHA (46)
1851 # define R600_BLEND_MASK (63)
1852 # define R600_SRC_BLEND_SHIFT (16)
1853 # define R600_DST_BLEND_SHIFT (24)
1854
1855 /* Constant color used by the blender. Pipelined through the blender.
1856 * Note: For R520, this field is ignored, use RB3D_CONSTANT_COLOR_GB__BLUE,
1857 * RB3D_CONSTANT_COLOR_GB__GREEN, etc. instead.
1858 */
1859 #define R600_RB3D_BLEND_COLOR 0x4E10
1860
1861
1862 /* 3D Color Channel Mask. If all the channels used in the current color format
1863 * are disabled, then the cb will discard all the incoming quads. Pipelined
1864 * through the blender.
1865 */
1866 #define RB3D_COLOR_CHANNEL_MASK 0x4E0C
1867 # define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK0 (1 << 0)
1868 # define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK0 (1 << 1)
1869 # define RB3D_COLOR_CHANNEL_MASK_RED_MASK0 (1 << 2)
1870 # define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK0 (1 << 3)
1871 # define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK1 (1 << 4)
1872 # define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK1 (1 << 5)
1873 # define RB3D_COLOR_CHANNEL_MASK_RED_MASK1 (1 << 6)
1874 # define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK1 (1 << 7)
1875 # define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK2 (1 << 8)
1876 # define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK2 (1 << 9)
1877 # define RB3D_COLOR_CHANNEL_MASK_RED_MASK2 (1 << 10)
1878 # define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK2 (1 << 11)
1879 # define RB3D_COLOR_CHANNEL_MASK_BLUE_MASK3 (1 << 12)
1880 # define RB3D_COLOR_CHANNEL_MASK_GREEN_MASK3 (1 << 13)
1881 # define RB3D_COLOR_CHANNEL_MASK_RED_MASK3 (1 << 14)
1882 # define RB3D_COLOR_CHANNEL_MASK_ALPHA_MASK3 (1 << 15)
1883
1884 /* Clear color that is used when the color mask is set to 00. Unpipelined.
1885 * Program this register with a 32-bit value in ARGB8888 or ARGB2101010
1886 * formats, ignoring the fields.
1887 */
1888 #define RB3D_COLOR_CLEAR_VALUE 0x4e14
1889
1890 /* gap */
1891
1892 /* Color Compare Color. Stalls the 2d/3d datapath until it is idle. */
1893 #define RB3D_CLRCMP_CLR 0x4e20
1894
1895 /* Color Compare Mask. Stalls the 2d/3d datapath until it is idle. */
1896 #define RB3D_CLRCMP_MSK 0x4e24
1897
1898 /* Color Buffer Address Offset of multibuffer 0. Unpipelined. */
1899 #define R600_RB3D_COLOROFFSET0 0x4E28
1900 # define R600_COLOROFFSET_MASK 0xFFFFFFE0
1901 /* Color Buffer Address Offset of multibuffer 1. Unpipelined. */
1902 #define R600_RB3D_COLOROFFSET1 0x4E2C
1903 /* Color Buffer Address Offset of multibuffer 2. Unpipelined. */
1904 #define R600_RB3D_COLOROFFSET2 0x4E30
1905 /* Color Buffer Address Offset of multibuffer 3. Unpipelined. */
1906 #define R600_RB3D_COLOROFFSET3 0x4E34
1907
1908 /* Color buffer format and tiling control for all the multibuffers and the
1909 * pitch of multibuffer 0 to 3. Unpipelined. The cache must be empty before any
1910 * of the registers are changed.
1911 *
1912 * Bit 16: Larger tiles
1913 * Bit 17: 4x2 tiles
1914 * Bit 18: Extremely weird tile like, but some pixels duplicated?
1915 */
1916 #define R600_RB3D_COLORPITCH0 0x4E38
1917 # define R600_COLORPITCH_MASK 0x00003FFE
1918 # define R600_COLOR_TILE_DISABLE (0 << 16)
1919 # define R600_COLOR_TILE_ENABLE (1 << 16)
1920 # define R600_COLOR_MICROTILE_DISABLE (0 << 17)
1921 # define R600_COLOR_MICROTILE_ENABLE (1 << 17)
1922 # define R600_COLOR_MICROTILE_ENABLE_SQUARE (2 << 17) /* Only available in 16-bit */
1923 # define R600_COLOR_ENDIAN_NO_SWAP (0 << 19)
1924 # define R600_COLOR_ENDIAN_WORD_SWAP (1 << 19)
1925 # define R600_COLOR_ENDIAN_DWORD_SWAP (2 << 19)
1926 # define R600_COLOR_ENDIAN_HALF_DWORD_SWAP (3 << 19)
1927 # define R600_COLOR_FORMAT_ARGB1555 (3 << 21)
1928 # define R600_COLOR_FORMAT_RGB565 (4 << 21)
1929 # define R600_COLOR_FORMAT_ARGB8888 (6 << 21)
1930 # define R600_COLOR_FORMAT_ARGB32323232 (7 << 21)
1931 /* reserved */
1932 # define R600_COLOR_FORMAT_I8 (9 << 21)
1933 # define R600_COLOR_FORMAT_ARGB16161616 (10 << 21)
1934 # define R600_COLOR_FORMAT_VYUY (11 << 21)
1935 # define R600_COLOR_FORMAT_YVYU (12 << 21)
1936 # define R600_COLOR_FORMAT_UV88 (13 << 21)
1937 # define R600_COLOR_FORMAT_ARGB4444 (15 << 21)
1938 #define R600_RB3D_COLORPITCH1 0x4E3C
1939 #define R600_RB3D_COLORPITCH2 0x4E40
1940 #define R600_RB3D_COLORPITCH3 0x4E44
1941
1942 /* gap */
1943
1944 /* Destination Color Buffer Cache Control/Status. If the cb is in e2 mode, then
1945 * a flush or free will not occur upon a write to this register, but a sync
1946 * will be immediately sent if one is requested. If both DC_FLUSH and DC_FREE
1947 * are zero but DC_FINISH is one, then a sync will be sent immediately -- the
1948 * cb will not wait for all the previous operations to complete before sending
1949 * the sync. Unpipelined except when DC_FINISH and DC_FREE are both set to
1950 * zero.
1951 *
1952 * Set to 0A before 3D operations, set to 02 afterwards.
1953 */
1954 #define R600_RB3D_DSTCACHE_CTLSTAT 0x4e4c
1955 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_NO_EFFECT (0 << 0)
1956 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_NO_EFFECT_1 (1 << 0)
1957 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D (2 << 0)
1958 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FLUSH_FLUSH_DIRTY_3D_1 (3 << 0)
1959 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FREE_NO_EFFECT (0 << 2)
1960 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FREE_NO_EFFECT_1 (1 << 2)
1961 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS (2 << 2)
1962 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FREE_FREE_3D_TAGS_1 (3 << 2)
1963 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_NO_SIGNAL (0 << 4)
1964 # define R600_RB3D_DSTCACHE_CTLSTAT_DC_FINISH_SIGNAL (1 << 4)
1965
1966 #define R600_RB3D_DITHER_CTL 0x4E50
1967 # define R600_RB3D_DITHER_CTL_DITHER_MODE_TRUNCATE (0 << 0)
1968 # define R600_RB3D_DITHER_CTL_DITHER_MODE_ROUND (1 << 0)
1969 # define R600_RB3D_DITHER_CTL_DITHER_MODE_LUT (2 << 0)
1970 /* reserved */
1971 # define R600_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_TRUNCATE (0 << 2)
1972 # define R600_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_ROUND (1 << 2)
1973 # define R600_RB3D_DITHER_CTL_ALPHA_DITHER_MODE_LUT (2 << 2)
1974 /* reserved */
1975
1976 /* Resolve buffer destination address. The cache must be empty before changing
1977 * this register if the cb is in resolve mode. Unpipelined
1978 */
1979 #define R600_RB3D_AARESOLVE_OFFSET 0x4e80
1980 # define R600_RB3D_AARESOLVE_OFFSET_SHIFT 5
1981 # define R600_RB3D_AARESOLVE_OFFSET_MASK 0xffffffe0 /* At least according to the calculations of Christoph Brill */
1982
1983 /* Resolve Buffer Pitch and Tiling Control. The cache must be empty before
1984 * changing this register if the cb is in resolve mode. Unpipelined
1985 */
1986 #define R600_RB3D_AARESOLVE_PITCH 0x4e84
1987 # define R600_RB3D_AARESOLVE_PITCH_SHIFT 1
1988 # define R600_RB3D_AARESOLVE_PITCH_MASK 0x00003ffe /* At least according to the calculations of Christoph Brill */
1989
1990 /* Resolve Buffer Control. Unpipelined */
1991 #define R600_RB3D_AARESOLVE_CTL 0x4e88
1992 # define R600_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_NORMAL (0 << 0)
1993 # define R600_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_RESOLVE (1 << 0)
1994 # define R600_RB3D_AARESOLVE_CTL_AARESOLVE_GAMMA_10 (0 << 1)
1995 # define R600_RB3D_AARESOLVE_CTL_AARESOLVE_GAMMA_22 (1 << 1)
1996 # define R600_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_SAMPLE0 (0 << 2)
1997 # define R600_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_AVERAGE (1 << 2)
1998
1999 /* 3D ROP Control. Stalls the 2d/3d datapath until it is idle. */
2000 #define R600_RB3D_ROPCNTL 0x4e18
2001 # define R600_RB3D_ROPCNTL_ROP_ENABLE 0x00000004
2002 # define R600_RB3D_ROPCNTL_ROP_MASK (15 << 8)
2003 # define R600_RB3D_ROPCNTL_ROP_SHIFT 8
2004
2005 /* Color Compare Flip. Stalls the 2d/3d datapath until it is idle. */
2006 #define R600_RB3D_CLRCMP_FLIPE 0x4e1c
2007
2008 /* gap */
2009 /* There seems to be no "write only" setting, so use Z-test = ALWAYS
2010 * for this.
2011 * Bit (1<<8) is the "test" bit. so plain write is 6 - vd
2012 */
2013 #define R600_ZB_CNTL 0x4F00
2014 # define R600_STENCIL_ENABLE (1 << 0)
2015 # define R600_Z_ENABLE (1 << 1)
2016 # define R600_Z_WRITE_ENABLE (1 << 2)
2017 # define R600_Z_SIGNED_COMPARE (1 << 3)
2018 # define R600_STENCIL_FRONT_BACK (1 << 4)
2019
2020 #define R600_ZB_ZSTENCILCNTL 0x4f04
2021 /* functions */
2022 # define R600_ZS_NEVER 0
2023 # define R600_ZS_LESS 1
2024 # define R600_ZS_LEQUAL 2
2025 # define R600_ZS_EQUAL 3
2026 # define R600_ZS_GEQUAL 4
2027 # define R600_ZS_GREATER 5
2028 # define R600_ZS_NOTEQUAL 6
2029 # define R600_ZS_ALWAYS 7
2030 # define R600_ZS_MASK 7
2031 /* operations */
2032 # define R600_ZS_KEEP 0
2033 # define R600_ZS_ZERO 1
2034 # define R600_ZS_REPLACE 2
2035 # define R600_ZS_INCR 3
2036 # define R600_ZS_DECR 4
2037 # define R600_ZS_INVERT 5
2038 # define R600_ZS_INCR_WRAP 6
2039 # define R600_ZS_DECR_WRAP 7
2040 # define R600_Z_FUNC_SHIFT 0
2041 /* front and back refer to operations done for front
2042 and back faces, i.e. separate stencil function support */
2043 # define R600_S_FRONT_FUNC_SHIFT 3
2044 # define R600_S_FRONT_SFAIL_OP_SHIFT 6
2045 # define R600_S_FRONT_ZPASS_OP_SHIFT 9
2046 # define R600_S_FRONT_ZFAIL_OP_SHIFT 12
2047 # define R600_S_BACK_FUNC_SHIFT 15
2048 # define R600_S_BACK_SFAIL_OP_SHIFT 18
2049 # define R600_S_BACK_ZPASS_OP_SHIFT 21
2050 # define R600_S_BACK_ZFAIL_OP_SHIFT 24
2051
2052 #define R600_ZB_STENCILREFMASK 0x4f08
2053 # define R600_STENCILREF_SHIFT 0
2054 # define R600_STENCILREF_MASK 0x000000ff
2055 # define R600_STENCILMASK_SHIFT 8
2056 # define R600_STENCILMASK_MASK 0x0000ff00
2057 # define R600_STENCILWRITEMASK_SHIFT 16
2058 # define R600_STENCILWRITEMASK_MASK 0x00ff0000
2059
2060 /* gap */
2061
2062 #define R600_ZB_FORMAT 0x4f10
2063 # define R600_DEPTHFORMAT_16BIT_INT_Z (0 << 0)
2064 # define R600_DEPTHFORMAT_16BIT_13E3 (1 << 0)
2065 # define R600_DEPTHFORMAT_24BIT_INT_Z_8BIT_STENCIL (2 << 0)
2066 /* reserved up to (15 << 0) */
2067 # define R600_INVERT_13E3_LEADING_ONES (0 << 4)
2068 # define R600_INVERT_13E3_LEADING_ZEROS (1 << 4)
2069
2070 #define R600_ZB_ZTOP 0x4F14
2071 # define R600_ZTOP_DISABLE (0 << 0)
2072 # define R600_ZTOP_ENABLE (1 << 0)
2073
2074 /* gap */
2075
2076 #define R600_ZB_ZCACHE_CTLSTAT 0x4f18
2077 # define R600_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_NO_EFFECT (0 << 0)
2078 # define R600_ZB_ZCACHE_CTLSTAT_ZC_FLUSH_FLUSH_AND_FREE (1 << 0)
2079 # define R600_ZB_ZCACHE_CTLSTAT_ZC_FREE_NO_EFFECT (0 << 1)
2080 # define R600_ZB_ZCACHE_CTLSTAT_ZC_FREE_FREE (1 << 1)
2081 # define R600_ZB_ZCACHE_CTLSTAT_ZC_BUSY_IDLE (0 << 31)
2082 # define R600_ZB_ZCACHE_CTLSTAT_ZC_BUSY_BUSY (1 << 31)
2083
2084 #define R600_ZB_BW_CNTL 0x4f1c
2085 # define R600_HIZ_DISABLE (0 << 0)
2086 # define R600_HIZ_ENABLE (1 << 0)
2087 # define R600_HIZ_MIN (0 << 1)
2088 # define R600_HIZ_MAX (1 << 1)
2089 # define R600_FAST_FILL_DISABLE (0 << 2)
2090 # define R600_FAST_FILL_ENABLE (1 << 2)
2091 # define R600_RD_COMP_DISABLE (0 << 3)
2092 # define R600_RD_COMP_ENABLE (1 << 3)
2093 # define R600_WR_COMP_DISABLE (0 << 4)
2094 # define R600_WR_COMP_ENABLE (1 << 4)
2095 # define R600_ZB_CB_CLEAR_RMW (0 << 5)
2096 # define R600_ZB_CB_CLEAR_CACHE_LINEAR (1 << 5)
2097 # define R600_FORCE_COMPRESSED_STENCIL_VALUE_DISABLE (0 << 6)
2098 # define R600_FORCE_COMPRESSED_STENCIL_VALUE_ENABLE (1 << 6)
2099
2100 /* gap */
2101
2102 /* Z Buffer Address Offset.
2103 * Bits 31 to 5 are used for aligned Z buffer address offset for macro tiles.
2104 */
2105 #define R600_ZB_DEPTHOFFSET 0x4f20
2106
2107 /* Z Buffer Pitch and Endian Control */
2108 #define R600_ZB_DEPTHPITCH 0x4f24
2109 # define R600_DEPTHPITCH_MASK 0x00003FFC
2110 # define R600_DEPTHMACROTILE_DISABLE (0 << 16)
2111 # define R600_DEPTHMACROTILE_ENABLE (1 << 16)
2112 # define R600_DEPTHMICROTILE_LINEAR (0 << 17)
2113 # define R600_DEPTHMICROTILE_TILED (1 << 17)
2114 # define R600_DEPTHMICROTILE_TILED_SQUARE (2 << 17)
2115 # define R600_DEPTHENDIAN_NO_SWAP (0 << 18)
2116 # define R600_DEPTHENDIAN_WORD_SWAP (1 << 18)
2117 # define R600_DEPTHENDIAN_DWORD_SWAP (2 << 18)
2118 # define R600_DEPTHENDIAN_HALF_DWORD_SWAP (3 << 18)
2119
2120 /* Z Buffer Clear Value */
2121 #define R600_ZB_DEPTHCLEARVALUE 0x4f28
2122
2123 /* Hierarchical Z Memory Offset */
2124 #define R600_ZB_HIZ_OFFSET 0x4f44
2125
2126 /* Hierarchical Z Write Index */
2127 #define R600_ZB_HIZ_WRINDEX 0x4f48
2128
2129 /* Hierarchical Z Data */
2130 #define R600_ZB_HIZ_DWORD 0x4f4c
2131
2132 /* Hierarchical Z Read Index */
2133 #define R600_ZB_HIZ_RDINDEX 0x4f50
2134
2135 /* Hierarchical Z Pitch */
2136 #define R600_ZB_HIZ_PITCH 0x4f54
2137
2138 /* Z Buffer Z Pass Counter Data */
2139 #define R600_ZB_ZPASS_DATA 0x4f58
2140
2141 /* Z Buffer Z Pass Counter Address */
2142 #define R600_ZB_ZPASS_ADDR 0x4f5c
2143
2144 /* Depth buffer X and Y coordinate offset */
2145 #define R600_ZB_DEPTHXY_OFFSET 0x4f60
2146 # define R600_DEPTHX_OFFSET_SHIFT 1
2147 # define R600_DEPTHX_OFFSET_MASK 0x000007FE
2148 # define R600_DEPTHY_OFFSET_SHIFT 17
2149 # define R600_DEPTHY_OFFSET_MASK 0x07FE0000
2150
2151 /**
2152 * \defgroup R3XX_R5XX_PROGRAMMABLE_VERTEX_SHADER_DESCRIPTION R3XX-R5XX PROGRAMMABLE VERTEX SHADER DESCRIPTION
2153 *
2154 * The PVS_DST_MATH_INST is used to identify whether the instruction is a Vector
2155 * Engine instruction or a Math Engine instruction.
2156 */
2157
2158 /*\{*/
2159
2160 enum {
2161 /* R3XX */
2162 VECTOR_NO_OP = 0,
2163 VE_DOT_PRODUCT = 1,
2164 VE_MULTIPLY = 2,
2165 VE_ADD = 3,
2166 VE_MULTIPLY_ADD = 4,
2167 VE_DISTANCE_VECTOR = 5,
2168 VE_FRACTION = 6,
2169 VE_MAXIMUM = 7,
2170 VE_MINIMUM = 8,
2171 VE_SET_GREATER_THAN_EQUAL = 9,
2172 VE_SET_LESS_THAN = 10,
2173 VE_MULTIPLYX2_ADD = 11,
2174 VE_MULTIPLY_CLAMP = 12,
2175 VE_FLT2FIX_DX = 13,
2176 VE_FLT2FIX_DX_RND = 14,
2177 /* R5XX */
2178 VE_PRED_SET_EQ_PUSH = 15,
2179 VE_PRED_SET_GT_PUSH = 16,
2180 VE_PRED_SET_GTE_PUSH = 17,
2181 VE_PRED_SET_NEQ_PUSH = 18,
2182 VE_COND_WRITE_EQ = 19,
2183 VE_COND_WRITE_GT = 20,
2184 VE_COND_WRITE_GTE = 21,
2185 VE_COND_WRITE_NEQ = 22,
2186 VE_COND_MUX_EQ = 23,
2187 VE_COND_MUX_GT = 24,
2188 VE_COND_MUX_GTE = 25,
2189 VE_SET_GREATER_THAN = 26,
2190 VE_SET_EQUAL = 27,
2191 VE_SET_NOT_EQUAL = 28,
2192 };
2193
2194 enum {
2195 /* R3XX */
2196 MATH_NO_OP = 0,
2197 ME_EXP_BASE2_DX = 1,
2198 ME_LOG_BASE2_DX = 2,
2199 ME_EXP_BASEE_FF = 3,
2200 ME_LIGHT_COEFF_DX = 4,
2201 ME_POWER_FUNC_FF = 5,
2202 ME_RECIP_DX = 6,
2203 ME_RECIP_FF = 7,
2204 ME_RECIP_SQRT_DX = 8,
2205 ME_RECIP_SQRT_FF = 9,
2206 ME_MULTIPLY = 10,
2207 ME_EXP_BASE2_FULL_DX = 11,
2208 ME_LOG_BASE2_FULL_DX = 12,
2209 ME_POWER_FUNC_FF_CLAMP_B = 13,
2210 ME_POWER_FUNC_FF_CLAMP_B1 = 14,
2211 ME_POWER_FUNC_FF_CLAMP_01 = 15,
2212 ME_SIN = 16,
2213 ME_COS = 17,
2214 /* R5XX */
2215 ME_LOG_BASE2_IEEE = 18,
2216 ME_RECIP_IEEE = 19,
2217 ME_RECIP_SQRT_IEEE = 20,
2218 ME_PRED_SET_EQ = 21,
2219 ME_PRED_SET_GT = 22,
2220 ME_PRED_SET_GTE = 23,
2221 ME_PRED_SET_NEQ = 24,
2222 ME_PRED_SET_CLR = 25,
2223 ME_PRED_SET_INV = 26,
2224 ME_PRED_SET_POP = 27,
2225 ME_PRED_SET_RESTORE = 28,
2226 };
2227
2228 enum {
2229 /* R3XX */
2230 PVS_MACRO_OP_2CLK_MADD = 0,
2231 PVS_MACRO_OP_2CLK_M2X_ADD = 1,
2232 };
2233
2234 enum {
2235 PVS_SRC_REG_TEMPORARY = 0, /* Intermediate Storage */
2236 PVS_SRC_REG_INPUT = 1, /* Input Vertex Storage */
2237 PVS_SRC_REG_CONSTANT = 2, /* Constant State Storage */
2238 PVS_SRC_REG_ALT_TEMPORARY = 3, /* Alternate Intermediate Storage */
2239 };
2240
2241 enum {
2242 PVS_DST_REG_TEMPORARY = 0, /* Intermediate Storage */
2243 PVS_DST_REG_A0 = 1, /* Address Register Storage */
2244 PVS_DST_REG_OUT = 2, /* Output Memory. Used for all outputs */
2245 PVS_DST_REG_OUT_REPL_X = 3, /* Output Memory & Replicate X to all channels */
2246 PVS_DST_REG_ALT_TEMPORARY = 4, /* Alternate Intermediate Storage */
2247 PVS_DST_REG_INPUT = 5, /* Output Memory & Replicate X to all channels */
2248 };
2249
2250 enum {
2251 PVS_SRC_SELECT_X = 0, /* Select X Component */
2252 PVS_SRC_SELECT_Y = 1, /* Select Y Component */
2253 PVS_SRC_SELECT_Z = 2, /* Select Z Component */
2254 PVS_SRC_SELECT_W = 3, /* Select W Component */
2255 PVS_SRC_SELECT_FORCE_0 = 4, /* Force Component to 0.0 */
2256 PVS_SRC_SELECT_FORCE_1 = 5, /* Force Component to 1.0 */
2257 };
2258
2259 /* PVS Opcode & Destination Operand Description */
2260
2261 enum {
2262 PVS_DST_OPCODE_MASK = 0x3f,
2263 PVS_DST_OPCODE_SHIFT = 0,
2264 PVS_DST_MATH_INST_MASK = 0x1,
2265 PVS_DST_MATH_INST_SHIFT = 6,
2266 PVS_DST_MACRO_INST_MASK = 0x1,
2267 PVS_DST_MACRO_INST_SHIFT = 7,
2268 PVS_DST_REG_TYPE_MASK = 0xf,
2269 PVS_DST_REG_TYPE_SHIFT = 8,
2270 PVS_DST_ADDR_MODE_1_MASK = 0x1,
2271 PVS_DST_ADDR_MODE_1_SHIFT = 12,
2272 PVS_DST_OFFSET_MASK = 0x7f,
2273 PVS_DST_OFFSET_SHIFT = 13,
2274 PVS_DST_WE_X_MASK = 0x1,
2275 PVS_DST_WE_X_SHIFT = 20,
2276 PVS_DST_WE_Y_MASK = 0x1,
2277 PVS_DST_WE_Y_SHIFT = 21,
2278 PVS_DST_WE_Z_MASK = 0x1,
2279 PVS_DST_WE_Z_SHIFT = 22,
2280 PVS_DST_WE_W_MASK = 0x1,
2281 PVS_DST_WE_W_SHIFT = 23,
2282 PVS_DST_VE_SAT_MASK = 0x1,
2283 PVS_DST_VE_SAT_SHIFT = 24,
2284 PVS_DST_ME_SAT_MASK = 0x1,
2285 PVS_DST_ME_SAT_SHIFT = 25,
2286 PVS_DST_PRED_ENABLE_MASK = 0x1,
2287 PVS_DST_PRED_ENABLE_SHIFT = 26,
2288 PVS_DST_PRED_SENSE_MASK = 0x1,
2289 PVS_DST_PRED_SENSE_SHIFT = 27,
2290 PVS_DST_DUAL_MATH_OP_MASK = 0x3,
2291 PVS_DST_DUAL_MATH_OP_SHIFT = 27,
2292 PVS_DST_ADDR_SEL_MASK = 0x3,
2293 PVS_DST_ADDR_SEL_SHIFT = 29,
2294 PVS_DST_ADDR_MODE_0_MASK = 0x1,
2295 PVS_DST_ADDR_MODE_0_SHIFT = 31,
2296 };
2297
2298 /* PVS Source Operand Description */
2299
2300 enum {
2301 PVS_SRC_REG_TYPE_MASK = 0x3,
2302 PVS_SRC_REG_TYPE_SHIFT = 0,
2303 SPARE_0_MASK = 0x1,
2304 SPARE_0_SHIFT = 2,
2305 PVS_SRC_ABS_XYZW_MASK = 0x1,
2306 PVS_SRC_ABS_XYZW_SHIFT = 3,
2307 PVS_SRC_ADDR_MODE_0_MASK = 0x1,
2308 PVS_SRC_ADDR_MODE_0_SHIFT = 4,
2309 PVS_SRC_OFFSET_MASK = 0xff,
2310 PVS_SRC_OFFSET_SHIFT = 5,
2311 PVS_SRC_SWIZZLE_X_MASK = 0x7,
2312 PVS_SRC_SWIZZLE_X_SHIFT = 13,
2313 PVS_SRC_SWIZZLE_Y_MASK = 0x7,
2314 PVS_SRC_SWIZZLE_Y_SHIFT = 16,
2315 PVS_SRC_SWIZZLE_Z_MASK = 0x7,
2316 PVS_SRC_SWIZZLE_Z_SHIFT = 19,
2317 PVS_SRC_SWIZZLE_W_MASK = 0x7,
2318 PVS_SRC_SWIZZLE_W_SHIFT = 22,
2319 PVS_SRC_MODIFIER_X_MASK = 0x1,
2320 PVS_SRC_MODIFIER_X_SHIFT = 25,
2321 PVS_SRC_MODIFIER_Y_MASK = 0x1,
2322 PVS_SRC_MODIFIER_Y_SHIFT = 26,
2323 PVS_SRC_MODIFIER_Z_MASK = 0x1,
2324 PVS_SRC_MODIFIER_Z_SHIFT = 27,
2325 PVS_SRC_MODIFIER_W_MASK = 0x1,
2326 PVS_SRC_MODIFIER_W_SHIFT = 28,
2327 PVS_SRC_ADDR_SEL_MASK = 0x3,
2328 PVS_SRC_ADDR_SEL_SHIFT = 29,
2329 PVS_SRC_ADDR_MODE_1_MASK = 0x0,
2330 PVS_SRC_ADDR_MODE_1_SHIFT = 32,
2331 };
2332
2333 /*\}*/
2334
2335 /* BEGIN: Packet 3 commands */
2336
2337 /* A primitive emission dword. */
2338 #define R600_PRIM_TYPE_NONE (0 << 0)
2339 #define R600_PRIM_TYPE_POINT (1 << 0)
2340 #define R600_PRIM_TYPE_LINE (2 << 0)
2341 #define R600_PRIM_TYPE_LINE_STRIP (3 << 0)
2342 #define R600_PRIM_TYPE_TRI_LIST (4 << 0)
2343 #define R600_PRIM_TYPE_TRI_FAN (5 << 0)
2344 #define R600_PRIM_TYPE_TRI_STRIP (6 << 0)
2345 #define R600_PRIM_TYPE_TRI_TYPE2 (7 << 0)
2346 #define R600_PRIM_TYPE_RECT_LIST (8 << 0)
2347 #define R600_PRIM_TYPE_3VRT_POINT_LIST (9 << 0)
2348 #define R600_PRIM_TYPE_3VRT_LINE_LIST (10 << 0)
2349 /* GUESS (based on r200) */
2350 #define R600_PRIM_TYPE_POINT_SPRITES (11 << 0)
2351 #define R600_PRIM_TYPE_LINE_LOOP (12 << 0)
2352 #define R600_PRIM_TYPE_QUADS (13 << 0)
2353 #define R600_PRIM_TYPE_QUAD_STRIP (14 << 0)
2354 #define R600_PRIM_TYPE_POLYGON (15 << 0)
2355 #define R600_PRIM_TYPE_MASK 0xF
2356 #define R600_PRIM_WALK_IND (1 << 4)
2357 #define R600_PRIM_WALK_LIST (2 << 4)
2358 #define R600_PRIM_WALK_RING (3 << 4)
2359 #define R600_PRIM_WALK_MASK (3 << 4)
2360 /* GUESS (based on r200) */
2361 #define R600_PRIM_COLOR_ORDER_BGRA (0 << 6)
2362 #define R600_PRIM_COLOR_ORDER_RGBA (1 << 6)
2363 #define R600_PRIM_NUM_VERTICES_SHIFT 16
2364 #define R600_PRIM_NUM_VERTICES_MASK 0xffff
2365
2366 #define R600_US_W_FMT 0x46b4
2367 # define R600_W_FMT_W0 (0 << 0)
2368 # define R600_W_FMT_W24 (1 << 0)
2369 # define R600_W_FMT_W24FP (2 << 0)
2370 # define R600_W_SRC_US (0 << 2)
2371 # define R600_W_SRC_RAS (1 << 2)
2372
2373
2374 /* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR.
2375 * Two parameter dwords:
2376 * 0. VAP_VTX_FMT: The first parameter is not written to hardware
2377 * 1. VAP_VF_CTL: The second parameter is a standard primitive emission dword.
2378 */
2379 #define R600_PACKET3_3D_DRAW_VBUF 0x00002800
2380
2381 /* Draw a primitive from immediate vertices in this packet
2382 * Up to 16382 dwords:
2383 * 0. VAP_VTX_FMT: The first parameter is not written to hardware
2384 * 1. VAP_VF_CTL: The second parameter is a standard primitive emission dword.
2385 * 2 to end: Up to 16380 dwords of vertex data.
2386 */
2387 #define R600_PACKET3_3D_DRAW_IMMD 0x00002900
2388
2389 /* Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR and
2390 * immediate vertices in this packet
2391 * Up to 16382 dwords:
2392 * 0. VAP_VTX_FMT: The first parameter is not written to hardware
2393 * 1. VAP_VF_CTL: The second parameter is a standard primitive emission dword.
2394 * 2 to end: Up to 16380 dwords of vertex data.
2395 */
2396 #define R600_PACKET3_3D_DRAW_INDX 0x00002A00
2397
2398
2399 /* Specify the full set of vertex arrays as (address, stride).
2400 * The first parameter is the number of vertex arrays specified.
2401 * The rest of the command is a variable length list of blocks, where
2402 * each block is three dwords long and specifies two arrays.
2403 * The first dword of a block is split into two words, the lower significant
2404 * word refers to the first array, the more significant word to the second
2405 * array in the block.
2406 * The low byte of each word contains the size of an array entry in dwords,
2407 * the high byte contains the stride of the array.
2408 * The second dword of a block contains the pointer to the first array,
2409 * the third dword of a block contains the pointer to the second array.
2410 * Note that if the total number of arrays is odd, the third dword of
2411 * the last block is omitted.
2412 */
2413 #define R600_PACKET3_3D_LOAD_VBPNTR 0x00002F00
2414
2415 #define R600_PACKET3_INDX_BUFFER 0x00003300
2416 # define R600_INDX_BUFFER_DST_SHIFT 0
2417 # define R600_INDX_BUFFER_SKIP_SHIFT 16
2418 # define R600_INDX_BUFFER_ONE_REG_WR (1<<31)
2419
2420 /* Same as R600_PACKET3_3D_DRAW_VBUF but without VAP_VTX_FMT */
2421 #define R600_PACKET3_3D_DRAW_VBUF_2 0x00003400
2422 /* Same as R600_PACKET3_3D_DRAW_IMMD but without VAP_VTX_FMT */
2423 #define R600_PACKET3_3D_DRAW_IMMD_2 0x00003500
2424 /* Same as R600_PACKET3_3D_DRAW_INDX but without VAP_VTX_FMT */
2425 #define R600_PACKET3_3D_DRAW_INDX_2 0x00003600
2426
2427 /* Clears a portion of hierachical Z RAM
2428 * 3 dword parameters
2429 * 0. START
2430 * 1. COUNT: 13:0 (max is 0x3FFF)
2431 * 2. CLEAR_VALUE: Value to write into HIZ RAM.
2432 */
2433 #define R600_PACKET3_3D_CLEAR_HIZ 0x00003700
2434
2435 /* Draws a set of primitives using vertex buffers pointed by the state data.
2436 * At least 2 Parameters:
2437 * 0. VAP_VF_CNTL: The first parameter is a standard primitive emission dword.
2438 * 2 to end: Data or indices (see other 3D_DRAW_* packets for details)
2439 */
2440 #define R600_PACKET3_3D_DRAW_128 0x00003900
2441
2442 /* END: Packet 3 commands */
2443
2444
2445 /* Color formats for 2d packets
2446 */
2447 #define R600_CP_COLOR_FORMAT_CI8 2
2448 #define R600_CP_COLOR_FORMAT_ARGB1555 3
2449 #define R600_CP_COLOR_FORMAT_RGB565 4
2450 #define R600_CP_COLOR_FORMAT_ARGB8888 6
2451 #define R600_CP_COLOR_FORMAT_RGB332 7
2452 #define R600_CP_COLOR_FORMAT_RGB8 9
2453 #define R600_CP_COLOR_FORMAT_ARGB4444 15
2454
2455 /*
2456 * CP type-3 packets
2457 */
2458 #define R600_CP_CMD_BITBLT_MULTI 0xC0009B00
2459
2460 #endif /* _R600_REG_H */
2461
2462 /* *INDENT-ON* */
2463
2464 /* vim: set foldenable foldmarker=\\{,\\} foldmethod=marker : */