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_vertprog.h 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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_SWZ_X_SHIFT 9
  73. #define NV30_VP_INST_COND_SWZ_X_MASK (0x03 << 9)
  74. #define NV30_VP_INST_COND_SWZ_Y_SHIFT 7
  75. #define NV30_VP_INST_COND_SWZ_Y_MASK (0x03 << 7)
  76. #define NV30_VP_INST_COND_SWZ_Z_SHIFT 5
  77. #define NV30_VP_INST_COND_SWZ_Z_MASK (0x03 << 5)
  78. #define NV30_VP_INST_COND_SWZ_W_SHIFT 3
  79. #define NV30_VP_INST_COND_SWZ_W_MASK (0x03 << 3)
  80. #define NV30_VP_INST_COND_SWZ_ALL_SHIFT 3
  81. #define NV30_VP_INST_COND_SWZ_ALL_MASK (0xFF << 3)
  82. #define NV30_VP_INST_ADDR_SWZ_SHIFT 1
  83. #define NV30_VP_INST_ADDR_SWZ_MASK (0x03 << 1)
  84. #define NV30_VP_INST_SCA_OPCODEH_SHIFT 0
  85. #define NV30_VP_INST_SCA_OPCODEH_MASK (0x01 << 0)
  86. /* DWORD 1 */
  87. #define NV30_VP_INST_SCA_OPCODEL_SHIFT 28
  88. #define NV30_VP_INST_SCA_OPCODEL_MASK (0x0F << 28)
  89. #define NV30_VP_INST_VEC_OPCODE_SHIFT 23
  90. #define NV30_VP_INST_VEC_OPCODE_MASK (0x1F << 23)
  91. #define NV30_VP_INST_CONST_SRC_SHIFT 14
  92. #define NV30_VP_INST_CONST_SRC_MASK (0xFF << 14)
  93. #define NV30_VP_INST_INPUT_SRC_SHIFT 9 /*NV20*/
  94. #define NV30_VP_INST_INPUT_SRC_MASK (0x0F << 9) /*NV20*/
  95. #define NV30_VP_INST_SRC0H_SHIFT 0 /*NV20*/
  96. #define NV30_VP_INST_SRC0H_MASK (0x1FF << 0) /*NV20*/
  97. /* Please note: the IADDR fields overlap other fields because they are used
  98. * only for branch instructions. See Branching: label above
  99. *
  100. * DWORD 2
  101. */
  102. #define NV30_VP_INST_SRC0L_SHIFT 26 /*NV20*/
  103. #define NV30_VP_INST_SRC0L_MASK (0x3F <<26) /* NV30_VP_SRC0_LOW_MASK << 26 */
  104. #define NV30_VP_INST_SRC1_SHIFT 11 /*NV20*/
  105. #define NV30_VP_INST_SRC1_MASK (0x7FFF<<11) /*NV20*/
  106. #define NV30_VP_INST_SRC2H_SHIFT 0 /*NV20*/
  107. #define NV30_VP_INST_SRC2H_MASK (0x7FF << 0) /* NV30_VP_SRC2_HIGH_MASK >> 4*/
  108. #define NV30_VP_INST_IADDR_SHIFT 2
  109. #define NV30_VP_INST_IADDR_MASK (0xF << 28) /* NV30_VP_SRC2_LOW_MASK << 28 */
  110. /* DWORD 3 */
  111. #define NV30_VP_INST_SRC2L_SHIFT 28 /*NV20*/
  112. #define NV30_VP_INST_SRC2L_MASK (0x0F <<28) /*NV20*/
  113. #define NV30_VP_INST_STEMP_WRITEMASK_SHIFT 24
  114. #define NV30_VP_INST_STEMP_WRITEMASK_MASK (0x0F << 24)
  115. #define NV30_VP_INST_VTEMP_WRITEMASK_SHIFT 20
  116. #define NV30_VP_INST_VTEMP_WRITEMASK_MASK (0x0F << 20)
  117. #define NV30_VP_INST_SDEST_WRITEMASK_SHIFT 16
  118. #define NV30_VP_INST_SDEST_WRITEMASK_MASK (0x0F << 16)
  119. #define NV30_VP_INST_VDEST_WRITEMASK_SHIFT 12 /*NV20*/
  120. #define NV30_VP_INST_VDEST_WRITEMASK_MASK (0x0F << 12) /*NV20*/
  121. #define NV30_VP_INST_DEST_SHIFT 2
  122. #define NV30_VP_INST_DEST_MASK (0x0F << 2)
  123. # define NV30_VP_INST_DEST_POS 0
  124. # define NV30_VP_INST_DEST_BFC0 1
  125. # define NV30_VP_INST_DEST_BFC1 2
  126. # define NV30_VP_INST_DEST_COL0 3
  127. # define NV30_VP_INST_DEST_COL1 4
  128. # define NV30_VP_INST_DEST_FOGC 5
  129. # define NV30_VP_INST_DEST_PSZ 6
  130. # define NV30_VP_INST_DEST_TC(n) (8+n)
  131. /* Useful to split the source selection regs into their pieces */
  132. #define NV30_VP_SRC0_HIGH_SHIFT 6
  133. #define NV30_VP_SRC0_HIGH_MASK 0x00007FC0
  134. #define NV30_VP_SRC0_LOW_MASK 0x0000003F
  135. #define NV30_VP_SRC2_HIGH_SHIFT 4
  136. #define NV30_VP_SRC2_HIGH_MASK 0x00007FF0
  137. #define NV30_VP_SRC2_LOW_MASK 0x0000000F
  138. /* Source-register definition - matches NV20 exactly */
  139. #define NV30_VP_SRC_NEGATE (1<<14)
  140. #define NV30_VP_SRC_SWZ_X_SHIFT 12
  141. #define NV30_VP_SRC_REG_SWZ_X_MASK (0x03 <<12)
  142. #define NV30_VP_SRC_SWZ_Y_SHIFT 10
  143. #define NV30_VP_SRC_REG_SWZ_Y_MASK (0x03 <<10)
  144. #define NV30_VP_SRC_SWZ_Z_SHIFT 8
  145. #define NV30_VP_SRC_REG_SWZ_Z_MASK (0x03 << 8)
  146. #define NV30_VP_SRC_SWZ_W_SHIFT 6
  147. #define NV30_VP_SRC_REG_SWZ_W_MASK (0x03 << 6)
  148. #define NV30_VP_SRC_REG_SWZ_ALL_SHIFT 6
  149. #define NV30_VP_SRC_REG_SWZ_ALL_MASK (0xFF << 6)
  150. #define NV30_VP_SRC_TEMP_SRC_SHIFT 2
  151. #define NV30_VP_SRC_REG_TEMP_ID_MASK (0x0F << 0)
  152. #define NV30_VP_SRC_REG_TYPE_SHIFT 0
  153. #define NV30_VP_SRC_REG_TYPE_MASK (0x03 << 0)
  154. #define NV30_VP_SRC_REG_TYPE_TEMP 1
  155. #define NV30_VP_SRC_REG_TYPE_INPUT 2
  156. #define NV30_VP_SRC_REG_TYPE_CONST 3 /* guess */
  157. #include "nvfx_shader.h"
  158. #endif