Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  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_BITS(data, high, low) ((data & INTEL_MASK((high), (low))) >> (low))
  42. #define GET_FIELD(word, field) (((word)  & field ## _MASK) >> field ## _SHIFT)
  43.  
  44. #ifndef BRW_DEFINES_H
  45. #define BRW_DEFINES_H
  46.  
  47. /* 3D state:
  48.  */
  49. #define CMD_3D_PRIM                                 0x7b00 /* 3DPRIMITIVE */
  50. /* DW0 */
  51. # define GEN4_3DPRIM_TOPOLOGY_TYPE_SHIFT            10
  52. # define GEN4_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 15)
  53. # define GEN4_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     (1 << 15)
  54. # define GEN7_3DPRIM_INDIRECT_PARAMETER_ENABLE      (1 << 10)
  55. # define GEN7_3DPRIM_PREDICATE_ENABLE               (1 << 8)
  56. /* DW1 */
  57. # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL (0 << 8)
  58. # define GEN7_3DPRIM_VERTEXBUFFER_ACCESS_RANDOM     (1 << 8)
  59.  
  60. #define _3DPRIM_POINTLIST         0x01
  61. #define _3DPRIM_LINELIST          0x02
  62. #define _3DPRIM_LINESTRIP         0x03
  63. #define _3DPRIM_TRILIST           0x04
  64. #define _3DPRIM_TRISTRIP          0x05
  65. #define _3DPRIM_TRIFAN            0x06
  66. #define _3DPRIM_QUADLIST          0x07
  67. #define _3DPRIM_QUADSTRIP         0x08
  68. #define _3DPRIM_LINELIST_ADJ      0x09
  69. #define _3DPRIM_LINESTRIP_ADJ     0x0A
  70. #define _3DPRIM_TRILIST_ADJ       0x0B
  71. #define _3DPRIM_TRISTRIP_ADJ      0x0C
  72. #define _3DPRIM_TRISTRIP_REVERSE  0x0D
  73. #define _3DPRIM_POLYGON           0x0E
  74. #define _3DPRIM_RECTLIST          0x0F
  75. #define _3DPRIM_LINELOOP          0x10
  76. #define _3DPRIM_POINTLIST_BF      0x11
  77. #define _3DPRIM_LINESTRIP_CONT    0x12
  78. #define _3DPRIM_LINESTRIP_BF      0x13
  79. #define _3DPRIM_LINESTRIP_CONT_BF 0x14
  80. #define _3DPRIM_TRIFAN_NOSTIPPLE  0x15
  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 DW1 */
  534. #define GEN8_SURFACE_MOCS_SHIFT         24
  535. #define GEN8_SURFACE_MOCS_MASK          INTEL_MASK(30, 24)
  536. #define GEN8_SURFACE_QPITCH_SHIFT       0
  537. #define GEN8_SURFACE_QPITCH_MASK        INTEL_MASK(14, 0)
  538.  
  539. /* Surface state DW2 */
  540. #define BRW_SURFACE_HEIGHT_SHIFT        19
  541. #define BRW_SURFACE_HEIGHT_MASK         INTEL_MASK(31, 19)
  542. #define BRW_SURFACE_WIDTH_SHIFT         6
  543. #define BRW_SURFACE_WIDTH_MASK          INTEL_MASK(18, 6)
  544. #define BRW_SURFACE_LOD_SHIFT           2
  545. #define BRW_SURFACE_LOD_MASK            INTEL_MASK(5, 2)
  546. #define GEN7_SURFACE_HEIGHT_SHIFT       16
  547. #define GEN7_SURFACE_HEIGHT_MASK        INTEL_MASK(29, 16)
  548. #define GEN7_SURFACE_WIDTH_SHIFT        0
  549. #define GEN7_SURFACE_WIDTH_MASK         INTEL_MASK(13, 0)
  550.  
  551. /* Surface state DW3 */
  552. #define BRW_SURFACE_DEPTH_SHIFT         21
  553. #define BRW_SURFACE_DEPTH_MASK          INTEL_MASK(31, 21)
  554. #define BRW_SURFACE_PITCH_SHIFT         3
  555. #define BRW_SURFACE_PITCH_MASK          INTEL_MASK(19, 3)
  556. #define BRW_SURFACE_TILED               (1 << 1)
  557. #define BRW_SURFACE_TILED_Y             (1 << 0)
  558. #define HSW_SURFACE_IS_INTEGER_FORMAT   (1 << 18)
  559.  
  560. /* Surface state DW4 */
  561. #define BRW_SURFACE_MIN_LOD_SHIFT       28
  562. #define BRW_SURFACE_MIN_LOD_MASK        INTEL_MASK(31, 28)
  563. #define BRW_SURFACE_MIN_ARRAY_ELEMENT_SHIFT     17
  564. #define BRW_SURFACE_MIN_ARRAY_ELEMENT_MASK      INTEL_MASK(27, 17)
  565. #define BRW_SURFACE_RENDER_TARGET_VIEW_EXTENT_SHIFT     8
  566. #define BRW_SURFACE_RENDER_TARGET_VIEW_EXTENT_MASK      INTEL_MASK(16, 8)
  567. #define BRW_SURFACE_MULTISAMPLECOUNT_1  (0 << 4)
  568. #define BRW_SURFACE_MULTISAMPLECOUNT_4  (2 << 4)
  569. #define GEN7_SURFACE_MULTISAMPLECOUNT_1         (0 << 3)
  570. #define GEN8_SURFACE_MULTISAMPLECOUNT_2         (1 << 3)
  571. #define GEN7_SURFACE_MULTISAMPLECOUNT_4         (2 << 3)
  572. #define GEN7_SURFACE_MULTISAMPLECOUNT_8         (3 << 3)
  573. #define GEN8_SURFACE_MULTISAMPLECOUNT_16        (4 << 3)
  574. #define GEN7_SURFACE_MSFMT_MSS                  (0 << 6)
  575. #define GEN7_SURFACE_MSFMT_DEPTH_STENCIL        (1 << 6)
  576. #define GEN7_SURFACE_MIN_ARRAY_ELEMENT_SHIFT    18
  577. #define GEN7_SURFACE_MIN_ARRAY_ELEMENT_MASK     INTEL_MASK(28, 18)
  578. #define GEN7_SURFACE_RENDER_TARGET_VIEW_EXTENT_SHIFT    7
  579. #define GEN7_SURFACE_RENDER_TARGET_VIEW_EXTENT_MASK   INTEL_MASK(17, 7)
  580.  
  581. /* Surface state DW5 */
  582. #define BRW_SURFACE_X_OFFSET_SHIFT              25
  583. #define BRW_SURFACE_X_OFFSET_MASK               INTEL_MASK(31, 25)
  584. #define BRW_SURFACE_VERTICAL_ALIGN_ENABLE       (1 << 24)
  585. #define BRW_SURFACE_Y_OFFSET_SHIFT              20
  586. #define BRW_SURFACE_Y_OFFSET_MASK               INTEL_MASK(23, 20)
  587. #define GEN7_SURFACE_MIN_LOD_SHIFT              4
  588. #define GEN7_SURFACE_MIN_LOD_MASK               INTEL_MASK(7, 4)
  589. #define GEN8_SURFACE_Y_OFFSET_SHIFT             21
  590. #define GEN8_SURFACE_Y_OFFSET_MASK              INTEL_MASK(23, 21)
  591.  
  592. #define GEN7_SURFACE_MOCS_SHIFT                 16
  593. #define GEN7_SURFACE_MOCS_MASK                  INTEL_MASK(19, 16)
  594.  
  595. /* Surface state DW6 */
  596. #define GEN7_SURFACE_MCS_ENABLE                 (1 << 0)
  597. #define GEN7_SURFACE_MCS_PITCH_SHIFT            3
  598. #define GEN7_SURFACE_MCS_PITCH_MASK             INTEL_MASK(11, 3)
  599. #define GEN8_SURFACE_AUX_QPITCH_SHIFT           16
  600. #define GEN8_SURFACE_AUX_QPITCH_MASK            INTEL_MASK(30, 16)
  601. #define GEN8_SURFACE_AUX_PITCH_SHIFT            3
  602. #define GEN8_SURFACE_AUX_PITCH_MASK             INTEL_MASK(11, 3)
  603. #define GEN8_SURFACE_AUX_MODE_MASK              INTEL_MASK(2, 0)
  604.  
  605. #define GEN8_SURFACE_AUX_MODE_NONE              0
  606. #define GEN8_SURFACE_AUX_MODE_MCS               1
  607. #define GEN8_SURFACE_AUX_MODE_APPEND            2
  608. #define GEN8_SURFACE_AUX_MODE_HIZ               3
  609.  
  610. /* Surface state DW7 */
  611. #define GEN9_SURFACE_RT_COMPRESSION_SHIFT       30
  612. #define GEN9_SURFACE_RT_COMPRESSION_MASK        INTEL_MASK(30, 30)
  613. #define GEN7_SURFACE_CLEAR_COLOR_SHIFT          28
  614. #define GEN7_SURFACE_SCS_R_SHIFT                25
  615. #define GEN7_SURFACE_SCS_R_MASK                 INTEL_MASK(27, 25)
  616. #define GEN7_SURFACE_SCS_G_SHIFT                22
  617. #define GEN7_SURFACE_SCS_G_MASK                 INTEL_MASK(24, 22)
  618. #define GEN7_SURFACE_SCS_B_SHIFT                19
  619. #define GEN7_SURFACE_SCS_B_MASK                 INTEL_MASK(21, 19)
  620. #define GEN7_SURFACE_SCS_A_SHIFT                16
  621. #define GEN7_SURFACE_SCS_A_MASK                 INTEL_MASK(18, 16)
  622.  
  623. /* The actual swizzle values/what channel to use */
  624. #define HSW_SCS_ZERO                     0
  625. #define HSW_SCS_ONE                      1
  626. #define HSW_SCS_RED                      4
  627. #define HSW_SCS_GREEN                    5
  628. #define HSW_SCS_BLUE                     6
  629. #define HSW_SCS_ALPHA                    7
  630.  
  631. /* SAMPLER_STATE DW0 */
  632. #define BRW_SAMPLER_DISABLE                     (1 << 31)
  633. #define BRW_SAMPLER_LOD_PRECLAMP_ENABLE         (1 << 28)
  634. #define GEN6_SAMPLER_MIN_MAG_NOT_EQUAL          (1 << 27) /* Gen6 only */
  635. #define BRW_SAMPLER_BASE_MIPLEVEL_MASK          INTEL_MASK(26, 22)
  636. #define BRW_SAMPLER_BASE_MIPLEVEL_SHIFT         22
  637. #define BRW_SAMPLER_MIP_FILTER_MASK             INTEL_MASK(21, 20)
  638. #define BRW_SAMPLER_MIP_FILTER_SHIFT            20
  639. #define BRW_SAMPLER_MAG_FILTER_MASK             INTEL_MASK(19, 17)
  640. #define BRW_SAMPLER_MAG_FILTER_SHIFT            17
  641. #define BRW_SAMPLER_MIN_FILTER_MASK             INTEL_MASK(16, 14)
  642. #define BRW_SAMPLER_MIN_FILTER_SHIFT            14
  643. #define GEN4_SAMPLER_LOD_BIAS_MASK              INTEL_MASK(13, 3)
  644. #define GEN4_SAMPLER_LOD_BIAS_SHIFT             3
  645. #define GEN4_SAMPLER_SHADOW_FUNCTION_MASK       INTEL_MASK(2, 0)
  646. #define GEN4_SAMPLER_SHADOW_FUNCTION_SHIFT      0
  647.  
  648. #define GEN7_SAMPLER_LOD_BIAS_MASK              INTEL_MASK(13, 1)
  649. #define GEN7_SAMPLER_LOD_BIAS_SHIFT             1
  650. #define GEN7_SAMPLER_EWA_ANISOTROPIC_ALGORITHM  (1 << 0)
  651.  
  652. /* SAMPLER_STATE DW1 */
  653. #define GEN4_SAMPLER_MIN_LOD_MASK               INTEL_MASK(31, 22)
  654. #define GEN4_SAMPLER_MIN_LOD_SHIFT              22
  655. #define GEN4_SAMPLER_MAX_LOD_MASK               INTEL_MASK(21, 12)
  656. #define GEN4_SAMPLER_MAX_LOD_SHIFT              12
  657. #define GEN4_SAMPLER_CUBE_CONTROL_OVERRIDE      (1 << 9)
  658. /* Wrap modes are in DW1 on Gen4-6 and DW3 on Gen7+ */
  659. #define BRW_SAMPLER_TCX_WRAP_MODE_MASK          INTEL_MASK(8, 6)
  660. #define BRW_SAMPLER_TCX_WRAP_MODE_SHIFT         6
  661. #define BRW_SAMPLER_TCY_WRAP_MODE_MASK          INTEL_MASK(5, 3)
  662. #define BRW_SAMPLER_TCY_WRAP_MODE_SHIFT         3
  663. #define BRW_SAMPLER_TCZ_WRAP_MODE_MASK          INTEL_MASK(2, 0)
  664. #define BRW_SAMPLER_TCZ_WRAP_MODE_SHIFT         0
  665.  
  666. #define GEN7_SAMPLER_MIN_LOD_MASK               INTEL_MASK(31, 20)
  667. #define GEN7_SAMPLER_MIN_LOD_SHIFT              20
  668. #define GEN7_SAMPLER_MAX_LOD_MASK               INTEL_MASK(19, 8)
  669. #define GEN7_SAMPLER_MAX_LOD_SHIFT              8
  670. #define GEN7_SAMPLER_SHADOW_FUNCTION_MASK       INTEL_MASK(3, 1)
  671. #define GEN7_SAMPLER_SHADOW_FUNCTION_SHIFT      1
  672. #define GEN7_SAMPLER_CUBE_CONTROL_OVERRIDE      (1 << 0)
  673.  
  674. /* SAMPLER_STATE DW2 - border color pointer */
  675.  
  676. /* SAMPLER_STATE DW3 */
  677. #define BRW_SAMPLER_MAX_ANISOTROPY_MASK         INTEL_MASK(21, 19)
  678. #define BRW_SAMPLER_MAX_ANISOTROPY_SHIFT        19
  679. #define BRW_SAMPLER_ADDRESS_ROUNDING_MASK       INTEL_MASK(18, 13)
  680. #define BRW_SAMPLER_ADDRESS_ROUNDING_SHIFT      13
  681. #define GEN7_SAMPLER_NON_NORMALIZED_COORDINATES (1 << 10)
  682. /* Gen7+ wrap modes reuse the same BRW_SAMPLER_TC*_WRAP_MODE enums. */
  683. #define GEN6_SAMPLER_NON_NORMALIZED_COORDINATES (1 << 0)
  684.  
  685. enum brw_wrap_mode {
  686.    BRW_TEXCOORDMODE_WRAP         = 0,
  687.    BRW_TEXCOORDMODE_MIRROR       = 1,
  688.    BRW_TEXCOORDMODE_CLAMP        = 2,
  689.    BRW_TEXCOORDMODE_CUBE         = 3,
  690.    BRW_TEXCOORDMODE_CLAMP_BORDER = 4,
  691.    BRW_TEXCOORDMODE_MIRROR_ONCE  = 5,
  692.    GEN8_TEXCOORDMODE_HALF_BORDER = 6,
  693. };
  694.  
  695. #define BRW_THREAD_PRIORITY_NORMAL   0
  696. #define BRW_THREAD_PRIORITY_HIGH     1
  697.  
  698. #define BRW_TILEWALK_XMAJOR                 0
  699. #define BRW_TILEWALK_YMAJOR                 1
  700.  
  701. #define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS  0
  702. #define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS  1
  703.  
  704. /* Execution Unit (EU) defines
  705.  */
  706.  
  707. #define BRW_ALIGN_1   0
  708. #define BRW_ALIGN_16  1
  709.  
  710. #define BRW_ADDRESS_DIRECT                        0
  711. #define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER    1
  712.  
  713. #define BRW_CHANNEL_X     0
  714. #define BRW_CHANNEL_Y     1
  715. #define BRW_CHANNEL_Z     2
  716. #define BRW_CHANNEL_W     3
  717.  
  718. enum brw_compression {
  719.    BRW_COMPRESSION_NONE       = 0,
  720.    BRW_COMPRESSION_2NDHALF    = 1,
  721.    BRW_COMPRESSION_COMPRESSED = 2,
  722. };
  723.  
  724. #define GEN6_COMPRESSION_1Q             0
  725. #define GEN6_COMPRESSION_2Q             1
  726. #define GEN6_COMPRESSION_3Q             2
  727. #define GEN6_COMPRESSION_4Q             3
  728. #define GEN6_COMPRESSION_1H             0
  729. #define GEN6_COMPRESSION_2H             2
  730.  
  731. enum PACKED brw_conditional_mod {
  732.    BRW_CONDITIONAL_NONE = 0,
  733.    BRW_CONDITIONAL_Z    = 1,
  734.    BRW_CONDITIONAL_NZ   = 2,
  735.    BRW_CONDITIONAL_EQ   = 1,    /* Z */
  736.    BRW_CONDITIONAL_NEQ  = 2,    /* NZ */
  737.    BRW_CONDITIONAL_G    = 3,
  738.    BRW_CONDITIONAL_GE   = 4,
  739.    BRW_CONDITIONAL_L    = 5,
  740.    BRW_CONDITIONAL_LE   = 6,
  741.    BRW_CONDITIONAL_R    = 7,    /* Gen <= 5 */
  742.    BRW_CONDITIONAL_O    = 8,
  743.    BRW_CONDITIONAL_U    = 9,
  744. };
  745.  
  746. #define BRW_DEBUG_NONE        0
  747. #define BRW_DEBUG_BREAKPOINT  1
  748.  
  749. #define BRW_DEPENDENCY_NORMAL         0
  750. #define BRW_DEPENDENCY_NOTCLEARED     1
  751. #define BRW_DEPENDENCY_NOTCHECKED     2
  752. #define BRW_DEPENDENCY_DISABLE        3
  753.  
  754. enum PACKED brw_execution_size {
  755.    BRW_EXECUTE_1  = 0,
  756.    BRW_EXECUTE_2  = 1,
  757.    BRW_EXECUTE_4  = 2,
  758.    BRW_EXECUTE_8  = 3,
  759.    BRW_EXECUTE_16 = 4,
  760.    BRW_EXECUTE_32 = 5,
  761. };
  762.  
  763. enum PACKED brw_horizontal_stride {
  764.    BRW_HORIZONTAL_STRIDE_0 = 0,
  765.    BRW_HORIZONTAL_STRIDE_1 = 1,
  766.    BRW_HORIZONTAL_STRIDE_2 = 2,
  767.    BRW_HORIZONTAL_STRIDE_4 = 3,
  768. };
  769.  
  770. #define BRW_INSTRUCTION_NORMAL    0
  771. #define BRW_INSTRUCTION_SATURATE  1
  772.  
  773. #define BRW_MASK_ENABLE   0
  774. #define BRW_MASK_DISABLE  1
  775.  
  776. /** @{
  777.  *
  778.  * Gen6 has replaced "mask enable/disable" with WECtrl, which is
  779.  * effectively the same but much simpler to think about.  Now, there
  780.  * are two contributors ANDed together to whether channels are
  781.  * executed: The predication on the instruction, and the channel write
  782.  * enable.
  783.  */
  784. /**
  785.  * This is the default value.  It means that a channel's write enable is set
  786.  * if the per-channel IP is pointing at this instruction.
  787.  */
  788. #define BRW_WE_NORMAL           0
  789. /**
  790.  * This is used like BRW_MASK_DISABLE, and causes all channels to have
  791.  * their write enable set.  Note that predication still contributes to
  792.  * whether the channel actually gets written.
  793.  */
  794. #define BRW_WE_ALL              1
  795. /** @} */
  796.  
  797. enum opcode {
  798.    /* These are the actual hardware opcodes. */
  799.    BRW_OPCODE_MOV =     1,
  800.    BRW_OPCODE_SEL =     2,
  801.    BRW_OPCODE_NOT =     4,
  802.    BRW_OPCODE_AND =     5,
  803.    BRW_OPCODE_OR =      6,
  804.    BRW_OPCODE_XOR =     7,
  805.    BRW_OPCODE_SHR =     8,
  806.    BRW_OPCODE_SHL =     9,
  807.    BRW_OPCODE_ASR =     12,
  808.    BRW_OPCODE_CMP =     16,
  809.    BRW_OPCODE_CMPN =    17,
  810.    BRW_OPCODE_CSEL =    18,  /**< Gen8+ */
  811.    BRW_OPCODE_F32TO16 = 19,  /**< Gen7 only */
  812.    BRW_OPCODE_F16TO32 = 20,  /**< Gen7 only */
  813.    BRW_OPCODE_BFREV =   23,  /**< Gen7+ */
  814.    BRW_OPCODE_BFE =     24,  /**< Gen7+ */
  815.    BRW_OPCODE_BFI1 =    25,  /**< Gen7+ */
  816.    BRW_OPCODE_BFI2 =    26,  /**< Gen7+ */
  817.    BRW_OPCODE_JMPI =    32,
  818.    BRW_OPCODE_IF =      34,
  819.    BRW_OPCODE_IFF =     35,  /**< Pre-Gen6 */
  820.    BRW_OPCODE_ELSE =    36,
  821.    BRW_OPCODE_ENDIF =   37,
  822.    BRW_OPCODE_DO =      38,
  823.    BRW_OPCODE_WHILE =   39,
  824.    BRW_OPCODE_BREAK =   40,
  825.    BRW_OPCODE_CONTINUE = 41,
  826.    BRW_OPCODE_HALT =    42,
  827.    BRW_OPCODE_MSAVE =   44,  /**< Pre-Gen6 */
  828.    BRW_OPCODE_MRESTORE = 45, /**< Pre-Gen6 */
  829.    BRW_OPCODE_PUSH =    46,  /**< Pre-Gen6 */
  830.    BRW_OPCODE_GOTO =    46,  /**< Gen8+    */
  831.    BRW_OPCODE_POP =     47,  /**< Pre-Gen6 */
  832.    BRW_OPCODE_WAIT =    48,
  833.    BRW_OPCODE_SEND =    49,
  834.    BRW_OPCODE_SENDC =   50,
  835.    BRW_OPCODE_MATH =    56,  /**< Gen6+ */
  836.    BRW_OPCODE_ADD =     64,
  837.    BRW_OPCODE_MUL =     65,
  838.    BRW_OPCODE_AVG =     66,
  839.    BRW_OPCODE_FRC =     67,
  840.    BRW_OPCODE_RNDU =    68,
  841.    BRW_OPCODE_RNDD =    69,
  842.    BRW_OPCODE_RNDE =    70,
  843.    BRW_OPCODE_RNDZ =    71,
  844.    BRW_OPCODE_MAC =     72,
  845.    BRW_OPCODE_MACH =    73,
  846.    BRW_OPCODE_LZD =     74,
  847.    BRW_OPCODE_FBH =     75,  /**< Gen7+ */
  848.    BRW_OPCODE_FBL =     76,  /**< Gen7+ */
  849.    BRW_OPCODE_CBIT =    77,  /**< Gen7+ */
  850.    BRW_OPCODE_ADDC =    78,  /**< Gen7+ */
  851.    BRW_OPCODE_SUBB =    79,  /**< Gen7+ */
  852.    BRW_OPCODE_SAD2 =    80,
  853.    BRW_OPCODE_SADA2 =   81,
  854.    BRW_OPCODE_DP4 =     84,
  855.    BRW_OPCODE_DPH =     85,
  856.    BRW_OPCODE_DP3 =     86,
  857.    BRW_OPCODE_DP2 =     87,
  858.    BRW_OPCODE_LINE =    89,
  859.    BRW_OPCODE_PLN =     90,  /**< G45+ */
  860.    BRW_OPCODE_MAD =     91,  /**< Gen6+ */
  861.    BRW_OPCODE_LRP =     92,  /**< Gen6+ */
  862.    BRW_OPCODE_NENOP =   125, /**< G45 only */
  863.    BRW_OPCODE_NOP =     126,
  864.  
  865.    /* These are compiler backend opcodes that get translated into other
  866.     * instructions.
  867.     */
  868.    FS_OPCODE_FB_WRITE = 128,
  869.    FS_OPCODE_BLORP_FB_WRITE,
  870.    FS_OPCODE_REP_FB_WRITE,
  871.    SHADER_OPCODE_RCP,
  872.    SHADER_OPCODE_RSQ,
  873.    SHADER_OPCODE_SQRT,
  874.    SHADER_OPCODE_EXP2,
  875.    SHADER_OPCODE_LOG2,
  876.    SHADER_OPCODE_POW,
  877.    SHADER_OPCODE_INT_QUOTIENT,
  878.    SHADER_OPCODE_INT_REMAINDER,
  879.    SHADER_OPCODE_SIN,
  880.    SHADER_OPCODE_COS,
  881.  
  882.    SHADER_OPCODE_TEX,
  883.    SHADER_OPCODE_TXD,
  884.    SHADER_OPCODE_TXF,
  885.    SHADER_OPCODE_TXL,
  886.    SHADER_OPCODE_TXS,
  887.    FS_OPCODE_TXB,
  888.    SHADER_OPCODE_TXF_CMS,
  889.    SHADER_OPCODE_TXF_UMS,
  890.    SHADER_OPCODE_TXF_MCS,
  891.    SHADER_OPCODE_LOD,
  892.    SHADER_OPCODE_TG4,
  893.    SHADER_OPCODE_TG4_OFFSET,
  894.  
  895.    /**
  896.     * Combines multiple sources of size 1 into a larger virtual GRF.
  897.     * For example, parameters for a send-from-GRF message.  Or, updating
  898.     * channels of a size 4 VGRF used to store vec4s such as texturing results.
  899.     *
  900.     * This will be lowered into MOVs from each source to consecutive reg_offsets
  901.     * of the destination VGRF.
  902.     *
  903.     * src[0] may be BAD_FILE.  If so, the lowering pass skips emitting the MOV,
  904.     * but still reserves the first channel of the destination VGRF.  This can be
  905.     * used to reserve space for, say, a message header set up by the generators.
  906.     */
  907.    SHADER_OPCODE_LOAD_PAYLOAD,
  908.  
  909.    SHADER_OPCODE_SHADER_TIME_ADD,
  910.  
  911.    SHADER_OPCODE_UNTYPED_ATOMIC,
  912.    SHADER_OPCODE_UNTYPED_SURFACE_READ,
  913.    SHADER_OPCODE_UNTYPED_SURFACE_WRITE,
  914.  
  915.    SHADER_OPCODE_TYPED_ATOMIC,
  916.    SHADER_OPCODE_TYPED_SURFACE_READ,
  917.    SHADER_OPCODE_TYPED_SURFACE_WRITE,
  918.  
  919.    SHADER_OPCODE_MEMORY_FENCE,
  920.  
  921.    SHADER_OPCODE_GEN4_SCRATCH_READ,
  922.    SHADER_OPCODE_GEN4_SCRATCH_WRITE,
  923.    SHADER_OPCODE_GEN7_SCRATCH_READ,
  924.  
  925.    SHADER_OPCODE_URB_WRITE_SIMD8,
  926.  
  927.    /**
  928.     * Return the index of an arbitrary live channel (i.e. one of the channels
  929.     * enabled in the current execution mask) and assign it to the first
  930.     * component of the destination.  Expected to be used as input for the
  931.     * BROADCAST pseudo-opcode.
  932.     */
  933.    SHADER_OPCODE_FIND_LIVE_CHANNEL,
  934.  
  935.    /**
  936.     * Pick the channel from its first source register given by the index
  937.     * specified as second source.  Useful for variable indexing of surfaces.
  938.     */
  939.    SHADER_OPCODE_BROADCAST,
  940.  
  941.    VEC4_OPCODE_MOV_BYTES,
  942.    VEC4_OPCODE_PACK_BYTES,
  943.    VEC4_OPCODE_UNPACK_UNIFORM,
  944.  
  945.    FS_OPCODE_DDX_COARSE,
  946.    FS_OPCODE_DDX_FINE,
  947.    /**
  948.     * Compute dFdy(), dFdyCoarse(), or dFdyFine().
  949.     * src1 is an immediate storing the key->render_to_fbo boolean.
  950.     */
  951.    FS_OPCODE_DDY_COARSE,
  952.    FS_OPCODE_DDY_FINE,
  953.    FS_OPCODE_CINTERP,
  954.    FS_OPCODE_LINTERP,
  955.    FS_OPCODE_PIXEL_X,
  956.    FS_OPCODE_PIXEL_Y,
  957.    FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD,
  958.    FS_OPCODE_UNIFORM_PULL_CONSTANT_LOAD_GEN7,
  959.    FS_OPCODE_VARYING_PULL_CONSTANT_LOAD,
  960.    FS_OPCODE_VARYING_PULL_CONSTANT_LOAD_GEN7,
  961.    FS_OPCODE_MOV_DISPATCH_TO_FLAGS,
  962.    FS_OPCODE_DISCARD_JUMP,
  963.    FS_OPCODE_SET_OMASK,
  964.    FS_OPCODE_SET_SAMPLE_ID,
  965.    FS_OPCODE_SET_SIMD4X2_OFFSET,
  966.    FS_OPCODE_PACK_HALF_2x16_SPLIT,
  967.    FS_OPCODE_UNPACK_HALF_2x16_SPLIT_X,
  968.    FS_OPCODE_UNPACK_HALF_2x16_SPLIT_Y,
  969.    FS_OPCODE_PLACEHOLDER_HALT,
  970.    FS_OPCODE_INTERPOLATE_AT_CENTROID,
  971.    FS_OPCODE_INTERPOLATE_AT_SAMPLE,
  972.    FS_OPCODE_INTERPOLATE_AT_SHARED_OFFSET,
  973.    FS_OPCODE_INTERPOLATE_AT_PER_SLOT_OFFSET,
  974.  
  975.    VS_OPCODE_URB_WRITE,
  976.    VS_OPCODE_PULL_CONSTANT_LOAD,
  977.    VS_OPCODE_PULL_CONSTANT_LOAD_GEN7,
  978.    VS_OPCODE_SET_SIMD4X2_HEADER_GEN9,
  979.    VS_OPCODE_UNPACK_FLAGS_SIMD4X2,
  980.  
  981.    /**
  982.     * Write geometry shader output data to the URB.
  983.     *
  984.     * Unlike VS_OPCODE_URB_WRITE, this opcode doesn't do an implied move from
  985.     * R0 to the first MRF.  This allows the geometry shader to override the
  986.     * "Slot {0,1} Offset" fields in the message header.
  987.     */
  988.    GS_OPCODE_URB_WRITE,
  989.  
  990.    /**
  991.     * Write geometry shader output data to the URB and request a new URB
  992.     * handle (gen6).
  993.     *
  994.     * This opcode doesn't do an implied move from R0 to the first MRF.
  995.     */
  996.    GS_OPCODE_URB_WRITE_ALLOCATE,
  997.  
  998.    /**
  999.     * Terminate the geometry shader thread by doing an empty URB write.
  1000.     *
  1001.     * This opcode doesn't do an implied move from R0 to the first MRF.  This
  1002.     * allows the geometry shader to override the "GS Number of Output Vertices
  1003.     * for Slot {0,1}" fields in the message header.
  1004.     */
  1005.    GS_OPCODE_THREAD_END,
  1006.  
  1007.    /**
  1008.     * Set the "Slot {0,1} Offset" fields of a URB_WRITE message header.
  1009.     *
  1010.     * - dst is the MRF containing the message header.
  1011.     *
  1012.     * - src0.x indicates which portion of the URB should be written to (e.g. a
  1013.     *   vertex number)
  1014.     *
  1015.     * - src1 is an immediate multiplier which will be applied to src0
  1016.     *   (e.g. the size of a single vertex in the URB).
  1017.     *
  1018.     * Note: the hardware will apply this offset *in addition to* the offset in
  1019.     * vec4_instruction::offset.
  1020.     */
  1021.    GS_OPCODE_SET_WRITE_OFFSET,
  1022.  
  1023.    /**
  1024.     * Set the "GS Number of Output Vertices for Slot {0,1}" fields of a
  1025.     * URB_WRITE message header.
  1026.     *
  1027.     * - dst is the MRF containing the message header.
  1028.     *
  1029.     * - src0.x is the vertex count.  The upper 16 bits will be ignored.
  1030.     */
  1031.    GS_OPCODE_SET_VERTEX_COUNT,
  1032.  
  1033.    /**
  1034.     * Set DWORD 2 of dst to the value in src.
  1035.     */
  1036.    GS_OPCODE_SET_DWORD_2,
  1037.  
  1038.    /**
  1039.     * Prepare the dst register for storage in the "Channel Mask" fields of a
  1040.     * URB_WRITE message header.
  1041.     *
  1042.     * DWORD 4 of dst is shifted left by 4 bits, so that later,
  1043.     * GS_OPCODE_SET_CHANNEL_MASKS can OR DWORDs 0 and 4 together to form the
  1044.     * final channel mask.
  1045.     *
  1046.     * Note: since GS_OPCODE_SET_CHANNEL_MASKS ORs DWORDs 0 and 4 together to
  1047.     * form the final channel mask, DWORDs 0 and 4 of the dst register must not
  1048.     * have any extraneous bits set prior to execution of this opcode (that is,
  1049.     * they should be in the range 0x0 to 0xf).
  1050.     */
  1051.    GS_OPCODE_PREPARE_CHANNEL_MASKS,
  1052.  
  1053.    /**
  1054.     * Set the "Channel Mask" fields of a URB_WRITE message header.
  1055.     *
  1056.     * - dst is the MRF containing the message header.
  1057.     *
  1058.     * - src.x is the channel mask, as prepared by
  1059.     *   GS_OPCODE_PREPARE_CHANNEL_MASKS.  DWORDs 0 and 4 are OR'ed together to
  1060.     *   form the final channel mask.
  1061.     */
  1062.    GS_OPCODE_SET_CHANNEL_MASKS,
  1063.  
  1064.    /**
  1065.     * Get the "Instance ID" fields from the payload.
  1066.     *
  1067.     * - dst is the GRF for gl_InvocationID.
  1068.     */
  1069.    GS_OPCODE_GET_INSTANCE_ID,
  1070.  
  1071.    /**
  1072.     * Send a FF_SYNC message to allocate initial URB handles (gen6).
  1073.     *
  1074.     * - dst will be used as the writeback register for the FF_SYNC operation.
  1075.     *
  1076.     * - src0 is the number of primitives written.
  1077.     *
  1078.     * - src1 is the value to hold in M0.0: number of SO vertices to write
  1079.     *   and number of SO primitives needed. Its value will be overwritten
  1080.     *   with the SVBI values if transform feedback is enabled.
  1081.     *
  1082.     * Note: This opcode uses an implicit MRF register for the ff_sync message
  1083.     * header, so the caller is expected to set inst->base_mrf and initialize
  1084.     * that MRF register to r0. This opcode will also write to this MRF register
  1085.     * to include the allocated URB handle so it can then be reused directly as
  1086.     * the header in the URB write operation we are allocating the handle for.
  1087.     */
  1088.    GS_OPCODE_FF_SYNC,
  1089.  
  1090.    /**
  1091.     * Move r0.1 (which holds PrimitiveID information in gen6) to a separate
  1092.     * register.
  1093.     *
  1094.     * - dst is the GRF where PrimitiveID information will be moved.
  1095.     */
  1096.    GS_OPCODE_SET_PRIMITIVE_ID,
  1097.  
  1098.    /**
  1099.     * Write transform feedback data to the SVB by sending a SVB WRITE message.
  1100.     * Used in gen6.
  1101.     *
  1102.     * - dst is the MRF register containing the message header.
  1103.     *
  1104.     * - src0 is the register where the vertex data is going to be copied from.
  1105.     *
  1106.     * - src1 is the destination register when write commit occurs.
  1107.     */
  1108.    GS_OPCODE_SVB_WRITE,
  1109.  
  1110.    /**
  1111.     * Set destination index in the SVB write message payload (M0.5). Used
  1112.     * in gen6 for transform feedback.
  1113.     *
  1114.     * - dst is the header to save the destination indices for SVB WRITE.
  1115.     * - src is the register that holds the destination indices value.
  1116.     */
  1117.    GS_OPCODE_SVB_SET_DST_INDEX,
  1118.  
  1119.    /**
  1120.     * Prepare Mx.0 subregister for being used in the FF_SYNC message header.
  1121.     * Used in gen6 for transform feedback.
  1122.     *
  1123.     * - dst will hold the register with the final Mx.0 value.
  1124.     *
  1125.     * - src0 has the number of vertices emitted in SO (NumSOVertsToWrite)
  1126.     *
  1127.     * - src1 has the number of needed primitives for SO (NumSOPrimsNeeded)
  1128.     *
  1129.     * - src2 is the value to hold in M0: number of SO vertices to write
  1130.     *   and number of SO primitives needed.
  1131.     */
  1132.    GS_OPCODE_FF_SYNC_SET_PRIMITIVES,
  1133.  
  1134.    /**
  1135.     * Terminate the compute shader.
  1136.     */
  1137.    CS_OPCODE_CS_TERMINATE,
  1138. };
  1139.  
  1140. enum brw_urb_write_flags {
  1141.    BRW_URB_WRITE_NO_FLAGS = 0,
  1142.  
  1143.    /**
  1144.     * Causes a new URB entry to be allocated, and its address stored in the
  1145.     * destination register (gen < 7).
  1146.     */
  1147.    BRW_URB_WRITE_ALLOCATE = 0x1,
  1148.  
  1149.    /**
  1150.     * Causes the current URB entry to be deallocated (gen < 7).
  1151.     */
  1152.    BRW_URB_WRITE_UNUSED = 0x2,
  1153.  
  1154.    /**
  1155.     * Causes the thread to terminate.
  1156.     */
  1157.    BRW_URB_WRITE_EOT = 0x4,
  1158.  
  1159.    /**
  1160.     * Indicates that the given URB entry is complete, and may be sent further
  1161.     * down the 3D pipeline (gen < 7).
  1162.     */
  1163.    BRW_URB_WRITE_COMPLETE = 0x8,
  1164.  
  1165.    /**
  1166.     * Indicates that an additional offset (which may be different for the two
  1167.     * vec4 slots) is stored in the message header (gen == 7).
  1168.     */
  1169.    BRW_URB_WRITE_PER_SLOT_OFFSET = 0x10,
  1170.  
  1171.    /**
  1172.     * Indicates that the channel masks in the URB_WRITE message header should
  1173.     * not be overridden to 0xff (gen == 7).
  1174.     */
  1175.    BRW_URB_WRITE_USE_CHANNEL_MASKS = 0x20,
  1176.  
  1177.    /**
  1178.     * Indicates that the data should be sent to the URB using the
  1179.     * URB_WRITE_OWORD message rather than URB_WRITE_HWORD (gen == 7).  This
  1180.     * causes offsets to be interpreted as multiples of an OWORD instead of an
  1181.     * HWORD, and only allows one OWORD to be written.
  1182.     */
  1183.    BRW_URB_WRITE_OWORD = 0x40,
  1184.  
  1185.    /**
  1186.     * Convenient combination of flags: end the thread while simultaneously
  1187.     * marking the given URB entry as complete.
  1188.     */
  1189.    BRW_URB_WRITE_EOT_COMPLETE = BRW_URB_WRITE_EOT | BRW_URB_WRITE_COMPLETE,
  1190.  
  1191.    /**
  1192.     * Convenient combination of flags: mark the given URB entry as complete
  1193.     * and simultaneously allocate a new one.
  1194.     */
  1195.    BRW_URB_WRITE_ALLOCATE_COMPLETE =
  1196.       BRW_URB_WRITE_ALLOCATE | BRW_URB_WRITE_COMPLETE,
  1197. };
  1198.  
  1199. #ifdef __cplusplus
  1200. /**
  1201.  * Allow brw_urb_write_flags enums to be ORed together.
  1202.  */
  1203. inline brw_urb_write_flags
  1204. operator|(brw_urb_write_flags x, brw_urb_write_flags y)
  1205. {
  1206.    return static_cast<brw_urb_write_flags>(static_cast<int>(x) |
  1207.                                            static_cast<int>(y));
  1208. }
  1209. #endif
  1210.  
  1211. enum PACKED brw_predicate {
  1212.    BRW_PREDICATE_NONE                =  0,
  1213.    BRW_PREDICATE_NORMAL              =  1,
  1214.    BRW_PREDICATE_ALIGN1_ANYV         =  2,
  1215.    BRW_PREDICATE_ALIGN1_ALLV         =  3,
  1216.    BRW_PREDICATE_ALIGN1_ANY2H        =  4,
  1217.    BRW_PREDICATE_ALIGN1_ALL2H        =  5,
  1218.    BRW_PREDICATE_ALIGN1_ANY4H        =  6,
  1219.    BRW_PREDICATE_ALIGN1_ALL4H        =  7,
  1220.    BRW_PREDICATE_ALIGN1_ANY8H        =  8,
  1221.    BRW_PREDICATE_ALIGN1_ALL8H        =  9,
  1222.    BRW_PREDICATE_ALIGN1_ANY16H       = 10,
  1223.    BRW_PREDICATE_ALIGN1_ALL16H       = 11,
  1224.    BRW_PREDICATE_ALIGN1_ANY32H       = 12,
  1225.    BRW_PREDICATE_ALIGN1_ALL32H       = 13,
  1226.    BRW_PREDICATE_ALIGN16_REPLICATE_X =  2,
  1227.    BRW_PREDICATE_ALIGN16_REPLICATE_Y =  3,
  1228.    BRW_PREDICATE_ALIGN16_REPLICATE_Z =  4,
  1229.    BRW_PREDICATE_ALIGN16_REPLICATE_W =  5,
  1230.    BRW_PREDICATE_ALIGN16_ANY4H       =  6,
  1231.    BRW_PREDICATE_ALIGN16_ALL4H       =  7,
  1232. };
  1233.  
  1234. #define BRW_ARCHITECTURE_REGISTER_FILE    0
  1235. #define BRW_GENERAL_REGISTER_FILE         1
  1236. #define BRW_MESSAGE_REGISTER_FILE         2
  1237. #define BRW_IMMEDIATE_VALUE               3
  1238.  
  1239. #define BRW_HW_REG_TYPE_UD  0
  1240. #define BRW_HW_REG_TYPE_D   1
  1241. #define BRW_HW_REG_TYPE_UW  2
  1242. #define BRW_HW_REG_TYPE_W   3
  1243. #define BRW_HW_REG_TYPE_F   7
  1244. #define GEN8_HW_REG_TYPE_UQ 8
  1245. #define GEN8_HW_REG_TYPE_Q  9
  1246.  
  1247. #define BRW_HW_REG_NON_IMM_TYPE_UB  4
  1248. #define BRW_HW_REG_NON_IMM_TYPE_B   5
  1249. #define GEN7_HW_REG_NON_IMM_TYPE_DF 6
  1250. #define GEN8_HW_REG_NON_IMM_TYPE_HF 10
  1251.  
  1252. #define BRW_HW_REG_IMM_TYPE_UV  4 /* Gen6+ packed unsigned immediate vector */
  1253. #define BRW_HW_REG_IMM_TYPE_VF  5 /* packed float immediate vector */
  1254. #define BRW_HW_REG_IMM_TYPE_V   6 /* packed int imm. vector; uword dest only */
  1255. #define GEN8_HW_REG_IMM_TYPE_DF 10
  1256. #define GEN8_HW_REG_IMM_TYPE_HF 11
  1257.  
  1258. /* SNB adds 3-src instructions (MAD and LRP) that only operate on floats, so
  1259.  * the types were implied. IVB adds BFE and BFI2 that operate on doublewords
  1260.  * and unsigned doublewords, so a new field is also available in the da3src
  1261.  * struct (part of struct brw_instruction.bits1 in brw_structs.h) to select
  1262.  * dst and shared-src types. The values are different from BRW_REGISTER_TYPE_*.
  1263.  */
  1264. #define BRW_3SRC_TYPE_F  0
  1265. #define BRW_3SRC_TYPE_D  1
  1266. #define BRW_3SRC_TYPE_UD 2
  1267. #define BRW_3SRC_TYPE_DF 3
  1268.  
  1269. #define BRW_ARF_NULL                  0x00
  1270. #define BRW_ARF_ADDRESS               0x10
  1271. #define BRW_ARF_ACCUMULATOR           0x20
  1272. #define BRW_ARF_FLAG                  0x30
  1273. #define BRW_ARF_MASK                  0x40
  1274. #define BRW_ARF_MASK_STACK            0x50
  1275. #define BRW_ARF_MASK_STACK_DEPTH      0x60
  1276. #define BRW_ARF_STATE                 0x70
  1277. #define BRW_ARF_CONTROL               0x80
  1278. #define BRW_ARF_NOTIFICATION_COUNT    0x90
  1279. #define BRW_ARF_IP                    0xA0
  1280. #define BRW_ARF_TDR                   0xB0
  1281. #define BRW_ARF_TIMESTAMP             0xC0
  1282.  
  1283. #define BRW_MRF_COMPR4                  (1 << 7)
  1284.  
  1285. #define BRW_AMASK   0
  1286. #define BRW_IMASK   1
  1287. #define BRW_LMASK   2
  1288. #define BRW_CMASK   3
  1289.  
  1290.  
  1291.  
  1292. #define BRW_THREAD_NORMAL     0
  1293. #define BRW_THREAD_ATOMIC     1
  1294. #define BRW_THREAD_SWITCH     2
  1295.  
  1296. enum PACKED brw_vertical_stride {
  1297.    BRW_VERTICAL_STRIDE_0               = 0,
  1298.    BRW_VERTICAL_STRIDE_1               = 1,
  1299.    BRW_VERTICAL_STRIDE_2               = 2,
  1300.    BRW_VERTICAL_STRIDE_4               = 3,
  1301.    BRW_VERTICAL_STRIDE_8               = 4,
  1302.    BRW_VERTICAL_STRIDE_16              = 5,
  1303.    BRW_VERTICAL_STRIDE_32              = 6,
  1304.    BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL = 0xF,
  1305. };
  1306.  
  1307. enum PACKED brw_width {
  1308.    BRW_WIDTH_1  = 0,
  1309.    BRW_WIDTH_2  = 1,
  1310.    BRW_WIDTH_4  = 2,
  1311.    BRW_WIDTH_8  = 3,
  1312.    BRW_WIDTH_16 = 4,
  1313. };
  1314.  
  1315. #define BRW_STATELESS_BUFFER_BOUNDARY_1K      0
  1316. #define BRW_STATELESS_BUFFER_BOUNDARY_2K      1
  1317. #define BRW_STATELESS_BUFFER_BOUNDARY_4K      2
  1318. #define BRW_STATELESS_BUFFER_BOUNDARY_8K      3
  1319. #define BRW_STATELESS_BUFFER_BOUNDARY_16K     4
  1320. #define BRW_STATELESS_BUFFER_BOUNDARY_32K     5
  1321. #define BRW_STATELESS_BUFFER_BOUNDARY_64K     6
  1322. #define BRW_STATELESS_BUFFER_BOUNDARY_128K    7
  1323. #define BRW_STATELESS_BUFFER_BOUNDARY_256K    8
  1324. #define BRW_STATELESS_BUFFER_BOUNDARY_512K    9
  1325. #define BRW_STATELESS_BUFFER_BOUNDARY_1M      10
  1326. #define BRW_STATELESS_BUFFER_BOUNDARY_2M      11
  1327.  
  1328. #define BRW_POLYGON_FACING_FRONT      0
  1329. #define BRW_POLYGON_FACING_BACK       1
  1330.  
  1331. /**
  1332.  * Message target: Shared Function ID for where to SEND a message.
  1333.  *
  1334.  * These are enumerated in the ISA reference under "send - Send Message".
  1335.  * In particular, see the following tables:
  1336.  * - G45 PRM, Volume 4, Table 14-15 "Message Descriptor Definition"
  1337.  * - Sandybridge PRM, Volume 4 Part 2, Table 8-16 "Extended Message Descriptor"
  1338.  * - Ivybridge PRM, Volume 1 Part 1, section 3.2.7 "GPE Function IDs"
  1339.  */
  1340. enum brw_message_target {
  1341.    BRW_SFID_NULL                     = 0,
  1342.    BRW_SFID_MATH                     = 1, /* Only valid on Gen4-5 */
  1343.    BRW_SFID_SAMPLER                  = 2,
  1344.    BRW_SFID_MESSAGE_GATEWAY          = 3,
  1345.    BRW_SFID_DATAPORT_READ            = 4,
  1346.    BRW_SFID_DATAPORT_WRITE           = 5,
  1347.    BRW_SFID_URB                      = 6,
  1348.    BRW_SFID_THREAD_SPAWNER           = 7,
  1349.    BRW_SFID_VME                      = 8,
  1350.  
  1351.    GEN6_SFID_DATAPORT_SAMPLER_CACHE  = 4,
  1352.    GEN6_SFID_DATAPORT_RENDER_CACHE   = 5,
  1353.    GEN6_SFID_DATAPORT_CONSTANT_CACHE = 9,
  1354.  
  1355.    GEN7_SFID_DATAPORT_DATA_CACHE     = 10,
  1356.    GEN7_SFID_PIXEL_INTERPOLATOR      = 11,
  1357.    HSW_SFID_DATAPORT_DATA_CACHE_1    = 12,
  1358.    HSW_SFID_CRE                      = 13,
  1359. };
  1360.  
  1361. #define GEN7_MESSAGE_TARGET_DP_DATA_CACHE     10
  1362.  
  1363. #define BRW_SAMPLER_RETURN_FORMAT_FLOAT32     0
  1364. #define BRW_SAMPLER_RETURN_FORMAT_UINT32      2
  1365. #define BRW_SAMPLER_RETURN_FORMAT_SINT32      3
  1366.  
  1367. #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE              0
  1368. #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE             0
  1369. #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS        0
  1370. #define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX             1
  1371. #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD        1
  1372. #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD         1
  1373. #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS  2
  1374. #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS    2
  1375. #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE    0
  1376. #define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE     2
  1377. #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE 0
  1378. #define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD_COMPARE 1
  1379. #define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE  1
  1380. #define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO           2
  1381. #define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO            2
  1382. #define BRW_SAMPLER_MESSAGE_SIMD4X2_LD                3
  1383. #define BRW_SAMPLER_MESSAGE_SIMD8_LD                  3
  1384. #define BRW_SAMPLER_MESSAGE_SIMD16_LD                 3
  1385.  
  1386. #define GEN5_SAMPLER_MESSAGE_SAMPLE              0
  1387. #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS         1
  1388. #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD          2
  1389. #define GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE      3
  1390. #define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS       4
  1391. #define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5
  1392. #define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE  6
  1393. #define GEN5_SAMPLER_MESSAGE_SAMPLE_LD           7
  1394. #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4      8
  1395. #define GEN5_SAMPLER_MESSAGE_LOD                 9
  1396. #define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO      10
  1397. #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4_C    16
  1398. #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4_PO   17
  1399. #define GEN7_SAMPLER_MESSAGE_SAMPLE_GATHER4_PO_C 18
  1400. #define HSW_SAMPLER_MESSAGE_SAMPLE_DERIV_COMPARE 20
  1401. #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD_MCS       29
  1402. #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DMS       30
  1403. #define GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DSS       31
  1404.  
  1405. /* for GEN5 only */
  1406. #define BRW_SAMPLER_SIMD_MODE_SIMD4X2                   0
  1407. #define BRW_SAMPLER_SIMD_MODE_SIMD8                     1
  1408. #define BRW_SAMPLER_SIMD_MODE_SIMD16                    2
  1409. #define BRW_SAMPLER_SIMD_MODE_SIMD32_64                 3
  1410.  
  1411. /* GEN9 changes SIMD mode 0 to mean SIMD8D, but lets us get the SIMD4x2
  1412.  * behavior by setting bit 22 of dword 2 in the message header. */
  1413. #define GEN9_SAMPLER_SIMD_MODE_SIMD8D                   0
  1414. #define GEN9_SAMPLER_SIMD_MODE_EXTENSION_SIMD4X2        (1 << 22)
  1415.  
  1416. #define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW   0
  1417. #define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH  1
  1418. #define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS     2
  1419. #define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS     3
  1420. #define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS     4
  1421.  
  1422. #define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD     0
  1423. #define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS    2
  1424.  
  1425. #define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS   2
  1426. #define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS  3
  1427.  
  1428. /* This one stays the same across generations. */
  1429. #define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ          0
  1430. /* GEN4 */
  1431. #define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     1
  1432. #define BRW_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ          2
  1433. #define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      3
  1434. /* G45, GEN5 */
  1435. #define G45_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ         1
  1436. #define G45_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     2
  1437. #define G45_DATAPORT_READ_MESSAGE_AVC_LOOP_FILTER_READ      3
  1438. #define G45_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ          4
  1439. #define G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      6
  1440. /* GEN6 */
  1441. #define GEN6_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ        1
  1442. #define GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ     2
  1443. #define GEN6_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ          4
  1444. #define GEN6_DATAPORT_READ_MESSAGE_OWORD_UNALIGN_BLOCK_READ  5
  1445. #define GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ      6
  1446.  
  1447. #define BRW_DATAPORT_READ_TARGET_DATA_CACHE      0
  1448. #define BRW_DATAPORT_READ_TARGET_RENDER_CACHE    1
  1449. #define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE   2
  1450.  
  1451. #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE                0
  1452. #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED     1
  1453. #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01         2
  1454. #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23         3
  1455. #define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01       4
  1456.  
  1457. #define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE                0
  1458. #define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE           1
  1459. #define BRW_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE                2
  1460. #define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE            3
  1461. #define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE              4
  1462. #define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE     5
  1463. #define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE               7
  1464.  
  1465. /* GEN6 */
  1466. #define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_ATOMIC_WRITE              7
  1467. #define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE               8
  1468. #define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE          9
  1469. #define GEN6_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE               10
  1470. #define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE           11
  1471. #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE             12
  1472. #define GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VB_WRITE               13
  1473. #define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_UNORM_WRITE       14
  1474.  
  1475. /* GEN7 */
  1476. #define GEN7_DATAPORT_RC_MEDIA_BLOCK_READ                           4
  1477. #define GEN7_DATAPORT_RC_TYPED_SURFACE_READ                         5
  1478. #define GEN7_DATAPORT_RC_TYPED_ATOMIC_OP                            6
  1479. #define GEN7_DATAPORT_RC_MEMORY_FENCE                               7
  1480. #define GEN7_DATAPORT_RC_MEDIA_BLOCK_WRITE                          10
  1481. #define GEN7_DATAPORT_RC_RENDER_TARGET_WRITE                        12
  1482. #define GEN7_DATAPORT_RC_TYPED_SURFACE_WRITE                        13
  1483. #define GEN7_DATAPORT_DC_OWORD_BLOCK_READ                           0
  1484. #define GEN7_DATAPORT_DC_UNALIGNED_OWORD_BLOCK_READ                 1
  1485. #define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_READ                      2
  1486. #define GEN7_DATAPORT_DC_DWORD_SCATTERED_READ                       3
  1487. #define GEN7_DATAPORT_DC_BYTE_SCATTERED_READ                        4
  1488. #define GEN7_DATAPORT_DC_UNTYPED_SURFACE_READ                       5
  1489. #define GEN7_DATAPORT_DC_UNTYPED_ATOMIC_OP                          6
  1490. #define GEN7_DATAPORT_DC_MEMORY_FENCE                               7
  1491. #define GEN7_DATAPORT_DC_OWORD_BLOCK_WRITE                          8
  1492. #define GEN7_DATAPORT_DC_OWORD_DUAL_BLOCK_WRITE                     10
  1493. #define GEN7_DATAPORT_DC_DWORD_SCATTERED_WRITE                      11
  1494. #define GEN7_DATAPORT_DC_BYTE_SCATTERED_WRITE                       12
  1495. #define GEN7_DATAPORT_DC_UNTYPED_SURFACE_WRITE                      13
  1496.  
  1497. #define GEN7_DATAPORT_SCRATCH_READ                            ((1 << 18) | \
  1498.                                                                (0 << 17))
  1499. #define GEN7_DATAPORT_SCRATCH_WRITE                           ((1 << 18) | \
  1500.                                                                (1 << 17))
  1501. #define GEN7_DATAPORT_SCRATCH_NUM_REGS_SHIFT                        12
  1502.  
  1503. #define GEN7_PIXEL_INTERPOLATOR_LOC_SHARED_OFFSET     0
  1504. #define GEN7_PIXEL_INTERPOLATOR_LOC_SAMPLE            1
  1505. #define GEN7_PIXEL_INTERPOLATOR_LOC_CENTROID          2
  1506. #define GEN7_PIXEL_INTERPOLATOR_LOC_PER_SLOT_OFFSET   3
  1507.  
  1508. /* HSW */
  1509. #define HSW_DATAPORT_DC_PORT0_OWORD_BLOCK_READ                      0
  1510. #define HSW_DATAPORT_DC_PORT0_UNALIGNED_OWORD_BLOCK_READ            1
  1511. #define HSW_DATAPORT_DC_PORT0_OWORD_DUAL_BLOCK_READ                 2
  1512. #define HSW_DATAPORT_DC_PORT0_DWORD_SCATTERED_READ                  3
  1513. #define HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_READ                   4
  1514. #define HSW_DATAPORT_DC_PORT0_MEMORY_FENCE                          7
  1515. #define HSW_DATAPORT_DC_PORT0_OWORD_BLOCK_WRITE                     8
  1516. #define HSW_DATAPORT_DC_PORT0_OWORD_DUAL_BLOCK_WRITE                10
  1517. #define HSW_DATAPORT_DC_PORT0_DWORD_SCATTERED_WRITE                 11
  1518. #define HSW_DATAPORT_DC_PORT0_BYTE_SCATTERED_WRITE                  12
  1519.  
  1520. #define HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_READ                  1
  1521. #define HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP                     2
  1522. #define HSW_DATAPORT_DC_PORT1_UNTYPED_ATOMIC_OP_SIMD4X2             3
  1523. #define HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_READ                      4
  1524. #define HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_READ                    5
  1525. #define HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP                       6
  1526. #define HSW_DATAPORT_DC_PORT1_TYPED_ATOMIC_OP_SIMD4X2               7
  1527. #define HSW_DATAPORT_DC_PORT1_UNTYPED_SURFACE_WRITE                 9
  1528. #define HSW_DATAPORT_DC_PORT1_MEDIA_BLOCK_WRITE                     10
  1529. #define HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP                     11
  1530. #define HSW_DATAPORT_DC_PORT1_ATOMIC_COUNTER_OP_SIMD4X2             12
  1531. #define HSW_DATAPORT_DC_PORT1_TYPED_SURFACE_WRITE                   13
  1532.  
  1533. /* dataport atomic operations. */
  1534. #define BRW_AOP_AND                   1
  1535. #define BRW_AOP_OR                    2
  1536. #define BRW_AOP_XOR                   3
  1537. #define BRW_AOP_MOV                   4
  1538. #define BRW_AOP_INC                   5
  1539. #define BRW_AOP_DEC                   6
  1540. #define BRW_AOP_ADD                   7
  1541. #define BRW_AOP_SUB                   8
  1542. #define BRW_AOP_REVSUB                9
  1543. #define BRW_AOP_IMAX                  10
  1544. #define BRW_AOP_IMIN                  11
  1545. #define BRW_AOP_UMAX                  12
  1546. #define BRW_AOP_UMIN                  13
  1547. #define BRW_AOP_CMPWR                 14
  1548. #define BRW_AOP_PREDEC                15
  1549.  
  1550. #define BRW_MATH_FUNCTION_INV                              1
  1551. #define BRW_MATH_FUNCTION_LOG                              2
  1552. #define BRW_MATH_FUNCTION_EXP                              3
  1553. #define BRW_MATH_FUNCTION_SQRT                             4
  1554. #define BRW_MATH_FUNCTION_RSQ                              5
  1555. #define BRW_MATH_FUNCTION_SIN                              6
  1556. #define BRW_MATH_FUNCTION_COS                              7
  1557. #define BRW_MATH_FUNCTION_SINCOS                           8 /* gen4, gen5 */
  1558. #define BRW_MATH_FUNCTION_FDIV                             9 /* gen6+ */
  1559. #define BRW_MATH_FUNCTION_POW                              10
  1560. #define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER   11
  1561. #define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT                 12
  1562. #define BRW_MATH_FUNCTION_INT_DIV_REMAINDER                13
  1563. #define GEN8_MATH_FUNCTION_INVM                            14
  1564. #define GEN8_MATH_FUNCTION_RSQRTM                          15
  1565.  
  1566. #define BRW_MATH_INTEGER_UNSIGNED     0
  1567. #define BRW_MATH_INTEGER_SIGNED       1
  1568.  
  1569. #define BRW_MATH_PRECISION_FULL        0
  1570. #define BRW_MATH_PRECISION_PARTIAL     1
  1571.  
  1572. #define BRW_MATH_SATURATE_NONE         0
  1573. #define BRW_MATH_SATURATE_SATURATE     1
  1574.  
  1575. #define BRW_MATH_DATA_VECTOR  0
  1576. #define BRW_MATH_DATA_SCALAR  1
  1577.  
  1578. #define BRW_URB_OPCODE_WRITE_HWORD  0
  1579. #define BRW_URB_OPCODE_WRITE_OWORD  1
  1580. #define GEN8_URB_OPCODE_SIMD8_WRITE  7
  1581.  
  1582. #define BRW_URB_SWIZZLE_NONE          0
  1583. #define BRW_URB_SWIZZLE_INTERLEAVE    1
  1584. #define BRW_URB_SWIZZLE_TRANSPOSE     2
  1585.  
  1586. #define BRW_SCRATCH_SPACE_SIZE_1K     0
  1587. #define BRW_SCRATCH_SPACE_SIZE_2K     1
  1588. #define BRW_SCRATCH_SPACE_SIZE_4K     2
  1589. #define BRW_SCRATCH_SPACE_SIZE_8K     3
  1590. #define BRW_SCRATCH_SPACE_SIZE_16K    4
  1591. #define BRW_SCRATCH_SPACE_SIZE_32K    5
  1592. #define BRW_SCRATCH_SPACE_SIZE_64K    6
  1593. #define BRW_SCRATCH_SPACE_SIZE_128K   7
  1594. #define BRW_SCRATCH_SPACE_SIZE_256K   8
  1595. #define BRW_SCRATCH_SPACE_SIZE_512K   9
  1596. #define BRW_SCRATCH_SPACE_SIZE_1M     10
  1597. #define BRW_SCRATCH_SPACE_SIZE_2M     11
  1598.  
  1599.  
  1600. #define CMD_URB_FENCE                 0x6000
  1601. #define CMD_CS_URB_STATE              0x6001
  1602. #define CMD_CONST_BUFFER              0x6002
  1603.  
  1604. #define CMD_STATE_BASE_ADDRESS        0x6101
  1605. #define CMD_STATE_SIP                 0x6102
  1606. #define CMD_PIPELINE_SELECT_965       0x6104
  1607. #define CMD_PIPELINE_SELECT_GM45      0x6904
  1608.  
  1609. #define _3DSTATE_PIPELINED_POINTERS             0x7800
  1610. #define _3DSTATE_BINDING_TABLE_POINTERS         0x7801
  1611. # define GEN6_BINDING_TABLE_MODIFY_VS   (1 << 8)
  1612. # define GEN6_BINDING_TABLE_MODIFY_GS   (1 << 9)
  1613. # define GEN6_BINDING_TABLE_MODIFY_PS   (1 << 12)
  1614.  
  1615. #define _3DSTATE_BINDING_TABLE_POINTERS_VS      0x7826 /* GEN7+ */
  1616. #define _3DSTATE_BINDING_TABLE_POINTERS_HS      0x7827 /* GEN7+ */
  1617. #define _3DSTATE_BINDING_TABLE_POINTERS_DS      0x7828 /* GEN7+ */
  1618. #define _3DSTATE_BINDING_TABLE_POINTERS_GS      0x7829 /* GEN7+ */
  1619. #define _3DSTATE_BINDING_TABLE_POINTERS_PS      0x782A /* GEN7+ */
  1620.  
  1621. #define _3DSTATE_SAMPLER_STATE_POINTERS         0x7802 /* GEN6+ */
  1622. # define PS_SAMPLER_STATE_CHANGE                                (1 << 12)
  1623. # define GS_SAMPLER_STATE_CHANGE                                (1 << 9)
  1624. # define VS_SAMPLER_STATE_CHANGE                                (1 << 8)
  1625. /* DW1: VS */
  1626. /* DW2: GS */
  1627. /* DW3: PS */
  1628.  
  1629. #define _3DSTATE_SAMPLER_STATE_POINTERS_VS      0x782B /* GEN7+ */
  1630. #define _3DSTATE_SAMPLER_STATE_POINTERS_GS      0x782E /* GEN7+ */
  1631. #define _3DSTATE_SAMPLER_STATE_POINTERS_PS      0x782F /* GEN7+ */
  1632.  
  1633. #define _3DSTATE_VERTEX_BUFFERS       0x7808
  1634. # define BRW_VB0_INDEX_SHIFT            27
  1635. # define GEN6_VB0_INDEX_SHIFT           26
  1636. # define BRW_VB0_ACCESS_VERTEXDATA      (0 << 26)
  1637. # define BRW_VB0_ACCESS_INSTANCEDATA    (1 << 26)
  1638. # define GEN6_VB0_ACCESS_VERTEXDATA     (0 << 20)
  1639. # define GEN6_VB0_ACCESS_INSTANCEDATA   (1 << 20)
  1640. # define GEN7_VB0_ADDRESS_MODIFYENABLE  (1 << 14)
  1641. # define BRW_VB0_PITCH_SHIFT            0
  1642.  
  1643. #define _3DSTATE_VERTEX_ELEMENTS      0x7809
  1644. # define BRW_VE0_INDEX_SHIFT            27
  1645. # define GEN6_VE0_INDEX_SHIFT           26
  1646. # define BRW_VE0_FORMAT_SHIFT           16
  1647. # define BRW_VE0_VALID                  (1 << 26)
  1648. # define GEN6_VE0_VALID                 (1 << 25)
  1649. # define GEN6_VE0_EDGE_FLAG_ENABLE      (1 << 15)
  1650. # define BRW_VE0_SRC_OFFSET_SHIFT       0
  1651. # define BRW_VE1_COMPONENT_NOSTORE      0
  1652. # define BRW_VE1_COMPONENT_STORE_SRC    1
  1653. # define BRW_VE1_COMPONENT_STORE_0      2
  1654. # define BRW_VE1_COMPONENT_STORE_1_FLT  3
  1655. # define BRW_VE1_COMPONENT_STORE_1_INT  4
  1656. # define BRW_VE1_COMPONENT_STORE_VID    5
  1657. # define BRW_VE1_COMPONENT_STORE_IID    6
  1658. # define BRW_VE1_COMPONENT_STORE_PID    7
  1659. # define BRW_VE1_COMPONENT_0_SHIFT      28
  1660. # define BRW_VE1_COMPONENT_1_SHIFT      24
  1661. # define BRW_VE1_COMPONENT_2_SHIFT      20
  1662. # define BRW_VE1_COMPONENT_3_SHIFT      16
  1663. # define BRW_VE1_DST_OFFSET_SHIFT       0
  1664.  
  1665. #define CMD_INDEX_BUFFER              0x780a
  1666. #define GEN4_3DSTATE_VF_STATISTICS              0x780b
  1667. #define GM45_3DSTATE_VF_STATISTICS              0x680b
  1668. #define _3DSTATE_CC_STATE_POINTERS              0x780e /* GEN6+ */
  1669. #define _3DSTATE_BLEND_STATE_POINTERS           0x7824 /* GEN7+ */
  1670. #define _3DSTATE_DEPTH_STENCIL_STATE_POINTERS   0x7825 /* GEN7+ */
  1671.  
  1672. #define _3DSTATE_URB                            0x7805 /* GEN6 */
  1673. # define GEN6_URB_VS_SIZE_SHIFT                         16
  1674. # define GEN6_URB_VS_ENTRIES_SHIFT                      0
  1675. # define GEN6_URB_GS_ENTRIES_SHIFT                      8
  1676. # define GEN6_URB_GS_SIZE_SHIFT                         0
  1677.  
  1678. #define _3DSTATE_VF                             0x780c /* GEN7.5+ */
  1679. #define HSW_CUT_INDEX_ENABLE                            (1 << 8)
  1680.  
  1681. #define _3DSTATE_VF_INSTANCING                  0x7849 /* GEN8+ */
  1682. # define GEN8_VF_INSTANCING_ENABLE                      (1 << 8)
  1683.  
  1684. #define _3DSTATE_VF_SGVS                        0x784a /* GEN8+ */
  1685. # define GEN8_SGVS_ENABLE_INSTANCE_ID                   (1 << 31)
  1686. # define GEN8_SGVS_INSTANCE_ID_COMPONENT_SHIFT          29
  1687. # define GEN8_SGVS_INSTANCE_ID_ELEMENT_OFFSET_SHIFT     16
  1688. # define GEN8_SGVS_ENABLE_VERTEX_ID                     (1 << 15)
  1689. # define GEN8_SGVS_VERTEX_ID_COMPONENT_SHIFT            13
  1690. # define GEN8_SGVS_VERTEX_ID_ELEMENT_OFFSET_SHIFT       0
  1691.  
  1692. #define _3DSTATE_VF_TOPOLOGY                    0x784b /* GEN8+ */
  1693.  
  1694. #define _3DSTATE_WM_CHROMAKEY                   0x784c /* GEN8+ */
  1695.  
  1696. #define _3DSTATE_URB_VS                         0x7830 /* GEN7+ */
  1697. #define _3DSTATE_URB_HS                         0x7831 /* GEN7+ */
  1698. #define _3DSTATE_URB_DS                         0x7832 /* GEN7+ */
  1699. #define _3DSTATE_URB_GS                         0x7833 /* GEN7+ */
  1700. # define GEN7_URB_ENTRY_SIZE_SHIFT                      16
  1701. # define GEN7_URB_STARTING_ADDRESS_SHIFT                25
  1702.  
  1703. /* Gen7 "GS URB Entry Allocation Size" is a U9-1 field, so the maximum gs_size
  1704.  * is 2^9, or 512.  It's counted in multiples of 64 bytes.
  1705.  */
  1706. #define GEN7_MAX_GS_URB_ENTRY_SIZE_BYTES                (512*64)
  1707. /* Gen6 "GS URB Entry Allocation Size" is defined as a number of 1024-bit
  1708.  * (128 bytes) URB rows and the maximum allowed value is 5 rows.
  1709.  */
  1710. #define GEN6_MAX_GS_URB_ENTRY_SIZE_BYTES                (5*128)
  1711.  
  1712. #define _3DSTATE_PUSH_CONSTANT_ALLOC_VS         0x7912 /* GEN7+ */
  1713. #define _3DSTATE_PUSH_CONSTANT_ALLOC_GS         0x7915 /* GEN7+ */
  1714. #define _3DSTATE_PUSH_CONSTANT_ALLOC_PS         0x7916 /* GEN7+ */
  1715. # define GEN7_PUSH_CONSTANT_BUFFER_OFFSET_SHIFT         16
  1716.  
  1717. #define _3DSTATE_VIEWPORT_STATE_POINTERS        0x780d /* GEN6+ */
  1718. # define GEN6_CC_VIEWPORT_MODIFY                        (1 << 12)
  1719. # define GEN6_SF_VIEWPORT_MODIFY                        (1 << 11)
  1720. # define GEN6_CLIP_VIEWPORT_MODIFY                      (1 << 10)
  1721. # define GEN6_NUM_VIEWPORTS                             16
  1722.  
  1723. #define _3DSTATE_VIEWPORT_STATE_POINTERS_CC     0x7823 /* GEN7+ */
  1724. #define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CL  0x7821 /* GEN7+ */
  1725.  
  1726. #define _3DSTATE_SCISSOR_STATE_POINTERS         0x780f /* GEN6+ */
  1727.  
  1728. #define _3DSTATE_VS                             0x7810 /* GEN6+ */
  1729. /* DW2 */
  1730. # define GEN6_VS_SPF_MODE                               (1 << 31)
  1731. # define GEN6_VS_VECTOR_MASK_ENABLE                     (1 << 30)
  1732. # define GEN6_VS_SAMPLER_COUNT_SHIFT                    27
  1733. # define GEN6_VS_BINDING_TABLE_ENTRY_COUNT_SHIFT        18
  1734. # define GEN6_VS_FLOATING_POINT_MODE_IEEE_754           (0 << 16)
  1735. # define GEN6_VS_FLOATING_POINT_MODE_ALT                (1 << 16)
  1736. /* DW4 */
  1737. # define GEN6_VS_DISPATCH_START_GRF_SHIFT               20
  1738. # define GEN6_VS_URB_READ_LENGTH_SHIFT                  11
  1739. # define GEN6_VS_URB_ENTRY_READ_OFFSET_SHIFT            4
  1740. /* DW5 */
  1741. # define GEN6_VS_MAX_THREADS_SHIFT                      25
  1742. # define HSW_VS_MAX_THREADS_SHIFT                       23
  1743. # define GEN6_VS_STATISTICS_ENABLE                      (1 << 10)
  1744. # define GEN6_VS_CACHE_DISABLE                          (1 << 1)
  1745. # define GEN6_VS_ENABLE                                 (1 << 0)
  1746. /* Gen8+ DW7 */
  1747. # define GEN8_VS_SIMD8_ENABLE                           (1 << 2)
  1748. /* Gen8+ DW8 */
  1749. # define GEN8_VS_URB_ENTRY_OUTPUT_OFFSET_SHIFT          21
  1750. # define GEN8_VS_URB_OUTPUT_LENGTH_SHIFT                16
  1751. # define GEN8_VS_USER_CLIP_DISTANCE_SHIFT               8
  1752.  
  1753. #define _3DSTATE_GS                             0x7811 /* GEN6+ */
  1754. /* DW2 */
  1755. # define GEN6_GS_SPF_MODE                               (1 << 31)
  1756. # define GEN6_GS_VECTOR_MASK_ENABLE                     (1 << 30)
  1757. # define GEN6_GS_SAMPLER_COUNT_SHIFT                    27
  1758. # define GEN6_GS_BINDING_TABLE_ENTRY_COUNT_SHIFT        18
  1759. # define GEN6_GS_FLOATING_POINT_MODE_IEEE_754           (0 << 16)
  1760. # define GEN6_GS_FLOATING_POINT_MODE_ALT                (1 << 16)
  1761. /* DW4 */
  1762. # define GEN7_GS_OUTPUT_VERTEX_SIZE_SHIFT               23
  1763. # define GEN7_GS_OUTPUT_TOPOLOGY_SHIFT                  17
  1764. # define GEN6_GS_URB_READ_LENGTH_SHIFT                  11
  1765. # define GEN7_GS_INCLUDE_VERTEX_HANDLES                 (1 << 10)
  1766. # define GEN6_GS_URB_ENTRY_READ_OFFSET_SHIFT            4
  1767. # define GEN6_GS_DISPATCH_START_GRF_SHIFT               0
  1768. /* DW5 */
  1769. # define GEN6_GS_MAX_THREADS_SHIFT                      25
  1770. # define HSW_GS_MAX_THREADS_SHIFT                       24
  1771. # define IVB_GS_CONTROL_DATA_FORMAT_SHIFT               24
  1772. # define GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_CUT          0
  1773. # define GEN7_GS_CONTROL_DATA_FORMAT_GSCTL_SID          1
  1774. # define GEN7_GS_CONTROL_DATA_HEADER_SIZE_SHIFT         20
  1775. # define GEN7_GS_INSTANCE_CONTROL_SHIFT                 15
  1776. # define GEN7_GS_DISPATCH_MODE_SINGLE                   (0 << 11)
  1777. # define GEN7_GS_DISPATCH_MODE_DUAL_INSTANCE            (1 << 11)
  1778. # define GEN7_GS_DISPATCH_MODE_DUAL_OBJECT              (2 << 11)
  1779. # define GEN6_GS_STATISTICS_ENABLE                      (1 << 10)
  1780. # define GEN6_GS_SO_STATISTICS_ENABLE                   (1 << 9)
  1781. # define GEN6_GS_RENDERING_ENABLE                       (1 << 8)
  1782. # define GEN7_GS_INCLUDE_PRIMITIVE_ID                   (1 << 4)
  1783. # define GEN7_GS_REORDER_TRAILING                       (1 << 2)
  1784. # define GEN7_GS_ENABLE                                 (1 << 0)
  1785. /* DW6 */
  1786. # define HSW_GS_CONTROL_DATA_FORMAT_SHIFT               31
  1787. # define GEN6_GS_REORDER                                (1 << 30)
  1788. # define GEN6_GS_DISCARD_ADJACENCY                      (1 << 29)
  1789. # define GEN6_GS_SVBI_PAYLOAD_ENABLE                    (1 << 28)
  1790. # define GEN6_GS_SVBI_POSTINCREMENT_ENABLE              (1 << 27)
  1791. # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_SHIFT         16
  1792. # define GEN6_GS_SVBI_POSTINCREMENT_VALUE_MASK          INTEL_MASK(25, 16)
  1793. # define GEN6_GS_ENABLE                                 (1 << 15)
  1794.  
  1795. /* Gen8+ DW9 */
  1796. # define GEN8_GS_URB_ENTRY_OUTPUT_OFFSET_SHIFT          21
  1797. # define GEN8_GS_URB_OUTPUT_LENGTH_SHIFT                16
  1798. # define GEN8_GS_USER_CLIP_DISTANCE_SHIFT               8
  1799.  
  1800. # define BRW_GS_EDGE_INDICATOR_0                        (1 << 8)
  1801. # define BRW_GS_EDGE_INDICATOR_1                        (1 << 9)
  1802.  
  1803. /* GS Thread Payload
  1804.  */
  1805. /* R0 */
  1806. # define GEN7_GS_PAYLOAD_INSTANCE_ID_SHIFT              27
  1807.  
  1808. /* 3DSTATE_GS "Output Vertex Size" has an effective maximum of 62.  It's
  1809.  * counted in multiples of 16 bytes.
  1810.  */
  1811. #define GEN7_MAX_GS_OUTPUT_VERTEX_SIZE_BYTES            (62*16)
  1812.  
  1813. #define _3DSTATE_HS                             0x781B /* GEN7+ */
  1814. #define _3DSTATE_TE                             0x781C /* GEN7+ */
  1815. #define _3DSTATE_DS                             0x781D /* GEN7+ */
  1816.  
  1817. #define _3DSTATE_CLIP                           0x7812 /* GEN6+ */
  1818. /* DW1 */
  1819. # define GEN7_CLIP_WINDING_CW                           (0 << 20)
  1820. # define GEN7_CLIP_WINDING_CCW                          (1 << 20)
  1821. # define GEN7_CLIP_VERTEX_SUBPIXEL_PRECISION_8          (0 << 19)
  1822. # define GEN7_CLIP_VERTEX_SUBPIXEL_PRECISION_4          (1 << 19)
  1823. # define GEN7_CLIP_EARLY_CULL                           (1 << 18)
  1824. # define GEN7_CLIP_CULLMODE_BOTH                        (0 << 16)
  1825. # define GEN7_CLIP_CULLMODE_NONE                        (1 << 16)
  1826. # define GEN7_CLIP_CULLMODE_FRONT                       (2 << 16)
  1827. # define GEN7_CLIP_CULLMODE_BACK                        (3 << 16)
  1828. # define GEN6_CLIP_STATISTICS_ENABLE                    (1 << 10)
  1829. /**
  1830.  * Just does cheap culling based on the clip distance.  Bits must be
  1831.  * disjoint with USER_CLIP_CLIP_DISTANCE bits.
  1832.  */
  1833. # define GEN6_USER_CLIP_CULL_DISTANCES_SHIFT            0
  1834. /* DW2 */
  1835. # define GEN6_CLIP_ENABLE                               (1 << 31)
  1836. # define GEN6_CLIP_API_OGL                              (0 << 30)
  1837. # define GEN6_CLIP_API_D3D                              (1 << 30)
  1838. # define GEN6_CLIP_XY_TEST                              (1 << 28)
  1839. # define GEN6_CLIP_Z_TEST                               (1 << 27)
  1840. # define GEN6_CLIP_GB_TEST                              (1 << 26)
  1841. /** 8-bit field of which user clip distances to clip aganist. */
  1842. # define GEN6_USER_CLIP_CLIP_DISTANCES_SHIFT            16
  1843. # define GEN6_CLIP_MODE_NORMAL                          (0 << 13)
  1844. # define GEN6_CLIP_MODE_REJECT_ALL                      (3 << 13)
  1845. # define GEN6_CLIP_MODE_ACCEPT_ALL                      (4 << 13)
  1846. # define GEN6_CLIP_PERSPECTIVE_DIVIDE_DISABLE           (1 << 9)
  1847. # define GEN6_CLIP_NON_PERSPECTIVE_BARYCENTRIC_ENABLE   (1 << 8)
  1848. # define GEN6_CLIP_TRI_PROVOKE_SHIFT                    4
  1849. # define GEN6_CLIP_LINE_PROVOKE_SHIFT                   2
  1850. # define GEN6_CLIP_TRIFAN_PROVOKE_SHIFT                 0
  1851. /* DW3 */
  1852. # define GEN6_CLIP_MIN_POINT_WIDTH_SHIFT                17
  1853. # define GEN6_CLIP_MAX_POINT_WIDTH_SHIFT                6
  1854. # define GEN6_CLIP_FORCE_ZERO_RTAINDEX                  (1 << 5)
  1855. # define GEN6_CLIP_MAX_VP_INDEX_MASK                    INTEL_MASK(3, 0)
  1856.  
  1857. #define _3DSTATE_SF                             0x7813 /* GEN6+ */
  1858. /* DW1 (for gen6) */
  1859. # define GEN6_SF_NUM_OUTPUTS_SHIFT                      22
  1860. # define GEN6_SF_SWIZZLE_ENABLE                         (1 << 21)
  1861. # define GEN6_SF_POINT_SPRITE_UPPERLEFT                 (0 << 20)
  1862. # define GEN6_SF_POINT_SPRITE_LOWERLEFT                 (1 << 20)
  1863. # define GEN9_SF_LINE_WIDTH_SHIFT                       12 /* U11.7 */
  1864. # define GEN6_SF_URB_ENTRY_READ_LENGTH_SHIFT            11
  1865. # define GEN6_SF_URB_ENTRY_READ_OFFSET_SHIFT            4
  1866. /* DW2 */
  1867. # define GEN6_SF_LEGACY_GLOBAL_DEPTH_BIAS               (1 << 11)
  1868. # define GEN6_SF_STATISTICS_ENABLE                      (1 << 10)
  1869. # define GEN6_SF_GLOBAL_DEPTH_OFFSET_SOLID              (1 << 9)
  1870. # define GEN6_SF_GLOBAL_DEPTH_OFFSET_WIREFRAME          (1 << 8)
  1871. # define GEN6_SF_GLOBAL_DEPTH_OFFSET_POINT              (1 << 7)
  1872. # define GEN6_SF_FRONT_SOLID                            (0 << 5)
  1873. # define GEN6_SF_FRONT_WIREFRAME                        (1 << 5)
  1874. # define GEN6_SF_FRONT_POINT                            (2 << 5)
  1875. # define GEN6_SF_BACK_SOLID                             (0 << 3)
  1876. # define GEN6_SF_BACK_WIREFRAME                         (1 << 3)
  1877. # define GEN6_SF_BACK_POINT                             (2 << 3)
  1878. # define GEN6_SF_VIEWPORT_TRANSFORM_ENABLE              (1 << 1)
  1879. # define GEN6_SF_WINDING_CCW                            (1 << 0)
  1880. /* DW3 */
  1881. # define GEN6_SF_LINE_AA_ENABLE                         (1 << 31)
  1882. # define GEN6_SF_CULL_BOTH                              (0 << 29)
  1883. # define GEN6_SF_CULL_NONE                              (1 << 29)
  1884. # define GEN6_SF_CULL_FRONT                             (2 << 29)
  1885. # define GEN6_SF_CULL_BACK                              (3 << 29)
  1886. # define GEN6_SF_LINE_WIDTH_SHIFT                       18 /* U3.7 */
  1887. # define GEN6_SF_LINE_END_CAP_WIDTH_0_5                 (0 << 16)
  1888. # define GEN6_SF_LINE_END_CAP_WIDTH_1_0                 (1 << 16)
  1889. # define GEN6_SF_LINE_END_CAP_WIDTH_2_0                 (2 << 16)
  1890. # define GEN6_SF_LINE_END_CAP_WIDTH_4_0                 (3 << 16)
  1891. # define GEN6_SF_SCISSOR_ENABLE                         (1 << 11)
  1892. # define GEN6_SF_MSRAST_OFF_PIXEL                       (0 << 8)
  1893. # define GEN6_SF_MSRAST_OFF_PATTERN                     (1 << 8)
  1894. # define GEN6_SF_MSRAST_ON_PIXEL                        (2 << 8)
  1895. # define GEN6_SF_MSRAST_ON_PATTERN                      (3 << 8)
  1896. /* DW4 */
  1897. # define GEN6_SF_TRI_PROVOKE_SHIFT                      29
  1898. # define GEN6_SF_LINE_PROVOKE_SHIFT                     27
  1899. # define GEN6_SF_TRIFAN_PROVOKE_SHIFT                   25
  1900. # define GEN6_SF_LINE_AA_MODE_MANHATTAN                 (0 << 14)
  1901. # define GEN6_SF_LINE_AA_MODE_TRUE                      (1 << 14)
  1902. # define GEN6_SF_VERTEX_SUBPIXEL_8BITS                  (0 << 12)
  1903. # define GEN6_SF_VERTEX_SUBPIXEL_4BITS                  (1 << 12)
  1904. # define GEN6_SF_USE_STATE_POINT_WIDTH                  (1 << 11)
  1905. # define GEN6_SF_POINT_WIDTH_SHIFT                      0 /* U8.3 */
  1906. /* DW5: depth offset constant */
  1907. /* DW6: depth offset scale */
  1908. /* DW7: depth offset clamp */
  1909. /* DW8 */
  1910. # define ATTRIBUTE_1_OVERRIDE_W                         (1 << 31)
  1911. # define ATTRIBUTE_1_OVERRIDE_Z                         (1 << 30)
  1912. # define ATTRIBUTE_1_OVERRIDE_Y                         (1 << 29)
  1913. # define ATTRIBUTE_1_OVERRIDE_X                         (1 << 28)
  1914. # define ATTRIBUTE_1_CONST_SOURCE_SHIFT                 25
  1915. # define ATTRIBUTE_1_SWIZZLE_SHIFT                      22
  1916. # define ATTRIBUTE_1_SOURCE_SHIFT                       16
  1917. # define ATTRIBUTE_0_OVERRIDE_W                         (1 << 15)
  1918. # define ATTRIBUTE_0_OVERRIDE_Z                         (1 << 14)
  1919. # define ATTRIBUTE_0_OVERRIDE_Y                         (1 << 13)
  1920. # define ATTRIBUTE_0_OVERRIDE_X                         (1 << 12)
  1921. # define ATTRIBUTE_0_CONST_SOURCE_SHIFT                 9
  1922. #  define ATTRIBUTE_CONST_0000                          0
  1923. #  define ATTRIBUTE_CONST_0001_FLOAT                    1
  1924. #  define ATTRIBUTE_CONST_1111_FLOAT                    2
  1925. #  define ATTRIBUTE_CONST_PRIM_ID                       3
  1926. # define ATTRIBUTE_0_SWIZZLE_SHIFT                      6
  1927. # define ATTRIBUTE_0_SOURCE_SHIFT                       0
  1928.  
  1929. # define ATTRIBUTE_SWIZZLE_INPUTATTR                    0
  1930. # define ATTRIBUTE_SWIZZLE_INPUTATTR_FACING             1
  1931. # define ATTRIBUTE_SWIZZLE_INPUTATTR_W                  2
  1932. # define ATTRIBUTE_SWIZZLE_INPUTATTR_FACING_W           3
  1933. # define ATTRIBUTE_SWIZZLE_SHIFT                        6
  1934.  
  1935. /* DW16: Point sprite texture coordinate enables */
  1936. /* DW17: Constant interpolation enables */
  1937. /* DW18: attr 0-7 wrap shortest enables */
  1938. /* DW19: attr 8-16 wrap shortest enables */
  1939.  
  1940. /* On GEN7, many fields of 3DSTATE_SF were split out into a new command:
  1941.  * 3DSTATE_SBE.  The remaining fields live in different DWords, but retain
  1942.  * the same bit-offset.  The only new field:
  1943.  */
  1944. /* GEN7/DW1: */
  1945. # define GEN7_SF_DEPTH_BUFFER_SURFACE_FORMAT_SHIFT      12
  1946. /* GEN7/DW2: */
  1947. # define HSW_SF_LINE_STIPPLE_ENABLE                     (1 << 14)
  1948.  
  1949. # define GEN8_SF_SMOOTH_POINT_ENABLE                    (1 << 13)
  1950.  
  1951. #define _3DSTATE_SBE                            0x781F /* GEN7+ */
  1952. /* DW1 */
  1953. # define GEN8_SBE_FORCE_URB_ENTRY_READ_LENGTH           (1 << 29)
  1954. # define GEN8_SBE_FORCE_URB_ENTRY_READ_OFFSET           (1 << 28)
  1955. # define GEN7_SBE_SWIZZLE_CONTROL_MODE                  (1 << 28)
  1956. # define GEN7_SBE_NUM_OUTPUTS_SHIFT                     22
  1957. # define GEN7_SBE_SWIZZLE_ENABLE                        (1 << 21)
  1958. # define GEN7_SBE_POINT_SPRITE_LOWERLEFT                (1 << 20)
  1959. # define GEN7_SBE_URB_ENTRY_READ_LENGTH_SHIFT           11
  1960. # define GEN7_SBE_URB_ENTRY_READ_OFFSET_SHIFT           4
  1961. # define GEN8_SBE_URB_ENTRY_READ_OFFSET_SHIFT           5
  1962. /* DW2-9: Attribute setup (same as DW8-15 of gen6 _3DSTATE_SF) */
  1963. /* DW10: Point sprite texture coordinate enables */
  1964. /* DW11: Constant interpolation enables */
  1965. /* DW12: attr 0-7 wrap shortest enables */
  1966. /* DW13: attr 8-16 wrap shortest enables */
  1967.  
  1968. /* DW4-5: Attribute active components (gen9) */
  1969. #define GEN9_SBE_ACTIVE_COMPONENT_NONE                  0
  1970. #define GEN9_SBE_ACTIVE_COMPONENT_XY                    1
  1971. #define GEN9_SBE_ACTIVE_COMPONENT_XYZ                   2
  1972. #define GEN9_SBE_ACTIVE_COMPONENT_XYZW                  3
  1973.  
  1974. #define _3DSTATE_SBE_SWIZ                       0x7851 /* GEN8+ */
  1975.  
  1976. #define _3DSTATE_RASTER                         0x7850 /* GEN8+ */
  1977. /* DW1 */
  1978. # define GEN9_RASTER_VIEWPORT_Z_FAR_CLIP_TEST_ENABLE    (1 << 26)
  1979. # define GEN8_RASTER_FRONT_WINDING_CCW                  (1 << 21)
  1980. # define GEN8_RASTER_CULL_BOTH                          (0 << 16)
  1981. # define GEN8_RASTER_CULL_NONE                          (1 << 16)
  1982. # define GEN8_RASTER_CULL_FRONT                         (2 << 16)
  1983. # define GEN8_RASTER_CULL_BACK                          (3 << 16)
  1984. # define GEN8_RASTER_SMOOTH_POINT_ENABLE                (1 << 13)
  1985. # define GEN8_RASTER_API_MULTISAMPLE_ENABLE             (1 << 12)
  1986. # define GEN8_RASTER_LINE_AA_ENABLE                     (1 << 2)
  1987. # define GEN8_RASTER_SCISSOR_ENABLE                     (1 << 1)
  1988. # define GEN8_RASTER_VIEWPORT_Z_CLIP_TEST_ENABLE        (1 << 0)
  1989. # define GEN9_RASTER_VIEWPORT_Z_NEAR_CLIP_TEST_ENABLE   (1 << 0)
  1990.  
  1991. /* Gen8 BLEND_STATE */
  1992. /* DW0 */
  1993. #define GEN8_BLEND_ALPHA_TO_COVERAGE_ENABLE             (1 << 31)
  1994. #define GEN8_BLEND_INDEPENDENT_ALPHA_BLEND_ENABLE       (1 << 30)
  1995. #define GEN8_BLEND_ALPHA_TO_ONE_ENABLE                  (1 << 29)
  1996. #define GEN8_BLEND_ALPHA_TO_COVERAGE_DITHER_ENABLE      (1 << 28)
  1997. #define GEN8_BLEND_ALPHA_TEST_ENABLE                    (1 << 27)
  1998. #define GEN8_BLEND_ALPHA_TEST_FUNCTION_MASK             INTEL_MASK(26, 24)
  1999. #define GEN8_BLEND_ALPHA_TEST_FUNCTION_SHIFT            24
  2000. #define GEN8_BLEND_COLOR_DITHER_ENABLE                  (1 << 23)
  2001. #define GEN8_BLEND_X_DITHER_OFFSET_MASK                 INTEL_MASK(22, 21)
  2002. #define GEN8_BLEND_X_DITHER_OFFSET_SHIFT                21
  2003. #define GEN8_BLEND_Y_DITHER_OFFSET_MASK                 INTEL_MASK(20, 19)
  2004. #define GEN8_BLEND_Y_DITHER_OFFSET_SHIFT                19
  2005. /* DW1 + 2n */
  2006. #define GEN8_BLEND_COLOR_BUFFER_BLEND_ENABLE            (1 << 31)
  2007. #define GEN8_BLEND_SRC_BLEND_FACTOR_MASK                INTEL_MASK(30, 26)
  2008. #define GEN8_BLEND_SRC_BLEND_FACTOR_SHIFT               26
  2009. #define GEN8_BLEND_DST_BLEND_FACTOR_MASK                INTEL_MASK(25, 21)
  2010. #define GEN8_BLEND_DST_BLEND_FACTOR_SHIFT               21
  2011. #define GEN8_BLEND_COLOR_BLEND_FUNCTION_MASK            INTEL_MASK(20, 18)
  2012. #define GEN8_BLEND_COLOR_BLEND_FUNCTION_SHIFT           18
  2013. #define GEN8_BLEND_SRC_ALPHA_BLEND_FACTOR_MASK          INTEL_MASK(17, 13)
  2014. #define GEN8_BLEND_SRC_ALPHA_BLEND_FACTOR_SHIFT         13
  2015. #define GEN8_BLEND_DST_ALPHA_BLEND_FACTOR_MASK          INTEL_MASK(12, 8)
  2016. #define GEN8_BLEND_DST_ALPHA_BLEND_FACTOR_SHIFT         8
  2017. #define GEN8_BLEND_ALPHA_BLEND_FUNCTION_MASK            INTEL_MASK(7, 5)
  2018. #define GEN8_BLEND_ALPHA_BLEND_FUNCTION_SHIFT           5
  2019. #define GEN8_BLEND_WRITE_DISABLE_ALPHA                  (1 << 3)
  2020. #define GEN8_BLEND_WRITE_DISABLE_RED                    (1 << 2)
  2021. #define GEN8_BLEND_WRITE_DISABLE_GREEN                  (1 << 1)
  2022. #define GEN8_BLEND_WRITE_DISABLE_BLUE                   (1 << 0)
  2023. /* DW1 + 2n + 1 */
  2024. #define GEN8_BLEND_LOGIC_OP_ENABLE                      (1 << 31)
  2025. #define GEN8_BLEND_LOGIC_OP_FUNCTION_MASK               INTEL_MASK(30, 27)
  2026. #define GEN8_BLEND_LOGIC_OP_FUNCTION_SHIFT              27
  2027. #define GEN8_BLEND_PRE_BLEND_SRC_ONLY_CLAMP_ENABLE      (1 << 4)
  2028. #define GEN8_BLEND_COLOR_CLAMP_RANGE_RTFORMAT           (2 << 2)
  2029. #define GEN8_BLEND_PRE_BLEND_COLOR_CLAMP_ENABLE         (1 << 1)
  2030. #define GEN8_BLEND_POST_BLEND_COLOR_CLAMP_ENABLE        (1 << 0)
  2031.  
  2032. #define _3DSTATE_WM_HZ_OP                       0x7852 /* GEN8+ */
  2033. /* DW1 */
  2034. # define GEN8_WM_HZ_STENCIL_CLEAR                       (1 << 31)
  2035. # define GEN8_WM_HZ_DEPTH_CLEAR                         (1 << 30)
  2036. # define GEN8_WM_HZ_DEPTH_RESOLVE                       (1 << 28)
  2037. # define GEN8_WM_HZ_HIZ_RESOLVE                         (1 << 27)
  2038. # define GEN8_WM_HZ_PIXEL_OFFSET_ENABLE                 (1 << 26)
  2039. # define GEN8_WM_HZ_FULL_SURFACE_DEPTH_CLEAR            (1 << 25)
  2040. # define GEN8_WM_HZ_STENCIL_CLEAR_VALUE_MASK            INTEL_MASK(23, 16)
  2041. # define GEN8_WM_HZ_STENCIL_CLEAR_VALUE_SHIFT           16
  2042. # define GEN8_WM_HZ_NUM_SAMPLES_MASK                    INTEL_MASK(15, 13)
  2043. # define GEN8_WM_HZ_NUM_SAMPLES_SHIFT                   13
  2044. /* DW2 */
  2045. # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MIN_MASK          INTEL_MASK(31, 16)
  2046. # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MIN_SHIFT         16
  2047. # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MIN_MASK          INTEL_MASK(15, 0)
  2048. # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MIN_SHIFT         0
  2049. /* DW3 */
  2050. # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MAX_MASK          INTEL_MASK(31, 16)
  2051. # define GEN8_WM_HZ_CLEAR_RECTANGLE_Y_MAX_SHIFT         16
  2052. # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MAX_MASK          INTEL_MASK(15, 0)
  2053. # define GEN8_WM_HZ_CLEAR_RECTANGLE_X_MAX_SHIFT         0
  2054. /* DW4 */
  2055. # define GEN8_WM_HZ_SAMPLE_MASK_MASK                    INTEL_MASK(15, 0)
  2056. # define GEN8_WM_HZ_SAMPLE_MASK_SHIFT                   0
  2057.  
  2058.  
  2059. #define _3DSTATE_PS_BLEND                       0x784D /* GEN8+ */
  2060. /* DW1 */
  2061. # define GEN8_PS_BLEND_ALPHA_TO_COVERAGE_ENABLE         (1 << 31)
  2062. # define GEN8_PS_BLEND_HAS_WRITEABLE_RT                 (1 << 30)
  2063. # define GEN8_PS_BLEND_COLOR_BUFFER_BLEND_ENABLE        (1 << 29)
  2064. # define GEN8_PS_BLEND_SRC_ALPHA_BLEND_FACTOR_MASK      INTEL_MASK(28, 24)
  2065. # define GEN8_PS_BLEND_SRC_ALPHA_BLEND_FACTOR_SHIFT     24
  2066. # define GEN8_PS_BLEND_DST_ALPHA_BLEND_FACTOR_MASK      INTEL_MASK(23, 19)
  2067. # define GEN8_PS_BLEND_DST_ALPHA_BLEND_FACTOR_SHIFT     19
  2068. # define GEN8_PS_BLEND_SRC_BLEND_FACTOR_MASK            INTEL_MASK(18, 14)
  2069. # define GEN8_PS_BLEND_SRC_BLEND_FACTOR_SHIFT           14
  2070. # define GEN8_PS_BLEND_DST_BLEND_FACTOR_MASK            INTEL_MASK(13, 9)
  2071. # define GEN8_PS_BLEND_DST_BLEND_FACTOR_SHIFT           9
  2072. # define GEN8_PS_BLEND_ALPHA_TEST_ENABLE                (1 << 8)
  2073. # define GEN8_PS_BLEND_INDEPENDENT_ALPHA_BLEND_ENABLE   (1 << 7)
  2074.  
  2075. #define _3DSTATE_WM_DEPTH_STENCIL               0x784E /* GEN8+ */
  2076. /* DW1 */
  2077. # define GEN8_WM_DS_STENCIL_FAIL_OP_SHIFT               29
  2078. # define GEN8_WM_DS_Z_FAIL_OP_SHIFT                     26
  2079. # define GEN8_WM_DS_Z_PASS_OP_SHIFT                     23
  2080. # define GEN8_WM_DS_BF_STENCIL_FUNC_SHIFT               20
  2081. # define GEN8_WM_DS_BF_STENCIL_FAIL_OP_SHIFT            17
  2082. # define GEN8_WM_DS_BF_Z_FAIL_OP_SHIFT                  14
  2083. # define GEN8_WM_DS_BF_Z_PASS_OP_SHIFT                  11
  2084. # define GEN8_WM_DS_STENCIL_FUNC_SHIFT                  8
  2085. # define GEN8_WM_DS_DEPTH_FUNC_SHIFT                    5
  2086. # define GEN8_WM_DS_DOUBLE_SIDED_STENCIL_ENABLE         (1 << 4)
  2087. # define GEN8_WM_DS_STENCIL_TEST_ENABLE                 (1 << 3)
  2088. # define GEN8_WM_DS_STENCIL_BUFFER_WRITE_ENABLE         (1 << 2)
  2089. # define GEN8_WM_DS_DEPTH_TEST_ENABLE                   (1 << 1)
  2090. # define GEN8_WM_DS_DEPTH_BUFFER_WRITE_ENABLE           (1 << 0)
  2091. /* DW2 */
  2092. # define GEN8_WM_DS_STENCIL_TEST_MASK_MASK              INTEL_MASK(31, 24)
  2093. # define GEN8_WM_DS_STENCIL_TEST_MASK_SHIFT             24
  2094. # define GEN8_WM_DS_STENCIL_WRITE_MASK_MASK             INTEL_MASK(23, 16)
  2095. # define GEN8_WM_DS_STENCIL_WRITE_MASK_SHIFT            16
  2096. # define GEN8_WM_DS_BF_STENCIL_TEST_MASK_MASK           INTEL_MASK(15, 8)
  2097. # define GEN8_WM_DS_BF_STENCIL_TEST_MASK_SHIFT          8
  2098. # define GEN8_WM_DS_BF_STENCIL_WRITE_MASK_MASK          INTEL_MASK(7, 0)
  2099. # define GEN8_WM_DS_BF_STENCIL_WRITE_MASK_SHIFT         0
  2100. /* DW3 */
  2101. # define GEN9_WM_DS_STENCIL_REF_MASK                    INTEL_MASK(15, 8)
  2102. # define GEN9_WM_DS_STENCIL_REF_SHIFT                   8
  2103. # define GEN9_WM_DS_BF_STENCIL_REF_MASK                 INTEL_MASK(7, 0)
  2104. # define GEN9_WM_DS_BF_STENCIL_REF_SHIFT                0
  2105.  
  2106. enum brw_pixel_shader_computed_depth_mode {
  2107.    BRW_PSCDEPTH_OFF   = 0, /* PS does not compute depth */
  2108.    BRW_PSCDEPTH_ON    = 1, /* PS computes depth; no guarantee about value */
  2109.    BRW_PSCDEPTH_ON_GE = 2, /* PS guarantees output depth >= source depth */
  2110.    BRW_PSCDEPTH_ON_LE = 3, /* PS guarantees output depth <= source depth */
  2111. };
  2112.  
  2113. #define _3DSTATE_PS_EXTRA                       0x784F /* GEN8+ */
  2114. /* DW1 */
  2115. # define GEN8_PSX_PIXEL_SHADER_VALID                    (1 << 31)
  2116. # define GEN8_PSX_PIXEL_SHADER_NO_RT_WRITE              (1 << 30)
  2117. # define GEN8_PSX_OMASK_TO_RENDER_TARGET                (1 << 29)
  2118. # define GEN8_PSX_KILL_ENABLE                           (1 << 28)
  2119. # define GEN8_PSX_COMPUTED_DEPTH_MODE_SHIFT             26
  2120. # define GEN8_PSX_FORCE_COMPUTED_DEPTH                  (1 << 25)
  2121. # define GEN8_PSX_USES_SOURCE_DEPTH                     (1 << 24)
  2122. # define GEN8_PSX_USES_SOURCE_W                         (1 << 23)
  2123. # define GEN8_PSX_ATTRIBUTE_ENABLE                      (1 << 8)
  2124. # define GEN8_PSX_SHADER_DISABLES_ALPHA_TO_COVERAGE     (1 << 7)
  2125. # define GEN8_PSX_SHADER_IS_PER_SAMPLE                  (1 << 6)
  2126. # define GEN8_PSX_SHADER_COMPUTES_STENCIL               (1 << 5)
  2127. # define GEN8_PSX_SHADER_HAS_UAV                        (1 << 2)
  2128. # define GEN8_PSX_SHADER_USES_INPUT_COVERAGE_MASK       (1 << 1)
  2129.  
  2130. enum brw_wm_barycentric_interp_mode {
  2131.    BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC         = 0,
  2132.    BRW_WM_PERSPECTIVE_CENTROID_BARYCENTRIC      = 1,
  2133.    BRW_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC        = 2,
  2134.    BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC      = 3,
  2135.    BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC   = 4,
  2136.    BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC     = 5,
  2137.    BRW_WM_BARYCENTRIC_INTERP_MODE_COUNT  = 6
  2138. };
  2139. #define BRW_WM_NONPERSPECTIVE_BARYCENTRIC_BITS \
  2140.    ((1 << BRW_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC) | \
  2141.     (1 << BRW_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC) | \
  2142.     (1 << BRW_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC))
  2143.  
  2144. #define _3DSTATE_WM                             0x7814 /* GEN6+ */
  2145. /* DW1: kernel pointer */
  2146. /* DW2 */
  2147. # define GEN6_WM_SPF_MODE                               (1 << 31)
  2148. # define GEN6_WM_VECTOR_MASK_ENABLE                     (1 << 30)
  2149. # define GEN6_WM_SAMPLER_COUNT_SHIFT                    27
  2150. # define GEN6_WM_BINDING_TABLE_ENTRY_COUNT_SHIFT        18
  2151. # define GEN6_WM_FLOATING_POINT_MODE_IEEE_754           (0 << 16)
  2152. # define GEN6_WM_FLOATING_POINT_MODE_ALT                (1 << 16)
  2153. /* DW3: scratch space */
  2154. /* DW4 */
  2155. # define GEN6_WM_STATISTICS_ENABLE                      (1 << 31)
  2156. # define GEN6_WM_DEPTH_CLEAR                            (1 << 30)
  2157. # define GEN6_WM_DEPTH_RESOLVE                          (1 << 28)
  2158. # define GEN6_WM_HIERARCHICAL_DEPTH_RESOLVE             (1 << 27)
  2159. # define GEN6_WM_DISPATCH_START_GRF_SHIFT_0             16
  2160. # define GEN6_WM_DISPATCH_START_GRF_SHIFT_1             8
  2161. # define GEN6_WM_DISPATCH_START_GRF_SHIFT_2             0
  2162. /* DW5 */
  2163. # define GEN6_WM_MAX_THREADS_SHIFT                      25
  2164. # define GEN6_WM_KILL_ENABLE                            (1 << 22)
  2165. # define GEN6_WM_COMPUTED_DEPTH                         (1 << 21)
  2166. # define GEN6_WM_USES_SOURCE_DEPTH                      (1 << 20)
  2167. # define GEN6_WM_DISPATCH_ENABLE                        (1 << 19)
  2168. # define GEN6_WM_LINE_END_CAP_AA_WIDTH_0_5              (0 << 16)
  2169. # define GEN6_WM_LINE_END_CAP_AA_WIDTH_1_0              (1 << 16)
  2170. # define GEN6_WM_LINE_END_CAP_AA_WIDTH_2_0              (2 << 16)
  2171. # define GEN6_WM_LINE_END_CAP_AA_WIDTH_4_0              (3 << 16)
  2172. # define GEN6_WM_LINE_AA_WIDTH_0_5                      (0 << 14)
  2173. # define GEN6_WM_LINE_AA_WIDTH_1_0                      (1 << 14)
  2174. # define GEN6_WM_LINE_AA_WIDTH_2_0                      (2 << 14)
  2175. # define GEN6_WM_LINE_AA_WIDTH_4_0                      (3 << 14)
  2176. # define GEN6_WM_POLYGON_STIPPLE_ENABLE                 (1 << 13)
  2177. # define GEN6_WM_LINE_STIPPLE_ENABLE                    (1 << 11)
  2178. # define GEN6_WM_OMASK_TO_RENDER_TARGET                 (1 << 9)
  2179. # define GEN6_WM_USES_SOURCE_W                          (1 << 8)
  2180. # define GEN6_WM_DUAL_SOURCE_BLEND_ENABLE               (1 << 7)
  2181. # define GEN6_WM_32_DISPATCH_ENABLE                     (1 << 2)
  2182. # define GEN6_WM_16_DISPATCH_ENABLE                     (1 << 1)
  2183. # define GEN6_WM_8_DISPATCH_ENABLE                      (1 << 0)
  2184. /* DW6 */
  2185. # define GEN6_WM_NUM_SF_OUTPUTS_SHIFT                   20
  2186. # define GEN6_WM_POSOFFSET_NONE                         (0 << 18)
  2187. # define GEN6_WM_POSOFFSET_CENTROID                     (2 << 18)
  2188. # define GEN6_WM_POSOFFSET_SAMPLE                       (3 << 18)
  2189. # define GEN6_WM_POSITION_ZW_PIXEL                      (0 << 16)
  2190. # define GEN6_WM_POSITION_ZW_CENTROID                   (2 << 16)
  2191. # define GEN6_WM_POSITION_ZW_SAMPLE                     (3 << 16)
  2192. # define GEN6_WM_NONPERSPECTIVE_SAMPLE_BARYCENTRIC      (1 << 15)
  2193. # define GEN6_WM_NONPERSPECTIVE_CENTROID_BARYCENTRIC    (1 << 14)
  2194. # define GEN6_WM_NONPERSPECTIVE_PIXEL_BARYCENTRIC       (1 << 13)
  2195. # define GEN6_WM_PERSPECTIVE_SAMPLE_BARYCENTRIC         (1 << 12)
  2196. # define GEN6_WM_PERSPECTIVE_CENTROID_BARYCENTRIC       (1 << 11)
  2197. # define GEN6_WM_PERSPECTIVE_PIXEL_BARYCENTRIC          (1 << 10)
  2198. # define GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT   10
  2199. # define GEN6_WM_POINT_RASTRULE_UPPER_RIGHT             (1 << 9)
  2200. # define GEN6_WM_MSRAST_OFF_PIXEL                       (0 << 1)
  2201. # define GEN6_WM_MSRAST_OFF_PATTERN                     (1 << 1)
  2202. # define GEN6_WM_MSRAST_ON_PIXEL                        (2 << 1)
  2203. # define GEN6_WM_MSRAST_ON_PATTERN                      (3 << 1)
  2204. # define GEN6_WM_MSDISPMODE_PERSAMPLE                   (0 << 0)
  2205. # define GEN6_WM_MSDISPMODE_PERPIXEL                    (1 << 0)
  2206. /* DW7: kernel 1 pointer */
  2207. /* DW8: kernel 2 pointer */
  2208.  
  2209. #define _3DSTATE_CONSTANT_VS                  0x7815 /* GEN6+ */
  2210. #define _3DSTATE_CONSTANT_GS                  0x7816 /* GEN6+ */
  2211. #define _3DSTATE_CONSTANT_PS                  0x7817 /* GEN6+ */
  2212. # define GEN6_CONSTANT_BUFFER_3_ENABLE                  (1 << 15)
  2213. # define GEN6_CONSTANT_BUFFER_2_ENABLE                  (1 << 14)
  2214. # define GEN6_CONSTANT_BUFFER_1_ENABLE                  (1 << 13)
  2215. # define GEN6_CONSTANT_BUFFER_0_ENABLE                  (1 << 12)
  2216.  
  2217. #define _3DSTATE_CONSTANT_HS                  0x7819 /* GEN7+ */
  2218. #define _3DSTATE_CONSTANT_DS                  0x781A /* GEN7+ */
  2219.  
  2220. #define _3DSTATE_STREAMOUT                    0x781e /* GEN7+ */
  2221. /* DW1 */
  2222. # define SO_FUNCTION_ENABLE                             (1 << 31)
  2223. # define SO_RENDERING_DISABLE                           (1 << 30)
  2224. /* This selects which incoming rendering stream goes down the pipeline.  The
  2225.  * rendering stream is 0 if not defined by special cases in the GS state.
  2226.  */
  2227. # define SO_RENDER_STREAM_SELECT_SHIFT                  27
  2228. # define SO_RENDER_STREAM_SELECT_MASK                   INTEL_MASK(28, 27)
  2229. /* Controls reordering of TRISTRIP_* elements in stream output (not rendering).
  2230.  */
  2231. # define SO_REORDER_TRAILING                            (1 << 26)
  2232. /* Controls SO_NUM_PRIMS_WRITTEN_* and SO_PRIM_STORAGE_* */
  2233. # define SO_STATISTICS_ENABLE                           (1 << 25)
  2234. # define SO_BUFFER_ENABLE(n)                            (1 << (8 + (n)))
  2235. /* DW2 */
  2236. # define SO_STREAM_3_VERTEX_READ_OFFSET_SHIFT           29
  2237. # define SO_STREAM_3_VERTEX_READ_OFFSET_MASK            INTEL_MASK(29, 29)
  2238. # define SO_STREAM_3_VERTEX_READ_LENGTH_SHIFT           24
  2239. # define SO_STREAM_3_VERTEX_READ_LENGTH_MASK            INTEL_MASK(28, 24)
  2240. # define SO_STREAM_2_VERTEX_READ_OFFSET_SHIFT           21
  2241. # define SO_STREAM_2_VERTEX_READ_OFFSET_MASK            INTEL_MASK(21, 21)
  2242. # define SO_STREAM_2_VERTEX_READ_LENGTH_SHIFT           16
  2243. # define SO_STREAM_2_VERTEX_READ_LENGTH_MASK            INTEL_MASK(20, 16)
  2244. # define SO_STREAM_1_VERTEX_READ_OFFSET_SHIFT           13
  2245. # define SO_STREAM_1_VERTEX_READ_OFFSET_MASK            INTEL_MASK(13, 13)
  2246. # define SO_STREAM_1_VERTEX_READ_LENGTH_SHIFT           8
  2247. # define SO_STREAM_1_VERTEX_READ_LENGTH_MASK            INTEL_MASK(12, 8)
  2248. # define SO_STREAM_0_VERTEX_READ_OFFSET_SHIFT           5
  2249. # define SO_STREAM_0_VERTEX_READ_OFFSET_MASK            INTEL_MASK(5, 5)
  2250. # define SO_STREAM_0_VERTEX_READ_LENGTH_SHIFT           0
  2251. # define SO_STREAM_0_VERTEX_READ_LENGTH_MASK            INTEL_MASK(4, 0)
  2252.  
  2253. /* 3DSTATE_WM for Gen7 */
  2254. /* DW1 */
  2255. # define GEN7_WM_STATISTICS_ENABLE                      (1 << 31)
  2256. # define GEN7_WM_DEPTH_CLEAR                            (1 << 30)
  2257. # define GEN7_WM_DISPATCH_ENABLE                        (1 << 29)
  2258. # define GEN7_WM_DEPTH_RESOLVE                          (1 << 28)
  2259. # define GEN7_WM_HIERARCHICAL_DEPTH_RESOLVE             (1 << 27)
  2260. # define GEN7_WM_KILL_ENABLE                            (1 << 25)
  2261. # define GEN7_WM_COMPUTED_DEPTH_MODE_SHIFT              23
  2262. # define GEN7_WM_USES_SOURCE_DEPTH                      (1 << 20)
  2263. # define GEN7_WM_USES_SOURCE_W                          (1 << 19)
  2264. # define GEN7_WM_POSITION_ZW_PIXEL                      (0 << 17)
  2265. # define GEN7_WM_POSITION_ZW_CENTROID                   (2 << 17)
  2266. # define GEN7_WM_POSITION_ZW_SAMPLE                     (3 << 17)
  2267. # define GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT   11
  2268. # define GEN7_WM_USES_INPUT_COVERAGE_MASK               (1 << 10)
  2269. # define GEN7_WM_LINE_END_CAP_AA_WIDTH_0_5              (0 << 8)
  2270. # define GEN7_WM_LINE_END_CAP_AA_WIDTH_1_0              (1 << 8)
  2271. # define GEN7_WM_LINE_END_CAP_AA_WIDTH_2_0              (2 << 8)
  2272. # define GEN7_WM_LINE_END_CAP_AA_WIDTH_4_0              (3 << 8)
  2273. # define GEN7_WM_LINE_AA_WIDTH_0_5                      (0 << 6)
  2274. # define GEN7_WM_LINE_AA_WIDTH_1_0                      (1 << 6)
  2275. # define GEN7_WM_LINE_AA_WIDTH_2_0                      (2 << 6)
  2276. # define GEN7_WM_LINE_AA_WIDTH_4_0                      (3 << 6)
  2277. # define GEN7_WM_POLYGON_STIPPLE_ENABLE                 (1 << 4)
  2278. # define GEN7_WM_LINE_STIPPLE_ENABLE                    (1 << 3)
  2279. # define GEN7_WM_POINT_RASTRULE_UPPER_RIGHT             (1 << 2)
  2280. # define GEN7_WM_MSRAST_OFF_PIXEL                       (0 << 0)
  2281. # define GEN7_WM_MSRAST_OFF_PATTERN                     (1 << 0)
  2282. # define GEN7_WM_MSRAST_ON_PIXEL                        (2 << 0)
  2283. # define GEN7_WM_MSRAST_ON_PATTERN                      (3 << 0)
  2284. /* DW2 */
  2285. # define GEN7_WM_MSDISPMODE_PERSAMPLE                   (0 << 31)
  2286. # define GEN7_WM_MSDISPMODE_PERPIXEL                    (1 << 31)
  2287.  
  2288. #define _3DSTATE_PS                             0x7820 /* GEN7+ */
  2289. /* DW1: kernel pointer */
  2290. /* DW2 */
  2291. # define GEN7_PS_SPF_MODE                               (1 << 31)
  2292. # define GEN7_PS_VECTOR_MASK_ENABLE                     (1 << 30)
  2293. # define GEN7_PS_SAMPLER_COUNT_SHIFT                    27
  2294. # define GEN7_PS_SAMPLER_COUNT_MASK                     INTEL_MASK(29, 27)
  2295. # define GEN7_PS_BINDING_TABLE_ENTRY_COUNT_SHIFT        18
  2296. # define GEN7_PS_FLOATING_POINT_MODE_IEEE_754           (0 << 16)
  2297. # define GEN7_PS_FLOATING_POINT_MODE_ALT                (1 << 16)
  2298. /* DW3: scratch space */
  2299. /* DW4 */
  2300. # define IVB_PS_MAX_THREADS_SHIFT                       24
  2301. # define HSW_PS_MAX_THREADS_SHIFT                       23
  2302. # define HSW_PS_SAMPLE_MASK_SHIFT                       12
  2303. # define HSW_PS_SAMPLE_MASK_MASK                        INTEL_MASK(19, 12)
  2304. # define GEN7_PS_PUSH_CONSTANT_ENABLE                   (1 << 11)
  2305. # define GEN7_PS_ATTRIBUTE_ENABLE                       (1 << 10)
  2306. # define GEN7_PS_OMASK_TO_RENDER_TARGET                 (1 << 9)
  2307. # define GEN7_PS_RENDER_TARGET_FAST_CLEAR_ENABLE        (1 << 8)
  2308. # define GEN7_PS_DUAL_SOURCE_BLEND_ENABLE               (1 << 7)
  2309. # define GEN7_PS_RENDER_TARGET_RESOLVE_ENABLE           (1 << 6)
  2310. # define GEN7_PS_POSOFFSET_NONE                         (0 << 3)
  2311. # define GEN7_PS_POSOFFSET_CENTROID                     (2 << 3)
  2312. # define GEN7_PS_POSOFFSET_SAMPLE                       (3 << 3)
  2313. # define GEN7_PS_32_DISPATCH_ENABLE                     (1 << 2)
  2314. # define GEN7_PS_16_DISPATCH_ENABLE                     (1 << 1)
  2315. # define GEN7_PS_8_DISPATCH_ENABLE                      (1 << 0)
  2316. /* DW5 */
  2317. # define GEN7_PS_DISPATCH_START_GRF_SHIFT_0             16
  2318. # define GEN7_PS_DISPATCH_START_GRF_SHIFT_1             8
  2319. # define GEN7_PS_DISPATCH_START_GRF_SHIFT_2             0
  2320. /* DW6: kernel 1 pointer */
  2321. /* DW7: kernel 2 pointer */
  2322.  
  2323. #define _3DSTATE_SAMPLE_MASK                    0x7818 /* GEN6+ */
  2324.  
  2325. #define _3DSTATE_DRAWING_RECTANGLE              0x7900
  2326. #define _3DSTATE_BLEND_CONSTANT_COLOR           0x7901
  2327. #define _3DSTATE_CHROMA_KEY                     0x7904
  2328. #define _3DSTATE_DEPTH_BUFFER                   0x7905 /* GEN4-6 */
  2329. #define _3DSTATE_POLY_STIPPLE_OFFSET            0x7906
  2330. #define _3DSTATE_POLY_STIPPLE_PATTERN           0x7907
  2331. #define _3DSTATE_LINE_STIPPLE_PATTERN           0x7908
  2332. #define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP      0x7909
  2333. #define _3DSTATE_AA_LINE_PARAMETERS             0x790a /* G45+ */
  2334.  
  2335. #define _3DSTATE_GS_SVB_INDEX                   0x790b /* CTG+ */
  2336. /* DW1 */
  2337. # define SVB_INDEX_SHIFT                                29
  2338. # define SVB_LOAD_INTERNAL_VERTEX_COUNT                 (1 << 0) /* SNB+ */
  2339. /* DW2: SVB index */
  2340. /* DW3: SVB maximum index */
  2341.  
  2342. #define _3DSTATE_MULTISAMPLE                    0x790d /* GEN6+ */
  2343. #define GEN8_3DSTATE_MULTISAMPLE                0x780d /* GEN8+ */
  2344. /* DW1 */
  2345. # define MS_PIXEL_LOCATION_CENTER                       (0 << 4)
  2346. # define MS_PIXEL_LOCATION_UPPER_LEFT                   (1 << 4)
  2347. # define MS_NUMSAMPLES_1                                (0 << 1)
  2348. # define MS_NUMSAMPLES_2                                (1 << 1)
  2349. # define MS_NUMSAMPLES_4                                (2 << 1)
  2350. # define MS_NUMSAMPLES_8                                (3 << 1)
  2351. # define MS_NUMSAMPLES_16                               (4 << 1)
  2352.  
  2353. #define _3DSTATE_SAMPLE_PATTERN                 0x791c
  2354.  
  2355. #define _3DSTATE_STENCIL_BUFFER                 0x790e /* ILK, SNB */
  2356. #define _3DSTATE_HIER_DEPTH_BUFFER              0x790f /* ILK, SNB */
  2357.  
  2358. #define GEN7_3DSTATE_CLEAR_PARAMS               0x7804
  2359. #define GEN7_3DSTATE_DEPTH_BUFFER               0x7805
  2360. #define GEN7_3DSTATE_STENCIL_BUFFER             0x7806
  2361. # define HSW_STENCIL_ENABLED                            (1 << 31)
  2362. #define GEN7_3DSTATE_HIER_DEPTH_BUFFER          0x7807
  2363.  
  2364. #define _3DSTATE_CLEAR_PARAMS                   0x7910 /* ILK, SNB */
  2365. # define GEN5_DEPTH_CLEAR_VALID                         (1 << 15)
  2366. /* DW1: depth clear value */
  2367. /* DW2 */
  2368. # define GEN7_DEPTH_CLEAR_VALID                         (1 << 0)
  2369.  
  2370. #define _3DSTATE_SO_DECL_LIST                   0x7917 /* GEN7+ */
  2371. /* DW1 */
  2372. # define SO_STREAM_TO_BUFFER_SELECTS_3_SHIFT            12
  2373. # define SO_STREAM_TO_BUFFER_SELECTS_3_MASK             INTEL_MASK(15, 12)
  2374. # define SO_STREAM_TO_BUFFER_SELECTS_2_SHIFT            8
  2375. # define SO_STREAM_TO_BUFFER_SELECTS_2_MASK             INTEL_MASK(11, 8)
  2376. # define SO_STREAM_TO_BUFFER_SELECTS_1_SHIFT            4
  2377. # define SO_STREAM_TO_BUFFER_SELECTS_1_MASK             INTEL_MASK(7, 4)
  2378. # define SO_STREAM_TO_BUFFER_SELECTS_0_SHIFT            0
  2379. # define SO_STREAM_TO_BUFFER_SELECTS_0_MASK             INTEL_MASK(3, 0)
  2380. /* DW2 */
  2381. # define SO_NUM_ENTRIES_3_SHIFT                         24
  2382. # define SO_NUM_ENTRIES_3_MASK                          INTEL_MASK(31, 24)
  2383. # define SO_NUM_ENTRIES_2_SHIFT                         16
  2384. # define SO_NUM_ENTRIES_2_MASK                          INTEL_MASK(23, 16)
  2385. # define SO_NUM_ENTRIES_1_SHIFT                         8
  2386. # define SO_NUM_ENTRIES_1_MASK                          INTEL_MASK(15, 8)
  2387. # define SO_NUM_ENTRIES_0_SHIFT                         0
  2388. # define SO_NUM_ENTRIES_0_MASK                          INTEL_MASK(7, 0)
  2389.  
  2390. /* SO_DECL DW0 */
  2391. # define SO_DECL_OUTPUT_BUFFER_SLOT_SHIFT               12
  2392. # define SO_DECL_OUTPUT_BUFFER_SLOT_MASK                INTEL_MASK(13, 12)
  2393. # define SO_DECL_HOLE_FLAG                              (1 << 11)
  2394. # define SO_DECL_REGISTER_INDEX_SHIFT                   4
  2395. # define SO_DECL_REGISTER_INDEX_MASK                    INTEL_MASK(9, 4)
  2396. # define SO_DECL_COMPONENT_MASK_SHIFT                   0
  2397. # define SO_DECL_COMPONENT_MASK_MASK                    INTEL_MASK(3, 0)
  2398.  
  2399. #define _3DSTATE_SO_BUFFER                    0x7918 /* GEN7+ */
  2400. /* DW1 */
  2401. # define GEN8_SO_BUFFER_ENABLE                          (1 << 31)
  2402. # define SO_BUFFER_INDEX_SHIFT                          29
  2403. # define SO_BUFFER_INDEX_MASK                           INTEL_MASK(30, 29)
  2404. # define GEN8_SO_BUFFER_OFFSET_WRITE_ENABLE             (1 << 21)
  2405. # define GEN8_SO_BUFFER_OFFSET_ADDRESS_ENABLE           (1 << 20)
  2406. # define SO_BUFFER_PITCH_SHIFT                          0
  2407. # define SO_BUFFER_PITCH_MASK                           INTEL_MASK(11, 0)
  2408. /* DW2: start address */
  2409. /* DW3: end address. */
  2410.  
  2411. #define CMD_MI_FLUSH                  0x0200
  2412.  
  2413. # define BLT_X_SHIFT                                    0
  2414. # define BLT_X_MASK                                     INTEL_MASK(15, 0)
  2415. # define BLT_Y_SHIFT                                    16
  2416. # define BLT_Y_MASK                                     INTEL_MASK(31, 16)
  2417.  
  2418. #define GEN5_MI_REPORT_PERF_COUNT ((0x26 << 23) | (3 - 2))
  2419. /* DW0 */
  2420. # define GEN5_MI_COUNTER_SET_0      (0 << 6)
  2421. # define GEN5_MI_COUNTER_SET_1      (1 << 6)
  2422. /* DW1 */
  2423. # define MI_COUNTER_ADDRESS_GTT     (1 << 0)
  2424. /* DW2: a user-defined report ID (written to the buffer but can be anything) */
  2425.  
  2426. #define GEN6_MI_REPORT_PERF_COUNT ((0x28 << 23) | (3 - 2))
  2427.  
  2428. /* Bitfields for the URB_WRITE message, DW2 of message header: */
  2429. #define URB_WRITE_PRIM_END              0x1
  2430. #define URB_WRITE_PRIM_START            0x2
  2431. #define URB_WRITE_PRIM_TYPE_SHIFT       2
  2432.  
  2433.  
  2434. /* Maximum number of entries that can be addressed using a binding table
  2435.  * pointer of type SURFTYPE_BUFFER
  2436.  */
  2437. #define BRW_MAX_NUM_BUFFER_ENTRIES      (1 << 27)
  2438.  
  2439. /* Memory Object Control State:
  2440.  * Specifying zero for L3 means "uncached in L3", at least on Haswell
  2441.  * and Baytrail, since there are no PTE flags for setting L3 cacheability.
  2442.  * On Ivybridge, the PTEs do have a cache-in-L3 bit, so setting MOCS to 0
  2443.  * may still respect that.
  2444.  */
  2445. #define GEN7_MOCS_L3                    1
  2446.  
  2447. /* Ivybridge only: cache in LLC.
  2448.  * Specifying zero here means to use the PTE values set by the kernel;
  2449.  * non-zero overrides the PTE values.
  2450.  */
  2451. #define IVB_MOCS_LLC                    (1 << 1)
  2452.  
  2453. /* Baytrail only: snoop in CPU cache */
  2454. #define BYT_MOCS_SNOOP                  (1 << 1)
  2455.  
  2456. /* Haswell only: LLC/eLLC controls (write-back or uncached).
  2457.  * Specifying zero here means to use the PTE values set by the kernel,
  2458.  * which is useful since it offers additional control (write-through
  2459.  * cacheing and age).  Non-zero overrides the PTE values.
  2460.  */
  2461. #define HSW_MOCS_UC_LLC_UC_ELLC         (1 << 1)
  2462. #define HSW_MOCS_WB_LLC_WB_ELLC         (2 << 1)
  2463. #define HSW_MOCS_UC_LLC_WB_ELLC         (3 << 1)
  2464.  
  2465. /* Broadwell: these defines always use all available caches (L3, LLC, eLLC),
  2466.  * and let you force write-back (WB) or write-through (WT) caching, or leave
  2467.  * it up to the page table entry (PTE) specified by the kernel.
  2468.  */
  2469. #define BDW_MOCS_WB  0x78
  2470. #define BDW_MOCS_WT  0x58
  2471. #define BDW_MOCS_PTE 0x18
  2472.  
  2473. /* Skylake: MOCS is now an index into an array of 64 different configurable
  2474.  * cache settings.  We still use only either write-back or write-through; and
  2475.  * rely on the documented default values.
  2476.  */
  2477. #define SKL_MOCS_WB 9
  2478. #define SKL_MOCS_WT 5
  2479.  
  2480. #define MEDIA_VFE_STATE                         0x7000
  2481. /* GEN7 DW2, GEN8+ DW3 */
  2482. # define MEDIA_VFE_STATE_MAX_THREADS_SHIFT      16
  2483. # define MEDIA_VFE_STATE_MAX_THREADS_MASK       INTEL_MASK(31, 16)
  2484. # define MEDIA_VFE_STATE_URB_ENTRIES_SHIFT      8
  2485. # define MEDIA_VFE_STATE_URB_ENTRIES_MASK       INTEL_MASK(15, 8)
  2486. # define MEDIA_VFE_STATE_RESET_GTW_TIMER_SHIFT  7
  2487. # define MEDIA_VFE_STATE_RESET_GTW_TIMER_MASK   INTEL_MASK(7, 7)
  2488. # define MEDIA_VFE_STATE_BYPASS_GTW_SHIFT       6
  2489. # define MEDIA_VFE_STATE_BYPASS_GTW_MASK        INTEL_MASK(6, 6)
  2490. # define GEN7_MEDIA_VFE_STATE_GPGPU_MODE_SHIFT  2
  2491. # define GEN7_MEDIA_VFE_STATE_GPGPU_MODE_MASK   INTEL_MASK(2, 2)
  2492. /* GEN7 DW4, GEN8+ DW5 */
  2493. # define MEDIA_VFE_STATE_URB_ALLOC_SHIFT        16
  2494. # define MEDIA_VFE_STATE_URB_ALLOC_MASK         INTEL_MASK(31, 16)
  2495. # define MEDIA_VFE_STATE_CURBE_ALLOC_SHIFT      0
  2496. # define MEDIA_VFE_STATE_CURBE_ALLOC_MASK       INTEL_MASK(15, 0)
  2497.  
  2498. #define MEDIA_INTERFACE_DESCRIPTOR_LOAD         0x7002
  2499. #define MEDIA_STATE_FLUSH                       0x7004
  2500. #define GPGPU_WALKER                            0x7105
  2501. /* GEN8+ DW2 */
  2502. # define GPGPU_WALKER_INDIRECT_LENGTH_SHIFT     0
  2503. # define GPGPU_WALKER_INDIRECT_LENGTH_MASK      INTEL_MASK(15, 0)
  2504. /* GEN7 DW2, GEN8+ DW4 */
  2505. # define GPGPU_WALKER_SIMD_SIZE_SHIFT           30
  2506. # define GPGPU_WALKER_SIMD_SIZE_MASK            INTEL_MASK(31, 30)
  2507. # define GPGPU_WALKER_THREAD_DEPTH_MAX_SHIFT    16
  2508. # define GPGPU_WALKER_THREAD_DEPTH_MAX_MASK     INTEL_MASK(21, 16)
  2509. # define GPGPU_WALKER_THREAD_HEIGHT_MAX_SHIFT   8
  2510. # define GPGPU_WALKER_THREAD_HEIGHT_MAX_MASK    INTEL_MASK(31, 8)
  2511. # define GPGPU_WALKER_THREAD_WIDTH_MAX_SHIFT    0
  2512. # define GPGPU_WALKER_THREAD_WIDTH_MAX_MASK     INTEL_MASK(5, 0)
  2513.  
  2514. #endif
  2515.