Merge remote-tracking branch 'fdo-personal/wip/nir-vtn' into vulkan
[mesa.git] / src / mesa / drivers / dri / i965 / brw_defines.h
1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics 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 <keithw@vmware.com>
30 */
31
32 #define INTEL_MASK(high, low) (((1<<((high)-(low)+1))-1)<<(low))
33 /* Using the GNU statement expression extension */
34 #define SET_FIELD(value, field) \
35 ({ \
36 uint32_t fieldval = (value) << field ## _SHIFT; \
37 assert((fieldval & ~ field ## _MASK) == 0); \
38 fieldval & field ## _MASK; \
39 })
40
41 #define GET_FIELD(word, field) (((word) & field ## _MASK) >> field ## _SHIFT)
42
43 #ifndef BRW_DEFINES_H
44 #define BRW_DEFINES_H
45
46 /* 3D state:
47 */
48 #define CMD_3D_PRIM 0x7b00 /* 3DPRIMITIVE */
49 /* DW0 */
50 # define GEN4_3DPRIM_TOPOLOGY_TYPE_SHIFT 10
51 # define GEN4_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 15)
52 # define GEN4_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM (1 << 15)
53 # define GEN7_3DPRIM_INDIRECT_PARAMETER_ENABLE (1 << 10)
54 /* DW1 */
55 # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 8)
56 # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM (1 << 8)
57
58 #ifndef _3DPRIM_POINTLIST /* FIXME: Avoid clashing with defines from bdw_pack.h */
59 #define _3DPRIM_POINTLIST 0x01
60 #define _3DPRIM_LINELIST 0x02
61 #define _3DPRIM_LINESTRIP 0x03
62 #define _3DPRIM_TRILIST 0x04
63 #define _3DPRIM_TRISTRIP 0x05
64 #define _3DPRIM_TRIFAN 0x06
65 #define _3DPRIM_QUADLIST 0x07
66 #define _3DPRIM_QUADSTRIP 0x08
67 #define _3DPRIM_LINELIST_ADJ 0x09
68 #define _3DPRIM_LINESTRIP_ADJ 0x0A
69 #define _3DPRIM_TRILIST_ADJ 0x0B
70 #define _3DPRIM_TRISTRIP_ADJ 0x0C
71 #define _3DPRIM_TRISTRIP_REVERSE 0x0D
72 #define _3DPRIM_POLYGON 0x0E
73 #define _3DPRIM_RECTLIST 0x0F
74 #define _3DPRIM_LINELOOP 0x10
75 #define _3DPRIM_POINTLIST_BF 0x11
76 #define _3DPRIM_LINESTRIP_CONT 0x12
77 #define _3DPRIM_LINESTRIP_BF 0x13
78 #define _3DPRIM_LINESTRIP_CONT_BF 0x14
79 #define _3DPRIM_TRIFAN_NOSTIPPLE 0x15
80 #endif
81
82 /* We use this offset to be able to pass native primitive types in struct
83 * _mesa_prim::mode. Native primitive types are BRW_PRIM_OFFSET +
84 * native_type, which should be different from all GL types and still fit in
85 * the 8 bits avialable. */
86
87 #define BRW_PRIM_OFFSET 0x80
88
89 #define BRW_ANISORATIO_2 0
90 #define BRW_ANISORATIO_4 1
91 #define BRW_ANISORATIO_6 2
92 #define BRW_ANISORATIO_8 3
93 #define BRW_ANISORATIO_10 4
94 #define BRW_ANISORATIO_12 5
95 #define BRW_ANISORATIO_14 6
96 #define BRW_ANISORATIO_16 7
97
98 #define BRW_BLENDFACTOR_ONE 0x1
99 #define BRW_BLENDFACTOR_SRC_COLOR 0x2
100 #define BRW_BLENDFACTOR_SRC_ALPHA 0x3
101 #define BRW_BLENDFACTOR_DST_ALPHA 0x4
102 #define BRW_BLENDFACTOR_DST_COLOR 0x5
103 #define BRW_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6
104 #define BRW_BLENDFACTOR_CONST_COLOR 0x7
105 #define BRW_BLENDFACTOR_CONST_ALPHA 0x8
106 #define BRW_BLENDFACTOR_SRC1_COLOR 0x9
107 #define BRW_BLENDFACTOR_SRC1_ALPHA 0x0A
108 #define BRW_BLENDFACTOR_ZERO 0x11
109 #define BRW_BLENDFACTOR_INV_SRC_COLOR 0x12
110 #define BRW_BLENDFACTOR_INV_SRC_ALPHA 0x13
111 #define BRW_BLENDFACTOR_INV_DST_ALPHA 0x14
112 #define BRW_BLENDFACTOR_INV_DST_COLOR 0x15
113 #define BRW_BLENDFACTOR_INV_CONST_COLOR 0x17
114 #define BRW_BLENDFACTOR_INV_CONST_ALPHA 0x18
115 #define BRW_BLENDFACTOR_INV_SRC1_COLOR 0x19
116 #define BRW_BLENDFACTOR_INV_SRC1_ALPHA 0x1A
117
118 #define BRW_BLENDFUNCTION_ADD 0
119 #define BRW_BLENDFUNCTION_SUBTRACT 1
120 #define BRW_BLENDFUNCTION_REVERSE_SUBTRACT 2
121 #define BRW_BLENDFUNCTION_MIN 3
122 #define BRW_BLENDFUNCTION_MAX 4
123
124 #define BRW_ALPHATEST_FORMAT_UNORM8 0
125 #define BRW_ALPHATEST_FORMAT_FLOAT32 1
126
127 #define BRW_CHROMAKEY_KILL_ON_ANY_MATCH 0
128 #define BRW_CHROMAKEY_REPLACE_BLACK 1
129
130 #define BRW_CLIP_API_OGL 0
131 #define BRW_CLIP_API_DX 1
132
133 #define BRW_CLIPMODE_NORMAL 0
134 #define BRW_CLIPMODE_CLIP_ALL 1
135 #define BRW_CLIPMODE_CLIP_NON_REJECTED 2
136 #define BRW_CLIPMODE_REJECT_ALL 3
137 #define BRW_CLIPMODE_ACCEPT_ALL 4
138 #define BRW_CLIPMODE_KERNEL_CLIP 5
139
140 #define BRW_CLIP_NDCSPACE 0
141 #define BRW_CLIP_SCREENSPACE 1
142
143 #define BRW_COMPAREFUNCTION_ALWAYS 0
144 #define BRW_COMPAREFUNCTION_NEVER 1
145 #define BRW_COMPAREFUNCTION_LESS 2
146 #define BRW_COMPAREFUNCTION_EQUAL 3
147 #define BRW_COMPAREFUNCTION_LEQUAL 4
148 #define BRW_COMPAREFUNCTION_GREATER 5
149 #define BRW_COMPAREFUNCTION_NOTEQUAL 6
150 #define BRW_COMPAREFUNCTION_GEQUAL 7
151
152 #define BRW_COVERAGE_PIXELS_HALF 0
153 #define BRW_COVERAGE_PIXELS_1 1
154 #define BRW_COVERAGE_PIXELS_2 2
155 #define BRW_COVERAGE_PIXELS_4 3
156
157 #define BRW_CULLMODE_BOTH 0
158 #define BRW_CULLMODE_NONE 1
159 #define BRW_CULLMODE_FRONT 2
160 #define BRW_CULLMODE_BACK 3
161
162 #define BRW_DEFAULTCOLOR_R8G8B8A8_UNORM 0
163 #define BRW_DEFAULTCOLOR_R32G32B32A32_FLOAT 1
164
165 #define BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT 0
166 #define BRW_DEPTHFORMAT_D32_FLOAT 1
167 #define BRW_DEPTHFORMAT_D24_UNORM_S8_UINT 2
168 #define BRW_DEPTHFORMAT_D24_UNORM_X8_UINT 3 /* GEN5 */
169 #define BRW_DEPTHFORMAT_D16_UNORM 5
170
171 #define BRW_FLOATING_POINT_IEEE_754 0
172 #define BRW_FLOATING_POINT_NON_IEEE_754 1
173
174 #define BRW_FRONTWINDING_CW 0
175 #define BRW_FRONTWINDING_CCW 1
176
177 #define BRW_SPRITE_POINT_ENABLE 16
178
179 #define BRW_CUT_INDEX_ENABLE (1 << 10)
180
181 #define BRW_INDEX_BYTE 0
182 #define BRW_INDEX_WORD 1
183 #define BRW_INDEX_DWORD 2
184
185 #define BRW_LOGICOPFUNCTION_CLEAR 0
186 #define BRW_LOGICOPFUNCTION_NOR 1
187 #define BRW_LOGICOPFUNCTION_AND_INVERTED 2
188 #define BRW_LOGICOPFUNCTION_COPY_INVERTED 3
189 #define BRW_LOGICOPFUNCTION_AND_REVERSE 4
190 #define BRW_LOGICOPFUNCTION_INVERT 5
191 #define BRW_LOGICOPFUNCTION_XOR 6
192 #define BRW_LOGICOPFUNCTION_NAND 7
193 #define BRW_LOGICOPFUNCTION_AND 8
194 #define BRW_LOGICOPFUNCTION_EQUIV 9
195 #define BRW_LOGICOPFUNCTION_NOOP 10
196 #define BRW_LOGICOPFUNCTION_OR_INVERTED 11
197 #define BRW_LOGICOPFUNCTION_COPY 12
198 #define BRW_LOGICOPFUNCTION_OR_REVERSE 13
199 #define BRW_LOGICOPFUNCTION_OR 14
200 #define BRW_LOGICOPFUNCTION_SET 15
201
202 #define BRW_MAPFILTER_NEAREST 0x0
203 #define BRW_MAPFILTER_LINEAR 0x1
204 #define BRW_MAPFILTER_ANISOTROPIC 0x2
205
206 #define BRW_MIPFILTER_NONE 0
207 #define BRW_MIPFILTER_NEAREST 1
208 #define BRW_MIPFILTER_LINEAR 3
209
210 #define BRW_ADDRESS_ROUNDING_ENABLE_U_MAG 0x20
211 #define BRW_ADDRESS_ROUNDING_ENABLE_U_MIN 0x10
212 #define BRW_ADDRESS_ROUNDING_ENABLE_V_MAG 0x08
213 #define BRW_ADDRESS_ROUNDING_ENABLE_V_MIN 0x04
214 #define BRW_ADDRESS_ROUNDING_ENABLE_R_MAG 0x02
215 #define BRW_ADDRESS_ROUNDING_ENABLE_R_MIN 0x01
216
217 #define BRW_POLYGON_FRONT_FACING 0
218 #define BRW_POLYGON_BACK_FACING 1
219
220 #define BRW_PREFILTER_ALWAYS 0x0
221 #define BRW_PREFILTER_NEVER 0x1
222 #define BRW_PREFILTER_LESS 0x2
223 #define BRW_PREFILTER_EQUAL 0x3
224 #define BRW_PREFILTER_LEQUAL 0x4
225 #define BRW_PREFILTER_GREATER 0x5
226 #define BRW_PREFILTER_NOTEQUAL 0x6
227 #define BRW_PREFILTER_GEQUAL 0x7
228
229 #define BRW_PROVOKING_VERTEX_0 0
230 #define BRW_PROVOKING_VERTEX_1 1
231 #define BRW_PROVOKING_VERTEX_2 2
232
233 #define BRW_RASTRULE_UPPER_LEFT 0
234 #define BRW_RASTRULE_UPPER_RIGHT 1
235 /* These are listed as "Reserved, but not seen as useful"
236 * in Intel documentation (page 212, "Point Rasterization Rule",
237 * section 7.4 "SF Pipeline State Summary", of document
238 * "IntelĀ® 965 Express Chipset Family and IntelĀ® G35 Express
239 * Chipset Graphics Controller Programmer's Reference Manual,
240 * Volume 2: 3D/Media", Revision 1.0b as of January 2008,
241 * available at
242 * http://intellinuxgraphics.org/documentation.html
243 * at the time of this writing).
244 *
245 * These appear to be supported on at least some
246 * i965-family devices, and the BRW_RASTRULE_LOWER_RIGHT
247 * is useful when using OpenGL to render to a FBO
248 * (which has the pixel coordinate Y orientation inverted
249 * with respect to the normal OpenGL pixel coordinate system).
250 */
251 #define BRW_RASTRULE_LOWER_LEFT 2
252 #define BRW_RASTRULE_LOWER_RIGHT 3
253
254 #define BRW_RENDERTARGET_CLAMPRANGE_UNORM 0
255 #define BRW_RENDERTARGET_CLAMPRANGE_SNORM 1
256 #define BRW_RENDERTARGET_CLAMPRANGE_FORMAT 2
257
258 #define BRW_STENCILOP_KEEP 0
259 #define BRW_STENCILOP_ZERO 1
260 #define BRW_STENCILOP_REPLACE 2
261 #define BRW_STENCILOP_INCRSAT 3
262 #define BRW_STENCILOP_DECRSAT 4
263 #define BRW_STENCILOP_INCR 5
264 #define BRW_STENCILOP_DECR 6
265 #define BRW_STENCILOP_INVERT 7
266
267 /* Surface state DW0 */
268 #define GEN8_SURFACE_IS_ARRAY (1 << 28)
269 #define GEN8_SURFACE_VALIGN_4 (1 << 16)
270 #define GEN8_SURFACE_VALIGN_8 (2 << 16)
271 #define GEN8_SURFACE_VALIGN_16 (3 << 16)
272 #define GEN8_SURFACE_HALIGN_4 (1 << 14)
273 #define GEN8_SURFACE_HALIGN_8 (2 << 14)
274 #define GEN8_SURFACE_HALIGN_16 (3 << 14)
275 #define GEN8_SURFACE_TILING_NONE (0 << 12)
276 #define GEN8_SURFACE_TILING_W (1 << 12)
277 #define GEN8_SURFACE_TILING_X (2 << 12)
278 #define GEN8_SURFACE_TILING_Y (3 << 12)
279 #define BRW_SURFACE_RC_READ_WRITE (1 << 8)
280 #define BRW_SURFACE_MIPLAYOUT_SHIFT 10
281 #define BRW_SURFACE_MIPMAPLAYOUT_BELOW 0
282 #define BRW_SURFACE_MIPMAPLAYOUT_RIGHT 1
283 #define BRW_SURFACE_CUBEFACE_ENABLES 0x3f
284 #define BRW_SURFACE_BLEND_ENABLED (1 << 13)
285 #define BRW_SURFACE_WRITEDISABLE_B_SHIFT 14
286 #define BRW_SURFACE_WRITEDISABLE_G_SHIFT 15
287 #define BRW_SURFACE_WRITEDISABLE_R_SHIFT 16
288 #define BRW_SURFACE_WRITEDISABLE_A_SHIFT 17
289
290 #define BRW_SURFACEFORMAT_R32G32B32A32_FLOAT 0x000
291 #define BRW_SURFACEFORMAT_R32G32B32A32_SINT 0x001
292 #define BRW_SURFACEFORMAT_R32G32B32A32_UINT 0x002
293 #define BRW_SURFACEFORMAT_R32G32B32A32_UNORM 0x003
294 #define BRW_SURFACEFORMAT_R32G32B32A32_SNORM 0x004
295 #define BRW_SURFACEFORMAT_R64G64_FLOAT 0x005
296 #define BRW_SURFACEFORMAT_R32G32B32X32_FLOAT 0x006
297 #define BRW_SURFACEFORMAT_R32G32B32A32_SSCALED 0x007
298 #define BRW_SURFACEFORMAT_R32G32B32A32_USCALED 0x008
299 #define BRW_SURFACEFORMAT_R32G32B32A32_SFIXED 0x020
300 #define BRW_SURFACEFORMAT_R64G64_PASSTHRU 0x021
301 #define BRW_SURFACEFORMAT_R32G32B32_FLOAT 0x040
302 #define BRW_SURFACEFORMAT_R32G32B32_SINT 0x041
303 #define BRW_SURFACEFORMAT_R32G32B32_UINT 0x042
304 #define BRW_SURFACEFORMAT_R32G32B32_UNORM 0x043
305 #define BRW_SURFACEFORMAT_R32G32B32_SNORM 0x044
306 #define BRW_SURFACEFORMAT_R32G32B32_SSCALED 0x045
307 #define BRW_SURFACEFORMAT_R32G32B32_USCALED 0x046
308 #define BRW_SURFACEFORMAT_R32G32B32_SFIXED 0x050
309 #define BRW_SURFACEFORMAT_R16G16B16A16_UNORM 0x080
310 #define BRW_SURFACEFORMAT_R16G16B16A16_SNORM 0x081
311 #define BRW_SURFACEFORMAT_R16G16B16A16_SINT 0x082
312 #define BRW_SURFACEFORMAT_R16G16B16A16_UINT 0x083
313 #define BRW_SURFACEFORMAT_R16G16B16A16_FLOAT 0x084
314 #define BRW_SURFACEFORMAT_R32G32_FLOAT 0x085
315 #define BRW_SURFACEFORMAT_R32G32_SINT 0x086
316 #define BRW_SURFACEFORMAT_R32G32_UINT 0x087
317 #define BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS 0x088
318 #define BRW_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT 0x089
319 #define BRW_SURFACEFORMAT_L32A32_FLOAT 0x08A
320 #define BRW_SURFACEFORMAT_R32G32_UNORM 0x08B
321 #define BRW_SURFACEFORMAT_R32G32_SNORM 0x08C
322 #define BRW_SURFACEFORMAT_R64_FLOAT 0x08D
323 #define BRW_SURFACEFORMAT_R16G16B16X16_UNORM 0x08E
324 #define BRW_SURFACEFORMAT_R16G16B16X16_FLOAT 0x08F
325 #define BRW_SURFACEFORMAT_A32X32_FLOAT 0x090
326 #define BRW_SURFACEFORMAT_L32X32_FLOAT 0x091
327 #define BRW_SURFACEFORMAT_I32X32_FLOAT 0x092
328 #define BRW_SURFACEFORMAT_R16G16B16A16_SSCALED 0x093
329 #define BRW_SURFACEFORMAT_R16G16B16A16_USCALED 0x094
330 #define BRW_SURFACEFORMAT_R32G32_SSCALED 0x095
331 #define BRW_SURFACEFORMAT_R32G32_USCALED 0x096
332 #define BRW_SURFACEFORMAT_R32G32_FLOAT_LD 0x097
333 #define BRW_SURFACEFORMAT_R32G32_SFIXED 0x0A0
334 #define BRW_SURFACEFORMAT_R64_PASSTHRU 0x0A1
335 #define BRW_SURFACEFORMAT_B8G8R8A8_UNORM 0x0C0
336 #define BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB 0x0C1
337 #define BRW_SURFACEFORMAT_R10G10B10A2_UNORM 0x0C2
338 #define BRW_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB 0x0C3
339 #define BRW_SURFACEFORMAT_R10G10B10A2_UINT 0x0C4
340 #define BRW_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM 0x0C5
341 #define BRW_SURFACEFORMAT_R8G8B8A8_UNORM 0x0C7
342 #define BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB 0x0C8
343 #define BRW_SURFACEFORMAT_R8G8B8A8_SNORM 0x0C9
344 #define BRW_SURFACEFORMAT_R8G8B8A8_SINT 0x0CA
345 #define BRW_SURFACEFORMAT_R8G8B8A8_UINT 0x0CB
346 #define BRW_SURFACEFORMAT_R16G16_UNORM 0x0CC
347 #define BRW_SURFACEFORMAT_R16G16_SNORM 0x0CD
348 #define BRW_SURFACEFORMAT_R16G16_SINT 0x0CE
349 #define BRW_SURFACEFORMAT_R16G16_UINT 0x0CF
350 #define BRW_SURFACEFORMAT_R16G16_FLOAT 0x0D0
351 #define BRW_SURFACEFORMAT_B10G10R10A2_UNORM 0x0D1
352 #define BRW_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB 0x0D2
353 #define BRW_SURFACEFORMAT_R11G11B10_FLOAT 0x0D3
354 #define BRW_SURFACEFORMAT_R32_SINT 0x0D6
355 #define BRW_SURFACEFORMAT_R32_UINT 0x0D7
356 #define BRW_SURFACEFORMAT_R32_FLOAT 0x0D8
357 #define BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS 0x0D9
358 #define BRW_SURFACEFORMAT_X24_TYPELESS_G8_UINT 0x0DA
359 #define BRW_SURFACEFORMAT_L16A16_UNORM 0x0DF
360 #define BRW_SURFACEFORMAT_I24X8_UNORM 0x0E0
361 #define BRW_SURFACEFORMAT_L24X8_UNORM 0x0E1
362 #define BRW_SURFACEFORMAT_A24X8_UNORM 0x0E2
363 #define BRW_SURFACEFORMAT_I32_FLOAT 0x0E3
364 #define BRW_SURFACEFORMAT_L32_FLOAT 0x0E4
365 #define BRW_SURFACEFORMAT_A32_FLOAT 0x0E5
366 #define BRW_SURFACEFORMAT_B8G8R8X8_UNORM 0x0E9
367 #define BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB 0x0EA
368 #define BRW_SURFACEFORMAT_R8G8B8X8_UNORM 0x0EB
369 #define BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB 0x0EC
370 #define BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP 0x0ED
371 #define BRW_SURFACEFORMAT_B10G10R10X2_UNORM 0x0EE
372 #define BRW_SURFACEFORMAT_L16A16_FLOAT 0x0F0
373 #define BRW_SURFACEFORMAT_R32_UNORM 0x0F1
374 #define BRW_SURFACEFORMAT_R32_SNORM 0x0F2
375 #define BRW_SURFACEFORMAT_R10G10B10X2_USCALED 0x0F3
376 #define BRW_SURFACEFORMAT_R8G8B8A8_SSCALED 0x0F4
377 #define BRW_SURFACEFORMAT_R8G8B8A8_USCALED 0x0F5
378 #define BRW_SURFACEFORMAT_R16G16_SSCALED 0x0F6
379 #define BRW_SURFACEFORMAT_R16G16_USCALED 0x0F7
380 #define BRW_SURFACEFORMAT_R32_SSCALED 0x0F8
381 #define BRW_SURFACEFORMAT_R32_USCALED 0x0F9
382 #define BRW_SURFACEFORMAT_B5G6R5_UNORM 0x100
383 #define BRW_SURFACEFORMAT_B5G6R5_UNORM_SRGB 0x101
384 #define BRW_SURFACEFORMAT_B5G5R5A1_UNORM 0x102
385 #define BRW_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB 0x103
386 #define BRW_SURFACEFORMAT_B4G4R4A4_UNORM 0x104
387 #define BRW_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB 0x105
388 #define BRW_SURFACEFORMAT_R8G8_UNORM 0x106
389 #define BRW_SURFACEFORMAT_R8G8_SNORM 0x107
390 #define BRW_SURFACEFORMAT_R8G8_SINT 0x108
391 #define BRW_SURFACEFORMAT_R8G8_UINT 0x109
392 #define BRW_SURFACEFORMAT_R16_UNORM 0x10A
393 #define BRW_SURFACEFORMAT_R16_SNORM 0x10B
394 #define BRW_SURFACEFORMAT_R16_SINT 0x10C
395 #define BRW_SURFACEFORMAT_R16_UINT 0x10D
396 #define BRW_SURFACEFORMAT_R16_FLOAT 0x10E
397 #define BRW_SURFACEFORMAT_A8P8_UNORM_PALETTE0 0x10F
398 #define BRW_SURFACEFORMAT_A8P8_UNORM_PALETTE1 0x110
399 #define BRW_SURFACEFORMAT_I16_UNORM 0x111
400 #define BRW_SURFACEFORMAT_L16_UNORM 0x112
401 #define BRW_SURFACEFORMAT_A16_UNORM 0x113
402 #define BRW_SURFACEFORMAT_L8A8_UNORM 0x114
403 #define BRW_SURFACEFORMAT_I16_FLOAT 0x115
404 #define BRW_SURFACEFORMAT_L16_FLOAT 0x116
405 #define BRW_SURFACEFORMAT_A16_FLOAT 0x117
406 #define BRW_SURFACEFORMAT_L8A8_UNORM_SRGB 0x118
407 #define BRW_SURFACEFORMAT_R5G5_SNORM_B6_UNORM 0x119
408 #define BRW_SURFACEFORMAT_B5G5R5X1_UNORM 0x11A
409 #define BRW_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB 0x11B
410 #define BRW_SURFACEFORMAT_R8G8_SSCALED 0x11C
411 #define BRW_SURFACEFORMAT_R8G8_USCALED 0x11D
412 #define BRW_SURFACEFORMAT_R16_SSCALED 0x11E
413 #define BRW_SURFACEFORMAT_R16_USCALED 0x11F
414 #define BRW_SURFACEFORMAT_P8A8_UNORM_PALETTE0 0x122
415 #define BRW_SURFACEFORMAT_P8A8_UNORM_PALETTE1 0x123
416 #define BRW_SURFACEFORMAT_A1B5G5R5_UNORM 0x124
417 #define BRW_SURFACEFORMAT_A4B4G4R4_UNORM 0x125
418 #define BRW_SURFACEFORMAT_L8A8_UINT 0x126
419 #define BRW_SURFACEFORMAT_L8A8_SINT 0x127
420 #define BRW_SURFACEFORMAT_R8_UNORM 0x140
421 #define BRW_SURFACEFORMAT_R8_SNORM 0x141
422 #define BRW_SURFACEFORMAT_R8_SINT 0x142
423 #define BRW_SURFACEFORMAT_R8_UINT 0x143
424 #define BRW_SURFACEFORMAT_A8_UNORM 0x144
425 #define BRW_SURFACEFORMAT_I8_UNORM 0x145
426 #define BRW_SURFACEFORMAT_L8_UNORM 0x146
427 #define BRW_SURFACEFORMAT_P4A4_UNORM 0x147
428 #define BRW_SURFACEFORMAT_A4P4_UNORM 0x148
429 #define BRW_SURFACEFORMAT_R8_SSCALED 0x149
430 #define BRW_SURFACEFORMAT_R8_USCALED 0x14A
431 #define BRW_SURFACEFORMAT_P8_UNORM_PALETTE0 0x14B
432 #define BRW_SURFACEFORMAT_L8_UNORM_SRGB 0x14C
433 #define BRW_SURFACEFORMAT_P8_UNORM_PALETTE1 0x14D
434 #define BRW_SURFACEFORMAT_P4A4_UNORM_PALETTE1 0x14E
435 #define BRW_SURFACEFORMAT_A4P4_UNORM_PALETTE1 0x14F
436 #define BRW_SURFACEFORMAT_Y8_SNORM 0x150
437 #define BRW_SURFACEFORMAT_L8_UINT 0x152
438 #define BRW_SURFACEFORMAT_L8_SINT 0x153
439 #define BRW_SURFACEFORMAT_I8_UINT 0x154
440 #define BRW_SURFACEFORMAT_I8_SINT 0x155
441 #define BRW_SURFACEFORMAT_DXT1_RGB_SRGB 0x180
442 #define BRW_SURFACEFORMAT_R1_UINT 0x181
443 #define BRW_SURFACEFORMAT_YCRCB_NORMAL 0x182
444 #define BRW_SURFACEFORMAT_YCRCB_SWAPUVY 0x183
445 #define BRW_SURFACEFORMAT_P2_UNORM_PALETTE0 0x184
446 #define BRW_SURFACEFORMAT_P2_UNORM_PALETTE1 0x185
447 #define BRW_SURFACEFORMAT_BC1_UNORM 0x186
448 #define BRW_SURFACEFORMAT_BC2_UNORM 0x187
449 #define BRW_SURFACEFORMAT_BC3_UNORM 0x188
450 #define BRW_SURFACEFORMAT_BC4_UNORM 0x189
451 #define BRW_SURFACEFORMAT_BC5_UNORM 0x18A
452 #define BRW_SURFACEFORMAT_BC1_UNORM_SRGB 0x18B
453 #define BRW_SURFACEFORMAT_BC2_UNORM_SRGB 0x18C
454 #define BRW_SURFACEFORMAT_BC3_UNORM_SRGB 0x18D
455 #define BRW_SURFACEFORMAT_MONO8 0x18E
456 #define BRW_SURFACEFORMAT_YCRCB_SWAPUV 0x18F
457 #define BRW_SURFACEFORMAT_YCRCB_SWAPY 0x190
458 #define BRW_SURFACEFORMAT_DXT1_RGB 0x191
459 #define BRW_SURFACEFORMAT_FXT1 0x192
460 #define BRW_SURFACEFORMAT_R8G8B8_UNORM 0x193
461 #define BRW_SURFACEFORMAT_R8G8B8_SNORM 0x194
462 #define BRW_SURFACEFORMAT_R8G8B8_SSCALED 0x195
463 #define BRW_SURFACEFORMAT_R8G8B8_USCALED 0x196
464 #define BRW_SURFACEFORMAT_R64G64B64A64_FLOAT 0x197
465 #define BRW_SURFACEFORMAT_R64G64B64_FLOAT 0x198
466 #define BRW_SURFACEFORMAT_BC4_SNORM 0x199
467 #define BRW_SURFACEFORMAT_BC5_SNORM 0x19A
468 #define BRW_SURFACEFORMAT_R16G16B16_FLOAT 0x19B
469 #define BRW_SURFACEFORMAT_R16G16B16_UNORM 0x19C
470 #define BRW_SURFACEFORMAT_R16G16B16_SNORM 0x19D
471 #define BRW_SURFACEFORMAT_R16G16B16_SSCALED 0x19E
472 #define BRW_SURFACEFORMAT_R16G16B16_USCALED 0x19F
473 #define BRW_SURFACEFORMAT_BC6H_SF16 0x1A1
474 #define BRW_SURFACEFORMAT_BC7_UNORM 0x1A2
475 #define BRW_SURFACEFORMAT_BC7_UNORM_SRGB 0x1A3
476 #define BRW_SURFACEFORMAT_BC6H_UF16 0x1A4
477 #define BRW_SURFACEFORMAT_PLANAR_420_8 0x1A5
478 #define BRW_SURFACEFORMAT_R8G8B8_UNORM_SRGB 0x1A8
479 #define BRW_SURFACEFORMAT_ETC1_RGB8 0x1A9
480 #define BRW_SURFACEFORMAT_ETC2_RGB8 0x1AA
481 #define BRW_SURFACEFORMAT_EAC_R11 0x1AB
482 #define BRW_SURFACEFORMAT_EAC_RG11 0x1AC
483 #define BRW_SURFACEFORMAT_EAC_SIGNED_R11 0x1AD
484 #define BRW_SURFACEFORMAT_EAC_SIGNED_RG11 0x1AE
485 #define BRW_SURFACEFORMAT_ETC2_SRGB8 0x1AF
486 #define BRW_SURFACEFORMAT_R16G16B16_UINT 0x1B0
487 #define BRW_SURFACEFORMAT_R16G16B16_SINT 0x1B1
488 #define BRW_SURFACEFORMAT_R32_SFIXED 0x1B2
489 #define BRW_SURFACEFORMAT_R10G10B10A2_SNORM 0x1B3
490 #define BRW_SURFACEFORMAT_R10G10B10A2_USCALED 0x1B4
491 #define BRW_SURFACEFORMAT_R10G10B10A2_SSCALED 0x1B5
492 #define BRW_SURFACEFORMAT_R10G10B10A2_SINT 0x1B6
493 #define BRW_SURFACEFORMAT_B10G10R10A2_SNORM 0x1B7
494 #define BRW_SURFACEFORMAT_B10G10R10A2_USCALED 0x1B8
495 #define BRW_SURFACEFORMAT_B10G10R10A2_SSCALED 0x1B9
496 #define BRW_SURFACEFORMAT_B10G10R10A2_UINT 0x1BA
497 #define BRW_SURFACEFORMAT_B10G10R10A2_SINT 0x1BB
498 #define BRW_SURFACEFORMAT_R64G64B64A64_PASSTHRU 0x1BC
499 #define BRW_SURFACEFORMAT_R64G64B64_PASSTHRU 0x1BD
500 #define BRW_SURFACEFORMAT_ETC2_RGB8_PTA 0x1C0
501 #define BRW_SURFACEFORMAT_ETC2_SRGB8_PTA 0x1C1
502 #define BRW_SURFACEFORMAT_ETC2_EAC_RGBA8 0x1C2
503 #define BRW_SURFACEFORMAT_ETC2_EAC_SRGB8_A8 0x1C3
504 #define BRW_SURFACEFORMAT_R8G8B8_UINT 0x1C8
505 #define BRW_SURFACEFORMAT_R8G8B8_SINT 0x1C9
506 #define BRW_SURFACEFORMAT_RAW 0x1FF
507 #define BRW_SURFACE_FORMAT_SHIFT 18
508 #define BRW_SURFACE_FORMAT_MASK INTEL_MASK(26, 18)
509
510 #define BRW_SURFACERETURNFORMAT_FLOAT32 0
511 #define BRW_SURFACERETURNFORMAT_S1 1
512
513 #define BRW_SURFACE_TYPE_SHIFT 29
514 #define BRW_SURFACE_TYPE_MASK INTEL_MASK(31, 29)
515 #define BRW_SURFACE_1D 0
516 #define BRW_SURFACE_2D 1
517 #define BRW_SURFACE_3D 2
518 #define BRW_SURFACE_CUBE 3
519 #define BRW_SURFACE_BUFFER 4
520 #define BRW_SURFACE_NULL 7
521
522 #define GEN7_SURFACE_IS_ARRAY (1 << 28)
523 #define GEN7_SURFACE_VALIGN_2 (0 << 16)
524 #define GEN7_SURFACE_VALIGN_4 (1 << 16)
525 #define GEN7_SURFACE_HALIGN_4 (0 << 15)
526 #define GEN7_SURFACE_HALIGN_8 (1 << 15)
527 #define GEN7_SURFACE_TILING_NONE (0 << 13)
528 #define GEN7_SURFACE_TILING_X (2 << 13)
529 #define GEN7_SURFACE_TILING_Y (3 << 13)
530 #define GEN7_SURFACE_ARYSPC_FULL (0 << 10)
531 #define GEN7_SURFACE_ARYSPC_LOD0 (1 << 10)
532
533 /* Surface state DW0 */
534 #define GEN8_SURFACE_MOCS_SHIFT 24
535 #define GEN8_SURFACE_MOCS_MASK INTEL_MASK(30, 24)
536
537 /* Surface state DW2 */
538 #define BRW_SURFACE_HEIGHT_SHIFT 19
539 #define BRW_SURFACE_HEIGHT_MASK INTEL_MASK(31, 19)
540 #define BRW_SURFACE_WIDTH_SHIFT 6
541 #define BRW_SURFACE_WIDTH_MASK INTEL_MASK(18, 6)
542 #define BRW_SURFACE_LOD_SHIFT 2
543 #define BRW_SURFACE_LOD_MASK INTEL_MASK(5, 2)
544 #define GEN7_SURFACE_HEIGHT_SHIFT 16
545 #define GEN7_SURFACE_HEIGHT_MASK INTEL_MASK(29, 16)
546 #define GEN7_SURFACE_WIDTH_SHIFT 0
547 #define GEN7_SURFACE_WIDTH_MASK INTEL_MASK(13, 0)
548
549 /* Surface state DW3 */
550 #define BRW_SURFACE_DEPTH_SHIFT 21
551 #define BRW_SURFACE_DEPTH_MASK INTEL_MASK(31, 21)
552 #define BRW_SURFACE_PITCH_SHIFT 3
553 #define BRW_SURFACE_PITCH_MASK INTEL_MASK(19, 3)
554 #define BRW_SURFACE_TILED (1 << 1)
555 #define BRW_SURFACE_TILED_Y (1 << 0)
556 #define HSW_SURFACE_IS_INTEGER_FORMAT (1 << 18)
557
558 /* Surface state DW4 */
559 #define BRW_SURFACE_MIN_LOD_SHIFT 28
560 #define BRW_SURFACE_MIN_LOD_MASK INTEL_MASK(31, 28)
561 #define BRW_SURFACE_MIN_ARRAY_ELEMENT_SHIFT 17
562 #define BRW_SURFACE_MIN_ARRAY_ELEMENT_MASK INTEL_MASK(27, 17)
563 #define BRW_SURFACE_RENDER_TARGET_VIEW_EXTENT_SHIFT 8
564 #define BRW_SURFACE_RENDER_TARGET_VIEW_EXTENT_MASK INTEL_MASK(16, 8)
565 #define BRW_SURFACE_MULTISAMPLECOUNT_1 (0 << 4)
566 #define BRW_SURFACE_MULTISAMPLECOUNT_4 (2 << 4)
567 #define GEN7_SURFACE_MULTISAMPLECOUNT_1 (0 << 3)
568 #define GEN8_SURFACE_MULTISAMPLECOUNT_2 (1 << 3)
569 #define GEN7_SURFACE_MULTISAMPLECOUNT_4 (2 << 3)
570 #define GEN7_SURFACE_MULTISAMPLECOUNT_8 (3 << 3)
571 #define GEN8_SURFACE_MULTISAMPLECOUNT_16 (4 << 3)
572 #define GEN7_SURFACE_MSFMT_MSS (0 << 6)
573 #define GEN7_SURFACE_MSFMT_DEPTH_STENCIL (1 << 6)
574 #define GEN7_SURFACE_MIN_ARRAY_ELEMENT_SHIFT 18
575 #define GEN7_SURFACE_MIN_ARRAY_ELEMENT_MASK INTEL_MASK(28, 18)
576 #define GEN7_SURFACE_RENDER_TARGET_VIEW_EXTENT_SHIFT 7
577 #define GEN7_SURFACE_RENDER_TARGET_VIEW_EXTENT_MASK INTEL_MASK(17, 7)
578
579 /* Surface state DW5 */
580 #define BRW_SURFACE_X_OFFSET_SHIFT 25
581 #define BRW_SURFACE_X_OFFSET_MASK INTEL_MASK(31, 25)
582 #define BRW_SURFACE_VERTICAL_ALIGN_ENABLE (1 << 24)
583 #define BRW_SURFACE_Y_OFFSET_SHIFT 20
584 #define BRW_SURFACE_Y_OFFSET_MASK INTEL_MASK(23, 20)
585 #define GEN7_SURFACE_MIN_LOD_SHIFT 4
586 #define GEN7_SURFACE_MIN_LOD_MASK INTEL_MASK(7, 4)
587 #define GEN8_SURFACE_Y_OFFSET_SHIFT 21
588 #define GEN8_SURFACE_Y_OFFSET_MASK INTEL_MASK(23, 21)
589
590 #define GEN7_SURFACE_MOCS_SHIFT 16
591 #define GEN7_SURFACE_MOCS_MASK INTEL_MASK(19, 16)
592
593 /* Surface state DW6 */
594 #define GEN7_SURFACE_MCS_ENABLE (1 << 0)
595 #define GEN7_SURFACE_MCS_PITCH_SHIFT 3
596 #define GEN7_SURFACE_MCS_PITCH_MASK INTEL_MASK(11, 3)
597 #define GEN8_SURFACE_AUX_QPITCH_SHIFT 16
598 #define GEN8_SURFACE_AUX_QPITCH_MASK INTEL_MASK(30, 16)
599 #define GEN8_SURFACE_AUX_PITCH_SHIFT 3
600 #define GEN8_SURFACE_AUX_PITCH_MASK INTEL_MASK(11, 3)
601 #define GEN8_SURFACE_AUX_MODE_MASK INTEL_MASK(2, 0)
602
603 #define GEN8_SURFACE_AUX_MODE_NONE 0
604 #define GEN8_SURFACE_AUX_MODE_MCS 1
605 #define GEN8_SURFACE_AUX_MODE_APPEND 2
606 #define GEN8_SURFACE_AUX_MODE_HIZ 3
607
608 /* Surface state DW7 */
609 #define GEN7_SURFACE_CLEAR_COLOR_SHIFT 28
610 #define GEN7_SURFACE_SCS_R_SHIFT 25
611 #define GEN7_SURFACE_SCS_R_MASK INTEL_MASK(27, 25)
612 #define GEN7_SURFACE_SCS_G_SHIFT 22
613 #define GEN7_SURFACE_SCS_G_MASK INTEL_MASK(24, 22)
614 #define GEN7_SURFACE_SCS_B_SHIFT 19
615 #define GEN7_SURFACE_SCS_B_MASK INTEL_MASK(21, 19)
616 #define GEN7_SURFACE_SCS_A_SHIFT 16
617 #define GEN7_SURFACE_SCS_A_MASK INTEL_MASK(18, 16)
618
619 /* The actual swizzle values/what channel to use */
620 #define HSW_SCS_ZERO 0
621 #define HSW_SCS_ONE 1
622 #define HSW_SCS_RED 4
623 #define HSW_SCS_GREEN 5
624 #define HSW_SCS_BLUE 6
625 #define HSW_SCS_ALPHA 7
626
627 /* SAMPLER_STATE DW0 */
628 #define BRW_SAMPLER_DISABLE (1 << 31)
629 #define BRW_SAMPLER_LOD_PRECLAMP_ENABLE (1 << 28)
630 #define GEN6_SAMPLER_MIN_MAG_NOT_EQUAL (1 << 27) /* Gen6 only */
631 #define BRW_SAMPLER_BASE_MIPLEVEL_MASK INTEL_MASK(26, 22)
632 #define BRW_SAMPLER_BASE_MIPLEVEL_SHIFT 22
633 #define BRW_SAMPLER_MIP_FILTER_MASK INTEL_MASK(21, 20)
634 #define BRW_SAMPLER_MIP_FILTER_SHIFT 20
635 #define BRW_SAMPLER_MAG_FILTER_MASK INTEL_MASK(19, 17)
636 #define BRW_SAMPLER_MAG_FILTER_SHIFT 17
637 #define BRW_SAMPLER_MIN_FILTER_MASK INTEL_MASK(16, 14)
638 #define BRW_SAMPLER_MIN_FILTER_SHIFT 14
639 #define GEN4_SAMPLER_LOD_BIAS_MASK INTEL_MASK(13, 3)
640 #define GEN4_SAMPLER_LOD_BIAS_SHIFT 3
641 #define GEN4_SAMPLER_SHADOW_FUNCTION_MASK INTEL_MASK(2, 0)
642 #define GEN4_SAMPLER_SHADOW_FUNCTION_SHIFT 0
643
644 #define GEN7_SAMPLER_LOD_BIAS_MASK INTEL_MASK(13, 1)
645 #define GEN7_SAMPLER_LOD_BIAS_SHIFT 1
646 #define GEN7_SAMPLER_EWA_ANISOTROPIC_ALGORITHM (1 << 0)
647
648 /* SAMPLER_STATE DW1 */
649 #define GEN4_SAMPLER_MIN_LOD_MASK INTEL_MASK(31, 22)
650 #define GEN4_SAMPLER_MIN_LOD_SHIFT 22
651 #define GEN4_SAMPLER_MAX_LOD_MASK INTEL_MASK(21, 12)
652 #define GEN4_SAMPLER_MAX_LOD_SHIFT 12
653 #define GEN4_SAMPLER_CUBE_CONTROL_OVERRIDE (1 << 9)
654 /* Wrap modes are in DW1 on Gen4-6 and DW3 on Gen7+ */
655 #define BRW_SAMPLER_TCX_WRAP_MODE_MASK INTEL_MASK(8, 6)
656 #define BRW_SAMPLER_TCX_WRAP_MODE_SHIFT 6
657 #define BRW_SAMPLER_TCY_WRAP_MODE_MASK INTEL_MASK(5, 3)
658 #define BRW_SAMPLER_TCY_WRAP_MODE_SHIFT 3
659 #define BRW_SAMPLER_TCZ_WRAP_MODE_MASK INTEL_MASK(2, 0)
660 #define BRW_SAMPLER_TCZ_WRAP_MODE_SHIFT 0
661
662 #define GEN7_SAMPLER_MIN_LOD_MASK INTEL_MASK(31, 20)
663 #define GEN7_SAMPLER_MIN_LOD_SHIFT 20
664 #define GEN7_SAMPLER_MAX_LOD_MASK INTEL_MASK(19, 8)
665 #define GEN7_SAMPLER_MAX_LOD_SHIFT 8
666 #define GEN7_SAMPLER_SHADOW_FUNCTION_MASK INTEL_MASK(3, 1)
667 #define GEN7_SAMPLER_SHADOW_FUNCTION_SHIFT 1
668 #define GEN7_SAMPLER_CUBE_CONTROL_OVERRIDE (1 << 0)
669
670 /* SAMPLER_STATE DW2 - border color pointer */
671
672 /* SAMPLER_STATE DW3 */
673 #define BRW_SAMPLER_MAX_ANISOTROPY_MASK INTEL_MASK(21, 19)
674 #define BRW_SAMPLER_MAX_ANISOTROPY_SHIFT 19
675 #define BRW_SAMPLER_ADDRESS_ROUNDING_MASK INTEL_MASK(18, 13)
676 #define BRW_SAMPLER_ADDRESS_ROUNDING_SHIFT 13
677 #define GEN7_SAMPLER_NON_NORMALIZED_COORDINATES (1 << 10)
678 /* Gen7+ wrap modes reuse the same BRW_SAMPLER_TC*_WRAP_MODE enums. */
679 #define GEN6_SAMPLER_NON_NORMALIZED_COORDINATES (1 << 0)
680
681 enum brw_wrap_mode {
682 BRW_TEXCOORDMODE_WRAP = 0,
683 BRW_TEXCOORDMODE_MIRROR = 1,
684 BRW_TEXCOORDMODE_CLAMP = 2,
685 BRW_TEXCOORDMODE_CUBE = 3,
686 BRW_TEXCOORDMODE_CLAMP_BORDER = 4,
687 BRW_TEXCOORDMODE_MIRROR_ONCE = 5,
688 GEN8_TEXCOORDMODE_HALF_BORDER = 6,
689 };
690
691 #define BRW_THREAD_PRIORITY_NORMAL 0
692 #define BRW_THREAD_PRIORITY_HIGH 1
693
694 #define BRW_TILEWALK_XMAJOR 0
695 #define BRW_TILEWALK_YMAJOR 1
696
697 #define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS 0
698 #define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS 1
699
700 /* Execution Unit (EU) defines
701 */
702
703 #define BRW_ALIGN_1 0
704 #define BRW_ALIGN_16 1
705
706 #define BRW_ADDRESS_DIRECT 0
707 #define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER 1
708
709 #define BRW_CHANNEL_X 0
710 #define BRW_CHANNEL_Y 1
711 #define BRW_CHANNEL_Z 2
712 #define BRW_CHANNEL_W 3
713
714 enum brw_compression {
715 BRW_COMPRESSION_NONE = 0,
716 BRW_COMPRESSION_2NDHALF = 1,
717 BRW_COMPRESSION_COMPRESSED = 2,
718 };
719
720 #define GEN6_COMPRESSION_1Q 0
721 #define GEN6_COMPRESSION_2Q 1
722 #define GEN6_COMPRESSION_3Q 2
723 #define GEN6_COMPRESSION_4Q 3
724 #define GEN6_COMPRESSION_1H 0
725 #define GEN6_COMPRESSION_2H 2
726
727 enum PACKED brw_conditional_mod {
728 BRW_CONDITIONAL_NONE = 0,
729 BRW_CONDITIONAL_Z = 1,
730 BRW_CONDITIONAL_NZ = 2,
731 BRW_CONDITIONAL_EQ = 1, /* Z */
732 BRW_CONDITIONAL_NEQ = 2, /* NZ */
733 BRW_CONDITIONAL_G = 3,
734 BRW_CONDITIONAL_GE = 4,
735 BRW_CONDITIONAL_L = 5,
736 BRW_CONDITIONAL_LE = 6,
737 BRW_CONDITIONAL_R = 7, /* Gen <= 5 */
738 BRW_CONDITIONAL_O = 8,
739 BRW_CONDITIONAL_U = 9,
740 };
741
742 #define BRW_DEBUG_NONE 0
743 #define BRW_DEBUG_BREAKPOINT 1
744
745 #define BRW_DEPENDENCY_NORMAL 0
746 #define BRW_DEPENDENCY_NOTCLEARED 1
747 #define BRW_DEPENDENCY_NOTCHECKED 2
748 #define BRW_DEPENDENCY_DISABLE 3
749
750 enum PACKED brw_execution_size {
751 BRW_EXECUTE_1 = 0,
752 BRW_EXECUTE_2 = 1,
753 BRW_EXECUTE_4 = 2,
754 BRW_EXECUTE_8 = 3,
755 BRW_EXECUTE_16 = 4,
756 BRW_EXECUTE_32 = 5,
757 };
758
759 enum PACKED brw_horizontal_stride {
760 BRW_HORIZONTAL_STRIDE_0 = 0,
761 BRW_HORIZONTAL_STRIDE_1 = 1,
762 BRW_HORIZONTAL_STRIDE_2 = 2,
763 BRW_HORIZONTAL_STRIDE_4 = 3,
764 };
765
766 #define BRW_INSTRUCTION_NORMAL 0
767 #define BRW_INSTRUCTION_SATURATE 1
768
769 #define BRW_MASK_ENABLE 0
770 #define BRW_MASK_DISABLE 1
771
772 /** @{
773 *
774 * Gen6 has replaced "mask enable/disable" with WECtrl, which is
775 * effectively the same but much simpler to think about. Now, there
776 * are two contributors ANDed together to whether channels are
777 * executed: The predication on the instruction, and the channel write
778 * enable.
779 */
780 /**
781 * This is the default value. It means that a channel's write enable is set
782 * if the per-channel IP is pointing at this instruction.
783 */
784 #define BRW_WE_NORMAL 0
785 /**
786 * This is used like BRW_MASK_DISABLE, and causes all channels to have
787 * their write enable set. Note that predication still contributes to
788 * whether the channel actually gets written.
789 */
790 #define BRW_WE_ALL 1
791 /** @} */
792
793 enum opcode {
794 /* These are the actual hardware opcodes. */
795 BRW_OPCODE_MOV = 1,
796 BRW_OPCODE_SEL = 2,
797 BRW_OPCODE_NOT = 4,
798 BRW_OPCODE_AND = 5,
799 BRW_OPCODE_OR = 6,
800 BRW_OPCODE_XOR = 7,
801 BRW_OPCODE_SHR = 8,
802 BRW_OPCODE_SHL = 9,
803 BRW_OPCODE_ASR = 12,
804 BRW_OPCODE_CMP = 16,
805 BRW_OPCODE_CMPN = 17,
806 BRW_OPCODE_CSEL = 18, /**< Gen8+ */
807 BRW_OPCODE_F32TO16 = 19, /**< Gen7 only */
808 BRW_OPCODE_F16TO32 = 20, /**< Gen7 only */
809 BRW_OPCODE_BFREV = 23, /**< Gen7+ */
810 BRW_OPCODE_BFE = 24, /**< Gen7+ */
811 BRW_OPCODE_BFI1 = 25, /**< Gen7+ */
812 BRW_OPCODE_BFI2 = 26, /**< Gen7+ */
813 BRW_OPCODE_JMPI = 32,
814 BRW_OPCODE_IF = 34,
815 BRW_OPCODE_IFF = 35, /**< Pre-Gen6 */
816 BRW_OPCODE_ELSE = 36,
817 BRW_OPCODE_ENDIF = 37,
818 BRW_OPCODE_DO = 38,
819 BRW_OPCODE_WHILE = 39,
820 BRW_OPCODE_BREAK = 40,
821 BRW_OPCODE_CONTINUE = 41,
822 BRW_OPCODE_HALT = 42,
823 BRW_OPCODE_MSAVE = 44, /**< Pre-Gen6 */
824 BRW_OPCODE_MRESTORE = 45, /**< Pre-Gen6 */
825 BRW_OPCODE_PUSH = 46, /**< Pre-Gen6 */
826 BRW_OPCODE_GOTO = 46, /**< Gen8+ */
827 BRW_OPCODE_POP = 47, /**< Pre-Gen6 */
828 BRW_OPCODE_WAIT = 48,
829 BRW_OPCODE_SEND = 49,
830 BRW_OPCODE_SENDC = 50,
831 BRW_OPCODE_MATH = 56, /**< Gen6+ */
832 BRW_OPCODE_ADD = 64,
833 BRW_OPCODE_MUL = 65,
834 BRW_OPCODE_AVG = 66,
835 BRW_OPCODE_FRC = 67,
836 BRW_OPCODE_RNDU = 68,
837 BRW_OPCODE_RNDD = 69,
838 BRW_OPCODE_RNDE = 70,
839 BRW_OPCODE_RNDZ = 71,
840 BRW_OPCODE_MAC = 72,
841 BRW_OPCODE_MACH = 73,
842 BRW_OPCODE_LZD = 74,
843 BRW_OPCODE_FBH = 75, /**< Gen7+ */
844 BRW_OPCODE_FBL = 76, /**< Gen7+ */
845 BRW_OPCODE_CBIT = 77, /**< Gen7+ */
846 BRW_OPCODE_ADDC = 78, /**< Gen7+ */
847 BRW_OPCODE_SUBB = 79, /**< Gen7+ */
848 BRW_OPCODE_SAD2 = 80,
849 BRW_OPCODE_SADA2 = 81,
850 BRW_OPCODE_DP4 = 84,
851 BRW_OPCODE_DPH = 85,
852 BRW_OPCODE_DP3 = 86,
853 BRW_OPCODE_DP2 = 87,
854 BRW_OPCODE_LINE = 89,
855 BRW_OPCODE_PLN = 90, /**< G45+ */
856 BRW_OPCODE_MAD = 91, /**< Gen6+ */
857 BRW_OPCODE_LRP = 92, /**< Gen6+ */
858 BRW_OPCODE_NENOP = 125, /**< G45 only */
859 BRW_OPCODE_NOP = 126,
860
861 /* These are compiler backend opcodes that get translated into other
862 * instructions.
863 */
864 FS_OPCODE_FB_WRITE = 128,
865 FS_OPCODE_BLORP_FB_WRITE,
866 FS_OPCODE_REP_FB_WRITE,
867 SHADER_OPCODE_RCP,
868 SHADER_OPCODE_RSQ,
869 SHADER_OPCODE_SQRT,
870 SHADER_OPCODE_EXP2,
871 SHADER_OPCODE_LOG2,
872 SHADER_OPCODE_POW,
873 SHADER_OPCODE_INT_QUOTIENT,
874 SHADER_OPCODE_INT_REMAINDER,
875 SHADER_OPCODE_SIN,
876 SHADER_OPCODE_COS,
877
878 SHADER_OPCODE_TEX,
879 SHADER_OPCODE_TXD,
880 SHADER_OPCODE_TXF,
881 SHADER_OPCODE_TXL,
882 SHADER_OPCODE_TXS,
883 FS_OPCODE_TXB,
884 SHADER_OPCODE_TXF_CMS,
885 SHADER_OPCODE_TXF_UMS,
886 SHADER_OPCODE_TXF_MCS,
887 SHADER_OPCODE_LOD,
888 SHADER_OPCODE_TG4,
889 SHADER_OPCODE_TG4_OFFSET,
890
891 /**
892 * Combines multiple sources of size 1 into a larger virtual GRF.
893 * For example, parameters for a send-from-GRF message. Or, updating
894 * channels of a size 4 VGRF used to store vec4s such as texturing results.
895 *
896 * This will be lowered into MOVs from each source to consecutive reg_offsets
897 * of the destination VGRF.
898 *
899 * src[0] may be BAD_FILE. If so, the lowering pass skips emitting the MOV,
900 * but still reserves the first channel of the destination VGRF. This can be
901 * used to reserve space for, say, a message header set up by the generators.
902 */
903 SHADER_OPCODE_LOAD_PAYLOAD,
904
905 SHADER_OPCODE_SHADER_TIME_ADD,
906
907 SHADER_OPCODE_UNTYPED_ATOMIC,
908 SHADER_OPCODE_UNTYPED_SURFACE_READ,
909 SHADER_OPCODE_UNTYPED_SURFACE_WRITE,
910
911 SHADER_OPCODE_TYPED_ATOMIC,
912 SHADER_OPCODE_TYPED_SURFACE_READ,
913 SHADER_OPCODE_TYPED_SURFACE_WRITE,
914
915 SHADER_OPCODE_MEMORY_FENCE,
916
917 SHADER_OPCODE_GEN4_SCRATCH_READ,
918 SHADER_OPCODE_GEN4_SCRATCH_WRITE,
919 SHADER_OPCODE_GEN7_SCRATCH_READ,
920
921 SHADER_OPCODE_URB_WRITE_SIMD8,
922
923 /**
924 * Return the index of an arbitrary live channel (i.e. one of the channels
925 * enabled in the current execution mask) and assign it to the first
926 * component of the destination. Expected to be used as input for the
927 * BROADCAST pseudo-opcode.
928 */
929 SHADER_OPCODE_FIND_LIVE_CHANNEL,
930
931 /**
932 * Pick the channel from its first source register given by the index
933 * specified as second source. Useful for variable indexing of surfaces.
934 */
935 SHADER_OPCODE_BROADCAST,
936
937 VEC4_OPCODE_MOV_BYTES,
938 VEC4_OPCODE_PACK_BYTES,
939 VEC4_OPCODE_UNPACK_UNIFORM,
940
941 FS_OPCODE_DDX_COARSE,
942 FS_OPCODE_DDX_FINE,
943 /**
944 * Compute dFdy(), dFdyCoarse(), or dFdyFine().
945 * src1 is an immediate storing the key->render_to_fbo boolean.
946 */
947 FS_OPCODE_DDY_COARSE,
948 FS_OPCODE_DDY_FINE,
949 FS_OPCODE_CINTERP,
950 FS_OPCODE_LINTERP,
951 FS_OPCODE_PIXEL_X,
952 FS_OPCODE_PIXEL_Y,
953 FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD,
954 FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7,
955 FS_OPCODE_VARYING_PULL_CONSTANT_LOAD,
956 FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7,
957 FS_OPCODE_MOV_DISPATCH_TO_FLAGS,
958 FS_OPCODE_DISCARD_JUMP,
959 FS_OPCODE_SET_OMASK,
960 FS_OPCODE_SET_SAMPLE_ID,
961 FS_OPCODE_SET_SIMD4X2_OFFSET,
962 FS_OPCODE_PACK_HALF_2x16_SPLIT,
963 FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X,
964 FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y,
965 FS_OPCODE_PLACEHOLDER_HALT,
966 FS_OPCODE_INTERPOLATE_AT_CENTROID,
967 FS_OPCODE_INTERPOLATE_AT_SAMPLE,
968 FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET,
969 FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET,
970
971 VS_OPCODE_URB_WRITE,
972 VS_OPCODE_PULL_CONSTANT_LOAD,
973 VS_OPCODE_PULL_CONSTANT_LOAD_GEN7,
974 VS_OPCODE_SET_SIMD4X2_HEADER_GEN9,
975 VS_OPCODE_UNPACK_FLAGS_SIMD4X2,
976
977 /**
978 * Write geometry shader output data to the URB.
979 *
980 * Unlike VS_OPCODE_URB_WRITE, this opcode doesn't do an implied move from
981 * R0 to the first MRF. This allows the geometry shader to override the
982 * "Slot {0,1} Offset" fields in the message header.
983 */
984 GS_OPCODE_URB_WRITE,
985
986 /**
987 * Write geometry shader output data to the URB and request a new URB
988 * handle (gen6).
989 *
990 * This opcode doesn't do an implied move from R0 to the first MRF.
991 */
992 GS_OPCODE_URB_WRITE_ALLOCATE,
993
994 /**
995 * Terminate the geometry shader thread by doing an empty URB write.
996 *
997 * This opcode doesn't do an implied move from R0 to the first MRF. This
998 * allows the geometry shader to override the "GS Number of Output Vertices
999 * for Slot {0,1}" fields in the message header.
1000 */
1001 GS_OPCODE_THREAD_END,
1002
1003 /**
1004 * Set the "Slot {0,1} Offset" fields of a URB_WRITE message header.
1005 *
1006 * - dst is the MRF containing the message header.
1007 *
1008 * - src0.x indicates which portion of the URB should be written to (e.g. a
1009 * vertex number)
1010 *
1011 * - src1 is an immediate multiplier which will be applied to src0
1012 * (e.g. the size of a single vertex in the URB).
1013 *
1014 * Note: the hardware will apply this offset *in addition to* the offset in
1015 * vec4_instruction::offset.
1016 */
1017 GS_OPCODE_SET_WRITE_OFFSET,
1018
1019 /**
1020 * Set the "GS Number of Output Vertices for Slot {0,1}" fields of a
1021 * URB_WRITE message header.
1022 *
1023 * - dst is the MRF containing the message header.
1024 *
1025 * - src0.x is the vertex count. The upper 16 bits will be ignored.
1026 */
1027 GS_OPCODE_SET_VERTEX_COUNT,
1028
1029 /**
1030 * Set DWORD 2 of dst to the value in src.
1031 */
1032 GS_OPCODE_SET_DWORD_2,
1033
1034 /**
1035 * Prepare the dst register for storage in the "Channel Mask" fields of a
1036 * URB_WRITE message header.
1037 *
1038 * DWORD 4 of dst is shifted left by 4 bits, so that later,
1039 * GS_OPCODE_SET_CHANNEL_MASKS can OR DWORDs 0 and 4 together to form the
1040 * final channel mask.
1041 *
1042 * Note: since GS_OPCODE_SET_CHANNEL_MASKS ORs DWORDs 0 and 4 together to
1043 * form the final channel mask, DWORDs 0 and 4 of the dst register must not
1044 * have any extraneous bits set prior to execution of this opcode (that is,
1045 * they should be in the range 0x0 to 0xf).
1046 */
1047 GS_OPCODE_PREPARE_CHANNEL_MASKS,
1048
1049 /**
1050 * Set the "Channel Mask" fields of a URB_WRITE message header.
1051 *
1052 * - dst is the MRF containing the message header.
1053 *
1054 * - src.x is the channel mask, as prepared by
1055 * GS_OPCODE_PREPARE_CHANNEL_MASKS. DWORDs 0 and 4 are OR'ed together to
1056 * form the final channel mask.
1057 */
1058 GS_OPCODE_SET_CHANNEL_MASKS,
1059
1060 /**
1061 * Get the "Instance ID" fields from the payload.
1062 *
1063 * - dst is the GRF for gl_InvocationID.
1064 */
1065 GS_OPCODE_GET_INSTANCE_ID,
1066
1067 /**
1068 * Send a FF_SYNC message to allocate initial URB handles (gen6).
1069 *
1070 * - dst will be used as the writeback register for the FF_SYNC operation.
1071 *
1072 * - src0 is the number of primitives written.
1073 *
1074 * - src1 is the value to hold in M0.0: number of SO vertices to write
1075 * and number of SO primitives needed. Its value will be overwritten
1076 * with the SVBI values if transform feedback is enabled.
1077 *
1078 * Note: This opcode uses an implicit MRF register for the ff_sync message
1079 * header, so the caller is expected to set inst->base_mrf and initialize
1080 * that MRF register to r0. This opcode will also write to this MRF register
1081 * to include the allocated URB handle so it can then be reused directly as
1082 * the header in the URB write operation we are allocating the handle for.
1083 */
1084 GS_OPCODE_FF_SYNC,
1085
1086 /**
1087 * Move r0.1 (which holds PrimitiveID information in gen6) to a separate
1088 * register.
1089 *
1090 * - dst is the GRF where PrimitiveID information will be moved.
1091 */
1092 GS_OPCODE_SET_PRIMITIVE_ID,
1093
1094 /**
1095 * Write transform feedback data to the SVB by sending a SVB WRITE message.
1096 * Used in gen6.
1097 *
1098 * - dst is the MRF register containing the message header.
1099 *
1100 * - src0 is the register where the vertex data is going to be copied from.
1101 *
1102 * - src1 is the destination register when write commit occurs.
1103 */
1104 GS_OPCODE_SVB_WRITE,
1105
1106 /**
1107 * Set destination index in the SVB write message payload (M0.5). Used
1108 * in gen6 for transform feedback.
1109 *
1110 * - dst is the header to save the destination indices for SVB WRITE.
1111 * - src is the register that holds the destination indices value.
1112 */
1113 GS_OPCODE_SVB_SET_DST_INDEX,
1114
1115 /**
1116 * Prepare Mx.0 subregister for being used in the FF_SYNC message header.
1117 * Used in gen6 for transform feedback.
1118 *
1119 * - dst will hold the register with the final Mx.0 value.
1120 *
1121 * - src0 has the number of vertices emitted in SO (NumSOVertsToWrite)
1122 *
1123 * - src1 has the number of needed primitives for SO (NumSOPrimsNeeded)
1124 *
1125 * - src2 is the value to hold in M0: number of SO vertices to write
1126 * and number of SO primitives needed.
1127 */
1128 GS_OPCODE_FF_SYNC_SET_PRIMITIVES,
1129
1130 /**
1131 * Terminate the compute shader.
1132 */
1133 CS_OPCODE_CS_TERMINATE,
1134 };
1135
1136 enum brw_urb_write_flags {
1137 BRW_URB_WRITE_NO_FLAGS = 0,
1138
1139 /**
1140 * Causes a new URB entry to be allocated, and its address stored in the
1141 * destination register (gen < 7).
1142 */
1143 BRW_URB_WRITE_ALLOCATE = 0x1,
1144
1145 /**
1146 * Causes the current URB entry to be deallocated (gen < 7).
1147 */
1148 BRW_URB_WRITE_UNUSED = 0x2,
1149
1150 /**
1151 * Causes the thread to terminate.
1152 */
1153 BRW_URB_WRITE_EOT = 0x4,
1154
1155 /**
1156 * Indicates that the given URB entry is complete, and may be sent further
1157 * down the 3D pipeline (gen < 7).
1158 */
1159 BRW_URB_WRITE_COMPLETE = 0x8,
1160
1161 /**
1162 * Indicates that an additional offset (which may be different for the two
1163 * vec4 slots) is stored in the message header (gen == 7).
1164 */
1165 BRW_URB_WRITE_PER_SLOT_OFFSET = 0x10,
1166
1167 /**
1168 * Indicates that the channel masks in the URB_WRITE message header should
1169 * not be overridden to 0xff (gen == 7).
1170 */
1171 BRW_URB_WRITE_USE_CHANNEL_MASKS = 0x20,
1172
1173 /**
1174 * Indicates that the data should be sent to the URB using the
1175 * URB_WRITE_OWORD message rather than URB_WRITE_HWORD (gen == 7). This
1176 * causes offsets to be interpreted as multiples of an OWORD instead of an
1177 * HWORD, and only allows one OWORD to be written.
1178 */
1179 BRW_URB_WRITE_OWORD = 0x40,
1180
1181 /**
1182 * Convenient combination of flags: end the thread while simultaneously
1183 * marking the given URB entry as complete.
1184 */
1185 BRW_URB_WRITE_EOT_COMPLETE = BRW_URB_WRITE_EOT | BRW_URB_WRITE_COMPLETE,
1186
1187 /**
1188 * Convenient combination of flags: mark the given URB entry as complete
1189 * and simultaneously allocate a new one.
1190 */
1191 BRW_URB_WRITE_ALLOCATE_COMPLETE =
1192 BRW_URB_WRITE_ALLOCATE | BRW_URB_WRITE_COMPLETE,
1193 };
1194
1195 #ifdef __cplusplus
1196 /**
1197 * Allow brw_urb_write_flags enums to be ORed together.
1198 */
1199 inline brw_urb_write_flags
1200 operator|(brw_urb_write_flags x, brw_urb_write_flags y)
1201 {
1202 return static_cast<brw_urb_write_flags>(static_cast<int>(x) |
1203 static_cast<int>(y));
1204 }
1205 #endif
1206
1207 enum PACKED brw_predicate {
1208 BRW_PREDICATE_NONE = 0,
1209 BRW_PREDICATE_NORMAL = 1,
1210 BRW_PREDICATE_ALIGN1_ANYV = 2,
1211 BRW_PREDICATE_ALIGN1_ALLV = 3,
1212 BRW_PREDICATE_ALIGN1_ANY2H = 4,
1213 BRW_PREDICATE_ALIGN1_ALL2H = 5,
1214 BRW_PREDICATE_ALIGN1_ANY4H = 6,
1215 BRW_PREDICATE_ALIGN1_ALL4H = 7,
1216 BRW_PREDICATE_ALIGN1_ANY8H = 8,
1217 BRW_PREDICATE_ALIGN1_ALL8H = 9,
1218 BRW_PREDICATE_ALIGN1_ANY16H = 10,
1219 BRW_PREDICATE_ALIGN1_ALL16H = 11,
1220 BRW_PREDICATE_ALIGN1_ANY32H = 12,
1221 BRW_PREDICATE_ALIGN1_ALL32H = 13,
1222 BRW_PREDICATE_ALIGN16_REPLICATE_X = 2,
1223 BRW_PREDICATE_ALIGN16_REPLICATE_Y = 3,
1224 BRW_PREDICATE_ALIGN16_REPLICATE_Z = 4,
1225 BRW_PREDICATE_ALIGN16_REPLICATE_W = 5,
1226 BRW_PREDICATE_ALIGN16_ANY4H = 6,
1227 BRW_PREDICATE_ALIGN16_ALL4H = 7,
1228 };
1229
1230 #define BRW_ARCHITECTURE_REGISTER_FILE 0
1231 #define BRW_GENERAL_REGISTER_FILE 1
1232 #define BRW_MESSAGE_REGISTER_FILE 2
1233 #define BRW_IMMEDIATE_VALUE 3
1234
1235 #define BRW_HW_REG_TYPE_UD 0
1236 #define BRW_HW_REG_TYPE_D 1
1237 #define BRW_HW_REG_TYPE_UW 2
1238 #define BRW_HW_REG_TYPE_W 3
1239 #define BRW_HW_REG_TYPE_F 7
1240 #define GEN8_HW_REG_TYPE_UQ 8
1241 #define GEN8_HW_REG_TYPE_Q 9
1242
1243 #define BRW_HW_REG_NON_IMM_TYPE_UB 4
1244 #define BRW_HW_REG_NON_IMM_TYPE_B 5
1245 #define GEN7_HW_REG_NON_IMM_TYPE_DF 6
1246 #define GEN8_HW_REG_NON_IMM_TYPE_HF 10
1247
1248 #define BRW_HW_REG_IMM_TYPE_UV 4 /* Gen6+ packed unsigned immediate vector */
1249 #define BRW_HW_REG_IMM_TYPE_VF 5 /* packed float immediate vector */
1250 #define BRW_HW_REG_IMM_TYPE_V 6 /* packed int imm. vector; uword dest only */
1251 #define GEN8_HW_REG_IMM_TYPE_DF 10
1252 #define GEN8_HW_REG_IMM_TYPE_HF 11
1253
1254 /* SNB adds 3-src instructions (MAD and LRP) that only operate on floats, so
1255 * the types were implied. IVB adds BFE and BFI2 that operate on doublewords
1256 * and unsigned doublewords, so a new field is also available in the da3src
1257 * struct (part of struct brw_instruction.bits1 in brw_structs.h) to select
1258 * dst and shared-src types. The values are different from BRW_REGISTER_TYPE_*.
1259 */
1260 #define BRW_3SRC_TYPE_F 0
1261 #define BRW_3SRC_TYPE_D 1
1262 #define BRW_3SRC_TYPE_UD 2
1263 #define BRW_3SRC_TYPE_DF 3
1264
1265 #define BRW_ARF_NULL 0x00
1266 #define BRW_ARF_ADDRESS 0x10
1267 #define BRW_ARF_ACCUMULATOR 0x20
1268 #define BRW_ARF_FLAG 0x30
1269 #define BRW_ARF_MASK 0x40
1270 #define BRW_ARF_MASK_STACK 0x50
1271 #define BRW_ARF_MASK_STACK_DEPTH 0x60
1272 #define BRW_ARF_STATE 0x70
1273 #define BRW_ARF_CONTROL 0x80
1274 #define BRW_ARF_NOTIFICATION_COUNT 0x90
1275 #define BRW_ARF_IP 0xA0
1276 #define BRW_ARF_TDR 0xB0
1277 #define BRW_ARF_TIMESTAMP 0xC0
1278
1279 #define BRW_MRF_COMPR4 (1 << 7)
1280
1281 #define BRW_AMASK 0
1282 #define BRW_IMASK 1
1283 #define BRW_LMASK 2
1284 #define BRW_CMASK 3
1285
1286
1287
1288 #define BRW_THREAD_NORMAL 0
1289 #define BRW_THREAD_ATOMIC 1
1290 #define BRW_THREAD_SWITCH 2
1291
1292 enum PACKED brw_vertical_stride {
1293 BRW_VERTICAL_STRIDE_0 = 0,
1294 BRW_VERTICAL_STRIDE_1 = 1,
1295 BRW_VERTICAL_STRIDE_2 = 2,
1296 BRW_VERTICAL_STRIDE_4 = 3,
1297 BRW_VERTICAL_STRIDE_8 = 4,
1298 BRW_VERTICAL_STRIDE_16 = 5,
1299 BRW_VERTICAL_STRIDE_32 = 6,
1300 BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL = 0xF,
1301 };
1302
1303 enum PACKED brw_width {
1304 BRW_WIDTH_1 = 0,
1305 BRW_WIDTH_2 = 1,
1306 BRW_WIDTH_4 = 2,
1307 BRW_WIDTH_8 = 3,
1308 BRW_WIDTH_16 = 4,
1309 };
1310
1311 #define BRW_STATELESS_BUFFER_BOUNDARY_1K 0
1312 #define BRW_STATELESS_BUFFER_BOUNDARY_2K 1
1313 #define BRW_STATELESS_BUFFER_BOUNDARY_4K 2
1314 #define BRW_STATELESS_BUFFER_BOUNDARY_8K 3
1315 #define BRW_STATELESS_BUFFER_BOUNDARY_16K 4
1316 #define BRW_STATELESS_BUFFER_BOUNDARY_32K 5
1317 #define BRW_STATELESS_BUFFER_BOUNDARY_64K 6
1318 #define BRW_STATELESS_BUFFER_BOUNDARY_128K 7
1319 #define BRW_STATELESS_BUFFER_BOUNDARY_256K 8
1320 #define BRW_STATELESS_BUFFER_BOUNDARY_512K 9
1321 #define BRW_STATELESS_BUFFER_BOUNDARY_1M 10
1322 #define BRW_STATELESS_BUFFER_BOUNDARY_2M 11
1323
1324 #define BRW_POLYGON_FACING_FRONT 0
1325 #define BRW_POLYGON_FACING_BACK 1
1326
1327 /**
1328 * Message target: Shared Function ID for where to SEND a message.
1329 *
1330 * These are enumerated in the ISA reference under "send - Send Message".
1331 * In particular, see the following tables:
1332 * - G45 PRM, Volume 4, Table 14-15 "Message Descriptor Definition"
1333 * - Sandybridge PRM, Volume 4 Part 2, Table 8-16 "Extended Message Descriptor"
1334 * - Ivybridge PRM, Volume 1 Part 1, section 3.2.7 "GPE Function IDs"
1335 */
1336 enum brw_message_target {
1337 BRW_SFID_NULL = 0,
1338 BRW_SFID_MATH = 1, /* Only valid on Gen4-5 */
1339 BRW_SFID_SAMPLER = 2,
1340 BRW_SFID_MESSAGE_GATEWAY = 3,
1341 BRW_SFID_DATAPORT_READ = 4,
1342 BRW_SFID_DATAPORT_WRITE = 5,
1343 BRW_SFID_URB = 6,
1344 BRW_SFID_THREAD_SPAWNER = 7,
1345 BRW_SFID_VME = 8,
1346
1347 GEN6_SFID_DATAPORT_SAMPLER_CACHE = 4,
1348 GEN6_SFID_DATAPORT_RENDER_CACHE = 5,
1349 GEN6_SFID_DATAPORT_CONSTANT_CACHE = 9,
1350
1351 GEN7_SFID_DATAPORT_DATA_CACHE = 10,
1352 GEN7_SFID_PIXEL_INTERPOLATOR = 11,
1353 HSW_SFID_DATAPORT_DATA_CACHE_1 = 12,
1354 HSW_SFID_CRE = 13,
1355 };
1356
1357 #define GEN7_MESSAGE_TARGET_DP_DATA_CACHE 10
1358
1359 #define BRW_SAMPLER_RETURN_FORMAT_FLOAT32 0
1360 #define BRW_SAMPLER_RETURN_FORMAT_UINT32 2
1361 #define BRW_SAMPLER_RETURN_FORMAT_SINT32 3
1362
1363 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE 0
1364 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE 0
1365 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS 0
1366 #define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX 1
1367 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD 1
1368 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD 1
1369 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS 2
1370 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS 2
1371 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE 0
1372 #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE 2
1373 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE 0
1374 #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD_COMPARE 1
1375 #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE 1
1376 #define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO 2
1377 #define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO 2
1378 #define BRW_SAMPLER_MESSAGE_SIMD4X2_LD 3
1379 #define BRW_SAMPLER_MESSAGE_SIMD8_LD 3
1380 #define BRW_SAMPLER_MESSAGE_SIMD16_LD 3
1381
1382 #define GEN5_SAMPLER_MESSAGE_SAMPLE 0
1383 #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS 1
1384 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD 2
1385 #define GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE 3
1386 #define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS 4
1387 #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
1388 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE 6
1389 #define GEN5_SAMPLER_MESSAGE_SAMPLE_LD 7
1390 #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4 8
1391 #define GEN5_SAMPLER_MESSAGE_LOD 9
1392 #define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO 10
1393 #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4_C 16
1394 #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4_PO 17
1395 #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4_PO_C 18
1396 #define HSW_SAMPLER_MESSAGE_SAMPLE_DERIV_COMPARE 20
1397 #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD_MCS 29
1398 #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DMS 30
1399 #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DSS 31
1400
1401 /* for GEN5 only */
1402 #define BRW_SAMPLER_SIMD_MODE_SIMD4X2 0
1403 #define BRW_SAMPLER_SIMD_MODE_SIMD8 1
1404 #define BRW_SAMPLER_SIMD_MODE_SIMD16 2
1405 #define BRW_SAMPLER_SIMD_MODE_SIMD32_64 3
1406
1407 /* GEN9 changes SIMD mode 0 to mean SIMD8D, but lets us get the SIMD4x2
1408 * behavior by setting bit 22 of dword 2 in the message header. */
1409 #define GEN9_SAMPLER_SIMD_MODE_SIMD8D 0
1410 #define GEN9_SAMPLER_SIMD_MODE_EXTENSION_SIMD4X2 (1 << 22)
1411
1412 #define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW 0
1413 #define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH 1
1414 #define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS 2
1415 #define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS 3
1416 #define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS 4
1417
1418 #define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD 0
1419 #define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS 2
1420
1421 #define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS 2
1422 #define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS 3
1423
1424 /* This one stays the same across generations. */
1425 #define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ 0
1426 /* GEN4 */
1427 #define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 1
1428 #define BRW_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ 2
1429 #define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 3
1430 /* G45, GEN5 */
1431 #define G45_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ 1
1432 #define G45_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 2
1433 #define G45_DATAPORT_READ_MESSAGE_AVC_LOOP_FILTER_READ 3
1434 #define G45_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ 4
1435 #define G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 6
1436 /* GEN6 */
1437 #define GEN6_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ 1
1438 #define GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 2
1439 #define GEN6_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ 4
1440 #define GEN6_DATAPORT_READ_MESSAGE_OWORD_UNALIGN_BLOCK_READ 5
1441 #define GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 6
1442
1443 #define BRW_DATAPORT_READ_TARGET_DATA_CACHE 0
1444 #define BRW_DATAPORT_READ_TARGET_RENDER_CACHE 1
1445 #define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE 2
1446
1447 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE 0
1448 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED 1
1449 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01 2
1450 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23 3
1451 #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01 4
1452
1453 #define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 0
1454 #define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 1
1455 #define BRW_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE 2
1456 #define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 3
1457 #define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 4
1458 #define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE 5
1459 #define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE 7
1460
1461 /* GEN6 */
1462 #define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_ATOMIC_WRITE 7
1463 #define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 8
1464 #define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 9
1465 #define GEN6_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE 10
1466 #define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 11
1467 #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 12
1468 #define GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VB_WRITE 13
1469 #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_UNORM_WRITE 14
1470
1471 /* GEN7 */
1472 #define GEN7_DATAPORT_RC_MEDIA_BLOCK_READ 4
1473 #define GEN7_DATAPORT_RC_TYPED_SURFACE_READ 5
1474 #define GEN7_DATAPORT_RC_TYPED_ATOMIC_OP 6
1475 #define GEN7_DATAPORT_RC_MEMORY_FENCE 7
1476 #define GEN7_DATAPORT_RC_MEDIA_BLOCK_WRITE 10
1477 #define GEN7_DATAPORT_RC_RENDER_TARGET_WRITE 12
1478 #define GEN7_DATAPORT_RC_TYPED_SURFACE_WRITE 13
1479 #define GEN7_DATAPORT_DC_OWORD_BLOCK_READ 0
1480 #define GEN7_DATAPORT_DC_UNALIGNED_OWORD_BLOCK_READ 1
1481 #define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_READ 2
1482 #define GEN7_DATAPORT_DC_DWORD_SCATTERED_READ 3
1483 #define GEN7_DATAPORT_DC_BYTE_SCATTERED_READ 4
1484 #define GEN7_DATAPORT_DC_UNTYPED_SURFACE_READ 5
1485 #define GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP 6
1486 #define GEN7_DATAPORT_DC_MEMORY_FENCE 7
1487 #define GEN7_DATAPORT_DC_OWORD_BLOCK_WRITE 8
1488 #define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_WRITE 10
1489 #define GEN7_DATAPORT_DC_DWORD_SCATTERED_WRITE 11
1490 #define GEN7_DATAPORT_DC_BYTE_SCATTERED_WRITE 12
1491 #define GEN7_DATAPORT_DC_UNTYPED_SURFACE_WRITE 13
1492
1493 #define GEN7_DATAPORT_SCRATCH_READ ((1 << 18) | \
1494 (0 << 17))
1495 #define GEN7_DATAPORT_SCRATCH_WRITE ((1 << 18) | \
1496 (1 << 17))
1497 #define GEN7_DATAPORT_SCRATCH_NUM_REGS_SHIFT 12
1498
1499 #define GEN7_PIXEL_INTERPOLATOR_LOC_SHARED_OFFSET 0
1500 #define GEN7_PIXEL_INTERPOLATOR_LOC_SAMPLE 1
1501 #define GEN7_PIXEL_INTERPOLATOR_LOC_CENTROID 2
1502 #define GEN7_PIXEL_INTERPOLATOR_LOC_PER_SLOT_OFFSET 3
1503
1504 /* HSW */
1505 #define HSW_DATAPORT_DC_PORT0_OWORD_BLOCK_READ 0
1506 #define HSW_DATAPORT_DC_PORT0_UNALIGNED_OWORD_BLOCK_READ 1
1507 #define HSW_DATAPORT_DC_PORT0_OWORD_DUAL_BLOCK_READ 2
1508 #define HSW_DATAPORT_DC_PORT0_DWORD_SCATTERED_READ 3
1509 #define HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_READ 4
1510 #define HSW_DATAPORT_DC_PORT0_MEMORY_FENCE 7
1511 #define HSW_DATAPORT_DC_PORT0_OWORD_BLOCK_WRITE 8
1512 #define HSW_DATAPORT_DC_PORT0_OWORD_DUAL_BLOCK_WRITE 10
1513 #define HSW_DATAPORT_DC_PORT0_DWORD_SCATTERED_WRITE 11
1514 #define HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_WRITE 12
1515
1516 #define HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_READ 1
1517 #define HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP 2
1518 #define HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP_SIMD4X2 3
1519 #define HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_READ 4
1520 #define HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_READ 5
1521 #define HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP 6
1522 #define HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP_SIMD4X2 7
1523 #define HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_WRITE 9
1524 #define HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_WRITE 10
1525 #define HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP 11
1526 #define HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP_SIMD4X2 12
1527 #define HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_WRITE 13
1528
1529 /* dataport atomic operations. */
1530 #define BRW_AOP_AND 1
1531 #define BRW_AOP_OR 2
1532 #define BRW_AOP_XOR 3
1533 #define BRW_AOP_MOV 4
1534 #define BRW_AOP_INC 5
1535 #define BRW_AOP_DEC 6
1536 #define BRW_AOP_ADD 7
1537 #define BRW_AOP_SUB 8
1538 #define BRW_AOP_REVSUB 9
1539 #define BRW_AOP_IMAX 10
1540 #define BRW_AOP_IMIN 11
1541 #define BRW_AOP_UMAX 12
1542 #define BRW_AOP_UMIN 13
1543 #define BRW_AOP_CMPWR 14
1544 #define BRW_AOP_PREDEC 15
1545
1546 #define BRW_MATH_FUNCTION_INV 1
1547 #define BRW_MATH_FUNCTION_LOG 2
1548 #define BRW_MATH_FUNCTION_EXP 3
1549 #define BRW_MATH_FUNCTION_SQRT 4
1550 #define BRW_MATH_FUNCTION_RSQ 5
1551 #define BRW_MATH_FUNCTION_SIN 6
1552 #define BRW_MATH_FUNCTION_COS 7
1553 #define BRW_MATH_FUNCTION_SINCOS 8 /* gen4, gen5 */
1554 #define BRW_MATH_FUNCTION_FDIV 9 /* gen6+ */
1555 #define BRW_MATH_FUNCTION_POW 10
1556 #define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER 11
1557 #define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT 12
1558 #define BRW_MATH_FUNCTION_INT_DIV_REMAINDER 13
1559 #define GEN8_MATH_FUNCTION_INVM 14
1560 #define GEN8_MATH_FUNCTION_RSQRTM 15
1561
1562 #define BRW_MATH_INTEGER_UNSIGNED 0
1563 #define BRW_MATH_INTEGER_SIGNED 1
1564
1565 #define BRW_MATH_PRECISION_FULL 0
1566 #define BRW_MATH_PRECISION_PARTIAL 1
1567
1568 #define BRW_MATH_SATURATE_NONE 0
1569 #define BRW_MATH_SATURATE_SATURATE 1
1570
1571 #define BRW_MATH_DATA_VECTOR 0
1572 #define BRW_MATH_DATA_SCALAR 1
1573
1574 #define BRW_URB_OPCODE_WRITE_HWORD 0
1575 #define BRW_URB_OPCODE_WRITE_OWORD 1
1576 #define GEN8_URB_OPCODE_SIMD8_WRITE 7
1577
1578 #define BRW_URB_SWIZZLE_NONE 0
1579 #define BRW_URB_SWIZZLE_INTERLEAVE 1
1580 #define BRW_URB_SWIZZLE_TRANSPOSE 2
1581
1582 #define BRW_SCRATCH_SPACE_SIZE_1K 0
1583 #define BRW_SCRATCH_SPACE_SIZE_2K 1
1584 #define BRW_SCRATCH_SPACE_SIZE_4K 2
1585 #define BRW_SCRATCH_SPACE_SIZE_8K 3
1586 #define BRW_SCRATCH_SPACE_SIZE_16K 4
1587 #define BRW_SCRATCH_SPACE_SIZE_32K 5
1588 #define BRW_SCRATCH_SPACE_SIZE_64K 6
1589 #define BRW_SCRATCH_SPACE_SIZE_128K 7
1590 #define BRW_SCRATCH_SPACE_SIZE_256K 8
1591 #define BRW_SCRATCH_SPACE_SIZE_512K 9
1592 #define BRW_SCRATCH_SPACE_SIZE_1M 10
1593 #define BRW_SCRATCH_SPACE_SIZE_2M 11
1594
1595
1596 #define CMD_URB_FENCE 0x6000
1597 #define CMD_CS_URB_STATE 0x6001
1598 #define CMD_CONST_BUFFER 0x6002
1599
1600 #define CMD_STATE_BASE_ADDRESS 0x6101
1601 #define CMD_STATE_SIP 0x6102
1602 #define CMD_PIPELINE_SELECT_965 0x6104
1603 #define CMD_PIPELINE_SELECT_GM45 0x6904
1604
1605 #define _3DSTATE_PIPELINED_POINTERS 0x7800
1606 #define _3DSTATE_BINDING_TABLE_POINTERS 0x7801
1607 # define GEN6_BINDING_TABLE_MODIFY_VS (1 << 8)
1608 # define GEN6_BINDING_TABLE_MODIFY_GS (1 << 9)
1609 # define GEN6_BINDING_TABLE_MODIFY_PS (1 << 12)
1610
1611 #define _3DSTATE_BINDING_TABLE_POINTERS_VS 0x7826 /* GEN7+ */
1612 #define _3DSTATE_BINDING_TABLE_POINTERS_HS 0x7827 /* GEN7+ */
1613 #define _3DSTATE_BINDING_TABLE_POINTERS_DS 0x7828 /* GEN7+ */
1614 #define _3DSTATE_BINDING_TABLE_POINTERS_GS 0x7829 /* GEN7+ */
1615 #define _3DSTATE_BINDING_TABLE_POINTERS_PS 0x782A /* GEN7+ */
1616
1617 #define _3DSTATE_SAMPLER_STATE_POINTERS 0x7802 /* GEN6+ */
1618 # define PS_SAMPLER_STATE_CHANGE (1 << 12)
1619 # define GS_SAMPLER_STATE_CHANGE (1 << 9)
1620 # define VS_SAMPLER_STATE_CHANGE (1 << 8)
1621 /* DW1: VS */
1622 /* DW2: GS */
1623 /* DW3: PS */
1624
1625 #define _3DSTATE_SAMPLER_STATE_POINTERS_VS 0x782B /* GEN7+ */
1626 #define _3DSTATE_SAMPLER_STATE_POINTERS_GS 0x782E /* GEN7+ */
1627 #define _3DSTATE_SAMPLER_STATE_POINTERS_PS 0x782F /* GEN7+ */
1628
1629 #define _3DSTATE_VERTEX_BUFFERS 0x7808
1630 # define BRW_VB0_INDEX_SHIFT 27
1631 # define GEN6_VB0_INDEX_SHIFT 26
1632 # define BRW_VB0_ACCESS_VERTEXDATA (0 << 26)
1633 # define BRW_VB0_ACCESS_INSTANCEDATA (1 << 26)
1634 # define GEN6_VB0_ACCESS_VERTEXDATA (0 << 20)
1635 # define GEN6_VB0_ACCESS_INSTANCEDATA (1 << 20)
1636 # define GEN7_VB0_ADDRESS_MODIFYENABLE (1 << 14)
1637 # define BRW_VB0_PITCH_SHIFT 0
1638
1639 #define _3DSTATE_VERTEX_ELEMENTS 0x7809
1640 # define BRW_VE0_INDEX_SHIFT 27
1641 # define GEN6_VE0_INDEX_SHIFT 26
1642 # define BRW_VE0_FORMAT_SHIFT 16
1643 # define BRW_VE0_VALID (1 << 26)
1644 # define GEN6_VE0_VALID (1 << 25)
1645 # define GEN6_VE0_EDGE_FLAG_ENABLE (1 << 15)
1646 # define BRW_VE0_SRC_OFFSET_SHIFT 0
1647 # define BRW_VE1_COMPONENT_NOSTORE 0
1648 # define BRW_VE1_COMPONENT_STORE_SRC 1
1649 # define BRW_VE1_COMPONENT_STORE_0 2
1650 # define BRW_VE1_COMPONENT_STORE_1_FLT 3
1651 # define BRW_VE1_COMPONENT_STORE_1_INT 4
1652 # define BRW_VE1_COMPONENT_STORE_VID 5
1653 # define BRW_VE1_COMPONENT_STORE_IID 6
1654 # define BRW_VE1_COMPONENT_STORE_PID 7
1655 # define BRW_VE1_COMPONENT_0_SHIFT 28
1656 # define BRW_VE1_COMPONENT_1_SHIFT 24
1657 # define BRW_VE1_COMPONENT_2_SHIFT 20
1658 # define BRW_VE1_COMPONENT_3_SHIFT 16
1659 # define BRW_VE1_DST_OFFSET_SHIFT 0
1660
1661 #define CMD_INDEX_BUFFER 0x780a
1662 #define GEN4_3DSTATE_VF_STATISTICS 0x780b
1663 #define GM45_3DSTATE_VF_STATISTICS 0x680b
1664 #define _3DSTATE_CC_STATE_POINTERS 0x780e /* GEN6+ */
1665 #define _3DSTATE_BLEND_STATE_POINTERS 0x7824 /* GEN7+ */
1666 #define _3DSTATE_DEPTH_STENCIL_STATE_POINTERS 0x7825 /* GEN7+ */
1667
1668 #define _3DSTATE_URB 0x7805 /* GEN6 */
1669 # define GEN6_URB_VS_SIZE_SHIFT 16
1670 # define GEN6_URB_VS_ENTRIES_SHIFT 0
1671 # define GEN6_URB_GS_ENTRIES_SHIFT 8
1672 # define GEN6_URB_GS_SIZE_SHIFT 0
1673
1674 #define _3DSTATE_VF 0x780c /* GEN7.5+ */
1675 #define HSW_CUT_INDEX_ENABLE (1 << 8)
1676
1677 #define _3DSTATE_VF_INSTANCING 0x7849 /* GEN8+ */
1678 # define GEN8_VF_INSTANCING_ENABLE (1 << 8)
1679
1680 #define _3DSTATE_VF_SGVS 0x784a /* GEN8+ */
1681 # define GEN8_SGVS_ENABLE_INSTANCE_ID (1 << 31)
1682 # define GEN8_SGVS_INSTANCE_ID_COMPONENT_SHIFT 29
1683 # define GEN8_SGVS_INSTANCE_ID_ELEMENT_OFFSET_SHIFT 16
1684 # define GEN8_SGVS_ENABLE_VERTEX_ID (1 << 15)
1685 # define GEN8_SGVS_VERTEX_ID_COMPONENT_SHIFT 13
1686 # define GEN8_SGVS_VERTEX_ID_ELEMENT_OFFSET_SHIFT 0
1687
1688 #define _3DSTATE_VF_TOPOLOGY 0x784b /* GEN8+ */
1689
1690 #define _3DSTATE_WM_CHROMAKEY 0x784c /* GEN8+ */
1691
1692 #define _3DSTATE_URB_VS 0x7830 /* GEN7+ */
1693 #define _3DSTATE_URB_HS 0x7831 /* GEN7+ */
1694 #define _3DSTATE_URB_DS 0x7832 /* GEN7+ */
1695 #define _3DSTATE_URB_GS 0x7833 /* GEN7+ */
1696 # define GEN7_URB_ENTRY_SIZE_SHIFT 16
1697 # define GEN7_URB_STARTING_ADDRESS_SHIFT 25
1698
1699 /* Gen7 "GS URB Entry Allocation Size" is a U9-1 field, so the maximum gs_size
1700 * is 2^9, or 512. It's counted in multiples of 64 bytes.
1701 */
1702 #define GEN7_MAX_GS_URB_ENTRY_SIZE_BYTES (512*64)
1703 /* Gen6 "GS URB Entry Allocation Size" is defined as a number of 1024-bit
1704 * (128 bytes) URB rows and the maximum allowed value is 5 rows.
1705 */
1706 #define GEN6_MAX_GS_URB_ENTRY_SIZE_BYTES (5*128)
1707
1708 #define _3DSTATE_PUSH_CONSTANT_ALLOC_VS 0x7912 /* GEN7+ */
1709 #define _3DSTATE_PUSH_CONSTANT_ALLOC_GS 0x7915 /* GEN7+ */
1710 #define _3DSTATE_PUSH_CONSTANT_ALLOC_PS 0x7916 /* GEN7+ */
1711 # define GEN7_PUSH_CONSTANT_BUFFER_OFFSET_SHIFT 16
1712
1713 #define _3DSTATE_VIEWPORT_STATE_POINTERS 0x780d /* GEN6+ */
1714 # define GEN6_CC_VIEWPORT_MODIFY (1 << 12)
1715 # define GEN6_SF_VIEWPORT_MODIFY (1 << 11)
1716 # define GEN6_CLIP_VIEWPORT_MODIFY (1 << 10)
1717 # define GEN6_NUM_VIEWPORTS 16
1718
1719 #define _3DSTATE_VIEWPORT_STATE_POINTERS_CC 0x7823 /* GEN7+ */
1720 #define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL 0x7821 /* GEN7+ */
1721
1722 #define _3DSTATE_SCISSOR_STATE_POINTERS 0x780f /* GEN6+ */
1723
1724 #define _3DSTATE_VS 0x7810 /* GEN6+ */
1725 /* DW2 */
1726 # define GEN6_VS_SPF_MODE (1 << 31)
1727 # define GEN6_VS_VECTOR_MASK_ENABLE (1 << 30)
1728 # define GEN6_VS_SAMPLER_COUNT_SHIFT 27
1729 # define GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT 18
1730 # define GEN6_VS_FLOATING_POINT_MODE_IEEE_754 (0 << 16)
1731 # define GEN6_VS_FLOATING_POINT_MODE_ALT (1 << 16)
1732 /* DW4 */
1733 # define GEN6_VS_DISPATCH_START_GRF_SHIFT 20
1734 # define GEN6_VS_URB_READ_LENGTH_SHIFT 11
1735 # define GEN6_VS_URB_ENTRY_READ_OFFSET_SHIFT 4
1736 /* DW5 */
1737 # define GEN6_VS_MAX_THREADS_SHIFT 25
1738 # define HSW_VS_MAX_THREADS_SHIFT 23
1739 # define GEN6_VS_STATISTICS_ENABLE (1 << 10)
1740 # define GEN6_VS_CACHE_DISABLE (1 << 1)
1741 # define GEN6_VS_ENABLE (1 << 0)
1742 /* Gen8+ DW7 */
1743 # define GEN8_VS_SIMD8_ENABLE (1 << 2)
1744 /* Gen8+ DW8 */
1745 # define GEN8_VS_URB_ENTRY_OUTPUT_OFFSET_SHIFT 21
1746 # define GEN8_VS_URB_OUTPUT_LENGTH_SHIFT 16
1747 # define GEN8_VS_USER_CLIP_DISTANCE_SHIFT 8
1748
1749 #define _3DSTATE_GS 0x7811 /* GEN6+ */
1750 /* DW2 */
1751 # define GEN6_GS_SPF_MODE (1 << 31)
1752 # define GEN6_GS_VECTOR_MASK_ENABLE (1 << 30)
1753 # define GEN6_GS_SAMPLER_COUNT_SHIFT 27
1754 # define GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT 18
1755 # define GEN6_GS_FLOATING_POINT_MODE_IEEE_754 (0 << 16)
1756 # define GEN6_GS_FLOATING_POINT_MODE_ALT (1 << 16)
1757 /* DW4 */
1758 # define GEN7_GS_OUTPUT_VERTEX_SIZE_SHIFT 23
1759 # define GEN7_GS_OUTPUT_TOPOLOGY_SHIFT 17
1760 # define GEN6_GS_URB_READ_LENGTH_SHIFT 11
1761 # define GEN7_GS_INCLUDE_VERTEX_HANDLES (1 << 10)
1762 # define GEN6_GS_URB_ENTRY_READ_OFFSET_SHIFT 4
1763 # define GEN6_GS_DISPATCH_START_GRF_SHIFT 0
1764 /* DW5 */
1765 # define GEN6_GS_MAX_THREADS_SHIFT 25
1766 # define HSW_GS_MAX_THREADS_SHIFT 24
1767 # define IVB_GS_CONTROL_DATA_FORMAT_SHIFT 24
1768 # define GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_CUT 0
1769 # define GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_SID 1
1770 # define GEN7_GS_CONTROL_DATA_HEADER_SIZE_SHIFT 20
1771 # define GEN7_GS_INSTANCE_CONTROL_SHIFT 15
1772 # define GEN7_GS_DISPATCH_MODE_SINGLE (0 << 11)
1773 # define GEN7_GS_DISPATCH_MODE_DUAL_INSTANCE (1 << 11)
1774 # define GEN7_GS_DISPATCH_MODE_DUAL_OBJECT (2 << 11)
1775 # define GEN6_GS_STATISTICS_ENABLE (1 << 10)
1776 # define GEN6_GS_SO_STATISTICS_ENABLE (1 << 9)
1777 # define GEN6_GS_RENDERING_ENABLE (1 << 8)
1778 # define GEN7_GS_INCLUDE_PRIMITIVE_ID (1 << 4)
1779 # define GEN7_GS_REORDER_TRAILING (1 << 2)
1780 # define GEN7_GS_ENABLE (1 << 0)
1781 /* DW6 */
1782 # define HSW_GS_CONTROL_DATA_FORMAT_SHIFT 31
1783 # define GEN6_GS_REORDER (1 << 30)
1784 # define GEN6_GS_DISCARD_ADJACENCY (1 << 29)
1785 # define GEN6_GS_SVBI_PAYLOAD_ENABLE (1 << 28)
1786 # define GEN6_GS_SVBI_POSTINCREMENT_ENABLE (1 << 27)
1787 # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_SHIFT 16
1788 # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_MASK INTEL_MASK(25, 16)
1789 # define GEN6_GS_ENABLE (1 << 15)
1790
1791 /* Gen8+ DW9 */
1792 # define GEN8_GS_URB_ENTRY_OUTPUT_OFFSET_SHIFT 21
1793 # define GEN8_GS_URB_OUTPUT_LENGTH_SHIFT 16
1794 # define GEN8_GS_USER_CLIP_DISTANCE_SHIFT 8
1795
1796 # define BRW_GS_EDGE_INDICATOR_0 (1 << 8)
1797 # define BRW_GS_EDGE_INDICATOR_1 (1 << 9)
1798
1799 /* GS Thread Payload
1800 */
1801 /* R0 */
1802 # define GEN7_GS_PAYLOAD_INSTANCE_ID_SHIFT 27
1803
1804 /* 3DSTATE_GS "Output Vertex Size" has an effective maximum of 62. It's
1805 * counted in multiples of 16 bytes.
1806 */
1807 #define GEN7_MAX_GS_OUTPUT_VERTEX_SIZE_BYTES (62*16)
1808
1809 #define _3DSTATE_HS 0x781B /* GEN7+ */
1810 #define _3DSTATE_TE 0x781C /* GEN7+ */
1811 #define _3DSTATE_DS 0x781D /* GEN7+ */
1812
1813 #define _3DSTATE_CLIP 0x7812 /* GEN6+ */
1814 /* DW1 */
1815 # define GEN7_CLIP_WINDING_CW (0 << 20)
1816 # define GEN7_CLIP_WINDING_CCW (1 << 20)
1817 # define GEN7_CLIP_VERTEX_SUBPIXEL_PRECISION_8 (0 << 19)
1818 # define GEN7_CLIP_VERTEX_SUBPIXEL_PRECISION_4 (1 << 19)
1819 # define GEN7_CLIP_EARLY_CULL (1 << 18)
1820 # define GEN7_CLIP_CULLMODE_BOTH (0 << 16)
1821 # define GEN7_CLIP_CULLMODE_NONE (1 << 16)
1822 # define GEN7_CLIP_CULLMODE_FRONT (2 << 16)
1823 # define GEN7_CLIP_CULLMODE_BACK (3 << 16)
1824 # define GEN6_CLIP_STATISTICS_ENABLE (1 << 10)
1825 /**
1826 * Just does cheap culling based on the clip distance. Bits must be
1827 * disjoint with USER_CLIP_CLIP_DISTANCE bits.
1828 */
1829 # define GEN6_USER_CLIP_CULL_DISTANCES_SHIFT 0
1830 /* DW2 */
1831 # define GEN6_CLIP_ENABLE (1 << 31)
1832 # define GEN6_CLIP_API_OGL (0 << 30)
1833 # define GEN6_CLIP_API_D3D (1 << 30)
1834 # define GEN6_CLIP_XY_TEST (1 << 28)
1835 # define GEN6_CLIP_Z_TEST (1 << 27)
1836 # define GEN6_CLIP_GB_TEST (1 << 26)
1837 /** 8-bit field of which user clip distances to clip aganist. */
1838 # define GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT 16
1839 # define GEN6_CLIP_MODE_NORMAL (0 << 13)
1840 # define GEN6_CLIP_MODE_REJECT_ALL (3 << 13)
1841 # define GEN6_CLIP_MODE_ACCEPT_ALL (4 << 13)
1842 # define GEN6_CLIP_PERSPECTIVE_DIVIDE_DISABLE (1 << 9)
1843 # define GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE (1 << 8)
1844 # define GEN6_CLIP_TRI_PROVOKE_SHIFT 4
1845 # define GEN6_CLIP_LINE_PROVOKE_SHIFT 2
1846 # define GEN6_CLIP_TRIFAN_PROVOKE_SHIFT 0
1847 /* DW3 */
1848 # define GEN6_CLIP_MIN_POINT_WIDTH_SHIFT 17
1849 # define GEN6_CLIP_MAX_POINT_WIDTH_SHIFT 6
1850 # define GEN6_CLIP_FORCE_ZERO_RTAINDEX (1 << 5)
1851 # define GEN6_CLIP_MAX_VP_INDEX_MASK INTEL_MASK(3, 0)
1852
1853 #define _3DSTATE_SF 0x7813 /* GEN6+ */
1854 /* DW1 (for gen6) */
1855 # define GEN6_SF_NUM_OUTPUTS_SHIFT 22
1856 # define GEN6_SF_SWIZZLE_ENABLE (1 << 21)
1857 # define GEN6_SF_POINT_SPRITE_UPPERLEFT (0 << 20)
1858 # define GEN6_SF_POINT_SPRITE_LOWERLEFT (1 << 20)
1859 # define GEN9_SF_LINE_WIDTH_SHIFT 12 /* U11.7 */
1860 # define GEN6_SF_URB_ENTRY_READ_LENGTH_SHIFT 11
1861 # define GEN6_SF_URB_ENTRY_READ_OFFSET_SHIFT 4
1862 /* DW2 */
1863 # define GEN6_SF_LEGACY_GLOBAL_DEPTH_BIAS (1 << 11)
1864 # define GEN6_SF_STATISTICS_ENABLE (1 << 10)
1865 # define GEN6_SF_GLOBAL_DEPTH_OFFSET_SOLID (1 << 9)
1866 # define GEN6_SF_GLOBAL_DEPTH_OFFSET_WIREFRAME (1 << 8)
1867 # define GEN6_SF_GLOBAL_DEPTH_OFFSET_POINT (1 << 7)
1868 # define GEN6_SF_FRONT_SOLID (0 << 5)
1869 # define GEN6_SF_FRONT_WIREFRAME (1 << 5)
1870 # define GEN6_SF_FRONT_POINT (2 << 5)
1871 # define GEN6_SF_BACK_SOLID (0 << 3)
1872 # define GEN6_SF_BACK_WIREFRAME (1 << 3)
1873 # define GEN6_SF_BACK_POINT (2 << 3)
1874 # define GEN6_SF_VIEWPORT_TRANSFORM_ENABLE (1 << 1)
1875 # define GEN6_SF_WINDING_CCW (1 << 0)
1876 /* DW3 */
1877 # define GEN6_SF_LINE_AA_ENABLE (1 << 31)
1878 # define GEN6_SF_CULL_BOTH (0 << 29)
1879 # define GEN6_SF_CULL_NONE (1 << 29)
1880 # define GEN6_SF_CULL_FRONT (2 << 29)
1881 # define GEN6_SF_CULL_BACK (3 << 29)
1882 # define GEN6_SF_LINE_WIDTH_SHIFT 18 /* U3.7 */
1883 # define GEN6_SF_LINE_END_CAP_WIDTH_0_5 (0 << 16)
1884 # define GEN6_SF_LINE_END_CAP_WIDTH_1_0 (1 << 16)
1885 # define GEN6_SF_LINE_END_CAP_WIDTH_2_0 (2 << 16)
1886 # define GEN6_SF_LINE_END_CAP_WIDTH_4_0 (3 << 16)
1887 # define GEN6_SF_SCISSOR_ENABLE (1 << 11)
1888 # define GEN6_SF_MSRAST_OFF_PIXEL (0 << 8)
1889 # define GEN6_SF_MSRAST_OFF_PATTERN (1 << 8)
1890 # define GEN6_SF_MSRAST_ON_PIXEL (2 << 8)
1891 # define GEN6_SF_MSRAST_ON_PATTERN (3 << 8)
1892 /* DW4 */
1893 # define GEN6_SF_TRI_PROVOKE_SHIFT 29
1894 # define GEN6_SF_LINE_PROVOKE_SHIFT 27
1895 # define GEN6_SF_TRIFAN_PROVOKE_SHIFT 25
1896 # define GEN6_SF_LINE_AA_MODE_MANHATTAN (0 << 14)
1897 # define GEN6_SF_LINE_AA_MODE_TRUE (1 << 14)
1898 # define GEN6_SF_VERTEX_SUBPIXEL_8BITS (0 << 12)
1899 # define GEN6_SF_VERTEX_SUBPIXEL_4BITS (1 << 12)
1900 # define GEN6_SF_USE_STATE_POINT_WIDTH (1 << 11)
1901 # define GEN6_SF_POINT_WIDTH_SHIFT 0 /* U8.3 */
1902 /* DW5: depth offset constant */
1903 /* DW6: depth offset scale */
1904 /* DW7: depth offset clamp */
1905 /* DW8 */
1906 # define ATTRIBUTE_1_OVERRIDE_W (1 << 31)
1907 # define ATTRIBUTE_1_OVERRIDE_Z (1 << 30)
1908 # define ATTRIBUTE_1_OVERRIDE_Y (1 << 29)
1909 # define ATTRIBUTE_1_OVERRIDE_X (1 << 28)
1910 # define ATTRIBUTE_1_CONST_SOURCE_SHIFT 25
1911 # define ATTRIBUTE_1_SWIZZLE_SHIFT 22
1912 # define ATTRIBUTE_1_SOURCE_SHIFT 16
1913 # define ATTRIBUTE_0_OVERRIDE_W (1 << 15)
1914 # define ATTRIBUTE_0_OVERRIDE_Z (1 << 14)
1915 # define ATTRIBUTE_0_OVERRIDE_Y (1 << 13)
1916 # define ATTRIBUTE_0_OVERRIDE_X (1 << 12)
1917 # define ATTRIBUTE_0_CONST_SOURCE_SHIFT 9
1918 # define ATTRIBUTE_CONST_0000 0
1919 # define ATTRIBUTE_CONST_0001_FLOAT 1
1920 # define ATTRIBUTE_CONST_1111_FLOAT 2
1921 # define ATTRIBUTE_CONST_PRIM_ID 3
1922 # define ATTRIBUTE_0_SWIZZLE_SHIFT 6
1923 # define ATTRIBUTE_0_SOURCE_SHIFT 0
1924
1925 # define ATTRIBUTE_SWIZZLE_INPUTATTR 0
1926 # define ATTRIBUTE_SWIZZLE_INPUTATTR_FACING 1
1927 # define ATTRIBUTE_SWIZZLE_INPUTATTR_W 2
1928 # define ATTRIBUTE_SWIZZLE_INPUTATTR_FACING_W 3
1929 # define ATTRIBUTE_SWIZZLE_SHIFT 6
1930
1931 /* DW16: Point sprite texture coordinate enables */
1932 /* DW17: Constant interpolation enables */
1933 /* DW18: attr 0-7 wrap shortest enables */
1934 /* DW19: attr 8-16 wrap shortest enables */
1935
1936 /* On GEN7, many fields of 3DSTATE_SF were split out into a new command:
1937 * 3DSTATE_SBE. The remaining fields live in different DWords, but retain
1938 * the same bit-offset. The only new field:
1939 */
1940 /* GEN7/DW1: */
1941 # define GEN7_SF_DEPTH_BUFFER_SURFACE_FORMAT_SHIFT 12
1942 /* GEN7/DW2: */
1943 # define HSW_SF_LINE_STIPPLE_ENABLE (1 << 14)
1944
1945 # define GEN8_SF_SMOOTH_POINT_ENABLE (1 << 13)
1946
1947 #define _3DSTATE_SBE 0x781F /* GEN7+ */
1948 /* DW1 */
1949 # define GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH (1 << 29)
1950 # define GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET (1 << 28)
1951 # define GEN7_SBE_SWIZZLE_CONTROL_MODE (1 << 28)
1952 # define GEN7_SBE_NUM_OUTPUTS_SHIFT 22
1953 # define GEN7_SBE_SWIZZLE_ENABLE (1 << 21)
1954 # define GEN7_SBE_POINT_SPRITE_LOWERLEFT (1 << 20)
1955 # define GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT 11
1956 # define GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT 4
1957 # define GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT 5
1958 /* DW2-9: Attribute setup (same as DW8-15 of gen6 _3DSTATE_SF) */
1959 /* DW10: Point sprite texture coordinate enables */
1960 /* DW11: Constant interpolation enables */
1961 /* DW12: attr 0-7 wrap shortest enables */
1962 /* DW13: attr 8-16 wrap shortest enables */
1963
1964 /* DW4-5: Attribute active components (gen9) */
1965 #define GEN9_SBE_ACTIVE_COMPONENT_NONE 0
1966 #define GEN9_SBE_ACTIVE_COMPONENT_XY 1
1967 #define GEN9_SBE_ACTIVE_COMPONENT_XYZ 2
1968 #define GEN9_SBE_ACTIVE_COMPONENT_XYZW 3
1969
1970 #define _3DSTATE_SBE_SWIZ 0x7851 /* GEN8+ */
1971
1972 #define _3DSTATE_RASTER 0x7850 /* GEN8+ */
1973 /* DW1 */
1974 # define GEN9_RASTER_VIEWPORT_Z_FAR_CLIP_TEST_ENABLE (1 << 26)
1975 # define GEN8_RASTER_FRONT_WINDING_CCW (1 << 21)
1976 # define GEN8_RASTER_CULL_BOTH (0 << 16)
1977 # define GEN8_RASTER_CULL_NONE (1 << 16)
1978 # define GEN8_RASTER_CULL_FRONT (2 << 16)
1979 # define GEN8_RASTER_CULL_BACK (3 << 16)
1980 # define GEN8_RASTER_SMOOTH_POINT_ENABLE (1 << 13)
1981 # define GEN8_RASTER_API_MULTISAMPLE_ENABLE (1 << 12)
1982 # define GEN8_RASTER_LINE_AA_ENABLE (1 << 2)
1983 # define GEN8_RASTER_SCISSOR_ENABLE (1 << 1)
1984 # define GEN8_RASTER_VIEWPORT_Z_CLIP_TEST_ENABLE (1 << 0)
1985 # define GEN9_RASTER_VIEWPORT_Z_NEAR_CLIP_TEST_ENABLE (1 << 0)
1986
1987 /* Gen8 BLEND_STATE */
1988 /* DW0 */
1989 #define GEN8_BLEND_ALPHA_TO_COVERAGE_ENABLE (1 << 31)
1990 #define GEN8_BLEND_INDEPENDENT_ALPHA_BLEND_ENABLE (1 << 30)
1991 #define GEN8_BLEND_ALPHA_TO_ONE_ENABLE (1 << 29)
1992 #define GEN8_BLEND_ALPHA_TO_COVERAGE_DITHER_ENABLE (1 << 28)
1993 #define GEN8_BLEND_ALPHA_TEST_ENABLE (1 << 27)
1994 #define GEN8_BLEND_ALPHA_TEST_FUNCTION_MASK INTEL_MASK(26, 24)
1995 #define GEN8_BLEND_ALPHA_TEST_FUNCTION_SHIFT 24
1996 #define GEN8_BLEND_COLOR_DITHER_ENABLE (1 << 23)
1997 #define GEN8_BLEND_X_DITHER_OFFSET_MASK INTEL_MASK(22, 21)
1998 #define GEN8_BLEND_X_DITHER_OFFSET_SHIFT 21
1999 #define GEN8_BLEND_Y_DITHER_OFFSET_MASK INTEL_MASK(20, 19)
2000 #define GEN8_BLEND_Y_DITHER_OFFSET_SHIFT 19
2001 /* DW1 + 2n */
2002 #define GEN8_BLEND_COLOR_BUFFER_BLEND_ENABLE (1 << 31)
2003 #define GEN8_BLEND_SRC_BLEND_FACTOR_MASK INTEL_MASK(30, 26)
2004 #define GEN8_BLEND_SRC_BLEND_FACTOR_SHIFT 26
2005 #define GEN8_BLEND_DST_BLEND_FACTOR_MASK INTEL_MASK(25, 21)
2006 #define GEN8_BLEND_DST_BLEND_FACTOR_SHIFT 21
2007 #define GEN8_BLEND_COLOR_BLEND_FUNCTION_MASK INTEL_MASK(20, 18)
2008 #define GEN8_BLEND_COLOR_BLEND_FUNCTION_SHIFT 18
2009 #define GEN8_BLEND_SRC_ALPHA_BLEND_FACTOR_MASK INTEL_MASK(17, 13)
2010 #define GEN8_BLEND_SRC_ALPHA_BLEND_FACTOR_SHIFT 13
2011 #define GEN8_BLEND_DST_ALPHA_BLEND_FACTOR_MASK INTEL_MASK(12, 8)
2012 #define GEN8_BLEND_DST_ALPHA_BLEND_FACTOR_SHIFT 8
2013 #define GEN8_BLEND_ALPHA_BLEND_FUNCTION_MASK INTEL_MASK(7, 5)
2014 #define GEN8_BLEND_ALPHA_BLEND_FUNCTION_SHIFT 5
2015 #define GEN8_BLEND_WRITE_DISABLE_ALPHA (1 << 3)
2016 #define GEN8_BLEND_WRITE_DISABLE_RED (1 << 2)
2017 #define GEN8_BLEND_WRITE_DISABLE_GREEN (1 << 1)
2018 #define GEN8_BLEND_WRITE_DISABLE_BLUE (1 << 0)
2019 /* DW1 + 2n + 1 */
2020 #define GEN8_BLEND_LOGIC_OP_ENABLE (1 << 31)
2021 #define GEN8_BLEND_LOGIC_OP_FUNCTION_MASK INTEL_MASK(30, 27)
2022 #define GEN8_BLEND_LOGIC_OP_FUNCTION_SHIFT 27
2023 #define GEN8_BLEND_PRE_BLEND_SRC_ONLY_CLAMP_ENABLE (1 << 4)
2024 #define GEN8_BLEND_COLOR_CLAMP_RANGE_RTFORMAT (2 << 2)
2025 #define GEN8_BLEND_PRE_BLEND_COLOR_CLAMP_ENABLE (1 << 1)
2026 #define GEN8_BLEND_POST_BLEND_COLOR_CLAMP_ENABLE (1 << 0)
2027
2028 #define _3DSTATE_WM_HZ_OP 0x7852 /* GEN8+ */
2029 /* DW1 */
2030 # define GEN8_WM_HZ_STENCIL_CLEAR (1 << 31)
2031 # define GEN8_WM_HZ_DEPTH_CLEAR (1 << 30)
2032 # define GEN8_WM_HZ_DEPTH_RESOLVE (1 << 28)
2033 # define GEN8_WM_HZ_HIZ_RESOLVE (1 << 27)
2034 # define GEN8_WM_HZ_PIXEL_OFFSET_ENABLE (1 << 26)
2035 # define GEN8_WM_HZ_FULL_SURFACE_DEPTH_CLEAR (1 << 25)
2036 # define GEN8_WM_HZ_STENCIL_CLEAR_VALUE_MASK INTEL_MASK(23, 16)
2037 # define GEN8_WM_HZ_STENCIL_CLEAR_VALUE_SHIFT 16
2038 # define GEN8_WM_HZ_NUM_SAMPLES_MASK INTEL_MASK(15, 13)
2039 # define GEN8_WM_HZ_NUM_SAMPLES_SHIFT 13
2040 /* DW2 */
2041 # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MIN_MASK INTEL_MASK(31, 16)
2042 # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MIN_SHIFT 16
2043 # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MIN_MASK INTEL_MASK(15, 0)
2044 # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MIN_SHIFT 0
2045 /* DW3 */
2046 # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MAX_MASK INTEL_MASK(31, 16)
2047 # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MAX_SHIFT 16
2048 # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MAX_MASK INTEL_MASK(15, 0)
2049 # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MAX_SHIFT 0
2050 /* DW4 */
2051 # define GEN8_WM_HZ_SAMPLE_MASK_MASK INTEL_MASK(15, 0)
2052 # define GEN8_WM_HZ_SAMPLE_MASK_SHIFT 0
2053
2054
2055 #define _3DSTATE_PS_BLEND 0x784D /* GEN8+ */
2056 /* DW1 */
2057 # define GEN8_PS_BLEND_ALPHA_TO_COVERAGE_ENABLE (1 << 31)
2058 # define GEN8_PS_BLEND_HAS_WRITEABLE_RT (1 << 30)
2059 # define GEN8_PS_BLEND_COLOR_BUFFER_BLEND_ENABLE (1 << 29)
2060 # define GEN8_PS_BLEND_SRC_ALPHA_BLEND_FACTOR_MASK INTEL_MASK(28, 24)
2061 # define GEN8_PS_BLEND_SRC_ALPHA_BLEND_FACTOR_SHIFT 24
2062 # define GEN8_PS_BLEND_DST_ALPHA_BLEND_FACTOR_MASK INTEL_MASK(23, 19)
2063 # define GEN8_PS_BLEND_DST_ALPHA_BLEND_FACTOR_SHIFT 19
2064 # define GEN8_PS_BLEND_SRC_BLEND_FACTOR_MASK INTEL_MASK(18, 14)
2065 # define GEN8_PS_BLEND_SRC_BLEND_FACTOR_SHIFT 14
2066 # define GEN8_PS_BLEND_DST_BLEND_FACTOR_MASK INTEL_MASK(13, 9)
2067 # define GEN8_PS_BLEND_DST_BLEND_FACTOR_SHIFT 9
2068 # define GEN8_PS_BLEND_ALPHA_TEST_ENABLE (1 << 8)
2069 # define GEN8_PS_BLEND_INDEPENDENT_ALPHA_BLEND_ENABLE (1 << 7)
2070
2071 #define _3DSTATE_WM_DEPTH_STENCIL 0x784E /* GEN8+ */
2072 /* DW1 */
2073 # define GEN8_WM_DS_STENCIL_FAIL_OP_SHIFT 29
2074 # define GEN8_WM_DS_Z_FAIL_OP_SHIFT 26
2075 # define GEN8_WM_DS_Z_PASS_OP_SHIFT 23
2076 # define GEN8_WM_DS_BF_STENCIL_FUNC_SHIFT 20
2077 # define GEN8_WM_DS_BF_STENCIL_FAIL_OP_SHIFT 17
2078 # define GEN8_WM_DS_BF_Z_FAIL_OP_SHIFT 14
2079 # define GEN8_WM_DS_BF_Z_PASS_OP_SHIFT 11
2080 # define GEN8_WM_DS_STENCIL_FUNC_SHIFT 8
2081 # define GEN8_WM_DS_DEPTH_FUNC_SHIFT 5
2082 # define GEN8_WM_DS_DOUBLE_SIDED_STENCIL_ENABLE (1 << 4)
2083 # define GEN8_WM_DS_STENCIL_TEST_ENABLE (1 << 3)
2084 # define GEN8_WM_DS_STENCIL_BUFFER_WRITE_ENABLE (1 << 2)
2085 # define GEN8_WM_DS_DEPTH_TEST_ENABLE (1 << 1)
2086 # define GEN8_WM_DS_DEPTH_BUFFER_WRITE_ENABLE (1 << 0)
2087 /* DW2 */
2088 # define GEN8_WM_DS_STENCIL_TEST_MASK_MASK INTEL_MASK(31, 24)
2089 # define GEN8_WM_DS_STENCIL_TEST_MASK_SHIFT 24
2090 # define GEN8_WM_DS_STENCIL_WRITE_MASK_MASK INTEL_MASK(23, 16)
2091 # define GEN8_WM_DS_STENCIL_WRITE_MASK_SHIFT 16
2092 # define GEN8_WM_DS_BF_STENCIL_TEST_MASK_MASK INTEL_MASK(15, 8)
2093 # define GEN8_WM_DS_BF_STENCIL_TEST_MASK_SHIFT 8
2094 # define GEN8_WM_DS_BF_STENCIL_WRITE_MASK_MASK INTEL_MASK(7, 0)
2095 # define GEN8_WM_DS_BF_STENCIL_WRITE_MASK_SHIFT 0
2096 /* DW3 */
2097 # define GEN9_WM_DS_STENCIL_REF_MASK INTEL_MASK(15, 8)
2098 # define GEN9_WM_DS_STENCIL_REF_SHIFT 8
2099 # define GEN9_WM_DS_BF_STENCIL_REF_MASK INTEL_MASK(7, 0)
2100 # define GEN9_WM_DS_BF_STENCIL_REF_SHIFT 0
2101
2102 enum brw_pixel_shader_computed_depth_mode {
2103 BRW_PSCDEPTH_OFF = 0, /* PS does not compute depth */
2104 BRW_PSCDEPTH_ON = 1, /* PS computes depth; no guarantee about value */
2105 BRW_PSCDEPTH_ON_GE = 2, /* PS guarantees output depth >= source depth */
2106 BRW_PSCDEPTH_ON_LE = 3, /* PS guarantees output depth <= source depth */
2107 };
2108
2109 #define _3DSTATE_PS_EXTRA 0x784F /* GEN8+ */
2110 /* DW1 */
2111 # define GEN8_PSX_PIXEL_SHADER_VALID (1 << 31)
2112 # define GEN8_PSX_PIXEL_SHADER_NO_RT_WRITE (1 << 30)
2113 # define GEN8_PSX_OMASK_TO_RENDER_TARGET (1 << 29)
2114 # define GEN8_PSX_KILL_ENABLE (1 << 28)
2115 # define GEN8_PSX_COMPUTED_DEPTH_MODE_SHIFT 26
2116 # define GEN8_PSX_FORCE_COMPUTED_DEPTH (1 << 25)
2117 # define GEN8_PSX_USES_SOURCE_DEPTH (1 << 24)
2118 # define GEN8_PSX_USES_SOURCE_W (1 << 23)
2119 # define GEN8_PSX_ATTRIBUTE_ENABLE (1 << 8)
2120 # define GEN8_PSX_SHADER_DISABLES_ALPHA_TO_COVERAGE (1 << 7)
2121 # define GEN8_PSX_SHADER_IS_PER_SAMPLE (1 << 6)
2122 # define GEN8_PSX_SHADER_COMPUTES_STENCIL (1 << 5)
2123 # define GEN8_PSX_SHADER_HAS_UAV (1 << 2)
2124 # define GEN8_PSX_SHADER_USES_INPUT_COVERAGE_MASK (1 << 1)
2125
2126 enum brw_wm_barycentric_interp_mode {
2127 BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC = 0,
2128 BRW_WM_PERSPECTIVE_CENTROID_BARYCENTRIC = 1,
2129 BRW_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC = 2,
2130 BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC = 3,
2131 BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC = 4,
2132 BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC = 5,
2133 BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT = 6
2134 };
2135 #define BRW_WM_NONPERSPECTIVE_BARYCENTRIC_BITS \
2136 ((1 << BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC) | \
2137 (1 << BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC) | \
2138 (1 << BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC))
2139
2140 #define _3DSTATE_WM 0x7814 /* GEN6+ */
2141 /* DW1: kernel pointer */
2142 /* DW2 */
2143 # define GEN6_WM_SPF_MODE (1 << 31)
2144 # define GEN6_WM_VECTOR_MASK_ENABLE (1 << 30)
2145 # define GEN6_WM_SAMPLER_COUNT_SHIFT 27
2146 # define GEN6_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT 18
2147 # define GEN6_WM_FLOATING_POINT_MODE_IEEE_754 (0 << 16)
2148 # define GEN6_WM_FLOATING_POINT_MODE_ALT (1 << 16)
2149 /* DW3: scratch space */
2150 /* DW4 */
2151 # define GEN6_WM_STATISTICS_ENABLE (1 << 31)
2152 # define GEN6_WM_DEPTH_CLEAR (1 << 30)
2153 # define GEN6_WM_DEPTH_RESOLVE (1 << 28)
2154 # define GEN6_WM_HIERARCHICAL_DEPTH_RESOLVE (1 << 27)
2155 # define GEN6_WM_DISPATCH_START_GRF_SHIFT_0 16
2156 # define GEN6_WM_DISPATCH_START_GRF_SHIFT_1 8
2157 # define GEN6_WM_DISPATCH_START_GRF_SHIFT_2 0
2158 /* DW5 */
2159 # define GEN6_WM_MAX_THREADS_SHIFT 25
2160 # define GEN6_WM_KILL_ENABLE (1 << 22)
2161 # define GEN6_WM_COMPUTED_DEPTH (1 << 21)
2162 # define GEN6_WM_USES_SOURCE_DEPTH (1 << 20)
2163 # define GEN6_WM_DISPATCH_ENABLE (1 << 19)
2164 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_0_5 (0 << 16)
2165 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_1_0 (1 << 16)
2166 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_2_0 (2 << 16)
2167 # define GEN6_WM_LINE_END_CAP_AA_WIDTH_4_0 (3 << 16)
2168 # define GEN6_WM_LINE_AA_WIDTH_0_5 (0 << 14)
2169 # define GEN6_WM_LINE_AA_WIDTH_1_0 (1 << 14)
2170 # define GEN6_WM_LINE_AA_WIDTH_2_0 (2 << 14)
2171 # define GEN6_WM_LINE_AA_WIDTH_4_0 (3 << 14)
2172 # define GEN6_WM_POLYGON_STIPPLE_ENABLE (1 << 13)
2173 # define GEN6_WM_LINE_STIPPLE_ENABLE (1 << 11)
2174 # define GEN6_WM_OMASK_TO_RENDER_TARGET (1 << 9)
2175 # define GEN6_WM_USES_SOURCE_W (1 << 8)
2176 # define GEN6_WM_DUAL_SOURCE_BLEND_ENABLE (1 << 7)
2177 # define GEN6_WM_32_DISPATCH_ENABLE (1 << 2)
2178 # define GEN6_WM_16_DISPATCH_ENABLE (1 << 1)
2179 # define GEN6_WM_8_DISPATCH_ENABLE (1 << 0)
2180 /* DW6 */
2181 # define GEN6_WM_NUM_SF_OUTPUTS_SHIFT 20
2182 # define GEN6_WM_POSOFFSET_NONE (0 << 18)
2183 # define GEN6_WM_POSOFFSET_CENTROID (2 << 18)
2184 # define GEN6_WM_POSOFFSET_SAMPLE (3 << 18)
2185 # define GEN6_WM_POSITION_ZW_PIXEL (0 << 16)
2186 # define GEN6_WM_POSITION_ZW_CENTROID (2 << 16)
2187 # define GEN6_WM_POSITION_ZW_SAMPLE (3 << 16)
2188 # define GEN6_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC (1 << 15)
2189 # define GEN6_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC (1 << 14)
2190 # define GEN6_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC (1 << 13)
2191 # define GEN6_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC (1 << 12)
2192 # define GEN6_WM_PERSPECTIVE_CENTROID_BARYCENTRIC (1 << 11)
2193 # define GEN6_WM_PERSPECTIVE_PIXEL_BARYCENTRIC (1 << 10)
2194 # define GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT 10
2195 # define GEN6_WM_POINT_RASTRULE_UPPER_RIGHT (1 << 9)
2196 # define GEN6_WM_MSRAST_OFF_PIXEL (0 << 1)
2197 # define GEN6_WM_MSRAST_OFF_PATTERN (1 << 1)
2198 # define GEN6_WM_MSRAST_ON_PIXEL (2 << 1)
2199 # define GEN6_WM_MSRAST_ON_PATTERN (3 << 1)
2200 # define GEN6_WM_MSDISPMODE_PERSAMPLE (0 << 0)
2201 # define GEN6_WM_MSDISPMODE_PERPIXEL (1 << 0)
2202 /* DW7: kernel 1 pointer */
2203 /* DW8: kernel 2 pointer */
2204
2205 #define _3DSTATE_CONSTANT_VS 0x7815 /* GEN6+ */
2206 #define _3DSTATE_CONSTANT_GS 0x7816 /* GEN6+ */
2207 #define _3DSTATE_CONSTANT_PS 0x7817 /* GEN6+ */
2208 # define GEN6_CONSTANT_BUFFER_3_ENABLE (1 << 15)
2209 # define GEN6_CONSTANT_BUFFER_2_ENABLE (1 << 14)
2210 # define GEN6_CONSTANT_BUFFER_1_ENABLE (1 << 13)
2211 # define GEN6_CONSTANT_BUFFER_0_ENABLE (1 << 12)
2212
2213 #define _3DSTATE_CONSTANT_HS 0x7819 /* GEN7+ */
2214 #define _3DSTATE_CONSTANT_DS 0x781A /* GEN7+ */
2215
2216 #define _3DSTATE_STREAMOUT 0x781e /* GEN7+ */
2217 /* DW1 */
2218 # define SO_FUNCTION_ENABLE (1 << 31)
2219 # define SO_RENDERING_DISABLE (1 << 30)
2220 /* This selects which incoming rendering stream goes down the pipeline. The
2221 * rendering stream is 0 if not defined by special cases in the GS state.
2222 */
2223 # define SO_RENDER_STREAM_SELECT_SHIFT 27
2224 # define SO_RENDER_STREAM_SELECT_MASK INTEL_MASK(28, 27)
2225 /* Controls reordering of TRISTRIP_* elements in stream output (not rendering).
2226 */
2227 # define SO_REORDER_TRAILING (1 << 26)
2228 /* Controls SO_NUM_PRIMS_WRITTEN_* and SO_PRIM_STORAGE_* */
2229 # define SO_STATISTICS_ENABLE (1 << 25)
2230 # define SO_BUFFER_ENABLE(n) (1 << (8 + (n)))
2231 /* DW2 */
2232 # define SO_STREAM_3_VERTEX_READ_OFFSET_SHIFT 29
2233 # define SO_STREAM_3_VERTEX_READ_OFFSET_MASK INTEL_MASK(29, 29)
2234 # define SO_STREAM_3_VERTEX_READ_LENGTH_SHIFT 24
2235 # define SO_STREAM_3_VERTEX_READ_LENGTH_MASK INTEL_MASK(28, 24)
2236 # define SO_STREAM_2_VERTEX_READ_OFFSET_SHIFT 21
2237 # define SO_STREAM_2_VERTEX_READ_OFFSET_MASK INTEL_MASK(21, 21)
2238 # define SO_STREAM_2_VERTEX_READ_LENGTH_SHIFT 16
2239 # define SO_STREAM_2_VERTEX_READ_LENGTH_MASK INTEL_MASK(20, 16)
2240 # define SO_STREAM_1_VERTEX_READ_OFFSET_SHIFT 13
2241 # define SO_STREAM_1_VERTEX_READ_OFFSET_MASK INTEL_MASK(13, 13)
2242 # define SO_STREAM_1_VERTEX_READ_LENGTH_SHIFT 8
2243 # define SO_STREAM_1_VERTEX_READ_LENGTH_MASK INTEL_MASK(12, 8)
2244 # define SO_STREAM_0_VERTEX_READ_OFFSET_SHIFT 5
2245 # define SO_STREAM_0_VERTEX_READ_OFFSET_MASK INTEL_MASK(5, 5)
2246 # define SO_STREAM_0_VERTEX_READ_LENGTH_SHIFT 0
2247 # define SO_STREAM_0_VERTEX_READ_LENGTH_MASK INTEL_MASK(4, 0)
2248
2249 /* 3DSTATE_WM for Gen7 */
2250 /* DW1 */
2251 # define GEN7_WM_STATISTICS_ENABLE (1 << 31)
2252 # define GEN7_WM_DEPTH_CLEAR (1 << 30)
2253 # define GEN7_WM_DISPATCH_ENABLE (1 << 29)
2254 # define GEN7_WM_DEPTH_RESOLVE (1 << 28)
2255 # define GEN7_WM_HIERARCHICAL_DEPTH_RESOLVE (1 << 27)
2256 # define GEN7_WM_KILL_ENABLE (1 << 25)
2257 # define GEN7_WM_COMPUTED_DEPTH_MODE_SHIFT 23
2258 # define GEN7_WM_USES_SOURCE_DEPTH (1 << 20)
2259 # define GEN7_WM_USES_SOURCE_W (1 << 19)
2260 # define GEN7_WM_POSITION_ZW_PIXEL (0 << 17)
2261 # define GEN7_WM_POSITION_ZW_CENTROID (2 << 17)
2262 # define GEN7_WM_POSITION_ZW_SAMPLE (3 << 17)
2263 # define GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT 11
2264 # define GEN7_WM_USES_INPUT_COVERAGE_MASK (1 << 10)
2265 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_0_5 (0 << 8)
2266 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_1_0 (1 << 8)
2267 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_2_0 (2 << 8)
2268 # define GEN7_WM_LINE_END_CAP_AA_WIDTH_4_0 (3 << 8)
2269 # define GEN7_WM_LINE_AA_WIDTH_0_5 (0 << 6)
2270 # define GEN7_WM_LINE_AA_WIDTH_1_0 (1 << 6)
2271 # define GEN7_WM_LINE_AA_WIDTH_2_0 (2 << 6)
2272 # define GEN7_WM_LINE_AA_WIDTH_4_0 (3 << 6)
2273 # define GEN7_WM_POLYGON_STIPPLE_ENABLE (1 << 4)
2274 # define GEN7_WM_LINE_STIPPLE_ENABLE (1 << 3)
2275 # define GEN7_WM_POINT_RASTRULE_UPPER_RIGHT (1 << 2)
2276 # define GEN7_WM_MSRAST_OFF_PIXEL (0 << 0)
2277 # define GEN7_WM_MSRAST_OFF_PATTERN (1 << 0)
2278 # define GEN7_WM_MSRAST_ON_PIXEL (2 << 0)
2279 # define GEN7_WM_MSRAST_ON_PATTERN (3 << 0)
2280 /* DW2 */
2281 # define GEN7_WM_MSDISPMODE_PERSAMPLE (0 << 31)
2282 # define GEN7_WM_MSDISPMODE_PERPIXEL (1 << 31)
2283
2284 #define _3DSTATE_PS 0x7820 /* GEN7+ */
2285 /* DW1: kernel pointer */
2286 /* DW2 */
2287 # define GEN7_PS_SPF_MODE (1 << 31)
2288 # define GEN7_PS_VECTOR_MASK_ENABLE (1 << 30)
2289 # define GEN7_PS_SAMPLER_COUNT_SHIFT 27
2290 # define GEN7_PS_SAMPLER_COUNT_MASK INTEL_MASK(29, 27)
2291 # define GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT 18
2292 # define GEN7_PS_FLOATING_POINT_MODE_IEEE_754 (0 << 16)
2293 # define GEN7_PS_FLOATING_POINT_MODE_ALT (1 << 16)
2294 /* DW3: scratch space */
2295 /* DW4 */
2296 # define IVB_PS_MAX_THREADS_SHIFT 24
2297 # define HSW_PS_MAX_THREADS_SHIFT 23
2298 # define HSW_PS_SAMPLE_MASK_SHIFT 12
2299 # define HSW_PS_SAMPLE_MASK_MASK INTEL_MASK(19, 12)
2300 # define GEN7_PS_PUSH_CONSTANT_ENABLE (1 << 11)
2301 # define GEN7_PS_ATTRIBUTE_ENABLE (1 << 10)
2302 # define GEN7_PS_OMASK_TO_RENDER_TARGET (1 << 9)
2303 # define GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE (1 << 8)
2304 # define GEN7_PS_DUAL_SOURCE_BLEND_ENABLE (1 << 7)
2305 # define GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE (1 << 6)
2306 # define GEN7_PS_POSOFFSET_NONE (0 << 3)
2307 # define GEN7_PS_POSOFFSET_CENTROID (2 << 3)
2308 # define GEN7_PS_POSOFFSET_SAMPLE (3 << 3)
2309 # define GEN7_PS_32_DISPATCH_ENABLE (1 << 2)
2310 # define GEN7_PS_16_DISPATCH_ENABLE (1 << 1)
2311 # define GEN7_PS_8_DISPATCH_ENABLE (1 << 0)
2312 /* DW5 */
2313 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_0 16
2314 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_1 8
2315 # define GEN7_PS_DISPATCH_START_GRF_SHIFT_2 0
2316 /* DW6: kernel 1 pointer */
2317 /* DW7: kernel 2 pointer */
2318
2319 #define _3DSTATE_SAMPLE_MASK 0x7818 /* GEN6+ */
2320
2321 #define _3DSTATE_DRAWING_RECTANGLE 0x7900
2322 #define _3DSTATE_BLEND_CONSTANT_COLOR 0x7901
2323 #define _3DSTATE_CHROMA_KEY 0x7904
2324 #define _3DSTATE_DEPTH_BUFFER 0x7905 /* GEN4-6 */
2325 #define _3DSTATE_POLY_STIPPLE_OFFSET 0x7906
2326 #define _3DSTATE_POLY_STIPPLE_PATTERN 0x7907
2327 #define _3DSTATE_LINE_STIPPLE_PATTERN 0x7908
2328 #define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP 0x7909
2329 #define _3DSTATE_AA_LINE_PARAMETERS 0x790a /* G45+ */
2330
2331 #define _3DSTATE_GS_SVB_INDEX 0x790b /* CTG+ */
2332 /* DW1 */
2333 # define SVB_INDEX_SHIFT 29
2334 # define SVB_LOAD_INTERNAL_VERTEX_COUNT (1 << 0) /* SNB+ */
2335 /* DW2: SVB index */
2336 /* DW3: SVB maximum index */
2337
2338 #define _3DSTATE_MULTISAMPLE 0x790d /* GEN6+ */
2339 #define GEN8_3DSTATE_MULTISAMPLE 0x780d /* GEN8+ */
2340 /* DW1 */
2341 # define MS_PIXEL_LOCATION_CENTER (0 << 4)
2342 # define MS_PIXEL_LOCATION_UPPER_LEFT (1 << 4)
2343 # define MS_NUMSAMPLES_1 (0 << 1)
2344 # define MS_NUMSAMPLES_2 (1 << 1)
2345 # define MS_NUMSAMPLES_4 (2 << 1)
2346 # define MS_NUMSAMPLES_8 (3 << 1)
2347 # define MS_NUMSAMPLES_16 (4 << 1)
2348
2349 #define _3DSTATE_SAMPLE_PATTERN 0x791c
2350
2351 #define _3DSTATE_STENCIL_BUFFER 0x790e /* ILK, SNB */
2352 #define _3DSTATE_HIER_DEPTH_BUFFER 0x790f /* ILK, SNB */
2353
2354 #define GEN7_3DSTATE_CLEAR_PARAMS 0x7804
2355 #define GEN7_3DSTATE_DEPTH_BUFFER 0x7805
2356 #define GEN7_3DSTATE_STENCIL_BUFFER 0x7806
2357 # define HSW_STENCIL_ENABLED (1 << 31)
2358 #define GEN7_3DSTATE_HIER_DEPTH_BUFFER 0x7807
2359
2360 #define _3DSTATE_CLEAR_PARAMS 0x7910 /* ILK, SNB */
2361 # define GEN5_DEPTH_CLEAR_VALID (1 << 15)
2362 /* DW1: depth clear value */
2363 /* DW2 */
2364 # define GEN7_DEPTH_CLEAR_VALID (1 << 0)
2365
2366 #define _3DSTATE_SO_DECL_LIST 0x7917 /* GEN7+ */
2367 /* DW1 */
2368 # define SO_STREAM_TO_BUFFER_SELECTS_3_SHIFT 12
2369 # define SO_STREAM_TO_BUFFER_SELECTS_3_MASK INTEL_MASK(15, 12)
2370 # define SO_STREAM_TO_BUFFER_SELECTS_2_SHIFT 8
2371 # define SO_STREAM_TO_BUFFER_SELECTS_2_MASK INTEL_MASK(11, 8)
2372 # define SO_STREAM_TO_BUFFER_SELECTS_1_SHIFT 4
2373 # define SO_STREAM_TO_BUFFER_SELECTS_1_MASK INTEL_MASK(7, 4)
2374 # define SO_STREAM_TO_BUFFER_SELECTS_0_SHIFT 0
2375 # define SO_STREAM_TO_BUFFER_SELECTS_0_MASK INTEL_MASK(3, 0)
2376 /* DW2 */
2377 # define SO_NUM_ENTRIES_3_SHIFT 24
2378 # define SO_NUM_ENTRIES_3_MASK INTEL_MASK(31, 24)
2379 # define SO_NUM_ENTRIES_2_SHIFT 16
2380 # define SO_NUM_ENTRIES_2_MASK INTEL_MASK(23, 16)
2381 # define SO_NUM_ENTRIES_1_SHIFT 8
2382 # define SO_NUM_ENTRIES_1_MASK INTEL_MASK(15, 8)
2383 # define SO_NUM_ENTRIES_0_SHIFT 0
2384 # define SO_NUM_ENTRIES_0_MASK INTEL_MASK(7, 0)
2385
2386 /* SO_DECL DW0 */
2387 # define SO_DECL_OUTPUT_BUFFER_SLOT_SHIFT 12
2388 # define SO_DECL_OUTPUT_BUFFER_SLOT_MASK INTEL_MASK(13, 12)
2389 # define SO_DECL_HOLE_FLAG (1 << 11)
2390 # define SO_DECL_REGISTER_INDEX_SHIFT 4
2391 # define SO_DECL_REGISTER_INDEX_MASK INTEL_MASK(9, 4)
2392 # define SO_DECL_COMPONENT_MASK_SHIFT 0
2393 # define SO_DECL_COMPONENT_MASK_MASK INTEL_MASK(3, 0)
2394
2395 #define _3DSTATE_SO_BUFFER 0x7918 /* GEN7+ */
2396 /* DW1 */
2397 # define GEN8_SO_BUFFER_ENABLE (1 << 31)
2398 # define SO_BUFFER_INDEX_SHIFT 29
2399 # define SO_BUFFER_INDEX_MASK INTEL_MASK(30, 29)
2400 # define GEN8_SO_BUFFER_OFFSET_WRITE_ENABLE (1 << 21)
2401 # define GEN8_SO_BUFFER_OFFSET_ADDRESS_ENABLE (1 << 20)
2402 # define SO_BUFFER_PITCH_SHIFT 0
2403 # define SO_BUFFER_PITCH_MASK INTEL_MASK(11, 0)
2404 /* DW2: start address */
2405 /* DW3: end address. */
2406
2407 #define CMD_MI_FLUSH 0x0200
2408
2409 # define BLT_X_SHIFT 0
2410 # define BLT_X_MASK INTEL_MASK(15, 0)
2411 # define BLT_Y_SHIFT 16
2412 # define BLT_Y_MASK INTEL_MASK(31, 16)
2413
2414 #define GEN5_MI_REPORT_PERF_COUNT ((0x26 << 23) | (3 - 2))
2415 /* DW0 */
2416 # define GEN5_MI_COUNTER_SET_0 (0 << 6)
2417 # define GEN5_MI_COUNTER_SET_1 (1 << 6)
2418 /* DW1 */
2419 # define MI_COUNTER_ADDRESS_GTT (1 << 0)
2420 /* DW2: a user-defined report ID (written to the buffer but can be anything) */
2421
2422 #define GEN6_MI_REPORT_PERF_COUNT ((0x28 << 23) | (3 - 2))
2423
2424 /* Bitfields for the URB_WRITE message, DW2 of message header: */
2425 #define URB_WRITE_PRIM_END 0x1
2426 #define URB_WRITE_PRIM_START 0x2
2427 #define URB_WRITE_PRIM_TYPE_SHIFT 2
2428
2429
2430 /* Maximum number of entries that can be addressed using a binding table
2431 * pointer of type SURFTYPE_BUFFER
2432 */
2433 #define BRW_MAX_NUM_BUFFER_ENTRIES (1 << 27)
2434
2435 /* Memory Object Control State:
2436 * Specifying zero for L3 means "uncached in L3", at least on Haswell
2437 * and Baytrail, since there are no PTE flags for setting L3 cacheability.
2438 * On Ivybridge, the PTEs do have a cache-in-L3 bit, so setting MOCS to 0
2439 * may still respect that.
2440 */
2441 #define GEN7_MOCS_L3 1
2442
2443 /* Ivybridge only: cache in LLC.
2444 * Specifying zero here means to use the PTE values set by the kernel;
2445 * non-zero overrides the PTE values.
2446 */
2447 #define IVB_MOCS_LLC (1 << 1)
2448
2449 /* Baytrail only: snoop in CPU cache */
2450 #define BYT_MOCS_SNOOP (1 << 1)
2451
2452 /* Haswell only: LLC/eLLC controls (write-back or uncached).
2453 * Specifying zero here means to use the PTE values set by the kernel,
2454 * which is useful since it offers additional control (write-through
2455 * cacheing and age). Non-zero overrides the PTE values.
2456 */
2457 #define HSW_MOCS_UC_LLC_UC_ELLC (1 << 1)
2458 #define HSW_MOCS_WB_LLC_WB_ELLC (2 << 1)
2459 #define HSW_MOCS_UC_LLC_WB_ELLC (3 << 1)
2460
2461 /* Broadwell: these defines always use all available caches (L3, LLC, eLLC),
2462 * and let you force write-back (WB) or write-through (WT) caching, or leave
2463 * it up to the page table entry (PTE) specified by the kernel.
2464 */
2465 #define BDW_MOCS_WB 0x78
2466 #define BDW_MOCS_WT 0x58
2467 #define BDW_MOCS_PTE 0x18
2468
2469 /* Skylake: MOCS is now an index into an array of 64 different configurable
2470 * cache settings. We still use only either write-back or write-through; and
2471 * rely on the documented default values.
2472 */
2473 #define SKL_MOCS_WB 9
2474 #define SKL_MOCS_WT 5
2475
2476 #define MEDIA_VFE_STATE 0x7000
2477 /* GEN7 DW2, GEN8+ DW3 */
2478 # define MEDIA_VFE_STATE_MAX_THREADS_SHIFT 16
2479 # define MEDIA_VFE_STATE_MAX_THREADS_MASK INTEL_MASK(31, 16)
2480 # define MEDIA_VFE_STATE_URB_ENTRIES_SHIFT 8
2481 # define MEDIA_VFE_STATE_URB_ENTRIES_MASK INTEL_MASK(15, 8)
2482 # define MEDIA_VFE_STATE_RESET_GTW_TIMER_SHIFT 7
2483 # define MEDIA_VFE_STATE_RESET_GTW_TIMER_MASK INTEL_MASK(7, 7)
2484 # define MEDIA_VFE_STATE_BYPASS_GTW_SHIFT 6
2485 # define MEDIA_VFE_STATE_BYPASS_GTW_MASK INTEL_MASK(6, 6)
2486 # define GEN7_MEDIA_VFE_STATE_GPGPU_MODE_SHIFT 2
2487 # define GEN7_MEDIA_VFE_STATE_GPGPU_MODE_MASK INTEL_MASK(2, 2)
2488 /* GEN7 DW4, GEN8+ DW5 */
2489 # define MEDIA_VFE_STATE_URB_ALLOC_SHIFT 16
2490 # define MEDIA_VFE_STATE_URB_ALLOC_MASK INTEL_MASK(31, 16)
2491 # define MEDIA_VFE_STATE_CURBE_ALLOC_SHIFT 0
2492 # define MEDIA_VFE_STATE_CURBE_ALLOC_MASK INTEL_MASK(15, 0)
2493
2494 #define MEDIA_INTERFACE_DESCRIPTOR_LOAD 0x7002
2495 #define MEDIA_STATE_FLUSH 0x7004
2496 #define GPGPU_WALKER 0x7105
2497 /* GEN8+ DW2 */
2498 # define GPGPU_WALKER_INDIRECT_LENGTH_SHIFT 0
2499 # define GPGPU_WALKER_INDIRECT_LENGTH_MASK INTEL_MASK(15, 0)
2500 /* GEN7 DW2, GEN8+ DW4 */
2501 # define GPGPU_WALKER_SIMD_SIZE_SHIFT 30
2502 # define GPGPU_WALKER_SIMD_SIZE_MASK INTEL_MASK(31, 30)
2503 # define GPGPU_WALKER_THREAD_DEPTH_MAX_SHIFT 16
2504 # define GPGPU_WALKER_THREAD_DEPTH_MAX_MASK INTEL_MASK(21, 16)
2505 # define GPGPU_WALKER_THREAD_HEIGHT_MAX_SHIFT 8
2506 # define GPGPU_WALKER_THREAD_HEIGHT_MAX_MASK INTEL_MASK(31, 8)
2507 # define GPGPU_WALKER_THREAD_WIDTH_MAX_SHIFT 0
2508 # define GPGPU_WALKER_THREAD_WIDTH_MAX_MASK INTEL_MASK(5, 0)
2509
2510 #endif