1172af040ad087e74dfd4490551a8494ffa315d3
[mesa.git] / src / gallium / drivers / radeon / r600d_common.h
1 /*
2 * Copyright 2013 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Authors: Marek Olšák <maraeo@gmail.com>
24 */
25
26 #ifndef R600D_COMMON_H
27 #define R600D_COMMON_H
28
29 #define R600_CONFIG_REG_OFFSET 0x08000
30 #define R600_CONTEXT_REG_OFFSET 0x28000
31 #define CIK_UCONFIG_REG_OFFSET 0x00030000
32 #define CIK_UCONFIG_REG_END 0x00031000
33
34 #define PKT_TYPE_S(x) (((x) & 0x3) << 30)
35 #define PKT_COUNT_S(x) (((x) & 0x3FFF) << 16)
36 #define PKT3_IT_OPCODE_S(x) (((x) & 0xFF) << 8)
37 #define PKT3_PREDICATE(x) (((x) >> 0) & 0x1)
38 #define PKT3(op, count, predicate) (PKT_TYPE_S(3) | PKT_COUNT_S(count) | PKT3_IT_OPCODE_S(op) | PKT3_PREDICATE(predicate))
39
40 #define RADEON_CP_PACKET3_COMPUTE_MODE 0x00000002
41
42 #define PKT3_NOP 0x10
43 #define PKT3_SET_PREDICATION 0x20
44 #define PKT3_STRMOUT_BUFFER_UPDATE 0x34
45 #define STRMOUT_STORE_BUFFER_FILLED_SIZE 1
46 #define STRMOUT_OFFSET_SOURCE(x) (((x) & 0x3) << 1)
47 #define STRMOUT_OFFSET_FROM_PACKET 0
48 #define STRMOUT_OFFSET_FROM_VGT_FILLED_SIZE 1
49 #define STRMOUT_OFFSET_FROM_MEM 2
50 #define STRMOUT_OFFSET_NONE 3
51 #define STRMOUT_SELECT_BUFFER(x) (((x) & 0x3) << 8)
52 #define PKT3_WAIT_REG_MEM 0x3C
53 #define WAIT_REG_MEM_EQUAL 3
54 #define PKT3_EVENT_WRITE 0x46
55 #define PKT3_EVENT_WRITE_EOP 0x47
56 #define PKT3_SET_CONFIG_REG 0x68
57 #define PKT3_SET_CONTEXT_REG 0x69
58 #define PKT3_STRMOUT_BASE_UPDATE 0x72 /* r700 only */
59 #define PKT3_SURFACE_BASE_UPDATE 0x73 /* r600 only */
60 #define SURFACE_BASE_UPDATE_DEPTH (1 << 0)
61 #define SURFACE_BASE_UPDATE_COLOR(x) (2 << (x))
62 #define SURFACE_BASE_UPDATE_COLOR_NUM(x) (((1 << x) - 1) << 1)
63 #define SURFACE_BASE_UPDATE_STRMOUT(x) (0x200 << (x))
64 #define PKT3_SET_UCONFIG_REG 0x79 /* new for CIK */
65
66 #define EVENT_TYPE_PS_PARTIAL_FLUSH 0x10
67 #define EVENT_TYPE_CACHE_FLUSH_AND_INV_TS_EVENT 0x14
68 #define EVENT_TYPE_ZPASS_DONE 0x15
69 #define EVENT_TYPE_CACHE_FLUSH_AND_INV_EVENT 0x16
70 #define EVENT_TYPE_PIPELINESTAT_START 25
71 #define EVENT_TYPE_PIPELINESTAT_STOP 26
72 #define EVENT_TYPE_SAMPLE_PIPELINESTAT 30
73 #define EVENT_TYPE_SO_VGTSTREAMOUT_FLUSH 0x1f
74 #define EVENT_TYPE_SAMPLE_STREAMOUTSTATS 0x20
75 #define EVENT_TYPE_FLUSH_AND_INV_DB_META 0x2c /* supported on r700+ */
76 #define EVENT_TYPE_FLUSH_AND_INV_CB_META 46 /* supported on r700+ */
77 #define EVENT_TYPE(x) ((x) << 0)
78 #define EVENT_INDEX(x) ((x) << 8)
79 /* 0 - any non-TS event
80 * 1 - ZPASS_DONE
81 * 2 - SAMPLE_PIPELINESTAT
82 * 3 - SAMPLE_STREAMOUTSTAT*
83 * 4 - *S_PARTIAL_FLUSH
84 * 5 - TS events
85 */
86
87 #define PREDICATION_OP_CLEAR 0x0
88 #define PREDICATION_OP_ZPASS 0x1
89 #define PREDICATION_OP_PRIMCOUNT 0x2
90 #define PRED_OP(x) ((x) << 16)
91 #define PREDICATION_CONTINUE (1 << 31)
92 #define PREDICATION_HINT_WAIT (0 << 12)
93 #define PREDICATION_HINT_NOWAIT_DRAW (1 << 12)
94 #define PREDICATION_DRAW_NOT_VISIBLE (0 << 8)
95 #define PREDICATION_DRAW_VISIBLE (1 << 8)
96
97 /* R600-R700*/
98 #define R_008490_CP_STRMOUT_CNTL 0x008490
99 #define S_008490_OFFSET_UPDATE_DONE(x) (((x) & 0x1) << 0)
100 #define R_028AB0_VGT_STRMOUT_EN 0x028AB0
101 #define S_028AB0_STREAMOUT(x) (((x) & 0x1) << 0)
102 #define G_028AB0_STREAMOUT(x) (((x) >> 0) & 0x1)
103 #define C_028AB0_STREAMOUT 0xFFFFFFFE
104 #define R_028B20_VGT_STRMOUT_BUFFER_EN 0x028B20
105 #define S_028B20_BUFFER_0_EN(x) (((x) & 0x1) << 0)
106 #define G_028B20_BUFFER_0_EN(x) (((x) >> 0) & 0x1)
107 #define C_028B20_BUFFER_0_EN 0xFFFFFFFE
108 #define S_028B20_BUFFER_1_EN(x) (((x) & 0x1) << 1)
109 #define G_028B20_BUFFER_1_EN(x) (((x) >> 1) & 0x1)
110 #define C_028B20_BUFFER_1_EN 0xFFFFFFFD
111 #define S_028B20_BUFFER_2_EN(x) (((x) & 0x1) << 2)
112 #define G_028B20_BUFFER_2_EN(x) (((x) >> 2) & 0x1)
113 #define C_028B20_BUFFER_2_EN 0xFFFFFFFB
114 #define S_028B20_BUFFER_3_EN(x) (((x) & 0x1) << 3)
115 #define G_028B20_BUFFER_3_EN(x) (((x) >> 3) & 0x1)
116 #define C_028B20_BUFFER_3_EN 0xFFFFFFF7
117 #define R_028AD0_VGT_STRMOUT_BUFFER_SIZE_0 0x028AD0
118
119 #define V_0280A0_SWAP_STD 0x00000000
120 #define V_0280A0_SWAP_ALT 0x00000001
121 #define V_0280A0_SWAP_STD_REV 0x00000002
122 #define V_0280A0_SWAP_ALT_REV 0x00000003
123
124 /* EG+ */
125 #define R_0084FC_CP_STRMOUT_CNTL 0x0084FC
126 #define S_0084FC_OFFSET_UPDATE_DONE(x) (((x) & 0x1) << 0)
127 #define R_028B94_VGT_STRMOUT_CONFIG 0x028B94
128 #define S_028B94_STREAMOUT_0_EN(x) (((x) & 0x1) << 0)
129 #define G_028B94_STREAMOUT_0_EN(x) (((x) >> 0) & 0x1)
130 #define C_028B94_STREAMOUT_0_EN 0xFFFFFFFE
131 #define S_028B94_STREAMOUT_1_EN(x) (((x) & 0x1) << 1)
132 #define G_028B94_STREAMOUT_1_EN(x) (((x) >> 1) & 0x1)
133 #define C_028B94_STREAMOUT_1_EN 0xFFFFFFFD
134 #define S_028B94_STREAMOUT_2_EN(x) (((x) & 0x1) << 2)
135 #define G_028B94_STREAMOUT_2_EN(x) (((x) >> 2) & 0x1)
136 #define C_028B94_STREAMOUT_2_EN 0xFFFFFFFB
137 #define S_028B94_STREAMOUT_3_EN(x) (((x) & 0x1) << 3)
138 #define G_028B94_STREAMOUT_3_EN(x) (((x) >> 3) & 0x1)
139 #define C_028B94_STREAMOUT_3_EN 0xFFFFFFF7
140 #define S_028B94_RAST_STREAM(x) (((x) & 0x07) << 4)
141 #define G_028B94_RAST_STREAM(x) (((x) >> 4) & 0x07)
142 #define C_028B94_RAST_STREAM 0xFFFFFF8F
143 #define S_028B94_RAST_STREAM_MASK(x) (((x) & 0x0F) << 8) /* SI+ */
144 #define G_028B94_RAST_STREAM_MASK(x) (((x) >> 8) & 0x0F)
145 #define C_028B94_RAST_STREAM_MASK 0xFFFFF0FF
146 #define S_028B94_USE_RAST_STREAM_MASK(x) (((x) & 0x1) << 31) /* SI+ */
147 #define G_028B94_USE_RAST_STREAM_MASK(x) (((x) >> 31) & 0x1)
148 #define C_028B94_USE_RAST_STREAM_MASK 0x7FFFFFFF
149 #define R_028B98_VGT_STRMOUT_BUFFER_CONFIG 0x028B98
150 #define S_028B98_STREAM_0_BUFFER_EN(x) (((x) & 0x0F) << 0)
151 #define G_028B98_STREAM_0_BUFFER_EN(x) (((x) >> 0) & 0x0F)
152 #define C_028B98_STREAM_0_BUFFER_EN 0xFFFFFFF0
153 #define S_028B98_STREAM_1_BUFFER_EN(x) (((x) & 0x0F) << 4)
154 #define G_028B98_STREAM_1_BUFFER_EN(x) (((x) >> 4) & 0x0F)
155 #define C_028B98_STREAM_1_BUFFER_EN 0xFFFFFF0F
156 #define S_028B98_STREAM_2_BUFFER_EN(x) (((x) & 0x0F) << 8)
157 #define G_028B98_STREAM_2_BUFFER_EN(x) (((x) >> 8) & 0x0F)
158 #define C_028B98_STREAM_2_BUFFER_EN 0xFFFFF0FF
159 #define S_028B98_STREAM_3_BUFFER_EN(x) (((x) & 0x0F) << 12)
160 #define G_028B98_STREAM_3_BUFFER_EN(x) (((x) >> 12) & 0x0F)
161 #define C_028B98_STREAM_3_BUFFER_EN 0xFFFF0FFF
162
163 #define CM_R_028804_DB_EQAA 0x00028804
164 #define S_028804_MAX_ANCHOR_SAMPLES(x) (((x) & 0x7) << 0)
165 #define S_028804_PS_ITER_SAMPLES(x) (((x) & 0x7) << 4)
166 #define S_028804_MASK_EXPORT_NUM_SAMPLES(x) (((x) & 0x7) << 8)
167 #define S_028804_ALPHA_TO_MASK_NUM_SAMPLES(x) (((x) & 0x7) << 12)
168 #define S_028804_HIGH_QUALITY_INTERSECTIONS(x) (((x) & 0x1) << 16)
169 #define S_028804_INCOHERENT_EQAA_READS(x) (((x) & 0x1) << 17)
170 #define S_028804_INTERPOLATE_COMP_Z(x) (((x) & 0x1) << 18)
171 #define S_028804_INTERPOLATE_SRC_Z(x) (((x) & 0x1) << 19)
172 #define S_028804_STATIC_ANCHOR_ASSOCIATIONS(x) (((x) & 0x1) << 20)
173 #define S_028804_ALPHA_TO_MASK_EQAA_DISABLE(x) (((x) & 0x1) << 21)
174 #define CM_R_028BDC_PA_SC_LINE_CNTL 0x28bdc
175 #define S_028BDC_EXPAND_LINE_WIDTH(x) (((x) & 0x1) << 9)
176 #define G_028BDC_EXPAND_LINE_WIDTH(x) (((x) >> 9) & 0x1)
177 #define C_028BDC_EXPAND_LINE_WIDTH 0xFFFFFDFF
178 #define S_028BDC_LAST_PIXEL(x) (((x) & 0x1) << 10)
179 #define G_028BDC_LAST_PIXEL(x) (((x) >> 10) & 0x1)
180 #define C_028BDC_LAST_PIXEL 0xFFFFFBFF
181 #define CM_R_028BE0_PA_SC_AA_CONFIG 0x28be0
182 #define S_028BE0_MSAA_NUM_SAMPLES(x) (((x) & 0x7) << 0)
183 #define S_028BE0_AA_MASK_CENTROID_DTMN(x) (((x) & 0x1) << 4)
184 #define S_028BE0_MAX_SAMPLE_DIST(x) (((x) & 0xf) << 13)
185 #define S_028BE0_MSAA_EXPOSED_SAMPLES(x) (((x) & 0x7) << 20)
186 #define S_028BE0_DETAIL_TO_EXPOSED_MODE(x) (((x) & 0x3) << 24)
187 #define CM_R_028BF8_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0 0x28bf8
188 #define CM_R_028C08_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_0 0x28c08
189 #define CM_R_028C18_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_0 0x28c18
190 #define CM_R_028C28_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_0 0x28c28
191
192 #define EG_S_028C70_FAST_CLEAR(x) (((x) & 0x1) << 17)
193 #define SI_S_028C70_FAST_CLEAR(x) (((x) & 0x1) << 13)
194
195 /*CIK+*/
196 #define R_0300FC_CP_STRMOUT_CNTL 0x0300FC
197
198 #endif