• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
3  Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4  develop this 3D driver.
5 
6  Permission is hereby granted, free of charge, to any person obtaining
7  a copy of this software and associated documentation files (the
8  "Software"), to deal in the Software without restriction, including
9  without limitation the rights to use, copy, modify, merge, publish,
10  distribute, sublicense, and/or sell copies of the Software, and to
11  permit persons to whom the Software is furnished to do so, subject to
12  the following conditions:
13 
14  The above copyright notice and this permission notice (including the
15  next paragraph) shall be included in all copies or substantial
16  portions of the Software.
17 
18  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 
26  **********************************************************************/
27  /*
28   * Authors:
29   *   Keith Whitwell <keith@tungstengraphics.com>
30   */
31 
32 #define INTEL_MASK(high, low) (((1<<((high)-(low)+1))-1)<<(low))
33 #define SET_FIELD(value, field) (((value) << field ## _SHIFT) & field ## _MASK)
34 #define GET_FIELD(word, field) (((word)  & field ## _MASK) >> field ## _SHIFT)
35 
36 #ifndef BRW_DEFINES_H
37 #define BRW_DEFINES_H
38 
39 /* 3D state:
40  */
41 #define PIPE_CONTROL_NOWRITE          0x00
42 #define PIPE_CONTROL_WRITEIMMEDIATE   0x01
43 #define PIPE_CONTROL_WRITEDEPTH       0x02
44 #define PIPE_CONTROL_WRITETIMESTAMP   0x03
45 
46 #define PIPE_CONTROL_GTTWRITE_PROCESS_LOCAL 0x00
47 #define PIPE_CONTROL_GTTWRITE_GLOBAL        0x01
48 
49 #define CMD_3D_PRIM                                 0x7b00 /* 3DPRIMITIVE */
50 /* DW0 */
51 # define GEN4_3DPRIM_TOPOLOGY_TYPE_SHIFT            10
52 # define GEN4_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 15)
53 # define GEN4_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     (1 << 15)
54 /* DW1 */
55 # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 8)
56 # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     (1 << 8)
57 
58 #define _3DPRIM_POINTLIST         0x01
59 #define _3DPRIM_LINELIST          0x02
60 #define _3DPRIM_LINESTRIP         0x03
61 #define _3DPRIM_TRILIST           0x04
62 #define _3DPRIM_TRISTRIP          0x05
63 #define _3DPRIM_TRIFAN            0x06
64 #define _3DPRIM_QUADLIST          0x07
65 #define _3DPRIM_QUADSTRIP         0x08
66 #define _3DPRIM_LINELIST_ADJ      0x09
67 #define _3DPRIM_LINESTRIP_ADJ     0x0A
68 #define _3DPRIM_TRILIST_ADJ       0x0B
69 #define _3DPRIM_TRISTRIP_ADJ      0x0C
70 #define _3DPRIM_TRISTRIP_REVERSE  0x0D
71 #define _3DPRIM_POLYGON           0x0E
72 #define _3DPRIM_RECTLIST          0x0F
73 #define _3DPRIM_LINELOOP          0x10
74 #define _3DPRIM_POINTLIST_BF      0x11
75 #define _3DPRIM_LINESTRIP_CONT    0x12
76 #define _3DPRIM_LINESTRIP_BF      0x13
77 #define _3DPRIM_LINESTRIP_CONT_BF 0x14
78 #define _3DPRIM_TRIFAN_NOSTIPPLE  0x15
79 
80 #define BRW_ANISORATIO_2     0
81 #define BRW_ANISORATIO_4     1
82 #define BRW_ANISORATIO_6     2
83 #define BRW_ANISORATIO_8     3
84 #define BRW_ANISORATIO_10    4
85 #define BRW_ANISORATIO_12    5
86 #define BRW_ANISORATIO_14    6
87 #define BRW_ANISORATIO_16    7
88 
89 #define BRW_BLENDFACTOR_ONE                 0x1
90 #define BRW_BLENDFACTOR_SRC_COLOR           0x2
91 #define BRW_BLENDFACTOR_SRC_ALPHA           0x3
92 #define BRW_BLENDFACTOR_DST_ALPHA           0x4
93 #define BRW_BLENDFACTOR_DST_COLOR           0x5
94 #define BRW_BLENDFACTOR_SRC_ALPHA_SATURATE  0x6
95 #define BRW_BLENDFACTOR_CONST_COLOR         0x7
96 #define BRW_BLENDFACTOR_CONST_ALPHA         0x8
97 #define BRW_BLENDFACTOR_SRC1_COLOR          0x9
98 #define BRW_BLENDFACTOR_SRC1_ALPHA          0x0A
99 #define BRW_BLENDFACTOR_ZERO                0x11
100 #define BRW_BLENDFACTOR_INV_SRC_COLOR       0x12
101 #define BRW_BLENDFACTOR_INV_SRC_ALPHA       0x13
102 #define BRW_BLENDFACTOR_INV_DST_ALPHA       0x14
103 #define BRW_BLENDFACTOR_INV_DST_COLOR       0x15
104 #define BRW_BLENDFACTOR_INV_CONST_COLOR     0x17
105 #define BRW_BLENDFACTOR_INV_CONST_ALPHA     0x18
106 #define BRW_BLENDFACTOR_INV_SRC1_COLOR      0x19
107 #define BRW_BLENDFACTOR_INV_SRC1_ALPHA      0x1A
108 
109 #define BRW_BLENDFUNCTION_ADD               0
110 #define BRW_BLENDFUNCTION_SUBTRACT          1
111 #define BRW_BLENDFUNCTION_REVERSE_SUBTRACT  2
112 #define BRW_BLENDFUNCTION_MIN               3
113 #define BRW_BLENDFUNCTION_MAX               4
114 
115 #define BRW_ALPHATEST_FORMAT_UNORM8         0
116 #define BRW_ALPHATEST_FORMAT_FLOAT32        1
117 
118 #define BRW_CHROMAKEY_KILL_ON_ANY_MATCH  0
119 #define BRW_CHROMAKEY_REPLACE_BLACK      1
120 
121 #define BRW_CLIP_API_OGL     0
122 #define BRW_CLIP_API_DX      1
123 
124 #define BRW_CLIPMODE_NORMAL              0
125 #define BRW_CLIPMODE_CLIP_ALL            1
126 #define BRW_CLIPMODE_CLIP_NON_REJECTED   2
127 #define BRW_CLIPMODE_REJECT_ALL          3
128 #define BRW_CLIPMODE_ACCEPT_ALL          4
129 #define BRW_CLIPMODE_KERNEL_CLIP         5
130 
131 #define BRW_CLIP_NDCSPACE     0
132 #define BRW_CLIP_SCREENSPACE  1
133 
134 #define BRW_COMPAREFUNCTION_ALWAYS       0
135 #define BRW_COMPAREFUNCTION_NEVER        1
136 #define BRW_COMPAREFUNCTION_LESS         2
137 #define BRW_COMPAREFUNCTION_EQUAL        3
138 #define BRW_COMPAREFUNCTION_LEQUAL       4
139 #define BRW_COMPAREFUNCTION_GREATER      5
140 #define BRW_COMPAREFUNCTION_NOTEQUAL     6
141 #define BRW_COMPAREFUNCTION_GEQUAL       7
142 
143 #define BRW_COVERAGE_PIXELS_HALF     0
144 #define BRW_COVERAGE_PIXELS_1        1
145 #define BRW_COVERAGE_PIXELS_2        2
146 #define BRW_COVERAGE_PIXELS_4        3
147 
148 #define BRW_CULLMODE_BOTH        0
149 #define BRW_CULLMODE_NONE        1
150 #define BRW_CULLMODE_FRONT       2
151 #define BRW_CULLMODE_BACK        3
152 
153 #define BRW_DEFAULTCOLOR_R8G8B8A8_UNORM      0
154 #define BRW_DEFAULTCOLOR_R32G32B32A32_FLOAT  1
155 
156 #define BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT     0
157 #define BRW_DEPTHFORMAT_D32_FLOAT                1
158 #define BRW_DEPTHFORMAT_D24_UNORM_S8_UINT        2
159 #define BRW_DEPTHFORMAT_D24_UNORM_X8_UINT        3 /* GEN5 */
160 #define BRW_DEPTHFORMAT_D16_UNORM                5
161 
162 #define BRW_FLOATING_POINT_IEEE_754        0
163 #define BRW_FLOATING_POINT_NON_IEEE_754    1
164 
165 #define BRW_FRONTWINDING_CW      0
166 #define BRW_FRONTWINDING_CCW     1
167 
168 #define BRW_SPRITE_POINT_ENABLE  16
169 
170 #define BRW_CUT_INDEX_ENABLE     (1 << 10)
171 
172 #define BRW_INDEX_BYTE     0
173 #define BRW_INDEX_WORD     1
174 #define BRW_INDEX_DWORD    2
175 
176 #define BRW_LOGICOPFUNCTION_CLEAR            0
177 #define BRW_LOGICOPFUNCTION_NOR              1
178 #define BRW_LOGICOPFUNCTION_AND_INVERTED     2
179 #define BRW_LOGICOPFUNCTION_COPY_INVERTED    3
180 #define BRW_LOGICOPFUNCTION_AND_REVERSE      4
181 #define BRW_LOGICOPFUNCTION_INVERT           5
182 #define BRW_LOGICOPFUNCTION_XOR              6
183 #define BRW_LOGICOPFUNCTION_NAND             7
184 #define BRW_LOGICOPFUNCTION_AND              8
185 #define BRW_LOGICOPFUNCTION_EQUIV            9
186 #define BRW_LOGICOPFUNCTION_NOOP             10
187 #define BRW_LOGICOPFUNCTION_OR_INVERTED      11
188 #define BRW_LOGICOPFUNCTION_COPY             12
189 #define BRW_LOGICOPFUNCTION_OR_REVERSE       13
190 #define BRW_LOGICOPFUNCTION_OR               14
191 #define BRW_LOGICOPFUNCTION_SET              15
192 
193 #define BRW_MAPFILTER_NEAREST        0x0
194 #define BRW_MAPFILTER_LINEAR         0x1
195 #define BRW_MAPFILTER_ANISOTROPIC    0x2
196 
197 #define BRW_MIPFILTER_NONE        0
198 #define BRW_MIPFILTER_NEAREST     1
199 #define BRW_MIPFILTER_LINEAR      3
200 
201 #define BRW_ADDRESS_ROUNDING_ENABLE_U_MAG	0x20
202 #define BRW_ADDRESS_ROUNDING_ENABLE_U_MIN	0x10
203 #define BRW_ADDRESS_ROUNDING_ENABLE_V_MAG	0x08
204 #define BRW_ADDRESS_ROUNDING_ENABLE_V_MIN	0x04
205 #define BRW_ADDRESS_ROUNDING_ENABLE_R_MAG	0x02
206 #define BRW_ADDRESS_ROUNDING_ENABLE_R_MIN	0x01
207 
208 #define BRW_POLYGON_FRONT_FACING     0
209 #define BRW_POLYGON_BACK_FACING      1
210 
211 #define BRW_PREFILTER_ALWAYS     0x0
212 #define BRW_PREFILTER_NEVER      0x1
213 #define BRW_PREFILTER_LESS       0x2
214 #define BRW_PREFILTER_EQUAL      0x3
215 #define BRW_PREFILTER_LEQUAL     0x4
216 #define BRW_PREFILTER_GREATER    0x5
217 #define BRW_PREFILTER_NOTEQUAL   0x6
218 #define BRW_PREFILTER_GEQUAL     0x7
219 
220 #define BRW_PROVOKING_VERTEX_0    0
221 #define BRW_PROVOKING_VERTEX_1    1
222 #define BRW_PROVOKING_VERTEX_2    2
223 
224 #define BRW_RASTRULE_UPPER_LEFT  0
225 #define BRW_RASTRULE_UPPER_RIGHT 1
226 /* These are listed as "Reserved, but not seen as useful"
227  * in Intel documentation (page 212, "Point Rasterization Rule",
228  * section 7.4 "SF Pipeline State Summary", of document
229  * "Intel® 965 Express Chipset Family and Intel® G35 Express
230  * Chipset Graphics Controller Programmer's Reference Manual,
231  * Volume 2: 3D/Media", Revision 1.0b as of January 2008,
232  * available at
233  *     http://intellinuxgraphics.org/documentation.html
234  * at the time of this writing).
235  *
236  * These appear to be supported on at least some
237  * i965-family devices, and the BRW_RASTRULE_LOWER_RIGHT
238  * is useful when using OpenGL to render to a FBO
239  * (which has the pixel coordinate Y orientation inverted
240  * with respect to the normal OpenGL pixel coordinate system).
241  */
242 #define BRW_RASTRULE_LOWER_LEFT  2
243 #define BRW_RASTRULE_LOWER_RIGHT 3
244 
245 #define BRW_RENDERTARGET_CLAMPRANGE_UNORM    0
246 #define BRW_RENDERTARGET_CLAMPRANGE_SNORM    1
247 #define BRW_RENDERTARGET_CLAMPRANGE_FORMAT   2
248 
249 #define BRW_STENCILOP_KEEP               0
250 #define BRW_STENCILOP_ZERO               1
251 #define BRW_STENCILOP_REPLACE            2
252 #define BRW_STENCILOP_INCRSAT            3
253 #define BRW_STENCILOP_DECRSAT            4
254 #define BRW_STENCILOP_INCR               5
255 #define BRW_STENCILOP_DECR               6
256 #define BRW_STENCILOP_INVERT             7
257 
258 /* Surface state DW0 */
259 #define BRW_SURFACE_RC_READ_WRITE	(1 << 8)
260 #define BRW_SURFACE_MIPLAYOUT_SHIFT	10
261 #define BRW_SURFACE_MIPMAPLAYOUT_BELOW   0
262 #define BRW_SURFACE_MIPMAPLAYOUT_RIGHT   1
263 #define BRW_SURFACE_CUBEFACE_ENABLES	0x3f
264 #define BRW_SURFACE_BLEND_ENABLED	(1 << 13)
265 #define BRW_SURFACE_WRITEDISABLE_B_SHIFT	14
266 #define BRW_SURFACE_WRITEDISABLE_G_SHIFT	15
267 #define BRW_SURFACE_WRITEDISABLE_R_SHIFT	16
268 #define BRW_SURFACE_WRITEDISABLE_A_SHIFT	17
269 
270 #define BRW_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
271 #define BRW_SURFACEFORMAT_R32G32B32A32_SINT              0x001
272 #define BRW_SURFACEFORMAT_R32G32B32A32_UINT              0x002
273 #define BRW_SURFACEFORMAT_R32G32B32A32_UNORM             0x003
274 #define BRW_SURFACEFORMAT_R32G32B32A32_SNORM             0x004
275 #define BRW_SURFACEFORMAT_R64G64_FLOAT                   0x005
276 #define BRW_SURFACEFORMAT_R32G32B32X32_FLOAT             0x006
277 #define BRW_SURFACEFORMAT_R32G32B32A32_SSCALED           0x007
278 #define BRW_SURFACEFORMAT_R32G32B32A32_USCALED           0x008
279 #define BRW_SURFACEFORMAT_R32G32B32A32_SFIXED            0x020
280 #define BRW_SURFACEFORMAT_R32G32B32_FLOAT                0x040
281 #define BRW_SURFACEFORMAT_R32G32B32_SINT                 0x041
282 #define BRW_SURFACEFORMAT_R32G32B32_UINT                 0x042
283 #define BRW_SURFACEFORMAT_R32G32B32_UNORM                0x043
284 #define BRW_SURFACEFORMAT_R32G32B32_SNORM                0x044
285 #define BRW_SURFACEFORMAT_R32G32B32_SSCALED              0x045
286 #define BRW_SURFACEFORMAT_R32G32B32_USCALED              0x046
287 #define BRW_SURFACEFORMAT_R32G32B32_SFIXED               0x050
288 #define BRW_SURFACEFORMAT_R16G16B16A16_UNORM             0x080
289 #define BRW_SURFACEFORMAT_R16G16B16A16_SNORM             0x081
290 #define BRW_SURFACEFORMAT_R16G16B16A16_SINT              0x082
291 #define BRW_SURFACEFORMAT_R16G16B16A16_UINT              0x083
292 #define BRW_SURFACEFORMAT_R16G16B16A16_FLOAT             0x084
293 #define BRW_SURFACEFORMAT_R32G32_FLOAT                   0x085
294 #define BRW_SURFACEFORMAT_R32G32_SINT                    0x086
295 #define BRW_SURFACEFORMAT_R32G32_UINT                    0x087
296 #define BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS       0x088
297 #define BRW_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT        0x089
298 #define BRW_SURFACEFORMAT_L32A32_FLOAT                   0x08A
299 #define BRW_SURFACEFORMAT_R32G32_UNORM                   0x08B
300 #define BRW_SURFACEFORMAT_R32G32_SNORM                   0x08C
301 #define BRW_SURFACEFORMAT_R64_FLOAT                      0x08D
302 #define BRW_SURFACEFORMAT_R16G16B16X16_UNORM             0x08E
303 #define BRW_SURFACEFORMAT_R16G16B16X16_FLOAT             0x08F
304 #define BRW_SURFACEFORMAT_A32X32_FLOAT                   0x090
305 #define BRW_SURFACEFORMAT_L32X32_FLOAT                   0x091
306 #define BRW_SURFACEFORMAT_I32X32_FLOAT                   0x092
307 #define BRW_SURFACEFORMAT_R16G16B16A16_SSCALED           0x093
308 #define BRW_SURFACEFORMAT_R16G16B16A16_USCALED           0x094
309 #define BRW_SURFACEFORMAT_R32G32_SSCALED                 0x095
310 #define BRW_SURFACEFORMAT_R32G32_USCALED                 0x096
311 #define BRW_SURFACEFORMAT_R32G32_SFIXED                  0x0A0
312 #define BRW_SURFACEFORMAT_B8G8R8A8_UNORM                 0x0C0
313 #define BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB            0x0C1
314 #define BRW_SURFACEFORMAT_R10G10B10A2_UNORM              0x0C2
315 #define BRW_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB         0x0C3
316 #define BRW_SURFACEFORMAT_R10G10B10A2_UINT               0x0C4
317 #define BRW_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM       0x0C5
318 #define BRW_SURFACEFORMAT_R8G8B8A8_UNORM                 0x0C7
319 #define BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB            0x0C8
320 #define BRW_SURFACEFORMAT_R8G8B8A8_SNORM                 0x0C9
321 #define BRW_SURFACEFORMAT_R8G8B8A8_SINT                  0x0CA
322 #define BRW_SURFACEFORMAT_R8G8B8A8_UINT                  0x0CB
323 #define BRW_SURFACEFORMAT_R16G16_UNORM                   0x0CC
324 #define BRW_SURFACEFORMAT_R16G16_SNORM                   0x0CD
325 #define BRW_SURFACEFORMAT_R16G16_SINT                    0x0CE
326 #define BRW_SURFACEFORMAT_R16G16_UINT                    0x0CF
327 #define BRW_SURFACEFORMAT_R16G16_FLOAT                   0x0D0
328 #define BRW_SURFACEFORMAT_B10G10R10A2_UNORM              0x0D1
329 #define BRW_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB         0x0D2
330 #define BRW_SURFACEFORMAT_R11G11B10_FLOAT                0x0D3
331 #define BRW_SURFACEFORMAT_R32_SINT                       0x0D6
332 #define BRW_SURFACEFORMAT_R32_UINT                       0x0D7
333 #define BRW_SURFACEFORMAT_R32_FLOAT                      0x0D8
334 #define BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS          0x0D9
335 #define BRW_SURFACEFORMAT_X24_TYPELESS_G8_UINT           0x0DA
336 #define BRW_SURFACEFORMAT_L16A16_UNORM                   0x0DF
337 #define BRW_SURFACEFORMAT_I24X8_UNORM                    0x0E0
338 #define BRW_SURFACEFORMAT_L24X8_UNORM                    0x0E1
339 #define BRW_SURFACEFORMAT_A24X8_UNORM                    0x0E2
340 #define BRW_SURFACEFORMAT_I32_FLOAT                      0x0E3
341 #define BRW_SURFACEFORMAT_L32_FLOAT                      0x0E4
342 #define BRW_SURFACEFORMAT_A32_FLOAT                      0x0E5
343 #define BRW_SURFACEFORMAT_B8G8R8X8_UNORM                 0x0E9
344 #define BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB            0x0EA
345 #define BRW_SURFACEFORMAT_R8G8B8X8_UNORM                 0x0EB
346 #define BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB            0x0EC
347 #define BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP             0x0ED
348 #define BRW_SURFACEFORMAT_B10G10R10X2_UNORM              0x0EE
349 #define BRW_SURFACEFORMAT_L16A16_FLOAT                   0x0F0
350 #define BRW_SURFACEFORMAT_R32_UNORM                      0x0F1
351 #define BRW_SURFACEFORMAT_R32_SNORM                      0x0F2
352 #define BRW_SURFACEFORMAT_R10G10B10X2_USCALED            0x0F3
353 #define BRW_SURFACEFORMAT_R8G8B8A8_SSCALED               0x0F4
354 #define BRW_SURFACEFORMAT_R8G8B8A8_USCALED               0x0F5
355 #define BRW_SURFACEFORMAT_R16G16_SSCALED                 0x0F6
356 #define BRW_SURFACEFORMAT_R16G16_USCALED                 0x0F7
357 #define BRW_SURFACEFORMAT_R32_SSCALED                    0x0F8
358 #define BRW_SURFACEFORMAT_R32_USCALED                    0x0F9
359 #define BRW_SURFACEFORMAT_B5G6R5_UNORM                   0x100
360 #define BRW_SURFACEFORMAT_B5G6R5_UNORM_SRGB              0x101
361 #define BRW_SURFACEFORMAT_B5G5R5A1_UNORM                 0x102
362 #define BRW_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB            0x103
363 #define BRW_SURFACEFORMAT_B4G4R4A4_UNORM                 0x104
364 #define BRW_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB            0x105
365 #define BRW_SURFACEFORMAT_R8G8_UNORM                     0x106
366 #define BRW_SURFACEFORMAT_R8G8_SNORM                     0x107
367 #define BRW_SURFACEFORMAT_R8G8_SINT                      0x108
368 #define BRW_SURFACEFORMAT_R8G8_UINT                      0x109
369 #define BRW_SURFACEFORMAT_R16_UNORM                      0x10A
370 #define BRW_SURFACEFORMAT_R16_SNORM                      0x10B
371 #define BRW_SURFACEFORMAT_R16_SINT                       0x10C
372 #define BRW_SURFACEFORMAT_R16_UINT                       0x10D
373 #define BRW_SURFACEFORMAT_R16_FLOAT                      0x10E
374 #define BRW_SURFACEFORMAT_I16_UNORM                      0x111
375 #define BRW_SURFACEFORMAT_L16_UNORM                      0x112
376 #define BRW_SURFACEFORMAT_A16_UNORM                      0x113
377 #define BRW_SURFACEFORMAT_L8A8_UNORM                     0x114
378 #define BRW_SURFACEFORMAT_I16_FLOAT                      0x115
379 #define BRW_SURFACEFORMAT_L16_FLOAT                      0x116
380 #define BRW_SURFACEFORMAT_A16_FLOAT                      0x117
381 #define BRW_SURFACEFORMAT_L8A8_UNORM_SRGB                0x118
382 #define BRW_SURFACEFORMAT_R5G5_SNORM_B6_UNORM            0x119
383 #define BRW_SURFACEFORMAT_B5G5R5X1_UNORM                 0x11A
384 #define BRW_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB            0x11B
385 #define BRW_SURFACEFORMAT_R8G8_SSCALED                   0x11C
386 #define BRW_SURFACEFORMAT_R8G8_USCALED                   0x11D
387 #define BRW_SURFACEFORMAT_R16_SSCALED                    0x11E
388 #define BRW_SURFACEFORMAT_R16_USCALED                    0x11F
389 #define BRW_SURFACEFORMAT_R8_UNORM                       0x140
390 #define BRW_SURFACEFORMAT_R8_SNORM                       0x141
391 #define BRW_SURFACEFORMAT_R8_SINT                        0x142
392 #define BRW_SURFACEFORMAT_R8_UINT                        0x143
393 #define BRW_SURFACEFORMAT_A8_UNORM                       0x144
394 #define BRW_SURFACEFORMAT_I8_UNORM                       0x145
395 #define BRW_SURFACEFORMAT_L8_UNORM                       0x146
396 #define BRW_SURFACEFORMAT_P4A4_UNORM                     0x147
397 #define BRW_SURFACEFORMAT_A4P4_UNORM                     0x148
398 #define BRW_SURFACEFORMAT_R8_SSCALED                     0x149
399 #define BRW_SURFACEFORMAT_R8_USCALED                     0x14A
400 #define BRW_SURFACEFORMAT_L8_UNORM_SRGB                  0x14C
401 #define BRW_SURFACEFORMAT_DXT1_RGB_SRGB                  0x180
402 #define BRW_SURFACEFORMAT_R1_UINT                        0x181
403 #define BRW_SURFACEFORMAT_YCRCB_NORMAL                   0x182
404 #define BRW_SURFACEFORMAT_YCRCB_SWAPUVY                  0x183
405 #define BRW_SURFACEFORMAT_BC1_UNORM                      0x186
406 #define BRW_SURFACEFORMAT_BC2_UNORM                      0x187
407 #define BRW_SURFACEFORMAT_BC3_UNORM                      0x188
408 #define BRW_SURFACEFORMAT_BC4_UNORM                      0x189
409 #define BRW_SURFACEFORMAT_BC5_UNORM                      0x18A
410 #define BRW_SURFACEFORMAT_BC1_UNORM_SRGB                 0x18B
411 #define BRW_SURFACEFORMAT_BC2_UNORM_SRGB                 0x18C
412 #define BRW_SURFACEFORMAT_BC3_UNORM_SRGB                 0x18D
413 #define BRW_SURFACEFORMAT_MONO8                          0x18E
414 #define BRW_SURFACEFORMAT_YCRCB_SWAPUV                   0x18F
415 #define BRW_SURFACEFORMAT_YCRCB_SWAPY                    0x190
416 #define BRW_SURFACEFORMAT_DXT1_RGB                       0x191
417 #define BRW_SURFACEFORMAT_FXT1                           0x192
418 #define BRW_SURFACEFORMAT_R8G8B8_UNORM                   0x193
419 #define BRW_SURFACEFORMAT_R8G8B8_SNORM                   0x194
420 #define BRW_SURFACEFORMAT_R8G8B8_SSCALED                 0x195
421 #define BRW_SURFACEFORMAT_R8G8B8_USCALED                 0x196
422 #define BRW_SURFACEFORMAT_R64G64B64A64_FLOAT             0x197
423 #define BRW_SURFACEFORMAT_R64G64B64_FLOAT                0x198
424 #define BRW_SURFACEFORMAT_BC4_SNORM                      0x199
425 #define BRW_SURFACEFORMAT_BC5_SNORM                      0x19A
426 #define BRW_SURFACEFORMAT_R16G16B16_UNORM                0x19C
427 #define BRW_SURFACEFORMAT_R16G16B16_SNORM                0x19D
428 #define BRW_SURFACEFORMAT_R16G16B16_SSCALED              0x19E
429 #define BRW_SURFACEFORMAT_R16G16B16_USCALED              0x19F
430 #define BRW_SURFACEFORMAT_R32_SFIXED                     0x1B2
431 #define BRW_SURFACEFORMAT_R10G10B10A2_SNORM              0x1B3
432 #define BRW_SURFACEFORMAT_R10G10B10A2_USCALED            0x1B4
433 #define BRW_SURFACEFORMAT_R10G10B10A2_SSCALED            0x1B5
434 #define BRW_SURFACEFORMAT_R10G10B10A2_SINT               0x1B6
435 #define BRW_SURFACEFORMAT_B10G10R10A2_SNORM              0x1B7
436 #define BRW_SURFACEFORMAT_B10G10R10A2_USCALED            0x1B8
437 #define BRW_SURFACEFORMAT_B10G10R10A2_SSCALED            0x1B9
438 #define BRW_SURFACEFORMAT_B10G10R10A2_UINT               0x1BA
439 #define BRW_SURFACEFORMAT_B10G10R10A2_SINT               0x1BB
440 #define BRW_SURFACE_FORMAT_SHIFT	18
441 #define BRW_SURFACE_FORMAT_MASK		INTEL_MASK(26, 18)
442 
443 #define BRW_SURFACERETURNFORMAT_FLOAT32  0
444 #define BRW_SURFACERETURNFORMAT_S1       1
445 
446 #define BRW_SURFACE_TYPE_SHIFT		29
447 #define BRW_SURFACE_TYPE_MASK		INTEL_MASK(31, 29)
448 #define BRW_SURFACE_1D      0
449 #define BRW_SURFACE_2D      1
450 #define BRW_SURFACE_3D      2
451 #define BRW_SURFACE_CUBE    3
452 #define BRW_SURFACE_BUFFER  4
453 #define BRW_SURFACE_NULL    7
454 
455 #define GEN7_SURFACE_IS_ARRAY           (1 << 28)
456 #define GEN7_SURFACE_VALIGN_2           (0 << 16)
457 #define GEN7_SURFACE_VALIGN_4           (1 << 16)
458 #define GEN7_SURFACE_HALIGN_4           (0 << 15)
459 #define GEN7_SURFACE_HALIGN_8           (1 << 15)
460 #define GEN7_SURFACE_TILING_NONE        (0 << 13)
461 #define GEN7_SURFACE_TILING_X           (2 << 13)
462 #define GEN7_SURFACE_TILING_Y           (3 << 13)
463 #define GEN7_SURFACE_ARYSPC_FULL	(0 << 10)
464 #define GEN7_SURFACE_ARYSPC_LOD0	(1 << 10)
465 
466 /* Surface state DW2 */
467 #define BRW_SURFACE_HEIGHT_SHIFT	19
468 #define BRW_SURFACE_HEIGHT_MASK		INTEL_MASK(31, 19)
469 #define BRW_SURFACE_WIDTH_SHIFT		6
470 #define BRW_SURFACE_WIDTH_MASK		INTEL_MASK(18, 6)
471 #define BRW_SURFACE_LOD_SHIFT		2
472 #define BRW_SURFACE_LOD_MASK		INTEL_MASK(5, 2)
473 #define GEN7_SURFACE_HEIGHT_SHIFT       16
474 #define GEN7_SURFACE_HEIGHT_MASK        INTEL_MASK(29, 16)
475 #define GEN7_SURFACE_WIDTH_SHIFT        0
476 #define GEN7_SURFACE_WIDTH_MASK         INTEL_MASK(13, 0)
477 
478 /* Surface state DW3 */
479 #define BRW_SURFACE_DEPTH_SHIFT		21
480 #define BRW_SURFACE_DEPTH_MASK		INTEL_MASK(31, 21)
481 #define BRW_SURFACE_PITCH_SHIFT		3
482 #define BRW_SURFACE_PITCH_MASK		INTEL_MASK(19, 3)
483 #define BRW_SURFACE_TILED		(1 << 1)
484 #define BRW_SURFACE_TILED_Y		(1 << 0)
485 
486 /* Surface state DW4 */
487 #define BRW_SURFACE_MIN_LOD_SHIFT	28
488 #define BRW_SURFACE_MIN_LOD_MASK	INTEL_MASK(31, 28)
489 #define BRW_SURFACE_MULTISAMPLECOUNT_1  (0 << 4)
490 #define BRW_SURFACE_MULTISAMPLECOUNT_4  (2 << 4)
491 #define GEN7_SURFACE_MULTISAMPLECOUNT_1         (0 << 3)
492 #define GEN7_SURFACE_MULTISAMPLECOUNT_4         (2 << 3)
493 #define GEN7_SURFACE_MULTISAMPLECOUNT_8         (3 << 3)
494 #define GEN7_SURFACE_MSFMT_MSS                  (0 << 6)
495 #define GEN7_SURFACE_MSFMT_DEPTH_STENCIL        (1 << 6)
496 
497 /* Surface state DW5 */
498 #define BRW_SURFACE_X_OFFSET_SHIFT		25
499 #define BRW_SURFACE_X_OFFSET_MASK		INTEL_MASK(31, 25)
500 #define BRW_SURFACE_VERTICAL_ALIGN_ENABLE	(1 << 24)
501 #define BRW_SURFACE_Y_OFFSET_SHIFT		20
502 #define BRW_SURFACE_Y_OFFSET_MASK		INTEL_MASK(23, 20)
503 #define GEN7_SURFACE_MIN_LOD_SHIFT              4
504 #define GEN7_SURFACE_MIN_LOD_MASK               INTEL_MASK(7, 4)
505 
506 /* Surface state DW6 */
507 #define GEN7_SURFACE_MCS_ENABLE                 (1 << 0)
508 #define GEN7_SURFACE_MCS_PITCH_SHIFT            3
509 #define GEN7_SURFACE_MCS_PITCH_MASK             INTEL_MASK(11, 3)
510 
511 /* Surface state DW7 */
512 #define GEN7_SURFACE_SCS_R_SHIFT                25
513 #define GEN7_SURFACE_SCS_R_MASK                 INTEL_MASK(27, 25)
514 #define GEN7_SURFACE_SCS_G_SHIFT                22
515 #define GEN7_SURFACE_SCS_G_MASK                 INTEL_MASK(24, 22)
516 #define GEN7_SURFACE_SCS_B_SHIFT                19
517 #define GEN7_SURFACE_SCS_B_MASK                 INTEL_MASK(21, 19)
518 #define GEN7_SURFACE_SCS_A_SHIFT                16
519 #define GEN7_SURFACE_SCS_A_MASK                 INTEL_MASK(18, 16)
520 
521 /* The actual swizzle values/what channel to use */
522 #define HSW_SCS_ZERO                     0
523 #define HSW_SCS_ONE                      1
524 #define HSW_SCS_RED                      4
525 #define HSW_SCS_GREEN                    5
526 #define HSW_SCS_BLUE                     6
527 #define HSW_SCS_ALPHA                    7
528 
529 #define BRW_TEXCOORDMODE_WRAP            0
530 #define BRW_TEXCOORDMODE_MIRROR          1
531 #define BRW_TEXCOORDMODE_CLAMP           2
532 #define BRW_TEXCOORDMODE_CUBE            3
533 #define BRW_TEXCOORDMODE_CLAMP_BORDER    4
534 #define BRW_TEXCOORDMODE_MIRROR_ONCE     5
535 
536 #define BRW_THREAD_PRIORITY_NORMAL   0
537 #define BRW_THREAD_PRIORITY_HIGH     1
538 
539 #define BRW_TILEWALK_XMAJOR                 0
540 #define BRW_TILEWALK_YMAJOR                 1
541 
542 #define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS  0
543 #define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS  1
544 
545 /* Execution Unit (EU) defines
546  */
547 
548 #define BRW_ALIGN_1   0
549 #define BRW_ALIGN_16  1
550 
551 #define BRW_ADDRESS_DIRECT                        0
552 #define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER    1
553 
554 #define BRW_CHANNEL_X     0
555 #define BRW_CHANNEL_Y     1
556 #define BRW_CHANNEL_Z     2
557 #define BRW_CHANNEL_W     3
558 
559 enum brw_compression {
560    BRW_COMPRESSION_NONE       = 0,
561    BRW_COMPRESSION_2NDHALF    = 1,
562    BRW_COMPRESSION_COMPRESSED = 2,
563 };
564 
565 #define GEN6_COMPRESSION_1Q		0
566 #define GEN6_COMPRESSION_2Q		1
567 #define GEN6_COMPRESSION_3Q		2
568 #define GEN6_COMPRESSION_4Q		3
569 #define GEN6_COMPRESSION_1H		0
570 #define GEN6_COMPRESSION_2H		2
571 
572 #define BRW_CONDITIONAL_NONE  0
573 #define BRW_CONDITIONAL_Z     1
574 #define BRW_CONDITIONAL_NZ    2
575 #define BRW_CONDITIONAL_EQ    1	/* Z */
576 #define BRW_CONDITIONAL_NEQ   2	/* NZ */
577 #define BRW_CONDITIONAL_G     3
578 #define BRW_CONDITIONAL_GE    4
579 #define BRW_CONDITIONAL_L     5
580 #define BRW_CONDITIONAL_LE    6
581 #define BRW_CONDITIONAL_R     7
582 #define BRW_CONDITIONAL_O     8
583 #define BRW_CONDITIONAL_U     9
584 
585 #define BRW_DEBUG_NONE        0
586 #define BRW_DEBUG_BREAKPOINT  1
587 
588 #define BRW_DEPENDENCY_NORMAL         0
589 #define BRW_DEPENDENCY_NOTCLEARED     1
590 #define BRW_DEPENDENCY_NOTCHECKED     2
591 #define BRW_DEPENDENCY_DISABLE        3
592 
593 #define BRW_EXECUTE_1     0
594 #define BRW_EXECUTE_2     1
595 #define BRW_EXECUTE_4     2
596 #define BRW_EXECUTE_8     3
597 #define BRW_EXECUTE_16    4
598 #define BRW_EXECUTE_32    5
599 
600 #define BRW_HORIZONTAL_STRIDE_0   0
601 #define BRW_HORIZONTAL_STRIDE_1   1
602 #define BRW_HORIZONTAL_STRIDE_2   2
603 #define BRW_HORIZONTAL_STRIDE_4   3
604 
605 #define BRW_INSTRUCTION_NORMAL    0
606 #define BRW_INSTRUCTION_SATURATE  1
607 
608 #define BRW_MASK_ENABLE   0
609 #define BRW_MASK_DISABLE  1
610 
611 #define BRW_ACCUMULATOR_WRITE_DISABLE 0
612 #define BRW_ACCUMULATOR_WRITE_ENABLE  1
613 
614 /** @{
615  *
616  * Gen6 has replaced "mask enable/disable" with WECtrl, which is
617  * effectively the same but much simpler to think about.  Now, there
618  * are two contributors ANDed together to whether channels are
619  * executed: The predication on the instruction, and the channel write
620  * enable.
621  */
622 /**
623  * This is the default value.  It means that a channel's write enable is set
624  * if the per-channel IP is pointing at this instruction.
625  */
626 #define BRW_WE_NORMAL		0
627 /**
628  * This is used like BRW_MASK_DISABLE, and causes all channels to have
629  * their write enable set.  Note that predication still contributes to
630  * whether the channel actually gets written.
631  */
632 #define BRW_WE_ALL		1
633 /** @} */
634 
635 enum opcode {
636    /* These are the actual hardware opcodes. */
637    BRW_OPCODE_MOV =	1,
638    BRW_OPCODE_SEL =	2,
639    BRW_OPCODE_NOT =	4,
640    BRW_OPCODE_AND =	5,
641    BRW_OPCODE_OR =	6,
642    BRW_OPCODE_XOR =	7,
643    BRW_OPCODE_SHR =	8,
644    BRW_OPCODE_SHL =	9,
645    BRW_OPCODE_RSR =	10,
646    BRW_OPCODE_RSL =	11,
647    BRW_OPCODE_ASR =	12,
648    BRW_OPCODE_CMP =	16,
649    BRW_OPCODE_CMPN =	17,
650    BRW_OPCODE_F32TO16 = 19,
651    BRW_OPCODE_F16TO32 = 20,
652    BRW_OPCODE_BFREV =	23,
653    BRW_OPCODE_BFE =	24,
654    BRW_OPCODE_BFI1 =	25,
655    BRW_OPCODE_BFI2 =	26,
656    BRW_OPCODE_JMPI =	32,
657    BRW_OPCODE_BRD =	33,
658    BRW_OPCODE_IF =	34,
659    BRW_OPCODE_IFF =	35,
660    BRW_OPCODE_BRC =	35,
661    BRW_OPCODE_ELSE =	36,
662    BRW_OPCODE_ENDIF =	37,
663    BRW_OPCODE_DO =	38,
664    BRW_OPCODE_WHILE =	39,
665    BRW_OPCODE_BREAK =	40,
666    BRW_OPCODE_CONTINUE = 41,
667    BRW_OPCODE_HALT =	42,
668    BRW_OPCODE_MSAVE =	44,
669    BRW_OPCODE_CALL =	44,
670    BRW_OPCODE_MRESTORE = 45,
671    BRW_OPCODE_RET =	45,
672    BRW_OPCODE_PUSH =	46,
673    BRW_OPCODE_POP =	47,
674    BRW_OPCODE_WAIT =	48,
675    BRW_OPCODE_SEND =	49,
676    BRW_OPCODE_SENDC =	50,
677    BRW_OPCODE_MATH =	56,
678    BRW_OPCODE_ADD =	64,
679    BRW_OPCODE_MUL =	65,
680    BRW_OPCODE_AVG =	66,
681    BRW_OPCODE_FRC =	67,
682    BRW_OPCODE_RNDU =	68,
683    BRW_OPCODE_RNDD =	69,
684    BRW_OPCODE_RNDE =	70,
685    BRW_OPCODE_RNDZ =	71,
686    BRW_OPCODE_MAC =	72,
687    BRW_OPCODE_MACH =	73,
688    BRW_OPCODE_LZD =	74,
689    BRW_OPCODE_FBH =	75,
690    BRW_OPCODE_FBL =	76,
691    BRW_OPCODE_CBIT =	77,
692    BRW_OPCODE_ADDC =	78,
693    BRW_OPCODE_SUBB =	79,
694    BRW_OPCODE_SAD2 =	80,
695    BRW_OPCODE_SADA2 =	81,
696    BRW_OPCODE_DP4 =	84,
697    BRW_OPCODE_DPH =	85,
698    BRW_OPCODE_DP3 =	86,
699    BRW_OPCODE_DP2 =	87,
700    BRW_OPCODE_DPA2 =	88,
701    BRW_OPCODE_LINE =	89,
702    BRW_OPCODE_PLN =	90,
703    BRW_OPCODE_MAD =	91,
704    BRW_OPCODE_LRP =	92,
705    BRW_OPCODE_NOP =	126,
706 
707    /* These are compiler backend opcodes that get translated into other
708     * instructions.
709     */
710    FS_OPCODE_FB_WRITE = 128,
711    SHADER_OPCODE_RCP,
712    SHADER_OPCODE_RSQ,
713    SHADER_OPCODE_SQRT,
714    SHADER_OPCODE_EXP2,
715    SHADER_OPCODE_LOG2,
716    SHADER_OPCODE_POW,
717    SHADER_OPCODE_INT_QUOTIENT,
718    SHADER_OPCODE_INT_REMAINDER,
719    SHADER_OPCODE_SIN,
720    SHADER_OPCODE_COS,
721 
722    SHADER_OPCODE_TEX,
723    SHADER_OPCODE_TXD,
724    SHADER_OPCODE_TXF,
725    SHADER_OPCODE_TXL,
726    SHADER_OPCODE_TXS,
727    FS_OPCODE_TXB,
728 
729    SHADER_OPCODE_SHADER_TIME_ADD,
730 
731    FS_OPCODE_DDX,
732    FS_OPCODE_DDY,
733    FS_OPCODE_PIXEL_X,
734    FS_OPCODE_PIXEL_Y,
735    FS_OPCODE_CINTERP,
736    FS_OPCODE_LINTERP,
737    FS_OPCODE_SPILL,
738    FS_OPCODE_UNSPILL,
739    FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD,
740    FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7,
741    FS_OPCODE_VARYING_PULL_CONSTANT_LOAD,
742    FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7,
743    FS_OPCODE_MOV_DISPATCH_TO_FLAGS,
744    FS_OPCODE_DISCARD_JUMP,
745    FS_OPCODE_SET_GLOBAL_OFFSET,
746 
747    VS_OPCODE_URB_WRITE,
748    VS_OPCODE_SCRATCH_READ,
749    VS_OPCODE_SCRATCH_WRITE,
750    VS_OPCODE_PULL_CONSTANT_LOAD,
751 };
752 
753 #define BRW_PREDICATE_NONE             0
754 #define BRW_PREDICATE_NORMAL           1
755 #define BRW_PREDICATE_ALIGN1_ANYV             2
756 #define BRW_PREDICATE_ALIGN1_ALLV             3
757 #define BRW_PREDICATE_ALIGN1_ANY2H            4
758 #define BRW_PREDICATE_ALIGN1_ALL2H            5
759 #define BRW_PREDICATE_ALIGN1_ANY4H            6
760 #define BRW_PREDICATE_ALIGN1_ALL4H            7
761 #define BRW_PREDICATE_ALIGN1_ANY8H            8
762 #define BRW_PREDICATE_ALIGN1_ALL8H            9
763 #define BRW_PREDICATE_ALIGN1_ANY16H           10
764 #define BRW_PREDICATE_ALIGN1_ALL16H           11
765 #define BRW_PREDICATE_ALIGN16_REPLICATE_X     2
766 #define BRW_PREDICATE_ALIGN16_REPLICATE_Y     3
767 #define BRW_PREDICATE_ALIGN16_REPLICATE_Z     4
768 #define BRW_PREDICATE_ALIGN16_REPLICATE_W     5
769 #define BRW_PREDICATE_ALIGN16_ANY4H           6
770 #define BRW_PREDICATE_ALIGN16_ALL4H           7
771 
772 #define BRW_ARCHITECTURE_REGISTER_FILE    0
773 #define BRW_GENERAL_REGISTER_FILE         1
774 #define BRW_MESSAGE_REGISTER_FILE         2
775 #define BRW_IMMEDIATE_VALUE               3
776 
777 #define BRW_REGISTER_TYPE_UD  0
778 #define BRW_REGISTER_TYPE_D   1
779 #define BRW_REGISTER_TYPE_UW  2
780 #define BRW_REGISTER_TYPE_W   3
781 #define BRW_REGISTER_TYPE_UB  4
782 #define BRW_REGISTER_TYPE_B   5
783 #define BRW_REGISTER_TYPE_VF  5	/* packed float vector, immediates only? */
784 #define BRW_REGISTER_TYPE_HF  6
785 #define BRW_REGISTER_TYPE_V   6	/* packed int vector, immediates only, uword dest only */
786 #define BRW_REGISTER_TYPE_F   7
787 
788 #define BRW_REGISTER_3SRC_TYPE_F    0
789 #define BRW_REGISTER_3SRC_TYPE_D    1
790 #define BRW_REGISTER_3SRC_TYPE_UD   2
791 #define BRW_REGISTER_3SRC_TYPE_DF   3
792 
793 #define BRW_ARF_NULL                  0x00
794 #define BRW_ARF_ADDRESS               0x10
795 #define BRW_ARF_ACCUMULATOR           0x20
796 #define BRW_ARF_FLAG                  0x30
797 #define BRW_ARF_MASK                  0x40
798 #define BRW_ARF_MASK_STACK            0x50
799 #define BRW_ARF_MASK_STACK_DEPTH      0x60
800 #define BRW_ARF_STATE                 0x70
801 #define BRW_ARF_CONTROL               0x80
802 #define BRW_ARF_NOTIFICATION_COUNT    0x90
803 #define BRW_ARF_IP                    0xA0
804 #define BRW_ARF_TDR                   0xB0
805 #define BRW_ARF_TIMESTAMP             0xC0
806 
807 #define BRW_MRF_COMPR4			(1 << 7)
808 
809 #define BRW_AMASK   0
810 #define BRW_IMASK   1
811 #define BRW_LMASK   2
812 #define BRW_CMASK   3
813 
814 
815 
816 #define BRW_THREAD_NORMAL     0
817 #define BRW_THREAD_ATOMIC     1
818 #define BRW_THREAD_SWITCH     2
819 
820 #define BRW_VERTICAL_STRIDE_0                 0
821 #define BRW_VERTICAL_STRIDE_1                 1
822 #define BRW_VERTICAL_STRIDE_2                 2
823 #define BRW_VERTICAL_STRIDE_4                 3
824 #define BRW_VERTICAL_STRIDE_8                 4
825 #define BRW_VERTICAL_STRIDE_16                5
826 #define BRW_VERTICAL_STRIDE_32                6
827 #define BRW_VERTICAL_STRIDE_64                7
828 #define BRW_VERTICAL_STRIDE_128               8
829 #define BRW_VERTICAL_STRIDE_256               9
830 #define BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL   0xF
831 
832 #define BRW_WIDTH_1       0
833 #define BRW_WIDTH_2       1
834 #define BRW_WIDTH_4       2
835 #define BRW_WIDTH_8       3
836 #define BRW_WIDTH_16      4
837 
838 #define BRW_STATELESS_BUFFER_BOUNDARY_1K      0
839 #define BRW_STATELESS_BUFFER_BOUNDARY_2K      1
840 #define BRW_STATELESS_BUFFER_BOUNDARY_4K      2
841 #define BRW_STATELESS_BUFFER_BOUNDARY_8K      3
842 #define BRW_STATELESS_BUFFER_BOUNDARY_16K     4
843 #define BRW_STATELESS_BUFFER_BOUNDARY_32K     5
844 #define BRW_STATELESS_BUFFER_BOUNDARY_64K     6
845 #define BRW_STATELESS_BUFFER_BOUNDARY_128K    7
846 #define BRW_STATELESS_BUFFER_BOUNDARY_256K    8
847 #define BRW_STATELESS_BUFFER_BOUNDARY_512K    9
848 #define BRW_STATELESS_BUFFER_BOUNDARY_1M      10
849 #define BRW_STATELESS_BUFFER_BOUNDARY_2M      11
850 
851 #define BRW_POLYGON_FACING_FRONT      0
852 #define BRW_POLYGON_FACING_BACK       1
853 
854 /**
855  * Message target: Shared Function ID for where to SEND a message.
856  *
857  * These are enumerated in the ISA reference under "send - Send Message".
858  * In particular, see the following tables:
859  * - G45 PRM, Volume 4, Table 14-15 "Message Descriptor Definition"
860  * - Sandybridge PRM, Volume 4 Part 2, Table 8-16 "Extended Message Descriptor"
861  * - BSpec, Volume 1a (GPU Overview) / Graphics Processing Engine (GPE) /
862  *   Overview / GPE Function IDs
863  */
864 enum brw_message_target {
865    BRW_SFID_NULL                     = 0,
866    BRW_SFID_MATH                     = 1, /* Only valid on Gen4-5 */
867    BRW_SFID_SAMPLER                  = 2,
868    BRW_SFID_MESSAGE_GATEWAY          = 3,
869    BRW_SFID_DATAPORT_READ            = 4,
870    BRW_SFID_DATAPORT_WRITE           = 5,
871    BRW_SFID_URB                      = 6,
872    BRW_SFID_THREAD_SPAWNER           = 7,
873 
874    GEN6_SFID_DATAPORT_SAMPLER_CACHE  = 4,
875    GEN6_SFID_DATAPORT_RENDER_CACHE   = 5,
876    GEN6_SFID_VME                     = 8,
877    GEN6_SFID_DATAPORT_CONSTANT_CACHE = 9,
878 
879    GEN7_SFID_DATAPORT_DATA_CACHE     = 10,
880 
881    HSW_SFID_DATAPORT_DATA_CACHE1     = 0x0c,
882    HSW_SFID_CRE                      = 0x0d,
883 
884    /* There is no Sampler data port cache(0x04) on SKL and it is used
885     * as the extension of DP_DC0/DP_DC1.
886     */
887    SKL_SFID_DATAPORT_DATA_CACHE2     = 0x4,
888    /* Data Read only Data port cache */
889    SKL_SFID_DATAPORT_DCR0            = 0x9,
890 };
891 
892 #define BRW_SAMPLER_RETURN_FORMAT_FLOAT32     0
893 #define BRW_SAMPLER_RETURN_FORMAT_UINT32      2
894 #define BRW_SAMPLER_RETURN_FORMAT_SINT32      3
895 
896 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE              0
897 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE             0
898 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS        0
899 #define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX             1
900 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD        1
901 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD         1
902 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS  2
903 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS    2
904 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE    0
905 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE     2
906 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE 0
907 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD_COMPARE 1
908 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE  1
909 #define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO           2
910 #define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO            2
911 #define BRW_SAMPLER_MESSAGE_SIMD4X2_LD                3
912 #define BRW_SAMPLER_MESSAGE_SIMD8_LD                  3
913 #define BRW_SAMPLER_MESSAGE_SIMD16_LD                 3
914 
915 #define GEN5_SAMPLER_MESSAGE_SAMPLE              0
916 #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS         1
917 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD          2
918 #define GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE      3
919 #define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS       4
920 #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
921 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE  6
922 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LD           7
923 #define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO      10
924 #define HSW_SAMPLER_MESSAGE_SAMPLE_DERIV_COMPARE 20
925 #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD_MCS       29
926 #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DMS       30
927 #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DSS       31
928 
929 /* for GEN5 only */
930 #define BRW_SAMPLER_SIMD_MODE_SIMD4X2                   0
931 #define BRW_SAMPLER_SIMD_MODE_SIMD8                     1
932 #define BRW_SAMPLER_SIMD_MODE_SIMD16                    2
933 #define BRW_SAMPLER_SIMD_MODE_SIMD32_64                 3
934 
935 #define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW   0
936 #define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH  1
937 #define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS     2
938 #define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS     3
939 #define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS     4
940 
941 #define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD     0
942 #define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS    2
943 
944 #define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS   2
945 #define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS  3
946 
947 /* This one stays the same across generations. */
948 #define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ          0
949 /* GEN4 */
950 #define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     1
951 #define BRW_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ          2
952 #define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      3
953 /* G45, GEN5 */
954 #define G45_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ	    1
955 #define G45_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     2
956 #define G45_DATAPORT_READ_MESSAGE_AVC_LOOP_FILTER_READ	    3
957 #define G45_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ          4
958 #define G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      6
959 /* GEN6 */
960 #define GEN6_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ	    1
961 #define GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     2
962 #define GEN6_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ          4
963 #define GEN6_DATAPORT_READ_MESSAGE_OWORD_UNALIGN_BLOCK_READ  5
964 #define GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      6
965 
966 #define BRW_DATAPORT_READ_TARGET_DATA_CACHE      0
967 #define BRW_DATAPORT_READ_TARGET_RENDER_CACHE    1
968 #define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE   2
969 
970 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE                0
971 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED     1
972 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01         2
973 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23         3
974 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01       4
975 
976 #define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE                0
977 #define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE           1
978 #define BRW_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE                2
979 #define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE            3
980 #define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE              4
981 #define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE     5
982 #define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE               7
983 
984 /* GEN6 */
985 #define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_ATOMIC_WRITE              7
986 #define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE               8
987 #define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE          9
988 #define GEN6_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE               10
989 #define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE           11
990 #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE             12
991 #define GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VB_WRITE               13
992 #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_UNORM_WRITE       14
993 
994 /* GEN7 */
995 #define GEN7_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE          10
996 #define GEN7_DATAPORT_DC_DWORD_SCATTERED_READ                       3
997 
998 /* dataport atomic operations. */
999 #define BRW_AOP_AND                   1
1000 #define BRW_AOP_OR                    2
1001 #define BRW_AOP_XOR                   3
1002 #define BRW_AOP_MOV                   4
1003 #define BRW_AOP_INC                   5
1004 #define BRW_AOP_DEC                   6
1005 #define BRW_AOP_ADD                   7
1006 #define BRW_AOP_SUB                   8
1007 #define BRW_AOP_REVSUB                9
1008 #define BRW_AOP_IMAX                  10
1009 #define BRW_AOP_IMIN                  11
1010 #define BRW_AOP_UMAX                  12
1011 #define BRW_AOP_UMIN                  13
1012 #define BRW_AOP_CMPWR                 14
1013 #define BRW_AOP_PREDEC                15
1014 
1015 #define BRW_MATH_FUNCTION_INV                              1
1016 #define BRW_MATH_FUNCTION_LOG                              2
1017 #define BRW_MATH_FUNCTION_EXP                              3
1018 #define BRW_MATH_FUNCTION_SQRT                             4
1019 #define BRW_MATH_FUNCTION_RSQ                              5
1020 #define BRW_MATH_FUNCTION_SIN                              6 /* was 7 */
1021 #define BRW_MATH_FUNCTION_COS                              7 /* was 8 */
1022 #define BRW_MATH_FUNCTION_SINCOS                           8 /* was 6 */
1023 #define BRW_MATH_FUNCTION_TAN                              9 /* gen4 */
1024 #define BRW_MATH_FUNCTION_FDIV                             9 /* gen6+ */
1025 #define BRW_MATH_FUNCTION_POW                              10
1026 #define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER   11
1027 #define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT                 12
1028 #define BRW_MATH_FUNCTION_INT_DIV_REMAINDER                13
1029 
1030 #define BRW_MATH_INTEGER_UNSIGNED     0
1031 #define BRW_MATH_INTEGER_SIGNED       1
1032 
1033 #define BRW_MATH_PRECISION_FULL        0
1034 #define BRW_MATH_PRECISION_PARTIAL     1
1035 
1036 #define BRW_MATH_SATURATE_NONE         0
1037 #define BRW_MATH_SATURATE_SATURATE     1
1038 
1039 #define BRW_MATH_DATA_VECTOR  0
1040 #define BRW_MATH_DATA_SCALAR  1
1041 
1042 #define BRW_URB_OPCODE_WRITE  0
1043 
1044 #define BRW_URB_SWIZZLE_NONE          0
1045 #define BRW_URB_SWIZZLE_INTERLEAVE    1
1046 #define BRW_URB_SWIZZLE_TRANSPOSE     2
1047 
1048 #define BRW_SCRATCH_SPACE_SIZE_1K     0
1049 #define BRW_SCRATCH_SPACE_SIZE_2K     1
1050 #define BRW_SCRATCH_SPACE_SIZE_4K     2
1051 #define BRW_SCRATCH_SPACE_SIZE_8K     3
1052 #define BRW_SCRATCH_SPACE_SIZE_16K    4
1053 #define BRW_SCRATCH_SPACE_SIZE_32K    5
1054 #define BRW_SCRATCH_SPACE_SIZE_64K    6
1055 #define BRW_SCRATCH_SPACE_SIZE_128K   7
1056 #define BRW_SCRATCH_SPACE_SIZE_256K   8
1057 #define BRW_SCRATCH_SPACE_SIZE_512K   9
1058 #define BRW_SCRATCH_SPACE_SIZE_1M     10
1059 #define BRW_SCRATCH_SPACE_SIZE_2M     11
1060 
1061 
1062 #define CMD_URB_FENCE                 0x6000
1063 #define CMD_CS_URB_STATE              0x6001
1064 #define CMD_CONST_BUFFER              0x6002
1065 
1066 #define CMD_STATE_BASE_ADDRESS        0x6101
1067 #define CMD_STATE_SIP                 0x6102
1068 #define CMD_PIPELINE_SELECT_965       0x6104
1069 #define CMD_PIPELINE_SELECT_GM45      0x6904
1070 
1071 #define _3DSTATE_PIPELINED_POINTERS		0x7800
1072 #define _3DSTATE_BINDING_TABLE_POINTERS		0x7801
1073 # define GEN6_BINDING_TABLE_MODIFY_VS	(1 << 8)
1074 # define GEN6_BINDING_TABLE_MODIFY_GS	(1 << 9)
1075 # define GEN6_BINDING_TABLE_MODIFY_PS	(1 << 12)
1076 
1077 #define _3DSTATE_BINDING_TABLE_POINTERS_VS	0x7826 /* GEN7+ */
1078 #define _3DSTATE_BINDING_TABLE_POINTERS_HS	0x7827 /* GEN7+ */
1079 #define _3DSTATE_BINDING_TABLE_POINTERS_DS	0x7828 /* GEN7+ */
1080 #define _3DSTATE_BINDING_TABLE_POINTERS_GS	0x7829 /* GEN7+ */
1081 #define _3DSTATE_BINDING_TABLE_POINTERS_PS	0x782A /* GEN7+ */
1082 
1083 #define _3DSTATE_SAMPLER_STATE_POINTERS		0x7802 /* GEN6+ */
1084 # define PS_SAMPLER_STATE_CHANGE				(1 << 12)
1085 # define GS_SAMPLER_STATE_CHANGE				(1 << 9)
1086 # define VS_SAMPLER_STATE_CHANGE				(1 << 8)
1087 /* DW1: VS */
1088 /* DW2: GS */
1089 /* DW3: PS */
1090 
1091 #define _3DSTATE_SAMPLER_STATE_POINTERS_VS	0x782B /* GEN7+ */
1092 #define _3DSTATE_SAMPLER_STATE_POINTERS_GS	0x782E /* GEN7+ */
1093 #define _3DSTATE_SAMPLER_STATE_POINTERS_PS	0x782F /* GEN7+ */
1094 
1095 #define _3DSTATE_VERTEX_BUFFERS       0x7808
1096 # define BRW_VB0_INDEX_SHIFT		27
1097 # define GEN6_VB0_INDEX_SHIFT		26
1098 # define BRW_VB0_ACCESS_VERTEXDATA	(0 << 26)
1099 # define BRW_VB0_ACCESS_INSTANCEDATA	(1 << 26)
1100 # define GEN6_VB0_ACCESS_VERTEXDATA	(0 << 20)
1101 # define GEN6_VB0_ACCESS_INSTANCEDATA	(1 << 20)
1102 # define GEN7_VB0_ADDRESS_MODIFYENABLE  (1 << 14)
1103 # define BRW_VB0_PITCH_SHIFT		0
1104 
1105 #define _3DSTATE_VERTEX_ELEMENTS      0x7809
1106 # define BRW_VE0_INDEX_SHIFT		27
1107 # define GEN6_VE0_INDEX_SHIFT		26
1108 # define BRW_VE0_FORMAT_SHIFT		16
1109 # define BRW_VE0_VALID			(1 << 26)
1110 # define GEN6_VE0_VALID			(1 << 25)
1111 # define GEN6_VE0_EDGE_FLAG_ENABLE	(1 << 15)
1112 # define BRW_VE0_SRC_OFFSET_SHIFT	0
1113 # define BRW_VE1_COMPONENT_NOSTORE	0
1114 # define BRW_VE1_COMPONENT_STORE_SRC	1
1115 # define BRW_VE1_COMPONENT_STORE_0	2
1116 # define BRW_VE1_COMPONENT_STORE_1_FLT	3
1117 # define BRW_VE1_COMPONENT_STORE_1_INT	4
1118 # define BRW_VE1_COMPONENT_STORE_VID	5
1119 # define BRW_VE1_COMPONENT_STORE_IID	6
1120 # define BRW_VE1_COMPONENT_STORE_PID	7
1121 # define BRW_VE1_COMPONENT_0_SHIFT	28
1122 # define BRW_VE1_COMPONENT_1_SHIFT	24
1123 # define BRW_VE1_COMPONENT_2_SHIFT	20
1124 # define BRW_VE1_COMPONENT_3_SHIFT	16
1125 # define BRW_VE1_DST_OFFSET_SHIFT	0
1126 
1127 #define CMD_INDEX_BUFFER              0x780a
1128 #define GEN4_3DSTATE_VF_STATISTICS		0x780b
1129 #define GM45_3DSTATE_VF_STATISTICS		0x680b
1130 #define _3DSTATE_CC_STATE_POINTERS		0x780e /* GEN6+ */
1131 #define _3DSTATE_BLEND_STATE_POINTERS		0x7824 /* GEN7+ */
1132 #define _3DSTATE_DEPTH_STENCIL_STATE_POINTERS	0x7825 /* GEN7+ */
1133 
1134 #define _3DSTATE_URB				0x7805 /* GEN6 */
1135 # define GEN6_URB_VS_SIZE_SHIFT				16
1136 # define GEN6_URB_VS_ENTRIES_SHIFT			0
1137 # define GEN6_URB_GS_ENTRIES_SHIFT			8
1138 # define GEN6_URB_GS_SIZE_SHIFT				0
1139 
1140 #define _3DSTATE_VF                             0x780c /* GEN7.5+ */
1141 #define HSW_CUT_INDEX_ENABLE                            (1 << 8)
1142 
1143 #define _3DSTATE_URB_VS                         0x7830 /* GEN7+ */
1144 #define _3DSTATE_URB_HS                         0x7831 /* GEN7+ */
1145 #define _3DSTATE_URB_DS                         0x7832 /* GEN7+ */
1146 #define _3DSTATE_URB_GS                         0x7833 /* GEN7+ */
1147 # define GEN7_URB_ENTRY_SIZE_SHIFT                      16
1148 # define GEN7_URB_STARTING_ADDRESS_SHIFT                25
1149 
1150 #define _3DSTATE_PUSH_CONSTANT_ALLOC_VS         0x7912 /* GEN7+ */
1151 #define _3DSTATE_PUSH_CONSTANT_ALLOC_PS         0x7916 /* GEN7+ */
1152 # define GEN7_PUSH_CONSTANT_BUFFER_OFFSET_SHIFT         16
1153 
1154 #define _3DSTATE_VIEWPORT_STATE_POINTERS	0x780d /* GEN6+ */
1155 # define GEN6_CC_VIEWPORT_MODIFY			(1 << 12)
1156 # define GEN6_SF_VIEWPORT_MODIFY			(1 << 11)
1157 # define GEN6_CLIP_VIEWPORT_MODIFY			(1 << 10)
1158 
1159 #define _3DSTATE_VIEWPORT_STATE_POINTERS_CC	0x7823 /* GEN7+ */
1160 #define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL	0x7821 /* GEN7+ */
1161 
1162 #define _3DSTATE_SCISSOR_STATE_POINTERS		0x780f /* GEN6+ */
1163 
1164 #define _3DSTATE_VS				0x7810 /* GEN6+ */
1165 /* DW2 */
1166 # define GEN6_VS_SPF_MODE				(1 << 31)
1167 # define GEN6_VS_VECTOR_MASK_ENABLE			(1 << 30)
1168 # define GEN6_VS_SAMPLER_COUNT_SHIFT			27
1169 # define GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
1170 # define GEN6_VS_FLOATING_POINT_MODE_IEEE_754		(0 << 16)
1171 # define GEN6_VS_FLOATING_POINT_MODE_ALT		(1 << 16)
1172 /* DW4 */
1173 # define GEN6_VS_DISPATCH_START_GRF_SHIFT		20
1174 # define GEN6_VS_URB_READ_LENGTH_SHIFT			11
1175 # define GEN6_VS_URB_ENTRY_READ_OFFSET_SHIFT		4
1176 /* DW5 */
1177 # define GEN6_VS_MAX_THREADS_SHIFT			25
1178 # define HSW_VS_MAX_THREADS_SHIFT			23
1179 # define GEN6_VS_STATISTICS_ENABLE			(1 << 10)
1180 # define GEN6_VS_CACHE_DISABLE				(1 << 1)
1181 # define GEN6_VS_ENABLE					(1 << 0)
1182 
1183 #define _3DSTATE_GS		      		0x7811 /* GEN6+ */
1184 /* DW2 */
1185 # define GEN6_GS_SPF_MODE				(1 << 31)
1186 # define GEN6_GS_VECTOR_MASK_ENABLE			(1 << 30)
1187 # define GEN6_GS_SAMPLER_COUNT_SHIFT			27
1188 # define GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
1189 # define GEN6_GS_FLOATING_POINT_MODE_IEEE_754		(0 << 16)
1190 # define GEN6_GS_FLOATING_POINT_MODE_ALT		(1 << 16)
1191 /* DW4 */
1192 # define GEN6_GS_URB_READ_LENGTH_SHIFT			11
1193 # define GEN7_GS_INCLUDE_VERTEX_HANDLES		        (1 << 10)
1194 # define GEN6_GS_URB_ENTRY_READ_OFFSET_SHIFT		4
1195 # define GEN6_GS_DISPATCH_START_GRF_SHIFT		0
1196 /* DW5 */
1197 # define GEN6_GS_MAX_THREADS_SHIFT			25
1198 # define GEN6_GS_STATISTICS_ENABLE			(1 << 10)
1199 # define GEN6_GS_SO_STATISTICS_ENABLE			(1 << 9)
1200 # define GEN6_GS_RENDERING_ENABLE			(1 << 8)
1201 # define GEN7_GS_ENABLE					(1 << 0)
1202 /* DW6 */
1203 # define GEN6_GS_REORDER				(1 << 30)
1204 # define GEN6_GS_DISCARD_ADJACENCY			(1 << 29)
1205 # define GEN6_GS_SVBI_PAYLOAD_ENABLE			(1 << 28)
1206 # define GEN6_GS_SVBI_POSTINCREMENT_ENABLE		(1 << 27)
1207 # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_SHIFT		16
1208 # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_MASK		INTEL_MASK(25, 16)
1209 # define GEN6_GS_ENABLE					(1 << 15)
1210 
1211 # define BRW_GS_EDGE_INDICATOR_0			(1 << 8)
1212 # define BRW_GS_EDGE_INDICATOR_1			(1 << 9)
1213 
1214 #define _3DSTATE_HS                             0x781B /* GEN7+ */
1215 #define _3DSTATE_TE                             0x781C /* GEN7+ */
1216 #define _3DSTATE_DS                             0x781D /* GEN7+ */
1217 
1218 #define _3DSTATE_CLIP				0x7812 /* GEN6+ */
1219 /* DW1 */
1220 # define GEN7_CLIP_WINDING_CW                           (0 << 20)
1221 # define GEN7_CLIP_WINDING_CCW                          (1 << 20)
1222 # define GEN7_CLIP_VERTEX_SUBPIXEL_PRECISION_8          (0 << 19)
1223 # define GEN7_CLIP_VERTEX_SUBPIXEL_PRECISION_4          (1 << 19)
1224 # define GEN7_CLIP_EARLY_CULL                           (1 << 18)
1225 # define GEN7_CLIP_CULLMODE_BOTH                        (0 << 16)
1226 # define GEN7_CLIP_CULLMODE_NONE                        (1 << 16)
1227 # define GEN7_CLIP_CULLMODE_FRONT                       (2 << 16)
1228 # define GEN7_CLIP_CULLMODE_BACK                        (3 << 16)
1229 # define GEN6_CLIP_STATISTICS_ENABLE			(1 << 10)
1230 /**
1231  * Just does cheap culling based on the clip distance.  Bits must be
1232  * disjoint with USER_CLIP_CLIP_DISTANCE bits.
1233  */
1234 # define GEN6_USER_CLIP_CULL_DISTANCES_SHIFT		0
1235 /* DW2 */
1236 # define GEN6_CLIP_ENABLE				(1 << 31)
1237 # define GEN6_CLIP_API_OGL				(0 << 30)
1238 # define GEN6_CLIP_API_D3D				(1 << 30)
1239 # define GEN6_CLIP_XY_TEST				(1 << 28)
1240 # define GEN6_CLIP_Z_TEST				(1 << 27)
1241 # define GEN6_CLIP_GB_TEST				(1 << 26)
1242 /** 8-bit field of which user clip distances to clip aganist. */
1243 # define GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT		16
1244 # define GEN6_CLIP_MODE_NORMAL				(0 << 13)
1245 # define GEN6_CLIP_MODE_REJECT_ALL			(3 << 13)
1246 # define GEN6_CLIP_MODE_ACCEPT_ALL			(4 << 13)
1247 # define GEN6_CLIP_PERSPECTIVE_DIVIDE_DISABLE		(1 << 9)
1248 # define GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE	(1 << 8)
1249 # define GEN6_CLIP_TRI_PROVOKE_SHIFT			4
1250 # define GEN6_CLIP_LINE_PROVOKE_SHIFT			2
1251 # define GEN6_CLIP_TRIFAN_PROVOKE_SHIFT			0
1252 /* DW3 */
1253 # define GEN6_CLIP_MIN_POINT_WIDTH_SHIFT		17
1254 # define GEN6_CLIP_MAX_POINT_WIDTH_SHIFT		6
1255 # define GEN6_CLIP_FORCE_ZERO_RTAINDEX			(1 << 5)
1256 
1257 #define _3DSTATE_SF				0x7813 /* GEN6+ */
1258 /* DW1 (for gen6) */
1259 # define GEN6_SF_NUM_OUTPUTS_SHIFT			22
1260 # define GEN6_SF_SWIZZLE_ENABLE				(1 << 21)
1261 # define GEN6_SF_POINT_SPRITE_UPPERLEFT			(0 << 20)
1262 # define GEN6_SF_POINT_SPRITE_LOWERLEFT			(1 << 20)
1263 # define GEN6_SF_URB_ENTRY_READ_LENGTH_SHIFT		11
1264 # define GEN6_SF_URB_ENTRY_READ_OFFSET_SHIFT		4
1265 /* DW2 */
1266 # define GEN6_SF_LEGACY_GLOBAL_DEPTH_BIAS		(1 << 11)
1267 # define GEN6_SF_STATISTICS_ENABLE			(1 << 10)
1268 # define GEN6_SF_GLOBAL_DEPTH_OFFSET_SOLID		(1 << 9)
1269 # define GEN6_SF_GLOBAL_DEPTH_OFFSET_WIREFRAME		(1 << 8)
1270 # define GEN6_SF_GLOBAL_DEPTH_OFFSET_POINT		(1 << 7)
1271 # define GEN6_SF_FRONT_SOLID				(0 << 5)
1272 # define GEN6_SF_FRONT_WIREFRAME			(1 << 5)
1273 # define GEN6_SF_FRONT_POINT				(2 << 5)
1274 # define GEN6_SF_BACK_SOLID				(0 << 3)
1275 # define GEN6_SF_BACK_WIREFRAME				(1 << 3)
1276 # define GEN6_SF_BACK_POINT				(2 << 3)
1277 # define GEN6_SF_VIEWPORT_TRANSFORM_ENABLE		(1 << 1)
1278 # define GEN6_SF_WINDING_CCW				(1 << 0)
1279 /* DW3 */
1280 # define GEN6_SF_LINE_AA_ENABLE				(1 << 31)
1281 # define GEN6_SF_CULL_BOTH				(0 << 29)
1282 # define GEN6_SF_CULL_NONE				(1 << 29)
1283 # define GEN6_SF_CULL_FRONT				(2 << 29)
1284 # define GEN6_SF_CULL_BACK				(3 << 29)
1285 # define GEN6_SF_LINE_WIDTH_SHIFT			18 /* U3.7 */
1286 # define GEN6_SF_LINE_END_CAP_WIDTH_0_5			(0 << 16)
1287 # define GEN6_SF_LINE_END_CAP_WIDTH_1_0			(1 << 16)
1288 # define GEN6_SF_LINE_END_CAP_WIDTH_2_0			(2 << 16)
1289 # define GEN6_SF_LINE_END_CAP_WIDTH_4_0			(3 << 16)
1290 # define GEN6_SF_SCISSOR_ENABLE				(1 << 11)
1291 # define GEN6_SF_MSRAST_OFF_PIXEL			(0 << 8)
1292 # define GEN6_SF_MSRAST_OFF_PATTERN			(1 << 8)
1293 # define GEN6_SF_MSRAST_ON_PIXEL			(2 << 8)
1294 # define GEN6_SF_MSRAST_ON_PATTERN			(3 << 8)
1295 /* DW4 */
1296 # define GEN6_SF_TRI_PROVOKE_SHIFT			29
1297 # define GEN6_SF_LINE_PROVOKE_SHIFT			27
1298 # define GEN6_SF_TRIFAN_PROVOKE_SHIFT			25
1299 # define GEN6_SF_LINE_AA_MODE_MANHATTAN			(0 << 14)
1300 # define GEN6_SF_LINE_AA_MODE_TRUE			(1 << 14)
1301 # define GEN6_SF_VERTEX_SUBPIXEL_8BITS			(0 << 12)
1302 # define GEN6_SF_VERTEX_SUBPIXEL_4BITS			(1 << 12)
1303 # define GEN6_SF_USE_STATE_POINT_WIDTH			(1 << 11)
1304 # define GEN6_SF_POINT_WIDTH_SHIFT			0 /* U8.3 */
1305 /* DW5: depth offset constant */
1306 /* DW6: depth offset scale */
1307 /* DW7: depth offset clamp */
1308 /* DW8 */
1309 # define ATTRIBUTE_1_OVERRIDE_W				(1 << 31)
1310 # define ATTRIBUTE_1_OVERRIDE_Z				(1 << 30)
1311 # define ATTRIBUTE_1_OVERRIDE_Y				(1 << 29)
1312 # define ATTRIBUTE_1_OVERRIDE_X				(1 << 28)
1313 # define ATTRIBUTE_1_CONST_SOURCE_SHIFT			25
1314 # define ATTRIBUTE_1_SWIZZLE_SHIFT			22
1315 # define ATTRIBUTE_1_SOURCE_SHIFT			16
1316 # define ATTRIBUTE_0_OVERRIDE_W				(1 << 15)
1317 # define ATTRIBUTE_0_OVERRIDE_Z				(1 << 14)
1318 # define ATTRIBUTE_0_OVERRIDE_Y				(1 << 13)
1319 # define ATTRIBUTE_0_OVERRIDE_X				(1 << 12)
1320 # define ATTRIBUTE_0_CONST_SOURCE_SHIFT			9
1321 # define ATTRIBUTE_0_SWIZZLE_SHIFT			6
1322 # define ATTRIBUTE_0_SOURCE_SHIFT			0
1323 
1324 # define ATTRIBUTE_SWIZZLE_INPUTATTR                    0
1325 # define ATTRIBUTE_SWIZZLE_INPUTATTR_FACING             1
1326 # define ATTRIBUTE_SWIZZLE_INPUTATTR_W                  2
1327 # define ATTRIBUTE_SWIZZLE_INPUTATTR_FACING_W           3
1328 # define ATTRIBUTE_SWIZZLE_SHIFT                        6
1329 
1330 /* DW16: Point sprite texture coordinate enables */
1331 /* DW17: Constant interpolation enables */
1332 /* DW18: attr 0-7 wrap shortest enables */
1333 /* DW19: attr 8-16 wrap shortest enables */
1334 
1335 /* On GEN7, many fields of 3DSTATE_SF were split out into a new command:
1336  * 3DSTATE_SBE.  The remaining fields live in different DWords, but retain
1337  * the same bit-offset.  The only new field:
1338  */
1339 /* GEN7/DW1: */
1340 # define GEN7_SF_DEPTH_BUFFER_SURFACE_FORMAT_SHIFT	12
1341 /* GEN7/DW2: */
1342 # define HSW_SF_LINE_STIPPLE_ENABLE			14
1343 
1344 #define _3DSTATE_SBE				0x781F /* GEN7+ */
1345 /* DW1 */
1346 # define GEN7_SBE_SWIZZLE_CONTROL_MODE			(1 << 28)
1347 # define GEN7_SBE_NUM_OUTPUTS_SHIFT			22
1348 # define GEN7_SBE_SWIZZLE_ENABLE			(1 << 21)
1349 # define GEN7_SBE_POINT_SPRITE_LOWERLEFT		(1 << 20)
1350 # define GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT		11
1351 # define GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT		4
1352 /* DW2-9: Attribute setup (same as DW8-15 of gen6 _3DSTATE_SF) */
1353 /* DW10: Point sprite texture coordinate enables */
1354 /* DW11: Constant interpolation enables */
1355 /* DW12: attr 0-7 wrap shortest enables */
1356 /* DW13: attr 8-16 wrap shortest enables */
1357 
1358 enum brw_wm_barycentric_interp_mode {
1359    BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC		= 0,
1360    BRW_WM_PERSPECTIVE_CENTROID_BARYCENTRIC	= 1,
1361    BRW_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC	= 2,
1362    BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC	= 3,
1363    BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC	= 4,
1364    BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC	= 5,
1365    BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT  = 6
1366 };
1367 #define BRW_WM_NONPERSPECTIVE_BARYCENTRIC_BITS \
1368    ((1 << BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC) | \
1369     (1 << BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC) | \
1370     (1 << BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC))
1371 
1372 #define _3DSTATE_WM				0x7814 /* GEN6+ */
1373 /* DW1: kernel pointer */
1374 /* DW2 */
1375 # define GEN6_WM_SPF_MODE				(1 << 31)
1376 # define GEN6_WM_VECTOR_MASK_ENABLE			(1 << 30)
1377 # define GEN6_WM_SAMPLER_COUNT_SHIFT			27
1378 # define GEN6_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
1379 # define GEN6_WM_FLOATING_POINT_MODE_IEEE_754		(0 << 16)
1380 # define GEN6_WM_FLOATING_POINT_MODE_ALT		(1 << 16)
1381 /* DW3: scratch space */
1382 /* DW4 */
1383 # define GEN6_WM_STATISTICS_ENABLE			(1 << 31)
1384 # define GEN6_WM_DEPTH_CLEAR				(1 << 30)
1385 # define GEN6_WM_DEPTH_RESOLVE				(1 << 28)
1386 # define GEN6_WM_HIERARCHICAL_DEPTH_RESOLVE		(1 << 27)
1387 # define GEN6_WM_DISPATCH_START_GRF_SHIFT_0		16
1388 # define GEN6_WM_DISPATCH_START_GRF_SHIFT_1		8
1389 # define GEN6_WM_DISPATCH_START_GRF_SHIFT_2		0
1390 /* DW5 */
1391 # define GEN6_WM_MAX_THREADS_SHIFT			25
1392 # define GEN6_WM_KILL_ENABLE				(1 << 22)
1393 # define GEN6_WM_COMPUTED_DEPTH				(1 << 21)
1394 # define GEN6_WM_USES_SOURCE_DEPTH			(1 << 20)
1395 # define GEN6_WM_DISPATCH_ENABLE			(1 << 19)
1396 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_0_5		(0 << 16)
1397 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_1_0		(1 << 16)
1398 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_2_0		(2 << 16)
1399 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_4_0		(3 << 16)
1400 # define GEN6_WM_LINE_AA_WIDTH_0_5			(0 << 14)
1401 # define GEN6_WM_LINE_AA_WIDTH_1_0			(1 << 14)
1402 # define GEN6_WM_LINE_AA_WIDTH_2_0			(2 << 14)
1403 # define GEN6_WM_LINE_AA_WIDTH_4_0			(3 << 14)
1404 # define GEN6_WM_POLYGON_STIPPLE_ENABLE			(1 << 13)
1405 # define GEN6_WM_LINE_STIPPLE_ENABLE			(1 << 11)
1406 # define GEN6_WM_OMASK_TO_RENDER_TARGET			(1 << 9)
1407 # define GEN6_WM_USES_SOURCE_W				(1 << 8)
1408 # define GEN6_WM_DUAL_SOURCE_BLEND_ENABLE		(1 << 7)
1409 # define GEN6_WM_32_DISPATCH_ENABLE			(1 << 2)
1410 # define GEN6_WM_16_DISPATCH_ENABLE			(1 << 1)
1411 # define GEN6_WM_8_DISPATCH_ENABLE			(1 << 0)
1412 /* DW6 */
1413 # define GEN6_WM_NUM_SF_OUTPUTS_SHIFT			20
1414 # define GEN6_WM_POSOFFSET_NONE				(0 << 18)
1415 # define GEN6_WM_POSOFFSET_CENTROID			(2 << 18)
1416 # define GEN6_WM_POSOFFSET_SAMPLE			(3 << 18)
1417 # define GEN6_WM_POSITION_ZW_PIXEL			(0 << 16)
1418 # define GEN6_WM_POSITION_ZW_CENTROID			(2 << 16)
1419 # define GEN6_WM_POSITION_ZW_SAMPLE			(3 << 16)
1420 # define GEN6_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC	(1 << 15)
1421 # define GEN6_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 14)
1422 # define GEN6_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC	(1 << 13)
1423 # define GEN6_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC		(1 << 12)
1424 # define GEN6_WM_PERSPECTIVE_CENTROID_BARYCENTRIC	(1 << 11)
1425 # define GEN6_WM_PERSPECTIVE_PIXEL_BARYCENTRIC		(1 << 10)
1426 # define GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT   10
1427 # define GEN6_WM_POINT_RASTRULE_UPPER_RIGHT		(1 << 9)
1428 # define GEN6_WM_MSRAST_OFF_PIXEL			(0 << 1)
1429 # define GEN6_WM_MSRAST_OFF_PATTERN			(1 << 1)
1430 # define GEN6_WM_MSRAST_ON_PIXEL			(2 << 1)
1431 # define GEN6_WM_MSRAST_ON_PATTERN			(3 << 1)
1432 # define GEN6_WM_MSDISPMODE_PERSAMPLE			(0 << 0)
1433 # define GEN6_WM_MSDISPMODE_PERPIXEL			(1 << 0)
1434 /* DW7: kernel 1 pointer */
1435 /* DW8: kernel 2 pointer */
1436 
1437 #define _3DSTATE_CONSTANT_VS		      0x7815 /* GEN6+ */
1438 #define _3DSTATE_CONSTANT_GS		      0x7816 /* GEN6+ */
1439 #define _3DSTATE_CONSTANT_PS		      0x7817 /* GEN6+ */
1440 # define GEN6_CONSTANT_BUFFER_3_ENABLE			(1 << 15)
1441 # define GEN6_CONSTANT_BUFFER_2_ENABLE			(1 << 14)
1442 # define GEN6_CONSTANT_BUFFER_1_ENABLE			(1 << 13)
1443 # define GEN6_CONSTANT_BUFFER_0_ENABLE			(1 << 12)
1444 
1445 #define _3DSTATE_CONSTANT_HS                  0x7819 /* GEN7+ */
1446 #define _3DSTATE_CONSTANT_DS                  0x781A /* GEN7+ */
1447 
1448 #define _3DSTATE_STREAMOUT                    0x781e /* GEN7+ */
1449 /* DW1 */
1450 # define SO_FUNCTION_ENABLE				(1 << 31)
1451 # define SO_RENDERING_DISABLE				(1 << 30)
1452 /* This selects which incoming rendering stream goes down the pipeline.  The
1453  * rendering stream is 0 if not defined by special cases in the GS state.
1454  */
1455 # define SO_RENDER_STREAM_SELECT_SHIFT			27
1456 # define SO_RENDER_STREAM_SELECT_MASK			INTEL_MASK(28, 27)
1457 /* Controls reordering of TRISTRIP_* elements in stream output (not rendering).
1458  */
1459 # define SO_REORDER_TRAILING				(1 << 26)
1460 /* Controls SO_NUM_PRIMS_WRITTEN_* and SO_PRIM_STORAGE_* */
1461 # define SO_STATISTICS_ENABLE				(1 << 25)
1462 # define SO_BUFFER_ENABLE(n)				(1 << (8 + (n)))
1463 /* DW2 */
1464 # define SO_STREAM_3_VERTEX_READ_OFFSET_SHIFT		29
1465 # define SO_STREAM_3_VERTEX_READ_OFFSET_MASK		INTEL_MASK(29, 29)
1466 # define SO_STREAM_3_VERTEX_READ_LENGTH_SHIFT		24
1467 # define SO_STREAM_3_VERTEX_READ_LENGTH_MASK		INTEL_MASK(28, 24)
1468 # define SO_STREAM_2_VERTEX_READ_OFFSET_SHIFT		21
1469 # define SO_STREAM_2_VERTEX_READ_OFFSET_MASK		INTEL_MASK(21, 21)
1470 # define SO_STREAM_2_VERTEX_READ_LENGTH_SHIFT		16
1471 # define SO_STREAM_2_VERTEX_READ_LENGTH_MASK		INTEL_MASK(20, 16)
1472 # define SO_STREAM_1_VERTEX_READ_OFFSET_SHIFT		13
1473 # define SO_STREAM_1_VERTEX_READ_OFFSET_MASK		INTEL_MASK(13, 13)
1474 # define SO_STREAM_1_VERTEX_READ_LENGTH_SHIFT		8
1475 # define SO_STREAM_1_VERTEX_READ_LENGTH_MASK		INTEL_MASK(12, 8)
1476 # define SO_STREAM_0_VERTEX_READ_OFFSET_SHIFT		5
1477 # define SO_STREAM_0_VERTEX_READ_OFFSET_MASK		INTEL_MASK(5, 5)
1478 # define SO_STREAM_0_VERTEX_READ_LENGTH_SHIFT		0
1479 # define SO_STREAM_0_VERTEX_READ_LENGTH_MASK		INTEL_MASK(4, 0)
1480 
1481 /* 3DSTATE_WM for Gen7 */
1482 /* DW1 */
1483 # define GEN7_WM_STATISTICS_ENABLE			(1 << 31)
1484 # define GEN7_WM_DEPTH_CLEAR				(1 << 30)
1485 # define GEN7_WM_DISPATCH_ENABLE			(1 << 29)
1486 # define GEN7_WM_DEPTH_RESOLVE				(1 << 28)
1487 # define GEN7_WM_HIERARCHICAL_DEPTH_RESOLVE		(1 << 27)
1488 # define GEN7_WM_KILL_ENABLE				(1 << 25)
1489 # define GEN7_WM_PSCDEPTH_OFF			        (0 << 23)
1490 # define GEN7_WM_PSCDEPTH_ON			        (1 << 23)
1491 # define GEN7_WM_PSCDEPTH_ON_GE			        (2 << 23)
1492 # define GEN7_WM_PSCDEPTH_ON_LE			        (3 << 23)
1493 # define GEN7_WM_USES_SOURCE_DEPTH			(1 << 20)
1494 # define GEN7_WM_USES_SOURCE_W			        (1 << 19)
1495 # define GEN7_WM_POSITION_ZW_PIXEL			(0 << 17)
1496 # define GEN7_WM_POSITION_ZW_CENTROID			(2 << 17)
1497 # define GEN7_WM_POSITION_ZW_SAMPLE			(3 << 17)
1498 # define GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT   11
1499 # define GEN7_WM_USES_INPUT_COVERAGE_MASK	        (1 << 10)
1500 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_0_5		(0 << 8)
1501 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_1_0		(1 << 8)
1502 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_2_0		(2 << 8)
1503 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_4_0		(3 << 8)
1504 # define GEN7_WM_LINE_AA_WIDTH_0_5			(0 << 6)
1505 # define GEN7_WM_LINE_AA_WIDTH_1_0			(1 << 6)
1506 # define GEN7_WM_LINE_AA_WIDTH_2_0			(2 << 6)
1507 # define GEN7_WM_LINE_AA_WIDTH_4_0			(3 << 6)
1508 # define GEN7_WM_POLYGON_STIPPLE_ENABLE			(1 << 4)
1509 # define GEN7_WM_LINE_STIPPLE_ENABLE			(1 << 3)
1510 # define GEN7_WM_POINT_RASTRULE_UPPER_RIGHT		(1 << 2)
1511 # define GEN7_WM_MSRAST_OFF_PIXEL			(0 << 0)
1512 # define GEN7_WM_MSRAST_OFF_PATTERN			(1 << 0)
1513 # define GEN7_WM_MSRAST_ON_PIXEL			(2 << 0)
1514 # define GEN7_WM_MSRAST_ON_PATTERN			(3 << 0)
1515 /* DW2 */
1516 # define GEN7_WM_MSDISPMODE_PERSAMPLE			(0 << 31)
1517 # define GEN7_WM_MSDISPMODE_PERPIXEL			(1 << 31)
1518 
1519 #define _3DSTATE_PS				0x7820 /* GEN7+ */
1520 /* DW1: kernel pointer */
1521 /* DW2 */
1522 # define GEN7_PS_SPF_MODE				(1 << 31)
1523 # define GEN7_PS_VECTOR_MASK_ENABLE			(1 << 30)
1524 # define GEN7_PS_SAMPLER_COUNT_SHIFT			27
1525 # define GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT	18
1526 # define GEN7_PS_FLOATING_POINT_MODE_IEEE_754		(0 << 16)
1527 # define GEN7_PS_FLOATING_POINT_MODE_ALT		(1 << 16)
1528 /* DW3: scratch space */
1529 /* DW4 */
1530 # define IVB_PS_MAX_THREADS_SHIFT			24
1531 # define HSW_PS_MAX_THREADS_SHIFT			23
1532 # define HSW_PS_SAMPLE_MASK_SHIFT		        12
1533 # define HSW_PS_SAMPLE_MASK_MASK			INTEL_MASK(19, 12)
1534 # define GEN7_PS_PUSH_CONSTANT_ENABLE		        (1 << 11)
1535 # define GEN7_PS_ATTRIBUTE_ENABLE		        (1 << 10)
1536 # define GEN7_PS_OMASK_TO_RENDER_TARGET			(1 << 9)
1537 # define GEN7_PS_DUAL_SOURCE_BLEND_ENABLE		(1 << 7)
1538 # define GEN7_PS_POSOFFSET_NONE				(0 << 3)
1539 # define GEN7_PS_POSOFFSET_CENTROID			(2 << 3)
1540 # define GEN7_PS_POSOFFSET_SAMPLE			(3 << 3)
1541 # define GEN7_PS_32_DISPATCH_ENABLE			(1 << 2)
1542 # define GEN7_PS_16_DISPATCH_ENABLE			(1 << 1)
1543 # define GEN7_PS_8_DISPATCH_ENABLE			(1 << 0)
1544 /* DW5 */
1545 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_0		16
1546 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_1		8
1547 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_2		0
1548 /* DW6: kernel 1 pointer */
1549 /* DW7: kernel 2 pointer */
1550 
1551 #define _3DSTATE_SAMPLE_MASK			0x7818 /* GEN6+ */
1552 
1553 #define _3DSTATE_DRAWING_RECTANGLE		0x7900
1554 #define _3DSTATE_BLEND_CONSTANT_COLOR		0x7901
1555 #define _3DSTATE_CHROMA_KEY			0x7904
1556 #define _3DSTATE_DEPTH_BUFFER			0x7905 /* GEN4-6 */
1557 #define _3DSTATE_POLY_STIPPLE_OFFSET		0x7906
1558 #define _3DSTATE_POLY_STIPPLE_PATTERN		0x7907
1559 #define _3DSTATE_LINE_STIPPLE_PATTERN		0x7908
1560 #define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP	0x7909
1561 #define _3DSTATE_AA_LINE_PARAMETERS		0x790a /* G45+ */
1562 
1563 #define _3DSTATE_GS_SVB_INDEX			0x790b /* CTG+ */
1564 /* DW1 */
1565 # define SVB_INDEX_SHIFT				29
1566 # define SVB_LOAD_INTERNAL_VERTEX_COUNT			(1 << 0) /* SNB+ */
1567 /* DW2: SVB index */
1568 /* DW3: SVB maximum index */
1569 
1570 #define _3DSTATE_MULTISAMPLE			0x790d /* GEN6+ */
1571 /* DW1 */
1572 # define MS_PIXEL_LOCATION_CENTER			(0 << 4)
1573 # define MS_PIXEL_LOCATION_UPPER_LEFT			(1 << 4)
1574 # define MS_NUMSAMPLES_1				(0 << 1)
1575 # define MS_NUMSAMPLES_4				(2 << 1)
1576 # define MS_NUMSAMPLES_8				(3 << 1)
1577 
1578 #define _3DSTATE_STENCIL_BUFFER			0x790e /* ILK, SNB */
1579 #define _3DSTATE_HIER_DEPTH_BUFFER		0x790f /* ILK, SNB */
1580 
1581 #define GEN7_3DSTATE_CLEAR_PARAMS		0x7804
1582 #define GEN7_3DSTATE_DEPTH_BUFFER		0x7805
1583 #define GEN7_3DSTATE_STENCIL_BUFFER		0x7806
1584 # define HSW_STENCIL_ENABLED                            (1 << 31)
1585 #define GEN7_3DSTATE_HIER_DEPTH_BUFFER		0x7807
1586 
1587 #define _3DSTATE_CLEAR_PARAMS			0x7910 /* ILK, SNB */
1588 # define GEN5_DEPTH_CLEAR_VALID				(1 << 15)
1589 /* DW1: depth clear value */
1590 /* DW2 */
1591 # define GEN7_DEPTH_CLEAR_VALID				(1 << 0)
1592 
1593 #define _3DSTATE_SO_DECL_LIST			0x7917 /* GEN7+ */
1594 /* DW1 */
1595 # define SO_STREAM_TO_BUFFER_SELECTS_3_SHIFT		12
1596 # define SO_STREAM_TO_BUFFER_SELECTS_3_MASK		INTEL_MASK(15, 12)
1597 # define SO_STREAM_TO_BUFFER_SELECTS_2_SHIFT		8
1598 # define SO_STREAM_TO_BUFFER_SELECTS_2_MASK		INTEL_MASK(11, 8)
1599 # define SO_STREAM_TO_BUFFER_SELECTS_1_SHIFT		4
1600 # define SO_STREAM_TO_BUFFER_SELECTS_1_MASK		INTEL_MASK(7, 4)
1601 # define SO_STREAM_TO_BUFFER_SELECTS_0_SHIFT		0
1602 # define SO_STREAM_TO_BUFFER_SELECTS_0_MASK		INTEL_MASK(3, 0)
1603 /* DW2 */
1604 # define SO_NUM_ENTRIES_3_SHIFT				24
1605 # define SO_NUM_ENTRIES_3_MASK				INTEL_MASK(31, 24)
1606 # define SO_NUM_ENTRIES_2_SHIFT				16
1607 # define SO_NUM_ENTRIES_2_MASK				INTEL_MASK(23, 16)
1608 # define SO_NUM_ENTRIES_1_SHIFT				8
1609 # define SO_NUM_ENTRIES_1_MASK				INTEL_MASK(15, 8)
1610 # define SO_NUM_ENTRIES_0_SHIFT				0
1611 # define SO_NUM_ENTRIES_0_MASK				INTEL_MASK(7, 0)
1612 
1613 /* SO_DECL DW0 */
1614 # define SO_DECL_OUTPUT_BUFFER_SLOT_SHIFT		12
1615 # define SO_DECL_OUTPUT_BUFFER_SLOT_MASK		INTEL_MASK(13, 12)
1616 # define SO_DECL_HOLE_FLAG				(1 << 11)
1617 # define SO_DECL_REGISTER_INDEX_SHIFT			4
1618 # define SO_DECL_REGISTER_INDEX_MASK			INTEL_MASK(9, 4)
1619 # define SO_DECL_COMPONENT_MASK_SHIFT			0
1620 # define SO_DECL_COMPONENT_MASK_MASK			INTEL_MASK(3, 0)
1621 
1622 #define _3DSTATE_SO_BUFFER                    0x7918 /* GEN7+ */
1623 /* DW1 */
1624 # define SO_BUFFER_INDEX_SHIFT				29
1625 # define SO_BUFFER_INDEX_MASK				INTEL_MASK(30, 29)
1626 # define SO_BUFFER_PITCH_SHIFT				0
1627 # define SO_BUFFER_PITCH_MASK				INTEL_MASK(11, 0)
1628 /* DW2: start address */
1629 /* DW3: end address. */
1630 
1631 #define CMD_PIPE_CONTROL              0x7a00
1632 
1633 #define CMD_MI_FLUSH                  0x0200
1634 
1635 
1636 /* Bitfields for the URB_WRITE message, DW2 of message header: */
1637 #define URB_WRITE_PRIM_END		0x1
1638 #define URB_WRITE_PRIM_START		0x2
1639 #define URB_WRITE_PRIM_TYPE_SHIFT	2
1640 
1641 
1642 /* Maximum number of entries that can be addressed using a binding table
1643  * pointer of type SURFTYPE_BUFFER
1644  */
1645 #define BRW_MAX_NUM_BUFFER_ENTRIES	(1 << 27)
1646 
1647 #define EX_DESC_SFID_MASK 0xF
1648 #define EX_DESC_EOT_MASK  0x20
1649 
1650 #define EX_DESC_FUNC_MASK 0xFFFFFFC0
1651 
1652 #endif
1653