Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

nv30_shader.h 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  1. #ifndef __NV30_SHADER_H__
  2. #define __NV30_SHADER_H__
  3. /* Vertex programs instruction set
  4. *
  5. * 128bit opcodes, split into 4 32-bit ones for ease of use.
  6. *
  7. * Non-native instructions
  8. * ABS - MOV + NV40_VP_INST0_DEST_ABS
  9. * POW - EX2 + MUL + LG2
  10. * SUB - ADD, second source negated
  11. * SWZ - MOV
  12. * XPD -
  13. *
  14. * Register access
  15. * - Only one INPUT can be accessed per-instruction (move extras into TEMPs)
  16. * - Only one CONST can be accessed per-instruction (move extras into TEMPs)
  17. *
  18. * Relative Addressing
  19. * According to the value returned for
  20. * MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB
  21. *
  22. * there are only two address registers available. The destination in the
  23. * ARL instruction is set to TEMP <n> (The temp isn't actually written).
  24. *
  25. * When using vanilla ARB_v_p, the proprietary driver will squish both the
  26. * available ADDRESS regs into the first hardware reg in the X and Y
  27. * components.
  28. *
  29. * To use an address reg as an index into consts, the CONST_SRC is set to
  30. * (const_base + offset) and INDEX_CONST is set.
  31. *
  32. * To access the second address reg use ADDR_REG_SELECT_1. A particular
  33. * component of the address regs is selected with ADDR_SWZ.
  34. *
  35. * Only one address register can be accessed per instruction.
  36. *
  37. * Conditional execution (see NV_vertex_program{2,3} for details) Conditional
  38. * execution of an instruction is enabled by setting COND_TEST_ENABLE, and
  39. * selecting the condition which will allow the test to pass with
  40. * COND_{FL,LT,...}. It is possible to swizzle the values in the condition
  41. * register, which allows for testing against an individual component.
  42. *
  43. * Branching:
  44. *
  45. * The BRA/CAL instructions seem to follow a slightly different opcode
  46. * layout. The destination instruction ID (IADDR) overlaps a source field.
  47. * Instruction ID's seem to be numbered based on the UPLOAD_FROM_ID FIFO
  48. * command, and is incremented automatically on each UPLOAD_INST FIFO
  49. * command.
  50. *
  51. * Conditional branching is achieved by using the condition tests described
  52. * above. There doesn't appear to be dedicated looping instructions, but
  53. * this can be done using a temp reg + conditional branching.
  54. *
  55. * Subroutines may be uploaded before the main program itself, but the first
  56. * executed instruction is determined by the PROGRAM_START_ID FIFO command.
  57. *
  58. */
  59. /* DWORD 0 */
  60. #define NV30_VP_INST_ADDR_REG_SELECT_1 (1 << 24)
  61. #define NV30_VP_INST_SRC2_ABS (1 << 23) /* guess */
  62. #define NV30_VP_INST_SRC1_ABS (1 << 22) /* guess */
  63. #define NV30_VP_INST_SRC0_ABS (1 << 21) /* guess */
  64. #define NV30_VP_INST_VEC_RESULT (1 << 20)
  65. #define NV30_VP_INST_DEST_TEMP_ID_SHIFT 16
  66. #define NV30_VP_INST_DEST_TEMP_ID_MASK (0x0F << 16)
  67. #define NV30_VP_INST_COND_UPDATE_ENABLE (1<<15)
  68. #define NV30_VP_INST_VEC_DEST_TEMP_MASK (0xF << 16)
  69. #define NV30_VP_INST_COND_TEST_ENABLE (1<<14)
  70. #define NV30_VP_INST_COND_SHIFT 11
  71. #define NV30_VP_INST_COND_MASK (0x07 << 11)
  72. # define NV30_VP_INST_COND_FL 0 /* guess */
  73. # define NV30_VP_INST_COND_LT 1
  74. # define NV30_VP_INST_COND_EQ 2
  75. # define NV30_VP_INST_COND_LE 3
  76. # define NV30_VP_INST_COND_GT 4
  77. # define NV30_VP_INST_COND_NE 5
  78. # define NV30_VP_INST_COND_GE 6
  79. # define NV30_VP_INST_COND_TR 7 /* guess */
  80. #define NV30_VP_INST_COND_SWZ_X_SHIFT 9
  81. #define NV30_VP_INST_COND_SWZ_X_MASK (0x03 << 9)
  82. #define NV30_VP_INST_COND_SWZ_Y_SHIFT 7
  83. #define NV30_VP_INST_COND_SWZ_Y_MASK (0x03 << 7)
  84. #define NV30_VP_INST_COND_SWZ_Z_SHIFT 5
  85. #define NV30_VP_INST_COND_SWZ_Z_MASK (0x03 << 5)
  86. #define NV30_VP_INST_COND_SWZ_W_SHIFT 3
  87. #define NV30_VP_INST_COND_SWZ_W_MASK (0x03 << 3)
  88. #define NV30_VP_INST_COND_SWZ_ALL_SHIFT 3
  89. #define NV30_VP_INST_COND_SWZ_ALL_MASK (0xFF << 3)
  90. #define NV30_VP_INST_ADDR_SWZ_SHIFT 1
  91. #define NV30_VP_INST_ADDR_SWZ_MASK (0x03 << 1)
  92. #define NV30_VP_INST_SCA_OPCODEH_SHIFT 0
  93. #define NV30_VP_INST_SCA_OPCODEH_MASK (0x01 << 0)
  94. /* DWORD 1 */
  95. #define NV30_VP_INST_SCA_OPCODEL_SHIFT 28
  96. #define NV30_VP_INST_SCA_OPCODEL_MASK (0x0F << 28)
  97. # define NV30_VP_INST_OP_NOP 0x00
  98. # define NV30_VP_INST_OP_RCP 0x02
  99. # define NV30_VP_INST_OP_RCC 0x03
  100. # define NV30_VP_INST_OP_RSQ 0x04
  101. # define NV30_VP_INST_OP_EXP 0x05
  102. # define NV30_VP_INST_OP_LOG 0x06
  103. # define NV30_VP_INST_OP_LIT 0x07
  104. # define NV30_VP_INST_OP_BRA 0x09
  105. # define NV30_VP_INST_OP_CAL 0x0B
  106. # define NV30_VP_INST_OP_RET 0x0C
  107. # define NV30_VP_INST_OP_LG2 0x0D
  108. # define NV30_VP_INST_OP_EX2 0x0E
  109. # define NV30_VP_INST_OP_SIN 0x0F
  110. # define NV30_VP_INST_OP_COS 0x10
  111. #define NV30_VP_INST_VEC_OPCODE_SHIFT 23
  112. #define NV30_VP_INST_VEC_OPCODE_MASK (0x1F << 23)
  113. # define NV30_VP_INST_OP_NOPV 0x00
  114. # define NV30_VP_INST_OP_MOV 0x01
  115. # define NV30_VP_INST_OP_MUL 0x02
  116. # define NV30_VP_INST_OP_ADD 0x03
  117. # define NV30_VP_INST_OP_MAD 0x04
  118. # define NV30_VP_INST_OP_DP3 0x05
  119. # define NV30_VP_INST_OP_DP4 0x07
  120. # define NV30_VP_INST_OP_DPH 0x06
  121. # define NV30_VP_INST_OP_DST 0x08
  122. # define NV30_VP_INST_OP_MIN 0x09
  123. # define NV30_VP_INST_OP_MAX 0x0A
  124. # define NV30_VP_INST_OP_SLT 0x0B
  125. # define NV30_VP_INST_OP_SGE 0x0C
  126. # define NV30_VP_INST_OP_ARL 0x0D
  127. # define NV30_VP_INST_OP_FRC 0x0E
  128. # define NV30_VP_INST_OP_FLR 0x0F
  129. # define NV30_VP_INST_OP_SEQ 0x10
  130. # define NV30_VP_INST_OP_SFL 0x11
  131. # define NV30_VP_INST_OP_SGT 0x12
  132. # define NV30_VP_INST_OP_SLE 0x13
  133. # define NV30_VP_INST_OP_SNE 0x14
  134. # define NV30_VP_INST_OP_STR 0x15
  135. # define NV30_VP_INST_OP_SSG 0x16
  136. # define NV30_VP_INST_OP_ARR 0x17
  137. # define NV30_VP_INST_OP_ARA 0x18
  138. #define NV30_VP_INST_CONST_SRC_SHIFT 14
  139. #define NV30_VP_INST_CONST_SRC_MASK (0xFF << 14)
  140. #define NV30_VP_INST_INPUT_SRC_SHIFT 9 /*NV20*/
  141. #define NV30_VP_INST_INPUT_SRC_MASK (0x0F << 9) /*NV20*/
  142. # define NV30_VP_INST_IN_POS 0 /* These seem to match the bindings specified in */
  143. # define NV30_VP_INST_IN_WEIGHT 1 /* the ARB_v_p spec (2.14.3.1) */
  144. # define NV30_VP_INST_IN_NORMAL 2
  145. # define NV30_VP_INST_IN_COL0 3 /* Should probably confirm them all though */
  146. # define NV30_VP_INST_IN_COL1 4
  147. # define NV30_VP_INST_IN_FOGC 5
  148. # define NV30_VP_INST_IN_TC0 8
  149. # define NV30_VP_INST_IN_TC(n) (8+n)
  150. #define NV30_VP_INST_SRC0H_SHIFT 0 /*NV20*/
  151. #define NV30_VP_INST_SRC0H_MASK (0x1FF << 0) /*NV20*/
  152. /* Please note: the IADDR fields overlap other fields because they are used
  153. * only for branch instructions. See Branching: label above
  154. *
  155. * DWORD 2
  156. */
  157. #define NV30_VP_INST_SRC0L_SHIFT 26 /*NV20*/
  158. #define NV30_VP_INST_SRC0L_MASK (0x3F <<26) /* NV30_VP_SRC0_LOW_MASK << 26 */
  159. #define NV30_VP_INST_SRC1_SHIFT 11 /*NV20*/
  160. #define NV30_VP_INST_SRC1_MASK (0x7FFF<<11) /*NV20*/
  161. #define NV30_VP_INST_SRC2H_SHIFT 0 /*NV20*/
  162. #define NV30_VP_INST_SRC2H_MASK (0x7FF << 0) /* NV30_VP_SRC2_HIGH_MASK >> 4*/
  163. #define NV30_VP_INST_IADDR_SHIFT 2
  164. #define NV30_VP_INST_IADDR_MASK (0xF << 28) /* NV30_VP_SRC2_LOW_MASK << 28 */
  165. /* DWORD 3 */
  166. #define NV30_VP_INST_SRC2L_SHIFT 28 /*NV20*/
  167. #define NV30_VP_INST_SRC2L_MASK (0x0F <<28) /*NV20*/
  168. #define NV30_VP_INST_STEMP_WRITEMASK_SHIFT 24
  169. #define NV30_VP_INST_STEMP_WRITEMASK_MASK (0x0F << 24)
  170. #define NV30_VP_INST_VTEMP_WRITEMASK_SHIFT 20
  171. #define NV30_VP_INST_VTEMP_WRITEMASK_MASK (0x0F << 20)
  172. #define NV30_VP_INST_SDEST_WRITEMASK_SHIFT 16
  173. #define NV30_VP_INST_SDEST_WRITEMASK_MASK (0x0F << 16)
  174. #define NV30_VP_INST_VDEST_WRITEMASK_SHIFT 12 /*NV20*/
  175. #define NV30_VP_INST_VDEST_WRITEMASK_MASK (0x0F << 12) /*NV20*/
  176. #define NV30_VP_INST_DEST_SHIFT 2
  177. #define NV30_VP_INST_DEST_MASK (0x0F << 2)
  178. # define NV30_VP_INST_DEST_POS 0
  179. # define NV30_VP_INST_DEST_BFC0 1
  180. # define NV30_VP_INST_DEST_BFC1 2
  181. # define NV30_VP_INST_DEST_COL0 3
  182. # define NV30_VP_INST_DEST_COL1 4
  183. # define NV30_VP_INST_DEST_FOGC 5
  184. # define NV30_VP_INST_DEST_PSZ 6
  185. # define NV30_VP_INST_DEST_TC(n) (8+n)
  186. #define NV30_VP_INST_LAST (1 << 0)
  187. /* Useful to split the source selection regs into their pieces */
  188. #define NV30_VP_SRC0_HIGH_SHIFT 6
  189. #define NV30_VP_SRC0_HIGH_MASK 0x00007FC0
  190. #define NV30_VP_SRC0_LOW_MASK 0x0000003F
  191. #define NV30_VP_SRC2_HIGH_SHIFT 4
  192. #define NV30_VP_SRC2_HIGH_MASK 0x00007FF0
  193. #define NV30_VP_SRC2_LOW_MASK 0x0000000F
  194. /* Source-register definition - matches NV20 exactly */
  195. #define NV30_VP_SRC_NEGATE (1<<14)
  196. #define NV30_VP_SRC_SWZ_X_SHIFT 12
  197. #define NV30_VP_SRC_REG_SWZ_X_MASK (0x03 <<12)
  198. #define NV30_VP_SRC_SWZ_Y_SHIFT 10
  199. #define NV30_VP_SRC_REG_SWZ_Y_MASK (0x03 <<10)
  200. #define NV30_VP_SRC_SWZ_Z_SHIFT 8
  201. #define NV30_VP_SRC_REG_SWZ_Z_MASK (0x03 << 8)
  202. #define NV30_VP_SRC_SWZ_W_SHIFT 6
  203. #define NV30_VP_SRC_REG_SWZ_W_MASK (0x03 << 6)
  204. #define NV30_VP_SRC_REG_SWZ_ALL_SHIFT 6
  205. #define NV30_VP_SRC_REG_SWZ_ALL_MASK (0xFF << 6)
  206. #define NV30_VP_SRC_TEMP_SRC_SHIFT 2
  207. #define NV30_VP_SRC_REG_TEMP_ID_MASK (0x0F << 0)
  208. #define NV30_VP_SRC_REG_TYPE_SHIFT 0
  209. #define NV30_VP_SRC_REG_TYPE_MASK (0x03 << 0)
  210. #define NV30_VP_SRC_REG_TYPE_TEMP 1
  211. #define NV30_VP_SRC_REG_TYPE_INPUT 2
  212. #define NV30_VP_SRC_REG_TYPE_CONST 3 /* guess */
  213. /*
  214. * Each fragment program opcode appears to be comprised of 4 32-bit values.
  215. *
  216. * 0 - Opcode, output reg/mask, ATTRIB source
  217. * 1 - Source 0
  218. * 2 - Source 1
  219. * 3 - Source 2
  220. *
  221. * There appears to be no special difference between result regs and temp regs.
  222. * result.color == R0.xyzw
  223. * result.depth == R1.z
  224. * When the fragprog contains instructions to write depth, NV30_TCL_PRIMITIVE_3D_UNK1D78=0
  225. * otherwise it is set to 1.
  226. *
  227. * Constants are inserted directly after the instruction that uses them.
  228. *
  229. * It appears that it's not possible to use two input registers in one
  230. * instruction as the input sourcing is done in the instruction dword
  231. * and not the source selection dwords. As such instructions such as:
  232. *
  233. * ADD result.color, fragment.color, fragment.texcoord[0];
  234. *
  235. * must be split into two MOV's and then an ADD (nvidia does this) but
  236. * I'm not sure why it's not just one MOV and then source the second input
  237. * in the ADD instruction..
  238. *
  239. * Negation of the full source is done with NV30_FP_REG_NEGATE, arbitrary
  240. * negation requires multiplication with a const.
  241. *
  242. * Arbitrary swizzling is supported with the exception of SWIZZLE_ZERO/SWIZZLE_ONE
  243. * The temp/result regs appear to be initialised to (0.0, 0.0, 0.0, 0.0) as SWIZZLE_ZERO
  244. * is implemented simply by not writing to the relevant components of the destination.
  245. *
  246. * Conditional execution
  247. * TODO
  248. *
  249. * Non-native instructions:
  250. * LIT
  251. * LRP - MAD+MAD
  252. * SUB - ADD, negate second source
  253. * RSQ - LG2 + EX2
  254. * POW - LG2 + MUL + EX2
  255. * SCS - COS + SIN
  256. * XPD
  257. */
  258. //== Opcode / Destination selection ==
  259. #define NV30_FP_OP_PROGRAM_END (1 << 0)
  260. #define NV30_FP_OP_OUT_REG_SHIFT 1
  261. #define NV30_FP_OP_OUT_REG_MASK (31 << 1) /* uncertain */
  262. /* Needs to be set when writing outputs to get expected result.. */
  263. #define NV30_FP_OP_OUT_REG_HALF (1 << 7)
  264. #define NV30_FP_OP_COND_WRITE_ENABLE (1 << 8)
  265. #define NV30_FP_OP_OUTMASK_SHIFT 9
  266. #define NV30_FP_OP_OUTMASK_MASK (0xF << 9)
  267. # define NV30_FP_OP_OUT_X (1<<9)
  268. # define NV30_FP_OP_OUT_Y (1<<10)
  269. # define NV30_FP_OP_OUT_Z (1<<11)
  270. # define NV30_FP_OP_OUT_W (1<<12)
  271. /* Uncertain about these, especially the input_src values.. it's possible that
  272. * they can be dynamically changed.
  273. */
  274. #define NV30_FP_OP_INPUT_SRC_SHIFT 13
  275. #define NV30_FP_OP_INPUT_SRC_MASK (15 << 13)
  276. # define NV30_FP_OP_INPUT_SRC_POSITION 0x0
  277. # define NV30_FP_OP_INPUT_SRC_COL0 0x1
  278. # define NV30_FP_OP_INPUT_SRC_COL1 0x2
  279. # define NV30_FP_OP_INPUT_SRC_FOGC 0x3
  280. # define NV30_FP_OP_INPUT_SRC_TC0 0x4
  281. # define NV30_FP_OP_INPUT_SRC_TC(n) (0x4 + n)
  282. #define NV30_FP_OP_TEX_UNIT_SHIFT 17
  283. #define NV30_FP_OP_TEX_UNIT_MASK (0xF << 17) /* guess */
  284. #define NV30_FP_OP_PRECISION_SHIFT 22
  285. #define NV30_FP_OP_PRECISION_MASK (3 << 22)
  286. # define NV30_FP_PRECISION_FP32 0
  287. # define NV30_FP_PRECISION_FP16 1
  288. # define NV30_FP_PRECISION_FX12 2
  289. #define NV30_FP_OP_OPCODE_SHIFT 24
  290. #define NV30_FP_OP_OPCODE_MASK (0x3F << 24)
  291. # define NV30_FP_OP_OPCODE_NOP 0x00
  292. # define NV30_FP_OP_OPCODE_MOV 0x01
  293. # define NV30_FP_OP_OPCODE_MUL 0x02
  294. # define NV30_FP_OP_OPCODE_ADD 0x03
  295. # define NV30_FP_OP_OPCODE_MAD 0x04
  296. # define NV30_FP_OP_OPCODE_DP3 0x05
  297. # define NV30_FP_OP_OPCODE_DP4 0x06
  298. # define NV30_FP_OP_OPCODE_DST 0x07
  299. # define NV30_FP_OP_OPCODE_MIN 0x08
  300. # define NV30_FP_OP_OPCODE_MAX 0x09
  301. # define NV30_FP_OP_OPCODE_SLT 0x0A
  302. # define NV30_FP_OP_OPCODE_SGE 0x0B
  303. # define NV30_FP_OP_OPCODE_SLE 0x0C
  304. # define NV30_FP_OP_OPCODE_SGT 0x0D
  305. # define NV30_FP_OP_OPCODE_SNE 0x0E
  306. # define NV30_FP_OP_OPCODE_SEQ 0x0F
  307. # define NV30_FP_OP_OPCODE_FRC 0x10
  308. # define NV30_FP_OP_OPCODE_FLR 0x11
  309. # define NV30_FP_OP_OPCODE_KIL 0x12
  310. # define NV30_FP_OP_OPCODE_PK4B 0x13
  311. # define NV30_FP_OP_OPCODE_UP4B 0x14
  312. # define NV30_FP_OP_OPCODE_DDX 0x15 /* can only write XY */
  313. # define NV30_FP_OP_OPCODE_DDY 0x16 /* can only write XY */
  314. # define NV30_FP_OP_OPCODE_TEX 0x17
  315. # define NV30_FP_OP_OPCODE_TXP 0x18
  316. # define NV30_FP_OP_OPCODE_TXD 0x19
  317. # define NV30_FP_OP_OPCODE_RCP 0x1A
  318. # define NV30_FP_OP_OPCODE_RSQ 0x1B
  319. # define NV30_FP_OP_OPCODE_EX2 0x1C
  320. # define NV30_FP_OP_OPCODE_LG2 0x1D
  321. # define NV30_FP_OP_OPCODE_LIT 0x1E
  322. # define NV30_FP_OP_OPCODE_LRP 0x1F
  323. # define NV30_FP_OP_OPCODE_STR 0x20
  324. # define NV30_FP_OP_OPCODE_SFL 0x21
  325. # define NV30_FP_OP_OPCODE_COS 0x22
  326. # define NV30_FP_OP_OPCODE_SIN 0x23
  327. # define NV30_FP_OP_OPCODE_PK2H 0x24
  328. # define NV30_FP_OP_OPCODE_UP2H 0x25
  329. # define NV30_FP_OP_OPCODE_POW 0x26
  330. # define NV30_FP_OP_OPCODE_PK4UB 0x27
  331. # define NV30_FP_OP_OPCODE_UP4UB 0x28
  332. # define NV30_FP_OP_OPCODE_PK2US 0x29
  333. # define NV30_FP_OP_OPCODE_UP2US 0x2A
  334. # define NV30_FP_OP_OPCODE_DP2A 0x2E
  335. # define NV30_FP_OP_OPCODE_TXB 0x31
  336. # define NV30_FP_OP_OPCODE_RFL 0x36
  337. # define NV30_FP_OP_OPCODE_DIV 0x3A
  338. #define NV30_FP_OP_OUT_SAT (1 << 31)
  339. /* high order bits of SRC0 */
  340. #define NV30_FP_OP_OUT_ABS (1 << 29)
  341. #define NV30_FP_OP_COND_SWZ_W_SHIFT 27
  342. #define NV30_FP_OP_COND_SWZ_W_MASK (3 << 27)
  343. #define NV30_FP_OP_COND_SWZ_Z_SHIFT 25
  344. #define NV30_FP_OP_COND_SWZ_Z_MASK (3 << 25)
  345. #define NV30_FP_OP_COND_SWZ_Y_SHIFT 23
  346. #define NV30_FP_OP_COND_SWZ_Y_MASK (3 << 23)
  347. #define NV30_FP_OP_COND_SWZ_X_SHIFT 21
  348. #define NV30_FP_OP_COND_SWZ_X_MASK (3 << 21)
  349. #define NV30_FP_OP_COND_SWZ_ALL_SHIFT 21
  350. #define NV30_FP_OP_COND_SWZ_ALL_MASK (0xFF << 21)
  351. #define NV30_FP_OP_COND_SHIFT 18
  352. #define NV30_FP_OP_COND_MASK (0x07 << 18)
  353. # define NV30_FP_OP_COND_FL 0
  354. # define NV30_FP_OP_COND_LT 1
  355. # define NV30_FP_OP_COND_EQ 2
  356. # define NV30_FP_OP_COND_LE 3
  357. # define NV30_FP_OP_COND_GT 4
  358. # define NV30_FP_OP_COND_NE 5
  359. # define NV30_FP_OP_COND_GE 6
  360. # define NV30_FP_OP_COND_TR 7
  361. /* high order bits of SRC1 */
  362. #define NV30_FP_OP_DST_SCALE_SHIFT 28
  363. #define NV30_FP_OP_DST_SCALE_MASK (3 << 28)
  364. #define NV30_FP_OP_DST_SCALE_1X 0
  365. #define NV30_FP_OP_DST_SCALE_2X 1
  366. #define NV30_FP_OP_DST_SCALE_4X 2
  367. #define NV30_FP_OP_DST_SCALE_8X 3
  368. #define NV30_FP_OP_DST_SCALE_INV_2X 5
  369. #define NV30_FP_OP_DST_SCALE_INV_4X 6
  370. #define NV30_FP_OP_DST_SCALE_INV_8X 7
  371. /* high order bits of SRC2 */
  372. #define NV30_FP_OP_INDEX_INPUT (1 << 30)
  373. //== Register selection ==
  374. #define NV30_FP_REG_TYPE_SHIFT 0
  375. #define NV30_FP_REG_TYPE_MASK (3 << 0)
  376. # define NV30_FP_REG_TYPE_TEMP 0
  377. # define NV30_FP_REG_TYPE_INPUT 1
  378. # define NV30_FP_REG_TYPE_CONST 2
  379. #define NV30_FP_REG_SRC_SHIFT 2 /* uncertain */
  380. #define NV30_FP_REG_SRC_MASK (31 << 2)
  381. #define NV30_FP_REG_SRC_HALF (1 << 8)
  382. #define NV30_FP_REG_SWZ_ALL_SHIFT 9
  383. #define NV30_FP_REG_SWZ_ALL_MASK (255 << 9)
  384. #define NV30_FP_REG_SWZ_X_SHIFT 9
  385. #define NV30_FP_REG_SWZ_X_MASK (3 << 9)
  386. #define NV30_FP_REG_SWZ_Y_SHIFT 11
  387. #define NV30_FP_REG_SWZ_Y_MASK (3 << 11)
  388. #define NV30_FP_REG_SWZ_Z_SHIFT 13
  389. #define NV30_FP_REG_SWZ_Z_MASK (3 << 13)
  390. #define NV30_FP_REG_SWZ_W_SHIFT 15
  391. #define NV30_FP_REG_SWZ_W_MASK (3 << 15)
  392. # define NV30_FP_SWIZZLE_X 0
  393. # define NV30_FP_SWIZZLE_Y 1
  394. # define NV30_FP_SWIZZLE_Z 2
  395. # define NV30_FP_SWIZZLE_W 3
  396. #define NV30_FP_REG_NEGATE (1 << 17)
  397. #define NV30SR_NONE 0
  398. #define NV30SR_OUTPUT 1
  399. #define NV30SR_INPUT 2
  400. #define NV30SR_TEMP 3
  401. #define NV30SR_CONST 4
  402. struct nv30_sreg {
  403. int type;
  404. int index;
  405. int dst_scale;
  406. int negate;
  407. int abs;
  408. int swz[4];
  409. int cc_update;
  410. int cc_update_reg;
  411. int cc_test;
  412. int cc_test_reg;
  413. int cc_swz[4];
  414. };
  415. static INLINE struct nv30_sreg
  416. nv30_sr(int type, int index)
  417. {
  418. struct nv30_sreg temp = {
  419. .type = type,
  420. .index = index,
  421. .dst_scale = DEF_SCALE,
  422. .abs = 0,
  423. .negate = 0,
  424. .swz = { 0, 1, 2, 3 },
  425. .cc_update = 0,
  426. .cc_update_reg = 0,
  427. .cc_test = DEF_CTEST,
  428. .cc_test_reg = 0,
  429. .cc_swz = { 0, 1, 2, 3 },
  430. };
  431. return temp;
  432. }
  433. static INLINE struct nv30_sreg
  434. nv30_sr_swz(struct nv30_sreg src, int x, int y, int z, int w)
  435. {
  436. struct nv30_sreg dst = src;
  437. dst.swz[SWZ_X] = src.swz[x];
  438. dst.swz[SWZ_Y] = src.swz[y];
  439. dst.swz[SWZ_Z] = src.swz[z];
  440. dst.swz[SWZ_W] = src.swz[w];
  441. return dst;
  442. }
  443. static INLINE struct nv30_sreg
  444. nv30_sr_neg(struct nv30_sreg src)
  445. {
  446. src.negate = !src.negate;
  447. return src;
  448. }
  449. static INLINE struct nv30_sreg
  450. nv30_sr_abs(struct nv30_sreg src)
  451. {
  452. src.abs = 1;
  453. return src;
  454. }
  455. static INLINE struct nv30_sreg
  456. nv30_sr_scale(struct nv30_sreg src, int scale)
  457. {
  458. src.dst_scale = scale;
  459. return src;
  460. }
  461. #endif