Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /**************************************************************************
  2.  *
  3.  * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  4.  * All Rights Reserved.
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * 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, sub license, 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 portions
  16.  * of the Software.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19.  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21.  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  22.  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23.  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24.  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  *
  26.  **************************************************************************/
  27.  
  28. #define CMD_MI                          (0x0 << 29)
  29. #define CMD_2D                          (0x2 << 29)
  30. #define CMD_3D                          (0x3 << 29)
  31.  
  32. #define MI_NOOP                         (CMD_MI | 0)
  33.  
  34. #define MI_BATCH_BUFFER_END             (CMD_MI | 0xA << 23)
  35.  
  36. #define MI_FLUSH                        (CMD_MI | (4 << 23))
  37. #define FLUSH_MAP_CACHE                         (1 << 0)
  38. #define INHIBIT_FLUSH_RENDER_CACHE              (1 << 2)
  39.  
  40. #define MI_LOAD_REGISTER_IMM            (CMD_MI | (0x22 << 23))
  41.  
  42. #define MI_FLUSH_DW                     (CMD_MI | (0x26 << 23) | 2)
  43.  
  44. /* Stalls command execution waiting for the given events to have occurred. */
  45. #define MI_WAIT_FOR_EVENT               (CMD_MI | (0x3 << 23))
  46. #define MI_WAIT_FOR_PLANE_B_FLIP        (1<<6)
  47. #define MI_WAIT_FOR_PLANE_A_FLIP        (1<<2)
  48.  
  49. #define MI_STORE_REGISTER_MEM           (CMD_MI | (0x24 << 23))
  50. # define MI_STORE_REGISTER_MEM_USE_GGTT         (1 << 22)
  51.  
  52. /* p189 */
  53. #define _3DSTATE_LOAD_STATE_IMMEDIATE_1   (CMD_3D | (0x1d<<24) | (0x04<<16))
  54. #define I1_LOAD_S(n)                      (1<<(4+n))
  55.  
  56. #define _3DSTATE_DRAWRECT_INFO          (CMD_3D | (0x1d<<24) | (0x80<<16) | 0x3)
  57.  
  58. /** @{
  59.  *
  60.  * PIPE_CONTROL operation, a combination MI_FLUSH and register write with
  61.  * additional flushing control.
  62.  */
  63. #define _3DSTATE_PIPE_CONTROL           (CMD_3D | (3 << 27) | (2 << 24))
  64. #define PIPE_CONTROL_CS_STALL           (1 << 20)
  65. #define PIPE_CONTROL_GLOBAL_SNAPSHOT_COUNT_RESET        (1 << 19)
  66. #define PIPE_CONTROL_TLB_INVALIDATE     (1 << 18)
  67. #define PIPE_CONTROL_SYNC_GFDT          (1 << 17)
  68. #define PIPE_CONTROL_MEDIA_STATE_CLEAR  (1 << 16)
  69. #define PIPE_CONTROL_NO_WRITE           (0 << 14)
  70. #define PIPE_CONTROL_WRITE_IMMEDIATE    (1 << 14)
  71. #define PIPE_CONTROL_WRITE_DEPTH_COUNT  (2 << 14)
  72. #define PIPE_CONTROL_WRITE_TIMESTAMP    (3 << 14)
  73. #define PIPE_CONTROL_DEPTH_STALL        (1 << 13)
  74. #define PIPE_CONTROL_WRITE_FLUSH        (1 << 12)
  75. #define PIPE_CONTROL_INSTRUCTION_FLUSH  (1 << 11)
  76. #define PIPE_CONTROL_TC_FLUSH           (1 << 10) /* GM45+ only */
  77. #define PIPE_CONTROL_ISP_DIS            (1 << 9)
  78. #define PIPE_CONTROL_INTERRUPT_ENABLE   (1 << 8)
  79. /* GT */
  80. #define PIPE_CONTROL_VF_CACHE_INVALIDATE        (1 << 4)
  81. #define PIPE_CONTROL_CONST_CACHE_INVALIDATE     (1 << 3)
  82. #define PIPE_CONTROL_STATE_CACHE_INVALIDATE     (1 << 2)
  83. #define PIPE_CONTROL_STALL_AT_SCOREBOARD        (1 << 1)
  84. #define PIPE_CONTROL_DEPTH_CACHE_FLUSH          (1 << 0)
  85. #define PIPE_CONTROL_PPGTT_WRITE        (0 << 2)
  86. #define PIPE_CONTROL_GLOBAL_GTT_WRITE   (1 << 2)
  87.  
  88. /** @} */
  89.  
  90. /** @{
  91.  * 915 definitions
  92.  *
  93.  * 915 documents say that bits 31:28 and 1 are "undefined, must be zero."
  94.  */
  95. #define S0_VB_OFFSET_MASK               0x0ffffffc
  96. #define S0_AUTO_CACHE_INV_DISABLE       (1<<0)
  97. /** @} */
  98.  
  99. /** @{
  100.  * 830 definitions
  101.  */
  102. #define S0_VB_OFFSET_MASK_830           0xffffff80
  103. #define S0_VB_PITCH_SHIFT_830           1
  104. #define S0_VB_ENABLE_830                (1<<0)
  105. /** @} */
  106.  
  107. #define S1_VERTEX_WIDTH_SHIFT          24
  108. #define S1_VERTEX_WIDTH_MASK           (0x3f<<24)
  109. #define S1_VERTEX_PITCH_SHIFT          16
  110. #define S1_VERTEX_PITCH_MASK           (0x3f<<16)
  111.  
  112. #define TEXCOORDFMT_2D                 0x0
  113. #define TEXCOORDFMT_3D                 0x1
  114. #define TEXCOORDFMT_4D                 0x2
  115. #define TEXCOORDFMT_1D                 0x3
  116. #define TEXCOORDFMT_2D_16              0x4
  117. #define TEXCOORDFMT_4D_16              0x5
  118. #define TEXCOORDFMT_NOT_PRESENT        0xf
  119. #define S2_TEXCOORD_FMT0_MASK            0xf
  120. #define S2_TEXCOORD_FMT1_SHIFT           4
  121. #define S2_TEXCOORD_FMT(unit, type)    ((type)<<(unit*4))
  122. #define S2_TEXCOORD_NONE               (~0)
  123. #define S2_TEX_COUNT_SHIFT_830          12
  124. #define S2_VERTEX_1_WIDTH_SHIFT_830     0
  125. #define S2_VERTEX_0_WIDTH_SHIFT_830     6
  126. /* S3 not interesting */
  127.  
  128. #define S4_POINT_WIDTH_SHIFT           23
  129. #define S4_POINT_WIDTH_MASK            (0x1ff<<23)
  130. #define S4_LINE_WIDTH_SHIFT            19
  131. #define S4_LINE_WIDTH_ONE              (0x2<<19)
  132. #define S4_LINE_WIDTH_MASK             (0xf<<19)
  133. #define S4_FLATSHADE_ALPHA             (1<<18)
  134. #define S4_FLATSHADE_FOG               (1<<17)
  135. #define S4_FLATSHADE_SPECULAR          (1<<16)
  136. #define S4_FLATSHADE_COLOR             (1<<15)
  137. #define S4_CULLMODE_BOTH               (0<<13)
  138. #define S4_CULLMODE_NONE               (1<<13)
  139. #define S4_CULLMODE_CW                 (2<<13)
  140. #define S4_CULLMODE_CCW                (3<<13)
  141. #define S4_CULLMODE_MASK               (3<<13)
  142. #define S4_VFMT_POINT_WIDTH            (1<<12)
  143. #define S4_VFMT_SPEC_FOG               (1<<11)
  144. #define S4_VFMT_COLOR                  (1<<10)
  145. #define S4_VFMT_DEPTH_OFFSET           (1<<9)
  146. #define S4_VFMT_XYZ                    (1<<6)
  147. #define S4_VFMT_XYZW                   (2<<6)
  148. #define S4_VFMT_XY                     (3<<6)
  149. #define S4_VFMT_XYW                    (4<<6)
  150. #define S4_VFMT_XYZW_MASK              (7<<6)
  151. #define S4_FORCE_DEFAULT_DIFFUSE       (1<<5)
  152. #define S4_FORCE_DEFAULT_SPECULAR      (1<<4)
  153. #define S4_LOCAL_DEPTH_OFFSET_ENABLE   (1<<3)
  154. #define S4_VFMT_FOG_PARAM              (1<<2)
  155. #define S4_SPRITE_POINT_ENABLE         (1<<1)
  156. #define S4_LINE_ANTIALIAS_ENABLE       (1<<0)
  157.  
  158. #define S4_VFMT_MASK (S4_VFMT_POINT_WIDTH   |   \
  159.                       S4_VFMT_SPEC_FOG      |   \
  160.                       S4_VFMT_COLOR         |   \
  161.                       S4_VFMT_DEPTH_OFFSET  |   \
  162.                       S4_VFMT_XYZW_MASK     |   \
  163.                       S4_VFMT_FOG_PARAM)
  164.  
  165.  
  166. #define S5_WRITEDISABLE_ALPHA          (1<<31)
  167. #define S5_WRITEDISABLE_RED            (1<<30)
  168. #define S5_WRITEDISABLE_GREEN          (1<<29)
  169. #define S5_WRITEDISABLE_BLUE           (1<<28)
  170. #define S5_WRITEDISABLE_MASK           (0xf<<28)
  171. #define S5_FORCE_DEFAULT_POINT_SIZE    (1<<27)
  172. #define S5_LAST_PIXEL_ENABLE           (1<<26)
  173. #define S5_GLOBAL_DEPTH_OFFSET_ENABLE  (1<<25)
  174. #define S5_FOG_ENABLE                  (1<<24)
  175. #define S5_STENCIL_REF_SHIFT           16
  176. #define S5_STENCIL_REF_MASK            (0xff<<16)
  177. #define S5_STENCIL_TEST_FUNC_SHIFT     13
  178. #define S5_STENCIL_TEST_FUNC_MASK      (0x7<<13)
  179. #define S5_STENCIL_FAIL_SHIFT          10
  180. #define S5_STENCIL_FAIL_MASK           (0x7<<10)
  181. #define S5_STENCIL_PASS_Z_FAIL_SHIFT   7
  182. #define S5_STENCIL_PASS_Z_FAIL_MASK    (0x7<<7)
  183. #define S5_STENCIL_PASS_Z_PASS_SHIFT   4
  184. #define S5_STENCIL_PASS_Z_PASS_MASK    (0x7<<4)
  185. #define S5_STENCIL_WRITE_ENABLE        (1<<3)
  186. #define S5_STENCIL_TEST_ENABLE         (1<<2)
  187. #define S5_COLOR_DITHER_ENABLE         (1<<1)
  188. #define S5_LOGICOP_ENABLE              (1<<0)
  189.  
  190.  
  191. #define S6_ALPHA_TEST_ENABLE           (1<<31)
  192. #define S6_ALPHA_TEST_FUNC_SHIFT       28
  193. #define S6_ALPHA_TEST_FUNC_MASK        (0x7<<28)
  194. #define S6_ALPHA_REF_SHIFT             20
  195. #define S6_ALPHA_REF_MASK              (0xff<<20)
  196. #define S6_DEPTH_TEST_ENABLE           (1<<19)
  197. #define S6_DEPTH_TEST_FUNC_SHIFT       16
  198. #define S6_DEPTH_TEST_FUNC_MASK        (0x7<<16)
  199. #define S6_CBUF_BLEND_ENABLE           (1<<15)
  200. #define S6_CBUF_BLEND_FUNC_SHIFT       12
  201. #define S6_CBUF_BLEND_FUNC_MASK        (0x7<<12)
  202. #define S6_CBUF_SRC_BLEND_FACT_SHIFT   8
  203. #define S6_CBUF_SRC_BLEND_FACT_MASK    (0xf<<8)
  204. #define S6_CBUF_DST_BLEND_FACT_SHIFT   4
  205. #define S6_CBUF_DST_BLEND_FACT_MASK    (0xf<<4)
  206. #define S6_DEPTH_WRITE_ENABLE          (1<<3)
  207. #define S6_COLOR_WRITE_ENABLE          (1<<2)
  208. #define S6_TRISTRIP_PV_SHIFT           0
  209. #define S6_TRISTRIP_PV_MASK            (0x3<<0)
  210.  
  211. #define S7_DEPTH_OFFSET_CONST_MASK     ~0
  212.  
  213. /* p143 */
  214. #define _3DSTATE_BUF_INFO_CMD   (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
  215. /* Dword 1 */
  216. #define BUF_3D_ID_COLOR_BACK    (0x3<<24)
  217. #define BUF_3D_ID_DEPTH         (0x7<<24)
  218. #define BUF_3D_USE_FENCE        (1<<23)
  219. #define BUF_3D_TILED_SURFACE    (1<<22)
  220. #define BUF_3D_TILE_WALK_X      0
  221. #define BUF_3D_TILE_WALK_Y      (1<<21)
  222. #define BUF_3D_PITCH(x)         (((x)/4)<<2)
  223. /* Dword 2 */
  224. #define BUF_3D_ADDR(x)          ((x) & ~0x3)
  225.  
  226. /* Primitive dispatch on 830-945 */
  227. #define _3DPRIMITIVE                    (CMD_3D | (0x1f << 24))
  228. #define PRIM_INDIRECT            (1<<23)
  229. #define PRIM_INLINE              (0<<23)
  230. #define PRIM_INDIRECT_SEQUENTIAL (0<<17)
  231. #define PRIM_INDIRECT_ELTS       (1<<17)
  232.  
  233. #define PRIM3D_TRILIST          (0x0<<18)
  234. #define PRIM3D_TRISTRIP         (0x1<<18)
  235. #define PRIM3D_TRISTRIP_RVRSE   (0x2<<18)
  236. #define PRIM3D_TRIFAN           (0x3<<18)
  237. #define PRIM3D_POLY             (0x4<<18)
  238. #define PRIM3D_LINELIST         (0x5<<18)
  239. #define PRIM3D_LINESTRIP        (0x6<<18)
  240. #define PRIM3D_RECTLIST         (0x7<<18)
  241. #define PRIM3D_POINTLIST        (0x8<<18)
  242. #define PRIM3D_DIB              (0x9<<18)
  243. #define PRIM3D_MASK             (0x1f<<18)
  244.  
  245. #define XY_SETUP_BLT_CMD                (CMD_2D | (0x01 << 22))
  246.  
  247. #define XY_COLOR_BLT_CMD                (CMD_2D | (0x50 << 22))
  248.  
  249. #define XY_SRC_COPY_BLT_CMD             (CMD_2D | (0x53 << 22))
  250.  
  251. #define XY_TEXT_IMMEDIATE_BLIT_CMD      (CMD_2D | (0x31 << 22))
  252. # define XY_TEXT_BYTE_PACKED            (1 << 16)
  253.  
  254. /* BR00 */
  255. #define XY_BLT_WRITE_ALPHA      (1 << 21)
  256. #define XY_BLT_WRITE_RGB        (1 << 20)
  257. #define XY_SRC_TILED            (1 << 15)
  258. #define XY_DST_TILED            (1 << 11)
  259.  
  260. /* BR13 */
  261. #define BR13_8                  (0x0 << 24)
  262. #define BR13_565                (0x1 << 24)
  263. #define BR13_8888               (0x3 << 24)
  264.  
  265. #define FENCE_LINEAR 0
  266. #define FENCE_XMAJOR 1
  267. #define FENCE_YMAJOR 2
  268.  
  269. /* Pipeline Statistics Counter Registers */
  270. #define IA_VERTICES_COUNT               0x2310
  271. #define IA_PRIMITIVES_COUNT             0x2318
  272. #define VS_INVOCATION_COUNT             0x2320
  273. #define HS_INVOCATION_COUNT             0x2300
  274. #define DS_INVOCATION_COUNT             0x2308
  275. #define GS_INVOCATION_COUNT             0x2328
  276. #define GS_PRIMITIVES_COUNT             0x2330
  277. #define CL_INVOCATION_COUNT             0x2338
  278. #define CL_PRIMITIVES_COUNT             0x2340
  279. #define PS_INVOCATION_COUNT             0x2348
  280. #define PS_DEPTH_COUNT                  0x2350
  281.  
  282. #define SO_NUM_PRIM_STORAGE_NEEDED      0x2280
  283. #define SO_PRIM_STORAGE_NEEDED0_IVB     0x5240
  284. #define SO_PRIM_STORAGE_NEEDED1_IVB     0x5248
  285. #define SO_PRIM_STORAGE_NEEDED2_IVB     0x5250
  286. #define SO_PRIM_STORAGE_NEEDED3_IVB     0x5258
  287.  
  288. #define SO_NUM_PRIMS_WRITTEN            0x2288
  289. #define SO_NUM_PRIMS_WRITTEN0_IVB       0x5200
  290. #define SO_NUM_PRIMS_WRITTEN1_IVB       0x5208
  291. #define SO_NUM_PRIMS_WRITTEN2_IVB       0x5210
  292. #define SO_NUM_PRIMS_WRITTEN3_IVB       0x5218
  293.  
  294. #define TIMESTAMP                       0x2358
  295.  
  296. #define BCS_SWCTRL                      0x22200
  297. # define BCS_SWCTRL_SRC_Y               (1 << 0)
  298. # define BCS_SWCTRL_DST_Y               (1 << 1)
  299.