Leaked source code of windows server 2003
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.

502 lines
29 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  4. * !! !!
  5. * !! WARNING: NOT DDK SAMPLE CODE !!
  6. * !! !!
  7. * !! This source code is provided for completeness only and should not be !!
  8. * !! used as sample code for display driver development. Only those sources !!
  9. * !! marked as sample code for a given driver component should be used for !!
  10. * !! development purposes. !!
  11. * !! !!
  12. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  13. *
  14. * Module Name: bitmac2.h
  15. *
  16. * Content: Permedia3 macros to set bits in hw registers
  17. *
  18. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  19. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  20. \*****************************************************************************/
  21. // The macros in this file are used from the 2D side to correctly shift values
  22. // into the correct place in the register. The values passed to these macros
  23. // are in glintdef.h and pmdef.h, and p3rxdef.h
  24. #ifndef __BITMAC2
  25. #define __BITMAC2
  26. // *******************************************************************
  27. // Permedia Bit Field Macros
  28. // FBReadMode
  29. #define PM_FBREADMODE_PARTIAL(a) (a << 0)
  30. #define PM_FBREADMODE_READSOURCE(a) (a << 9)
  31. #define PM_FBREADMODE_READDEST(a) (a << 10)
  32. #define PM_FBREADMODE_DATATYPE(a) (a << 15)
  33. #define PM_FBREADMODE_WINDOWORIGIN(a) (a << 16)
  34. #define PM_FBREADMODE_TEXELINHIBIT(a) (a << 17)
  35. #define PM_FBREADMODE_PATCHENABLE(a) (a << 18)
  36. #define PM_FBREADMODE_PACKEDDATA(a) (a << 19)
  37. #define PM_FBREADMODE_RELATIVEOFFSET(a) (a << 20)
  38. #define PM_FBREADMODE_SCANLINEINTERVAL(a) (a << 23)
  39. #define PM_FBREADMODE_PARTIAL3(a) (a << 25)
  40. #define PM_FBREADMODE_PATCHMODE(a) (a << 25)
  41. #define PM_FBREADMODE_SOURCEADDRESS(a) (a << 28)
  42. // FBWriteMode
  43. #define PM_FBWRITEMODE_ENABLE(a) (a << 0)
  44. #define PM_FBWRITEMODE_UPLOADDATA(a) (a << 3)
  45. // Texture Address mode
  46. #define PM_TEXADDRESSMODE_ENABLE(a) (a << 0)
  47. #define PM_TEXADDRESSMODE_PERSPECTIVE(a) (a << 1)
  48. // Texture read mode
  49. #define PM_TEXREADMODE_ENABLE(a) (a << 0)
  50. #define PM_TEXREADMODE_SWRAP(a) (a << 1)
  51. #define PM_TEXREADMODE_TWRAP(a) (a << 3)
  52. #define PM_TEXREADMODE_WIDTH(a) (a << 9)
  53. #define PM_TEXREADMODE_HEIGHT(a) (a << 13)
  54. #define PM_TEXREADMODE_FILTER(a) (a << 17)
  55. #define PM_TEXREADMODE_PACKEDDATA(a) (a << 24)
  56. // TextureColorMode
  57. #define PM_TEXCOLORMODE_ENABLE(a) (a << 0)
  58. #define PM_TEXCOLORMODE_APPLICATIONMODE(a) (a << 1)
  59. #define PM_TEXCOLORMODE_TEXTURETYPE(a) (a << 4)
  60. #define PM_TEXCOLORMODE_KDDDA(a) (a << 5)
  61. #define PM_TEXCOLORMODE_KSDDA(a) (a << 6)
  62. // TextureDataFormat
  63. #define PM_TEXDATAFORMAT_FORMAT(a) (a << 0)
  64. #define PM_TEXDATAFORMAT_NOALPHABUFFER(a) (a << 4)
  65. #define PM_TEXDATAFORMAT_COLORORDER(a) (a << 5)
  66. #define PM_TEXDATAFORMAT_FORMATEXTENSION(a) (a << 6)
  67. #define PM_TEXDATAFORMAT_ALPHAMAP(a) (a << 7)
  68. #define PM_TEXDATAFORMAT_SPANFORMAT(a) (a << 9)
  69. // PackedDataLimits
  70. #define PM_PACKEDDATALIMITS_OFFSET(a) (a << 29)
  71. #define PM_PACKEDDATALIMITS_XSTART(a) (a << 0)
  72. #define PM_PACKEDDATALIMITS_XEND(a) (a << 16)
  73. // Window Register
  74. #define PM_WINDOW_FORCELBUPDATE(a) (a << 3)
  75. #define PM_WINDOW_LBUPDATESOURCE(a) (a << 4)
  76. #define PM_WINDOW_DISABLELBUPDATE(a) (a << 18)
  77. // Colors
  78. #define PM_BYTE_COLOR(a) (a << 15);
  79. // VideoPort Registers
  80. // Video Signal Config
  81. #define PM_VSCONFIG_UNITMODE(a) ((a) << 0)
  82. #define PM_VSCONFIG_GPMODE_A(a) ((a) << 3)
  83. #define PM_VSCONFIG_ROMPULSE(a) ((a) << 4)
  84. // Stream A
  85. #define PM_VSCONFIG_HREF_POL_A(a) ((a) << 9)
  86. #define PM_VSCONFIG_VREF_POL_A(a) ((a) << 10)
  87. #define PM_VSCONFIG_VACTIVE_POLA(a) ((a) << 11)
  88. #define PM_VSCONFIG_USEFIELD_A(a) ((a) << 12)
  89. #define PM_VSCONFIG_FIELD_POL_A(a) ((a) << 13)
  90. #define PM_VSCONFIG_FIELD_EDGE_A(a) ((a) << 14)
  91. #define PM_VSCONFIG_VACTIVE_VBI_A(a) ((a) << 15)
  92. #define PM_VSCONFIG_INTERLACE_A(a) ((a) << 16)
  93. #define PM_VSCONFIG_REVERSEDATA_A(a) ((a) << 17)
  94. // Stream B
  95. #define PM_VSCONFIG_HREF_POL_B(a) ((a) << 18)
  96. #define PM_VSCONFIG_VREF_POL_B(a) ((a) << 19)
  97. #define PM_VSCONFIG_VACTIVE_POLB(a) ((a) << 20)
  98. #define PM_VSCONFIG_USEFIELD_B(a) ((a) << 21)
  99. #define PM_VSCONFIG_FIELD_POL_B(a) ((a) << 22)
  100. #define PM_VSCONFIG_FIELD_EDGE_B(a) ((a) << 23)
  101. #define PM_VSCONFIG_VACTIVE_VBI_B(a) ((a) << 24)
  102. #define PM_VSCONFIG_INTERLACE_B(a) ((a) << 25)
  103. #define PM_VSCONFIG_COLORSPACE_B(a) ((a) << 26)
  104. #define PM_VSCONFIG_REVERSEDATA_B(a) ((a) << 27)
  105. #define PM_VSCONFIG_DOUBLEEDGE_B(a) ((a) << 28)
  106. // Video Signal Status
  107. // Macros for getting individual states
  108. #define PM_GET_VSSTATUS_GPBUSTIMEOUT(a) ((a & (1 << 0)) >> 0)
  109. #define PM_GET_VSSTATUS_FIFOOVERFLOW_A(a) ((a & (1 << 8)) >> 8)
  110. #define PM_GET_VSSTATUS_FIELDONE0_A(a) ((a & (1 << 9)) >> 9)
  111. #define PM_GET_VSSTATUS_FIELDONE1_A(a) ((a & (1 << 10)) >> 10)
  112. #define PM_GET_VSSTATUS_FIELDONE2_A(a) ((a & (1 << 11)) >> 11)
  113. #define PM_GET_VSSTATUS_INVALIDINTERLACE_A(a) ((a & (1 << 12)) >> 12)
  114. #define PM_GET_VSSTATUS_FIFOUNDERFLOW_B(a) ((a & (1 << 16)) >> 16)
  115. #define PM_GET_VSSTATUS_FIELDONE0_B(a) ((a & (1 << 17)) >> 17)
  116. #define PM_GET_VSSTATUS_FIELDONE1_B(a) ((a & (1 << 18)) >> 18)
  117. #define PM_GET_VSSTATUS_FIELDONE2_B(a) ((a & (1 << 19)) >> 19)
  118. #define PM_GET_VSSTATUS_INVALIDINTERLACE_B(a) ((a & (1 << 20)) >> 20)
  119. // Macros for setting individual states
  120. #define PM_SET_VSSTATUS_GPBUSTIMEOUT(a) (a << 0)
  121. #define PM_SET_VSSTATUS_FIFOOVERFLOW_A(a) (a << 8)
  122. #define PM_SET_VSSTATUS_FIFOUNDERFLOW_B(a) (a << 16)
  123. // Serial Bus Control
  124. // Get state
  125. #define PM_GET_VSSERIALBUS_DATAIN(a) ((a & (1 << 0)) >> 0)
  126. #define PM_GET_VSSERIALBUS_CLKIN(a) ((a & (1 << 1)) >> 1)
  127. #define PM_GET_VSSERIALBUS_DATAOUT(a) ((a & (1 << 2)) >> 2)
  128. #define PM_GET_VSSERIALBUS_CLKOUT(a) ((a & (1 << 3)) >> 3)
  129. #define PM_GET_VSSERIALBUS_LATCHEDDATA(a) ((a & (1 << 4)) >> 4)
  130. #define PM_GET_VSSERIALBUS_DATAVALID(a) ((a & (1 << 5)) >> 5)
  131. #define PM_GET_VSSERIALBUS_START(a) ((a & (1 << 6)) >> 6)
  132. #define PM_GET_VSSERIALBUS_STOP(a) ((a & (1 << 7)) >> 7)
  133. #define PM_GET_VSSERIALBUS_WAIT(a) ((a & (1 << 8)) >> 8)
  134. // Set State
  135. #define PM_SET_VSSERIALBUS_DATAOUT(a) (a << 2)
  136. #define PM_SET_VSSERIALBUS_CLKOUT(a) (a << 3)
  137. #define PM_SET_VSSERIALBUS_LATCHEDDATA(a) (a << 4)
  138. #define PM_SET_VSSERIALBUS_DATAVALID(a) (a << 5)
  139. #define PM_SET_VSSERIALBUS_START(a) (a << 6)
  140. #define PM_SET_VSSERIALBUS_STOP(a) (a << 7)
  141. #define PM_SET_VSSERIALBUS_WAIT(a) (a << 8)
  142. // Video Stream A Control
  143. #define PM_VSACONTROL_VIDEO(a) ((a) << 0)
  144. #define PM_VSACONTROL_VBI(a) ((a) << 1)
  145. #define PM_VSACONTROL_BUFFER(a) ((a) << 2)
  146. #define PM_VSACONTROL_SCALEX(a) ((a) << 3)
  147. #define PM_VSACONTROL_SCALEY(a) ((a) << 5)
  148. #define PM_VSACONTROL_MIRRORX(a) ((a) << 7)
  149. #define PM_VSACONTROL_MIRRORY(a) ((a) << 8)
  150. #define PM_VSACONTROL_DISCARD(a) ((a) << 9)
  151. #define PM_VSACONTROL_COMBINE(a) ((a) << 11)
  152. #define PM_VSACONTROL_LOCKTOB(a) ((a) << 12)
  153. // Video Stream B Control
  154. #define PM_VSBCONTROL_VIDEO(a) ((a) << 0)
  155. #define PM_VSBCONTROL_VBI(a) ((a) << 1)
  156. #define PM_VSBCONTROL_BUFFER(a) ((a) << 2)
  157. #define PM_VSBCONTROL_COMBINE(a) ((a) << 3)
  158. #define PM_VSBCONTROL_FORMAT(a) ((a) << 4)
  159. #define PM_VSBCONTROL_PIXELSIZE(a) ((a) << 9)
  160. #define PM_VSBCONTROL_RGB(a) ((a) << 11)
  161. #define PM_VSBCONTROL_GAMMA(a) ((a) << 12)
  162. #define PM_VSBCONTROL_LOCKTOA(a) ((a) << 13)
  163. // *******************************************************************
  164. // Permedia3 Bit Field Macros
  165. // Dither unit
  166. #define P3RX_DITHERMODE_ENABLE(a) ((a) << 0)
  167. #define P3RX_DITHERMODE_DITHERENABLE(a) ((a) << 1)
  168. #define P3RX_DITHERMODE_COLORFORMAT(a) ((a) << 2)
  169. #define P3RX_DITHERMODE_XOFFSET(a) ((a) << 6)
  170. #define P3RX_DITHERMODE_YOFFSET(a) ((a) << 8)
  171. #define P3RX_DITHERMODE_COLORORDER(a) ((a) << 10)
  172. #define P3RX_DITHERMODE_ALPHADITHER(a) ((a) << 14)
  173. #define P3RX_DITHERMODE_ROUNDINGMODE(a) ((a) << 15)
  174. // Render2D
  175. #define P3RX_RENDER2D_WIDTH(a) ((a) << 0)
  176. #define P3RX_RENDER2D_OPERATION(a) ((a) << 12)
  177. #define P3RX_RENDER2D_FBREADSOURCEENABLE(a) ((a) << 14)
  178. #define P3RX_RENDER2D_SPANOPERATION(a) ((a) << 15)
  179. #define P3RX_RENDER2D_HEIGHT(a) ((a) << 16)
  180. #define P3RX_RENDER2D_INCREASINGX(a) ((a) << 28)
  181. #define P3RX_RENDER2D_INCREASINGY(a) ((a) << 29)
  182. #define P3RX_RENDER2D_AREASTIPPLEENABLE(a) ((a) << 30)
  183. #define P3RX_RENDER2D_TEXTUREENABLE(a) ((a) << 31)
  184. // RectanglePosition
  185. #define P3RX_RECTANGLEPOSITION_X(a) ((a) << 0)
  186. #define P3RX_RECTANGLEPOSITION_Y(a) ((a) << 16)
  187. // Alpha blend unit.
  188. #define P3RX_ALPHABLENDCOLORMODE_ENABLE(a) ((a) << 0)
  189. #define P3RX_ALPHABLENDCOLORMODE_SRCBLEND(a) ((a) << 1)
  190. #define P3RX_ALPHABLENDCOLORMODE_DSTBLEND(a) ((a) << 5)
  191. #define P3RX_ALPHABLENDCOLORMODE_SRCTIMES2(a) ((a) << 8)
  192. #define P3RX_ALPHABLENDCOLORMODE_DSTTIMES2(a) ((a) << 9)
  193. #define P3RX_ALPHABLENDCOLORMODE_INVSRC(a) ((a) << 10)
  194. #define P3RX_ALPHABLENDCOLORMODE_INVDST(a) ((a) << 11)
  195. #define P3RX_ALPHABLENDCOLORMODE_COLORFORMAT(a) ((a) << 12)
  196. #define P3RX_ALPHABLENDCOLORMODE_COLORORDER(a) ((a) << 16)
  197. #define P3RX_ALPHABLENDCOLORMODE_COLORCONVERSION(a) ((a) << 17)
  198. #define P3RX_ALPHABLENDCOLORMODE_CONSTANTSRC(a) ((a) << 18)
  199. #define P3RX_ALPHABLENDCOLORMODE_CONSTANTDST(a) ((a) << 19)
  200. #define P3RX_ALPHABLENDCOLORMODE_OPERATION(a) ((a) << 20)
  201. #define P3RX_ALPHABLENDCOLORMODE_SWAPSD(a) ((a) << 24)
  202. #define P3RX_ALPHABLENDALPHAMODE_ENABLE(a) ((a) << 0)
  203. #define P3RX_ALPHABLENDALPHAMODE_SRCBLEND(a) ((a) << 1)
  204. #define P3RX_ALPHABLENDALPHAMODE_DSTBLEND(a) ((a) << 5)
  205. #define P3RX_ALPHABLENDALPHAMODE_SRCTIMES2(a) ((a) << 8)
  206. #define P3RX_ALPHABLENDALPHAMODE_DSTTIMES2(a) ((a) << 9)
  207. #define P3RX_ALPHABLENDALPHAMODE_INVSRC(a) ((a) << 10)
  208. #define P3RX_ALPHABLENDALPHAMODE_INVDST(a) ((a) << 11)
  209. #define P3RX_ALPHABLENDALPHAMODE_NOALPHABUFFER(a) ((a) << 12)
  210. #define P3RX_ALPHABLENDALPHAMODE_ALPHATYPE(a) ((a) << 13)
  211. #define P3RX_ALPHABLENDALPHAMODE_ALPHACONVERSION(a) ((a) << 14)
  212. #define P3RX_ALPHABLENDALPHAMODE_CONSTANTSRC(a) ((a) << 15)
  213. #define P3RX_ALPHABLENDALPHAMODE_CONSTANTDST(a) ((a) << 16)
  214. #define P3RX_ALPHABLENDALPHAMODE_OPERATION(a) ((a) << 17)
  215. #define P3RX_CHROMATESTMODE_ENABLE(a) ((a) << 0)
  216. #define P3RX_CHROMATESTMODE_SOURCE(a) ((a) << 1)
  217. #define P3RX_CHROMATESTMODE_PASSACTION(a) ((a) << 3)
  218. #define P3RX_CHROMATESTMODE_FAILACTION(a) ((a) << 5)
  219. // Framebuffer
  220. // FBDestRead
  221. #define P3RX_FBDESTREAD_READENABLE(a) ((a) << 0)
  222. #define P3RX_FBDESTREAD_LAYOUT0(a) ((a) << 12)
  223. #define P3RX_FBDESTREAD_LAYOUT1(a) ((a) << 14)
  224. #define P3RX_FBDESTREAD_LAYOUT2(a) ((a) << 16)
  225. #define P3RX_FBDESTREAD_LAYOUT3(a) ((a) << 18)
  226. #define P3RX_FBDESTREAD_ENABLE0(a) ((a) << 8)
  227. #define P3RX_FBDESTREAD_ENABLE1(a) ((a) << 9)
  228. #define P3RX_FBDESTREAD_ENABLE2(a) ((a) << 10)
  229. #define P3RX_FBDESTREAD_ENABLE3(a) ((a) << 11)
  230. // FBWrite
  231. #define P3RX_FBWRITEMODE_WRITEENABLE(a) ((a) << 0)
  232. #define P3RX_FBWRITEMODE_RESERVED(a) ((a) << 1)
  233. #define P3RX_FBWRITEMODE_REPLICATE(a) ((a) << 4)
  234. #define P3RX_FBWRITEMODE_OPAQUESPAN(a) ((a) << 5)
  235. #define P3RX_FBWRITEMODE_STRIPEPITCH(a) ((a) << 6)
  236. #define P3RX_FBWRITEMODE_STRIPEHEIGHT(a) ((a) << 9)
  237. #define P3RX_FBWRITEMODE_ENABLE0(a) ((a) << 12)
  238. #define P3RX_FBWRITEMODE_ENABLE1(a) ((a) << 13)
  239. #define P3RX_FBWRITEMODE_ENABLE2(a) ((a) << 14)
  240. #define P3RX_FBWRITEMODE_ENABLE3(a) ((a) << 15)
  241. #define P3RX_FBWRITEMODE_LAYOUT0(a) ((a) << 16)
  242. #define P3RX_FBWRITEMODE_LAYOUT1(a) ((a) << 18)
  243. #define P3RX_FBWRITEMODE_LAYOUT2(a) ((a) << 20)
  244. #define P3RX_FBWRITEMODE_LAYOUT3(a) ((a) << 22)
  245. #define P3RX_FBWRITEMODE_ORIGIN0(a) ((a) << 24)
  246. #define P3RX_FBWRITEMODE_ORIGIN1(a) ((a) << 25)
  247. #define P3RX_FBWRITEMODE_ORIGIN2(a) ((a) << 26)
  248. #define P3RX_FBWRITEMODE_ORIGIN3(a) ((a) << 27)
  249. // FBSourceRead
  250. #define P3RX_FBSOURCEREAD_READENABLE(a) ((a) << 0)
  251. #define P3RX_FBSOURCEREAD_PREFETCHENABLE(a) ((a) << 1)
  252. #define P3RX_FBSOURCEREAD_STRIPEPITCH(a) ((a) << 2)
  253. #define P3RX_FBSOURCEREAD_STRIPEHEIGHT(a) ((a) << 5)
  254. #define P3RX_FBSOURCEREAD_LAYOUT(a) ((a) << 8)
  255. #define P3RX_FBSOURCEREAD_ORIGIN(a) ((a) << 10)
  256. #define P3RX_FBSOURCEREAD_BLOCKING(a) ((a) << 11)
  257. // Render
  258. #define P3RX_RENDER_AREASTIPPLEENABLE(a) ((a) << 0)
  259. #define P3RX_RENDER_LINESTIPPLEENABLE(a) ((a) << 1)
  260. #define P3RX_RENDER_RESETLINESTIPPLE(a) ((a) << 2)
  261. #define P3RX_RENDER_FASTFILLENABLE(a) ((a) << 3)
  262. #define P3RX_RENDER_PRIMITIVETYPE(a) ((a) << 6)
  263. #define P3RX_RENDER_ANTIALIASENABLE(a) ((a) << 8)
  264. #define P3RX_RENDER_ANTIALIASINGQUALITY(a) ((a) << 9)
  265. #define P3RX_RENDER_USEPOINTTABLE(a) ((a) << 10)
  266. #define P3RX_RENDER_SYNCONBITMASK(a) ((a) << 11)
  267. #define P3RX_RENDER_SYNCONHOSTDATA(a) ((a) << 12)
  268. #define P3RX_RENDER_TEXTUREENABLE(a) ((a) << 13)
  269. #define P3RX_RENDER_FOGENABLE(a) ((a) << 14)
  270. #define P3RX_RENDER_COVERAGEENABLE(a) ((a) << 15)
  271. #define P3RX_RENDER_SUBPIXELCORRECTIONENABLE(a) ((a) << 16)
  272. #define P3RX_RENDER_SPANOPERATION(a) ((a) << 18)
  273. #define P3RX_RENDER_DERR(a) ((a) << 20)
  274. #define P3RX_RENDER_FBSOURCEREADENABLE(a) ((a) << 27)
  275. // TextureFilterMode - texture filter unit
  276. #define P3RX_TEXFILTERMODE_ENABLE(a) ((a) << 0)
  277. #define P3RX_TEXFILTERMODE_FORMAT0(a) ((a) << 1)
  278. #define P3RX_TEXFILTERMODE_COLORORDER0(a) ((a) << 5)
  279. #define P3RX_TEXFILTERMODE_ALPHAMAPENABLE0(a) ((a) << 6)
  280. #define P3RX_TEXFILTERMODE_ALPHAMAPSENSE0(a) ((a) << 7)
  281. #define P3RX_TEXFILTERMODE_COMBINECACHES(a) ((a) << 8)
  282. #define P3RX_TEXFILTERMODE_FORMAT1(a) ((a) << 9)
  283. #define P3RX_TEXFILTERMODE_COLORORDER1(a) ((a) << 13)
  284. #define P3RX_TEXFILTERMODE_ALPHAMAPENABLE1(a) ((a) << 14)
  285. #define P3RX_TEXFILTERMODE_ALPHAMAPSENSE1(a) ((a) << 15)
  286. #define P3RX_TEXFILTERMODE_ALPHAMAPFILTERING(a) ((a) << 16)
  287. #define P3RX_TEXFILTERMODE_ALPHAMAPFILTERLIMIT0(a) ((a) << 17)
  288. #define P3RX_TEXFILTERMODE_ALPHAMAPFILTERLIMIT1(a) ((a) << 20)
  289. #define P3RX_TEXFILTERMODE_ALPHAMAPFILTERLIMIT01(a) ((a) << 23)
  290. #define P3RX_TEXFILTERMODE_MULTITEXTURE(a) ((a) << 27)
  291. #define P3RX_TEXFILTERMODE_FORCEALPHATOONE0(a) ((a) << 28)
  292. #define P3RX_TEXFILTERMODE_FORCEALPHATOONE1(a) ((a) << 29)
  293. #define P3RX_TEXFILTERMODE_SHIFT0(a) ((a) << 30)
  294. #define P3RX_TEXFILTERMODE_SHIFT1(a) ((a) << 31)
  295. // Shortcuts - both textures the same (i.e. combined)
  296. #define P3RX_TEXFILTERMODE_FORMATBOTH(a) \
  297. ( P3RX_TEXFILTERMODE_FORMAT0(a) | P3RX_TEXFILTERMODE_FORMAT1(a) )
  298. #define P3RX_TEXFILTERMODE_COLORORDERBOTH(a) \
  299. ( P3RX_TEXFILTERMODE_COLORORDER0(a) | P3RX_TEXFILTERMODE_COLORORDER1(a) )
  300. #define P3RX_TEXFILTERMODE_ALPHAMAPENABLEBOTH(a) \
  301. ( P3RX_TEXFILTERMODE_ALPHAMAPENABLE0(a) | P3RX_TEXFILTERMODE_ALPHAMAPENABLE1(a) )
  302. #define P3RX_TEXFILTERMODE_ALPHAMAPFILTERLIMITBOTH(a) \
  303. ( P3RX_TEXFILTERMODE_ALPHAMAPFILTERLIMIT0(a) | P3RX_TEXFILTERMODE_ALPHAMAPFILTERLIMIT1(a) )
  304. #define P3RX_TEXFILTERMODE_ALPHAMAPSENSEBOTH(a) \
  305. ( P3RX_TEXFILTERMODE_ALPHAMAPSENSE0(a) | P3RX_TEXFILTERMODE_ALPHAMAPSENSE1(a) )
  306. #define P3RX_TEXFILTERMODE_FORCEALPHATOONEBOTH(a) \
  307. ( P3RX_TEXFILTERMODE_FORCEALPHATOONE0(a)| P3RX_TEXFILTERMODE_FORCEALPHATOONE1(a) )
  308. #define P3RX_TEXFILTERMODE_SHIFTBOTH(a) \
  309. ( P3RX_TEXFILTERMODE_SHIFT0(a) | P3RX_TEXFILTERMODE_SHIFT1(a) )
  310. // Texture Coordinate Unit.
  311. #define P3RX_TEXCOORDMODE_ENABLE(a) ((a) << 0)
  312. #define P3RX_TEXCOORDMODE_WRAPS(a) ((a) << 1)
  313. #define P3RX_TEXCOORDMODE_WRAPT(a) ((a) << 3)
  314. #define P3RX_TEXCOORDMODE_OPERATION(a) ((a) << 5)
  315. #define P3RX_TEXCOORDMODE_INHIBITDDAINIT(a) ((a) << 6)
  316. #define P3RX_TEXCOORDMODE_ENABLELOD(a) ((a) << 7)
  317. #define P3RX_TEXCOORDMODE_ENABLEDY(a) ((a) << 8)
  318. #define P3RX_TEXCOORDMODE_WIDTH(a) ((a) << 9)
  319. #define P3RX_TEXCOORDMODE_HEIGHT(a) ((a) << 13)
  320. #define P3RX_TEXCOORDMODE_TEXTUREMAPTYPE(a) ((a) << 17)
  321. #define P3RX_TEXCOORDMODE_WRAPS1(a) ((a) << 18)
  322. #define P3RX_TEXCOORDMODE_WRAPT1(a) ((a) << 20)
  323. #define P3RX_TEXCOORDMODE_DUPLICATECOORDS(a) ((a) << 22)
  324. // Alpha test unit.
  325. #define P3RX_ANTIALIASMODE_ENABLE(a) ((a) << 0)
  326. #define P3RX_ANTIALIASMODE_COLORMODE(a) ((a) << 1)
  327. #define P3RX_ANTIALIASMODE_SCALECOLOR(a) ((a) << 2)
  328. #define P3RX_ALPHATESTMODE_ENABLE(a) ((a) << 0)
  329. #define P3RX_ALPHATESTMODE_COMPARE(a) ((a) << 1)
  330. #define P3RX_ALPHATESTMODE_REFERENCE(a) ((a) << 4)
  331. // Texture application unit.
  332. #define P3RX_TEXAPPMODE_ENABLE(a) ((a) << 0)
  333. #define P3RX_TEXAPPMODE_COLORA(a) ((a) << 1)
  334. #define P3RX_TEXAPPMODE_COLORB(a) ((a) << 3)
  335. #define P3RX_TEXAPPMODE_COLORI(a) ((a) << 5)
  336. #define P3RX_TEXAPPMODE_COLORINVI(a) ((a) << 7)
  337. #define P3RX_TEXAPPMODE_COLOROP(a) ((a) << 8)
  338. #define P3RX_TEXAPPMODE_ALPHAA(a) ((a) << 11)
  339. #define P3RX_TEXAPPMODE_ALPHAB(a) ((a) << 13)
  340. #define P3RX_TEXAPPMODE_ALPHAI(a) ((a) << 15)
  341. #define P3RX_TEXAPPMODE_ALPHAINVI(a) ((a) << 17)
  342. #define P3RX_TEXAPPMODE_ALPHAOP(a) ((a) << 18)
  343. #define P3RX_TEXAPPMODE_KDENABLE(a) ((a) << 21)
  344. #define P3RX_TEXAPPMODE_KSENABLE(a) ((a) << 22)
  345. #define P3RX_TEXAPPMODE_MOTIONCOMPENABLE(a) ((a) << 23)
  346. // Short-cuts - passing xxxC to alpha channel equates to xxxA
  347. #define P3RX_TEXAPPMODE_BOTHA(a) \
  348. ( P3RX_TEXAPPMODE_COLORA(a) | P3RX_TEXAPPMODE_ALPHAA(a) )
  349. #define P3RX_TEXAPPMODE_BOTHB(a) \
  350. ( P3RX_TEXAPPMODE_COLORB(a) | P3RX_TEXAPPMODE_ALPHAB(a) )
  351. #define P3RX_TEXAPPMODE_BOTHI(a) \
  352. ( P3RX_TEXAPPMODE_COLORI(a) | P3RX_TEXAPPMODE_ALPHAI(a) )
  353. #define P3RX_TEXAPPMODE_BOTHINVI(a) \
  354. ( P3RX_TEXAPPMODE_COLORINVI(a) | P3RX_TEXAPPMODE_ALPHAINVI(a) )
  355. #define P3RX_TEXAPPMODE_BOTHOP(a) \
  356. ( P3RX_TEXAPPMODE_COLOROP(a) | P3RX_TEXAPPMODE_ALPHAOP(a) )
  357. // Texture composite mode.
  358. #define P3RX_TEXCOMPMODE_ENABLE(a) ((a) << 0)
  359. // These are used for TextureComposite(Colour|Alpha)Mode(0|1)
  360. // Use the P3RX_TEXAPP_* defines.
  361. #define P3RX_TEXCOMPCAMODE01_ENABLE(a) ((a) << 0)
  362. #define P3RX_TEXCOMPCAMODE01_ARG1(a) ((a) << 1)
  363. #define P3RX_TEXCOMPCAMODE01_INVARG1(a) ((a) << 5)
  364. #define P3RX_TEXCOMPCAMODE01_ARG2(a) ((a) << 6)
  365. #define P3RX_TEXCOMPCAMODE01_INVARG2(a) ((a) << 10)
  366. #define P3RX_TEXCOMPCAMODE01_I(a) ((a) << 11)
  367. #define P3RX_TEXCOMPCAMODE01_INVI(a) ((a) << 14)
  368. #define P3RX_TEXCOMPCAMODE01_A(a) ((a) << 15)
  369. #define P3RX_TEXCOMPCAMODE01_B(a) ((a) << 16)
  370. #define P3RX_TEXCOMPCAMODE01_OPERATION(a) ((a) << 17)
  371. #define P3RX_TEXCOMPCAMODE01_SCALE(a) ((a) << 21)
  372. // Texture index mode
  373. #define P3RX_TEXINDEXMODE_ENABLE(a) ((a) << 0)
  374. #define P3RX_TEXINDEXMODE_WIDTH(a) ((a) << 1)
  375. #define P3RX_TEXINDEXMODE_HEIGHT(a) ((a) << 5)
  376. #define P3RX_TEXINDEXMODE_BORDER(a) ((a) << 9)
  377. #define P3RX_TEXINDEXMODE_WRAPU(a) ((a) << 10)
  378. #define P3RX_TEXINDEXMODE_WRAPV(a) ((a) << 12)
  379. #define P3RX_TEXINDEXMODE_MAPTYPE(a) ((a) << 14)
  380. #define P3RX_TEXINDEXMODE_MAGFILTER(a) ((a) << 15)
  381. #define P3RX_TEXINDEXMODE_MINFILTER(a) ((a) << 16)
  382. #define P3RX_TEXINDEXMODE_TEX3DENABLE(a) ((a) << 19)
  383. #define P3RX_TEXINDEXMODE_MIPMAPENABLE(a) ((a) << 20)
  384. #define P3RX_TEXINDEXMODE_NEARESTBIAS(a) ((a) << 21)
  385. #define P3RX_TEXINDEXMODE_LINEARBIAS(a) ((a) << 23)
  386. #define P3RX_TEXINDEXMODE_SOURCETEXELENABLE(a) ((a) << 25)
  387. // Texture read unit.
  388. #define P3RX_TEXREADMODE_ENABLE(a) ((a) << 0)
  389. #define P3RX_TEXREADMODE_WIDTH(a) ((a) << 1)
  390. #define P3RX_TEXREADMODE_HEIGHT(a) ((a) << 5)
  391. #define P3RX_TEXREADMODE_TEXELSIZE(a) ((a) << 9)
  392. #define P3RX_TEXREADMODE_TEXTURE3D(a) ((a) << 11)
  393. #define P3RX_TEXREADMODE_COMBINECACHES(a) ((a) << 12)
  394. #define P3RX_TEXREADMODE_MAPBASELEVEL(a) ((a) << 13)
  395. #define P3RX_TEXREADMODE_MAPMAXLEVEL(a) ((a) << 17)
  396. #define P3RX_TEXREADMODE_LOGICALTEXTURE(a) ((a) << 21)
  397. #define P3RX_TEXREADMODE_ORIGIN(a) ((a) << 22)
  398. #define P3RX_TEXREADMODE_TEXTURETYPE(a) ((a) << 23)
  399. #define P3RX_TEXREADMODE_BYTESWAP(a) ((a) << 25)
  400. #define P3RX_TEXREADMODE_MIRROR(a) ((a) << 28)
  401. #define P3RX_TEXREADMODE_INVERT(a) ((a) << 29)
  402. #define P3RX_TEXREADMODE_OPAQUESPAN(a) ((a) << 30)
  403. #define P3RX_TEXMAPWIDTH_WIDTH(a) ((a) << 0)
  404. #define P3RX_TEXMAPWIDTH_BORDER(a) ((a) << 12)
  405. #define P3RX_TEXMAPWIDTH_LAYOUT(a) ((a) << 13)
  406. #define P3RX_TEXMAPWIDTH_HOSTTEXTURE(a) ((a) << 15)
  407. #define P3RX_TEXCACHEREPLACEMODE_KEEPOLDEST0(a) ((a) << 0)
  408. #define P3RX_TEXCACHEREPLACEMODE_SCRATCHLINES0(a) ((a) << 1)
  409. #define P3RX_TEXCACHEREPLACEMODE_KEEPOLDEST1(a) ((a) << 6)
  410. #define P3RX_TEXCACHEREPLACEMODE_SCRATCHLINES1(a) ((a) << 7)
  411. #define P3RX_TEXCACHEREPLACEMODE_SHOWCACHEINFO(a) ((a) << 12)
  412. #define P3RX_TEXINVALIDATECACHE_BANK0(a) ((a) << 0)
  413. #define P3RX_TEXINVALIDATECACHE_BANK1(a) ((a) << 1)
  414. #define P3RX_TEXINVALIDATECACHE_TLB(a) ((a) << 2)
  415. #define P3RX_INVALIDATECACHE(a, b) \
  416. do \
  417. { \
  418. SEND_P3_DATA(InvalidateCache, P3RX_TEXINVALIDATECACHE_BANK0((a)) | \
  419. P3RX_TEXINVALIDATECACHE_BANK1((a)) | \
  420. P3RX_TEXINVALIDATECACHE_TLB((b))); \
  421. SEND_P3_DATA(FogModeOr, 0); \
  422. SEND_P3_DATA(TextureReadMode0Or, 0); \
  423. } while (0)
  424. // Logical op unit
  425. #define P3RX_LOGICALOPMODE_ENABLE(a) ((a) << 0)
  426. #define P3RX_LOGICALOPMODE_LOGICOP(a) ((a) << 1)
  427. #define P3RX_LOGICALOPMODE_USECONSTANTFBWRITEDATA(a) ((a) << 5)
  428. #define P3RX_LOGICALOPMODE_BACKGROUNDENABLE(a) ((a) << 6)
  429. #define P3RX_LOGICALOPMODE_BACKGROUNDLOGICALOP(a) ((a) << 7)
  430. #define P3RX_LOGICALOPMODE_USECONSTANTSOURCE(a) ((a) << 11)
  431. #define P3RX_LOGICALOPMODE_OPAQUESPAN(a) ((a) << 12)
  432. // LUT
  433. #define P3RX_LUTMODE_ENABLE(a) ((a) << 0)
  434. #define P3RX_LUTMODE_INCOLORORDER(a) ((a) << 1)
  435. #define P3RX_LUTMODE_LOADFORMAT(a) ((a) << 2)
  436. #define P3RX_LUTMODE_LOADCOLORORDER(a) ((a) << 4)
  437. #define P3RX_LUTMODE_FRAGMENTOP(a) ((a) << 5)
  438. #define P3RX_LUTMODE_SPANOP(a) ((a) << 8)
  439. #define P3RX_LUTMODE_MOTIONCOMP8BITS(a) ((a) << 11)
  440. #define P3RX_LUTMODE_XOFFSET(a) ((a) << 12)
  441. #define P3RX_LUTMODE_YOFFSET(a) ((a) << 15)
  442. #define P3RX_LUTMODE_PATTERNBASE(a) ((a) << 18)
  443. #define P3RX_LUTMODE_SPANCCXALIGN(a) ((a) << 26)
  444. #define P3RX_LUTMODE_SPANVCXALIGN(a) ((a) << 27)
  445. // YUV unit.
  446. #define P3RX_YUVMODE_ENABLE(a) ((a) << 0)
  447. // Color DDA Unit
  448. #define P3RX_COLORDDA_ENABLE(a) ((a) << 0)
  449. #define P3RX_COLORDDA_SHADING(a) ((a) << 1)
  450. // Scissor
  451. #define P3RX_SCISSORMODE_USER(a) ((a) << 0)
  452. #define P3RX_SCISSORMODE_SCREEN(a) ((a) << 1)
  453. #define P3RX_SCISSOR_X_Y(a, b) ((b) << 16 | ((a) & 0xFFFF))
  454. #endif // __BITMAC2